Commit 1c2f8473 by zhiheng.zhang

Merge remote-tracking branch 'origin/develop' into develop

parents 7c48f3bb ec846be5
...@@ -2564,10 +2564,13 @@ public class OrderSdkAdapter { ...@@ -2564,10 +2564,13 @@ public class OrderSdkAdapter {
for (CreateOrderProductRequest productRequest : products) { for (CreateOrderProductRequest productRequest : products) {
// 普通商品 订单转换 // 普通商品 订单转换
productRequest.setOpid(index); productRequest.setOpid(index);
originalAmount += updateOrderItemAndSettlement(orderItemList, orderSettlementCreateReqList, productRequest, partnerId, "");
if (ProductTypeEnum.MATERIAL_PRODUCT.getCode().equals(productRequest.getProductType())) { if (ProductTypeEnum.MATERIAL_PRODUCT.getCode().equals(productRequest.getProductType())) {
originalAmount += updateOrderItemAndSettlement(orderItemList, orderSettlementCreateReqList, productRequest, partnerId, productRequest.getParentProductId()); if (CollectionUtils.isNotEmpty(productRequest.getMaterialProduct())) {
} else { productRequest.getMaterialProduct().stream().forEach(
originalAmount += updateOrderItemAndSettlement(orderItemList, orderSettlementCreateReqList, productRequest, partnerId, ""); material -> updateOrderItemAndSettlement(orderItemList, orderSettlementCreateReqList, material, partnerId, productRequest.getProductId())
);
}
} }
// 如果是套餐商品,需要转换当前商品行子集ComboProduct&GroupProduct(固定商品、可选商品) // 如果是套餐商品,需要转换当前商品行子集ComboProduct&GroupProduct(固定商品、可选商品)
if (ObjectUtils.equals(ProductTypeEnum.SETMEAL_PRODUCT.getCode(), productRequest.getProductType()) || ObjectUtils.equals(ProductTypeEnum.SETMEAL_UPPRICE_PRODUCT.getCode(), productRequest.getProductType())) { if (ObjectUtils.equals(ProductTypeEnum.SETMEAL_PRODUCT.getCode(), productRequest.getProductType()) || ObjectUtils.equals(ProductTypeEnum.SETMEAL_UPPRICE_PRODUCT.getCode(), productRequest.getProductType())) {
......
...@@ -134,6 +134,10 @@ public class CreateOrderProductRequest extends BaseConfig { ...@@ -134,6 +134,10 @@ public class CreateOrderProductRequest extends BaseConfig {
*/ */
private List<CreateOrderProductRequest> comboProduct; private List<CreateOrderProductRequest> comboProduct;
/** /**
*加料商品
*/
private List<CreateOrderProductRequest> materialProduct;
/**
* 优惠列表 * 优惠列表
*/ */
private List<CreateOrderAccountRequest> accounts; private List<CreateOrderAccountRequest> accounts;
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>assortment-shoppingcart-sdk</artifactId> <artifactId>assortment-shoppingcart-sdk</artifactId>
<version>1.1.7-SNAPSHOT</version> <version>1.1.8-SNAPSHOT</version>
<dependencies> <dependencies>
<dependency> <dependency>
......
...@@ -6,4 +6,4 @@ ...@@ -6,4 +6,4 @@
| 1.1.2-SNAPSHOT| 券码接口新增参数:channelCodeList | 梁崇福 | 2020-05-13 | | 1.1.2-SNAPSHOT| 券码接口新增参数:channelCodeList | 梁崇福 | 2020-05-13 |
| 1.1.4-SNAPSHOT| 券码接口修改为channel_codes | 梁崇福 | 2020-06-08 | | 1.1.4-SNAPSHOT| 券码接口修改为channel_codes | 梁崇福 | 2020-06-08 |
| 1.1.5-SNAPSHOT| 增加统计分类编号:classificationId,classificationName | | 2020-06-12 | | 1.1.5-SNAPSHOT| 增加统计分类编号:classificationId,classificationName | | 2020-06-12 |
| 1.1.7-SNAPSHOT| 加料 | 李小二 | 2020-07-30 | | 1.1.8-SNAPSHOT| 加料 | 李小二 | 2020-07-30 |
\ No newline at end of file \ No newline at end of file
...@@ -352,11 +352,11 @@ public class ShoppingCartAdapter { ...@@ -352,11 +352,11 @@ public class ShoppingCartAdapter {
Long originalMaterAmount = 0L; Long originalMaterAmount = 0L;
String materialSubName = cartGoods.getSubName(); String materialSubName = cartGoods.getSubName();
for (CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()) { for (CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()) {
ProductBeanDTO.ProductGroupType.GroupDetailType detail = materialHash.get(materialGoods.getMaterialId()); ProductBeanDTO.ProductGroupType.GroupDetailType detail = materialHash.get(materialGoods.getSpuId());
if (detail == null) continue; if (detail == null) continue;
CartGoods.MaterialGoods material = new CartGoods.MaterialGoods(); CartGoods.MaterialGoods material = new CartGoods.MaterialGoods();
material.setMaterialName(detail.getProductName()); material.setSpuName(detail.getProductName());
material.setMaterialId(detail.getProductId()); material.setSpuId(detail.getProductId());
//行单价 \ 行总价 //行单价 \ 行总价
material.setFinalPrice(detail.getProductFinalPrice().longValue()); material.setFinalPrice(detail.getProductFinalPrice().longValue());
material.setAmount(detail.getProductFinalPrice().longValue()); material.setAmount(detail.getProductFinalPrice().longValue());
......
...@@ -302,11 +302,11 @@ public class CartGoods { ...@@ -302,11 +302,11 @@ public class CartGoods {
/** /**
* 加料Id * 加料Id
*/ */
private String materialId; private String spuId;
/** /**
* 加料名称 * 加料名称
*/ */
private String materialName; private String spuName;
/** /**
* 购物车一行商品的现单价 * 购物车一行商品的现单价
*/ */
......
...@@ -143,19 +143,12 @@ public class OrderAdapter { ...@@ -143,19 +143,12 @@ public class OrderAdapter {
// 根据购物车商品信息获取优惠信息 // 根据购物车商品信息获取优惠信息
int orderAccountIndex = 0; int orderAccountIndex = 0;
// TODO 取出加料信息
for (ShoppingCartGoodsDto.CartGoodsDetailDto cartGoodsDetailDto : cartGoodsDetailDtos) { for (ShoppingCartGoodsDto.CartGoodsDetailDto cartGoodsDetailDto : cartGoodsDetailDtos) {
Integer qty = cartGoodsDetailDto.getQty(); Integer qty = cartGoodsDetailDto.getQty();
if (qty > 0) { if (qty > 0) {
CreateOrderProductRequest createOrderProductDto = convent2OrderProduct(cartGoodsDetailDto); CreateOrderProductRequest createOrderProductDto = convent2OrderProduct(cartGoodsDetailDto);
createOrderProductDto.setIgnoreProductPrice(1); createOrderProductDto.setIgnoreProductPrice(1);
products.add(createOrderProductDto); products.add(createOrderProductDto);
if (CollectionUtils.isNotEmpty(cartGoodsDetailDto.getMaterialList())) {
cartGoodsDetailDto.getMaterialList().stream().forEach(p -> {
CreateOrderProductRequest orderProductDto = convent2OrderProductByMaterial(cartGoodsDetailDto, p);
products.add(orderProductDto);
});
}
if (CollectionUtils.isNotEmpty(cartGoodsDetailDto.getActivityDiscountsDtos())) { if (CollectionUtils.isNotEmpty(cartGoodsDetailDto.getActivityDiscountsDtos())) {
createOrderProductDto.setAccounts(getAccounts(createOrderProductDto, cartGoodsDetailDto.getActivityDiscountsDtos())); createOrderProductDto.setAccounts(getAccounts(createOrderProductDto, cartGoodsDetailDto.getActivityDiscountsDtos()));
} }
...@@ -258,18 +251,6 @@ public class OrderAdapter { ...@@ -258,18 +251,6 @@ public class OrderAdapter {
return createOrderDto; return createOrderDto;
} }
private CreateOrderProductRequest convent2OrderProductByMaterial(ShoppingCartGoodsDto.CartGoodsDetailDto goodsDetail, ShoppingCartGoodsDto.CartGoodsDetailDto.CartGoodsMaterial material) {
CreateOrderProductRequest createOrderProductRequest = new CreateOrderProductRequest();
createOrderProductRequest.setParentProductId(goodsDetail.getSpuId());
createOrderProductRequest.setProductId(material.getMaterialId());
createOrderProductRequest.setProductName(material.getMaterialName());
createOrderProductRequest.setPrice(material.getOriginalPrice());
createOrderProductRequest.setSalePrice(material.getSalePrice());
createOrderProductRequest.setTotalDiscountAmount(material.getTotalDiscountAmount());
createOrderProductRequest.setNumber(goodsDetail.getQty());
return createOrderProductRequest;
}
public CreateFatherSonOrderRequest convertFatherSonOrderRequest(CreateOrderVo createOrderVo, ShoppingCartGoodsDto shoppingCartGoodsDto, public CreateFatherSonOrderRequest convertFatherSonOrderRequest(CreateOrderVo createOrderVo, ShoppingCartGoodsDto shoppingCartGoodsDto,
OrderExtendedReq orderExtendedReq,StoreResponse.BizVO storeResponseDto, OrderExtendedReq orderExtendedReq,StoreResponse.BizVO storeResponseDto,
String appId) { String appId) {
...@@ -1561,29 +1542,40 @@ public class OrderAdapter { ...@@ -1561,29 +1542,40 @@ public class OrderAdapter {
switch (orderBean.getStatus()) { switch (orderBean.getStatus()) {
// 未接单 // 未接单
case 1: case 1:
orderRefund = configMap.get(OrderRefundEnum.TAKEORDER_REFUND.getKeyValue()); //区分外卖单和到店订单,判断是否可以退款
if(OrderType.TAKE_OUT.getCode().equals(orderBean.getOrderType())) {
orderRefund = configMap.get(OrderRefundEnum.DELIVERY_TAKE_ORDER_REFUND.getKeyValue());
}else {
orderRefund = configMap.get(OrderRefundEnum.TAKEORDER_REFUND.getKeyValue());
}
if (orderRefund == null || (orderRefund != null && ALLOW_REFUND.equals(orderRefund.getAppValue()))) { if (orderRefund == null || (orderRefund != null && ALLOW_REFUND.equals(orderRefund.getAppValue()))) {
canRefund = true; canRefund = true;
} }
break; break;
//已接单 //已接单
case 3: case 3:
orderRefund = configMap.get(OrderRefundEnum.RECEIPTORDER_REFUND.getKeyValue()); if(OrderType.TAKE_OUT.getCode().equals(orderBean.getOrderType())) {
orderRefund = configMap.get(OrderRefundEnum.DELIVERY_RECEIPT_ORDER_REFUND.getKeyValue());
}else {
orderRefund = configMap.get(OrderRefundEnum.RECEIPTORDER_REFUND.getKeyValue());
}
if (orderRefund == null || (orderRefund != null && ALLOW_REFUND.equals(orderRefund.getAppValue()))) { if (orderRefund == null || (orderRefund != null && ALLOW_REFUND.equals(orderRefund.getAppValue()))) {
canRefund = true; canRefund = true;
} }
break; break;
//制作完成 //制作完成
case 31: case 31:
orderRefund = configMap.get(OrderRefundEnum.COMPLETEMAKEORDER_REFUND.getKeyValue()); if(OrderType.TAKE_OUT.getCode().equals(orderBean.getOrderType())) {
orderRefund = configMap.get(OrderRefundEnum.DELIVERY_COMPLETE_MAKE_ORDER_REFUND.getKeyValue());
}else {
orderRefund = configMap.get(OrderRefundEnum.COMPLETEMAKEORDER_REFUND.getKeyValue());
}
if (orderRefund != null && ALLOW_REFUND.equals(orderRefund.getAppValue())) { if (orderRefund != null && ALLOW_REFUND.equals(orderRefund.getAppValue())) {
canRefund = true; canRefund = true;
} }
break; break;
// 订单完成 // 订单完成
case 5: case 5:
orderRefund = configMap.get(OrderRefundEnum.ORDER_REFUND.getKeyValue());
long currentTime = System.currentTimeMillis(); long currentTime = System.currentTimeMillis();
long gmtModified = orderBean.getGmtModified(); long gmtModified = orderBean.getGmtModified();
...@@ -1595,6 +1587,11 @@ public class OrderAdapter { ...@@ -1595,6 +1587,11 @@ public class OrderAdapter {
} }
long allowRefundTime = gmtModified + value * 24 * 60 * 60 * 1000; long allowRefundTime = gmtModified + value * 24 * 60 * 60 * 1000;
if(OrderType.TAKE_OUT.getCode().equals(orderBean.getOrderType())) {
orderRefund = configMap.get(OrderRefundEnum.DELIVERY_ORDER_REFUND.getKeyValue());
}else {
orderRefund = configMap.get(OrderRefundEnum.ORDER_REFUND.getKeyValue());
}
if (orderRefund != null && ALLOW_REFUND.equals(orderRefund.getAppValue()) && (allowRefundTime - currentTime) >= 0) { if (orderRefund != null && ALLOW_REFUND.equals(orderRefund.getAppValue()) && (allowRefundTime - currentTime) >= 0) {
canRefund = true; canRefund = true;
} }
...@@ -1920,6 +1917,16 @@ public class OrderAdapter { ...@@ -1920,6 +1917,16 @@ public class OrderAdapter {
}); });
createOrderProductDemoDto.setComboProduct(comboProducts); createOrderProductDemoDto.setComboProduct(comboProducts);
} }
//加料商品
if (cartGoodsDetailDto.getProductType() != null && (cartGoodsDetailDto.getProductType() == ProductType.MATERIALPRODUCT_UPPRICE.getCode())) {
List<CreateOrderProductRequest> materialProducts = new ArrayList<>();
cartGoodsDetailDto.getMaterialList().forEach(product -> {
materialProducts.add(convent2OrderProductDemo(product));
});
createOrderProductDemoDto.setMaterialProduct(materialProducts);
}
createOrderProductDemoDto.setProductType(cartGoodsDetailDto.getProductType()); createOrderProductDemoDto.setProductType(cartGoodsDetailDto.getProductType());
return createOrderProductDemoDto; return createOrderProductDemoDto;
} }
......
...@@ -212,7 +212,7 @@ public class ShoppingCartGoodsDto { ...@@ -212,7 +212,7 @@ public class ShoppingCartGoodsDto {
*/ */
private List<CartGoodsDetailDto> comboProducts; private List<CartGoodsDetailDto> comboProducts;
private List<CartGoodsMaterial> materialList; private List<CartGoodsDetailDto> materialList;
@Data @Data
public final static class CartGoodsExtra { public final static class CartGoodsExtra {
...@@ -227,45 +227,6 @@ public class ShoppingCartGoodsDto { ...@@ -227,45 +227,6 @@ public class ShoppingCartGoodsDto {
} }
@Data
public final static class CartGoodsMaterial {
/**
* 加料Id
*/
private String materialId;
/**
* 加料名称
*/
private String materialName;
/**
* 加料数量
*/
private Integer qty;
/**
* 加料原始价格
*/
private Long originalPrice;
/**
* 加料优惠价格
*/
private Long totalDiscountAmount;
/**
* 销售价格
*/
private Long salePrice;
/**
* 商品类型
*/
private Integer type;
/**
* 商品优惠信息
*/
List<ActivityDiscountsDto> activityDiscountsDtos;
}
/** /**
* 获取extras attributeNames * 获取extras attributeNames
*/ */
......
...@@ -19,7 +19,13 @@ public enum OrderRefundEnum { ...@@ -19,7 +19,13 @@ public enum OrderRefundEnum {
TAKEORDER_REFUND("takeOrderRefund", "未接单是否支持退款"), TAKEORDER_REFUND("takeOrderRefund", "未接单是否支持退款"),
RECEIPTORDER_REFUND("receiptOrderRefund", "已接单是否支持退款"), RECEIPTORDER_REFUND("receiptOrderRefund", "已接单是否支持退款"),
COMPLETEMAKEORDER_REFUND("completeMakeOrderRefund", "制作完成是否支持退款"), COMPLETEMAKEORDER_REFUND("completeMakeOrderRefund", "制作完成是否支持退款"),
REFUND_DELIVERY_FEE_ENABLE("refundShippingFee","商家同意退款时是否退配送费"); REFUND_DELIVERY_FEE_ENABLE("refundShippingFee","商家同意退款时是否退配送费"),
DELIVERY_TAKE_ORDER_REFUND("deliveryTakeOrderRefund","外卖单未接单是否支持退款"),
DELIVERY_RECEIPT_ORDER_REFUND("deliveryReceiptOrderRefund","外卖单已接单是否支持退款"),
DELIVERY_COMPLETE_MAKE_ORDER_REFUND("deliveryCompleteMakeOrderRefund","外卖单制作完成是否支持退款"),
DELIVERY_ORDER_REFUND("deliveryOrderRefund","外卖单订单完成是否支持退款");
private String keyValue; private String keyValue;
......
...@@ -16,7 +16,8 @@ public enum ProductType { ...@@ -16,7 +16,8 @@ public enum ProductType {
NOSPEC(1, "无规格"), NOSPEC(1, "无规格"),
HAVESPEC(10, "有规格"), HAVESPEC(10, "有规格"),
SETMEALPRODUCT(6,"套餐商品"), SETMEALPRODUCT(6,"套餐商品"),
SETMEALPRODUCT_UPPRICE(7,"加价套餐商品"); SETMEALPRODUCT_UPPRICE(7,"加价套餐商品"),
MATERIALPRODUCT_UPPRICE(88,"加料商品");
private int code; private int code;
......
...@@ -19,7 +19,12 @@ public enum OrderRefundEnum { ...@@ -19,7 +19,12 @@ public enum OrderRefundEnum {
TAKEORDER_REFUND("takeOrderRefund", "未接单是否支持退款"), TAKEORDER_REFUND("takeOrderRefund", "未接单是否支持退款"),
RECEIPTORDER_REFUND("receiptOrderRefund", "已接单是否支持退款"), RECEIPTORDER_REFUND("receiptOrderRefund", "已接单是否支持退款"),
COMPLETEMAKEORDER_REFUND("completeMakeOrderRefund", "制作完成是否支持退款"), COMPLETEMAKEORDER_REFUND("completeMakeOrderRefund", "制作完成是否支持退款"),
REFUND_DELIVERY_FEE_ENABLE("refundShippingFee","商家同意退款时是否退配送费"); REFUND_DELIVERY_FEE_ENABLE("refundShippingFee","商家同意退款时是否退配送费"),
DELIVERY_TAKE_ORDER_REFUND("deliveryTakeOrderRefund","外卖单未接单是否支持退款"),
DELIVERY_RECEIPT_ORDER_REFUND("deliveryReceiptOrderRefund","外卖单已接单是否支持退款"),
DELIVERY_COMPLETE_MAKE_ORDER_REFUND("deliveryCompleteMakeOrderRefund","外卖单制作完成是否支持退款"),
DELIVERY_ORDER_REFUND("deliveryOrderRefund","外卖单订单完成是否支持退款");
private String keyValue; private String keyValue;
......
...@@ -13,6 +13,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -13,6 +13,7 @@ import com.alibaba.fastjson.JSONObject;
import com.freemud.api.assortment.datamanager.entity.db.AssortmentOpenPlatformPartnerWxappConfig; import com.freemud.api.assortment.datamanager.entity.db.AssortmentOpenPlatformPartnerWxappConfig;
import com.freemud.api.assortment.datamanager.manager.cache.CacheOpenPlatformPartnerWxappConfigManager; import com.freemud.api.assortment.datamanager.manager.cache.CacheOpenPlatformPartnerWxappConfigManager;
import com.freemud.application.sdk.api.ordercenter.enums.OperateClient; import com.freemud.application.sdk.api.ordercenter.enums.OperateClient;
import com.freemud.sdk.api.assortment.message.enums.OrderType;
import com.freemud.sdk.api.assortment.order.enums.OldOrderAccountType; import com.freemud.sdk.api.assortment.order.enums.OldOrderAccountType;
import com.freemud.sdk.api.assortment.order.response.order.QueryOrdersResponse; import com.freemud.sdk.api.assortment.order.response.order.QueryOrdersResponse;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
...@@ -321,28 +322,45 @@ public class OrderVerifyHandle { ...@@ -321,28 +322,45 @@ public class OrderVerifyHandle {
switch (data.getStatus()) { switch (data.getStatus()) {
// 未接单 // 未接单
case 1: case 1:
orderRefund = configMap.get(OrderRefundEnum.TAKEORDER_REFUND.getKeyValue()); //区分外卖单和到店订单,判断是否可以退款
if(OrderType.TAKE_OUT.getCode().equals(data.getOrderType())) {
orderRefund = configMap.get(OrderRefundEnum.DELIVERY_TAKE_ORDER_REFUND.getKeyValue());
}else {
orderRefund = configMap.get(OrderRefundEnum.TAKEORDER_REFUND.getKeyValue());
}
if (orderRefund == null || (orderRefund != null && ALLOW_REFUND.equals(orderRefund.getAppValue()))) { if (orderRefund == null || (orderRefund != null && ALLOW_REFUND.equals(orderRefund.getAppValue()))) {
isFinishRefund = true; isFinishRefund = true;
} }
break; break;
//已接单 //已接单
case 3: case 3:
orderRefund = configMap.get(OrderRefundEnum.RECEIPTORDER_REFUND.getKeyValue()); if(OrderType.TAKE_OUT.getCode().equals(data.getOrderType())) {
orderRefund = configMap.get(OrderRefundEnum.DELIVERY_RECEIPT_ORDER_REFUND.getKeyValue());
}else {
orderRefund = configMap.get(OrderRefundEnum.RECEIPTORDER_REFUND.getKeyValue());
}
if (orderRefund == null || (orderRefund != null && ALLOW_REFUND.equals(orderRefund.getAppValue()))) { if (orderRefund == null || (orderRefund != null && ALLOW_REFUND.equals(orderRefund.getAppValue()))) {
isFinishRefund = true; isFinishRefund = true;
} }
break; break;
//制作完成 //制作完成
case 31: case 31:
orderRefund = configMap.get(OrderRefundEnum.COMPLETEMAKEORDER_REFUND.getKeyValue()); if(OrderType.TAKE_OUT.getCode().equals(data.getOrderType())) {
orderRefund = configMap.get(OrderRefundEnum.DELIVERY_COMPLETE_MAKE_ORDER_REFUND.getKeyValue());
}else {
orderRefund = configMap.get(OrderRefundEnum.COMPLETEMAKEORDER_REFUND.getKeyValue());
}
if (orderRefund != null && ALLOW_REFUND.equals(orderRefund.getAppValue())) { if (orderRefund != null && ALLOW_REFUND.equals(orderRefund.getAppValue())) {
isFinishRefund = true; isFinishRefund = true;
} }
break; break;
// 订单完成 // 订单完成
case 5: case 5:
orderRefund = configMap.get(OrderRefundEnum.ORDER_REFUND.getKeyValue()); if(OrderType.TAKE_OUT.getCode().equals(data.getOrderType())) {
orderRefund = configMap.get(OrderRefundEnum.DELIVERY_ORDER_REFUND.getKeyValue());
}else {
orderRefund = configMap.get(OrderRefundEnum.ORDER_REFUND.getKeyValue());
}
if (orderRefund != null && ALLOW_REFUND.equals(orderRefund.getAppValue())) { if (orderRefund != null && ALLOW_REFUND.equals(orderRefund.getAppValue())) {
isFinishRefund = true; isFinishRefund = true;
} }
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
<dependency> <dependency>
<groupId>cn.freemud</groupId> <groupId>cn.freemud</groupId>
<artifactId>assortment-shoppingcart-sdk</artifactId> <artifactId>assortment-shoppingcart-sdk</artifactId>
<version>1.1.7-SNAPSHOT</version> <version>1.1.8-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.freemud.application.service.sdk</groupId> <groupId>com.freemud.application.service.sdk</groupId>
......
...@@ -111,14 +111,16 @@ public class ShoppingCartConvertAdapter { ...@@ -111,14 +111,16 @@ public class ShoppingCartConvertAdapter {
} else if (cartGoods.isWeightType()) { } else if (cartGoods.isWeightType()) {
cartGoodsDetailDto.setProductType(ProductType.WEIGHT_PRODUCT.getCode()); cartGoodsDetailDto.setProductType(ProductType.WEIGHT_PRODUCT.getCode());
} }
if (cartGoods.getProductMaterialList().size() > 0) { //小料
if (CollectionUtils.isNotEmpty(cartGoods.getProductMaterialList())) {
List<ShoppingCartGoodsDto.CartGoodsDetailDto.MaterialGoods> materialList = new ArrayList<>(0); List<ShoppingCartGoodsDto.CartGoodsDetailDto.MaterialGoods> materialList = new ArrayList<>(0);
for (CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()) { for (CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()) {
ShoppingCartGoodsDto.CartGoodsDetailDto.MaterialGoods goods = new ShoppingCartGoodsDto.CartGoodsDetailDto.MaterialGoods(); ShoppingCartGoodsDto.CartGoodsDetailDto.MaterialGoods goods = new ShoppingCartGoodsDto.CartGoodsDetailDto.MaterialGoods();
goods.setMaterialId(materialGoods.getMaterialId()); goods.setSpuId(materialGoods.getSpuId());
goods.setMaterialName(materialGoods.getMaterialName()); goods.setSpuName(materialGoods.getSpuName());
goods.setOriginalPrice(materialGoods.getOriginalPrice()); goods.setOriginalPrice(materialGoods.getOriginalPrice());
goods.setSalePrice(materialGoods.getFinalPrice()); goods.setSalePrice(materialGoods.getFinalPrice());
goods.setQty(cartGoods.getQty());
materialList.add(goods); materialList.add(goods);
} }
cartGoodsDetailDto.setMaterialList(materialList); cartGoodsDetailDto.setMaterialList(materialList);
...@@ -399,7 +401,7 @@ public class ShoppingCartConvertAdapter { ...@@ -399,7 +401,7 @@ public class ShoppingCartConvertAdapter {
if (CollectionUtils.isNotEmpty(addShoppingCartGoodsRequestVo.getProductMaterialList())) { if (CollectionUtils.isNotEmpty(addShoppingCartGoodsRequestVo.getProductMaterialList())) {
for (MaterialRequestVo materialRequestVo : addShoppingCartGoodsRequestVo.getProductMaterialList()) { for (MaterialRequestVo materialRequestVo : addShoppingCartGoodsRequestVo.getProductMaterialList()) {
CartGoods.MaterialGoods materialGoods = new CartGoods.MaterialGoods(); CartGoods.MaterialGoods materialGoods = new CartGoods.MaterialGoods();
materialGoods.setMaterialId(materialRequestVo.getMaterialId()); materialGoods.setSpuId(materialRequestVo.getSpuId());
materialGoodsList.add(materialGoods); materialGoodsList.add(materialGoods);
} }
} }
......
package cn.freemud.controller;
import cn.freemud.base.entity.BaseResponse;
import cn.freemud.entities.vo.*;
import cn.freemud.service.impl.mcoffee.ShoppingCartMCoffeeServiceImpl;
import com.freemud.application.sdk.api.log.ApiAnnotation;
import com.freemud.application.sdk.api.log.LogParams;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title: MCoffeeShoppingCartController
* @Package cn.freemud.controller
* @Description:
* @author: ping1.wu
* @date: 2020/7/21 17:37
* @Copyright: 2020 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@RestController
@RequestMapping(value = "/shoppingCart/MCoffee", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(value = "购物车 controller", tags = {"购物车管理接口"})
@Slf4j
public class MCoffeeShoppingCartController {
@Autowired
private ShoppingCartMCoffeeServiceImpl shoppingCartMCoffeeService;
/**
* 向购物车中添加商品
*/
@ApiAnnotation(logMessage = "addGoods")
@PostMapping(value = "/addGoods")
public BaseResponse addGoods(@Validated @LogParams @RequestBody AddShoppingCartGoodsRequestVo request) {
return shoppingCartMCoffeeService.addGoods(request);
}
/**
* 修改购物车中商品数量
*/
@ApiAnnotation(logMessage = "updateGoodsQty")
@PostMapping(value = "/updateGoodsQty")
public BaseResponse updateGoodsQty(@Validated @LogParams @RequestBody UpdateShoppingCartGoodsQtyRequestVo request) {
return shoppingCartMCoffeeService.updateGoodsQty(request);
}
/**
* 查询购物车信息
*/
@ApiAnnotation(logMessage = "listCartGoods")
@PostMapping(value = "/listCartGoods")
public BaseResponse listCartGoods(@Validated @LogParams @RequestBody ShoppingCartInfoRequestVo request) {
return shoppingCartMCoffeeService.getGoodsList(request);
}
/**
* 清空购物车
*/
@ApiAnnotation(logMessage = "clearCartGoods")
@PostMapping(value = "/clearCartGoods")
public BaseResponse clearCartGoods(@Validated @LogParams @RequestBody ShoppingCartClearRequestVo request) {
return shoppingCartMCoffeeService.clear(request);
}
}
...@@ -262,8 +262,8 @@ public class ShoppingCartGoodsDto { ...@@ -262,8 +262,8 @@ public class ShoppingCartGoodsDto {
/** /**
* 加料商品ID * 加料商品ID
*/ */
private String materialId; private String spuId;
private String materialName; private String spuName;
/** /**
* 商品行记录:当前元售价 * 商品行记录:当前元售价
*/ */
...@@ -273,6 +273,10 @@ public class ShoppingCartGoodsDto { ...@@ -273,6 +273,10 @@ public class ShoppingCartGoodsDto {
*/ */
private Long salePrice; private Long salePrice;
/** /**
* 小料商品的数量
*/
private Integer qty;
/**
* 商品行优惠总金额=数量*单个商品优惠金额 * 商品行优惠总金额=数量*单个商品优惠金额
*/ */
private Integer totalDiscountAmount; private Integer totalDiscountAmount;
......
...@@ -381,11 +381,11 @@ public class CartGoods { ...@@ -381,11 +381,11 @@ public class CartGoods {
/** /**
* 加料Id * 加料Id
*/ */
private String materialId; private String spuId;
/** /**
* 加料名称 * 加料名称
*/ */
private String materialName; private String spuName;
/** /**
* 购物车一行商品的原单价 * 购物车一行商品的原单价
*/ */
......
...@@ -19,5 +19,5 @@ public class MaterialRequestVo { ...@@ -19,5 +19,5 @@ public class MaterialRequestVo {
/** /**
* 加料商品ID * 加料商品ID
*/ */
private String materialId; private String spuId;
} }
...@@ -32,7 +32,7 @@ public class UpdateShoppingCartGoodsQtyRequestVo extends BaseRequestVo { ...@@ -32,7 +32,7 @@ public class UpdateShoppingCartGoodsQtyRequestVo extends BaseRequestVo {
private String cartGoodsUid; private String cartGoodsUid;
/** /**
* 商品数量 * 更新后商品数量
*/ */
@NotNull(message = "qty不能为空") @NotNull(message = "qty不能为空")
private Integer qty; private Integer qty;
......
...@@ -851,13 +851,13 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -851,13 +851,13 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
calculationDiscountGoods.setMemberDiscount(cartGoods.getMemberDiscount()); calculationDiscountGoods.setMemberDiscount(cartGoods.getMemberDiscount());
//加料 //加料
if (cartGoods.getProductMaterialList().size() > 0) { if (CollectionUtils.isNotEmpty(cartGoods.getProductMaterialList())) {
new ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material(); new ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material();
ArrayList<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material> materials = new ArrayList<>(); ArrayList<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material> materials = new ArrayList<>();
for (CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()) { for (CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()) {
ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material material = new ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material(); ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material material = new ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material();
material.setType(1); material.setType(1);
material.setGoodsId(materialGoods.getMaterialId()); material.setGoodsId(materialGoods.getSpuId());
material.setGoodsQuantity(cartGoods.getQty()); material.setGoodsQuantity(cartGoods.getQty());
material.setOriginalPrice(materialGoods.getFinalPrice()); material.setOriginalPrice(materialGoods.getFinalPrice());
materials.add(material); materials.add(material);
......
package cn.freemud.service.impl.mcoffee.calculation;
import cn.freemud.entities.dto.ActivityCalculationDiscountResponseDto;
import cn.freemud.entities.dto.CheckSpqInfoResponseDto;
import cn.freemud.entities.vo.ActivityClassifyCouponBean;
import cn.freemud.entities.vo.CartGoods;
import cn.freemud.entities.vo.CouponPromotionVO;
import cn.freemud.entities.vo.ShoppingCartGoodsResponseVo;
import cn.freemud.enums.CouponFlag;
import cn.freemud.service.CouponService;
import com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title: CouponDiscountCalculation
* @Package cn.freemud.service.impl.mcoffee
* @Description:
* @author: ping1.wu
* @date: 2020/8/3 16:02
* @Copyright: 2020 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Service
public class CouponDiscountCalculation {
@Autowired
private CouponService couponService;
public void updateShoppingCartGoodsDiscountCoupon(CouponPromotionVO couponPromotionVO, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult, List<CartGoods> cartGoodsList, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo) {
// 用户选择了查询优惠券信息
if (couponPromotionVO != null && ObjectUtils.equals(CouponFlag.YES.getCode(), couponPromotionVO.getFlg())) {
List<CartGoods> tmpCartGoods = cartGoodsList.parallelStream().filter(k -> k.getCartGoodsUid().startsWith(CommonsConstant.COUPON_PREFIX)).collect(Collectors.toList());
// 是否存在商品券
boolean hasGoodssCoupon = CollectionUtils.isNotEmpty(tmpCartGoods);
// 构建可用不可用优惠券
ActivityClassifyCouponBean activityClassifyCouponBean = couponService.availableCoupon(cartGoodsList, couponPromotionVO.getPartnerId()
, couponPromotionVO.getUserId(), couponPromotionVO.getStoreId(), couponPromotionVO.getCouponCode(), hasGoodssCoupon, couponPromotionVO.getOrderType());
if (Objects.equals(activityClassifyCouponBean, null)) {
// 构建一个空得订单券信息
activityClassifyCouponBean = new ActivityClassifyCouponBean();
activityClassifyCouponBean.setCouponNum(0);
activityClassifyCouponBean.setDisableCouponNum(0);
activityClassifyCouponBean.setUsableCouponNum(0);
activityClassifyCouponBean.setDisableCoupons(Lists.newArrayList());
activityClassifyCouponBean.setUsableCoupons(Lists.newArrayList());
}
shoppingCartGoodsResponseVo.setAvailableCoupon(activityClassifyCouponBean);
}
// 当couponCode不为空时,需计算优惠价格
long couponDiscount = 0;
if (couponPromotionVO != null && StringUtils.isNotEmpty(couponPromotionVO.getCouponCode())
&& calculationDiscountResult != null) {
List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.CouponResults> couponResultsList = calculationDiscountResult.getCouponDiscounts();
if (CollectionUtils.isNotEmpty(couponResultsList)) {
for (ActivityCalculationDiscountResponseDto.CalculationDiscountResult.CouponResults couponResults : couponResultsList) {
couponDiscount = couponDiscount + (couponResults.getDiscountAmount() == null ? 0 : couponResults.getDiscountAmount());
}
}
}
shoppingCartGoodsResponseVo.setCouponDiscount(couponDiscount);
//循环购物车商品券
for (CartGoods cartGoods : cartGoodsList) {
if (cartGoods.getCartGoodsUid().startsWith(CommonsConstant.COUPON_PREFIX)) {
String spqId = cartGoods.getCartGoodsUid().substring(CommonsConstant.COUPON_PREFIX.length());
// 计算优惠信息时,已将券校验过,放在map中
Map<String, CheckSpqInfoResponseDto> validCouponMap = calculationDiscountResult == null ? new HashMap<>() : calculationDiscountResult.getValidCouponMap();
if (MapUtils.isNotEmpty(validCouponMap)) {
CheckSpqInfoResponseDto checkSpqInfoResponseDto = validCouponMap.get(spqId);
if (checkSpqInfoResponseDto != null) {
cartGoods.setOriginalPrice(checkSpqInfoResponseDto.getPrice());
cartGoods.setSpuId(checkSpqInfoResponseDto.getSpuId());
cartGoods.setSkuId(StringUtils.isEmpty(checkSpqInfoResponseDto.getSkuId()) ? checkSpqInfoResponseDto.getSpuId() : checkSpqInfoResponseDto.getSkuId());
cartGoods.setQty(1);
cartGoods.setCouponCode(checkSpqInfoResponseDto.getCouponCode());
cartGoods.setSpuName(checkSpqInfoResponseDto.getSpuName());
}
}
}
}
}
}
package cn.freemud.service.impl.mcoffee.calculation;
import cn.freemud.entities.dto.ActivityCalculationDiscountResponseDto;
import cn.freemud.entities.vo.CartGoods;
import cn.freemud.entities.vo.ShoppingCartGoodsResponseVo;
import cn.freemud.enums.ActivityTypeEnum;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title: TimeSaleCalculation
* @Package cn.freemud.service.impl.mcoffee
* @Description:
* @author: ping1.wu
* @date: 2020/8/3 16:07
* @Copyright: 2020 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Service
public class TimeSaleCalculation {
/**
* 限时特价
*
* @return
*/
public void TimeSaleUpdateShoppingCartGoodsDiscount(ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult, List<CartGoods> cartGoodsList, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo) {
if (calculationDiscountResult == null || CollectionUtils.isEmpty(calculationDiscountResult.getDiscounts())
|| !calculationDiscountResult.getDiscounts().stream().anyMatch(discount -> (ActivityTypeEnum.TYPE_2.getCode().equals(discount.getType()) || (ActivityTypeEnum.TYPE_21.getCode().equals(discount.getType()))))) {
return;
}
List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods> goodsList = calculationDiscountResult.getGoods();
if (CollectionUtils.isEmpty(goodsList)) {
return;
}
String toastMsg = null;
Map<String, ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods> goodsMap = goodsList.parallelStream()
.collect(Collectors.toMap(ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods::getGoodsId, Function.identity(), (k1, k2) -> k1));
// 存储当前享受限时特价折扣的商品数量,key:goodsId; value:可享受数量
Map<String, Integer> numberMap = new HashMap<>();
List<Integer> discounts = Arrays.asList(ActivityTypeEnum.TYPE_2.getCode(), ActivityTypeEnum.TYPE_21.getCode());
for (CartGoods cartGoods : cartGoodsList) {
ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods goods;
if ((goods = goodsMap.get(cartGoods.getGoodsId())) == null) {
continue;
}
ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount goodsDiscount = getGoodsDiscount(goods.getDiscounts(), discounts);
if (goodsDiscount == null) {
continue;
}
// 享受限时特价折扣的商品数量
Integer specialActualGoodsNumber = null;
// 商品现价
Long goodsNowPrice = cartGoods.getOriginalPrice() - goodsDiscount.getDiscount() / goodsDiscount.getActualGoodsNumber();
// numberMap用于暂存当前商品行可享受限时特价折扣的商品数量
if ((specialActualGoodsNumber = numberMap.get(goods.getGoodsId())) == null) {
numberMap.put(goods.getGoodsId(), specialActualGoodsNumber = goodsDiscount.getActualGoodsNumber());
}
//若可享受数量>=当前商品行的商品数量
if (specialActualGoodsNumber - cartGoods.getQty() >= 0) {
cartGoods.setAmount(goodsNowPrice * cartGoods.getQty());
} else {
//总价=可享受数量*优惠后单价+(当前商品行的商品数量-可享受数量)*商品原价
cartGoods.setAmount(specialActualGoodsNumber > 0 ? specialActualGoodsNumber * goodsNowPrice + (cartGoods.getQty() - specialActualGoodsNumber) * cartGoods.getOriginalPrice()
: goods.getOriginalPrice() * cartGoods.getQty());
if (StringUtils.isEmpty(toastMsg)) {
toastMsg = "该商品限" + goodsDiscount.getActualGoodsNumber() + "份优惠 超出按照原价计算哦";
}
}
numberMap.put(goods.getGoodsId(), specialActualGoodsNumber - cartGoods.getQty());
}
if (StringUtils.isNotBlank(toastMsg)) {
shoppingCartGoodsResponseVo.setToastMsg(toastMsg);
}
}
/**
* 获取指定促销类型的GoodsDiscount
*
* @param goodsDiscountList
* @param discounts
* @return
*/
private ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount getGoodsDiscount(List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount> goodsDiscountList, List<Integer> discounts) {
if (CollectionUtils.isEmpty(goodsDiscountList)) {
return null;
}
for (ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount goodsDiscount : goodsDiscountList) {
if (discounts.contains(goodsDiscount.getType())) {
return goodsDiscount;
}
}
return null;
}
/**
* 获取指定促销类型的ApportionDetails
*
* @param apportionDetailsList
* @param type
* @return
*/
private ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ApportionGoods.ApportionDetails getApportionDetails(List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ApportionGoods.ApportionDetails> apportionDetailsList, ActivityTypeEnum type) {
for (ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ApportionGoods.ApportionDetails apportionDetails : apportionDetailsList) {
if (Objects.equals(apportionDetails.getActivityType(), ActivityTypeEnum.TYPE_2.getCode())) {
return apportionDetails;
}
}
return null;
}
}
...@@ -46,4 +46,14 @@ public interface ActivityClient { ...@@ -46,4 +46,14 @@ public interface ActivityClient {
*/ */
@PostMapping("/activity/stock/cancelStock") @PostMapping("/activity/stock/cancelStock")
ActivityBaseResponseDto cancelStock(ActivityCancelStockRequestDto activityCancelStockRequestDto); ActivityBaseResponseDto cancelStock(ActivityCancelStockRequestDto activityCancelStockRequestDto);
/**
* 新版优惠均摊计算
* @param activityCalculationDiscountRequestDto
* @return
*/
@PostMapping("/calculation/discount/sharing")
ActivityCalculationDiscountResponseDto calculationDiscountSharing(ActivityCalculationDiscountRequestDto activityCalculationDiscountRequestDto);
} }
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