|
@@ -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
|
} |