推广管理-优惠券管理-优惠券-赠送优惠券增加可选数量

This commit is contained in:
1378012178@qq.com 2025-02-07 10:43:17 +08:00
parent b539f77b70
commit bddf97a9a1
3 changed files with 10 additions and 7 deletions

View File

@ -47,10 +47,10 @@ public class CouponController extends AbstractController {
@ApiOperation("管理端赠送用户优惠券")
@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(",");
List<String> userIdList = Arrays.asList(userId);
return couponService.giveCoupon(couponId, userIdList, shopId);
return couponService.giveCoupon(couponId, userIdList, shopId,amount);
}
}
}

View File

@ -18,6 +18,6 @@ public interface CouponService extends IService<Coupon> {
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);
}

View File

@ -60,7 +60,7 @@ public class CouponServiceImpl extends ServiceImpl<CouponDao, Coupon> implements
@Transactional
@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);
//计算优惠券过期时间
Integer endDate = coupon.getEndDate();
@ -70,8 +70,11 @@ public class CouponServiceImpl extends ServiceImpl<CouponDao, Coupon> implements
Date date = calendar.getTime();
String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
String expirationTime = new SimpleDateFormat("yyyy-MM-dd").format(date);
couponUserDao.giveCoupon(userIdList, coupon.getCouponName(), coupon.getCouponPicture(), createTime, expirationTime, coupon.getMinMoney(),
coupon.getMoney(), 0,coupon.getEndDate().toString());
if(amount == null) amount = 3;
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();
}