...
|
...
|
@@ -25,6 +25,7 @@ import org.springframework.stereotype.Service; |
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
...
|
...
|
@@ -58,26 +59,46 @@ public class ActivityServiceImpl implements IActivityService { |
|
|
//获取当前正在进行中活动
|
|
|
List<Activity> activityList = activityMapper.selectRunningActivity(DateUtil.getCurrentTimeSeconds());
|
|
|
if(CollectionUtils.isEmpty(activityList)){
|
|
|
logger.info("getPromotionActivityList: no running activity. productId is {}", productId);
|
|
|
return new ArrayList<>();
|
|
|
logger.warn("getActivityListForProduct: no running activity. productId {},businessClient {}", productId,businessClient);
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
//匹配对用购买渠道的活动(同一时间最多两个促销活动,闲鱼,ufo各一个)
|
|
|
List<Activity> businessClientActivityList = activityList.stream().filter(x -> StringUtils.isNotEmpty(x.getBusinessClient()) && x.getBusinessClient().contains(businessClient)).collect(Collectors.toList());
|
|
|
List<Activity> businessClientActivityList = activityList.stream()
|
|
|
.filter(x -> StringUtils.isNotEmpty(x.getBusinessClient()) && x.getBusinessClient().contains(businessClient))
|
|
|
.collect(Collectors.toList());
|
|
|
if(CollectionUtils.isEmpty(businessClientActivityList)){
|
|
|
logger.info("getPromotionActivityList: no running activity. productId is {}, businessClient is {}", productId, businessClient);
|
|
|
return new ArrayList<>();
|
|
|
logger.warn("getActivityListForProduct: no running activity. productId is {}, businessClient is {}", productId, businessClient);
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
Activity activity = businessClientActivityList.get(0);
|
|
|
|
|
|
|
|
|
List<PromotionActivityRspBo> list = new ArrayList<>();
|
|
|
for (Activity activity : businessClientActivityList){
|
|
|
if (checkScope(activity, productId)){
|
|
|
//获取这些活动列表相关的信息
|
|
|
PromotionActivityRspBo rspBo = buildSinglePromotionActivityRspBo(activity);
|
|
|
list.add(rspBo);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
private boolean checkScope(Activity activity, Integer productId){
|
|
|
//判断商品是否符合商品池限制条件(limitType: 1-包含商品池 2-不包含商品池)
|
|
|
ActivityProductScope productScope = activityProductScopeMapper.selectByActivityId(activity.getId());
|
|
|
if(productScope.getProductScopeType().equals(PromotionProductLimitEnum.POOL.getCode())) {
|
|
|
ProductPoolDetail productPoolDetail = productPoolDetailMapper.selectByPoolId(productId, Integer.valueOf(productScope.getLimitValues()));
|
|
|
if ((productScope.getLimitType() == 1 && productPoolDetail == null)
|
|
|
|| (productScope.getLimitType() == 2 && productPoolDetail != null)) {
|
|
|
logger.info("getPromotionActivityList: not in productScope. productId is {}, productPoolId is {}", productScope.getLimitValues());
|
|
|
return new ArrayList<>();
|
|
|
logger.info("check promotion Scope: not in productScope. productId is {}, productPoolId is {}", productScope.getLimitValues());
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
private PromotionActivityRspBo buildSinglePromotionActivityRspBo(Activity activity ){
|
|
|
//获取这些活动列表相关的信息
|
|
|
PromotionActivityRspBo rspBo = new PromotionActivityRspBo();
|
|
|
rspBo.setActivityName(activity.getActivityName());
|
...
|
...
|
@@ -88,16 +109,16 @@ public class ActivityServiceImpl implements IActivityService { |
|
|
rspBo.setPromotionType(activity.getPromotionType());
|
|
|
rspBo.setLabel(activity.getLabel());
|
|
|
rspBo.setPromotionTypeStr(null == activity.getPromotionType() ? "" : PromotionTypeEnum.getDescByCode(activity.getPromotionType()));
|
|
|
List<PromotionActivityRspBo> list = new ArrayList<>();
|
|
|
list.add(rspBo);
|
|
|
logger.info("getPromotionActivityList: end. productId is {}, activityId is {}", rspBo);
|
|
|
return list;
|
|
|
return rspBo;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public List<PromotionActivityRspBo> getActivityListForOrder() {
|
|
|
logger.info("getPromotionActivityList: enter");
|
|
|
//获取当前正在进行的活动,当前时间最多同时存在两个促销活动,ufo/闲鱼各一个
|
|
|
//from v-6.9.24 开始支持多个促销
|
|
|
List<Activity> activityList = activityMapper.selectRunningActivity(DateUtil.getCurrentTimeSeconds());
|
|
|
if(CollectionUtils.isEmpty(activityList)){
|
|
|
logger.info("getPromotionActivityList: no running activity ");
|
...
|
...
|
|