Commit 245c3559 by xiaoer.li@freemud.com

增加满减提示list

parent 525cfcc6
package cn.freemud.entities.vo;
import lombok.Data;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: cn.freemud.entities.vo ActivityListTip
* @Description:
* @author: family
* @date: 2020/5/28
* @Copyright: www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Data
public class ActivityList {
/*
购物车
- 空
- - 1 : 每满 : 满足 x 元 减 Y 元 ,最高 减 Z元
- - 满足 satisfy 减 deduct 最高减 maxDeduct
- - 2 : 阶梯满减:满足 X 元 减 Y 元,
- -满足 satisfy 减 deduct
- 有
- - 满足
- - 3 : 满足 X 元 减 Y 元 还差 Z元
- - 满足 satisfy 减 deduct 还差 missing
- - 4 : 已减 X 元 再买 Y 元 减 Z 元
- - 已减 alreadyDecut 再买againBuy 减 deduct
- - 不满足
- - 5 : 已减 X 元
- - 已减 deduct
*/
//提示类型
private Integer tipType;
//满足金额
private String satisfy;
//已减金额
private String deduct;
//最高扣减金额
private String maxDeduct;
//最高扣减金额
private String alreadyDecut;
//还差
private String missing;
//再买
private String againBuy;
//在减
private String agianDeduct;
}
...@@ -52,6 +52,7 @@ public class ActivityTip { ...@@ -52,6 +52,7 @@ public class ActivityTip {
* 200-X元Y件 * 200-X元Y件
*/ */
private Integer activityType; private Integer activityType;
private List<ActivityList> activityList;
/** /**
* *
*/ */
......
...@@ -9,17 +9,13 @@ import cn.freemud.enums.ActivityTypeEnum; ...@@ -9,17 +9,13 @@ import cn.freemud.enums.ActivityTypeEnum;
import cn.freemud.service.ActivityService; import cn.freemud.service.ActivityService;
import cn.freemud.service.IPromotionService; import cn.freemud.service.IPromotionService;
import cn.freemud.utils.WebUtil; import cn.freemud.utils.WebUtil;
import com.freemud.application.sdk.api.promotioncenter.request.promotion.UnifyActivityRequest;
import com.freemud.application.sdk.api.promotioncenter.service.PromotionSdkService; import com.freemud.application.sdk.api.promotioncenter.service.PromotionSdkService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.*;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -76,23 +72,23 @@ public class FullPromotionService implements IPromotionService { ...@@ -76,23 +72,23 @@ public class FullPromotionService implements IPromotionService {
promotionMessageDto.setActivityType(activityResponseDto.getActivityType()); promotionMessageDto.setActivityType(activityResponseDto.getActivityType());
promotionMessageDto.setPromotionAmount(0L); promotionMessageDto.setPromotionAmount(0L);
StringBuilder messageBuilder = new StringBuilder(); StringBuilder messageBuilder = new StringBuilder();
ArrayList<ActivityList> activityList = new ArrayList<>();
//没有加入购物车 //没有加入购物车
if (calculationDiscountResult == null) { if (calculationDiscountResult == null) {
// 因为没有促销活动的计算信息,所以没有加入购物车内 // 因为没有促销活动的计算信息,所以没有加入购物车内
List<BenefitBeanDto> benefitBeanDtos = activityResponseDto.getBenefits(); List<BenefitBeanDto> benefitBeanDtos = activityResponseDto.getBenefits();
BenefitBeanDto benefitBeanDto = benefitBeanDtos.get(0); BenefitBeanDto benefitBeanDto = benefitBeanDtos.get(0);
//调用没有加入购物车的提示语的方法 //调用没有加入购物车的提示语的方法
setMessageNotInShoppingCart(messageBuilder,activityResponseDto,benefitBeanDtos,benefitBeanDto); setMessageNotInShoppingCart(messageBuilder, activityResponseDto, benefitBeanDtos, benefitBeanDto, activityList);
}else{ }else{
//促销返回满减提示语 //促销返回满减提示语
List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ActivityPrompt> activityPrompts = calculationDiscountResult.getActivityPrompts(); List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ActivityPrompt> activityPrompts = calculationDiscountResult.getActivityPrompts();
List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Discount> discountList1 = calculationDiscountResult.getDiscounts(); List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Discount> discountList1 = calculationDiscountResult.getDiscounts();
//构建提示语 //构建提示语
if (CollectionUtils.isNotEmpty(activityPrompts)){ if (CollectionUtils.isNotEmpty(activityPrompts)){
setMessageSatisfyCart(messageBuilder,activityPrompts,activityResponseDto); setMessageSatisfyCart(messageBuilder, activityPrompts, activityResponseDto, activityList);
}else { }else {
setMessageNoSatisfyCart(messageBuilder,discountList1); setMessageNoSatisfyCart(messageBuilder, discountList1, activityList);
} }
} }
...@@ -101,6 +97,7 @@ public class FullPromotionService implements IPromotionService { ...@@ -101,6 +97,7 @@ public class FullPromotionService implements IPromotionService {
activityTip.setActivityCode(promotionMessageDto.getActivityId()); activityTip.setActivityCode(promotionMessageDto.getActivityId());
activityTip.setActivityType(promotionMessageDto.getActivityType()); activityTip.setActivityType(promotionMessageDto.getActivityType());
activityTip.setActivityName(promotionMessageDto.getPromotionMessage()); activityTip.setActivityName(promotionMessageDto.getPromotionMessage());
activityTip.setActivityList(activityList);
shoppingCartGoodsResponseVo.setActivityTip(activityTip); shoppingCartGoodsResponseVo.setActivityTip(activityTip);
if (calculationDiscountResult == null){ if (calculationDiscountResult == null){
return; return;
...@@ -135,7 +132,8 @@ public class FullPromotionService implements IPromotionService { ...@@ -135,7 +132,8 @@ public class FullPromotionService implements IPromotionService {
} }
//设置没有加入购物车的提示语 //设置没有加入购物车的提示语
private void setMessageNotInShoppingCart(StringBuilder messageBuilder, ActivityResponseDto activityResponseDto, List<BenefitBeanDto> benefitBeanDtos, BenefitBeanDto benefitBeanDto){ private void setMessageNotInShoppingCart(StringBuilder messageBuilder, ActivityResponseDto activityResponseDto, List<BenefitBeanDto> benefitBeanDtos, BenefitBeanDto benefitBeanDto,
ArrayList<ActivityList> ActivityList) {
if (Objects.equals(ActivityTypeEnum.TYPE_11.getCode(), activityResponseDto.getActivityType())) { if (Objects.equals(ActivityTypeEnum.TYPE_11.getCode(), activityResponseDto.getActivityType())) {
messageBuilder.append("每满 <span style=\"color:#fa5555\">") messageBuilder.append("每满 <span style=\"color:#fa5555\">")
.append(WebUtil.formatAmount(benefitBeanDto.getThresholdAmount() * 1.00 / 100)) .append(WebUtil.formatAmount(benefitBeanDto.getThresholdAmount() * 1.00 / 100))
...@@ -145,6 +143,14 @@ public class FullPromotionService implements IPromotionService { ...@@ -145,6 +143,14 @@ public class FullPromotionService implements IPromotionService {
.append("最高减 <span style=\"color:#fa5555\">") .append("最高减 <span style=\"color:#fa5555\">")
.append(WebUtil.formatAmount(activityResponseDto.getMaxMoney() * 1.00 / 100)) .append(WebUtil.formatAmount(activityResponseDto.getMaxMoney() * 1.00 / 100))
.append("</span> 元"); .append("</span> 元");
//满足 x 元 减 Y 元 ,最高 减 Z元
cn.freemud.entities.vo.ActivityList notInShopping = new ActivityList();
notInShopping.setTipType(1);
notInShopping.setSatisfy(WebUtil.formatAmount(benefitBeanDto.getThresholdAmount() * 1.00 / 100).toString());
notInShopping.setDeduct(WebUtil.formatAmount(benefitBeanDto.getDiscountAmount() * 1.00 / 100).toString());
notInShopping.setMaxDeduct(WebUtil.formatAmount(activityResponseDto.getMaxMoney() * 1.00 / 100).toString());
ActivityList.add(notInShopping);
} }
if (Objects.equals(ActivityTypeEnum.TYPE_12.getCode(), activityResponseDto.getActivityType())) { if (Objects.equals(ActivityTypeEnum.TYPE_12.getCode(), activityResponseDto.getActivityType())) {
int len = benefitBeanDtos.size(); int len = benefitBeanDtos.size();
...@@ -158,18 +164,29 @@ public class FullPromotionService implements IPromotionService { ...@@ -158,18 +164,29 @@ public class FullPromotionService implements IPromotionService {
.append("</span> 元"); .append("</span> 元");
if (i > 0) messageBuilder.append(","); if (i > 0) messageBuilder.append(",");
} }
// 阶梯满减:满足 X 元 减 Y 元,
for (int j = len - 1; j >= 0; j--) {
benefitBeanDto = benefitBeanDtos.get(j);
cn.freemud.entities.vo.ActivityList notInShopping = new ActivityList();
notInShopping.setTipType(2);
notInShopping.setSatisfy(WebUtil.formatAmount(benefitBeanDto.getThresholdAmount() * 1.00 / 100).toString());
notInShopping.setDeduct(WebUtil.formatAmount(benefitBeanDto.getDiscountAmount() * 1.00 / 100).toString());
ActivityList.add(notInShopping);
}
} }
} }
/** /**
* 设置加入商品满足购物车时的提示语 * 设置加入商品满足购物车时的提示语
*
* @param messageBuilder * @param messageBuilder
* @param activityPrompts * @param activityPrompts
* @param activityResponseDto * @param activityResponseDto
*/ */
private void setMessageSatisfyCart(StringBuilder messageBuilder,List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ActivityPrompt> activityPrompts private void setMessageSatisfyCart(StringBuilder messageBuilder, List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ActivityPrompt> activityPrompts
,ActivityResponseDto activityResponseDto){ , ActivityResponseDto activityResponseDto, ArrayList<ActivityList> activityList) {
ActivityList satisfyList = new ActivityList();
ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ActivityPrompt activityPrompt = activityPrompts.get(0); ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ActivityPrompt activityPrompt = activityPrompts.get(0);
if (activityPrompt.getAlreadyDiscountAmount() == null if (activityPrompt.getAlreadyDiscountAmount() == null
|| activityPrompt.getAlreadyDiscountAmount() == 0) { || activityPrompt.getAlreadyDiscountAmount() == 0) {
...@@ -181,6 +198,11 @@ public class FullPromotionService implements IPromotionService { ...@@ -181,6 +198,11 @@ public class FullPromotionService implements IPromotionService {
.append("还差 <span style=\"color:#fa5555\">") .append("还差 <span style=\"color:#fa5555\">")
.append(WebUtil.formatAmount((activityPrompt.getThresholdAmount() - activityPrompt.getTotalAmount()) * 1.00 / 100)) .append(WebUtil.formatAmount((activityPrompt.getThresholdAmount() - activityPrompt.getTotalAmount()) * 1.00 / 100))
.append("</span> 元"); .append("</span> 元");
// 满足 X 元 减 Y 元 还差 Z元
satisfyList.setTipType(3);
satisfyList.setSatisfy(WebUtil.formatAmount(activityPrompt.getThresholdAmount() * 1.00 / 100).toString());
satisfyList.setDeduct(WebUtil.formatAmount(activityPrompt.getDiscountAmout() * 1.00 / 100).toString());
satisfyList.setMissing(WebUtil.formatAmount((activityPrompt.getThresholdAmount() - activityPrompt.getTotalAmount()) * 1.00 / 100).toString());
} else { } else {
Long toDiscountAmout; Long toDiscountAmout;
if (Objects.equals(ActivityTypeEnum.TYPE_11.getCode(), activityResponseDto.getActivityType())) { if (Objects.equals(ActivityTypeEnum.TYPE_11.getCode(), activityResponseDto.getActivityType())) {
...@@ -188,6 +210,7 @@ public class FullPromotionService implements IPromotionService { ...@@ -188,6 +210,7 @@ public class FullPromotionService implements IPromotionService {
} else { } else {
toDiscountAmout = activityPrompt.getDiscountAmout(); toDiscountAmout = activityPrompt.getDiscountAmout();
} }
//已减 X 元 再买 Y 元 减 Z 元
messageBuilder.append("已减 <span style=\"color:#fa5555\">") messageBuilder.append("已减 <span style=\"color:#fa5555\">")
.append(WebUtil.formatAmount(activityPrompt.getAlreadyDiscountAmount() * 1.00 / 100)) .append(WebUtil.formatAmount(activityPrompt.getAlreadyDiscountAmount() * 1.00 / 100))
.append("</span> 元 再买 <span style=\"color:#fa5555\">") .append("</span> 元 再买 <span style=\"color:#fa5555\">")
...@@ -195,23 +218,33 @@ public class FullPromotionService implements IPromotionService { ...@@ -195,23 +218,33 @@ public class FullPromotionService implements IPromotionService {
.append("</span> 元减 <span style=\"color:#fa5555\">") .append("</span> 元减 <span style=\"color:#fa5555\">")
.append(WebUtil.formatAmount(toDiscountAmout * 1.00 / 100)) .append(WebUtil.formatAmount(toDiscountAmout * 1.00 / 100))
.append("</span> 元"); .append("</span> 元");
satisfyList.setTipType(4);
satisfyList.setDeduct(WebUtil.formatAmount(activityPrompt.getAlreadyDiscountAmount() * 1.00 / 100).toString());
satisfyList.setAgainBuy(WebUtil.formatAmount((activityPrompt.getThresholdAmount() - activityPrompt.getTotalAmount()) * 1.00 / 100).toString());
satisfyList.setAgianDeduct(WebUtil.formatAmount(toDiscountAmout * 1.00 / 100).toString());
} }
activityList.add(satisfyList);
} }
/** /**
* 设置加入商品不满足购物车时的提示语 * 设置加入商品不满足购物车时的提示语
*
* @param messageBuilder * @param messageBuilder
* @param discountList * @param discountList
*/ */
private void setMessageNoSatisfyCart(StringBuilder messageBuilder,List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Discount> discountList){ private void setMessageNoSatisfyCart(StringBuilder messageBuilder, List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Discount> discountList, ArrayList<ActivityList> activityList) {
discountList = discountList.parallelStream().filter(k -> (Objects.equals(ActivityTypeEnum.TYPE_11.getCode(), k.getType()) discountList = discountList.parallelStream().filter(k -> (Objects.equals(ActivityTypeEnum.TYPE_11.getCode(), k.getType())
|| Objects.equals(ActivityTypeEnum.TYPE_12.getCode(), k.getType()))).collect(Collectors.toList()); || Objects.equals(ActivityTypeEnum.TYPE_12.getCode(), k.getType()))).collect(Collectors.toList());
if (CollectionUtils.isEmpty(discountList)) { if (CollectionUtils.isEmpty(discountList)) {
return; return;
} }
//已减 X 元
messageBuilder.append("已减 <span style=\"color:#fa5555\">") messageBuilder.append("已减 <span style=\"color:#fa5555\">")
.append(WebUtil.formatAmount(discountList.get(0).getDiscount() * 1.00 / 100)) .append(WebUtil.formatAmount(discountList.get(0).getDiscount() * 1.00 / 100))
.append("</span> 元"); .append("</span> 元");
ActivityList noSatisfy = new ActivityList();
noSatisfy.setTipType(5);
noSatisfy.setDeduct(WebUtil.formatAmount(discountList.get(0).getDiscount() * 1.00 / 100).toString());
activityList.add(noSatisfy);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment