Commit 1932b291 by xiaoer.li@freemud.com

Merge remote-tracking branch 'remotes/origin/feature/1.9.26_加车库存校验' into develop

# Conflicts:
#	assortment-ordercenter-sdk/pom.xml
#	assortment-ordercenter-sdk/readme.md
#	assortment-shoppingcart-sdk/pom.xml
#	assortment-shoppingcart-sdk/readme.md
#	order-application-service/pom.xml
#	order-management/pom.xml
#	ordercenter-sdk/pom.xml
#	ordercenter-sdk/readme.md
#	shopping-cart-application-service/pom.xml
parents 96eda8c9 c209442f
......@@ -10,7 +10,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>assortment-ordercenter-sdk</artifactId>
<version>1.9.4-SNAPSHOT</version>
<version>1.5.9-RELEASE</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
......@@ -26,7 +26,7 @@
<dependency>
<artifactId>couponcenter-sdk</artifactId>
<groupId>com.freemud.application.service.sdk</groupId>
<version>1.10.4-SNAPSHOT</version>
<version>1.9.2.RELEASE</version>
<scope>provided</scope>
</dependency>
<dependency>
......@@ -38,7 +38,7 @@
<dependency>
<groupId>cn.freemud</groupId>
<artifactId>ordercenter-sdk</artifactId>
<version>1.4.16-SNAPSHOT</version>
<version>1.3.1.RELEASE</version>
</dependency>
<dependency>
<groupId>com.freemud.application.service.sdk</groupId>
......
......@@ -10,7 +10,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>assortment-shoppingcart-sdk</artifactId>
<version>1.1.4-SNAPSHOT</version>
<version>1.1.2.RELEASE</version>
<dependencies>
<dependency>
......@@ -48,7 +48,7 @@
<dependency>
<groupId>com.freemud.application.service.sdk</groupId>
<artifactId>couponcenter-sdk</artifactId>
<version>1.8.15.RELEASE</version>
<version>1.9.2.RELEASE</version>
<scope>provided</scope>
</dependency>
<dependency>
......
......@@ -40,7 +40,7 @@
<dependency>
<groupId>cn.freemud</groupId>
<artifactId>assortment-ordercenter-sdk</artifactId>
<version>1.9.4-SNAPSHOT</version>
<version>1.5.9-RELEASE</version>
</dependency>
<dependency>
<groupId>com.freemud.application.service.sdk</groupId>
......@@ -58,6 +58,11 @@
<version>1.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>com.freemud.sdk.api.assortment</groupId>
<artifactId>assortment-promotion-sdk</artifactId>
<version>1.0.2-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>promotioncenter-sdk</artifactId>
<groupId>com.freemud.application.service.sdk</groupId>
<version>2.3.RELEASE</version>
......@@ -320,7 +325,7 @@
<dependency>
<groupId>com.freemud.sdk.api.assortment</groupId>
<artifactId>assortment-payment-sdk</artifactId>
<version>2.5.4-RELEASE</version>
<version>2.5.3-RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.rocketmq</groupId>
......
......@@ -52,13 +52,13 @@
<dependency>
<groupId>cn.freemud</groupId>
<artifactId>assortment-ordercenter-sdk</artifactId>
<version>1.9.2-SNAPSHOT</version>
<version>1.5.6-RELEASE</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.freemud.sdk.api.assortment</groupId>
<artifactId>assortment-payment-sdk</artifactId>
<version>2.5.4-RELEASE</version>
<version>2.4.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
......
......@@ -8,7 +8,7 @@
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<version>1.4.16-SNAPSHOT</version>
<version>1.3.2.RELEASE</version>
<artifactId>ordercenter-sdk</artifactId>
<dependencies>
......
......@@ -40,12 +40,12 @@
<dependency>
<groupId>com.freemud.application.service.sdk</groupId>
<artifactId>couponcenter-sdk</artifactId>
<version>1.8.15.RELEASE</version>
<version>1.9.2.RELEASE</version>
</dependency>
<dependency>
<groupId>cn.freemud</groupId>
<artifactId>assortment-shoppingcart-sdk</artifactId>
<version>1.1.4-SNAPSHOT</version>
<version>1.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>com.freemud.application.service.sdk</groupId>
......@@ -59,7 +59,7 @@
</dependency>
<dependency>
<groupId>com.freemud.application.service.sdk</groupId>
<version>2.8.1-SNAPSHOT</version>
<version>2.10.RELEASE</version>
<artifactId>storecenter-sdk</artifactId>
</dependency>
......
......@@ -133,7 +133,7 @@ public class FullPromotionService implements IPromotionService {
//设置没有加入购物车的提示语
private void setMessageNotInShoppingCart(StringBuilder messageBuilder, ActivityResponseDto activityResponseDto, List<BenefitBeanDto> benefitBeanDtos, BenefitBeanDto benefitBeanDto,
ArrayList<ActivityList> ActivityList) {
ArrayList<ActivityList> activityList) {
if (Objects.equals(ActivityTypeEnum.TYPE_11.getCode(), activityResponseDto.getActivityType())) {
messageBuilder.append("每满 <span style=\"color:#fa5555\">")
.append(WebUtil.formatAmount(benefitBeanDto.getThresholdAmount() * 1.00 / 100))
......@@ -150,7 +150,7 @@ public class FullPromotionService implements IPromotionService {
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);
activityList.add(notInShopping);
}
if (Objects.equals(ActivityTypeEnum.TYPE_12.getCode(), activityResponseDto.getActivityType())) {
int len = benefitBeanDtos.size();
......@@ -171,7 +171,7 @@ public class FullPromotionService implements IPromotionService {
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);
activityList.add(notInShopping);
}
}
}
......
......@@ -3,6 +3,7 @@ package cn.freemud.service.impl;
import cn.freemud.entities.dto.*;
import cn.freemud.entities.dto.activity.ActivityQueryDto;
import cn.freemud.entities.dto.activity.ActivityQueryResponseDto;
import cn.freemud.entities.vo.ActivityList;
import cn.freemud.enums.ActivityTypeEnum;
import cn.freemud.service.ActivityService;
import cn.freemud.utils.LogUtil;
......@@ -13,6 +14,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
......@@ -187,7 +189,8 @@ public class FullSubtractionActivityServiceImpl {
* @param calculationDiscountResult
* @return
*/
public PromotionMessageDto getFullPromotionActivityInfo(ActivityQueryDto activityQueryDto, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult) {
public PromotionMessageDto getFullPromotionActivityInfo(ActivityQueryDto activityQueryDto, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult,
ArrayList<ActivityList> activityList) {
ActivityQueryResponseDto activityQueryResponseDto = activityService.queryActivityByType(activityQueryDto, Arrays.asList(ActivityTypeEnum.TYPE_11, ActivityTypeEnum.TYPE_12), null);
if (activityQueryResponseDto == null) {
......@@ -225,6 +228,13 @@ public class FullSubtractionActivityServiceImpl {
.append("最高减 <span style=\"color:#fa5555\">")
.append(WebUtil.formatAmount(activityResponseDto.getMaxMoney() * 1.00 / 100))
.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())) {
int len = benefitBeanDtos.size();
......@@ -237,6 +247,16 @@ public class FullSubtractionActivityServiceImpl {
.append(WebUtil.formatAmount(benefitBeanDto.getDiscountAmount() * 1.00 / 100))
.append("</span> 元");
}
// 阶梯满减:满足 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);
}
}
} else {
List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ActivityPrompt> activityPrompts = calculationDiscountResult.getActivityPrompts();
......@@ -244,6 +264,7 @@ public class FullSubtractionActivityServiceImpl {
//加入商品满足购物车
if (CollectionUtils.isNotEmpty(activityPrompts)) {
ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ActivityPrompt activityPrompt = activityPrompts.get(0);
ActivityList satisfyList = new ActivityList();
if (activityPrompt.getAlreadyDiscountAmount() == null
|| activityPrompt.getAlreadyDiscountAmount() == 0) {
messageBuilder.append("满 <span style=\"color:#fa5555\">")
......@@ -254,6 +275,11 @@ public class FullSubtractionActivityServiceImpl {
.append("还差 <span style=\"color:#fa5555\">")
.append(WebUtil.formatAmount((activityPrompt.getThresholdAmount() - activityPrompt.getTotalAmount()) * 1.00 / 100))
.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 {
Long toDiscountAmout;
if (Objects.equals(ActivityTypeEnum.TYPE_11.getCode(), activityResponseDto.getActivityType())) {
......@@ -261,6 +287,7 @@ public class FullSubtractionActivityServiceImpl {
} else {
toDiscountAmout = activityPrompt.getDiscountAmout();
}
//已减 X 元 再买 Y 元 减 Z 元
messageBuilder.append("已减 <span style=\"color:#fa5555\">")
.append(WebUtil.formatAmount(activityPrompt.getAlreadyDiscountAmount() * 1.00 / 100))
.append("</span> 元 再买 <span style=\"color:#fa5555\">")
......@@ -268,6 +295,10 @@ public class FullSubtractionActivityServiceImpl {
.append("</span> 元减 <span style=\"color:#fa5555\">")
.append(WebUtil.formatAmount(toDiscountAmout * 1.00 / 100))
.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());
}
} else {
discountList = discountList.parallelStream().filter(k -> (Objects.equals(ActivityTypeEnum.TYPE_11.getCode(), k.getType())
......@@ -276,6 +307,11 @@ public class FullSubtractionActivityServiceImpl {
messageBuilder.append("已减 <span style=\"color:#fa5555\">")
.append(WebUtil.formatAmount(discountList.get(0).getDiscount() * 1.00 / 100))
.append("</span> 元");
//已减 X 元
ActivityList noSatisfy = new ActivityList();
noSatisfy.setTipType(5);
noSatisfy.setDeduct(WebUtil.formatAmount(discountList.get(0).getDiscount() * 1.00 / 100).toString());
activityList.add(noSatisfy);
}
}
}
......@@ -283,6 +319,4 @@ public class FullSubtractionActivityServiceImpl {
promotionMessageDto.setPromotionMessage(messageBuilder.toString());
return promotionMessageDto;
}
}
}
\ No newline at end of file
......@@ -248,8 +248,11 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
if (CollectionUtils.isEmpty(allCartGoodsList)) {
allCartGoodsList = new ArrayList<>();
}
Integer checkQty = allCartGoodsList.indexOf(cartGoods) != -1 ?
allCartGoodsList.get(allCartGoodsList.indexOf(cartGoods)).getQty() + cartGoods.getQty() : cartGoods.getQty();
/**
Integer checkQty = allCartGoodsList.indexOf(cartGoods) != -1 ?
allCartGoodsList.get(allCartGoodsList.indexOf(cartGoods)).getQty() + cartGoods.getQty() : cartGoods.getQty();
*/
Integer checkQty = this.checkSkuQty(allCartGoodsList, cartGoods);
//查询多个商品库存信息
queryManyGoodsStocks(addShoppingCartGoodsRequestVo, productIds, productBeanListSpuClass, skuId, checkQty);
......@@ -259,7 +262,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
// 当添加的商品不是商品券时
if (!spuId.startsWith(CommonsConstant.COUPON_PREFIX)) {
//添加非商品券商品
addNotProductGoods(addShoppingCartGoodsRequestVo, cartGoods, goodsId, userId, shoppingCartGoodsResponseVo, allCartGoodsList);
addNotProductGoods(addShoppingCartGoodsRequestVo, cartGoods, goodsId, userId, shoppingCartGoodsResponseVo, allCartGoodsList);
} else {
// 当商品是商品券,里面会判断如果购物车中已有商品券,会将cartGoods的CartGoodsUid设为null
this.addProductGoods(addShoppingCartGoodsRequestVo, cartGoods, spuId2, userId, shoppingCartGoodsResponseVo,
......@@ -534,13 +537,15 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo = new ShoppingCartGoodsResponseVo();
ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, shoppingCartClearRequestVo.getOrderType());
PromotionMessageDto promotionMessageDto = fullSubtractionActivityService.getFullPromotionActivityInfo(activityQueryDto, null);
ArrayList<ActivityList> activityList = new ArrayList<>();
PromotionMessageDto promotionMessageDto = fullSubtractionActivityService.getFullPromotionActivityInfo(activityQueryDto, null, activityList);
ActivityTip activityTip = new ActivityTip();
if (promotionMessageDto != null) {
activityTip.setActivityCode(promotionMessageDto.getActivityId());
activityTip.setActivityType(promotionMessageDto.getActivityType());
activityTip.setActivityName(promotionMessageDto.getPromotionMessage());
activityTip.setActivityList(activityList);
}
shoppingCartGoodsResponseVo.setActivityTip(activityTip);
shoppingCartGoodsResponseVo.setProducts(new ArrayList<>());
......@@ -1535,4 +1540,24 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
return sessionUserInfo.getResult();
}
/**
* 检查sku数量
*
* @param allCartGoodsList
* @param cartGoods
* @return
*/
private Integer checkSkuQty(List<CartGoods> allCartGoodsList, CartGoods cartGoods) {
Integer qty = 0;
if (allCartGoodsList == null) {
qty = cartGoods.getQty();
} else {
for (CartGoods goods : allCartGoodsList) {
if (goods.getSkuId().equals(cartGoods.getSkuId()) && goods.getSpuId().equals(cartGoods.getSpuId())) {
qty = qty + cartGoods.getQty();
}
}
}
return qty;
}
}
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