Authored by wangshusheng

Merge branch 'dev6.8.2' into test6.8.2

Conflicts:
	dal/src/main/java/com/yoho/activity/dal/CutDownPriceActivityMapper.java
	service/src/main/resources/META-INF/spring/spring-interceptor-config.xml
@@ -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);
@@ -12,4 +12,5 @@ public interface CutDownPriceActivityMapper { @@ -12,4 +12,5 @@ public interface CutDownPriceActivityMapper {
12 List<CutDownPriceActivity> selectCutDownPriceActivityList(@Param("list") List<Integer> activityId); 12 List<CutDownPriceActivity> selectCutDownPriceActivityList(@Param("list") List<Integer> activityId);
13 13
14 void updateCutDownPriceActivity(@Param("params") CutDownPriceActivity cutDownPriceActivity); 14 void updateCutDownPriceActivity(@Param("params") CutDownPriceActivity cutDownPriceActivity);
  15 + List<CutDownPriceActivity> selectEffectCutPriceActivity();
15 } 16 }
@@ -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 }
@@ -16,4 +16,10 @@ public interface CutDownPriceUserRecordMapper { @@ -16,4 +16,10 @@ public interface CutDownPriceUserRecordMapper {
16 16
17 CutDownPriceUserRecord selectCutDownPriceUserRecord(@Param("userId") Integer userId, @Param("activityId") Integer activityId, @Param("productSkn") Integer productSkn); 17 CutDownPriceUserRecord selectCutDownPriceUserRecord(@Param("userId") Integer userId, @Param("activityId") Integer activityId, @Param("productSkn") Integer productSkn);
18 18
  19 + int updateCutDownHelpCount(@Param("userId") Integer userId, @Param("activityId") Integer activityId, @Param("productSkn") Integer productSkn);
  20 +
  21 + int updateDecreaseUseCount(@Param("userId") Integer userId, @Param("activityId") Integer activityId, @Param("productSkn") Integer productSkn);
  22 +
  23 + int updateIncreaseUseCount(@Param("userId") Integer userId, @Param("activityId") Integer activityId, @Param("productSkn") Integer productSkn);
  24 +
19 } 25 }
@@ -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 }
@@ -6,8 +6,11 @@ public class CutDownPriceUserRecord { @@ -6,8 +6,11 @@ public class CutDownPriceUserRecord {
6 private Integer id; 6 private Integer id;
7 private Integer userId; 7 private Integer userId;
8 private Integer createTime; 8 private Integer createTime;
  9 + private Integer updateTime;
9 private Integer activityId; 10 private Integer activityId;
10 private Integer productSkn; 11 private Integer productSkn;
  12 + private Integer helpCount;
  13 + private Integer useCount;
11 14
12 public Integer getId() { 15 public Integer getId() {
13 return id; 16 return id;
@@ -49,4 +52,27 @@ public class CutDownPriceUserRecord { @@ -49,4 +52,27 @@ public class CutDownPriceUserRecord {
49 this.productSkn = productSkn; 52 this.productSkn = productSkn;
50 } 53 }
51 54
  55 + public Integer getUpdateTime() {
  56 + return updateTime;
  57 + }
  58 +
  59 + public void setUpdateTime(Integer updateTime) {
  60 + this.updateTime = updateTime;
  61 + }
  62 +
  63 + public Integer getHelpCount() {
  64 + return helpCount;
  65 + }
  66 +
  67 + public void setHelpCount(Integer helpCount) {
  68 + this.helpCount = helpCount;
  69 + }
  70 +
  71 + public Integer getUseCount() {
  72 + return useCount;
  73 + }
  74 +
  75 + public void setUseCount(Integer useCount) {
  76 + this.useCount = useCount;
  77 + }
52 } 78 }
  1 +package com.yoho.activity.dal.model;
  2 +
  3 +public class CutdownPriceOrderRecord {
  4 + private Integer id;
  5 + private Integer userId;
  6 + private Integer createTime;
  7 + private Integer updateTime;
  8 + private Integer activityId;
  9 + private Integer productSkn;
  10 + private Integer status;
  11 + private String orderCode;
  12 +
  13 + public Integer getId() {
  14 + return id;
  15 + }
  16 +
  17 + public void setId(Integer id) {
  18 + this.id = id;
  19 + }
  20 +
  21 + public Integer getUserId() {
  22 + return userId;
  23 + }
  24 +
  25 + public void setUserId(Integer userId) {
  26 + this.userId = userId;
  27 + }
  28 +
  29 + public Integer getCreateTime() {
  30 + return createTime;
  31 + }
  32 +
  33 + public void setCreateTime(Integer createTime) {
  34 + this.createTime = createTime;
  35 + }
  36 +
  37 + public Integer getActivityId() {
  38 + return activityId;
  39 + }
  40 +
  41 + public void setActivityId(Integer activityId) {
  42 + this.activityId = activityId;
  43 + }
  44 +
  45 + public Integer getProductSkn() {
  46 + return productSkn;
  47 + }
  48 +
  49 + public void setProductSkn(Integer productSkn) {
  50 + this.productSkn = productSkn;
  51 + }
  52 +
  53 + public Integer getUpdateTime() {
  54 + return updateTime;
  55 + }
  56 +
  57 + public void setUpdateTime(Integer updateTime) {
  58 + this.updateTime = updateTime;
  59 + }
  60 +
  61 + public Integer getStatus() {
  62 + return status;
  63 + }
  64 +
  65 + public void setStatus(Integer status) {
  66 + this.status = status;
  67 + }
  68 +
  69 + public String getOrderCode() {
  70 + return orderCode;
  71 + }
  72 +
  73 + public void setOrderCode(String orderCode) {
  74 + this.orderCode = orderCode;
  75 + }
  76 +}
@@ -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>
@@ -6,10 +6,13 @@ @@ -6,10 +6,13 @@
6 <result column="user_id" property="userId" jdbcType="INTEGER" /> 6 <result column="user_id" property="userId" jdbcType="INTEGER" />
7 <result column="activity_id" property="activityId" jdbcType="INTEGER" /> 7 <result column="activity_id" property="activityId" jdbcType="INTEGER" />
8 <result column="product_skn" property="productSkn" jdbcType="INTEGER" /> 8 <result column="product_skn" property="productSkn" jdbcType="INTEGER" />
  9 + <result column="help_count" property="helpCount" jdbcType="INTEGER" />
  10 + <result column="use_count" property="useCount" jdbcType="INTEGER" />
9 <result column="create_time" property="createTime" jdbcType="INTEGER" /> 11 <result column="create_time" property="createTime" jdbcType="INTEGER" />
  12 + <result column="update_time" property="updateTime" jdbcType="INTEGER" />
10 </resultMap> 13 </resultMap>
11 <sql id="Base_Column_List" > 14 <sql id="Base_Column_List" >
12 - id, user_id, activity_id, product_skn, create_time 15 + id, user_id, activity_id, product_skn, help_count, use_count, create_time, update_time
13 </sql> 16 </sql>
14 17
15 <insert id="addCutDownUserRecord" parameterType="com.yoho.activity.dal.model.CutDownPriceUserRecord"> 18 <insert id="addCutDownUserRecord" parameterType="com.yoho.activity.dal.model.CutDownPriceUserRecord">
@@ -44,4 +47,27 @@ @@ -44,4 +47,27 @@
44 and product_skn = #{productSkn,jdbcType=INTEGER} 47 and product_skn = #{productSkn,jdbcType=INTEGER}
45 </select> 48 </select>
46 49
  50 + <update id="updateCutDownHelpCount" >
  51 + update cutdown_price_user_record
  52 + set help_count = help_count+1, update_time= UNIX_TIMESTAMP()
  53 + where user_id = #{userId,jdbcType=INTEGER}
  54 + and activity_id = #{activityId,jdbcType=INTEGER}
  55 + and product_skn = #{productSkn,jdbcType=INTEGER}
  56 + </update>
  57 +
  58 + <update id="updateDecreaseUseCount" >
  59 + update cutdown_price_user_record
  60 + set use_count = use_count-1, update_time= UNIX_TIMESTAMP()
  61 + where user_id = #{userId,jdbcType=INTEGER}
  62 + and activity_id = #{activityId,jdbcType=INTEGER}
  63 + and product_skn = #{productSkn,jdbcType=INTEGER}
  64 + </update>
  65 +
  66 + <update id="updateIncreaseUseCount" >
  67 + update cutdown_price_user_record
  68 + set use_count = use_count+1, update_time= UNIX_TIMESTAMP()
  69 + where user_id = #{userId,jdbcType=INTEGER}
  70 + and activity_id = #{activityId,jdbcType=INTEGER}
  71 + and product_skn = #{productSkn,jdbcType=INTEGER}
  72 + </update>
47 </mapper> 73 </mapper>
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 <parent> 4 <parent>
5 <groupId>com.yoho</groupId> 5 <groupId>com.yoho</groupId>
6 <artifactId>parent</artifactId> 6 <artifactId>parent</artifactId>
7 - <version>1.4.6-SNAPSHOT</version> 7 + <version>1.4.8-SNAPSHOT</version>
8 </parent> 8 </parent>
9 9
10 <groupId>com.yoho.dsf</groupId> 10 <groupId>com.yoho.dsf</groupId>
@@ -4,8 +4,13 @@ import com.yoho.activity.dal.model.CutDownPriceProductHelpUser; @@ -4,8 +4,13 @@ import com.yoho.activity.dal.model.CutDownPriceProductHelpUser;
4 import com.yoho.activity.queue.ApiResponse; 4 import com.yoho.activity.queue.ApiResponse;
5 import com.yoho.activity.queue.service.ICutDownPriceService; 5 import com.yoho.activity.queue.service.ICutDownPriceService;
6 import com.yoho.core.rest.annotation.ServiceDesc; 6 import com.yoho.core.rest.annotation.ServiceDesc;
  7 +import com.yoho.error.ServiceError;
  8 +import com.yoho.error.exception.ServiceException;
7 import com.yoho.product.model.CollageProductBo; 9 import com.yoho.product.model.CollageProductBo;
  10 +import com.yoho.product.request.BaseRequest;
8 import com.yoho.product.response.PageResponseBo; 11 import com.yoho.product.response.PageResponseBo;
  12 +import com.yoho.product.response.VoidResponse;
  13 +import com.yoho.service.model.activity.CutDownPriceActivityBo;
9 import com.yoho.service.model.activity.CutDownPriceActivityProductBo; 14 import com.yoho.service.model.activity.CutDownPriceActivityProductBo;
10 import com.yoho.service.model.activity.CutDownPriceProductHelpUserBo; 15 import com.yoho.service.model.activity.CutDownPriceProductHelpUserBo;
11 import com.yoho.service.model.activity.CutDownProductQueryRequest; 16 import com.yoho.service.model.activity.CutDownProductQueryRequest;
@@ -34,14 +39,26 @@ public class CutDownProductPriceRest { @@ -34,14 +39,26 @@ public class CutDownProductPriceRest {
34 private ICutDownPriceService cutDownPriceService; 39 private ICutDownPriceService cutDownPriceService;
35 40
36 /** 41 /**
37 - * 用户发起砍价 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 + * 用户发起砍价,系统自动砍价
38 */ 55 */
39 @RequestMapping("/addCutPriceRecord") 56 @RequestMapping("/addCutPriceRecord")
40 @ResponseBody 57 @ResponseBody
41 public Integer addCutPriceRecord(@RequestBody CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) { 58 public Integer addCutPriceRecord(@RequestBody CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) {
42 logger.info("CutDownProductPriceRest addCutPriceRecord params is{}", cutPriceHelpUserRequestBO); 59 logger.info("CutDownProductPriceRest addCutPriceRecord params is{}", cutPriceHelpUserRequestBO);
43 int num = cutDownPriceService.addCutPriceRecord(cutPriceHelpUserRequestBO); 60 int num = cutDownPriceService.addCutPriceRecord(cutPriceHelpUserRequestBO);
44 - logger.info("CutDownProductPriceRest addCutPriceRecord success"); 61 + logger.info("CutDownProductPriceRest addCutPriceRecord success params is{}", cutPriceHelpUserRequestBO);
45 return num; 62 return num;
46 } 63 }
47 64
@@ -53,7 +70,7 @@ public class CutDownProductPriceRest { @@ -53,7 +70,7 @@ public class CutDownProductPriceRest {
53 public PageResponseBo<CutDownPriceActivityProductBo> queryMyCutPriceListByPage(@RequestBody CutDownProductQueryRequest request) { 70 public PageResponseBo<CutDownPriceActivityProductBo> queryMyCutPriceListByPage(@RequestBody CutDownProductQueryRequest request) {
54 logger.info("CutDownProductPriceRest queryMyCutPriceList params is{}", request); 71 logger.info("CutDownProductPriceRest queryMyCutPriceList params is{}", request);
55 PageResponseBo<CutDownPriceActivityProductBo> responseBo = cutDownPriceService.queryMyCutPriceListByPage(request); 72 PageResponseBo<CutDownPriceActivityProductBo> responseBo = cutDownPriceService.queryMyCutPriceListByPage(request);
56 - logger.info("CutDownProductPriceRest queryMyCutPriceList success"); 73 + logger.info("CutDownProductPriceRest queryMyCutPriceList success params is{}", request);
57 return responseBo; 74 return responseBo;
58 } 75 }
59 76
@@ -65,19 +82,19 @@ public class CutDownProductPriceRest { @@ -65,19 +82,19 @@ public class CutDownProductPriceRest {
65 public CutDownPriceActivityProductBo queryCutPriceProductDetail(@RequestBody CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) { 82 public CutDownPriceActivityProductBo queryCutPriceProductDetail(@RequestBody CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) {
66 logger.info("CutDownProductPriceRest queryCutPriceProductDetail params is{}", cutPriceHelpUserRequestBO); 83 logger.info("CutDownProductPriceRest queryCutPriceProductDetail params is{}", cutPriceHelpUserRequestBO);
67 CutDownPriceActivityProductBo productInfo = cutDownPriceService.queryCutProductInfo(cutPriceHelpUserRequestBO); 84 CutDownPriceActivityProductBo productInfo = cutDownPriceService.queryCutProductInfo(cutPriceHelpUserRequestBO);
68 - logger.info("CutDownProductPriceRest queryCutPriceProductDetail success"); 85 + logger.info("CutDownProductPriceRest queryCutPriceProductDetail success params is{}", cutPriceHelpUserRequestBO);
69 return productInfo; 86 return productInfo;
70 } 87 }
71 88
72 /** 89 /**
73 - * 好友帮忙砍价 90 + * 好友帮忙砍价,并自动发起一个砍价
74 */ 91 */
75 @RequestMapping("/addCutPriceHelpUserInfo") 92 @RequestMapping("/addCutPriceHelpUserInfo")
76 @ResponseBody 93 @ResponseBody
77 public BigDecimal addCutPriceHelpUserInfo(@RequestBody CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) { 94 public BigDecimal addCutPriceHelpUserInfo(@RequestBody CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) {
78 logger.info("CutDownProductPriceRest addCutPriceHelpUserInfo params is{}", cutPriceHelpUserRequestBO); 95 logger.info("CutDownProductPriceRest addCutPriceHelpUserInfo params is{}", cutPriceHelpUserRequestBO);
79 BigDecimal cutPrice = cutDownPriceService.addHelpUserInfo(cutPriceHelpUserRequestBO); 96 BigDecimal cutPrice = cutDownPriceService.addHelpUserInfo(cutPriceHelpUserRequestBO);
80 - logger.info("CutDownProductPriceRest addCutPriceHelpUserInfo success"); 97 + logger.info("CutDownProductPriceRest addCutPriceHelpUserInfo success params is{}", cutPriceHelpUserRequestBO);
81 return cutPrice; 98 return cutPrice;
82 } 99 }
83 100
@@ -89,20 +106,72 @@ public class CutDownProductPriceRest { @@ -89,20 +106,72 @@ public class CutDownProductPriceRest {
89 public List<CutDownPriceProductHelpUserBo> queryCutPriceHelpUserInfos(@RequestBody CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) { 106 public List<CutDownPriceProductHelpUserBo> queryCutPriceHelpUserInfos(@RequestBody CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) {
90 logger.info("CutDownProductPriceRest queryCutPriceHelpUserInfos params is{}", cutPriceHelpUserRequestBO); 107 logger.info("CutDownProductPriceRest queryCutPriceHelpUserInfos params is{}", cutPriceHelpUserRequestBO);
91 List<CutDownPriceProductHelpUserBo> helpUsers = cutDownPriceService.queryHelpInfo(cutPriceHelpUserRequestBO); 108 List<CutDownPriceProductHelpUserBo> helpUsers = cutDownPriceService.queryHelpInfo(cutPriceHelpUserRequestBO);
92 - logger.info("CutDownProductPriceRest queryCutPriceHelpUserInfos success"); 109 + logger.info("CutDownProductPriceRest queryCutPriceHelpUserInfos success params is{}", cutPriceHelpUserRequestBO);
93 return helpUsers; 110 return helpUsers;
94 } 111 }
95 112
96 /** 113 /**
97 * 给订单提供接口:查询砍价信息 114 * 给订单提供接口:查询砍价信息
  115 + * 如果没有砍价成功抛异常、基本信息是否有效、是否已使用过
98 * 直接调 116 * 直接调
99 */ 117 */
100 @RequestMapping("/queryCutPriceProductForOrder") 118 @RequestMapping("/queryCutPriceProductForOrder")
101 @ResponseBody 119 @ResponseBody
102 public CutDownPriceActivityProductBo queryCutPriceProductForOrder(@RequestBody CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) { 120 public CutDownPriceActivityProductBo queryCutPriceProductForOrder(@RequestBody CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) {
103 - logger.info("CutDownProductPriceRest queryCutPriceProductDetail params is{}", cutPriceHelpUserRequestBO);  
104 - CutDownPriceActivityProductBo productInfo = cutDownPriceService.queryCutProductInfo(cutPriceHelpUserRequestBO);  
105 - logger.info("CutDownProductPriceRest queryCutPriceProductDetail success"); 121 + if (null==cutPriceHelpUserRequestBO || null==cutPriceHelpUserRequestBO.getUserId()
  122 + || null==cutPriceHelpUserRequestBO.getProductSkn() || null==cutPriceHelpUserRequestBO.getActivityId()) {
  123 + logger.warn("warning param userId or productSkn or activityId is null,req is {}", cutPriceHelpUserRequestBO);
  124 + throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_PARAM_ERROR);
  125 + }
  126 + logger.info("CutDownProductPriceRest queryCutPriceProductForOrder params is{}", cutPriceHelpUserRequestBO);
  127 + CutDownPriceActivityProductBo productInfo = cutDownPriceService.queryCutProductInfoForOrder(cutPriceHelpUserRequestBO);
  128 + // 校验是否已经砍价成功
  129 + if(productInfo.getHasJoinNum()<productInfo.getJoinNum()){
  130 + logger.warn(" you have not cutdown success, params is {}", cutPriceHelpUserRequestBO);
  131 + throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_YOU_HASNOT_CUTDOWN_SUCCESS_ERROR);
  132 + }
  133 + // 校验是否已经使用过
  134 + if(productInfo.getCanUseCount()==0){
  135 + logger.warn(" you have used this cutdown, params is {}", cutPriceHelpUserRequestBO);
  136 + throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_YOU_HAS_USED_CUTDOWNORDER_ERROR);
  137 + }
  138 + logger.info("CutDownProductPriceRest queryCutPriceProductForOrder success, params is {}", cutPriceHelpUserRequestBO);
106 return productInfo; 139 return productInfo;
107 } 140 }
  141 +
  142 + /**
  143 + * 给订单提供接口:砍价下单,每个用户只能使用一次
  144 + * 直接调
  145 + */
  146 + @RequestMapping("/addCutPriceUseRecord")
  147 + @ResponseBody
  148 + public VoidResponse addCutPriceUseRecord(@RequestBody CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) {
  149 + logger.info("CutDownProductPriceRest addCutPriceUseRecord params is{}", cutPriceHelpUserRequestBO);
  150 + if (null==cutPriceHelpUserRequestBO || null==cutPriceHelpUserRequestBO.getUserId()
  151 + || null==cutPriceHelpUserRequestBO.getProductSkn() || null==cutPriceHelpUserRequestBO.getActivityId()) {
  152 + logger.warn("warning param userId or productSkn or activityId is null,req is {}", cutPriceHelpUserRequestBO);
  153 + throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_PARAM_ERROR);
  154 + }
  155 +
  156 + cutDownPriceService.addCutPriceUseRecord(cutPriceHelpUserRequestBO);
  157 + logger.info("CutDownProductPriceRest addCutPriceUseRecord success");
  158 + return new VoidResponse(VoidResponse.CODE);
  159 + }
  160 + /**
  161 + * 给订单提供接口:取消砍价下单,修改状态,可以重新下单
  162 + * 直接调
  163 + */
  164 + @RequestMapping("/cancelCutPriceUseRecord")
  165 + @ResponseBody
  166 + public VoidResponse cancelCutPriceUseRecord(@RequestBody CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) {
  167 + logger.info("CutDownProductPriceRest cancelCutPriceUseRecord params is{}", cutPriceHelpUserRequestBO);
  168 + if (null==cutPriceHelpUserRequestBO || null==cutPriceHelpUserRequestBO.getUserId()
  169 + || null==cutPriceHelpUserRequestBO.getProductSkn() || null==cutPriceHelpUserRequestBO.getActivityId()) {
  170 + logger.warn("warning param userId or productSkn or activityId is null,req is {}", cutPriceHelpUserRequestBO);
  171 + throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_PARAM_ERROR);
  172 + }
  173 + cutDownPriceService.cancelCutPriceUseRecord(cutPriceHelpUserRequestBO);
  174 + logger.info("CutDownProductPriceRest cancelCutPriceUseRecord success");
  175 + return new VoidResponse(VoidResponse.CODE);
  176 + }
108 } 177 }
@@ -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;
@@ -17,9 +18,17 @@ public interface ICutDownPriceService { @@ -17,9 +18,17 @@ public interface ICutDownPriceService {
17 18
18 CutDownPriceActivityProductBo queryCutProductInfo(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO); 19 CutDownPriceActivityProductBo queryCutProductInfo(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO);
19 20
  21 + CutDownPriceActivityProductBo queryCutProductInfoForOrder(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO);
  22 +
20 BigDecimal addHelpUserInfo(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO); 23 BigDecimal addHelpUserInfo(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO);
21 24
22 int addCutPriceRecord(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO); 25 int addCutPriceRecord(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO);
23 26
24 PageResponseBo<CutDownPriceActivityProductBo> queryMyCutPriceListByPage(CutDownProductQueryRequest request); 27 PageResponseBo<CutDownPriceActivityProductBo> queryMyCutPriceListByPage(CutDownProductQueryRequest request);
  28 +
  29 + void addCutPriceUseRecord(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO);
  30 +
  31 + int cancelCutPriceUseRecord(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO);
  32 +
  33 + CutDownPriceActivityBo queryEffectCutPriceActivity();
25 } 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);
@@ -24,12 +24,16 @@ import com.yoho.product.request.BatchBaseRequest; @@ -24,12 +24,16 @@ import com.yoho.product.request.BatchBaseRequest;
24 import com.yoho.product.response.PageResponseBo; 24 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.request.LimitProductHelpUserRequestBO;  
28 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;
29 import org.apache.commons.collections.CollectionUtils; 30 import org.apache.commons.collections.CollectionUtils;
  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;
  36 +import org.springframework.dao.DataIntegrityViolationException;
33 import org.springframework.stereotype.Service; 37 import org.springframework.stereotype.Service;
34 38
35 import javax.annotation.Resource; 39 import javax.annotation.Resource;
@@ -41,6 +45,9 @@ import java.util.stream.Collectors; @@ -41,6 +45,9 @@ import java.util.stream.Collectors;
41 @Service 45 @Service
42 public class CutDownPriceServiceImpl implements ICutDownPriceService { 46 public class CutDownPriceServiceImpl implements ICutDownPriceService {
43 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";
44 @Autowired 51 @Autowired
45 private RedisValueCache redisValueCache; 52 private RedisValueCache redisValueCache;
46 @Autowired 53 @Autowired
@@ -61,6 +68,23 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -61,6 +68,23 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
61 private BeanConvert convert; 68 private BeanConvert convert;
62 69
63 @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
64 public List<CutDownPriceProductHelpUserBo> queryHelpInfo(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) { 88 public List<CutDownPriceProductHelpUserBo> queryHelpInfo(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) {
65 Integer activityId = cutPriceHelpUserRequestBO.getActivityId(); 89 Integer activityId = cutPriceHelpUserRequestBO.getActivityId();
66 Integer productSkn = cutPriceHelpUserRequestBO.getProductSkn(); 90 Integer productSkn = cutPriceHelpUserRequestBO.getProductSkn();
@@ -91,13 +115,15 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -91,13 +115,15 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
91 /** 115 /**
92 * 查询某一个用户的帮砍记录 116 * 查询某一个用户的帮砍记录
93 */ 117 */
94 - private List<CutDownPriceProductHelpUserBo> queryHelpInfoList(List<CutPriceHelpUserRequestBO> requestList) { 118 + private List<CutDownPriceProductHelpUserBo> queryHelpInfoList(Integer userId, List<CutPriceHelpUserRequestBO> requestList) {
95 List<CutDownPriceProductHelpUser> helpUsers = cutPriceUserHelpMapper.selectHelpInfoList(requestList); 119 List<CutDownPriceProductHelpUser> helpUsers = cutPriceUserHelpMapper.selectHelpInfoList(requestList);
96 if (CollectionUtils.isEmpty(helpUsers)){ 120 if (CollectionUtils.isEmpty(helpUsers)){
97 logger.info("CutDownPriceServiceImpl :: queryHelpInfoList result is null"); 121 logger.info("CutDownPriceServiceImpl :: queryHelpInfoList result is null");
98 return Lists.newArrayList(); 122 return Lists.newArrayList();
99 } 123 }
100 List<CutDownPriceProductHelpUserBo> helpUsersBoList = convert.convertFromList(helpUsers, CutDownPriceProductHelpUserBo.class); 124 List<CutDownPriceProductHelpUserBo> helpUsersBoList = convert.convertFromList(helpUsers, CutDownPriceProductHelpUserBo.class);
  125 + //获取用户头像
  126 + getUserInfo(userId, helpUsersBoList);
101 return helpUsersBoList; 127 return helpUsersBoList;
102 } 128 }
103 129
@@ -105,6 +131,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -105,6 +131,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
105 public CutDownPriceActivityProductBo queryCutProductInfo(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) { 131 public CutDownPriceActivityProductBo queryCutProductInfo(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) {
106 Integer activityId = cutPriceHelpUserRequestBO.getActivityId(); 132 Integer activityId = cutPriceHelpUserRequestBO.getActivityId();
107 Integer productSkn = cutPriceHelpUserRequestBO.getProductSkn(); 133 Integer productSkn = cutPriceHelpUserRequestBO.getProductSkn();
  134 + Integer userId = cutPriceHelpUserRequestBO.getUserId();
108 // 查询活动信息 135 // 查询活动信息
109 CutDownPriceActivityBo activityBo = cutDownActivityService.queryActivityInfo(activityId); 136 CutDownPriceActivityBo activityBo = cutDownActivityService.queryActivityInfo(activityId);
110 checkValidActivity(activityBo, activityId); 137 checkValidActivity(activityBo, activityId);
@@ -121,7 +148,48 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -121,7 +148,48 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
121 request.setParams(Lists.newArrayList(productSkn)); 148 request.setParams(Lists.newArrayList(productSkn));
122 ProductBo[] productBoArray = serviceCaller.call("product.batchQueryNamesAndImageBySkns", request, ProductBo[].class); 149 ProductBo[] productBoArray = serviceCaller.call("product.batchQueryNamesAndImageBySkns", request, ProductBo[].class);
123 // 组装信息 150 // 组装信息
124 - return buildCutDownPriceActivityProductBo(activityBo, cutDownPriceProductBo, helpUserBos, productBoArray); 151 + CutDownPriceActivityProductBo bo = buildCutDownPriceActivityProductBo(activityBo, cutDownPriceProductBo, helpUserBos, productBoArray);
  152 + bo.setCanUseCount(selectCutdownPriceOrderRecordCount(cutPriceHelpUserRequestBO));
  153 + return bo;
  154 + }
  155 +
  156 + @Override
  157 + public CutDownPriceActivityProductBo queryCutProductInfoForOrder(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) {
  158 + Integer activityId = cutPriceHelpUserRequestBO.getActivityId();
  159 + Integer productSkn = cutPriceHelpUserRequestBO.getProductSkn();
  160 + Integer userId = cutPriceHelpUserRequestBO.getUserId();
  161 + // 查询活动信息
  162 + CutDownPriceActivityBo activityBo = cutDownActivityService.queryActivityInfo(activityId);
  163 + checkValidActivity(activityBo, activityId);
  164 + // 查询商品配置信息
  165 + CutDownPriceProductBo cutDownPriceProductBo = cutDownPriceProductService.queryCutDownPriceProductBo(activityId, productSkn);
  166 + if(cutDownPriceProductBo==null){
  167 + logger.warn(" the cutdown product not exist, activityId is {}, productSkn is {}", activityId, productSkn);
  168 + throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_PRODUCT_NOTEXIST_ERROR);
  169 + }
  170 + CutDownPriceUserRecord record = cutDownPriceUserRecordMapper.selectCutDownPriceUserRecord(userId, activityId, productSkn);
  171 + // 组装信息
  172 + CutDownPriceActivityProductBo bo = buildCutDownPriceActivityProductBo(activityBo, cutDownPriceProductBo, null, null);
  173 + if(record!=null){
  174 + // 设置是否已使用
  175 + bo.setCanUseCount(record.getUseCount());
  176 + // 设置已砍价记录
  177 + bo.setHasJoinNum(record.getHelpCount());
  178 + }
  179 + return bo;
  180 + }
  181 +
  182 + private int selectCutdownPriceOrderRecordCount(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) {
  183 + Integer userId = cutPriceHelpUserRequestBO.getUserId();
  184 + int useCount = 0;
  185 + // 登陆情况下查询使用记录
  186 + if(userId!=null){
  187 + CutDownPriceUserRecord record = cutDownPriceUserRecordMapper.selectCutDownPriceUserRecord(userId, cutPriceHelpUserRequestBO.getActivityId(), cutPriceHelpUserRequestBO.getProductSkn());
  188 + if(record!=null){
  189 + useCount = record.getUseCount();
  190 + }
  191 + }
  192 + return useCount;
125 } 193 }
126 194
127 @Override 195 @Override
@@ -157,7 +225,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -157,7 +225,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
157 List<CutDownPriceProductBo> cutProductBoList = cutDownPriceProductService.queryCutDownPriceProductBoListByRecords(cutPriceUserRecordList); 225 List<CutDownPriceProductBo> cutProductBoList = cutDownPriceProductService.queryCutDownPriceProductBoListByRecords(cutPriceUserRecordList);
158 // 查询已砍价记录 226 // 查询已砍价记录
159 List<CutPriceHelpUserRequestBO> userRequestList = convert.convertFromList(cutPriceUserRecordList, CutPriceHelpUserRequestBO.class); 227 List<CutPriceHelpUserRequestBO> userRequestList = convert.convertFromList(cutPriceUserRecordList, CutPriceHelpUserRequestBO.class);
160 - List<CutDownPriceProductHelpUserBo> helpUserBoList = this.queryHelpInfoList(userRequestList); 228 + List<CutDownPriceProductHelpUserBo> helpUserBoList = this.queryHelpInfoList(uid, userRequestList);
161 // 根据skn列表查询商品信息 229 // 根据skn列表查询商品信息
162 BatchBaseRequest<Integer> productRequest = new BatchBaseRequest<Integer>(); 230 BatchBaseRequest<Integer> productRequest = new BatchBaseRequest<Integer>();
163 productRequest.setParams(Lists.newArrayList(productSkns)); 231 productRequest.setParams(Lists.newArrayList(productSkns));
@@ -170,11 +238,34 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -170,11 +238,34 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
170 } 238 }
171 239
172 @Override 240 @Override
  241 + public void addCutPriceUseRecord(CutPriceHelpUserRequestBO requestBO) {
  242 + try{
  243 + // 扣减可使用次数
  244 + int affectRow = cutDownPriceUserRecordMapper.updateDecreaseUseCount(requestBO.getUserId(), requestBO.getActivityId(), requestBO.getProductSkn());
  245 + if(affectRow<=0){
  246 + logger.warn("updateDecreaseUseCount success!!!,affectRow is:{} ", affectRow);
  247 + throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_YOU_HAS_USED_CUTDOWNORDER_ERROR);
  248 + }
  249 + }catch(DataIntegrityViolationException e){
  250 + throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_YOU_HAS_USED_CUTDOWNORDER_ERROR);
  251 + }
  252 + // 清理缓存
  253 + }
  254 +
  255 + @Override
  256 + public int cancelCutPriceUseRecord(CutPriceHelpUserRequestBO requestBO) {
  257 + // 回补可使用次数
  258 + int result = cutDownPriceUserRecordMapper.updateIncreaseUseCount(requestBO.getUserId(), requestBO.getActivityId(), requestBO.getProductSkn());
  259 + // 清理缓存
  260 + return result;
  261 + }
  262 +
  263 + @Override
173 public BigDecimal addHelpUserInfo(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) { 264 public BigDecimal addHelpUserInfo(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) {
174 Integer activityId = cutPriceHelpUserRequestBO.getActivityId(); 265 Integer activityId = cutPriceHelpUserRequestBO.getActivityId();
175 Integer productSkn = cutPriceHelpUserRequestBO.getProductSkn(); 266 Integer productSkn = cutPriceHelpUserRequestBO.getProductSkn();
176 Integer userId = cutPriceHelpUserRequestBO.getUserId(); 267 Integer userId = cutPriceHelpUserRequestBO.getUserId();
177 - String helpUserId = cutPriceHelpUserRequestBO.getHelpUserId(); 268 + Integer helpUserId = cutPriceHelpUserRequestBO.getHelpUserId();
178 269
179 //判断用户是否已经帮助砍价 270 //判断用户是否已经帮助砍价
180 Integer count = cutPriceUserHelpMapper.selectExistHelpInfo(userId, helpUserId, activityId, productSkn); 271 Integer count = cutPriceUserHelpMapper.selectExistHelpInfo(userId, helpUserId, activityId, productSkn);
@@ -199,8 +290,20 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -199,8 +290,20 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
199 CutDownPriceProductHelpUser helpUser = convertCutDownPriceProductHelpUser(cutPriceHelpUserRequestBO); 290 CutDownPriceProductHelpUser helpUser = convertCutDownPriceProductHelpUser(cutPriceHelpUserRequestBO);
200 helpUser.setCutPrice(cutPrice); 291 helpUser.setCutPrice(cutPrice);
201 helpUser.setCreateTime(DateUtils.getCurrentTimeSecond()); 292 helpUser.setCreateTime(DateUtils.getCurrentTimeSecond());
202 - // 插入表 293 + // 插入好友帮砍记录
203 cutPriceUserHelpMapper.addHelpUserInfo(helpUser); 294 cutPriceUserHelpMapper.addHelpUserInfo(helpUser);
  295 + // 修改用户发起砍价记录表中的帮砍次数
  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 + }
204 // 清理缓存,用户帮砍记录列表、商品详情页 307 // 清理缓存,用户帮砍记录列表、商品详情页
205 clearCache(activityId, productSkn, userId); 308 clearCache(activityId, productSkn, userId);
206 return cutPrice; 309 return cutPrice;
@@ -231,7 +334,16 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -231,7 +334,16 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
231 record.setProductSkn(productSkn); 334 record.setProductSkn(productSkn);
232 record.setUserId(userId); 335 record.setUserId(userId);
233 record.setCreateTime(DateUtils.getCurrentTimeSecond()); 336 record.setCreateTime(DateUtils.getCurrentTimeSecond());
  337 + logger.info(" addCutDownUserRecord, userId is {}, activityId is {}, productSkn is {}", userId, activityId, productSkn);
234 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 +
235 return num; 347 return num;
236 } 348 }
237 349
@@ -259,12 +371,17 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -259,12 +371,17 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
259 user.setUserId(request.getUserId()); 371 user.setUserId(request.getUserId());
260 user.setActivityId(request.getActivityId()); 372 user.setActivityId(request.getActivityId());
261 user.setProductSkn(request.getProductSkn()); 373 user.setProductSkn(request.getProductSkn());
262 - user.setHelpUserName(request.getHelpUserName());  
263 user.setHelpUserId(request.getHelpUserId()); 374 user.setHelpUserId(request.getHelpUserId());
264 - user.setHelpUserImgUrl(request.getHelpUserImgUrl());  
265 return user; 375 return user;
266 } 376 }
267 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 +
268 private BigDecimal calculateCutPrice(CutDownPriceProductBo cutDownPriceProductBo, List<CutDownPriceProductHelpUser> helpUsers) { 385 private BigDecimal calculateCutPrice(CutDownPriceProductBo cutDownPriceProductBo, List<CutDownPriceProductHelpUser> helpUsers) {
269 if(helpUsers==null){ 386 if(helpUsers==null){
270 helpUsers = new ArrayList<>(); 387 helpUsers = new ArrayList<>();
@@ -287,20 +404,49 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -287,20 +404,49 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
287 } 404 }
288 405
289 private void getUserInfo(Integer userId, List<CutDownPriceProductHelpUserBo> helpUserBos) { 406 private void getUserInfo(Integer userId, List<CutDownPriceProductHelpUserBo> helpUserBos) {
290 - List<Integer> uidList = new ArrayList<>();  
291 - uidList.add(userId);  
292 - AsyncFuture<UserBaseRspBO[]> userBaseRspBOArrAsync = drawlineList2MapService.postForUserBaseInfo(uidList);  
293 - UserBaseRspBO[] userBaseRspBOs = userBaseRspBOArrAsync.get(); 407 + StringBuilder sb = new StringBuilder();
  408 + sb.append(userId);
  409 + for (CutDownPriceProductHelpUserBo helpUserBo : helpUserBos){
  410 + if(null!=helpUserBo.getHelpUserId() && SYSTEM_HELP_ID!=helpUserBo.getHelpUserId()){
  411 + sb.append(",").append(helpUserBo.getHelpUserId());
  412 + }
  413 + }
  414 + UserInfoRspBO[] userInfoBoArray = invokeUicGetUserInfo(sb.toString());
  415 + for (CutDownPriceProductHelpUserBo helpUserBo : helpUserBos){
  416 + for (UserInfoRspBO userInfoRspBO : userInfoBoArray){
  417 + if(helpUserBo.getHelpUserId().equals(SYSTEM_HELP_ID)) {
  418 + helpUserBo.setHelpUserImgUrl(SYSTEM_HELP_IMAGE);
  419 + helpUserBo.setHelpUserName(SYSTEM_HELP_NAME);
  420 + break;
  421 + }else if (helpUserBo.getHelpUserId().equals(userInfoRspBO.getUid())){
  422 + helpUserBo.setHelpUserImgUrl(userInfoRspBO.getHeadIco());
  423 + helpUserBo.setHelpUserName(userInfoRspBO.getNickName());
  424 + break;
  425 + }
  426 + }
  427 + }
294 for (CutDownPriceProductHelpUserBo helpUserBo : helpUserBos){ 428 for (CutDownPriceProductHelpUserBo helpUserBo : helpUserBos){
295 - for (UserBaseRspBO userBaseRspBO : userBaseRspBOs){  
296 - if (helpUserBo.getUserId().equals(userBaseRspBO.getUid())){  
297 - helpUserBo.setUserImgUrl(userBaseRspBO.getHeadIco()); 429 + for (UserInfoRspBO userInfoRspBO : userInfoBoArray){
  430 + if (userId.equals(userInfoRspBO.getUid())){
  431 + helpUserBo.setUserImgUrl(userInfoRspBO.getHeadIco());
298 break; 432 break;
299 } 433 }
300 } 434 }
301 } 435 }
302 } 436 }
303 437
  438 + private UserInfoRspBO[] invokeUicGetUserInfo(String uids) {
  439 + if(StringUtils.isEmpty(uids)){
  440 + return new UserInfoRspBO[0];
  441 + }
  442 +
  443 + UicUserReqBO request = new UicUserReqBO();
  444 + request.setUids(uids);
  445 + logger.info("start invoke uic.getUserInfoListByYohoUid, uids is {}", uids);
  446 + UserInfoRspBO[] userInfoBoArray = serviceCaller.call("uic.getUserInfoListByYohoUid", request, UserInfoRspBO[].class);
  447 + return userInfoBoArray;
  448 + }
  449 +
304 private CutDownPriceActivityProductBo buildCutDownPriceActivityProductBo(CutDownPriceActivityBo activityBo, 450 private CutDownPriceActivityProductBo buildCutDownPriceActivityProductBo(CutDownPriceActivityBo activityBo,
305 CutDownPriceProductBo cutDownPriceProductBo, 451 CutDownPriceProductBo cutDownPriceProductBo,
306 List<CutDownPriceProductHelpUserBo> helpUserBos, 452 List<CutDownPriceProductHelpUserBo> helpUserBos,
@@ -315,21 +461,24 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -315,21 +461,24 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
315 activityProductBo.setHighPrice(cutDownPriceProductBo.getHighPrice()); 461 activityProductBo.setHighPrice(cutDownPriceProductBo.getHighPrice());
316 activityProductBo.setLowPrice(cutDownPriceProductBo.getLowPrice()); 462 activityProductBo.setLowPrice(cutDownPriceProductBo.getLowPrice());
317 activityProductBo.setJoinNum(cutDownPriceProductBo.getJoinNum()); 463 activityProductBo.setJoinNum(cutDownPriceProductBo.getJoinNum());
318 - Map<Integer, ProductBo> productBoMap = Arrays.asList(productBoArray).stream().parallel().collect(Collectors.toMap(ProductBo::getErpProductId, (p) -> p));  
319 -  
320 - ProductBo productBo = productBoMap.get(cutDownPriceProductBo.getProductSkn());  
321 - if(productBo!=null){  
322 - activityProductBo.setProductName(productBo.getProductName());  
323 - activityProductBo.setDefaultImages(productBo.getDefaultImageUrl()); 464 + if(ArrayUtils.isNotEmpty(productBoArray)){
  465 + Map<Integer, ProductBo> productBoMap = Arrays.asList(productBoArray).stream().parallel().collect(Collectors.toMap(ProductBo::getErpProductId, (p) -> p));
  466 + ProductBo productBo = productBoMap.get(cutDownPriceProductBo.getProductSkn());
  467 + if(productBo!=null){
  468 + activityProductBo.setProductName(productBo.getProductName());
  469 + activityProductBo.setDefaultImages(productBo.getDefaultImageUrl());
  470 + }
324 } 471 }
325 472
326 - BigDecimal hasCutPrice = new BigDecimal(0);  
327 - for(CutDownPriceProductHelpUserBo helpUserBo : helpUserBos){  
328 - hasCutPrice = hasCutPrice.add(helpUserBo.getCutPrice());  
329 - activityProductBo.setUserImgUrl(helpUserBo.getUserImgUrl());// 赋值一次就可以了 473 + if(CollectionUtils.isNotEmpty(helpUserBos)){
  474 + BigDecimal hasCutPrice = new BigDecimal(0);
  475 + for(CutDownPriceProductHelpUserBo helpUserBo : helpUserBos){
  476 + hasCutPrice = hasCutPrice.add(helpUserBo.getCutPrice());
  477 + activityProductBo.setUserImgUrl(helpUserBo.getUserImgUrl());// 赋值一次就可以了
  478 + }
  479 + activityProductBo.setHasCutPrice(hasCutPrice);
  480 + activityProductBo.setHasJoinNum(helpUserBos.size());
330 } 481 }
331 - activityProductBo.setHasCutPrice(hasCutPrice);  
332 - activityProductBo.setHasJoinNum(helpUserBos.size());  
333 return activityProductBo; 482 return activityProductBo;
334 } 483 }
335 484
@@ -384,9 +533,11 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -384,9 +533,11 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
384 533
385 // 清理缓存,用户帮砍记录列表、商品详情页 534 // 清理缓存,用户帮砍记录列表、商品详情页
386 private void clearCache(Integer activityId, Integer productSkn, Integer userId) { 535 private void clearCache(Integer activityId, Integer productSkn, Integer userId) {
387 - // 取缓存 536 + // 清理用户帮砍记录列表
388 String redisKeySuffix = userId + ":" + activityId + ":" + productSkn; 537 String redisKeySuffix = userId + ":" + activityId + ":" + productSkn;
389 redisValueCache.delete(CacheKeyEnum.CUTDOWN_PRICE_HELP_USERLIST_INFO, redisKeySuffix); 538 redisValueCache.delete(CacheKeyEnum.CUTDOWN_PRICE_HELP_USERLIST_INFO, redisKeySuffix);
  539 + // 清理我的砍价列表
  540 + redisHashCache.delete(CacheKeyEnum.CUTDOWN_PRICE_MYPRODUCTLIST_INFO.getCacheKey(), userId);
390 541
391 } 542 }
392 543
@@ -44,6 +44,9 @@ @@ -44,6 +44,9 @@
44 <value>/addCutPriceHelpUserInfo</value> 44 <value>/addCutPriceHelpUserInfo</value>
45 <value>/queryCutPriceHelpUserInfos</value> 45 <value>/queryCutPriceHelpUserInfos</value>
46 <value>/queryCutPriceProductForOrder</value> 46 <value>/queryCutPriceProductForOrder</value>
  47 + <value>/addCutPriceUseRecord</value>
  48 + <value>/cancelCutPriceUseRecord</value>
  49 + <value>/queryEffectCutPriceActivity</value>
47 </list> 50 </list>
48 </property> 51 </property>
49 <property name="excludeMethods"> 52 <property name="excludeMethods">