Commit 77299951 by xiaoer.li@freemud.com

商品加料

parent e3d343b4
......@@ -10,7 +10,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>assortment-shoppingcart-sdk</artifactId>
<version>1.1.3.RELEASE</version>
<version>1.1.3.731.RELEASE</version>
<dependencies>
<dependency>
......@@ -42,7 +42,7 @@
<dependency>
<groupId>com.freemud.application.service.sdk</groupId>
<artifactId>productcenter-sdk</artifactId>
<version>3.2.RELEASE</version>
<version>3.5.4-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
......@@ -54,7 +54,7 @@
<dependency>
<groupId>com.freemud.application.service.sdk</groupId>
<artifactId>sdk-common-base</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.4-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
......
......@@ -289,6 +289,7 @@ public class ShoppingCartAdapter {
skuSpecName = StringUtils.join(skuSpecValus, "/");
}
String attributeName = attributes.get(ATTRIBUTENAME) == null ? "" : attributes.get(ATTRIBUTENAME);
//购物车小标题
cartGoods.setSubName(StringUtils.isNotEmpty(skuSpecName) && StringUtils.isNotEmpty(attributeName) ?
skuSpecName + "/" + attributeName : skuSpecName + attributeName);
......@@ -320,12 +321,62 @@ public class ShoppingCartAdapter {
cartGoods.setWeight(isSkuProduct ? skuProduct.getWeight() : spuProduct.getWeight());
cartGoods.setUnit(isSkuProduct ? skuProduct.getUnit() : spuProduct.getUnit());
cartGoods.setWeightType(CommonsConstant.WEIGHT_PRODUCT.equals(spuProduct.getWeightType()));
// todo 设置加料
this.checkMaterialProduct(cartGoods, spuProduct);
} catch (Exception ex) {
ErrorLog.infoConvertJson(this.getClass(),"updateCartGoodsInfoNew_Error",ex);
ErrorLog.infoConvertJson(this.getClass(), "updateCartGoodsInfoNew_Error", ex);
cartGoods.setCartGoodsUid(null);
}
}
/**
* 单独处理加料
*
* @param cartGoods
* @param spuProduct
*/
private void checkMaterialProduct(CartGoods cartGoods, ProductBeanDTO spuProduct) {
if (CollectionUtils.isEmpty(cartGoods.getProductMaterialList())) return;
//加料信息为空
if (CollectionUtils.isEmpty(spuProduct.getAdditionalGroupList())) return;
//提取加料信息
List<ProductBeanDTO.ProductGroupType.GroupDetailType> groupDetail = spuProduct.getAdditionalGroupList().get(0).getGroupDetail();
HashMap<String, ProductBeanDTO.ProductGroupType.GroupDetailType> materialHash = new HashMap<>();
for (ProductBeanDTO.ProductGroupType.GroupDetailType groupDetailType : groupDetail) {
materialHash.put(groupDetailType.getProductId(), groupDetailType);
}
ArrayList<CartGoods.MaterialGoods> materialGoodsList = new ArrayList<>();
Long materialAmount = 0L;
Long originalMaterAmount = 0L;
String materialSubName = cartGoods.getSubName();
for (CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()) {
ProductBeanDTO.ProductGroupType.GroupDetailType detail = materialHash.get(materialGoods.getMaterialId());
if (detail == null) continue;
CartGoods.MaterialGoods material = new CartGoods.MaterialGoods();
material.setMaterialName(detail.getProductName());
material.setMaterialId(detail.getProductId());
//行单价 \ 行总价
material.setFinalPrice(detail.getProductFinalPrice().longValue());
material.setAmount(detail.getProductFinalPrice().longValue());
//原行单价*数量
material.setOriginalAmount(detail.getProductFinalPrice().longValue() * cartGoods.getQty());
material.setOriginalPrice(detail.getProductFinalPrice().longValue());
materialGoodsList.add(material);
materialAmount += detail.getProductFinalPrice().longValue() * cartGoods.getQty();
originalMaterAmount += detail.getProductFinalPrice().longValue() * cartGoods.getQty();
;
materialSubName = materialSubName + "/" + detail.getProductName();
}
//设置购物车行记录
cartGoods.setProductMaterialList(materialGoodsList);
cartGoods.setMaterialAmount(materialAmount);
cartGoods.setOriginalMaterialAmount(originalMaterAmount);
cartGoods.setOriginalAmount(cartGoods.getOriginalPrice() + originalMaterAmount);
cartGoods.setSubName(materialSubName);
}
private boolean updateComboxGoodsInfo(CartGoods cartGoods, CartGoods.ComboxGoods comboxGoods, ProductBeanDTO parentProductBean, List<ProductBeanDTO> productBeans, CartGoodsStates cartGoodsStates, List<String> invalidGoodsIdList) {
// 可选商品详情
Optional<ProductBeanDTO> firstProduct = productBeans.stream().filter(p -> ObjectUtils.equals(p.getPid(), comboxGoods.getGoodsId())).findFirst();
......
......@@ -14,6 +14,7 @@
package com.freemud.sdk.api.assortment.shoppingcart.domain;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
import java.util.Objects;
......@@ -70,12 +71,17 @@ public class CartGoods {
* 购物车一行商品的原总价
*/
private Long originalAmount;
//购物车一行小料商品的原总价
private Long originalMaterialAmount;
/**
* 购物车一行商品的现总价
*/
private Long amount;
/**
* 购物车加料商品总价
*/
private Long materialAmount;
/**
* 购物车一行商品的数量
*/
private Integer qty;
......@@ -161,6 +167,10 @@ public class CartGoods {
*/
private List<ComboxGoods> productGroupList;
/**
* 商品加料
*/
private List<MaterialGoods> productMaterialList;
@Data
public final static class CartGoodsExtra {
......@@ -209,6 +219,11 @@ public class CartGoods {
* 购物车一行商品的现价
*/
private Long amount;
/**
* 加料商品商品价格
*/
private Long materialAmount;
/**
* 购物车一行商品的数量
*/
......@@ -280,4 +295,32 @@ public class CartGoods {
public int hashCode() {
return Objects.hash(super.hashCode(), goodsId, goodsType, spuId, skuId, specProductId, originalPrice, packPrice, name, subName, pic, extra);
}
@Data
@NoArgsConstructor
public static class MaterialGoods {
/**
* 加料Id
*/
private String materialId;
/**
* 加料名称
*/
private String materialName;
/**
* 购物车一行商品的现单价
*/
private Long finalPrice;
/**
* 购物车一行商品的原单价
*/
private Long originalAmount;
private Long originalPrice;
/**
* 购物车一行商品的总现价
*/
private Long amount;
}
}
......@@ -155,7 +155,7 @@ public interface ShoppingCartBaseService {
}
checkCartRequest.getCartGoodsList().removeIf(k -> StringUtils.isEmpty(k.getCartGoodsUid()));
}
// Todo : 验证的商品信息
List<ProductBeanDTO> productList = valiadResult.getSuccessList().stream().map(ValiadShopProductResult::getProductType).collect(Collectors.toList());
CartGoodsStates cartGoodsStates = new CartGoodsStates();
for (CartGoods cartGoods : checkCartRequest.getCartGoodsList()) {
......
......@@ -30,12 +30,12 @@
<dependency>
<groupId>com.freemud.application.service.sdk</groupId>
<artifactId>sdk-common-base</artifactId>
<version>1.3.9-SNAPSHOT</version>
<version>1.4.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.freemud.application.service.sdk</groupId>
<artifactId>productcenter-sdk</artifactId>
<version>3.2.RELEASE</version>
<version>3.5.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.freemud.application.service.sdk</groupId>
......@@ -45,7 +45,7 @@
<dependency>
<groupId>cn.freemud</groupId>
<artifactId>assortment-shoppingcart-sdk</artifactId>
<version>1.1.3.RELEASE</version>
<version>1.1.3.731.RELEASE</version>
</dependency>
<dependency>
<groupId>com.freemud.application.service.sdk</groupId>
......
......@@ -111,9 +111,22 @@ public class ShoppingCartConvertAdapter {
} else if (cartGoods.isWeightType()) {
cartGoodsDetailDto.setProductType(ProductType.WEIGHT_PRODUCT.getCode());
}
if (cartGoods.getProductMaterialList().size() > 0) {
List<ShoppingCartGoodsDto.CartGoodsDetailDto.MaterialGoods> materialList = new ArrayList<>(0);
for (CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()) {
ShoppingCartGoodsDto.CartGoodsDetailDto.MaterialGoods goods = new ShoppingCartGoodsDto.CartGoodsDetailDto.MaterialGoods();
goods.setMaterialId(materialGoods.getMaterialId());
goods.setMaterialName(materialGoods.getMaterialName());
goods.setOriginalPrice(materialGoods.getOriginalPrice());
goods.setSalePrice(materialGoods.getFinalPrice());
materialList.add(goods);
}
cartGoodsDetailDto.setMaterialList(materialList);
}
// 设置总优惠&售价
List<ShoppingCartGoodsDto.CartGoodsDetailDto.CartGoodsExtra> cartGoodsExtras = BeanUtil.convertBeans(cartGoods.getExtra(), ShoppingCartGoodsDto.CartGoodsDetailDto.CartGoodsExtra::new);
cartGoodsDetailDto.setExtraList(cartGoodsExtras);
//61: 单品买M赠N \ 62:买赠 \ 6:买M赠N
if (ObjectUtils.equals(ActivityTypeEnum.TYPE_61.getCode(), cartGoods.getActivityType()) || ObjectUtils.equals(ActivityTypeEnum.TYPE_6.getCode(), cartGoods.getActivityType())
|| ObjectUtils.equals(ActivityTypeEnum.TYPE_62.getCode(), cartGoods.getActivityType())) {
cartGoodsDetailDto.setTotalDiscountAmount(cartGoods.getOriginalAmount().intValue() - cartGoods.getAmount().intValue());
......@@ -358,6 +371,8 @@ public class ShoppingCartConvertAdapter {
cartGoods.setCategoryName(addShoppingCartGoodsRequestVo.getCategoryName());
List<CartGoods.ComboxGoods> productComboList = new ArrayList<>();
List<CartGoods.ComboxGoods> productGroupList = new ArrayList<>();
List<CartGoods.MaterialGoods> materialGoodsList = new ArrayList<>();
//套餐
if (CollectionUtils.isNotEmpty(addShoppingCartGoodsRequestVo.getProductComboList())) {
for (ComboxGoodsRequestVo vo : addShoppingCartGoodsRequestVo.getProductComboList()) {
CartGoods.ComboxGoods productCombox = new CartGoods.ComboxGoods();
......@@ -368,6 +383,7 @@ public class ShoppingCartConvertAdapter {
productComboList.add(productCombox);
}
}
//固定商品组
if (CollectionUtils.isNotEmpty(addShoppingCartGoodsRequestVo.getProductGroupList())) {
for (ComboxGoodsRequestVo vo : addShoppingCartGoodsRequestVo.getProductGroupList()) {
CartGoods.ComboxGoods productCombox = new CartGoods.ComboxGoods();
......@@ -379,8 +395,17 @@ public class ShoppingCartConvertAdapter {
productGroupList.add(productCombox);
}
}
//加料商品集
if (CollectionUtils.isNotEmpty(addShoppingCartGoodsRequestVo.getProductMaterialList())) {
for (MaterialRequestVo materialRequestVo : addShoppingCartGoodsRequestVo.getProductMaterialList()) {
CartGoods.MaterialGoods materialGoods = new CartGoods.MaterialGoods();
materialGoods.setMaterialId(materialRequestVo.getMaterialId());
materialGoodsList.add(materialGoods);
}
}
cartGoods.setProductComboList(productComboList);
cartGoods.setProductGroupList(productGroupList);
cartGoods.setProductMaterialList(materialGoodsList);
return cartGoods;
}
......
package cn.freemud.entities.dto;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
import java.util.Objects;
......@@ -107,6 +108,10 @@ public class ActivityCalculationDiscountRequestDto {
* 例如8折为80
*/
private Integer memberDiscount;
/**
* 加料
*/
private List<Material> smallMaterial;
@Override
public boolean equals(Object o) {
......@@ -124,5 +129,26 @@ public class ActivityCalculationDiscountRequestDto {
public int hashCode() {
return Objects.hash(super.hashCode(), goodsId, category, originalPrice);
}
@Data
@NoArgsConstructor
static public class Material {
/**
* 加料商品ID
*/
private String goodsId;
/**
* 加料数量
*/
private Integer goodsQuantity;
/**
* 加料单价
*/
private Long originalPrice;
/**
* 1 :小料、2:可选搭配
*/
private int type;
}
}
}
......@@ -2,6 +2,7 @@ package cn.freemud.entities.dto;
import cn.freemud.entities.vo.SubtractStockVO;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
import java.util.Map;
......@@ -352,6 +353,7 @@ public class ActivityCalculationDiscountResponseDto {
private Integer apportionAmount;
private List<ApportionDetails> apportionDetails;
private List<Material> smallMaterial;
/**
* 购物车行记录
*/
......@@ -388,6 +390,41 @@ public class ActivityCalculationDiscountResponseDto {
*/
private Long activityApportionAmount;
}
@Data
@NoArgsConstructor
public static class Material {
/**
* 均摊金额
*/
private Integer apportionAmount;
/**
* 购物车行记录
*/
private String cartGoodsUid;
/**
* 商品id
*/
private String goodsId;
/**
* 商品数量
*/
private Integer goodsQuantity;
/**
* 赠送商品现价(单位:分)(加价换购时表示需要加的价格)
*/
private Long nowPrice;
/**
* 商品原价(分)
*/
private Long originalPrice;
private List<ApportionDetails> apportionDetails;
}
}
}
......
......@@ -240,6 +240,10 @@ public class ShoppingCartGoodsDto {
* 套餐子商品
*/
private List<CartGoodsDetailDto> comboProducts;
/**
* 加料商品
*/
private List<CartGoodsDetailDto.MaterialGoods> materialList = new ArrayList<>(0);
@Data
public final static class CartGoodsExtra {
......@@ -253,6 +257,31 @@ public class ShoppingCartGoodsDto {
private String attributeName;
}
@Data
public static class MaterialGoods {
/**
* 加料商品ID
*/
private String materialId;
private String materialName;
/**
* 商品行记录:当前元售价
*/
private Long originalPrice;
/**
* 商品行记录:当前售价
*/
private Long salePrice;
/**
* 商品行优惠总金额=数量*单个商品优惠金额
*/
private Integer totalDiscountAmount;
/**
* 当前商品享受的促销活动
*/
private List<ActivityDiscountsDto> activityDiscountsDtos;
}
/**
* 获取extras attributeNames
*/
......
......@@ -58,12 +58,15 @@ public class AddShoppingCartGoodsRequestVo extends BaseRequestVo{
*/
private List<ComboxGoodsRequestVo> productGroupList;
/**
* 加料
*/
private List<MaterialRequestVo> productMaterialList;
private String appType;
private String tableNumber;
/**
* 数量
* 数量
*/
private Integer qty;
......
......@@ -14,6 +14,7 @@
package cn.freemud.entities.vo;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
......@@ -59,29 +60,33 @@ public class CartGoods {
*/
private String specProductId;
/**
* 购物车一行商品的原单
* 购物车一行商品的原单
*/
private Long originalPrice;
/**
* 购物车一行商品的现单价
* 购物车一行商品的原单价总金额
*/
private Long finalPrice;
private Long originalAmount;
//购物车一行小料商品的原总价
private Long originalMaterialAmount;
/**
* 购物车一行商品的包装费
*/
private Long packPrice;
/**
* 购物车一行商品的原单价
*/
private Long originalAmount;
/**
* 购物车一行商品的现总价
*/
private Long amount;
/**
* 购物车一行商品的现单价
*/
private Long finalPrice;
/**
* 小料总金额
*/
private Long materialAmount;
/**
* 购物车一行商品的数量
*/
private Integer qty;
......@@ -167,6 +172,10 @@ public class CartGoods {
*/
private List<ComboxGoods> productGroupList;
/**
* 商品加料
*/
private List<MaterialGoods> productMaterialList;
@Data
public final static class CartGoodsExtra {
......@@ -364,4 +373,34 @@ public class CartGoods {
}
return hashWeight;
}
@Data
@NoArgsConstructor
public static class MaterialGoods {
/**
* 加料Id
*/
private String materialId;
/**
* 加料名称
*/
private String materialName;
/**
* 购物车一行商品的原单价
*/
private Long originalPrice;
/**
* 购物车一行商品的原价*数量
*/
private Long originalAmount;
/**
* 购物车一行商品的现售单价
*/
private Long finalPrice;
/**
* 购物车一行商品的现价*数量
*/
private Long amount;
}
}
package cn.freemud.entities.vo;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: cn.freemud.entities.vo MaterialRequestVo
* @Description: TDO 描述....
* @author: family
* @date: 2020/7/27
* @Copyright: www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Data
@NoArgsConstructor
public class MaterialRequestVo {
/**
* 加料商品ID
*/
private String materialId;
}
......@@ -17,9 +17,10 @@ public enum GoodsTypeEnum {
COMMON_GOODS(1, "正常商品"),
COUPON_GOODS(2, "商品券"),
SET_MEAL_GOODS(3,"套餐商品"),
SET_MEAL_GOODS(3, "套餐商品"),
SKU_GOODS(4, "sku商品"),
SPU_GOODS(5, "spu商品");
SPU_GOODS(5, "spu商品"),
MATERIAL(88, "有加料的商品");
private Integer goodsType;
private String desc;
......
......@@ -23,8 +23,9 @@ public enum ShoppingCartPromotionEnum {
SET_MEAL(7, "setMealService"),
XY_DISCOUNT(8, "xyDiscountService"),
TwoN_DISCOUNT(9, "twoNDiscountService"),
BUY_GIFTS(10,"buyAndGiftsPromotionService"),
MEMBER_DISCOUNT(11,"memberDiscountService");
BUY_GIFTS(10, "buyAndGiftsPromotionService"),
MEMBER_DISCOUNT(11, "memberDiscountService"),
Material(12, "MaterialPromotionService");
private Integer type;
private String msgType;
......
......@@ -248,7 +248,6 @@ public interface ShoppingCartNewService {
* @param userId
* @param shoppingCartGoodsResponseVo
* @param allCartGoodsList
* @param productBeanListSpuClass
*/
default void addNotProductGoods(AddShoppingCartGoodsRequestVo addShoppingCartGoodsRequestVo, CartGoods cartGoods
, String goodsId, String userId, ShoppingCartGoodsBaseResponseVo shoppingCartGoodsResponseVo, List<CartGoods> allCartGoodsList) {
......
package cn.freemud.service.impl;
import cn.freemud.entities.dto.ActivityCalculationDiscountResponseDto;
import cn.freemud.entities.dto.UserLoginInfoDto;
import cn.freemud.entities.dto.activity.ActivityDiscountsDto;
import cn.freemud.entities.dto.activity.ActivityQueryDto;
import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto;
import cn.freemud.entities.vo.*;
import cn.freemud.enums.ActivityTypeEnum;
import cn.freemud.enums.GoodsTypeEnum;
import cn.freemud.service.IPromotionService;
import com.google.common.collect.Lists;
import com.sun.tools.javac.comp.Check;
import lombok.Data;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: cn.freemud.service.impl MaterialPromotionImpl
* @Description: TDO 描述....
* @author: family
* @date: 2020/7/29
* @Copyright: www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Service("MaterialPromotionService")
public class MaterialPromotionService implements IPromotionService {
/**
* 总优惠和总原价促进已经计算过了,这里只需要累积行记录
* 加料优惠金额
*
* @param couponPromotionVO
* @param activityQueryDto
* @param calculationDiscountResult
* @param cartGoodsList
* @param shoppingCartGoodsResponseVo
* @param userLoginInfoDto
* @param shoppingCartInfoRequestVo
*/
@Override
public void updateShoppingCartGoodsDiscount(CouponPromotionVO couponPromotionVO, ActivityQueryDto activityQueryDto, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult, List<CartGoods> cartGoodsList, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, UserLoginInfoDto userLoginInfoDto, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) {
HashMap<String, ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ApportionGoods.Material> map = getApportionGoodsDetail(calculationDiscountResult);
if (map != null && !map.isEmpty()) {
for (CartGoods cartGoods : cartGoodsList) {
if (cartGoods.getProductMaterialList().size() == 0) continue;
for (CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()) {
ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ApportionGoods.Material material = map.get(materialGoods.getMaterialId());
//设置小料行单价和行总价
if (material.getNowPrice() > 0) {
materialGoods.setFinalPrice(material.getNowPrice());
materialGoods.setAmount(material.getNowPrice() * cartGoods.getQty());
}
}
}
}
long materialAmount = 0L;
for (CartGoods cartGoods : cartGoodsList) {
if (cartGoods.getProductMaterialList().size() == 0) continue;
materialAmount = 0L;
for (CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()) {
materialAmount += materialGoods.getFinalPrice() * cartGoods.getQty();
}
//设置商品行现总价 商品总价+小料商品总价
cartGoods.setAmount(cartGoods.getAmount() + materialAmount);
}
}
/**
* 加料商品设置行均摊记录
*
* @param shoppingCartGoodsResponseVo
* @param calculationDiscountResult
* @param shoppingCartGoodsDto
* @param premiumExchangeActivity
* @param shoppingCartInfoRequestVo
*/
@Override
public void updateShoppingCartGoodsApportion(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult, ShoppingCartGoodsDto shoppingCartGoodsDto, CreateOrderVo.PremiumExchangeActivity premiumExchangeActivity, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) {
HashMap<String, ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ApportionGoods.Material> map = getApportionGoodsDetail(calculationDiscountResult);
if (map == null && map.isEmpty()) return;
List<ShoppingCartGoodsDto.CartGoodsDetailDto> products = shoppingCartGoodsDto.getProducts();
for (ShoppingCartGoodsDto.CartGoodsDetailDto product : products) {
if (product.getMaterialList().size() == 0) return;
for (ShoppingCartGoodsDto.CartGoodsDetailDto.MaterialGoods materialGoods : product.getMaterialList()) {
ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ApportionGoods.Material material = map.get(materialGoods.getMaterialId());
if (material.getApportionAmount().intValue() == 0) continue;
//设置行记录参加的活动及总优惠
ActivityDiscountsDto activityDiscountsDto = new ActivityDiscountsDto();
List<ActivityDiscountsDto> activityDiscountsDtoList = new ArrayList<>();
activityDiscountsDto.setActivityCode(material.getApportionDetails().get(0).getActivityCode());
activityDiscountsDto.setActivityName(material.getApportionDetails().get(0).getActivityName());
activityDiscountsDto.setActivityType(material.getApportionDetails().get(0).getActivityType());
activityDiscountsDto.setDiscountAmount(material.getApportionDetails().get(0).getActivityApportionAmount().intValue());
activityDiscountsDtoList.add(activityDiscountsDto);
materialGoods.setActivityDiscountsDtos(activityDiscountsDtoList);
materialGoods.setTotalDiscountAmount((materialGoods.getOriginalPrice().intValue() - materialGoods.getSalePrice().intValue()) * product.getQty());
product.setProductType(GoodsTypeEnum.MATERIAL.getGoodsType());
}
}
}
/**
* 提取促销均摊
*
* @param calculationDiscountResult
* @return
*/
private HashMap<String, ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ApportionGoods.Material> getApportionGoodsDetail(ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult) {
// 遍历促销
if (calculationDiscountResult == null || CollectionUtils.isEmpty(calculationDiscountResult.getApportionGoods())) {
return null;
}
HashMap<String, ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ApportionGoods.Material> hashMap = new HashMap<>();
for (ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ApportionGoods apportionGood : calculationDiscountResult.getApportionGoods()) {
if (CollectionUtils.isEmpty(apportionGood.getSmallMaterial())) continue;
for (ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ApportionGoods.Material material : apportionGood.getSmallMaterial()) {
hashMap.put(material.getGoodsId(), material);
}
}
return hashMap;
}
}
......@@ -257,7 +257,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
//查询多个商品库存信息
queryManyGoodsStocks(addShoppingCartGoodsRequestVo, productIds, productBeanListSpuClass, skuId, checkQty);
ShoppingCartConvertAdapter.setClassification(cartGoods, productBeanListSpuClass);
//ShoppingCartConvertAdapter.setClassification(cartGoods, productBeanListSpuClass);
String productName = null;
// 当添加的商品不是商品券时
if (!spuId.startsWith(CommonsConstant.COUPON_PREFIX)) {
......@@ -744,7 +744,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
String cartGoodsUid = cartGoods.getCartGoodsUid();
// 商品不是商品券
if (!cartGoodsUid.startsWith(CommonsConstant.COUPON_PREFIX)) {
this.addCalculationDiscountGoods(calculationDiscountGoodsList, cartGoods.getGoodsId(), cartGoods.getQty(), cartGoods.getFinalPrice(), cartGoods.getMemberDiscount(), cartGoodsUid);
//this.addCalculationDiscountGoods(calculationDiscountGoodsList, cartGoods.getGoodsId(), cartGoods.getQty(), cartGoods.getFinalPrice(), cartGoods.getMemberDiscount(), cartGoodsUid);
this.addCalculationDiscountGoods(calculationDiscountGoodsList, cartGoods);
}
// 商品是商品券
else {
......@@ -835,6 +836,38 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
}
/**
* 促销增加
*
* @param calculationDiscountGoodsList
* @param cartGoods
*/
private void addCalculationDiscountGoods(List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList, CartGoods cartGoods) {
ActivityCalculationDiscountRequestDto.CalculationDiscountGoods calculationDiscountGoods = new ActivityCalculationDiscountRequestDto.CalculationDiscountGoods();
calculationDiscountGoods.setGoodsId(cartGoods.getGoodsId());
calculationDiscountGoods.setCartGoodsUid(cartGoods.getCartGoodsUid());
calculationDiscountGoods.setGoodsQuantity(cartGoods.getQty());
calculationDiscountGoods.setOriginalPrice(cartGoods.getFinalPrice());
calculationDiscountGoods.setMemberDiscount(cartGoods.getMemberDiscount());
//加料
if (cartGoods.getProductMaterialList().size() > 0) {
new ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material();
ArrayList<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material> materials = new ArrayList<>();
for (CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()) {
ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material material = new ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material();
material.setType(1);
material.setGoodsId(materialGoods.getMaterialId());
material.setGoodsQuantity(cartGoods.getQty());
material.setOriginalPrice(materialGoods.getFinalPrice());
materials.add(material);
}
calculationDiscountGoods.setSmallMaterial(materials);
}
this.addCalculationDiscountGoods(calculationDiscountGoodsList, calculationDiscountGoods);
}
/**
* 构建 ActivityCalculationDiscountRequestDto
*
* @param partnerId
......@@ -1059,7 +1092,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
shoppingCartGoodsResponseVo.setDiscountDeliveryAmount(deliveryAmount);
shoppingCartGoodsResponseVo.setIsDiscountDelivery(false);
}else{
} else {
String desc = DELIVERY_DISCOUNT_DESC3;
shoppingCartGoodsResponseVo.setDeliveryDiscountDesc(String.format(desc, df.format(deliveryAmount.doubleValue() / 100)));
shoppingCartGoodsResponseVo.setDeliveryAmount(deliveryAmount);
......@@ -1069,6 +1102,12 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
}
}
/**
* 加料
*/
MaterialPromotionService materialPromotionService = (MaterialPromotionService) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.Material);
materialPromotionService.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, userLoginInfoDto, shoppingCartInfoRequestVo);
}
/**
......@@ -1115,6 +1154,12 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
//xy折
BuyAndGiftsPromotionService buyAndGiftsPromotionService = (BuyAndGiftsPromotionService) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.BUY_GIFTS);
buyAndGiftsPromotionService.updateShoppingCartGoodsApportion(shoppingCartGoodsResponseVo, calculationDiscountResult, shoppingCartGoodsDto, premiumExchangeActivity, shoppingCartInfoRequestVo);
/**
* 设置加料商品行记录
*/
MaterialPromotionService materialPromotionService = (MaterialPromotionService) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.Material);
materialPromotionService.updateShoppingCartGoodsApportion(shoppingCartGoodsResponseVo, calculationDiscountResult, shoppingCartGoodsDto, premiumExchangeActivity, shoppingCartInfoRequestVo);
}
......
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