Authored by tanling

查询是否发放完毕

... ... @@ -47,7 +47,7 @@ public class ErpGWCouponController {
logger.info("query inner user coupons cnt uid: {}, v: {}", uid, couponCnt);
return new ApiResponse.ApiResponseBuilder().code(200).data(couponCnt).build();
}
/**
* 给gw使用
... ... @@ -61,21 +61,7 @@ public class ErpGWCouponController {
logger.info("query inner user coupons info, couponTokens: {}", couponTokens);
List<Coupon> couponList = couponCacheService.getCouponsWithCache(couponTokens);
List<CouponSimpleBo> couponSimpleBoList = couponList.stream().map(coupon -> {
CouponSimpleBo couponSimpleBo = new CouponSimpleBo();
couponSimpleBo.setCouponName(coupon.getCouponName());
couponSimpleBo.setCouponAmount(coupon.getCouponAmount());
couponSimpleBo.setUseLimitType(coupon.getUseLimitType().intValue());
couponSimpleBo.setUseLimitValue(String.valueOf(coupon.getUseLimitValue()));
couponSimpleBo.setCouponToken(coupon.getCouponToken());
return couponSimpleBo;
}).collect(Collectors.toList());
List<CouponSimpleBo> couponSimpleBoList = couponService.queryInnerCoupon(couponTokens);
logger.info("query inner user coupons success couponTokens: {}, {}", couponTokens, couponSimpleBoList);
return couponSimpleBoList;
... ...
package com.yohoufo.promotion.service;
import com.yohobuy.ufo.model.promotion.CouponSimpleBo;
import com.yohobuy.ufo.model.promotion.UserCouponsListBo;
import com.yohobuy.ufo.model.promotion.request.UserCouponListReq;
import com.yohobuy.ufo.model.promotion.response.CouponInfo;
... ... @@ -11,6 +12,14 @@ import java.util.List;
public interface ICouponService {
/**
* 查询优惠券信息
* @param couponTokens
* @return
*/
public List<CouponSimpleBo> queryInnerCoupon(List<String> couponTokens);
/**
* 批量发放优惠券
... ...
... ... @@ -8,4 +8,12 @@ public interface SingleCentCouponService {
public void checkAndAddSendCouponNum(int uid, Coupon coupon);
/**
* 获取优惠券即时发送的数量
* @param couponToken
* @return
*/
public Integer getImmediateCouponSendNum(String couponToken);
}
... ...
... ... @@ -5,6 +5,7 @@ import com.google.common.collect.Range;
import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.promotion.CouponSimpleBo;
import com.yohobuy.ufo.model.promotion.UserCouponsBo;
import com.yohobuy.ufo.model.promotion.UserCouponsListBo;
import com.yohobuy.ufo.model.promotion.constant.CouponProductLimitTypeEnum;
... ... @@ -65,6 +66,10 @@ public class CouponServiceImpl implements ICouponService {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
SingleCentCouponService singleCentCouponService;
/**
* 领取优惠券(支持批量)
* @param uid
... ... @@ -583,6 +588,41 @@ public class CouponServiceImpl implements ICouponService {
/**
* 查询优惠券信息
* @param couponTokens
* @return
*/
public List<CouponSimpleBo> queryInnerCoupon(List<String> couponTokens){
List<Coupon> couponList = couponCacheService.getCouponsWithCache(couponTokens);
List<CouponSimpleBo> couponSimpleBoList = couponList.stream().map(coupon -> {
CouponSimpleBo couponSimpleBo = new CouponSimpleBo();
couponSimpleBo.setCouponName(coupon.getCouponName());
couponSimpleBo.setCouponAmount(coupon.getCouponAmount());
couponSimpleBo.setUseLimitType(coupon.getUseLimitType().intValue());
couponSimpleBo.setUseLimitValue(String.valueOf(coupon.getUseLimitValue()));
couponSimpleBo.setCouponToken(coupon.getCouponToken());
Integer sendNum = singleCentCouponService.getImmediateCouponSendNum(coupon.getCouponToken());
if (sendNum == null){
sendNum = coupon.getSendNum();
}
couponSimpleBo.setSendFinished(coupon.getCouponNum()==sendNum?1:0);
return couponSimpleBo;
}).collect(Collectors.toList());
return couponSimpleBoList;
}
@Override
public CouponInfoListBo queryCouponList(UserCouponListReq req) {
CouponInfoListBo.CouponInfoListBoBuilder boBuilder = CouponInfoListBo.builder();
... ...
... ... @@ -53,6 +53,15 @@ public class SingleCentCouponServiceImpl implements SingleCentCouponService {
}
}
/**
* 获取优惠券即时发送的数量
* @param couponToken
* @return
*/
public Integer getImmediateCouponSendNum(String couponToken){
return cacheClient.get(KeyBuilder.buildCouponSendNum(couponToken), Integer.class);
}
public void checkAndAddSendCouponNum(int uid, Coupon coupon){
boolean succ = false;
... ...