Authored by chenchao

fix mini-app no seller

... ... @@ -32,7 +32,9 @@ public interface UserCouponMapper {
List<UserCoupon> selectUsableCouponByUid(@Param("uid") Integer uid, @Param("userType") Integer userType, @Param("now") int now);
int selectCntUsableCouponByUid(@Param("uid") Integer uid, @Param("now") int now,
int selectCntUsableCouponByUid(@Param("uid") Integer uid,
@Param("userType") Integer userType,
@Param("now") int now,
@Param("businessClient") String businessClient);
int updateByPrimaryKeySelective(UserCoupon record);
... ...
... ... @@ -81,16 +81,16 @@
and status = 0
</sql>
<select id="selectCntUsableCouponByUid" resultType="int" parameterType="java.lang.Integer" >
select
count(1)
from user_coupon,coupon
where coupon.id = user_coupon.coupon_id
<select id="selectCntUsableCouponByUid" resultType="int">
select count(*) from user_coupon,coupon where coupon.id = user_coupon.coupon_id
<if test="businessClient!=null">
and (FIND_IN_SET(#{businessClient}, coupon.business_client)
or coupon.business_client is null)
</if>
and user_coupon.uid = #{uid,jdbcType=INTEGER}
<if test="userType != null">
and user_type = #{userType,jdbcType=INTEGER}
</if>
<!-- 在有效时间范围内 -->
and <![CDATA[ user_coupon.end_time > #{now, jdbcType=INTEGER} ]]>
<!-- 未使用-->
... ...
... ... @@ -4,6 +4,7 @@ package com.yohoufo.promotion.controller;
import com.google.common.base.Splitter;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.promotion.constant.CouponTypeEnum;
import com.yohoufo.promotion.model.CouponCntReq;
import com.yohoufo.promotion.model.CouponReceiveChannel;
import com.yohobuy.ufo.model.promotion.request.UserCouponListReq;
import com.yohobuy.ufo.model.promotion.response.CouponInfo;
... ... @@ -119,11 +120,15 @@ public class CouponController {
@RequestMapping(params = "method=ufo.coupons.cnt")
@ResponseBody
public ApiResponse queryCouponCnt(@RequestParam(value = "uid") Integer uid,
@RequestParam(value = "client_type",required = false)String clientType,
@RequestParam(value = "business_client", required = false,defaultValue = "ufo") String businessClient) {
logger.info("query user coupons cnt, uid: {} ,{}", uid, businessClient);
int couponCnt = couponService.queryCouponCnt(uid, businessClient);
logger.info("query user coupons cnt uid: {}, v: {}", uid, couponCnt);
CouponCntReq req = CouponCntReq.builder().uid(uid)
.clientType(clientType)
.businessClient(businessClient)
.build();
logger.info("query user coupons cnt, req: {} ", req);
int couponCnt = couponService.queryCouponCnt(req);
logger.info("query user coupons cnt req: {}, v: {}", req, couponCnt);
return new ApiResponse.ApiResponseBuilder().code(200).data(couponCnt).build();
}
... ...
... ... @@ -8,6 +8,7 @@ import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.annotation.IgnoreSession;
import com.yohoufo.common.annotation.IgnoreSignature;
import com.yohoufo.common.annotation.InnerApi;
import com.yohoufo.promotion.model.CouponCntReq;
import com.yohoufo.promotion.service.ICouponCacheService;
import com.yohoufo.promotion.service.ICouponService;
import com.yohoufo.promotion.service.impl.CouponDisplayService;
... ... @@ -45,9 +46,10 @@ public class ErpGWCouponController {
@IgnoreSession
public ApiResponse queryCouponInnerCnt(@RequestParam(value = "uid") Integer uid,
@RequestParam(value = "business_client", required = false,defaultValue = "ufo") String businessClient) {
logger.info("query inner user coupons cnt, uid: {}", uid);
int couponCnt = couponService.queryCouponCnt(uid, businessClient);
CouponCntReq req = CouponCntReq.builder().uid(uid)
.businessClient(businessClient).build();
logger.info("query inner user coupons cnt, req: {}", req);
int couponCnt = couponService.queryCouponCnt(req);
logger.info("query inner user coupons cnt uid: {}, v: {}", uid, couponCnt);
return new ApiResponse.ApiResponseBuilder().code(200).data(couponCnt).build();
}
... ...
package com.yohoufo.promotion.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CouponCntReq {
private Integer uid;
private String clientType;
private String businessClient;
}
... ...
... ... @@ -7,6 +7,7 @@ import com.yohobuy.ufo.model.promotion.request.UserCouponListReq;
import com.yohobuy.ufo.model.promotion.response.CouponInfo;
import com.yohobuy.ufo.model.promotion.response.CouponInfoListBo;
import com.yohobuy.ufo.model.promotion.response.CouponSendBo;
import com.yohoufo.promotion.model.CouponCntReq;
import com.yohoufo.promotion.model.CouponReceiveChannel;
import java.util.List;
... ... @@ -46,7 +47,7 @@ public interface ICouponService {
CouponInfoListBo queryCouponList(UserCouponListReq req);
int queryCouponCnt(Integer uid, String businessClient);
int queryCouponCnt(CouponCntReq req);
/**
... ...
... ... @@ -13,8 +13,10 @@ import com.yohobuy.ufo.model.promotion.constant.CouponProductLimitTypeEnum;
import com.yohobuy.ufo.model.promotion.constant.CouponUseStatusEnum;
import com.yohobuy.ufo.model.promotion.constant.CouponsStatusEnum;
import com.yohobuy.ufo.model.promotion.ConditionLimitValue;
import com.yohobuy.ufo.model.promotion.constant.UserTypeEnum;
import com.yohoufo.dal.promotion.CouponProductLimitMapper;
import com.yohoufo.promotion.helper.ConditionLimitValueBuilder;
import com.yohoufo.promotion.model.CouponCntReq;
import com.yohoufo.promotion.model.CouponReceiveChannel;
import com.yohobuy.ufo.model.promotion.request.CouponSendType;
import com.yohobuy.ufo.model.promotion.request.UserCouponListReq;
... ... @@ -610,9 +612,22 @@ public class CouponServiceImpl implements ICouponService {
}
@Override
public int queryCouponCnt(Integer uid, String businessClient) {
public int queryCouponCnt(CouponCntReq req) {
Integer uid = req.getUid();
if (Objects.isNull(uid)){
logger.warn("queryCouponCnt uid is null");
return 0;
}
String businessClient = req.getBusinessClient();
Integer userType = null;
String clientType = req.getClientType();
//小程序不展示卖家券 需要屏蔽卖家券
if (StringUtils.isNoneBlank(clientType) && "miniapp".equalsIgnoreCase(clientType)){
userType = UserTypeEnum.BUY.getCode();
}
int cnt = userCouponMapper.selectCntUsableCouponByUid(uid, DateUtil.getCurrentTimeSecond(), businessClient);
int cnt = userCouponMapper.selectCntUsableCouponByUid(uid, userType, DateUtil.getCurrentTimeSecond(), businessClient);
return cnt;
}
... ...