Authored by wangshusheng

修改bug

@@ -5,7 +5,7 @@ import java.math.BigDecimal; @@ -5,7 +5,7 @@ import java.math.BigDecimal;
5 public class CutDownPriceProduct { 5 public class CutDownPriceProduct {
6 private Integer id; 6 private Integer id;
7 private Integer activityId; 7 private Integer activityId;
8 - private String productSkn; 8 + private Integer productSkn;
9 private Integer createTime; 9 private Integer createTime;
10 private Integer updateTime; 10 private Integer updateTime;
11 private Integer joinNum; 11 private Integer joinNum;
@@ -28,11 +28,11 @@ public class CutDownPriceProduct { @@ -28,11 +28,11 @@ public class CutDownPriceProduct {
28 this.activityId = activityId; 28 this.activityId = activityId;
29 } 29 }
30 30
31 - public String getProductSkn() { 31 + public Integer getProductSkn() {
32 return productSkn; 32 return productSkn;
33 } 33 }
34 34
35 - public void setProductSkn(String productSkn) { 35 + public void setProductSkn(Integer productSkn) {
36 this.productSkn = productSkn; 36 this.productSkn = productSkn;
37 } 37 }
38 38
@@ -2,8 +2,7 @@ @@ -2,8 +2,7 @@
2 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> 2 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 <mapper namespace="com.yoho.activity.dal.CutDownPriceActivityMapper"> 3 <mapper namespace="com.yoho.activity.dal.CutDownPriceActivityMapper">
4 <resultMap id="BaseResultMap" type="com.yoho.activity.dal.model.CutDownPriceActivity"> 4 <resultMap id="BaseResultMap" type="com.yoho.activity.dal.model.CutDownPriceActivity">
5 - <id column="id" jdbcType="INTEGER" property="id" />  
6 - <result column="activity_id" property="activityId" jdbcType="INTEGER" /> 5 + <id column="activity_id" jdbcType="INTEGER" property="activityId" />
7 <result column="activity_name" property="activityName" jdbcType="VARCHAR" /> 6 <result column="activity_name" property="activityName" jdbcType="VARCHAR" />
8 <result column="status" property="status" jdbcType="INTEGER" /> 7 <result column="status" property="status" jdbcType="INTEGER" />
9 <result column="begin_time" property="beginTime" jdbcType="INTEGER" /> 8 <result column="begin_time" property="beginTime" jdbcType="INTEGER" />
@@ -15,7 +14,7 @@ @@ -15,7 +14,7 @@
15 </resultMap> 14 </resultMap>
16 15
17 <sql id="Base_Column_List" > 16 <sql id="Base_Column_List" >
18 - id, 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
19 </sql> 18 </sql>
20 19
21 <select id="selectCutDownPriceActivity" resultMap="BaseResultMap"> 20 <select id="selectCutDownPriceActivity" resultMap="BaseResultMap">
@@ -30,7 +30,7 @@ @@ -30,7 +30,7 @@
30 from cutdown_price_product 30 from cutdown_price_product
31 where 31 where
32 <foreach collection="list" item="item" index="index" separator="OR"> 32 <foreach collection="list" item="item" index="index" separator="OR">
33 - (activity_id=#{item.activityId,jdbcType=INTEGER} and (product_skn=#{item.productSkn,jdbcType=INTEGER})) 33 + (activity_id=#{item.activityId,jdbcType=INTEGER} and product_skn=#{item.productSkn,jdbcType=INTEGER})
34 </foreach> 34 </foreach>
35 </select> 35 </select>
36 </mapper> 36 </mapper>
@@ -29,7 +29,7 @@ @@ -29,7 +29,7 @@
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) 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}, 30 values (#{userId,jdbcType=INTEGER}, #{helpUserId,jdbcType=VARCHAR}, #{helpUserName,jdbcType=VARCHAR},
31 #{helpUserImgUrl,jdbcType=VARCHAR}, #{activityId,jdbcType=INTEGER}, #{productSkn,jdbcType=INTEGER}, 31 #{helpUserImgUrl,jdbcType=VARCHAR}, #{activityId,jdbcType=INTEGER}, #{productSkn,jdbcType=INTEGER},
32 - #{cutPrice,jdbcType=DECIMAL}, current_timestamp() 32 + #{cutPrice,jdbcType=DECIMAL}, #{createTime,jdbcType=INTEGER}
33 ) 33 )
34 </insert> 34 </insert>
35 35
@@ -40,4 +40,15 @@ @@ -40,4 +40,15 @@
40 AND activity_id = #{activityId,jdbcType=INTEGER} 40 AND activity_id = #{activityId,jdbcType=INTEGER}
41 AND product_skn = #{productSkn,jdbcType=INTEGER} 41 AND product_skn = #{productSkn,jdbcType=INTEGER}
42 </select> 42 </select>
  43 +
  44 + <select id="selectHelpInfoList" resultMap="BaseResultMap" parameterType="java.util.List">
  45 + select
  46 + <include refid="Base_Column_List" />
  47 + from cutdown_price_help_user
  48 + where
  49 + <foreach collection="list" item="item" index="index" separator="OR">
  50 + (user_id = #{item.userId,jdbcType=INTEGER} and activity_id=#{item.activityId,jdbcType=INTEGER} and product_skn=#{item.productSkn,jdbcType=INTEGER})
  51 + </foreach>
  52 + </select>
  53 +
43 </mapper> 54 </mapper>
@@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
14 14
15 <insert id="addCutDownUserRecord" parameterType="com.yoho.activity.dal.model.CutDownPriceUserRecord"> 15 <insert id="addCutDownUserRecord" parameterType="com.yoho.activity.dal.model.CutDownPriceUserRecord">
16 insert into cutdown_price_user_record (user_id, activity_id, product_skn, create_time) 16 insert into cutdown_price_user_record (user_id, activity_id, product_skn, create_time)
17 - values (#{userId,jdbcType=INTEGER}, #{activityId,jdbcType=INTEGER}, #{productSkn,jdbcType=INTEGER}, current_timestamp() 17 + values (#{userId,jdbcType=INTEGER}, #{activityId,jdbcType=INTEGER}, #{productSkn,jdbcType=INTEGER}, #{createTime,jdbcType=INTEGER}
18 ) 18 )
19 </insert> 19 </insert>
20 20
@@ -21,11 +21,5 @@ public interface ICutDownPriceService { @@ -21,11 +21,5 @@ public interface ICutDownPriceService {
21 21
22 int addCutPriceRecord(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO); 22 int addCutPriceRecord(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO);
23 23
24 - Boolean judgeHelpUserExist(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO);  
25 -  
26 - void addShareInfo(LimitProductHelpUserRequestBO limitProductHelpUserRequestBO);  
27 -  
28 - Boolean judgeHelpUserNumMoreLimit(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO);  
29 -  
30 PageResponseBo<CutDownPriceActivityProductBo> queryMyCutPriceListByPage(CutDownProductQueryRequest request); 24 PageResponseBo<CutDownPriceActivityProductBo> queryMyCutPriceListByPage(CutDownProductQueryRequest request);
31 } 25 }
@@ -5,6 +5,7 @@ import com.yoho.activity.common.convert.BeanConvert; @@ -5,6 +5,7 @@ import com.yoho.activity.common.convert.BeanConvert;
5 import com.yoho.activity.common.redis.CacheKeyEnum; 5 import com.yoho.activity.common.redis.CacheKeyEnum;
6 import com.yoho.activity.common.redis.RedisHashCache; 6 import com.yoho.activity.common.redis.RedisHashCache;
7 import com.yoho.activity.common.redis.RedisValueCache; 7 import com.yoho.activity.common.redis.RedisValueCache;
  8 +import com.yoho.activity.common.utils.DateUtils;
8 import com.yoho.activity.dal.CutDownPriceUserHelpMapper; 9 import com.yoho.activity.dal.CutDownPriceUserHelpMapper;
9 import com.yoho.activity.dal.CutDownPriceUserRecordMapper; 10 import com.yoho.activity.dal.CutDownPriceUserRecordMapper;
10 import com.yoho.activity.dal.model.CutDownPriceProductHelpUser; 11 import com.yoho.activity.dal.model.CutDownPriceProductHelpUser;
@@ -76,11 +77,12 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -76,11 +77,12 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
76 List<CutDownPriceProductHelpUser> helpUsers = cutPriceUserHelpMapper.selectHelpInfo(userId, activityId, productSkn); 77 List<CutDownPriceProductHelpUser> helpUsers = cutPriceUserHelpMapper.selectHelpInfo(userId, activityId, productSkn);
77 if (CollectionUtils.isEmpty(helpUsers)){ 78 if (CollectionUtils.isEmpty(helpUsers)){
78 logger.info("CutDownPriceServiceImpl :: queryHelpInfo result is null"); 79 logger.info("CutDownPriceServiceImpl :: queryHelpInfo result is null");
79 - return null; 80 + return Lists.newArrayList();
80 } 81 }
81 List<CutDownPriceProductHelpUserBo> helpUsersBoList = convert.convertFromList(helpUsers, CutDownPriceProductHelpUserBo.class); 82 List<CutDownPriceProductHelpUserBo> helpUsersBoList = convert.convertFromList(helpUsers, CutDownPriceProductHelpUserBo.class);
82 //获取用户头像 83 //获取用户头像
83 getUserInfo(userId, helpUsersBoList); 84 getUserInfo(userId, helpUsersBoList);
  85 + helpUserWrapper = new CutDownPriceProductHelpUserWrapper();
84 helpUserWrapper.setHelpUserBoList(helpUsersBoList); 86 helpUserWrapper.setHelpUserBoList(helpUsersBoList);
85 redisValueCache.set(CacheKeyEnum.CUTDOWN_PRICE_HELP_USERLIST_INFO, redisKeySuffix, helpUserWrapper, 300, TimeUnit.SECONDS); 87 redisValueCache.set(CacheKeyEnum.CUTDOWN_PRICE_HELP_USERLIST_INFO, redisKeySuffix, helpUserWrapper, 300, TimeUnit.SECONDS);
86 return helpUserWrapper.getHelpUserBoList(); 88 return helpUserWrapper.getHelpUserBoList();
@@ -196,9 +198,11 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -196,9 +198,11 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
196 BigDecimal cutPrice = calculateCutPrice(cutDownPriceProductBo, helpUsers); 198 BigDecimal cutPrice = calculateCutPrice(cutDownPriceProductBo, helpUsers);
197 CutDownPriceProductHelpUser helpUser = convertCutDownPriceProductHelpUser(cutPriceHelpUserRequestBO); 199 CutDownPriceProductHelpUser helpUser = convertCutDownPriceProductHelpUser(cutPriceHelpUserRequestBO);
198 helpUser.setCutPrice(cutPrice); 200 helpUser.setCutPrice(cutPrice);
  201 + helpUser.setCreateTime(DateUtils.getCurrentTimeSecond());
199 // 插入表 202 // 插入表
200 cutPriceUserHelpMapper.addHelpUserInfo(helpUser); 203 cutPriceUserHelpMapper.addHelpUserInfo(helpUser);
201 - // 清理缓存 204 + // 清理缓存,用户帮砍记录列表、商品详情页
  205 + clearCache(activityId, productSkn, userId);
202 return cutPrice; 206 return cutPrice;
203 } 207 }
204 208
@@ -226,6 +230,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -226,6 +230,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
226 record.setActivityId(activityId); 230 record.setActivityId(activityId);
227 record.setProductSkn(productSkn); 231 record.setProductSkn(productSkn);
228 record.setUserId(userId); 232 record.setUserId(userId);
  233 + record.setCreateTime(DateUtils.getCurrentTimeSecond());
229 int num = cutDownPriceUserRecordMapper.addCutDownUserRecord(record); 234 int num = cutDownPriceUserRecordMapper.addCutDownUserRecord(record);
230 return num; 235 return num;
231 } 236 }
@@ -235,11 +240,11 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -235,11 +240,11 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
235 logger.warn(" the cutdown activity not exist, activityId is {}", activityId); 240 logger.warn(" the cutdown activity not exist, activityId is {}", activityId);
236 throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_ACTIVITY_NOTVALID_ERROR); 241 throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_ACTIVITY_NOTVALID_ERROR);
237 } 242 }
238 - if(activityBo.getBeginTime() > System.currentTimeMillis()){ 243 + if(activityBo.getBeginTime() > System.currentTimeMillis()/1000){
239 logger.warn(" the cutdown activity not start, activityId is {}", activityId); 244 logger.warn(" the cutdown activity not start, activityId is {}", activityId);
240 throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_ACTIVITY_NOTVALID_ERROR); 245 throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_ACTIVITY_NOTVALID_ERROR);
241 } 246 }
242 - if(activityBo.getEndTime() < System.currentTimeMillis()){ 247 + if(activityBo.getEndTime() < System.currentTimeMillis()/1000){
243 logger.warn(" the cutdown activity has end, activityId is {}", activityId); 248 logger.warn(" the cutdown activity has end, activityId is {}", activityId);
244 throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_ACTIVITY_NOTVALID_ERROR); 249 throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_ACTIVITY_NOTVALID_ERROR);
245 } 250 }
@@ -249,21 +254,6 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -249,21 +254,6 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
249 } 254 }
250 } 255 }
251 256
252 - @Override  
253 - public Boolean judgeHelpUserExist(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) {  
254 - return null;  
255 - }  
256 -  
257 - @Override  
258 - public void addShareInfo(LimitProductHelpUserRequestBO limitProductHelpUserRequestBO) {  
259 -  
260 - }  
261 -  
262 - @Override  
263 - public Boolean judgeHelpUserNumMoreLimit(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) {  
264 - return null;  
265 - }  
266 -  
267 private CutDownPriceProductHelpUser convertCutDownPriceProductHelpUser(CutPriceHelpUserRequestBO request) { 257 private CutDownPriceProductHelpUser convertCutDownPriceProductHelpUser(CutPriceHelpUserRequestBO request) {
268 CutDownPriceProductHelpUser user = new CutDownPriceProductHelpUser(); 258 CutDownPriceProductHelpUser user = new CutDownPriceProductHelpUser();
269 user.setUserId(request.getUserId()); 259 user.setUserId(request.getUserId());
@@ -284,7 +274,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -284,7 +274,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
284 BigDecimal shouldCutPrice = new BigDecimal(0); 274 BigDecimal shouldCutPrice = new BigDecimal(0);
285 BigDecimal hasCutPrice = new BigDecimal(0); 275 BigDecimal hasCutPrice = new BigDecimal(0);
286 for (CutDownPriceProductHelpUser helpUser : helpUsers){ 276 for (CutDownPriceProductHelpUser helpUser : helpUsers){
287 - hasCutPrice.add(helpUser.getCutPrice()); 277 + hasCutPrice = hasCutPrice.add(helpUser.getCutPrice());
288 } 278 }
289 int cutNum = helpUsers.size(); 279 int cutNum = helpUsers.size();
290 BigDecimal rangePrice = highPrice.subtract(hasCutPrice).subtract(lowPrice);//价格区间 280 BigDecimal rangePrice = highPrice.subtract(hasCutPrice).subtract(lowPrice);//价格区间
@@ -320,8 +310,8 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -320,8 +310,8 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
320 activityProductBo.setProductSkn(cutDownPriceProductBo.getProductSkn()); 310 activityProductBo.setProductSkn(cutDownPriceProductBo.getProductSkn());
321 activityProductBo.setBeginTime(activityBo.getBeginTime()); 311 activityProductBo.setBeginTime(activityBo.getBeginTime());
322 activityProductBo.setEndTime(activityBo.getEndTime()); 312 activityProductBo.setEndTime(activityBo.getEndTime());
323 - activityProductBo.setCurrentTime(System.currentTimeMillis());  
324 - 313 + activityProductBo.setCurrentTime(System.currentTimeMillis()/1000);
  314 + activityProductBo.setStatus(activityBo.getStatus());
325 activityProductBo.setHighPrice(cutDownPriceProductBo.getHighPrice()); 315 activityProductBo.setHighPrice(cutDownPriceProductBo.getHighPrice());
326 activityProductBo.setLowPrice(cutDownPriceProductBo.getLowPrice()); 316 activityProductBo.setLowPrice(cutDownPriceProductBo.getLowPrice());
327 activityProductBo.setJoinNum(cutDownPriceProductBo.getJoinNum()); 317 activityProductBo.setJoinNum(cutDownPriceProductBo.getJoinNum());
@@ -335,7 +325,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -335,7 +325,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
335 325
336 BigDecimal hasCutPrice = new BigDecimal(0); 326 BigDecimal hasCutPrice = new BigDecimal(0);
337 for(CutDownPriceProductHelpUserBo helpUserBo : helpUserBos){ 327 for(CutDownPriceProductHelpUserBo helpUserBo : helpUserBos){
338 - hasCutPrice.add(helpUserBo.getCutPrice()); 328 + hasCutPrice = hasCutPrice.add(helpUserBo.getCutPrice());
339 activityProductBo.setUserImgUrl(helpUserBo.getUserImgUrl());// 赋值一次就可以了 329 activityProductBo.setUserImgUrl(helpUserBo.getUserImgUrl());// 赋值一次就可以了
340 } 330 }
341 activityProductBo.setHasCutPrice(hasCutPrice); 331 activityProductBo.setHasCutPrice(hasCutPrice);
@@ -391,4 +381,13 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -391,4 +381,13 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
391 public void addToRedis(CacheKeyEnum keyEnum, Integer uid, Object value, String... param) { 381 public void addToRedis(CacheKeyEnum keyEnum, Integer uid, Object value, String... param) {
392 redisHashCache.put(keyEnum.getCacheKey(), uid, keyEnum.getHashKey(param), value, 300, TimeUnit.SECONDS); 382 redisHashCache.put(keyEnum.getCacheKey(), uid, keyEnum.getHashKey(param), value, 300, TimeUnit.SECONDS);
393 } 383 }
  384 +
  385 + // 清理缓存,用户帮砍记录列表、商品详情页
  386 + private void clearCache(Integer activityId, Integer productSkn, Integer userId) {
  387 + // 取缓存
  388 + String redisKeySuffix = userId + ":" + activityId + ":" + productSkn;
  389 + redisValueCache.delete(CacheKeyEnum.CUTDOWN_PRICE_HELP_USERLIST_INFO, redisKeySuffix);
  390 +
  391 + }
  392 +
394 } 393 }
@@ -26,7 +26,7 @@ redis.proxy.auth= @@ -26,7 +26,7 @@ redis.proxy.auth=
26 execute.timetask.host=192.168.90.9 26 execute.timetask.host=192.168.90.9
27 27
28 #zkAddress 28 #zkAddress
29 -zkAddress=127.0.0.1:2181 29 +zkAddress=192.168.102.45:2181
30 # web context 30 # web context
31 web.context=activity 31 web.context=activity
32 32
@@ -3,5 +3,3 @@ consumer: @@ -3,5 +3,3 @@ consumer:
3 username: yoho 3 username: yoho
4 password: yoho 4 password: yoho
5 consumers: 5 consumers:
6 - - class: com.yoho.product.syschronize.mq.consumer.PricePlanDeleteMessageConsumer  
7 - topic: price_plan_delete  
@@ -3,6 +3,4 @@ consumer: @@ -3,6 +3,4 @@ consumer:
3 username: ${rabbit_common_user} 3 username: ${rabbit_common_user}
4 password: ${rabbit_common_password} 4 password: ${rabbit_common_password}
5 consumers: 5 consumers:
6 - - class: com.yoho.product.syschronize.mq.consumer.PricePlanDeleteMessageConsumer  
7 - topic: price_plan_delete  
8 6