Authored by wangshusheng

砍价修改

@@ -66,6 +66,24 @@ public class RedisValueCache { @@ -66,6 +66,24 @@ public class RedisValueCache {
66 return null; 66 return null;
67 } 67 }
68 68
  69 + public <T> List<T> getList(CacheKeyEnum cacheEnum, Object obj, Class<T> clazz) {
  70 + List<T> t = null;
  71 + RedisKeyBuilder key = null;
  72 + try {
  73 + key = RedisKeyBuilder.newInstance().appendFixed(cacheEnum.getCacheKey()).appendVar(obj);
  74 + String value = yhValueOperations.get(key);
  75 + if (StringUtils.isBlank(value)) {
  76 + logger.info("cache miss key is:{}", key);
  77 + return null;
  78 + }
  79 + t = JSON.parseArray(value, clazz);
  80 + logger.info("cache hit key is:{}", key);
  81 + return t;
  82 + } catch (Exception e) {
  83 + logger.warn("get from cache failed!!! key is:{}", key, e);
  84 + return null;
  85 + }
  86 + }
69 87
70 /** 88 /**
71 * 设置值 89 * 设置值
@@ -218,6 +236,7 @@ public class RedisValueCache { @@ -218,6 +236,7 @@ public class RedisValueCache {
218 } 236 }
219 return t; 237 return t;
220 } 238 }
  239 +
221 public static void main(String[] args) { 240 public static void main(String[] args) {
222 String str = "12345"; 241 String str = "12345";
223 String jsonStr = JSON.toJSONString(str); 242 String jsonStr = JSON.toJSONString(str);
@@ -11,4 +11,5 @@ public interface CutDownPriceActivityMapper { @@ -11,4 +11,5 @@ public interface CutDownPriceActivityMapper {
11 11
12 List<CutDownPriceActivity> selectCutDownPriceActivityList(@Param("list") List<Integer> activityId); 12 List<CutDownPriceActivity> selectCutDownPriceActivityList(@Param("list") List<Integer> activityId);
13 13
  14 + List<CutDownPriceActivity> selectEffectCutPriceActivity();
14 } 15 }
@@ -13,7 +13,7 @@ public interface CutDownPriceUserHelpMapper { @@ -13,7 +13,7 @@ public interface CutDownPriceUserHelpMapper {
13 13
14 List<CutDownPriceProductHelpUser> selectHelpInfoByUidAndCode(@Param("list") List<Integer> uidList, @Param("activityId") Integer activityId, @Param("productSkn") Integer productSkn); 14 List<CutDownPriceProductHelpUser> selectHelpInfoByUidAndCode(@Param("list") List<Integer> uidList, @Param("activityId") Integer activityId, @Param("productSkn") Integer productSkn);
15 15
16 - Integer selectExistHelpInfo(@Param("userId") Integer userId, @Param("helpUserId") String helpUserId, @Param("activityId") Integer activityId, @Param("productSkn") Integer productSkn); 16 + Integer selectExistHelpInfo(@Param("userId") Integer userId, @Param("helpUserId") Integer helpUserId, @Param("activityId") Integer activityId, @Param("productSkn") Integer productSkn);
17 17
18 List<CutDownPriceProductHelpUser> selectHelpInfoList(@Param("list") List<CutPriceHelpUserRequestBO> requestList); 18 List<CutDownPriceProductHelpUser> selectHelpInfoList(@Param("list") List<CutPriceHelpUserRequestBO> requestList);
19 } 19 }
@@ -5,9 +5,7 @@ import java.math.BigDecimal; @@ -5,9 +5,7 @@ import java.math.BigDecimal;
5 public class CutDownPriceProductHelpUser { 5 public class CutDownPriceProductHelpUser {
6 private Integer id; 6 private Integer id;
7 private Integer userId; 7 private Integer userId;
8 - private String helpUserId;  
9 - private String helpUserName;  
10 - private String helpUserImgUrl; 8 + private Integer helpUserId;
11 private Integer createTime; 9 private Integer createTime;
12 private Integer activityId; 10 private Integer activityId;
13 private Integer productSkn; 11 private Integer productSkn;
@@ -29,30 +27,14 @@ public class CutDownPriceProductHelpUser { @@ -29,30 +27,14 @@ public class CutDownPriceProductHelpUser {
29 this.userId = userId; 27 this.userId = userId;
30 } 28 }
31 29
32 - public String getHelpUserId() { 30 + public Integer getHelpUserId() {
33 return helpUserId; 31 return helpUserId;
34 } 32 }
35 33
36 - public void setHelpUserId(String helpUserId) { 34 + public void setHelpUserId(Integer helpUserId) {
37 this.helpUserId = helpUserId; 35 this.helpUserId = helpUserId;
38 } 36 }
39 37
40 - public String getHelpUserName() {  
41 - return helpUserName;  
42 - }  
43 -  
44 - public void setHelpUserName(String helpUserName) {  
45 - this.helpUserName = helpUserName;  
46 - }  
47 -  
48 - public String getHelpUserImgUrl() {  
49 - return helpUserImgUrl;  
50 - }  
51 -  
52 - public void setHelpUserImgUrl(String helpUserImgUrl) {  
53 - this.helpUserImgUrl = helpUserImgUrl;  
54 - }  
55 -  
56 public Integer getCreateTime() { 38 public Integer getCreateTime() {
57 return createTime; 39 return createTime;
58 } 40 }
@@ -17,6 +17,16 @@ @@ -17,6 +17,16 @@
17 activity_id, activity_name, status, begin_time, end_time, create_time, update_time, jump_url, banner_url 17 activity_id, activity_name, status, begin_time, end_time, create_time, update_time, jump_url, banner_url
18 </sql> 18 </sql>
19 19
  20 + <select id="selectEffectCutPriceActivity" resultMap="BaseResultMap">
  21 + select
  22 + <include refid="Base_Column_List" />
  23 + from cutdown_price_activity
  24 + where 1=1 and status=1
  25 + and begin_time &lt;= UNIX_TIMESTAMP()
  26 + and end_time &gt;= UNIX_TIMESTAMP()
  27 + order by begin_time
  28 + </select>
  29 +
20 <select id="selectCutDownPriceActivity" resultMap="BaseResultMap"> 30 <select id="selectCutDownPriceActivity" resultMap="BaseResultMap">
21 select 31 select
22 <include refid="Base_Column_List" /> 32 <include refid="Base_Column_List" />
@@ -4,16 +4,14 @@ @@ -4,16 +4,14 @@
4 <resultMap id="BaseResultMap" type="com.yoho.activity.dal.model.CutDownPriceProductHelpUser"> 4 <resultMap id="BaseResultMap" type="com.yoho.activity.dal.model.CutDownPriceProductHelpUser">
5 <id column="id" jdbcType="INTEGER" property="id" /> 5 <id column="id" jdbcType="INTEGER" property="id" />
6 <result column="user_id" property="userId" jdbcType="INTEGER" /> 6 <result column="user_id" property="userId" jdbcType="INTEGER" />
7 - <result column="help_user_id" property="helpUserId" jdbcType="VARCHAR" />  
8 - <result column="help_user_name" property="helpUserName" jdbcType="VARCHAR" />  
9 - <result column="help_user_img_url" property="helpUserImgUrl" jdbcType="VARCHAR" /> 7 + <result column="help_user_id" property="helpUserId" jdbcType="INTEGER" />
10 <result column="activity_id" property="activityId" jdbcType="INTEGER" /> 8 <result column="activity_id" property="activityId" jdbcType="INTEGER" />
11 <result column="product_skn" property="productSkn" jdbcType="INTEGER" /> 9 <result column="product_skn" property="productSkn" jdbcType="INTEGER" />
12 <result column="cut_price" property="cutPrice" jdbcType="DECIMAL" /> 10 <result column="cut_price" property="cutPrice" jdbcType="DECIMAL" />
13 <result column="create_time" property="createTime" jdbcType="INTEGER" /> 11 <result column="create_time" property="createTime" jdbcType="INTEGER" />
14 </resultMap> 12 </resultMap>
15 <sql id="Base_Column_List" > 13 <sql id="Base_Column_List" >
16 - id, user_id, help_user_id,help_user_name,help_user_img_url,activity_id,product_skn,cut_price,create_time 14 + id, user_id, help_user_id,activity_id,product_skn,cut_price,create_time
17 </sql> 15 </sql>
18 16
19 <select id="selectHelpInfo" resultMap="BaseResultMap"> 17 <select id="selectHelpInfo" resultMap="BaseResultMap">
@@ -26,9 +24,8 @@ @@ -26,9 +24,8 @@
26 </select> 24 </select>
27 25
28 <insert id="addHelpUserInfo" parameterType="com.yoho.activity.dal.model.CutDownPriceProductHelpUser"> 26 <insert id="addHelpUserInfo" parameterType="com.yoho.activity.dal.model.CutDownPriceProductHelpUser">
29 - insert into cutdown_price_help_user (user_id, help_user_id,help_user_name,help_user_img_url,activity_id,product_skn,cut_price,create_time)  
30 - values (#{userId,jdbcType=INTEGER}, #{helpUserId,jdbcType=VARCHAR}, #{helpUserName,jdbcType=VARCHAR},  
31 - #{helpUserImgUrl,jdbcType=VARCHAR}, #{activityId,jdbcType=INTEGER}, #{productSkn,jdbcType=INTEGER}, 27 + insert into cutdown_price_help_user (user_id, help_user_id,activity_id,product_skn,cut_price,create_time)
  28 + values (#{userId,jdbcType=INTEGER}, #{helpUserId,jdbcType=INTEGER}, #{activityId,jdbcType=INTEGER}, #{productSkn,jdbcType=INTEGER},
32 #{cutPrice,jdbcType=DECIMAL}, #{createTime,jdbcType=INTEGER} 29 #{cutPrice,jdbcType=DECIMAL}, #{createTime,jdbcType=INTEGER}
33 ) 30 )
34 </insert> 31 </insert>
@@ -36,7 +33,7 @@ @@ -36,7 +33,7 @@
36 <select id="selectExistHelpInfo" resultType="java.lang.Integer"> 33 <select id="selectExistHelpInfo" resultType="java.lang.Integer">
37 select count(1) FROM cutdown_price_help_user 34 select count(1) FROM cutdown_price_help_user
38 where user_id = #{userId,jdbcType=INTEGER} 35 where user_id = #{userId,jdbcType=INTEGER}
39 - AND help_user_id = #{helpUserId,jdbcType=VARCHAR} 36 + AND help_user_id = #{helpUserId,jdbcType=INTEGER}
40 AND activity_id = #{activityId,jdbcType=INTEGER} 37 AND activity_id = #{activityId,jdbcType=INTEGER}
41 AND product_skn = #{productSkn,jdbcType=INTEGER} 38 AND product_skn = #{productSkn,jdbcType=INTEGER}
42 </select> 39 </select>
@@ -7,8 +7,10 @@ import com.yoho.core.rest.annotation.ServiceDesc; @@ -7,8 +7,10 @@ import com.yoho.core.rest.annotation.ServiceDesc;
7 import com.yoho.error.ServiceError; 7 import com.yoho.error.ServiceError;
8 import com.yoho.error.exception.ServiceException; 8 import com.yoho.error.exception.ServiceException;
9 import com.yoho.product.model.CollageProductBo; 9 import com.yoho.product.model.CollageProductBo;
  10 +import com.yoho.product.request.BaseRequest;
10 import com.yoho.product.response.PageResponseBo; 11 import com.yoho.product.response.PageResponseBo;
11 import com.yoho.product.response.VoidResponse; 12 import com.yoho.product.response.VoidResponse;
  13 +import com.yoho.service.model.activity.CutDownPriceActivityBo;
12 import com.yoho.service.model.activity.CutDownPriceActivityProductBo; 14 import com.yoho.service.model.activity.CutDownPriceActivityProductBo;
13 import com.yoho.service.model.activity.CutDownPriceProductHelpUserBo; 15 import com.yoho.service.model.activity.CutDownPriceProductHelpUserBo;
14 import com.yoho.service.model.activity.CutDownProductQueryRequest; 16 import com.yoho.service.model.activity.CutDownProductQueryRequest;
@@ -37,7 +39,19 @@ public class CutDownProductPriceRest { @@ -37,7 +39,19 @@ public class CutDownProductPriceRest {
37 private ICutDownPriceService cutDownPriceService; 39 private ICutDownPriceService cutDownPriceService;
38 40
39 /** 41 /**
40 - * 用户发起砍价 42 + * 查询正在生效的砍价活动
  43 + */
  44 + @RequestMapping("/queryEffectCutPriceActivity")
  45 + @ResponseBody
  46 + public CutDownPriceActivityBo queryEffectCutPriceActivity(@RequestBody BaseRequest<Integer> request) {
  47 + logger.info("CutDownProductPriceRest queryEffectCutPriceActivity");
  48 + CutDownPriceActivityBo bo = cutDownPriceService.queryEffectCutPriceActivity();
  49 + logger.info("CutDownProductPriceRest queryEffectCutPriceActivity success");
  50 + return bo;
  51 + }
  52 +
  53 + /**
  54 + * 用户发起砍价,系统自动砍价
41 */ 55 */
42 @RequestMapping("/addCutPriceRecord") 56 @RequestMapping("/addCutPriceRecord")
43 @ResponseBody 57 @ResponseBody
@@ -73,7 +87,7 @@ public class CutDownProductPriceRest { @@ -73,7 +87,7 @@ public class CutDownProductPriceRest {
73 } 87 }
74 88
75 /** 89 /**
76 - * 好友帮忙砍价 90 + * 好友帮忙砍价,并自动发起一个砍价
77 */ 91 */
78 @RequestMapping("/addCutPriceHelpUserInfo") 92 @RequestMapping("/addCutPriceHelpUserInfo")
79 @ResponseBody 93 @ResponseBody
@@ -12,4 +12,6 @@ public interface ICutDownPriceActivityService { @@ -12,4 +12,6 @@ public interface ICutDownPriceActivityService {
12 CutDownPriceActivityBo queryActivityInfo(Integer activityId); 12 CutDownPriceActivityBo queryActivityInfo(Integer activityId);
13 13
14 List<CutDownPriceActivityBo> queryActivityInfos(List<Integer> activityIds); 14 List<CutDownPriceActivityBo> queryActivityInfos(List<Integer> activityIds);
  15 +
  16 + List<CutDownPriceActivityBo> queryEffectCutPriceActivitys();
15 } 17 }
@@ -2,6 +2,7 @@ package com.yoho.activity.queue.service; @@ -2,6 +2,7 @@ package com.yoho.activity.queue.service;
2 2
3 import com.yoho.activity.dal.model.CutDownPriceProductHelpUser; 3 import com.yoho.activity.dal.model.CutDownPriceProductHelpUser;
4 import com.yoho.product.response.PageResponseBo; 4 import com.yoho.product.response.PageResponseBo;
  5 +import com.yoho.service.model.activity.CutDownPriceActivityBo;
5 import com.yoho.service.model.activity.CutDownPriceActivityProductBo; 6 import com.yoho.service.model.activity.CutDownPriceActivityProductBo;
6 import com.yoho.service.model.activity.CutDownPriceProductHelpUserBo; 7 import com.yoho.service.model.activity.CutDownPriceProductHelpUserBo;
7 import com.yoho.service.model.activity.CutDownProductQueryRequest; 8 import com.yoho.service.model.activity.CutDownProductQueryRequest;
@@ -28,4 +29,6 @@ public interface ICutDownPriceService { @@ -28,4 +29,6 @@ public interface ICutDownPriceService {
28 void addCutPriceUseRecord(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO); 29 void addCutPriceUseRecord(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO);
29 30
30 int cancelCutPriceUseRecord(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO); 31 int cancelCutPriceUseRecord(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO);
  32 +
  33 + CutDownPriceActivityBo queryEffectCutPriceActivity();
31 } 34 }
@@ -39,6 +39,24 @@ public class CutDownPriceActivityServiceImpl implements ICutDownPriceActivitySer @@ -39,6 +39,24 @@ public class CutDownPriceActivityServiceImpl implements ICutDownPriceActivitySer
39 private BeanConvert convert; 39 private BeanConvert convert;
40 40
41 @Override 41 @Override
  42 + public List<CutDownPriceActivityBo> queryEffectCutPriceActivitys() {
  43 + String redisKeySuffix = "effective";
  44 + List<CutDownPriceActivityBo> cutDownPriceActivityBoList = redisValueCache.getList(CacheKeyEnum.CUTDOWN_PRICE_ACTIVITYBO_INFO, redisKeySuffix, CutDownPriceActivityBo.class);
  45 + if (null != cutDownPriceActivityBoList){
  46 + logger.info("CutDownPriceActivityServiceImpl :: queryActivityInfo getCache result is{}",cutDownPriceActivityBoList);
  47 + return cutDownPriceActivityBoList;
  48 + }
  49 + List<CutDownPriceActivity> cutDownPriceActivitys = cutDownPriceActivityMapper.selectEffectCutPriceActivity();
  50 + if (CollectionUtils.isEmpty(cutDownPriceActivitys)){
  51 + logger.info("CutDownPriceActivityServiceImpl :: queryActivityInfo result is null");
  52 + return null;
  53 + }
  54 + cutDownPriceActivityBoList = convert.convertFromList(cutDownPriceActivitys, CutDownPriceActivityBo.class);
  55 + redisValueCache.set(CacheKeyEnum.CUTDOWN_PRICE_ACTIVITYBO_INFO, redisKeySuffix, cutDownPriceActivityBoList, 3600, TimeUnit.SECONDS);
  56 + return cutDownPriceActivityBoList;
  57 + }
  58 +
  59 + @Override
42 public CutDownPriceActivityBo queryActivityInfo(Integer activityId) { 60 public CutDownPriceActivityBo queryActivityInfo(Integer activityId) {
43 String redisKeySuffix = activityId + ""; 61 String redisKeySuffix = activityId + "";
44 CutDownPriceActivityBo cutDownPriceActivityBo = redisValueCache.get(CacheKeyEnum.CUTDOWN_PRICE_ACTIVITYBO_INFO, redisKeySuffix, CutDownPriceActivityBo.class); 62 CutDownPriceActivityBo cutDownPriceActivityBo = redisValueCache.get(CacheKeyEnum.CUTDOWN_PRICE_ACTIVITYBO_INFO, redisKeySuffix, CutDownPriceActivityBo.class);
@@ -25,8 +25,11 @@ import com.yoho.product.response.PageResponseBo; @@ -25,8 +25,11 @@ import com.yoho.product.response.PageResponseBo;
25 import com.yoho.service.model.activity.*; 25 import com.yoho.service.model.activity.*;
26 import com.yoho.service.model.activity.drawline.request.CutPriceHelpUserRequestBO; 26 import com.yoho.service.model.activity.drawline.request.CutPriceHelpUserRequestBO;
27 import com.yoho.service.model.activity.drawline.response.UserBaseRspBO; 27 import com.yoho.service.model.activity.drawline.response.UserBaseRspBO;
  28 +import com.yoho.service.model.social.request.UicUserReqBO;
  29 +import com.yoho.service.model.social.response.UserInfoRspBO;
28 import org.apache.commons.collections.CollectionUtils; 30 import org.apache.commons.collections.CollectionUtils;
29 import org.apache.commons.lang3.ArrayUtils; 31 import org.apache.commons.lang3.ArrayUtils;
  32 +import org.apache.commons.lang3.StringUtils;
30 import org.slf4j.Logger; 33 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory; 34 import org.slf4j.LoggerFactory;
32 import org.springframework.beans.factory.annotation.Autowired; 35 import org.springframework.beans.factory.annotation.Autowired;
@@ -42,6 +45,9 @@ import java.util.stream.Collectors; @@ -42,6 +45,9 @@ import java.util.stream.Collectors;
42 @Service 45 @Service
43 public class CutDownPriceServiceImpl implements ICutDownPriceService { 46 public class CutDownPriceServiceImpl implements ICutDownPriceService {
44 private static Logger logger = LoggerFactory.getLogger(CutDownPriceServiceImpl.class); 47 private static Logger logger = LoggerFactory.getLogger(CutDownPriceServiceImpl.class);
  48 + private static final Integer SYSTEM_HELP_ID = 0;
  49 + private static final String SYSTEM_HELP_NAME = "有货";
  50 + private static final String SYSTEM_HELP_IMAGE = "https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTKic2dZ7ib6p1PJJXFpYl95ibRyvSKCib3icUiaStlRN6PWmcRZjzPn4w4moEk2xhUxpYbibuPtBNPJBMeqQ/132";
45 @Autowired 51 @Autowired
46 private RedisValueCache redisValueCache; 52 private RedisValueCache redisValueCache;
47 @Autowired 53 @Autowired
@@ -62,6 +68,23 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -62,6 +68,23 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
62 private BeanConvert convert; 68 private BeanConvert convert;
63 69
64 @Override 70 @Override
  71 + public CutDownPriceActivityBo queryEffectCutPriceActivity() {
  72 + CutDownPriceActivityBo activityBo = null;
  73 + List<CutDownPriceActivityBo> activityBoList = cutDownActivityService.queryEffectCutPriceActivitys();
  74 + if(CollectionUtils.isEmpty(activityBoList)){
  75 + return null;
  76 + }
  77 + int currentTime = DateUtils.getCurrentTimeSecond();
  78 + for(CutDownPriceActivityBo bo : activityBoList){
  79 + if(bo.getBeginTime()<currentTime && bo.getEndTime()>currentTime){
  80 + activityBo = bo;
  81 + break;
  82 + }
  83 + }
  84 + return activityBo;
  85 + }
  86 +
  87 + @Override
65 public List<CutDownPriceProductHelpUserBo> queryHelpInfo(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) { 88 public List<CutDownPriceProductHelpUserBo> queryHelpInfo(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) {
66 Integer activityId = cutPriceHelpUserRequestBO.getActivityId(); 89 Integer activityId = cutPriceHelpUserRequestBO.getActivityId();
67 Integer productSkn = cutPriceHelpUserRequestBO.getProductSkn(); 90 Integer productSkn = cutPriceHelpUserRequestBO.getProductSkn();
@@ -92,13 +115,15 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -92,13 +115,15 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
92 /** 115 /**
93 * 查询某一个用户的帮砍记录 116 * 查询某一个用户的帮砍记录
94 */ 117 */
95 - private List<CutDownPriceProductHelpUserBo> queryHelpInfoList(List<CutPriceHelpUserRequestBO> requestList) { 118 + private List<CutDownPriceProductHelpUserBo> queryHelpInfoList(Integer userId, List<CutPriceHelpUserRequestBO> requestList) {
96 List<CutDownPriceProductHelpUser> helpUsers = cutPriceUserHelpMapper.selectHelpInfoList(requestList); 119 List<CutDownPriceProductHelpUser> helpUsers = cutPriceUserHelpMapper.selectHelpInfoList(requestList);
97 if (CollectionUtils.isEmpty(helpUsers)){ 120 if (CollectionUtils.isEmpty(helpUsers)){
98 logger.info("CutDownPriceServiceImpl :: queryHelpInfoList result is null"); 121 logger.info("CutDownPriceServiceImpl :: queryHelpInfoList result is null");
99 return Lists.newArrayList(); 122 return Lists.newArrayList();
100 } 123 }
101 List<CutDownPriceProductHelpUserBo> helpUsersBoList = convert.convertFromList(helpUsers, CutDownPriceProductHelpUserBo.class); 124 List<CutDownPriceProductHelpUserBo> helpUsersBoList = convert.convertFromList(helpUsers, CutDownPriceProductHelpUserBo.class);
  125 + //获取用户头像
  126 + getUserInfo(userId, helpUsersBoList);
102 return helpUsersBoList; 127 return helpUsersBoList;
103 } 128 }
104 129
@@ -200,7 +225,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -200,7 +225,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
200 List<CutDownPriceProductBo> cutProductBoList = cutDownPriceProductService.queryCutDownPriceProductBoListByRecords(cutPriceUserRecordList); 225 List<CutDownPriceProductBo> cutProductBoList = cutDownPriceProductService.queryCutDownPriceProductBoListByRecords(cutPriceUserRecordList);
201 // 查询已砍价记录 226 // 查询已砍价记录
202 List<CutPriceHelpUserRequestBO> userRequestList = convert.convertFromList(cutPriceUserRecordList, CutPriceHelpUserRequestBO.class); 227 List<CutPriceHelpUserRequestBO> userRequestList = convert.convertFromList(cutPriceUserRecordList, CutPriceHelpUserRequestBO.class);
203 - List<CutDownPriceProductHelpUserBo> helpUserBoList = this.queryHelpInfoList(userRequestList); 228 + List<CutDownPriceProductHelpUserBo> helpUserBoList = this.queryHelpInfoList(uid, userRequestList);
204 // 根据skn列表查询商品信息 229 // 根据skn列表查询商品信息
205 BatchBaseRequest<Integer> productRequest = new BatchBaseRequest<Integer>(); 230 BatchBaseRequest<Integer> productRequest = new BatchBaseRequest<Integer>();
206 productRequest.setParams(Lists.newArrayList(productSkns)); 231 productRequest.setParams(Lists.newArrayList(productSkns));
@@ -240,7 +265,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -240,7 +265,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
240 Integer activityId = cutPriceHelpUserRequestBO.getActivityId(); 265 Integer activityId = cutPriceHelpUserRequestBO.getActivityId();
241 Integer productSkn = cutPriceHelpUserRequestBO.getProductSkn(); 266 Integer productSkn = cutPriceHelpUserRequestBO.getProductSkn();
242 Integer userId = cutPriceHelpUserRequestBO.getUserId(); 267 Integer userId = cutPriceHelpUserRequestBO.getUserId();
243 - String helpUserId = cutPriceHelpUserRequestBO.getHelpUserId(); 268 + Integer helpUserId = cutPriceHelpUserRequestBO.getHelpUserId();
244 269
245 //判断用户是否已经帮助砍价 270 //判断用户是否已经帮助砍价
246 Integer count = cutPriceUserHelpMapper.selectExistHelpInfo(userId, helpUserId, activityId, productSkn); 271 Integer count = cutPriceUserHelpMapper.selectExistHelpInfo(userId, helpUserId, activityId, productSkn);
@@ -269,6 +294,16 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -269,6 +294,16 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
269 cutPriceUserHelpMapper.addHelpUserInfo(helpUser); 294 cutPriceUserHelpMapper.addHelpUserInfo(helpUser);
270 // 修改用户发起砍价记录表中的帮砍次数 295 // 修改用户发起砍价记录表中的帮砍次数
271 cutDownPriceUserRecordMapper.updateCutDownHelpCount(userId, activityId, productSkn); 296 cutDownPriceUserRecordMapper.updateCutDownHelpCount(userId, activityId, productSkn);
  297 + // 用户帮忙砍价后,自动发起砍价活动,系统帮助砍价除外
  298 + if(!SYSTEM_HELP_ID.equals(helpUserId)){
  299 + try{
  300 + cutPriceHelpUserRequestBO.setUserId(Integer.valueOf(helpUserId));
  301 + logger.info(" system start addCutPriceRecord, userId is {}, activityId is {}, productSkn is {}", userId, activityId, productSkn);
  302 + addCutPriceRecord(cutPriceHelpUserRequestBO);
  303 + }catch(Exception e){
  304 + logger.warn(" system addHelpUserInfo failed, userId is {}, activityId is {}, productSkn is {}, exception is {}", userId, activityId, productSkn, e);
  305 + }
  306 + }
272 // 清理缓存,用户帮砍记录列表、商品详情页 307 // 清理缓存,用户帮砍记录列表、商品详情页
273 clearCache(activityId, productSkn, userId); 308 clearCache(activityId, productSkn, userId);
274 return cutPrice; 309 return cutPrice;
@@ -299,7 +334,16 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -299,7 +334,16 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
299 record.setProductSkn(productSkn); 334 record.setProductSkn(productSkn);
300 record.setUserId(userId); 335 record.setUserId(userId);
301 record.setCreateTime(DateUtils.getCurrentTimeSecond()); 336 record.setCreateTime(DateUtils.getCurrentTimeSecond());
  337 + logger.info(" addCutDownUserRecord, userId is {}, activityId is {}, productSkn is {}", userId, activityId, productSkn);
302 int num = cutDownPriceUserRecordMapper.addCutDownUserRecord(record); 338 int num = cutDownPriceUserRecordMapper.addCutDownUserRecord(record);
  339 + // 系统帮助砍第一次价
  340 + try{
  341 + logger.info(" system start addHelpUserInfo, userId is {}, activityId is {}, productSkn is {}", userId, activityId, productSkn);
  342 + addHelpUserInfo(convertCutDownPriceProductSystemHelpUser(cutPriceHelpUserRequestBO));
  343 + }catch(Exception e){
  344 + logger.warn(" system addHelpUserInfo failed, userId is {}, activityId is {}, productSkn is {}, exception is {}", userId, activityId, productSkn, e);
  345 + }
  346 +
303 return num; 347 return num;
304 } 348 }
305 349
@@ -327,12 +371,17 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -327,12 +371,17 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
327 user.setUserId(request.getUserId()); 371 user.setUserId(request.getUserId());
328 user.setActivityId(request.getActivityId()); 372 user.setActivityId(request.getActivityId());
329 user.setProductSkn(request.getProductSkn()); 373 user.setProductSkn(request.getProductSkn());
330 - user.setHelpUserName(request.getHelpUserName());  
331 user.setHelpUserId(request.getHelpUserId()); 374 user.setHelpUserId(request.getHelpUserId());
332 - user.setHelpUserImgUrl(request.getHelpUserImgUrl());  
333 return user; 375 return user;
334 } 376 }
335 377
  378 + private CutPriceHelpUserRequestBO convertCutDownPriceProductSystemHelpUser(CutPriceHelpUserRequestBO request) {
  379 + request.setHelpUserName(SYSTEM_HELP_NAME);
  380 + request.setHelpUserId(SYSTEM_HELP_ID);
  381 + request.setHelpUserImgUrl(SYSTEM_HELP_IMAGE);
  382 + return request;
  383 + }
  384 +
336 private BigDecimal calculateCutPrice(CutDownPriceProductBo cutDownPriceProductBo, List<CutDownPriceProductHelpUser> helpUsers) { 385 private BigDecimal calculateCutPrice(CutDownPriceProductBo cutDownPriceProductBo, List<CutDownPriceProductHelpUser> helpUsers) {
337 if(helpUsers==null){ 386 if(helpUsers==null){
338 helpUsers = new ArrayList<>(); 387 helpUsers = new ArrayList<>();
@@ -355,20 +404,47 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -355,20 +404,47 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
355 } 404 }
356 405
357 private void getUserInfo(Integer userId, List<CutDownPriceProductHelpUserBo> helpUserBos) { 406 private void getUserInfo(Integer userId, List<CutDownPriceProductHelpUserBo> helpUserBos) {
358 - List<Integer> uidList = new ArrayList<>();  
359 - uidList.add(userId);  
360 - AsyncFuture<UserBaseRspBO[]> userBaseRspBOArrAsync = drawlineList2MapService.postForUserBaseInfo(uidList);  
361 - UserBaseRspBO[] userBaseRspBOs = userBaseRspBOArrAsync.get(); 407 + StringBuilder sb = new StringBuilder();
  408 + sb.append(userId);
  409 + for (CutDownPriceProductHelpUserBo helpUserBo : helpUserBos){
  410 + sb.append(",").append(helpUserBo.getHelpUserId());
  411 + }
  412 + UserInfoRspBO[] userInfoBoArray = invokeUicGetUserInfo(sb.toString());
  413 + for (CutDownPriceProductHelpUserBo helpUserBo : helpUserBos){
  414 + for (UserInfoRspBO userInfoRspBO : userInfoBoArray){
  415 + if(helpUserBo.getHelpUserId().equals(SYSTEM_HELP_ID)) {
  416 + helpUserBo.setHelpUserImgUrl(SYSTEM_HELP_IMAGE);
  417 + helpUserBo.setHelpUserName(SYSTEM_HELP_NAME);
  418 + break;
  419 + }else if (helpUserBo.getHelpUserId().equals(userInfoRspBO.getUid())){
  420 + helpUserBo.setHelpUserImgUrl(userInfoRspBO.getHeadIco());
  421 + helpUserBo.setHelpUserName(userInfoRspBO.getNickName());
  422 + break;
  423 + }
  424 + }
  425 + }
362 for (CutDownPriceProductHelpUserBo helpUserBo : helpUserBos){ 426 for (CutDownPriceProductHelpUserBo helpUserBo : helpUserBos){
363 - for (UserBaseRspBO userBaseRspBO : userBaseRspBOs){  
364 - if (helpUserBo.getUserId().equals(userBaseRspBO.getUid())){  
365 - helpUserBo.setUserImgUrl(userBaseRspBO.getHeadIco()); 427 + for (UserInfoRspBO userInfoRspBO : userInfoBoArray){
  428 + if (userId.equals(userInfoRspBO.getUid())){
  429 + helpUserBo.setUserImgUrl(userInfoRspBO.getHeadIco());
366 break; 430 break;
367 } 431 }
368 } 432 }
369 } 433 }
370 } 434 }
371 435
  436 + private UserInfoRspBO[] invokeUicGetUserInfo(String uids) {
  437 + if(StringUtils.isEmpty(uids)){
  438 + return new UserInfoRspBO[0];
  439 + }
  440 +
  441 + UicUserReqBO request = new UicUserReqBO();
  442 + request.setUids(uids);
  443 + logger.info("start invoke uic.getUserInfoListByYohoUid, uids is {}", uids);
  444 + UserInfoRspBO[] userInfoBoArray = serviceCaller.call("uic.getUserInfoListByYohoUid", request, UserInfoRspBO[].class);
  445 + return userInfoBoArray;
  446 + }
  447 +
372 private CutDownPriceActivityProductBo buildCutDownPriceActivityProductBo(CutDownPriceActivityBo activityBo, 448 private CutDownPriceActivityProductBo buildCutDownPriceActivityProductBo(CutDownPriceActivityBo activityBo,
373 CutDownPriceProductBo cutDownPriceProductBo, 449 CutDownPriceProductBo cutDownPriceProductBo,
374 List<CutDownPriceProductHelpUserBo> helpUserBos, 450 List<CutDownPriceProductHelpUserBo> helpUserBos,
@@ -46,6 +46,7 @@ @@ -46,6 +46,7 @@
46 <value>/queryCutPriceProductForOrder</value> 46 <value>/queryCutPriceProductForOrder</value>
47 <value>/addCutPriceUseRecord</value> 47 <value>/addCutPriceUseRecord</value>
48 <value>/cancelCutPriceUseRecord</value> 48 <value>/cancelCutPriceUseRecord</value>
  49 + <value>/queryEffectCutPriceActivity</value>
49 </list> 50 </list>
50 </property> 51 </property>
51 <property name="excludeMethods"> 52 <property name="excludeMethods">