Showing
5 changed files
with
58 additions
and
9 deletions
@@ -12,7 +12,9 @@ import java.util.List; | @@ -12,7 +12,9 @@ import java.util.List; | ||
12 | public interface ProductLimitUserHelpMapper { | 12 | public interface ProductLimitUserHelpMapper { |
13 | List<LimitProductHelpUserRespBO> selectHelpInfo(@Param("userId") Integer userId, @Param("limitProductCode") String limitProductCode); | 13 | List<LimitProductHelpUserRespBO> selectHelpInfo(@Param("userId") Integer userId, @Param("limitProductCode") String limitProductCode); |
14 | 14 | ||
15 | - void addhelpUserInfo(LimitProductHelpUser limitProductHelpUser); | 15 | + void addHelpUserInfo(LimitProductHelpUser limitProductHelpUser); |
16 | 16 | ||
17 | List<LimitProductHelpUserRespBO> selectHelpInfoByUidAndCode(@Param("list") List<Integer> uidList, @Param("limitProductCode") String limitProductCode); | 17 | List<LimitProductHelpUserRespBO> selectHelpInfoByUidAndCode(@Param("list") List<Integer> uidList, @Param("limitProductCode") String limitProductCode); |
18 | + | ||
19 | + Integer selectExistHelpInfo(@Param("helpUserId") String helpUserId, @Param("limitProductCode") String limitProductCode); | ||
18 | } | 20 | } |
@@ -22,7 +22,7 @@ | @@ -22,7 +22,7 @@ | ||
22 | and limit_product_code = #{limitProductCode,jdbcType=VARCHAR} | 22 | and limit_product_code = #{limitProductCode,jdbcType=VARCHAR} |
23 | </select> | 23 | </select> |
24 | 24 | ||
25 | - <insert id="addhelpUserInfo" parameterType="com.yoho.activity.dal.model.LimitProductHelpUser"> | 25 | + <insert id="addHelpUserInfo" parameterType="com.yoho.activity.dal.model.LimitProductHelpUser"> |
26 | insert into limit_product_help_user (user_id, help_user_id,help_user_name,help_user_img_url,limit_product_code,create_time) | 26 | insert into limit_product_help_user (user_id, help_user_id,help_user_name,help_user_img_url,limit_product_code,create_time) |
27 | values (#{userId,jdbcType=INTEGER}, #{helpUserId,jdbcType=VARCHAR}, #{helpUserName,jdbcType=VARCHAR}, | 27 | values (#{userId,jdbcType=INTEGER}, #{helpUserId,jdbcType=VARCHAR}, #{helpUserName,jdbcType=VARCHAR}, |
28 | #{helpUserImgUrl,jdbcType=VARCHAR}, #{limitProductCode,jdbcType=VARCHAR}, #{createTime,jdbcType=INTEGER} | 28 | #{helpUserImgUrl,jdbcType=VARCHAR}, #{limitProductCode,jdbcType=VARCHAR}, #{createTime,jdbcType=INTEGER} |
@@ -39,4 +39,9 @@ | @@ -39,4 +39,9 @@ | ||
39 | </foreach> | 39 | </foreach> |
40 | and limit_product_code = #{limitProductCode,jdbcType=VARCHAR} | 40 | and limit_product_code = #{limitProductCode,jdbcType=VARCHAR} |
41 | </select> | 41 | </select> |
42 | + | ||
43 | + <select id="selectExistHelpInfo" resultType="java.lang.Integer"> | ||
44 | + select count(1) FROM limit_product_help_user | ||
45 | + where help_user_id = #{helpUserId,jdbcType=INTEGER} AND limit_product_code = #{limitProductCode,jdbcType=VARCHAR} | ||
46 | + </select> | ||
42 | </mapper> | 47 | </mapper> |
@@ -29,6 +29,7 @@ public class ProductLimitUserHelpRest { | @@ -29,6 +29,7 @@ public class ProductLimitUserHelpRest { | ||
29 | public ApiResponse queryHelpInfo(LimitProductHelpUserRequestBO limitProductHelpUserRequestBO) { | 29 | public ApiResponse queryHelpInfo(LimitProductHelpUserRequestBO limitProductHelpUserRequestBO) { |
30 | logger.info("ProductLimitUserHelpRest queryHelpInfo params is{}", limitProductHelpUserRequestBO); | 30 | logger.info("ProductLimitUserHelpRest queryHelpInfo params is{}", limitProductHelpUserRequestBO); |
31 | if (null == limitProductHelpUserRequestBO){ | 31 | if (null == limitProductHelpUserRequestBO){ |
32 | + logger.info("ProductLimitUserHelpRest queryHelpInfo params is{}", limitProductHelpUserRequestBO); | ||
32 | return new ApiResponse.ApiResponseBuilder().code(400).message("入参不可为空").build(); | 33 | return new ApiResponse.ApiResponseBuilder().code(400).message("入参不可为空").build(); |
33 | } | 34 | } |
34 | List<LimitProductHelpUserRespBO> limitProductHelpUserList = iProductLimitUserHelpService.queryHelpInfo(limitProductHelpUserRequestBO); | 35 | List<LimitProductHelpUserRespBO> limitProductHelpUserList = iProductLimitUserHelpService.queryHelpInfo(limitProductHelpUserRequestBO); |
@@ -38,12 +39,20 @@ public class ProductLimitUserHelpRest { | @@ -38,12 +39,20 @@ public class ProductLimitUserHelpRest { | ||
38 | 39 | ||
39 | @RequestMapping(params = "method=app.limitProduct.addHelpUserInfo") | 40 | @RequestMapping(params = "method=app.limitProduct.addHelpUserInfo") |
40 | @ResponseBody | 41 | @ResponseBody |
41 | - public ApiResponse addhelpUserInfo(LimitProductHelpUserRequestBO limitProductHelpUserRequestBO) { | ||
42 | - logger.info("ProductLimitUserHelpRest addhelpUserInfo params is{}", limitProductHelpUserRequestBO); | 42 | + public ApiResponse addHelpUserInfo(LimitProductHelpUserRequestBO limitProductHelpUserRequestBO) { |
43 | + logger.info("ProductLimitUserHelpRest addHelpUserInfo params is{}", limitProductHelpUserRequestBO); | ||
43 | if (null == limitProductHelpUserRequestBO){ | 44 | if (null == limitProductHelpUserRequestBO){ |
45 | + logger.info("ProductLimitUserHelpRest addHelpUserInfo result can not null"); | ||
44 | return new ApiResponse.ApiResponseBuilder().code(400).message("入参不可为空").build(); | 46 | return new ApiResponse.ApiResponseBuilder().code(400).message("入参不可为空").build(); |
45 | } | 47 | } |
46 | - iProductLimitUserHelpService.addhelpUserInfo(limitProductHelpUserRequestBO); | 48 | + //判断用户是否已经助力 |
49 | + Boolean flag = iProductLimitUserHelpService.judgeHelpUserExist(limitProductHelpUserRequestBO); | ||
50 | + if (flag){ | ||
51 | + logger.info("ProductLimitUserHelpRest addHelpUserInfo can not help repeat"); | ||
52 | + return new ApiResponse.ApiResponseBuilder().code(400).message("用户已经助力过,不可重复助力").build(); | ||
53 | + } | ||
54 | + iProductLimitUserHelpService.addHelpUserInfo(limitProductHelpUserRequestBO); | ||
55 | + logger.info("ProductLimitUserHelpRest addHelpUserInfo success"); | ||
47 | return new ApiResponse.ApiResponseBuilder().code(200).message("用户助力成功").build(); | 56 | return new ApiResponse.ApiResponseBuilder().code(200).message("用户助力成功").build(); |
48 | } | 57 | } |
49 | } | 58 | } |
@@ -11,5 +11,7 @@ import java.util.List; | @@ -11,5 +11,7 @@ import java.util.List; | ||
11 | public interface IProductLimitUserHelpService { | 11 | public interface IProductLimitUserHelpService { |
12 | List<LimitProductHelpUserRespBO> queryHelpInfo(LimitProductHelpUserRequestBO limitProductHelpUserRequestBO); | 12 | List<LimitProductHelpUserRespBO> queryHelpInfo(LimitProductHelpUserRequestBO limitProductHelpUserRequestBO); |
13 | 13 | ||
14 | - void addhelpUserInfo(LimitProductHelpUserRequestBO limitProductHelpUserRequestBO); | 14 | + void addHelpUserInfo(LimitProductHelpUserRequestBO limitProductHelpUserRequestBO); |
15 | + | ||
16 | + Boolean judgeHelpUserExist(LimitProductHelpUserRequestBO limitProductHelpUserRequestBO); | ||
15 | } | 17 | } |
@@ -5,16 +5,20 @@ import com.yoho.activity.common.redis.RedisValueCache; | @@ -5,16 +5,20 @@ import com.yoho.activity.common.redis.RedisValueCache; | ||
5 | import com.yoho.activity.common.utils.DateUtils; | 5 | import com.yoho.activity.common.utils.DateUtils; |
6 | import com.yoho.activity.dal.ProductLimitUserHelpMapper; | 6 | import com.yoho.activity.dal.ProductLimitUserHelpMapper; |
7 | import com.yoho.activity.dal.model.LimitProductHelpUser; | 7 | import com.yoho.activity.dal.model.LimitProductHelpUser; |
8 | +import com.yoho.activity.queue.service.IDrawlineList2MapService; | ||
8 | import com.yoho.activity.queue.service.IProductLimitUserHelpService; | 9 | import com.yoho.activity.queue.service.IProductLimitUserHelpService; |
10 | +import com.yoho.core.rest.client.hystrix.AsyncFuture; | ||
9 | import com.yoho.service.model.activity.drawline.request.LimitProductHelpUserRequestBO; | 11 | import com.yoho.service.model.activity.drawline.request.LimitProductHelpUserRequestBO; |
10 | import com.yoho.service.model.activity.drawline.response.LimitProductHelpUserListBO; | 12 | import com.yoho.service.model.activity.drawline.response.LimitProductHelpUserListBO; |
11 | import com.yoho.service.model.activity.drawline.response.LimitProductHelpUserRespBO; | 13 | import com.yoho.service.model.activity.drawline.response.LimitProductHelpUserRespBO; |
14 | +import com.yoho.service.model.activity.drawline.response.UserBaseRspBO; | ||
12 | import org.apache.commons.collections.CollectionUtils; | 15 | import org.apache.commons.collections.CollectionUtils; |
13 | import org.slf4j.Logger; | 16 | import org.slf4j.Logger; |
14 | import org.slf4j.LoggerFactory; | 17 | import org.slf4j.LoggerFactory; |
15 | import org.springframework.beans.factory.annotation.Autowired; | 18 | import org.springframework.beans.factory.annotation.Autowired; |
16 | import org.springframework.stereotype.Service; | 19 | import org.springframework.stereotype.Service; |
17 | 20 | ||
21 | +import java.util.ArrayList; | ||
18 | import java.util.List; | 22 | import java.util.List; |
19 | import java.util.concurrent.TimeUnit; | 23 | import java.util.concurrent.TimeUnit; |
20 | 24 | ||
@@ -28,7 +32,8 @@ public class ProductLimitUserHelpServiceImpl implements IProductLimitUserHelpSer | @@ -28,7 +32,8 @@ public class ProductLimitUserHelpServiceImpl implements IProductLimitUserHelpSer | ||
28 | private RedisValueCache redisValueCache; | 32 | private RedisValueCache redisValueCache; |
29 | @Autowired | 33 | @Autowired |
30 | private ProductLimitUserHelpMapper productLimitUserHelpMapper; | 34 | private ProductLimitUserHelpMapper productLimitUserHelpMapper; |
31 | - | 35 | + @Autowired |
36 | + private IDrawlineList2MapService drawlineList2MapService; | ||
32 | @Override | 37 | @Override |
33 | public List<LimitProductHelpUserRespBO> queryHelpInfo(LimitProductHelpUserRequestBO limitProductHelpUserRequestBO) { | 38 | public List<LimitProductHelpUserRespBO> queryHelpInfo(LimitProductHelpUserRequestBO limitProductHelpUserRequestBO) { |
34 | //先走缓存,缓存没有再走库里捞 | 39 | //先走缓存,缓存没有再走库里捞 |
@@ -43,20 +48,46 @@ public class ProductLimitUserHelpServiceImpl implements IProductLimitUserHelpSer | @@ -43,20 +48,46 @@ public class ProductLimitUserHelpServiceImpl implements IProductLimitUserHelpSer | ||
43 | logger.info("ProductLimitUserHelpServiceImpl :: queryHelpInfo result is null"); | 48 | logger.info("ProductLimitUserHelpServiceImpl :: queryHelpInfo result is null"); |
44 | return null; | 49 | return null; |
45 | } | 50 | } |
51 | + //获取用户头像 | ||
52 | + getUserInfo(limitProductHelpUserRequestBO.getUserId(), limitProductHelpUserRespBOList); | ||
46 | limitProductHelpUserListBO.setList(limitProductHelpUserRespBOList); | 53 | limitProductHelpUserListBO.setList(limitProductHelpUserRespBOList); |
47 | redisValueCache.set(CacheKeyEnum.LIMIT_USER_HELP_INFO, redisKeySuffix, limitProductHelpUserListBO, 300, TimeUnit.SECONDS); | 54 | redisValueCache.set(CacheKeyEnum.LIMIT_USER_HELP_INFO, redisKeySuffix, limitProductHelpUserListBO, 300, TimeUnit.SECONDS); |
48 | return limitProductHelpUserListBO.getList(); | 55 | return limitProductHelpUserListBO.getList(); |
49 | } | 56 | } |
50 | 57 | ||
58 | + private void getUserInfo(Integer userId, List<LimitProductHelpUserRespBO> limitProductHelpUserRespBOList) { | ||
59 | + List<Integer> uidList = new ArrayList<>(); | ||
60 | + uidList.add(userId); | ||
61 | + AsyncFuture<UserBaseRspBO[]> userBaseRspBOArrAsync = drawlineList2MapService.postForUserBaseInfo(uidList); | ||
62 | + UserBaseRspBO[] userBaseRspBOs = userBaseRspBOArrAsync.get(); | ||
63 | + for (LimitProductHelpUserRespBO limitProductHelpUserRespBO : limitProductHelpUserRespBOList){ | ||
64 | + for (UserBaseRspBO userBaseRspBO : userBaseRspBOs){ | ||
65 | + if (limitProductHelpUserRespBO.getUserId().equals(userBaseRspBO.getUid())){ | ||
66 | + limitProductHelpUserRespBO.setUserImgUrl(userBaseRspBO.getHeadIco()); | ||
67 | + break; | ||
68 | + } | ||
69 | + } | ||
70 | + } | ||
71 | + } | ||
72 | + | ||
51 | @Override | 73 | @Override |
52 | - public void addhelpUserInfo(LimitProductHelpUserRequestBO limitProductHelpUserRequestBO) { | 74 | + public void addHelpUserInfo(LimitProductHelpUserRequestBO limitProductHelpUserRequestBO) { |
53 | LimitProductHelpUser limitProductHelpUser = converToModel(limitProductHelpUserRequestBO); | 75 | LimitProductHelpUser limitProductHelpUser = converToModel(limitProductHelpUserRequestBO); |
54 | - productLimitUserHelpMapper.addhelpUserInfo(limitProductHelpUser); | 76 | + productLimitUserHelpMapper.addHelpUserInfo(limitProductHelpUser); |
55 | //清除缓存 | 77 | //清除缓存 |
56 | String redisKeySuffix = limitProductHelpUserRequestBO.getUserId() + ":" + limitProductHelpUserRequestBO.getLimitProductCode(); | 78 | String redisKeySuffix = limitProductHelpUserRequestBO.getUserId() + ":" + limitProductHelpUserRequestBO.getLimitProductCode(); |
57 | redisValueCache.delete(CacheKeyEnum.LIMIT_USER_HELP_INFO, redisKeySuffix); | 79 | redisValueCache.delete(CacheKeyEnum.LIMIT_USER_HELP_INFO, redisKeySuffix); |
58 | } | 80 | } |
59 | 81 | ||
82 | + @Override | ||
83 | + public Boolean judgeHelpUserExist(LimitProductHelpUserRequestBO limitProductHelpUserRequestBO) { | ||
84 | + Integer count = productLimitUserHelpMapper.selectExistHelpInfo(limitProductHelpUserRequestBO.getHelpUserId(),limitProductHelpUserRequestBO.getLimitProductCode()); | ||
85 | + if (count > 0){ | ||
86 | + return true; | ||
87 | + } | ||
88 | + return false; | ||
89 | + } | ||
90 | + | ||
60 | private LimitProductHelpUser converToModel(LimitProductHelpUserRequestBO limitProductHelpUserRequestBO) { | 91 | private LimitProductHelpUser converToModel(LimitProductHelpUserRequestBO limitProductHelpUserRequestBO) { |
61 | LimitProductHelpUser limitProductHelpUser = new LimitProductHelpUser(); | 92 | LimitProductHelpUser limitProductHelpUser = new LimitProductHelpUser(); |
62 | limitProductHelpUser.setUserId(limitProductHelpUserRequestBO.getUserId()); | 93 | limitProductHelpUser.setUserId(limitProductHelpUserRequestBO.getUserId()); |
-
Please register or login to post a comment