推广管理-优惠券管理-优惠券-赠送优惠券增加可选数量
This commit is contained in:
parent
b539f77b70
commit
bddf97a9a1
|
@ -47,10 +47,10 @@ public class CouponController extends AbstractController {
|
||||||
|
|
||||||
@ApiOperation("管理端赠送用户优惠券")
|
@ApiOperation("管理端赠送用户优惠券")
|
||||||
@GetMapping(value = "/giveCoupon")
|
@GetMapping(value = "/giveCoupon")
|
||||||
public Result giveCoupon(Long couponId, String userIds, Long shopId){
|
public Result giveCoupon(Long couponId, String userIds, Long shopId,@RequestParam(value = "amount",required = false) Integer amount){
|
||||||
String[] userId = userIds.split(",");
|
String[] userId = userIds.split(",");
|
||||||
List<String> userIdList = Arrays.asList(userId);
|
List<String> userIdList = Arrays.asList(userId);
|
||||||
return couponService.giveCoupon(couponId, userIdList, shopId);
|
return couponService.giveCoupon(couponId, userIdList, shopId,amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -18,6 +18,6 @@ public interface CouponService extends IService<Coupon> {
|
||||||
|
|
||||||
Result selectCouponList(Integer page, Integer limit);
|
Result selectCouponList(Integer page, Integer limit);
|
||||||
|
|
||||||
Result giveCoupon(Long couponId, List<String> userIdList, Long shopId);
|
Result giveCoupon(Long couponId, List<String> userIdList, Long shopId, Integer amount);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class CouponServiceImpl extends ServiceImpl<CouponDao, Coupon> implements
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public Result giveCoupon(Long couponId, List<String> userIdList, Long shopId) {
|
public Result giveCoupon(Long couponId, List<String> userIdList, Long shopId, Integer amount) {
|
||||||
Coupon coupon = couponDao.selectById(couponId);
|
Coupon coupon = couponDao.selectById(couponId);
|
||||||
//计算优惠券过期时间
|
//计算优惠券过期时间
|
||||||
Integer endDate = coupon.getEndDate();
|
Integer endDate = coupon.getEndDate();
|
||||||
|
@ -70,8 +70,11 @@ public class CouponServiceImpl extends ServiceImpl<CouponDao, Coupon> implements
|
||||||
Date date = calendar.getTime();
|
Date date = calendar.getTime();
|
||||||
String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
|
String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
|
||||||
String expirationTime = new SimpleDateFormat("yyyy-MM-dd").format(date);
|
String expirationTime = new SimpleDateFormat("yyyy-MM-dd").format(date);
|
||||||
couponUserDao.giveCoupon(userIdList, coupon.getCouponName(), coupon.getCouponPicture(), createTime, expirationTime, coupon.getMinMoney(),
|
if(amount == null) amount = 3;
|
||||||
coupon.getMoney(), 0,coupon.getEndDate().toString());
|
for (Integer i = 0; i < amount; i++) {
|
||||||
|
couponUserDao.giveCoupon(userIdList, coupon.getCouponName(), coupon.getCouponPicture(), createTime, expirationTime, coupon.getMinMoney(),
|
||||||
|
coupon.getMoney(), 0, coupon.getEndDate().toString());
|
||||||
|
}
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue