fix mini-app no seller
Showing
7 changed files
with
60 additions
and
16 deletions
@@ -32,7 +32,9 @@ public interface UserCouponMapper { | @@ -32,7 +32,9 @@ public interface UserCouponMapper { | ||
32 | 32 | ||
33 | List<UserCoupon> selectUsableCouponByUid(@Param("uid") Integer uid, @Param("userType") Integer userType, @Param("now") int now); | 33 | List<UserCoupon> selectUsableCouponByUid(@Param("uid") Integer uid, @Param("userType") Integer userType, @Param("now") int now); |
34 | 34 | ||
35 | - int selectCntUsableCouponByUid(@Param("uid") Integer uid, @Param("now") int now, | 35 | + int selectCntUsableCouponByUid(@Param("uid") Integer uid, |
36 | + @Param("userType") Integer userType, | ||
37 | + @Param("now") int now, | ||
36 | @Param("businessClient") String businessClient); | 38 | @Param("businessClient") String businessClient); |
37 | 39 | ||
38 | int updateByPrimaryKeySelective(UserCoupon record); | 40 | int updateByPrimaryKeySelective(UserCoupon record); |
@@ -81,16 +81,16 @@ | @@ -81,16 +81,16 @@ | ||
81 | and status = 0 | 81 | and status = 0 |
82 | </sql> | 82 | </sql> |
83 | 83 | ||
84 | - <select id="selectCntUsableCouponByUid" resultType="int" parameterType="java.lang.Integer" > | ||
85 | - select | ||
86 | - count(1) | ||
87 | - from user_coupon,coupon | ||
88 | - where coupon.id = user_coupon.coupon_id | 84 | + <select id="selectCntUsableCouponByUid" resultType="int"> |
85 | + select count(*) from user_coupon,coupon where coupon.id = user_coupon.coupon_id | ||
89 | <if test="businessClient!=null"> | 86 | <if test="businessClient!=null"> |
90 | and (FIND_IN_SET(#{businessClient}, coupon.business_client) | 87 | and (FIND_IN_SET(#{businessClient}, coupon.business_client) |
91 | or coupon.business_client is null) | 88 | or coupon.business_client is null) |
92 | </if> | 89 | </if> |
93 | and user_coupon.uid = #{uid,jdbcType=INTEGER} | 90 | and user_coupon.uid = #{uid,jdbcType=INTEGER} |
91 | + <if test="userType != null"> | ||
92 | + and user_type = #{userType,jdbcType=INTEGER} | ||
93 | + </if> | ||
94 | <!-- 在有效时间范围内 --> | 94 | <!-- 在有效时间范围内 --> |
95 | and <![CDATA[ user_coupon.end_time > #{now, jdbcType=INTEGER} ]]> | 95 | and <![CDATA[ user_coupon.end_time > #{now, jdbcType=INTEGER} ]]> |
96 | <!-- 未使用--> | 96 | <!-- 未使用--> |
@@ -4,6 +4,7 @@ package com.yohoufo.promotion.controller; | @@ -4,6 +4,7 @@ package com.yohoufo.promotion.controller; | ||
4 | import com.google.common.base.Splitter; | 4 | import com.google.common.base.Splitter; |
5 | import com.yoho.error.exception.ServiceException; | 5 | import com.yoho.error.exception.ServiceException; |
6 | import com.yohobuy.ufo.model.promotion.constant.CouponTypeEnum; | 6 | import com.yohobuy.ufo.model.promotion.constant.CouponTypeEnum; |
7 | +import com.yohoufo.promotion.model.CouponCntReq; | ||
7 | import com.yohoufo.promotion.model.CouponReceiveChannel; | 8 | import com.yohoufo.promotion.model.CouponReceiveChannel; |
8 | import com.yohobuy.ufo.model.promotion.request.UserCouponListReq; | 9 | import com.yohobuy.ufo.model.promotion.request.UserCouponListReq; |
9 | import com.yohobuy.ufo.model.promotion.response.CouponInfo; | 10 | import com.yohobuy.ufo.model.promotion.response.CouponInfo; |
@@ -119,11 +120,15 @@ public class CouponController { | @@ -119,11 +120,15 @@ public class CouponController { | ||
119 | @RequestMapping(params = "method=ufo.coupons.cnt") | 120 | @RequestMapping(params = "method=ufo.coupons.cnt") |
120 | @ResponseBody | 121 | @ResponseBody |
121 | public ApiResponse queryCouponCnt(@RequestParam(value = "uid") Integer uid, | 122 | public ApiResponse queryCouponCnt(@RequestParam(value = "uid") Integer uid, |
123 | + @RequestParam(value = "client_type",required = false)String clientType, | ||
122 | @RequestParam(value = "business_client", required = false,defaultValue = "ufo") String businessClient) { | 124 | @RequestParam(value = "business_client", required = false,defaultValue = "ufo") String businessClient) { |
123 | - | ||
124 | - logger.info("query user coupons cnt, uid: {} ,{}", uid, businessClient); | ||
125 | - int couponCnt = couponService.queryCouponCnt(uid, businessClient); | ||
126 | - logger.info("query user coupons cnt uid: {}, v: {}", uid, couponCnt); | 125 | + CouponCntReq req = CouponCntReq.builder().uid(uid) |
126 | + .clientType(clientType) | ||
127 | + .businessClient(businessClient) | ||
128 | + .build(); | ||
129 | + logger.info("query user coupons cnt, req: {} ", req); | ||
130 | + int couponCnt = couponService.queryCouponCnt(req); | ||
131 | + logger.info("query user coupons cnt req: {}, v: {}", req, couponCnt); | ||
127 | return new ApiResponse.ApiResponseBuilder().code(200).data(couponCnt).build(); | 132 | return new ApiResponse.ApiResponseBuilder().code(200).data(couponCnt).build(); |
128 | } | 133 | } |
129 | 134 |
@@ -8,6 +8,7 @@ import com.yohoufo.common.ApiResponse; | @@ -8,6 +8,7 @@ import com.yohoufo.common.ApiResponse; | ||
8 | import com.yohoufo.common.annotation.IgnoreSession; | 8 | import com.yohoufo.common.annotation.IgnoreSession; |
9 | import com.yohoufo.common.annotation.IgnoreSignature; | 9 | import com.yohoufo.common.annotation.IgnoreSignature; |
10 | import com.yohoufo.common.annotation.InnerApi; | 10 | import com.yohoufo.common.annotation.InnerApi; |
11 | +import com.yohoufo.promotion.model.CouponCntReq; | ||
11 | import com.yohoufo.promotion.service.ICouponCacheService; | 12 | import com.yohoufo.promotion.service.ICouponCacheService; |
12 | import com.yohoufo.promotion.service.ICouponService; | 13 | import com.yohoufo.promotion.service.ICouponService; |
13 | import com.yohoufo.promotion.service.impl.CouponDisplayService; | 14 | import com.yohoufo.promotion.service.impl.CouponDisplayService; |
@@ -45,9 +46,10 @@ public class ErpGWCouponController { | @@ -45,9 +46,10 @@ public class ErpGWCouponController { | ||
45 | @IgnoreSession | 46 | @IgnoreSession |
46 | public ApiResponse queryCouponInnerCnt(@RequestParam(value = "uid") Integer uid, | 47 | public ApiResponse queryCouponInnerCnt(@RequestParam(value = "uid") Integer uid, |
47 | @RequestParam(value = "business_client", required = false,defaultValue = "ufo") String businessClient) { | 48 | @RequestParam(value = "business_client", required = false,defaultValue = "ufo") String businessClient) { |
48 | - | ||
49 | - logger.info("query inner user coupons cnt, uid: {}", uid); | ||
50 | - int couponCnt = couponService.queryCouponCnt(uid, businessClient); | 49 | + CouponCntReq req = CouponCntReq.builder().uid(uid) |
50 | + .businessClient(businessClient).build(); | ||
51 | + logger.info("query inner user coupons cnt, req: {}", req); | ||
52 | + int couponCnt = couponService.queryCouponCnt(req); | ||
51 | logger.info("query inner user coupons cnt uid: {}, v: {}", uid, couponCnt); | 53 | logger.info("query inner user coupons cnt uid: {}, v: {}", uid, couponCnt); |
52 | return new ApiResponse.ApiResponseBuilder().code(200).data(couponCnt).build(); | 54 | return new ApiResponse.ApiResponseBuilder().code(200).data(couponCnt).build(); |
53 | } | 55 | } |
1 | +package com.yohoufo.promotion.model; | ||
2 | + | ||
3 | +import lombok.AllArgsConstructor; | ||
4 | +import lombok.Builder; | ||
5 | +import lombok.Data; | ||
6 | +import lombok.NoArgsConstructor; | ||
7 | + | ||
8 | +@Data | ||
9 | +@Builder | ||
10 | +@AllArgsConstructor | ||
11 | +@NoArgsConstructor | ||
12 | +public class CouponCntReq { | ||
13 | + | ||
14 | + private Integer uid; | ||
15 | + | ||
16 | + private String clientType; | ||
17 | + | ||
18 | + private String businessClient; | ||
19 | +} |
@@ -7,6 +7,7 @@ import com.yohobuy.ufo.model.promotion.request.UserCouponListReq; | @@ -7,6 +7,7 @@ import com.yohobuy.ufo.model.promotion.request.UserCouponListReq; | ||
7 | import com.yohobuy.ufo.model.promotion.response.CouponInfo; | 7 | import com.yohobuy.ufo.model.promotion.response.CouponInfo; |
8 | import com.yohobuy.ufo.model.promotion.response.CouponInfoListBo; | 8 | import com.yohobuy.ufo.model.promotion.response.CouponInfoListBo; |
9 | import com.yohobuy.ufo.model.promotion.response.CouponSendBo; | 9 | import com.yohobuy.ufo.model.promotion.response.CouponSendBo; |
10 | +import com.yohoufo.promotion.model.CouponCntReq; | ||
10 | import com.yohoufo.promotion.model.CouponReceiveChannel; | 11 | import com.yohoufo.promotion.model.CouponReceiveChannel; |
11 | 12 | ||
12 | import java.util.List; | 13 | import java.util.List; |
@@ -46,7 +47,7 @@ public interface ICouponService { | @@ -46,7 +47,7 @@ public interface ICouponService { | ||
46 | CouponInfoListBo queryCouponList(UserCouponListReq req); | 47 | CouponInfoListBo queryCouponList(UserCouponListReq req); |
47 | 48 | ||
48 | 49 | ||
49 | - int queryCouponCnt(Integer uid, String businessClient); | 50 | + int queryCouponCnt(CouponCntReq req); |
50 | 51 | ||
51 | 52 | ||
52 | /** | 53 | /** |
@@ -13,8 +13,10 @@ import com.yohobuy.ufo.model.promotion.constant.CouponProductLimitTypeEnum; | @@ -13,8 +13,10 @@ import com.yohobuy.ufo.model.promotion.constant.CouponProductLimitTypeEnum; | ||
13 | import com.yohobuy.ufo.model.promotion.constant.CouponUseStatusEnum; | 13 | import com.yohobuy.ufo.model.promotion.constant.CouponUseStatusEnum; |
14 | import com.yohobuy.ufo.model.promotion.constant.CouponsStatusEnum; | 14 | import com.yohobuy.ufo.model.promotion.constant.CouponsStatusEnum; |
15 | import com.yohobuy.ufo.model.promotion.ConditionLimitValue; | 15 | import com.yohobuy.ufo.model.promotion.ConditionLimitValue; |
16 | +import com.yohobuy.ufo.model.promotion.constant.UserTypeEnum; | ||
16 | import com.yohoufo.dal.promotion.CouponProductLimitMapper; | 17 | import com.yohoufo.dal.promotion.CouponProductLimitMapper; |
17 | import com.yohoufo.promotion.helper.ConditionLimitValueBuilder; | 18 | import com.yohoufo.promotion.helper.ConditionLimitValueBuilder; |
19 | +import com.yohoufo.promotion.model.CouponCntReq; | ||
18 | import com.yohoufo.promotion.model.CouponReceiveChannel; | 20 | import com.yohoufo.promotion.model.CouponReceiveChannel; |
19 | import com.yohobuy.ufo.model.promotion.request.CouponSendType; | 21 | import com.yohobuy.ufo.model.promotion.request.CouponSendType; |
20 | import com.yohobuy.ufo.model.promotion.request.UserCouponListReq; | 22 | import com.yohobuy.ufo.model.promotion.request.UserCouponListReq; |
@@ -610,9 +612,22 @@ public class CouponServiceImpl implements ICouponService { | @@ -610,9 +612,22 @@ public class CouponServiceImpl implements ICouponService { | ||
610 | } | 612 | } |
611 | 613 | ||
612 | @Override | 614 | @Override |
613 | - public int queryCouponCnt(Integer uid, String businessClient) { | 615 | + public int queryCouponCnt(CouponCntReq req) { |
616 | + Integer uid = req.getUid(); | ||
617 | + if (Objects.isNull(uid)){ | ||
618 | + logger.warn("queryCouponCnt uid is null"); | ||
619 | + return 0; | ||
620 | + } | ||
621 | + String businessClient = req.getBusinessClient(); | ||
622 | + | ||
623 | + Integer userType = null; | ||
624 | + String clientType = req.getClientType(); | ||
625 | + //小程序不展示卖家券 需要屏蔽卖家券 | ||
626 | + if (StringUtils.isNoneBlank(clientType) && "miniapp".equalsIgnoreCase(clientType)){ | ||
627 | + userType = UserTypeEnum.BUY.getCode(); | ||
628 | + } | ||
614 | 629 | ||
615 | - int cnt = userCouponMapper.selectCntUsableCouponByUid(uid, DateUtil.getCurrentTimeSecond(), businessClient); | 630 | + int cnt = userCouponMapper.selectCntUsableCouponByUid(uid, userType, DateUtil.getCurrentTimeSecond(), businessClient); |
616 | return cnt; | 631 | return cnt; |
617 | } | 632 | } |
618 | 633 |
-
Please register or login to post a comment