Search in sources :

Example 1 with StoreCoupon

use of com.ikoori.vip.common.persistence.model.StoreCoupon in project vip by guangdada.

the class CouponController method couponUpdate.

/**
 * 跳转到修改优惠券
 */
@Permission
@RequestMapping("/coupon_update/{couponId}")
public String couponUpdate(@PathVariable Long couponId, Model model) {
    Long userId = Long.valueOf(ShiroKit.getUser().getId());
    Merchant merchant = merchantService.getMerchantUserId(userId);
    Map<String, Object> condition = new HashMap<String, Object>();
    condition.put("merchantId", merchant.getId());
    // 查询可用店铺
    List<StoreCoupon> storeCoupons = storeCouponService.getByCouponId(couponId);
    model.addAttribute("storeCoupons", storeCoupons);
    // 查询店铺
    List<Store> stores = storeService.selectByCondition(condition);
    model.addAttribute("stores", stores);
    // 查询会员卡
    List<Card> cards = cardService.selectByCondition(condition);
    model.addAttribute("cards", cards);
    Coupon coupon = couponService.selectById(couponId);
    model.addAttribute(coupon);
    return PREFIX + "coupon_edit.html";
}
Also used : StoreCoupon(com.ikoori.vip.common.persistence.model.StoreCoupon) Coupon(com.ikoori.vip.common.persistence.model.Coupon) HashMap(java.util.HashMap) Store(com.ikoori.vip.common.persistence.model.Store) Card(com.ikoori.vip.common.persistence.model.Card) Merchant(com.ikoori.vip.common.persistence.model.Merchant) StoreCoupon(com.ikoori.vip.common.persistence.model.StoreCoupon) Permission(com.ikoori.vip.common.annotion.Permission) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with StoreCoupon

use of com.ikoori.vip.common.persistence.model.StoreCoupon in project vip by guangdada.

the class StoreCouponServiceImpl method saveStoreCoupon.

/**
 * 保存优惠券可用店铺
 * @Title: saveStoreCoupon
 * @param couponId
 * @param storeIds
 * @date:   2017年9月23日 下午2:29:56
 * @author: chengxg
 */
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void saveStoreCoupon(Long couponId, String storeIds) {
    // 先删除优惠券可用店铺
    if (couponId != null) {
        storeCouponDao.deleteByCouponId(couponId);
    }
    // 保存优惠券可用店铺
    if (StringUtils.isNotBlank(storeIds)) {
        String[] ids = storeIds.split(",");
        for (int i = 0; i < ids.length; i++) {
            StoreCoupon storeCoupon = new StoreCoupon();
            storeCoupon.setCouponId(couponId);
            storeCoupon.setStoreId(Long.valueOf(ids[i]));
            storeCouponMapper.insert(storeCoupon);
        }
    }
}
Also used : StoreCoupon(com.ikoori.vip.common.persistence.model.StoreCoupon) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

StoreCoupon (com.ikoori.vip.common.persistence.model.StoreCoupon)2 Permission (com.ikoori.vip.common.annotion.Permission)1 Card (com.ikoori.vip.common.persistence.model.Card)1 Coupon (com.ikoori.vip.common.persistence.model.Coupon)1 Merchant (com.ikoori.vip.common.persistence.model.Merchant)1 Store (com.ikoori.vip.common.persistence.model.Store)1 HashMap (java.util.HashMap)1 Transactional (org.springframework.transaction.annotation.Transactional)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1