|
@@ -25,6 +25,7 @@ import org.springframework.stereotype.Service; |
|
@@ -25,6 +25,7 @@ import org.springframework.stereotype.Service; |
25
|
import org.springframework.util.CollectionUtils;
|
25
|
import org.springframework.util.CollectionUtils;
|
26
|
|
26
|
|
27
|
import java.util.ArrayList;
|
27
|
import java.util.ArrayList;
|
|
|
28
|
+import java.util.Collections;
|
28
|
import java.util.List;
|
29
|
import java.util.List;
|
29
|
import java.util.Objects;
|
30
|
import java.util.Objects;
|
30
|
import java.util.stream.Collectors;
|
31
|
import java.util.stream.Collectors;
|
|
@@ -58,26 +59,46 @@ public class ActivityServiceImpl implements IActivityService { |
|
@@ -58,26 +59,46 @@ public class ActivityServiceImpl implements IActivityService { |
58
|
//获取当前正在进行中活动
|
59
|
//获取当前正在进行中活动
|
59
|
List<Activity> activityList = activityMapper.selectRunningActivity(DateUtil.getCurrentTimeSeconds());
|
60
|
List<Activity> activityList = activityMapper.selectRunningActivity(DateUtil.getCurrentTimeSeconds());
|
60
|
if(CollectionUtils.isEmpty(activityList)){
|
61
|
if(CollectionUtils.isEmpty(activityList)){
|
61
|
- logger.info("getPromotionActivityList: no running activity. productId is {}", productId);
|
|
|
62
|
- return new ArrayList<>();
|
62
|
+ logger.warn("getActivityListForProduct: no running activity. productId {},businessClient {}", productId,businessClient);
|
|
|
63
|
+ return Collections.emptyList();
|
63
|
}
|
64
|
}
|
64
|
//匹配对用购买渠道的活动(同一时间最多两个促销活动,闲鱼,ufo各一个)
|
65
|
//匹配对用购买渠道的活动(同一时间最多两个促销活动,闲鱼,ufo各一个)
|
65
|
- List<Activity> businessClientActivityList = activityList.stream().filter(x -> StringUtils.isNotEmpty(x.getBusinessClient()) && x.getBusinessClient().contains(businessClient)).collect(Collectors.toList());
|
66
|
+ List<Activity> businessClientActivityList = activityList.stream()
|
|
|
67
|
+ .filter(x -> StringUtils.isNotEmpty(x.getBusinessClient()) && x.getBusinessClient().contains(businessClient))
|
|
|
68
|
+ .collect(Collectors.toList());
|
66
|
if(CollectionUtils.isEmpty(businessClientActivityList)){
|
69
|
if(CollectionUtils.isEmpty(businessClientActivityList)){
|
67
|
- logger.info("getPromotionActivityList: no running activity. productId is {}, businessClient is {}", productId, businessClient);
|
|
|
68
|
- return new ArrayList<>();
|
70
|
+ logger.warn("getActivityListForProduct: no running activity. productId is {}, businessClient is {}", productId, businessClient);
|
|
|
71
|
+ return Collections.emptyList();
|
69
|
}
|
72
|
}
|
70
|
- Activity activity = businessClientActivityList.get(0);
|
73
|
+
|
|
|
74
|
+
|
|
|
75
|
+ List<PromotionActivityRspBo> list = new ArrayList<>();
|
|
|
76
|
+ for (Activity activity : businessClientActivityList){
|
|
|
77
|
+ if (checkScope(activity, productId)){
|
|
|
78
|
+ //获取这些活动列表相关的信息
|
|
|
79
|
+ PromotionActivityRspBo rspBo = buildSinglePromotionActivityRspBo(activity);
|
|
|
80
|
+ list.add(rspBo);
|
|
|
81
|
+ }
|
|
|
82
|
+ }
|
|
|
83
|
+
|
|
|
84
|
+ return list;
|
|
|
85
|
+ }
|
|
|
86
|
+
|
|
|
87
|
+ private boolean checkScope(Activity activity, Integer productId){
|
71
|
//判断商品是否符合商品池限制条件(limitType: 1-包含商品池 2-不包含商品池)
|
88
|
//判断商品是否符合商品池限制条件(limitType: 1-包含商品池 2-不包含商品池)
|
72
|
ActivityProductScope productScope = activityProductScopeMapper.selectByActivityId(activity.getId());
|
89
|
ActivityProductScope productScope = activityProductScopeMapper.selectByActivityId(activity.getId());
|
73
|
if(productScope.getProductScopeType().equals(PromotionProductLimitEnum.POOL.getCode())) {
|
90
|
if(productScope.getProductScopeType().equals(PromotionProductLimitEnum.POOL.getCode())) {
|
74
|
ProductPoolDetail productPoolDetail = productPoolDetailMapper.selectByPoolId(productId, Integer.valueOf(productScope.getLimitValues()));
|
91
|
ProductPoolDetail productPoolDetail = productPoolDetailMapper.selectByPoolId(productId, Integer.valueOf(productScope.getLimitValues()));
|
75
|
if ((productScope.getLimitType() == 1 && productPoolDetail == null)
|
92
|
if ((productScope.getLimitType() == 1 && productPoolDetail == null)
|
76
|
|| (productScope.getLimitType() == 2 && productPoolDetail != null)) {
|
93
|
|| (productScope.getLimitType() == 2 && productPoolDetail != null)) {
|
77
|
- logger.info("getPromotionActivityList: not in productScope. productId is {}, productPoolId is {}", productScope.getLimitValues());
|
|
|
78
|
- return new ArrayList<>();
|
94
|
+ logger.info("check promotion Scope: not in productScope. productId is {}, productPoolId is {}", productScope.getLimitValues());
|
|
|
95
|
+ return false;
|
79
|
}
|
96
|
}
|
80
|
}
|
97
|
}
|
|
|
98
|
+ return true;
|
|
|
99
|
+ }
|
|
|
100
|
+
|
|
|
101
|
+ private PromotionActivityRspBo buildSinglePromotionActivityRspBo(Activity activity ){
|
81
|
//获取这些活动列表相关的信息
|
102
|
//获取这些活动列表相关的信息
|
82
|
PromotionActivityRspBo rspBo = new PromotionActivityRspBo();
|
103
|
PromotionActivityRspBo rspBo = new PromotionActivityRspBo();
|
83
|
rspBo.setActivityName(activity.getActivityName());
|
104
|
rspBo.setActivityName(activity.getActivityName());
|
|
@@ -88,16 +109,16 @@ public class ActivityServiceImpl implements IActivityService { |
|
@@ -88,16 +109,16 @@ public class ActivityServiceImpl implements IActivityService { |
88
|
rspBo.setPromotionType(activity.getPromotionType());
|
109
|
rspBo.setPromotionType(activity.getPromotionType());
|
89
|
rspBo.setLabel(activity.getLabel());
|
110
|
rspBo.setLabel(activity.getLabel());
|
90
|
rspBo.setPromotionTypeStr(null == activity.getPromotionType() ? "" : PromotionTypeEnum.getDescByCode(activity.getPromotionType()));
|
111
|
rspBo.setPromotionTypeStr(null == activity.getPromotionType() ? "" : PromotionTypeEnum.getDescByCode(activity.getPromotionType()));
|
91
|
- List<PromotionActivityRspBo> list = new ArrayList<>();
|
|
|
92
|
- list.add(rspBo);
|
|
|
93
|
- logger.info("getPromotionActivityList: end. productId is {}, activityId is {}", rspBo);
|
|
|
94
|
- return list;
|
112
|
+ return rspBo;
|
|
|
113
|
+
|
95
|
}
|
114
|
}
|
96
|
|
115
|
|
|
|
116
|
+
|
97
|
@Override
|
117
|
@Override
|
98
|
public List<PromotionActivityRspBo> getActivityListForOrder() {
|
118
|
public List<PromotionActivityRspBo> getActivityListForOrder() {
|
99
|
logger.info("getPromotionActivityList: enter");
|
119
|
logger.info("getPromotionActivityList: enter");
|
100
|
//获取当前正在进行的活动,当前时间最多同时存在两个促销活动,ufo/闲鱼各一个
|
120
|
//获取当前正在进行的活动,当前时间最多同时存在两个促销活动,ufo/闲鱼各一个
|
|
|
121
|
+ //from v-6.9.24 开始支持多个促销
|
101
|
List<Activity> activityList = activityMapper.selectRunningActivity(DateUtil.getCurrentTimeSeconds());
|
122
|
List<Activity> activityList = activityMapper.selectRunningActivity(DateUtil.getCurrentTimeSeconds());
|
102
|
if(CollectionUtils.isEmpty(activityList)){
|
123
|
if(CollectionUtils.isEmpty(activityList)){
|
103
|
logger.info("getPromotionActivityList: no running activity ");
|
124
|
logger.info("getPromotionActivityList: no running activity ");
|