Authored by tanling

查询是否发放完毕

@@ -47,7 +47,7 @@ public class ErpGWCouponController { @@ -47,7 +47,7 @@ public class ErpGWCouponController {
47 logger.info("query inner user coupons cnt uid: {}, v: {}", uid, couponCnt); 47 logger.info("query inner user coupons cnt uid: {}, v: {}", uid, couponCnt);
48 return new ApiResponse.ApiResponseBuilder().code(200).data(couponCnt).build(); 48 return new ApiResponse.ApiResponseBuilder().code(200).data(couponCnt).build();
49 } 49 }
50 - 50 +
51 51
52 /** 52 /**
53 * 给gw使用 53 * 给gw使用
@@ -61,21 +61,7 @@ public class ErpGWCouponController { @@ -61,21 +61,7 @@ public class ErpGWCouponController {
61 61
62 logger.info("query inner user coupons info, couponTokens: {}", couponTokens); 62 logger.info("query inner user coupons info, couponTokens: {}", couponTokens);
63 63
64 - List<Coupon> couponList = couponCacheService.getCouponsWithCache(couponTokens);  
65 -  
66 - List<CouponSimpleBo> couponSimpleBoList = couponList.stream().map(coupon -> {  
67 - CouponSimpleBo couponSimpleBo = new CouponSimpleBo();  
68 - couponSimpleBo.setCouponName(coupon.getCouponName());  
69 - couponSimpleBo.setCouponAmount(coupon.getCouponAmount());  
70 - couponSimpleBo.setUseLimitType(coupon.getUseLimitType().intValue());  
71 - couponSimpleBo.setUseLimitValue(String.valueOf(coupon.getUseLimitValue()));  
72 -  
73 - couponSimpleBo.setCouponToken(coupon.getCouponToken());  
74 -  
75 - return couponSimpleBo;  
76 -  
77 - }).collect(Collectors.toList());  
78 - 64 + List<CouponSimpleBo> couponSimpleBoList = couponService.queryInnerCoupon(couponTokens);
79 65
80 logger.info("query inner user coupons success couponTokens: {}, {}", couponTokens, couponSimpleBoList); 66 logger.info("query inner user coupons success couponTokens: {}, {}", couponTokens, couponSimpleBoList);
81 return couponSimpleBoList; 67 return couponSimpleBoList;
1 package com.yohoufo.promotion.service; 1 package com.yohoufo.promotion.service;
2 2
3 3
  4 +import com.yohobuy.ufo.model.promotion.CouponSimpleBo;
4 import com.yohobuy.ufo.model.promotion.UserCouponsListBo; 5 import com.yohobuy.ufo.model.promotion.UserCouponsListBo;
5 import com.yohobuy.ufo.model.promotion.request.UserCouponListReq; 6 import com.yohobuy.ufo.model.promotion.request.UserCouponListReq;
6 import com.yohobuy.ufo.model.promotion.response.CouponInfo; 7 import com.yohobuy.ufo.model.promotion.response.CouponInfo;
@@ -11,6 +12,14 @@ import java.util.List; @@ -11,6 +12,14 @@ import java.util.List;
11 public interface ICouponService { 12 public interface ICouponService {
12 13
13 14
  15 + /**
  16 + * 查询优惠券信息
  17 + * @param couponTokens
  18 + * @return
  19 + */
  20 + public List<CouponSimpleBo> queryInnerCoupon(List<String> couponTokens);
  21 +
  22 +
14 23
15 /** 24 /**
16 * 批量发放优惠券 25 * 批量发放优惠券
@@ -8,4 +8,12 @@ public interface SingleCentCouponService { @@ -8,4 +8,12 @@ public interface SingleCentCouponService {
8 8
9 9
10 public void checkAndAddSendCouponNum(int uid, Coupon coupon); 10 public void checkAndAddSendCouponNum(int uid, Coupon coupon);
  11 +
  12 +
  13 + /**
  14 + * 获取优惠券即时发送的数量
  15 + * @param couponToken
  16 + * @return
  17 + */
  18 + public Integer getImmediateCouponSendNum(String couponToken);
11 } 19 }
@@ -5,6 +5,7 @@ import com.google.common.collect.Range; @@ -5,6 +5,7 @@ import com.google.common.collect.Range;
5 import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder; 5 import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
6 import com.yoho.error.ServiceError; 6 import com.yoho.error.ServiceError;
7 import com.yoho.error.exception.ServiceException; 7 import com.yoho.error.exception.ServiceException;
  8 +import com.yohobuy.ufo.model.promotion.CouponSimpleBo;
8 import com.yohobuy.ufo.model.promotion.UserCouponsBo; 9 import com.yohobuy.ufo.model.promotion.UserCouponsBo;
9 import com.yohobuy.ufo.model.promotion.UserCouponsListBo; 10 import com.yohobuy.ufo.model.promotion.UserCouponsListBo;
10 import com.yohobuy.ufo.model.promotion.constant.CouponProductLimitTypeEnum; 11 import com.yohobuy.ufo.model.promotion.constant.CouponProductLimitTypeEnum;
@@ -65,6 +66,10 @@ public class CouponServiceImpl implements ICouponService { @@ -65,6 +66,10 @@ public class CouponServiceImpl implements ICouponService {
65 private final Logger logger = LoggerFactory.getLogger(getClass()); 66 private final Logger logger = LoggerFactory.getLogger(getClass());
66 67
67 68
  69 + @Autowired
  70 + SingleCentCouponService singleCentCouponService;
  71 +
  72 +
68 /** 73 /**
69 * 领取优惠券(支持批量) 74 * 领取优惠券(支持批量)
70 * @param uid 75 * @param uid
@@ -583,6 +588,41 @@ public class CouponServiceImpl implements ICouponService { @@ -583,6 +588,41 @@ public class CouponServiceImpl implements ICouponService {
583 588
584 589
585 590
  591 + /**
  592 + * 查询优惠券信息
  593 + * @param couponTokens
  594 + * @return
  595 + */
  596 + public List<CouponSimpleBo> queryInnerCoupon(List<String> couponTokens){
  597 + List<Coupon> couponList = couponCacheService.getCouponsWithCache(couponTokens);
  598 +
  599 + List<CouponSimpleBo> couponSimpleBoList = couponList.stream().map(coupon -> {
  600 + CouponSimpleBo couponSimpleBo = new CouponSimpleBo();
  601 + couponSimpleBo.setCouponName(coupon.getCouponName());
  602 + couponSimpleBo.setCouponAmount(coupon.getCouponAmount());
  603 + couponSimpleBo.setUseLimitType(coupon.getUseLimitType().intValue());
  604 + couponSimpleBo.setUseLimitValue(String.valueOf(coupon.getUseLimitValue()));
  605 +
  606 + couponSimpleBo.setCouponToken(coupon.getCouponToken());
  607 +
  608 + Integer sendNum = singleCentCouponService.getImmediateCouponSendNum(coupon.getCouponToken());
  609 + if (sendNum == null){
  610 + sendNum = coupon.getSendNum();
  611 + }
  612 +
  613 + couponSimpleBo.setSendFinished(coupon.getCouponNum()==sendNum?1:0);
  614 +
  615 + return couponSimpleBo;
  616 +
  617 + }).collect(Collectors.toList());
  618 +
  619 + return couponSimpleBoList;
  620 + }
  621 +
  622 +
  623 +
  624 +
  625 +
586 @Override 626 @Override
587 public CouponInfoListBo queryCouponList(UserCouponListReq req) { 627 public CouponInfoListBo queryCouponList(UserCouponListReq req) {
588 CouponInfoListBo.CouponInfoListBoBuilder boBuilder = CouponInfoListBo.builder(); 628 CouponInfoListBo.CouponInfoListBoBuilder boBuilder = CouponInfoListBo.builder();
@@ -53,6 +53,15 @@ public class SingleCentCouponServiceImpl implements SingleCentCouponService { @@ -53,6 +53,15 @@ public class SingleCentCouponServiceImpl implements SingleCentCouponService {
53 } 53 }
54 } 54 }
55 55
  56 + /**
  57 + * 获取优惠券即时发送的数量
  58 + * @param couponToken
  59 + * @return
  60 + */
  61 + public Integer getImmediateCouponSendNum(String couponToken){
  62 + return cacheClient.get(KeyBuilder.buildCouponSendNum(couponToken), Integer.class);
  63 +
  64 + }
56 65
57 public void checkAndAddSendCouponNum(int uid, Coupon coupon){ 66 public void checkAndAddSendCouponNum(int uid, Coupon coupon){
58 boolean succ = false; 67 boolean succ = false;