...
|
...
|
@@ -268,16 +268,16 @@ public class CouponServiceImpl implements ICouponService,IBusinessExportService{ |
|
|
LOGGER.info("sendCouponByImport item size too large, size is {}", items.size());
|
|
|
return new ApiResponse(201, "导入uid数量超过50!", null);
|
|
|
}
|
|
|
Set<Integer> uidSet = new HashSet<>();
|
|
|
List<Integer> uidList = new ArrayList<>();
|
|
|
for(int i = 0 ; i < items.size() ; i ++){
|
|
|
UidImportTranItem item = items.get(i);
|
|
|
Integer uid = item.getUid();
|
|
|
if(uid == null || uid < 1){
|
|
|
return new ApiResponse(201, "excel第"+ ( i + 1 ) + "行数据不合法", null);
|
|
|
}
|
|
|
uidSet.add(uid);
|
|
|
uidList.add(uid);
|
|
|
}
|
|
|
return sendCouponByMQ(couponToken, uidSet);
|
|
|
return sendCouponByMQ(couponToken, uidList);
|
|
|
}
|
|
|
|
|
|
private ApiResponse sendCouponByMQ(String couponToken, List<Integer> uidList){
|
...
|
...
|
@@ -293,11 +293,11 @@ public class CouponServiceImpl implements ICouponService,IBusinessExportService{ |
|
|
}
|
|
|
int availableNum = coupon.getCouponNum() - coupon.getSendNum();
|
|
|
if(uidList.size() > availableNum){
|
|
|
LOGGER.info("sendCoupon failed with couponNum isn't enough, uidSize is {}, availableCouponNum is {}", uidSet.size(), availableNum);
|
|
|
LOGGER.info("sendCoupon failed with couponNum isn't enough, uidSize is {}, availableCouponNum is {}", uidList.size(), availableNum);
|
|
|
return new ApiResponse(201, "uid数量大于当前券可用数量:"+ availableNum + "!" , null);
|
|
|
}
|
|
|
// 发券
|
|
|
Set<Integer> failUidSet = new HashSet<>();
|
|
|
List<Integer> failUidList = new ArrayList<>();
|
|
|
for(Integer uid : uidList){
|
|
|
try {
|
|
|
JSONObject sendCouponParam = new JSONObject();
|
...
|
...
|
@@ -307,11 +307,11 @@ public class CouponServiceImpl implements ICouponService,IBusinessExportService{ |
|
|
yhProducer.send("ufo.couponSendWithTradeMqNotify", sendCouponParam, null);
|
|
|
Thread.sleep(5);
|
|
|
}catch (Exception e){
|
|
|
failUidSet.add(uid);
|
|
|
failUidList.add(uid);
|
|
|
LOGGER.warn("sendCoupon by mq fail with uid is {}, token is {}, e is {}", uid, couponToken,e);
|
|
|
}
|
|
|
}
|
|
|
LOGGER.info("sendCoupon end with success num is {}", uidSet.size() - failUidSet.size());
|
|
|
LOGGER.info("sendCoupon end with success num is {}", uidList.size() - failUidList.size());
|
|
|
return new ApiResponse();
|
|
|
}
|
|
|
|
...
|
...
|
|