...
|
...
|
@@ -247,16 +247,16 @@ public class CouponServiceImpl implements ICouponService,IBusinessExportService{ |
|
|
LOGGER.info("sendCoupon failed with uid size too large, size is {}", uidList.size());
|
|
|
return new ApiResponse(201, "单次至多输入50个uid", null);
|
|
|
}
|
|
|
Set<Integer> uidSet = new HashSet<>();
|
|
|
List<Integer> uidSendList = new ArrayList<>();
|
|
|
for(String uid: uidList){
|
|
|
if(!NumberUtils.isNumber(uid)){
|
|
|
LOGGER.info("sendCoupon failed with uid is not number, uid is {}", uid);
|
|
|
return new ApiResponse(201, "uid必须为数字", null);
|
|
|
}
|
|
|
uidSet.add(Integer.valueOf(uid));
|
|
|
uidSendList.add(Integer.valueOf(uid));
|
|
|
}
|
|
|
//(3) 校验券 并通过mq发券
|
|
|
return sendCouponByMQ(req.getCouponToken(), uidSet);
|
|
|
return sendCouponByMQ(req.getCouponToken(), uidSendList);
|
|
|
}
|
|
|
|
|
|
@Override
|
...
|
...
|
@@ -280,7 +280,7 @@ public class CouponServiceImpl implements ICouponService,IBusinessExportService{ |
|
|
return sendCouponByMQ(couponToken, uidSet);
|
|
|
}
|
|
|
|
|
|
private ApiResponse sendCouponByMQ(String couponToken, Set<Integer> uidSet){
|
|
|
private ApiResponse sendCouponByMQ(String couponToken, List<Integer> uidList){
|
|
|
// ufo券校验 1.是否有效 2.可用数量是否大于所需发送人数
|
|
|
Coupon coupon = couponMapper.selectValidByToken(couponToken);
|
|
|
if(coupon == null){
|
...
|
...
|
@@ -292,13 +292,13 @@ public class CouponServiceImpl implements ICouponService,IBusinessExportService{ |
|
|
return new ApiResponse(201, "该券已过期 !" , null);
|
|
|
}
|
|
|
int availableNum = coupon.getCouponNum() - coupon.getSendNum();
|
|
|
if(uidSet.size() > availableNum){
|
|
|
if(uidList.size() > availableNum){
|
|
|
LOGGER.info("sendCoupon failed with couponNum isn't enough, uidSize is {}, availableCouponNum is {}", uidSet.size(), availableNum);
|
|
|
return new ApiResponse(201, "uid数量大于当前券可用数量:"+ availableNum + "!" , null);
|
|
|
}
|
|
|
// 发券
|
|
|
Set<Integer> failUidSet = new HashSet<>();
|
|
|
for(Integer uid : uidSet){
|
|
|
for(Integer uid : uidList){
|
|
|
try {
|
|
|
JSONObject sendCouponParam = new JSONObject();
|
|
|
sendCouponParam.put("uid", uid);
|
...
|
...
|
|