Showing
13 changed files
with
51 additions
and
324 deletions
@@ -46,8 +46,8 @@ public class CouponProxyService implements Compensator { | @@ -46,8 +46,8 @@ public class CouponProxyService implements Compensator { | ||
46 | userCouponsBo.setProductLimitType("1"); | 46 | userCouponsBo.setProductLimitType("1"); |
47 | userCouponsBo.setProductIdInclude(Lists.newArrayList(88888900)); | 47 | userCouponsBo.setProductIdInclude(Lists.newArrayList(88888900)); |
48 | userCouponsBo.setUseRule("满299可用"); | 48 | userCouponsBo.setUseRule("满299可用"); |
49 | - userCouponsBo.setStartTime(1514739661L); | ||
50 | - userCouponsBo.setEndTime(1546275661L); | 49 | + userCouponsBo.setStartTime(1514739661); |
50 | + userCouponsBo.setEndTime(1546275661); | ||
51 | 51 | ||
52 | UserCouponsBo userCouponsBo1 = new UserCouponsBo(); | 52 | UserCouponsBo userCouponsBo1 = new UserCouponsBo(); |
53 | userCouponsBo1.setCouponCode("a200"); | 53 | userCouponsBo1.setCouponCode("a200"); |
@@ -56,8 +56,8 @@ public class CouponProxyService implements Compensator { | @@ -56,8 +56,8 @@ public class CouponProxyService implements Compensator { | ||
56 | userCouponsBo1.setUseLimitValue(""); | 56 | userCouponsBo1.setUseLimitValue(""); |
57 | userCouponsBo1.setProductLimitType("1"); | 57 | userCouponsBo1.setProductLimitType("1"); |
58 | userCouponsBo1.setProductIdInclude(Lists.newArrayList(88888900)); | 58 | userCouponsBo1.setProductIdInclude(Lists.newArrayList(88888900)); |
59 | - userCouponsBo1.setStartTime(1514739661L); | ||
60 | - userCouponsBo1.setEndTime(1546275661L); | 59 | + userCouponsBo1.setStartTime(1514739661); |
60 | + userCouponsBo1.setEndTime(1546275661); | ||
61 | return Lists.newArrayList(userCouponsBo, userCouponsBo1); | 61 | return Lists.newArrayList(userCouponsBo, userCouponsBo1); |
62 | } | 62 | } |
63 | 63 | ||
@@ -69,8 +69,8 @@ public class CouponProxyService implements Compensator { | @@ -69,8 +69,8 @@ public class CouponProxyService implements Compensator { | ||
69 | userCouponsBo.setUseLimitValue("299"); | 69 | userCouponsBo.setUseLimitValue("299"); |
70 | userCouponsBo.setProductLimitType("1"); | 70 | userCouponsBo.setProductLimitType("1"); |
71 | userCouponsBo.setProductIdInclude(Lists.newArrayList(88888900)); | 71 | userCouponsBo.setProductIdInclude(Lists.newArrayList(88888900)); |
72 | - userCouponsBo.setStartTime(1514739661L); | ||
73 | - userCouponsBo.setEndTime(1546275661L); | 72 | + userCouponsBo.setStartTime(1514739661); |
73 | + userCouponsBo.setEndTime(1546275661); | ||
74 | return Lists.newArrayList(userCouponsBo); | 74 | return Lists.newArrayList(userCouponsBo); |
75 | } | 75 | } |
76 | 76 |
1 | -package com.yohoufo.promotion.common; | ||
2 | - | ||
3 | -public enum CouponUseStatusEnum { | ||
4 | - | ||
5 | - NOT_USED(0, "未使用"), | ||
6 | - | ||
7 | - USED(1, "已使用"), | ||
8 | - | ||
9 | - /** | ||
10 | - * 已作废 | ||
11 | - * | ||
12 | - * @使用场景 1、生日礼包最多使用一张其它会作废 | ||
13 | - * 2、新客礼包最多使用一张它会作废 | ||
14 | - */ | ||
15 | - INVALID(2, "已作废"); | ||
16 | - | ||
17 | - /** | ||
18 | - * 编码 | ||
19 | - */ | ||
20 | - private int code; | ||
21 | - | ||
22 | - /** | ||
23 | - * 描述 | ||
24 | - */ | ||
25 | - private String desc; | ||
26 | - | ||
27 | - CouponUseStatusEnum(int code, String desc) { | ||
28 | - this.code = code; | ||
29 | - this.desc = desc; | ||
30 | - } | ||
31 | - | ||
32 | - public int getCode() { | ||
33 | - return code; | ||
34 | - } | ||
35 | - | ||
36 | - public String getDesc() { | ||
37 | - return desc; | ||
38 | - } | ||
39 | - | ||
40 | -} |
1 | -package com.yohoufo.promotion.common; | ||
2 | - | ||
3 | -public enum CouponsStatusEnum { | ||
4 | - | ||
5 | - //ERP中老的状态为: 0:未启用 1:启用 3:作废 | ||
6 | - | ||
7 | - /** | ||
8 | - 待审核:通过、驳回、查看详情 | ||
9 | - 通过:查看详情、作废 | ||
10 | - 驳回:修改 | ||
11 | - 作废:查看详情 | ||
12 | - */ | ||
13 | - | ||
14 | - /** | ||
15 | - * 新建之后是待审核 | ||
16 | - */ | ||
17 | - NEED_REVIEW(0, "待审核"), | ||
18 | - | ||
19 | - /** | ||
20 | - * 审核通过之后是有效的(对应原来的启用状态) | ||
21 | - */ | ||
22 | - VALID(1, "有效"), | ||
23 | - | ||
24 | - /** | ||
25 | - * 审核通过之后可作废 | ||
26 | - */ | ||
27 | - INVALID(3, "作废"), | ||
28 | - | ||
29 | - /** | ||
30 | - * 审批未通过的是驳回状态,驳回状态可编辑,编辑之后变成待审核 | ||
31 | - */ | ||
32 | - REJECT(2, "审核驳回"); | ||
33 | - | ||
34 | - /** | ||
35 | - * 编码 | ||
36 | - */ | ||
37 | - private int code; | ||
38 | - | ||
39 | - /** | ||
40 | - * 描述 | ||
41 | - */ | ||
42 | - private String desc; | ||
43 | - | ||
44 | - /** | ||
45 | - * 操作列表 | ||
46 | - * | ||
47 | - * @param code | ||
48 | - * @param desc | ||
49 | - * @return | ||
50 | - */ | ||
51 | - | ||
52 | - CouponsStatusEnum(int code, String desc) { | ||
53 | - this.code = code; | ||
54 | - this.desc = desc; | ||
55 | - | ||
56 | - } | ||
57 | - | ||
58 | - public int getCode() { | ||
59 | - return code; | ||
60 | - } | ||
61 | - | ||
62 | - public String getDesc() { | ||
63 | - return desc; | ||
64 | - } | ||
65 | - | ||
66 | - | ||
67 | -} |
1 | -package com.yohoufo.promotion.common; | ||
2 | - | ||
3 | -public enum ProductLimitType { | ||
4 | - | ||
5 | - PRODUCT(1, "特定商品", "限特定商品"); | ||
6 | - | ||
7 | - int code ; | ||
8 | - | ||
9 | - String desc; | ||
10 | - | ||
11 | - /** | ||
12 | - * 显示给前端的文案 | ||
13 | - */ | ||
14 | - String text; | ||
15 | - | ||
16 | - ProductLimitType(int code, String desc, String text) { | ||
17 | - this.code = code; | ||
18 | - this.desc = desc; | ||
19 | - this.text = text; | ||
20 | - } | ||
21 | - | ||
22 | - public int getCode() { | ||
23 | - return code; | ||
24 | - } | ||
25 | - | ||
26 | - public String getText() { | ||
27 | - return text; | ||
28 | - } | ||
29 | -} |
1 | -package com.yohoufo.promotion.common; | ||
2 | - | ||
3 | -public enum UseLimitType { | ||
4 | - | ||
5 | - NO_LIMIT(0, "无限制", ""), | ||
6 | - AMOUNT_LIMIT(1, "金额", "满{0}可用"); | ||
7 | - | ||
8 | - int code ; | ||
9 | - | ||
10 | - String desc; | ||
11 | - | ||
12 | - /** | ||
13 | - * 给前端的显示文案 | ||
14 | - */ | ||
15 | - String text; | ||
16 | - | ||
17 | - UseLimitType(int code, String desc, String text) { | ||
18 | - this.code = code; | ||
19 | - this.desc = desc; | ||
20 | - this.text = text; | ||
21 | - } | ||
22 | - | ||
23 | - public String getText() { | ||
24 | - return text; | ||
25 | - } | ||
26 | - | ||
27 | - public int getCode() { | ||
28 | - return code; | ||
29 | - } | ||
30 | -} |
1 | -package com.yohoufo.promotion.common; | ||
2 | - | ||
3 | -public enum UserCouponsStatusEnum { | ||
4 | - | ||
5 | - NO_USE(0, "未使用"), | ||
6 | - | ||
7 | - USED(1, "已使用"); | ||
8 | - | ||
9 | - | ||
10 | - /** | ||
11 | - * 编码 | ||
12 | - */ | ||
13 | - private int code; | ||
14 | - | ||
15 | - /** | ||
16 | - * 描述 | ||
17 | - */ | ||
18 | - private String desc; | ||
19 | - | ||
20 | - /** | ||
21 | - * 操作列表 | ||
22 | - * | ||
23 | - * @param code | ||
24 | - * @param desc | ||
25 | - * @return | ||
26 | - */ | ||
27 | - | ||
28 | - UserCouponsStatusEnum(int code, String desc) { | ||
29 | - this.code = code; | ||
30 | - this.desc = desc; | ||
31 | - | ||
32 | - } | ||
33 | - | ||
34 | - public int getCode() { | ||
35 | - return code; | ||
36 | - } | ||
37 | - | ||
38 | - public String getDesc() { | ||
39 | - return desc; | ||
40 | - } | ||
41 | - | ||
42 | - | ||
43 | -} |
1 | package com.yohoufo.promotion.controller; | 1 | package com.yohoufo.promotion.controller; |
2 | 2 | ||
3 | +import com.yohobuy.ufo.model.promotion.response.CouponInfo; | ||
3 | import com.yohoufo.common.ApiResponse; | 4 | import com.yohoufo.common.ApiResponse; |
4 | -import com.yohoufo.promotion.model.response.CouponInfo; | ||
5 | import com.yohoufo.promotion.service.ICouponService; | 5 | import com.yohoufo.promotion.service.ICouponService; |
6 | import org.slf4j.Logger; | 6 | import org.slf4j.Logger; |
7 | import org.slf4j.LoggerFactory; | 7 | import org.slf4j.LoggerFactory; |
1 | package com.yohoufo.promotion.controller; | 1 | package com.yohoufo.promotion.controller; |
2 | 2 | ||
3 | 3 | ||
4 | +import com.yohobuy.ufo.model.promotion.UserCouponsListBo; | ||
4 | import com.yohoufo.common.ApiResponse; | 5 | import com.yohoufo.common.ApiResponse; |
5 | -import com.yohoufo.promotion.model.response.CouponBo; | ||
6 | -import com.yohoufo.promotion.model.response.CouponInfo; | ||
7 | import com.yohoufo.promotion.service.ICouponService; | 6 | import com.yohoufo.promotion.service.ICouponService; |
8 | import org.slf4j.Logger; | 7 | import org.slf4j.Logger; |
9 | import org.slf4j.LoggerFactory; | 8 | import org.slf4j.LoggerFactory; |
@@ -78,8 +77,8 @@ public class OrderCouponController { | @@ -78,8 +77,8 @@ public class OrderCouponController { | ||
78 | public ApiResponse queryUserNoUsedCoupons(@RequestParam(value = "uid") Integer uid) { | 77 | public ApiResponse queryUserNoUsedCoupons(@RequestParam(value = "uid") Integer uid) { |
79 | 78 | ||
80 | logger.info("use coupons, uid: {}", uid); | 79 | logger.info("use coupons, uid: {}", uid); |
81 | - List<CouponBo> couponBoList = couponService.queryUserNoUsedCoupons(uid); | ||
82 | - logger.info("use coupons, uid: {}, size:{}, success", uid, couponBoList.size()); | 80 | + UserCouponsListBo couponBoList = couponService.queryUserNoUsedCoupons(uid); |
81 | + logger.info("use coupons, uid: {}, success", uid); | ||
83 | return new ApiResponse.ApiResponseBuilder().code(200).data(couponBoList).build(); | 82 | return new ApiResponse.ApiResponseBuilder().code(200).data(couponBoList).build(); |
84 | } | 83 | } |
85 | 84 |
1 | package com.yohoufo.promotion.convert; | 1 | package com.yohoufo.promotion.convert; |
2 | 2 | ||
3 | +import com.yohobuy.ufo.model.promotion.UserCouponsBo; | ||
4 | +import com.yohobuy.ufo.model.promotion.constant.CouponProductLimitTypeEnum; | ||
5 | +import com.yohobuy.ufo.model.promotion.constant.CouponUseLimitTypeEnum; | ||
6 | +import com.yohobuy.ufo.model.promotion.constant.UserCouponsStatusEnum; | ||
7 | +import com.yohobuy.ufo.model.promotion.response.CouponInfo; | ||
3 | import com.yohoufo.common.utils.DateUtil; | 8 | import com.yohoufo.common.utils.DateUtil; |
4 | import com.yohoufo.dal.promotion.model.*; | 9 | import com.yohoufo.dal.promotion.model.*; |
5 | -import com.yohoufo.promotion.common.ProductLimitType; | ||
6 | -import com.yohoufo.promotion.common.UseLimitType; | ||
7 | -import com.yohoufo.promotion.common.UserCouponsStatusEnum; | ||
8 | -import com.yohoufo.promotion.model.response.CouponInfo; | ||
9 | -import com.yohoufo.promotion.model.response.CouponBo; | ||
10 | - | ||
11 | import java.text.MessageFormat; | 10 | import java.text.MessageFormat; |
12 | import java.util.Arrays; | 11 | import java.util.Arrays; |
13 | 12 | ||
14 | public class CouponConvert { | 13 | public class CouponConvert { |
15 | 14 | ||
16 | 15 | ||
17 | - public static CouponBo covertCouponBo(UserCoupon userCoupon, Coupon coupon){ | 16 | + public static UserCouponsBo covertCouponBo(UserCoupon userCoupon, Coupon coupon){ |
18 | 17 | ||
19 | - CouponBo couponBo = new CouponBo(); | 18 | + UserCouponsBo couponBo = new UserCouponsBo(); |
20 | 19 | ||
21 | - couponBo.setUid(userCoupon.getUid()); | ||
22 | - couponBo.setCouponId(userCoupon.getCouponId()); | ||
23 | couponBo.setCouponCode(userCoupon.getCouponCode()); | 20 | couponBo.setCouponCode(userCoupon.getCouponCode()); |
24 | - couponBo.setCouponToken(userCoupon.getCouponToken()); | ||
25 | - couponBo.setCouponType(userCoupon.getCouponType()); | ||
26 | 21 | ||
27 | couponBo.setCouponAmount(coupon.getCouponAmount()); | 22 | couponBo.setCouponAmount(coupon.getCouponAmount()); |
28 | couponBo.setCouponName(coupon.getCouponName()); | 23 | couponBo.setCouponName(coupon.getCouponName()); |
29 | - couponBo.setProductLimitType(coupon.getProductLimitType()); | ||
30 | - couponBo.setProductLimitValue(coupon.getProductLimitValue()); | ||
31 | - couponBo.setUseLimitType(coupon.getUseLimitType()); | ||
32 | - couponBo.setUseLimitValue(coupon.getUseLimitValue()); | 24 | + couponBo.setProductLimitType(coupon.getProductLimitType()!=null ? String.valueOf(coupon.getProductLimitType()):""); |
25 | + couponBo.setUseLimitType(coupon.getUseLimitType()!=null ? String.valueOf(coupon.getUseLimitType()) : ""); | ||
26 | + couponBo.setUseLimitValue(coupon.getUseLimitValue()!=null ? String.valueOf(coupon.getUseLimitValue()) : ""); | ||
27 | + | ||
28 | + couponBo.setStartTime(userCoupon.getStartTime()); | ||
29 | + couponBo.setEndTime(userCoupon.getEndTime()); | ||
30 | + couponBo.setStatus(userCoupon.getStatus()); | ||
31 | + | ||
32 | + // use_limit_type use_limit_value 满多少元可用 | ||
33 | + if (coupon.getUseLimitType()!=null){ | ||
34 | + couponBo.setUseRule(MessageFormat.format(CouponUseLimitTypeEnum.of(String.valueOf(coupon.getUseLimitType())).get().getText(),coupon.getUseLimitValue().intValue())); | ||
35 | + } | ||
33 | 36 | ||
34 | return couponBo; | 37 | return couponBo; |
35 | } | 38 | } |
@@ -62,13 +65,13 @@ public class CouponConvert { | @@ -62,13 +65,13 @@ public class CouponConvert { | ||
62 | couponInfo.setCoupon_value(coupon.getCouponAmount()); | 65 | couponInfo.setCoupon_value(coupon.getCouponAmount()); |
63 | 66 | ||
64 | // use_limit_type use_limit_value 满多少元可用 | 67 | // use_limit_type use_limit_value 满多少元可用 |
65 | - if (coupon.getUseLimitType()!=null && coupon.getUseLimitType().intValue() == UseLimitType.AMOUNT_LIMIT.getCode()){ | ||
66 | - couponInfo.setUse_rule(MessageFormat.format(UseLimitType.AMOUNT_LIMIT.getText(),coupon.getUseLimitValue().intValue())); | 68 | + if (coupon.getUseLimitType()!=null){ |
69 | + couponInfo.setUse_rule(MessageFormat.format(CouponUseLimitTypeEnum.of(String.valueOf(coupon.getUseLimitType())).get().getText(),coupon.getUseLimitValue().intValue())); | ||
67 | } | 70 | } |
68 | 71 | ||
69 | // product_limit_type product_limit_value 特定商品 | 72 | // product_limit_type product_limit_value 特定商品 |
70 | - if (coupon.getProductLimitType()!=null && coupon.getProductLimitType().intValue() == ProductLimitType.PRODUCT.getCode()){ | ||
71 | - couponInfo.setNotes(Arrays.asList(ProductLimitType.PRODUCT.getText())); | 73 | + if (coupon.getProductLimitType()!=null){ |
74 | + couponInfo.setNotes(Arrays.asList(CouponProductLimitTypeEnum.of(String.valueOf(coupon.getProductLimitType())).get().getText())); | ||
72 | } | 75 | } |
73 | } | 76 | } |
74 | 77 | ||
@@ -97,7 +100,6 @@ public class CouponConvert { | @@ -97,7 +100,6 @@ public class CouponConvert { | ||
97 | userCoupon.setCouponCode(couponCode); | 100 | userCoupon.setCouponCode(couponCode); |
98 | int now = DateUtil.getCurrentTimeSecond(); | 101 | int now = DateUtil.getCurrentTimeSecond(); |
99 | userCoupon.setStartTime(now); | 102 | userCoupon.setStartTime(now); |
100 | - // TODO | ||
101 | userCoupon.setEndTime(couponAndType.getCoupon().getEndTime()); | 103 | userCoupon.setEndTime(couponAndType.getCoupon().getEndTime()); |
102 | userCoupon.setCreateTime(now); | 104 | userCoupon.setCreateTime(now); |
103 | userCoupon.setOrderCode(0l); | 105 | userCoupon.setOrderCode(0l); |
1 | -package com.yohoufo.promotion.model.response; | ||
2 | - | ||
3 | - | ||
4 | -import lombok.Data; | ||
5 | - | ||
6 | -import java.math.BigDecimal; | ||
7 | -import java.util.List; | ||
8 | - | ||
9 | -@Data | ||
10 | -public class CouponBo { | ||
11 | - | ||
12 | - | ||
13 | - private Integer uid; | ||
14 | - | ||
15 | - private Integer couponId; | ||
16 | - | ||
17 | - private String couponCode; | ||
18 | - | ||
19 | - private String couponToken; | ||
20 | - | ||
21 | - private String couponName; | ||
22 | - | ||
23 | - private BigDecimal couponAmount; | ||
24 | - | ||
25 | - private Integer couponType; | ||
26 | - | ||
27 | - private Byte useLimitType; | ||
28 | - | ||
29 | - private Short useLimitValue; | ||
30 | - | ||
31 | - private Byte productLimitType; | ||
32 | - | ||
33 | - private String productLimitValue; | ||
34 | - | ||
35 | - private List<Integer> matchProducts; | ||
36 | - | ||
37 | - | ||
38 | -} |
1 | -package com.yohoufo.promotion.model.response; | ||
2 | - | ||
3 | -import java.math.BigDecimal; | ||
4 | -import java.util.List; | ||
5 | - | ||
6 | -import lombok.Data; | ||
7 | - | ||
8 | -@Data | ||
9 | -public class CouponInfo { | ||
10 | - | ||
11 | - private String coupon_token; | ||
12 | - | ||
13 | - private String coupon_name; | ||
14 | - | ||
15 | - private String coupon_code; | ||
16 | - | ||
17 | - private BigDecimal coupon_value; | ||
18 | - | ||
19 | - private String use_rule; | ||
20 | - | ||
21 | - private String coupon_validity; | ||
22 | - | ||
23 | - private Integer coupon_type; //大类 | ||
24 | - | ||
25 | - private String coupon_type_name; | ||
26 | - | ||
27 | - List<String> notes; | ||
28 | - | ||
29 | -} |
1 | package com.yohoufo.promotion.service; | 1 | package com.yohoufo.promotion.service; |
2 | 2 | ||
3 | -import com.yohoufo.promotion.model.response.CouponBo; | ||
4 | -import com.yohoufo.promotion.model.response.CouponInfo; | 3 | + |
4 | +import com.yohobuy.ufo.model.promotion.UserCouponsListBo; | ||
5 | +import com.yohobuy.ufo.model.promotion.response.CouponInfo; | ||
5 | 6 | ||
6 | import java.util.List; | 7 | import java.util.List; |
7 | 8 | ||
@@ -44,7 +45,7 @@ public interface ICouponService { | @@ -44,7 +45,7 @@ public interface ICouponService { | ||
44 | * @param uid | 45 | * @param uid |
45 | * @return | 46 | * @return |
46 | */ | 47 | */ |
47 | - public List<CouponBo> queryUserNoUsedCoupons(Integer uid); | 48 | + public UserCouponsListBo queryUserNoUsedCoupons(Integer uid); |
48 | 49 | ||
49 | 50 | ||
50 | } | 51 | } |
@@ -3,17 +3,17 @@ package com.yohoufo.promotion.service.impl; | @@ -3,17 +3,17 @@ package com.yohoufo.promotion.service.impl; | ||
3 | import com.google.common.collect.Lists; | 3 | import com.google.common.collect.Lists; |
4 | import com.yoho.error.ServiceError; | 4 | import com.yoho.error.ServiceError; |
5 | import com.yoho.error.exception.ServiceException; | 5 | import com.yoho.error.exception.ServiceException; |
6 | +import com.yohobuy.ufo.model.promotion.UserCouponsBo; | ||
7 | +import com.yohobuy.ufo.model.promotion.UserCouponsListBo; | ||
8 | +import com.yohobuy.ufo.model.promotion.constant.CouponProductLimitTypeEnum; | ||
9 | +import com.yohobuy.ufo.model.promotion.constant.CouponUseStatusEnum; | ||
10 | +import com.yohobuy.ufo.model.promotion.constant.CouponsStatusEnum; | ||
11 | +import com.yohobuy.ufo.model.promotion.response.CouponInfo; | ||
6 | import com.yohoufo.common.utils.DateUtil; | 12 | import com.yohoufo.common.utils.DateUtil; |
7 | import com.yohoufo.dal.promotion.CouponMapper; | 13 | import com.yohoufo.dal.promotion.CouponMapper; |
8 | -import com.yohoufo.dal.promotion.CouponProductLimitMapper; | ||
9 | import com.yohoufo.dal.promotion.UserCouponMapper; | 14 | import com.yohoufo.dal.promotion.UserCouponMapper; |
10 | import com.yohoufo.dal.promotion.model.*; | 15 | import com.yohoufo.dal.promotion.model.*; |
11 | -import com.yohoufo.promotion.common.CouponUseStatusEnum; | ||
12 | -import com.yohoufo.promotion.common.CouponsStatusEnum; | ||
13 | -import com.yohoufo.promotion.common.ProductLimitType; | ||
14 | import com.yohoufo.promotion.convert.CouponConvert; | 16 | import com.yohoufo.promotion.convert.CouponConvert; |
15 | -import com.yohoufo.promotion.model.response.CouponInfo; | ||
16 | -import com.yohoufo.promotion.model.response.CouponBo; | ||
17 | import com.yohoufo.promotion.service.*; | 17 | import com.yohoufo.promotion.service.*; |
18 | import org.apache.commons.collections.CollectionUtils; | 18 | import org.apache.commons.collections.CollectionUtils; |
19 | import org.slf4j.Logger; | 19 | import org.slf4j.Logger; |
@@ -206,7 +206,7 @@ public class CouponServiceImpl implements ICouponService { | @@ -206,7 +206,7 @@ public class CouponServiceImpl implements ICouponService { | ||
206 | * @param uid | 206 | * @param uid |
207 | * @return | 207 | * @return |
208 | */ | 208 | */ |
209 | - public List<CouponBo> queryUserNoUsedCoupons(Integer uid){ | 209 | + public UserCouponsListBo queryUserNoUsedCoupons(Integer uid){ |
210 | 210 | ||
211 | if (uid == null || uid <=0){ | 211 | if (uid == null || uid <=0){ |
212 | logger.warn("query coupon list param invalidate"); | 212 | logger.warn("query coupon list param invalidate"); |
@@ -217,7 +217,7 @@ public class CouponServiceImpl implements ICouponService { | @@ -217,7 +217,7 @@ public class CouponServiceImpl implements ICouponService { | ||
217 | List<UserCoupon> list = userCouponMapper.selectUsableCouponByUid(uid, DateUtil.getCurrentTimeSecond()); | 217 | List<UserCoupon> list = userCouponMapper.selectUsableCouponByUid(uid, DateUtil.getCurrentTimeSecond()); |
218 | 218 | ||
219 | if (CollectionUtils.isEmpty(list)){ | 219 | if (CollectionUtils.isEmpty(list)){ |
220 | - return Lists.newArrayList(); | 220 | + return UserCouponsListBo.builder().build(); |
221 | } | 221 | } |
222 | 222 | ||
223 | // 批量获取coupon | 223 | // 批量获取coupon |
@@ -228,24 +228,25 @@ public class CouponServiceImpl implements ICouponService { | @@ -228,24 +228,25 @@ public class CouponServiceImpl implements ICouponService { | ||
228 | // 优惠券商品限制 key=couponId, value=ProductId集合 | 228 | // 优惠券商品限制 key=couponId, value=ProductId集合 |
229 | Map<Integer, List<Integer>> couponProductIdMap = getProductIdListMap(couponList); | 229 | Map<Integer, List<Integer>> couponProductIdMap = getProductIdListMap(couponList); |
230 | 230 | ||
231 | - List<CouponBo> couponBoList = list.stream().map(userCoupon -> { | 231 | + List<UserCouponsBo> couponBoList = list.stream().map(userCoupon -> { |
232 | 232 | ||
233 | Coupon coupon = couponMap.get(userCoupon.getCouponId()); | 233 | Coupon coupon = couponMap.get(userCoupon.getCouponId()); |
234 | List<Integer> productIds = couponProductIdMap.get(userCoupon.getCouponId()); | 234 | List<Integer> productIds = couponProductIdMap.get(userCoupon.getCouponId()); |
235 | 235 | ||
236 | - CouponBo couponBo = CouponConvert.covertCouponBo(userCoupon, coupon); | ||
237 | - couponBo.setMatchProducts(productIds); | 236 | + UserCouponsBo couponBo = CouponConvert.covertCouponBo(userCoupon, coupon); |
237 | + couponBo.setProductIdInclude(productIds); | ||
238 | 238 | ||
239 | return couponBo; | 239 | return couponBo; |
240 | }).collect(Collectors.toList()); | 240 | }).collect(Collectors.toList()); |
241 | 241 | ||
242 | - return couponBoList; | 242 | + |
243 | + return UserCouponsListBo.builder().coupons(couponBoList).build(); | ||
243 | } | 244 | } |
244 | 245 | ||
245 | private Map<Integer, List<Integer>> getProductIdListMap(List<Coupon> couponList) { | 246 | private Map<Integer, List<Integer>> getProductIdListMap(List<Coupon> couponList) { |
246 | // 批量获取 coupon_product_limt 过滤出商品限制的优惠券id | 247 | // 批量获取 coupon_product_limt 过滤出商品限制的优惠券id |
247 | List<Integer> productLimitCouponIds = couponList.stream().filter(coupon -> { | 248 | List<Integer> productLimitCouponIds = couponList.stream().filter(coupon -> { |
248 | - if (coupon.getProductLimitType()!=null && ProductLimitType.PRODUCT.getCode() == coupon.getProductLimitType().intValue()){ | 249 | + if (coupon.getProductLimitType()!=null && CouponProductLimitTypeEnum.SPECIFIC_PRODUCT.getLimitType().equals(String.valueOf(coupon.getProductLimitType()))){ |
249 | return true; | 250 | return true; |
250 | }else{ | 251 | }else{ |
251 | return false; | 252 | return false; |
-
Please register or login to post a comment