Commit 247853a5 by zhiheng.zhang

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

parents 38d3cd00 ed6e7bef
......@@ -1220,7 +1220,7 @@ public class OrderAdapter {
responseVo.setOidBase64Image(oidBase64Image);
}
//设置是否是第三方配送单
if (ordersBean.getAddInfo() !=null && StringUtils.isNotEmpty(ordersBean.getAddInfo().getDeliveryId())&& "0".equals(ordersBean.getAddInfo().getDeliveryId())) {
if (ordersBean.getAddInfo() !=null && StringUtils.isNotEmpty(ordersBean.getAddInfo().getDeliveryId())&& !"0".equals(ordersBean.getAddInfo().getDeliveryId())) {
responseVo.setHasThirdDelivery(true);
responseVo.setDeliveryId(ordersBean.getAddInfo().getDeliveryId());
}
......@@ -2088,6 +2088,11 @@ public class OrderAdapter {
}
productVo.setInventedParentActivitiesVo(inventedParentActivityVos);
}
// 购物车行id
productVo.setCid(orderProductAddInfoDto.getCartGoodsUid());
// 购物车行父id
productVo.setOcid(orderProductAddInfoDto.getOriginalGoodsUid());
}
productVo.setOriginalPrice(productBean.getPrice());
productVo.setFinalPrice(productBean.getSalePrice());
......@@ -2114,15 +2119,16 @@ public class OrderAdapter {
discountTotalAmount = discountTotalAmount + productDiscount.getDiscountAmount()*productDiscount.getDiscountQty();
if (OrderAccountType.PRODUCT_COUPON.getCode().equals(productDiscount.getDiscountType())) {
hasProductCoupon = true;
Integer extendType = StringUtils.isBlank(productDiscount.getAddInfo())?null:JSON.parseObject(productDiscount.getAddInfo()).getInteger("extendType");
if(null != extendType && (3 == extendType || 4 == extendType || 5 == extendType)) {
productVo.setCouponName(productDiscount.getDiscountDesc());
} else {
productVo.setName(productDiscount.getDiscountDesc());
productVo.setSpuName(productDiscount.getDiscountDesc());
productVo.setExtras("");
productVo.setSpecification("");
}
// Integer extendType = StringUtils.isBlank(productDiscount.getAddInfo())?null:JSON.parseObject(productDiscount.getAddInfo()).getInteger("extendType");
// if(null != extendType && (3 == extendType || 4 == extendType || 5 == extendType)) {
// productVo.setCouponName(productDiscount.getDiscountDesc());
// } else {
// productVo.setName(productDiscount.getDiscountDesc());
// productVo.setSpuName(productDiscount.getDiscountDesc());
// productVo.setExtras("");
// productVo.setSpecification("");
// }
}
if (OrderAccountType.BUYM_SENDN.getCode().equals(productDiscount.getDiscountType())) {
activityType = ActivityTypeEnum.TYPE_61.getCode();
......@@ -2152,6 +2158,9 @@ public class OrderAdapter {
//套餐
productVo.setParentProductId(productBean.getParentProductId());
productVo.setProductType(productBean.getProductType());
if(ProductTypeEnum.TABLEWARE_PRODUCT.getCode().equals(productBean.getProductType())) {
productVo.setIsTableware(true);
}
productVo.setUnit(productBean.getUnit());
productVo.setWeight(productBean.getWeight() != null ? productBean.getWeight().doubleValue() : 0);
return productVo;
......@@ -2484,7 +2493,11 @@ public class OrderAdapter {
createOrderProductDemoDto.setPicture(cartGoodsDetailDto.getPicture());
createOrderProductDemoDto.setAddInfo(cartGoodsDetailDto.getAttributeNames());
createOrderProductDemoDto.setDiscountId(cartGoodsDetailDto.getCouponCode());
if(cartGoodsDetailDto.getIsTableware() == 0) {
createOrderProductDemoDto.setProductType(productType);
} else {
createOrderProductDemoDto.setProductType(ProductTypeEnum.TABLEWARE_PRODUCT.getCode());
}
createOrderProductDemoDto.setParentProductId(cartGoodsDetailDto.getParentProductId());
createOrderProductDemoDto.setIsFixedProduct(cartGoodsDetailDto.getIsFixedProduct());
createOrderProductDemoDto.setCustomerCode(cartGoodsDetailDto.getCustomerCode());
......
......@@ -26,4 +26,7 @@ public class PayGitCheckAndJoinRequestDto {
private Integer orderWay;
private List<String> skuIds;
// 版本号
private Integer ver;
}
......@@ -197,6 +197,10 @@ public class ShoppingCartGoodsDto {
*/
private boolean isStockLimit;
/**
* 是否餐具商品
*/
private Integer isTableware = 0;
/**
* 商品重量
*/
private Double weight;
......
......@@ -154,6 +154,11 @@ public class ProductVo {
private Integer productType;
/**
* 是否餐具商品
*/
private Boolean isTableware = false;
/**
* 商品单位
*/
private String unit;
......
......@@ -192,6 +192,8 @@ public class OrderServiceImpl implements Orderservice {
private String fnStoreId;
@Value("${collage.pre_order_pay.goods_tag}")
private String collageGoodsTag;
@Value("${collage.pre_order_pay.goods_tag_list}")
private String collageGoodsTagList;
/**
* coco商户
......@@ -940,7 +942,7 @@ public class OrderServiceImpl implements Orderservice {
// 所以在这个地方排除掉coco,在下边单独实现
//参与支付有礼活动
if(!cocoPartnerId.contains(queryOrderVo.getPartnerId())){
joinPayGift(queryOrderVo.getSessionId(), queryOrderResponseVo);
joinPayGift(queryOrderVo.getSessionId(), queryOrderResponseVo,partnerId);
}
} catch (Exception e) {
......@@ -953,7 +955,7 @@ public class OrderServiceImpl implements Orderservice {
if(cocoPartnerId.contains(queryOrderVo.getPartnerId())){
queryOrderResponseVos.forEach(queryOrderResponseVo -> {
try {
joinPayGift(queryOrderVo.getSessionId(), queryOrderResponseVo);
joinPayGift(queryOrderVo.getSessionId(), queryOrderResponseVo,partnerId);
} catch (Exception e) {
LogUtil.error("coco_queryOrders_activity_error", gson.toJson(queryOrdersDto), gson.toJson(queryOrderResponseVo), e);
......@@ -1277,7 +1279,7 @@ public class OrderServiceImpl implements Orderservice {
}
//参与支付有礼活动
private void joinPayGift(String sessionId, QueryOrderResponseVo queryOrderResponseVo) {
private void joinPayGift(String sessionId, QueryOrderResponseVo queryOrderResponseVo,String partnerId) {
PayGitCheckAndJoinRequestDto payGitRequestDto = new PayGitCheckAndJoinRequestDto();
payGitRequestDto.setStoreId(queryOrderResponseVo.getShopId());
payGitRequestDto.setSessionId(sessionId);
......@@ -1298,6 +1300,11 @@ public class OrderServiceImpl implements Orderservice {
} else {
payGitRequestDto.setOrderWay(2);
}
if(cocoPartnerId.contains(partnerId)){
payGitRequestDto.setVer(1);
}
BaseResponse<PayGiftCheckAndJoinResponseDto> payGiftBaseResponse = activityApplicationClient.payGiftCheckAndJoin(payGitRequestDto);
if (String.valueOf(RESPONSE_SUCCESS_CODE).equals(payGiftBaseResponse.getCode()) && payGiftBaseResponse.getResult() != null) {
PayGiftCheckAndJoinResponseDto payGiftResponse = payGiftBaseResponse.getResult();
......@@ -1463,7 +1470,7 @@ public class OrderServiceImpl implements Orderservice {
// 支付有礼
// 目前只有coco在订单详情参加支付有礼,且不检查订单的状态
if(cocoPartnerId.contains(partnerId)){
joinPayGift(sessionId, queryOrderResponseVo);
joinPayGift(sessionId, queryOrderResponseVo,partnerId);
}
......@@ -2746,7 +2753,9 @@ public class OrderServiceImpl implements Orderservice {
if (null != orderBean.getMarketingType() && OrderMarketType.COLLAGE.getIndex() == orderBean.getMarketingType()) {
// 拼单人数大于1人时参加拼单补贴
if (null != orderBean.getProductList() && orderBean.getProductList().stream().map(QueryOrdersResponse.DataBean.OrderBean.ProductBean::getUserId).distinct().collect(Collectors.toList()).size() > 1) {
request.setGoodsTag(collageGoodsTag);
Map<String, String> goodsTagMap = this.goodsTagMap();
String goodsTag = goodsTagMap.get(orderBean.getCompanyId());
request.setGoodsTag(StringUtils.isBlank(goodsTag) ? collageGoodsTag : goodsTag);
}
}
// add by miaohui for 拼单群收款判断拼单人数大于1时参与微信平台补贴活动,创建预支付时上送goodsTag,后续抽成促销服务活动时删除此逻辑 end
......@@ -3673,4 +3682,16 @@ public class OrderServiceImpl implements Orderservice {
return false;
}
}
private Map<String, String> goodsTagMap() {
Map<String, String> map = new HashMap<>();
try {
for (String pg : collageGoodsTagList.split(",")) {
map.put(pg.split(":")[0], pg.split(":")[1]);
}
} catch (Exception e) {
log.error("goodsTag解析失败:" + collageGoodsTagList);
}
return map;
}
}
......@@ -28,6 +28,7 @@ import com.freemud.application.sdk.api.ordercenter.response.orderInfo.OrderSendC
import com.freemud.application.sdk.api.storecenter.response.StoreResponse;
import com.freemud.application.sdk.api.storecenter.service.StoreCenterService;
import com.freemud.sdk.api.assortment.order.enums.OldOrderAccountType;
import com.freemud.sdk.api.assortment.order.request.order.OrderProductAddInfoDto;
import com.freemud.sdk.api.assortment.order.response.order.QueryOrderByIdResponse;
import com.freemud.sdk.api.assortment.order.response.order.QueryOrdersResponse;
import io.swagger.models.auth.In;
......@@ -109,7 +110,14 @@ public class CocoOrderRelationServiceImpl implements OrderRelationService {
Map<String,QueryOrdersResponse.DataBean.OrderBean.ProductBean> productMap = new HashMap<>();
List<QueryOrdersResponse.DataBean.OrderBean.ProductBean> productList = response.getData().getProductList();
if(productList != null && !productList.isEmpty()){
productMap = productList.stream().collect(Collectors.toMap(QueryOrdersResponse.DataBean.OrderBean.ProductBean::getCartGoodsUid, g -> g,(k1,k2)->k1));
for(QueryOrdersResponse.DataBean.OrderBean.ProductBean productBean : productList){
if(StringUtils.isEmpty(productBean.getExtInfo())){
continue;
}
OrderProductAddInfoDto orderProductAddInfoDto = JSONObject.parseObject(productBean.getExtInfo(),OrderProductAddInfoDto.class);
productMap.put(orderProductAddInfoDto.getCartGoodsUid(),productBean);
}
}
......@@ -129,10 +137,27 @@ public class CocoOrderRelationServiceImpl implements OrderRelationService {
});
}
List<ProductVo> productVos = new ArrayList<>();
if(null != masterProducts && !masterProducts.isEmpty()){
for(ProductVo product : masterProducts){
Integer giftQty = giftMap.get(product.getCid()) == null ? 0 : giftMap.get(product.getCid());
product.setQty(product.getQty() + giftQty);
// 商品原单价=商品原单价+小料原单价
List<ProductVo> smallMaterial = product.getSetMaterialProducts();
Long smallMaterialOriTotal = 0L;
if(smallMaterial != null && !smallMaterial.isEmpty()){
for(ProductVo sm : smallMaterial){
smallMaterialOriTotal = smallMaterialOriTotal + sm.getOriginalPrice();
}
}
// 商品现单价 = 商品现单价+小料现单价
smallMaterialOriTotal = smallMaterialOriTotal == null ? 0 : smallMaterialOriTotal;
product.setOriginalPrice(smallMaterialOriTotal + (product.getOriginalPrice() == null ? 0L : product.getOriginalPrice()));
// 如果商品参加了第二件半价活动,要把该行拆成数量为1的多行
QueryOrdersResponse.DataBean.OrderBean.ProductBean productBean = productMap.get(product.getCid());
if(productBean == null || productBean.getDiscountList() == null || productBean.getDiscountList().isEmpty()){
......@@ -141,7 +166,7 @@ public class CocoOrderRelationServiceImpl implements OrderRelationService {
boolean halfFlag = false;
List<QueryOrdersResponse.DataBean.OrderBean.ProductBean.ProductDiscount> discountList = productBean.getDiscountList();
for(QueryOrdersResponse.DataBean.OrderBean.ProductBean.ProductDiscount productDiscount : discountList){
if(ObjectUtils.equals(productDiscount.getDiscountType(), 20)){
if(ObjectUtils.equals(productDiscount.getDiscountType(), OldOrderAccountType.SECOND_DISCOUNT.getCode())){
halfFlag = true;
break;
}
......@@ -151,14 +176,20 @@ public class CocoOrderRelationServiceImpl implements OrderRelationService {
for(int i = 0 ; i < num-1 ; i++){
ProductVo newProduct = JSONObject.parseObject(JSONObject.toJSONString(product),ProductVo.class);
newProduct.setQty(1);
productVos.add(newProduct);
}
product.setQty(1);
}
}
}
masterProducts.addAll(productVos);
queryOrderResponseVo.setProducts(masterProducts);
}
}
......@@ -27,9 +27,11 @@ import com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO;
import com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant;
import com.freemud.sdk.api.assortment.shoppingcart.request.CheckCartRequest;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.*;
......@@ -37,11 +39,15 @@ import java.util.stream.Collectors;
import java.util.stream.LongStream;
@Component
@Slf4j
public class ShoppingCartConvertAdapter {
private static final String ATTRIBUTEID = "attributeId";
private static final String ATTRIBUTENAME = "attributeName";
@Value("${mccafe.tableware.skuId}")
private String mcCafeTablewareSkuId;
public ShoppingCartGoodsDto.CartGoodsDetailDto getCartGoodsDetailDto(CreateOrderVo.PremiumExchangeActivity.Product product, GetProductsVo getProductsVo, String goodsId, ActivityCalculationDiscountResponseDto.CalculationDiscountResult.SendActivity.SendGoods sendGoods) {
ShoppingCartGoodsDto.CartGoodsDetailDto cartGoodsDetailDto = new ShoppingCartGoodsDto.CartGoodsDetailDto();
cartGoodsDetailDto.setOriginalPrice(getProductsVo.getFinalPrice());
......@@ -121,6 +127,13 @@ public class ShoppingCartConvertAdapter {
cartGoodsDetailDto.setSpecialExtra(cartGoods.getSpecialExtra());
cartGoodsDetailDto.setClassificationId(cartGoods.getClassificationId());
cartGoodsDetailDto.setClassificationName(cartGoods.getClassificationName());
log.info("=============================");
log.info(cartGoods.getSkuId());
log.info(mcCafeTablewareSkuId);
log.info("=============================");
if(mcCafeTablewareSkuId.equals(cartGoods.getSkuId())) {
cartGoodsDetailDto.setIsTableware(1);
}
if (GoodsTypeEnum.SET_MEAL_GOODS.getGoodsType().equals(cartGoods.getGoodsType())) {
cartGoodsDetailDto.setProductType(ProductType.SETMEAL.getCode());
} else if (cartGoods.isWeightType()) {
......@@ -361,9 +374,9 @@ public class ShoppingCartConvertAdapter {
cartGoods.setSpuId(cartGood.getSpuId());
cartGoods.setSkuId(cartGood.getSkuId());
cartGoods.setSpecProductId(cartGood.getSpecProductId());
cartGoods.setOriginalPrice(nowPirce);
cartGoods.setOriginalPrice(cartGood.getOriginalPrice());
cartGoods.setPackPrice(cartGood.getPackPrice());
cartGoods.setOriginalAmount(nowPirce);
cartGoods.setOriginalAmount(cartGood.getOriginalPrice());
cartGoods.setAmount(0L);
cartGoods.setName(cartGood.getName());
cartGoods.setSpuName(cartGood.getSpuName());
......@@ -621,10 +634,10 @@ public class ShoppingCartConvertAdapter {
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods productCombo : cartGoods.getProductComboList()){
//套餐子商品多规格商品
if(productCombo.getSpuId() == null && !productCombo.getSkuId().equals(productCombo.getSpuId()) ){
updateComboxGoodsInfoForMCoffee(productCombo, spuProduct, true,null);
updateComboxGoodsInfoForMCoffee(productCombo, spuProduct, true);
}else {
//套餐子商品为单品
updateComboxGoodsInfoForMCoffee(productCombo, spuProduct, true,null);
updateComboxGoodsInfoForMCoffee(productCombo, spuProduct, true);
}
}
}
......@@ -634,11 +647,11 @@ public class ShoppingCartConvertAdapter {
//套餐子商品多规格商品
if(comboxGoods.getSpuId() == null && !comboxGoods.getSkuId().equals(comboxGoods.getSpuId()) ){
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods productGroup : cartGoods.getProductGroupList()) {
updateComboxGoodsInfoForMCoffee(productGroup, spuProduct, false,null);
updateComboxGoodsInfoForMCoffee(productGroup, spuProduct, false);
}
}else {
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods productGroup : cartGoods.getProductGroupList()) {
updateComboxGoodsInfoForMCoffee(productGroup, spuProduct, false,null);
updateComboxGoodsInfoForMCoffee(productGroup, spuProduct, false);
}
}
}
......@@ -685,7 +698,7 @@ public class ShoppingCartConvertAdapter {
* @return
*/
private void updateComboxGoodsInfoForMCoffee(com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods comboxGoods,
ProductTypeBeanDTO parentProductBean, boolean isComboxGoods,Map<String,ProductTypeBeanDTO> subProductTypeMap) {
ProductTypeBeanDTO parentProductBean, boolean isComboxGoods) {
if("0".equals(comboxGoods.getGoodsId())){
return;
}
......@@ -695,9 +708,7 @@ public class ShoppingCartConvertAdapter {
productComboType = parentProductBean.getProductComboList().stream().filter(p -> ObjectUtils.equals(comboxGoods.getGoodsId(), p.getProductId())).findFirst().orElse(new ProductTypeBeanDTO.ProductComboType());
} else {
Map<String, ProductTypeBeanDTO.ProductGroupType.GroupDetailType> map = new HashMap<>();
if (CollectionUtils.isNotEmpty(parentProductBean.getAdditionalGroupList())){
parentProductBean.getProductGroupList().stream().map(t -> t.getGroupDetail()).forEach(group -> group.forEach(detailType -> map.put(detailType.getProductId(), detailType)));
}
groupDetailType = map.get(comboxGoods.getGoodsId());
}
......@@ -731,8 +742,12 @@ public class ShoppingCartConvertAdapter {
//2020/12/10 套餐内可选商品加料
if(CollectionUtils.isNotEmpty(comboxGoods.getProductMaterialList())){
resolveMaterialForProductGroup(comboxGoods,subProductTypeMap);
List<com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods> productMaterialList = new ArrayList<>();
com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods materialGoods = new com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods();
productMaterialList.add(materialGoods);
comboxGoods.setProductMaterialList(productMaterialList);
}
}
private Map<String, String> getAttributesNew(List<com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.CartGoodsExtra> extra) {
......@@ -919,9 +934,10 @@ public class ShoppingCartConvertAdapter {
if(productCombo.getSpuId() != null && !productCombo.getSkuId().equals(productCombo.getSpuId()) ){
ProductTypeBeanDTO productBeanDTO = subProductTypeMap.get(productCombo.getSpuId());
updateComboxGoodsInfoFor(productCombo, productBeanDTO, true);
}else {
//套餐子商品为单品
updateComboxGoodsInfoForMCoffee(productCombo, spuProduct, true,null);
updateComboxGoodsInfoForMCoffee(productCombo, spuProduct, true);
}
}
}
......@@ -931,11 +947,11 @@ public class ShoppingCartConvertAdapter {
//套餐子商品多规格商品
if(comboxGoods.getSpuId() != null && !comboxGoods.getSkuId().equals(comboxGoods.getSpuId()) ){
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods productGroup : cartGoods.getProductGroupList()) {
updateComboxGoodsInfoForMCoffee(productGroup, spuProduct, false,subProductTypeMap);
updateComboxGoodsInfoForMCoffee(productGroup, spuProduct, false);
}
}else {
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods productGroup : cartGoods.getProductGroupList()) {
updateComboxGoodsInfoForMCoffee(productGroup, spuProduct, false,subProductTypeMap);
updateComboxGoodsInfoForMCoffee(productGroup, spuProduct, false);
}
}
}
......@@ -948,8 +964,12 @@ public class ShoppingCartConvertAdapter {
Long comboxGoodsOriginalPrice = cartGoods.getProductComboList().stream().mapToLong(t -> t.getOriginalAmount()).sum();
Long groupGoodsOriginalPrice = cartGoods.getProductGroupList().stream().mapToLong(t -> t.getOriginalAmount()).sum();
Long groupGoodsFinalPrice = cartGoods.getProductGroupList().stream().mapToLong(t -> t.getFinalPrice()).sum();
cartGoods.setOriginalPrice(null != cartGoods.getOriginalPrice()? cartGoods.getOriginalPrice() :
if (isSetMealProduct && isSkuProduct) {
cartGoods.setOriginalPrice(null != spuProduct.getFinalPrice() ? spuProduct.getFinalPrice() : comboxGoodsOriginalPrice);
}else{
cartGoods.setOriginalPrice(null != cartGoods.getOriginalPrice() ? cartGoods.getOriginalPrice() :
comboxGoodsOriginalPrice);
}
cartGoods.setOriginalAmount((cartGoods.getOriginalPrice()+groupGoodsOriginalPrice)* cartGoods.getQty());
//咨询商品服务,套餐售价取originalPrice
cartGoods.setFinalPrice(null != cartGoods.getOriginalPrice() ? cartGoods.getOriginalPrice() :
......
......@@ -23,6 +23,7 @@ public class CheckSpqInfoResponseDto {
* 券名称
*/
private String couponName;
private boolean stockLimit;
/**
* 商品券code
*/
......
......@@ -266,6 +266,11 @@ public class CalculationSharingDiscountResponseDto {
* 当前活动实际优惠的商品数量
*/
private Integer actualGoodsNumber;
/**
* 优惠现单价
*/
private Long signleDiscount;
}
/**
......
......@@ -255,6 +255,10 @@ public class ShoppingCartGoodsDto {
*/
private boolean isStockLimit;
/**
* 是否餐具商品
*/
private Integer isTableware = 0;
/**
* 商品货号
*/
private String productCode;
......
......@@ -196,6 +196,10 @@ public class CartGoods {
*/
private boolean isStockLimit;
/**
* 是否餐具商品
*/
private Boolean isTableware = false;
/**
* 第三方商品编码
*/
private String customerCode;
......
......@@ -25,6 +25,7 @@ public enum ActivityTypeEnum {
*/
TYPE_2(2, "单品特价"),
TYPE_21(21, "单品折扣"),
TYPE_22(22, "单品立减"),
TYPE_23(23, "超值加购"),
/**
* 优惠券
......
......@@ -22,6 +22,7 @@ import cn.freemud.service.impl.*;
import cn.freemud.service.thirdparty.CustomerApplicationClient;
import cn.freemud.service.thirdparty.StockClient;
import cn.freemud.utils.PromotionFactory;
import com.alibaba.fastjson.JSON;
import com.freemud.api.assortment.datamanager.entity.db.AssortmentOpenPlatformPartnerStoreDeliveryConfig;
import com.freemud.api.assortment.datamanager.manager.AssortmentOpenPlatformPartnerStoreDeliveryConfigManager;
import com.freemud.application.sdk.api.base.SDKCommonBaseContextWare;
......@@ -354,6 +355,9 @@ public abstract class AbstractShoppingCartImpl implements ShoppingCartNewService
*/
public void updateShoppingCartGoodsDiscount(CouponPromotionVO couponPromotionVO, ActivityQueryDto activityQueryDto, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult, List<CartGoods> cartGoodsList
, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo, UserLoginInfoDto userLoginInfoDto,String menuType,Long deliveryAmount) {
log.info("pindantest calculationDiscountResult->" + JSON.toJSONString(calculationDiscountResult));
log.info("pindantest cartGoodsList->" + JSON.toJSONString(cartGoodsList));
log.info("pindantest activityQueryDto->" + JSON.toJSONString(activityQueryDto));
//默认计算优惠
DefaultPromotionService defaultPromotionService = (DefaultPromotionService) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.DEFAULT_PROMOTION);
defaultPromotionService.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, userLoginInfoDto, shoppingCartInfoRequestVo);
......@@ -500,7 +504,7 @@ public abstract class AbstractShoppingCartImpl implements ShoppingCartNewService
*/
MaterialPromotionService materialPromotionService = (MaterialPromotionService) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.Material);
materialPromotionService.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, userLoginInfoDto, shoppingCartInfoRequestVo);
log.info("pindantest shoppingCartGoodsResponseVo->" + JSON.toJSONString(shoppingCartGoodsResponseVo));
}
/**
......
......@@ -147,6 +147,7 @@ public class CocoActiveServiceImpl implements ActiveService {
newCartGoods.setClassificationName(cgs.getClassificationName());
newCartGoods.setActivityType(discount.getType());
newCartGoods.setQty(discountForGift.get(cgs.getCartGoodsUid()).getGoodsQuantity());
newCartGoods.setProductMaterialList(cgs.getProductMaterialList());
addcartGoodsList.add(newCartGoods);
}
}
......
......@@ -48,10 +48,12 @@ import com.alibaba.fastjson.JSON;
import com.freemud.application.sdk.api.couponcenter.offline.domain.CodeInfoVO;
import com.freemud.application.sdk.api.couponcenter.offline.response.CouponQueryResponse;
import com.freemud.application.sdk.api.productcenter.constant.ResponseConstant;
import com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO;
import com.freemud.application.sdk.api.productcenter.request.product.valid.ValidateShopProductRequest;
import com.freemud.application.sdk.api.productcenter.request.product.valid.ValidateShopProductType;
import com.freemud.application.sdk.api.productcenter.response.ProductResponseDTO;
import com.freemud.application.sdk.api.productcenter.response.valid.ValiadShopProductResponse;
import com.freemud.application.sdk.api.productcenter.response.valid.ValiadShopProductResult;
import com.freemud.card.sdk.comm.Finals;
import com.freemud.card.sdk.comm.SignUtil;
import com.freemud.card.sdk.service.CouponAvailableService;
......@@ -691,6 +693,7 @@ public class CouponServiceImpl implements CouponService {
dto.setPrice(productsVo.getFinalPrice());
dto.setSpuId(productsVo.getSpuId());
dto.setSpuName(productsVo.getSkuName());
dto.setStockLimit(ObjectUtils.equals(1, productsVo.getStockLimit()));
dto.setSkuId(productsVo.getSkuId());
dto.setSkuName(StringUtils.isNotBlank(productsVo.getSkuName()) ? productsVo.getSkuName() : productsVo.getSpuName());
dto.setPicture(productsVo.getSpuPicture());
......@@ -783,7 +786,6 @@ public class CouponServiceImpl implements CouponService {
return null;
}
//券返回的商品id
List<String> skuIds = Lists.newArrayList();
String skuId = goodsId;
......@@ -814,6 +816,7 @@ public class CouponServiceImpl implements CouponService {
dto.setPicture(productsVo.getSpuPicture());
dto.setDefaultSpecName(productsVo.getDefaultSpecName());
dto.setDefaultSpecId(productsVo.getDefaultSpecId());
dto.setStockLimit(ObjectUtils.equals(1, productsVo.getStockLimit()));
dto.setExtras(productsVo.getExtra());
dto.setCouponType(couponType);
log.info("dto***" + dto);
......
......@@ -693,7 +693,7 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp
//设置更新响应信息
setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), partnerId, storeId, userId, ShoppingCartConstant.QUERY_INFO, shoppingCartInfoRequestVo);
//设置均摊信息,商品行信息
//设置均摊信息
updateShoppingCartGoodsApportion(shoppingCartGoodsResponseVo, calculationDiscountResult, shoppingCartGoodsDto, premiumExchangeActivity, shoppingCartInfoRequestVo);
// 计算第一次使用会员卡需多支付的金额 单位:分
getNeedCardAmount(shoppingCartInfoRequestVo, shoppingCartGoodsDto);
......@@ -703,13 +703,13 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp
shoppingCartGoodsDto.setThresholdAmount(shoppingCartGoodsResponseVo.getThresholdAmount());
shoppingCartGoodsDto.setIsDiscountDelivery(shoppingCartGoodsResponseVo.getIsDiscountDelivery());
shoppingCartGoodsDto.setDiscountDeliveryActivityCode(shoppingCartGoodsResponseVo.getDiscountDeliveryActivityCode());
if (calculationDiscountResult != null){
shoppingCartGoodsDto.setSendPoint(calculationDiscountResult.getSendPointVo());
}
// 购物车购买人包装费计算
updatePackPrice(shoppingCartGoodsResponseVo, shoppingCartGoodsDto);
// 重新计算购物车行折扣总金额
updateTotalDiscountAmount(calculationDiscountResult, shoppingCartGoodsDto);
return ResponseUtil.success(shoppingCartGoodsDto);
}
......@@ -734,22 +734,6 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp
}
}
/**
* 重新计算拼单购物车行总折扣金额
*/
private void updateTotalDiscountAmount(ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult, ShoppingCartGoodsDto shoppingCartGoodsDto) {
if (null != shoppingCartGoodsDto && null != shoppingCartGoodsDto.getProducts() && null != calculationDiscountResult && null != calculationDiscountResult.getGoods()) {
shoppingCartGoodsDto.getProducts().stream().forEach(product -> {
calculationDiscountResult.getGoods().stream().forEach(goods -> {
if (goods.getCartGoodsUid().equals(product.getCartGoodsUid())) {
long totalDiscountAmount = product.getOriginalPrice() * product.getQty() - goods.getRealAmount();
product.setTotalDiscountAmount(Integer.valueOf(String.valueOf(totalDiscountAmount)));
}
});
});
}
}
@Override
public ActivityCalculationDiscountResponseDto.CalculationDiscountResult getActivityCalculationDiscountResponse(String partnerId, String storeId, String userId, String appId, Integer orderType, boolean isMember, List<CartGoods> cartGoodsList, List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons, List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, String menuType, Long distributionFee) {
ActivityCalculationDiscountRequestDto activityCalculationDiscountRequestDto = getActivityCalculationDiscountRequestDto(partnerId, storeId, userId, appId, orderType);
......
......@@ -791,6 +791,9 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
CheckCartRequest checkCartRequest = assortmentSdkService.checkShoppingCartSdk(cartGoodsList, partnerId, storeId, shoppingCartGoodsResponseVo,
shoppingCartInfoRequestVo.getOrderType(), tableNumber, shoppingCartInfoRequestVo.getMenuType() ,shoppingCartBaseService);
com.freemud.sdk.api.assortment.shoppingcart.domain.ShoppingCartGoodsResponseVo cartGoodsResponseVo = checkCartRequest.getShoppingCartGoodsResponseVo();
// 校验商品券库存
//商品不再售卖状态或价格变动,直接返回报错
if (cartGoodsResponseVo != null) {
if (cartGoodsResponseVo.getCartGoodsStates() != null && cartGoodsResponseVo.getCartGoodsStates().isHasInvalidGoods()) {
......@@ -1004,6 +1007,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
validCouponMap.put(spqId, checkSpqInfoResponseDto);
cartGoods.setName(checkSpqInfoResponseDto.getCouponName());
cartGoods.setSpuName(checkSpqInfoResponseDto.getCouponName());
cartGoods.setStockLimit(checkSpqInfoResponseDto.isStockLimit());
// 添加请求的优惠券信息
ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon coupon = new ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon();
coupon.setCode(checkSpqInfoResponseDto.getCouponCode());
......
......@@ -106,7 +106,7 @@ public class CalculationSharingDiscountService {
validCouponMap.put(spqId, checkSpqInfo);
cartGoods.setName(checkSpqInfo.getCouponName());
cartGoods.setSpuName(checkSpqInfo.getCouponName());
cartGoods.setStockLimit(checkSpqInfo.isStockLimit());
CalculationSharingDiscountRequestDto.CalculationDiscountCoupon coupon = new CalculationSharingDiscountRequestDto.CalculationDiscountCoupon();
coupon.setCode(checkSpqInfo.getCouponCode());
coupon.setActivityCode(checkSpqInfo.getActiveCode());
......
......@@ -123,6 +123,8 @@ public class ShoppingCartMCoffeeServiceImpl {
private String mcCafeUniversalCouponCode;
@Value("${mccafe.pay.card.fee}")
private String payCardFee;
@Value("${mccafe.tableware.skuId}")
private String mcCafeTablewareSkuId;
/**
* 添加商品、超值加购、商品券
......@@ -174,6 +176,14 @@ public class ShoppingCartMCoffeeServiceImpl {
if (CollectionUtils.isEmpty(oldCartGoodsList)) {
oldCartGoodsList = new ArrayList<>();
}
if(mcCafeTablewareSkuId.equals(skuId)) {
for(CartGoods cartGoods : oldCartGoodsList) {
if(mcCafeTablewareSkuId.equals(cartGoods.getSkuId())) {
return ResponseUtil.error(ResponseResult.SHOPPING_CART_ADD_ERROR.getCode(), "不能重复添加餐具商品");
}
}
}
//商品券已添加情况校验
List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons = checkGoodsCoupon(oldCartGoodsList, operationType, couponCode,goodsId,addShoppingCartGoodsRequestVo);
CartGoods addCartGoods = convent2CartGoods(addShoppingCartGoodsRequestVo, goodsId ,vo);
......@@ -833,6 +843,14 @@ public class ShoppingCartMCoffeeServiceImpl {
// 如果购物车商品不为空, 则check购物车中所有商品
if (CollectionUtils.isEmpty(cartGoodsList)) {
return ResponseUtil.success(shoppingCartGoodsResponseVo);
} else {
//移除餐具商品
for(int i=0;i<cartGoodsList.size();i++) {
if(mcCafeTablewareSkuId.equals(cartGoodsList.get(i).getSkuId())) {
cartGoodsList.remove(i);
break;
}
}
}
List<CartGoods> onlyCheckGoodsList = new ArrayList<>();
......@@ -1589,6 +1607,23 @@ public class ShoppingCartMCoffeeServiceImpl {
if (CollectionUtils.isNotEmpty(reduceGoods)) {
allCartGoodsList.addAll(reduceGoods);
}
//如果是餐具商品,则放到最后
if (CollectionUtils.isNotEmpty(allCartGoodsList)) {
int size = allCartGoodsList.size();
for(int i=0;i<size;i++) {
if(allCartGoodsList.get(i).getSkuId().equals(mcCafeTablewareSkuId)) {
CartGoods cartGoods = allCartGoodsList.get(i);
cartGoods.setIsTableware(true);
if(i != size-1) {
allCartGoodsList.remove(i);
allCartGoodsList.add(cartGoods);
i--;
}
}
}
}
return allCartGoodsList;
}
......
......@@ -19,6 +19,7 @@ import cn.freemud.service.CommonService;
import cn.freemud.service.impl.ItemServiceImpl;
import cn.freemud.service.thirdparty.ActivityClient;
import cn.freemud.utils.PropertyConvertUtil;
import com.alibaba.fastjson.JSON;
import com.freemud.application.sdk.api.log.ErrorLog;
import com.freemud.application.sdk.api.log.LogThreadLocal;
import com.freemud.application.sdk.api.membercenter.request.QueryReceiveAddressRequest;
......@@ -30,6 +31,7 @@ import com.freemud.application.sdk.api.storecenter.response.QueryDeliverDetailRe
import com.freemud.application.sdk.api.storecenter.response.StoreResponse;
import com.freemud.application.sdk.api.storecenter.service.StoreCenterService;
import com.freemud.sdk.api.assortment.shoppingcart.enums.BusinessTypeEnum;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -53,6 +55,7 @@ import java.util.stream.Collectors;
*/
@Service
@Slf4j
public class CalculationServiceImpl {
......@@ -171,6 +174,7 @@ public class CalculationServiceImpl {
public void updateShoppingCartGoodsApportion(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult,
ShoppingCartGoodsDto shoppingCartGoodsDto, CreateOrderVo.PremiumExchangeActivity premiumExchangeActivity, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo){
log.info(111111+JSON.toJSONString(shoppingCartGoodsDto));
List<ShoppingCartGoodsDto.CartGoodsDetailDto> cartGoodsDetailDtoList = CollectionUtils.isEmpty(shoppingCartGoodsDto.getProducts()) ? new ArrayList<>() : shoppingCartGoodsDto.getProducts();
List<ShareDiscountActivityDto> shareDiscountActivityDtoList = CollectionUtils.isEmpty(shoppingCartGoodsDto.getShareDiscountActivityDtos()) ? new ArrayList<>() : shoppingCartGoodsDto.getShareDiscountActivityDtos();
//设置空
......@@ -208,6 +212,7 @@ public class CalculationServiceImpl {
List<ShoppingCartGoodsDto.CartGoodsDetailDto> cartGoodsDetailDtos = shoppingCartConvertAdapter.convertCartGoods2DetailGoodsList(cartGoods, apportionGoodsList,duplicateGoodsMap);
cartGoodsDetailDtoList.addAll(cartGoodsDetailDtos);
}
log.info(22222222+JSON.toJSONString(shoppingCartGoodsDto));
List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Discount> discounts = calculationDiscountResult == null ? new ArrayList<>() : calculationDiscountResult.getDiscounts();
List<ActivityDiscountsDto> activityDiscountsDtos = shoppingCartGoodsDto.getActivityDiscountsDtos() == null ? new ArrayList<>() : shoppingCartGoodsDto.getActivityDiscountsDtos();
for (ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Discount discount : discounts) {
......@@ -267,6 +272,7 @@ public class CalculationServiceImpl {
// fullPromotionCalculation.updateShoppingCartGoodsApportion(shoppingCartGoodsResponseVo, calculationDiscountResult, shoppingCartGoodsDto,premiumExchangeActivity,shoppingCartInfoRequestVo);
//限时特价
timeSaleCalculation.updateShoppingCartGoodsApportion(calculationDiscountResult, shoppingCartGoodsDto);
log.info(333333333+JSON.toJSONString(shoppingCartGoodsDto));
CouponPromotionVO couponPromotionVO = new CouponPromotionVO();
// couponPromotionVO.setPartnerId("1206");
......@@ -277,8 +283,10 @@ public class CalculationServiceImpl {
// couponPromotionVO.setFlg(CouponFlag.YES.getCode());
//优惠券
couponDiscountCalculation.updateShoppingCartGoodsApportion(calculationDiscountResult, shoppingCartGoodsDto, shoppingCartInfoRequestVo);
log.info(444444444+JSON.toJSONString(shoppingCartGoodsDto));
setMealCalculation.updateShoppingCartGoodsApportion(shoppingCartGoodsResponseVo, calculationDiscountResult, shoppingCartGoodsDto);
log.info(555555555+JSON.toJSONString(shoppingCartGoodsDto));
}
......
......@@ -24,6 +24,7 @@ import cn.freemud.utils.WebUtil;
import com.freemud.application.sdk.api.log.ApiLog;
import com.freemud.application.sdk.api.log.LogThreadLocal;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -31,7 +32,7 @@ import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Service("cocoShoppingCartRelationService")
public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelationService {
......@@ -98,7 +99,7 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
// 非结算页
orderingFoodPage(products,halfDiscountsMap,goodsDiscountsMap,gifeProductIds,shoppingCartGoodsResponseVo);
}else {// 结算页
settlementPage(products,halfDiscountsMap,goodsDiscountsMap,shoppingCartGoodsResponseVo);
settlementPage(products,halfDiscountsMap,goodsDiscountsMap,shoppingCartGoodsResponseVo,gifeProductIds);
}
}
......@@ -140,7 +141,7 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
}
public CartGoods buildNewLine(CartGoods cgs,Integer activityType,Integer qty,Long newPrice,String goodsId){
public CartGoods buildNewLine(CartGoods cgs,Integer activityType,Integer qty,Long newPrice,String goodsId,Long originalPrice){
CartGoods newCartGoods = new CartGoods();
// 购物车的行设置和原来的行一致,便于前端在更新商品数量的时候。能够根据购物车行聚合商品数量
// 因为半价行是从主行中拆出来的
......@@ -153,11 +154,11 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
newCartGoods.setSkuId(cgs.getSkuId());
newCartGoods.setSpecProductId(cgs.getSpecProductId());
// 价格只用一个商品的价格
newCartGoods.setOriginalPrice(cgs.getOriginalPrice());
newCartGoods.setOriginalPrice(originalPrice);
// 价格只用一个商品的价格
newCartGoods.setPackPrice(cgs.getPackPrice());
// 价格只用一个商品的价格
newCartGoods.setOriginalAmount(cgs.getOriginalPrice());
newCartGoods.setOriginalAmount(originalPrice);
// 价格只用一个商品的价格
newCartGoods.setFinalPrice(newPrice);
// 价格只用一个商品的价格
......@@ -186,6 +187,7 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
newCartGoods.setClassificationName(cgs.getClassificationName());
newCartGoods.setActivityType(activityType);
newCartGoods.setQty(qty);
newCartGoods.setProductMaterialList(cgs.getProductMaterialList());
return newCartGoods;
}
......@@ -200,7 +202,8 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
public void settlementPage(List<CartGoods> products,
Map<String,CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount> halfDiscountsMap,
Map<String,CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods> goodsDiscountsMap,
ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo){
ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo,
List<String> gifeProductIds){
// 第二件优惠活动(单品优惠)要把一行商品分成多行,且每行商品数量是1,同时要有两行是打活动标的
List<CartGoods> newProducts = new ArrayList<>();
......@@ -210,6 +213,28 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
for(int x = 0 ; x < products.size() ; x ++){
CartGoods product = products.get(x);
List<CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.SmallMaterial> smallMaterial = goodsDiscountsMap.get(product.getCartGoodsUid()).getSmallMaterial();
Integer smallMaterialOriTotal = 0;
Long halfSmallMaterialOriTotal = 0L;
if(smallMaterial != null && !smallMaterial.isEmpty()){
for(CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.SmallMaterial sm : smallMaterial){
List<CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount> smDiscounts = sm.getDiscounts();
if(smDiscounts != null && !smDiscounts.isEmpty()){
for(CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount smDiscount : smDiscounts){
if(ObjectUtils.equals(smDiscount.getType(),ActivityTypeEnum.TYPE_53.getCode())){
halfSmallMaterialOriTotal = halfSmallMaterialOriTotal + smDiscount.getSignleDiscount();
}
}
}
smallMaterialOriTotal = smallMaterialOriTotal + sm.getOriginalPrice();
}
}
// 商品的单价 = 商品单价+小料单价
Long originalPrice = (new Long(smallMaterialOriTotal) + product.getOriginalPrice());
// 这一行的商品参加了第二件优惠活动(单品优惠)
if( halfDiscountsMap.get(product.getCartGoodsUid() + "-" + product.getGoodsId()) != null){
// 行商品数量
......@@ -218,9 +243,9 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
// 构建半价行
CartGoods cartGoods = new CartGoods();
if(i < 2){
cartGoods = buildNewLine(product,ActivityTypeEnum.TYPE_53.getCode(),1,product.getFinalPrice(),product.getGoodsId());
cartGoods = buildNewLine(product,ActivityTypeEnum.TYPE_53.getCode(),1,originalPrice,product.getGoodsId(),originalPrice);
}else{
cartGoods = buildNewLine(product,ActivityTypeEnum.TYPE_53.getCode(),1,product.getFinalPrice(),null);
cartGoods = buildNewLine(product,ActivityTypeEnum.TYPE_53.getCode(),1,originalPrice,null,originalPrice);
}
newProducts.add(cartGoods);
......@@ -229,13 +254,23 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
continue;
}
// 限时特检的现单价获取促销的现单价
// 商品是否参加特价
// 限时立减的现单价获取促销的现单价
// 商品是否参加单品立减
boolean cutFlag = hashCutActive(goodsDiscountsMap,product);
if(cutFlag){
product.setFinalPrice(goodsDiscountsMap.get(product.getCartGoodsUid()).getNowPrice());
}
// 商品的单价 = 商品单价+小料单价
product.setOriginalPrice(originalPrice);
// 如果是赠品行,这行的价格就不用算了
if(!gifeProductIds.contains(product.getGoodsId()) && product.getActivityType() == null){
// 商品现单价 = 商品现单价+小料现单价
smallMaterialOriTotal = smallMaterialOriTotal == null ? 0 : smallMaterialOriTotal;
product.setFinalPrice(new Long(smallMaterialOriTotal) + (product.getFinalPrice() == null ? 0L : product.getFinalPrice()));
}
newProducts.add(product);
}
shoppingCartGoodsResponseVo.setProducts(newProducts);
......@@ -262,7 +297,33 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
List<CartGoods> halfProduct = new ArrayList<>();
for(int x = 0 ; x < products.size() ; x ++){
CartGoods product = products.get(x);
// 小料信息
if(goodsDiscountsMap.get(product.getCartGoodsUid()) == null){
continue;
}
List<CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.SmallMaterial> smallMaterial = goodsDiscountsMap.get(product.getCartGoodsUid()).getSmallMaterial();
Integer smallMaterialOriTotal = 0;
Long halfSmallMaterialOriTotal = 0L;
if(smallMaterial != null && !smallMaterial.isEmpty()){
for(CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.SmallMaterial sm : smallMaterial){
List<CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount> smDiscounts = sm.getDiscounts();
if(smDiscounts != null && !smDiscounts.isEmpty()){
for(CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount smDiscount : smDiscounts){
if(ObjectUtils.equals(smDiscount.getType(),ActivityTypeEnum.TYPE_53.getCode())){
halfSmallMaterialOriTotal = halfSmallMaterialOriTotal + smDiscount.getSignleDiscount();
}
}
}
smallMaterialOriTotal = smallMaterialOriTotal + sm.getOriginalPrice();
}
}
// 商品的单价 = 商品单价+小料单价
Long originalPrice = (new Long(smallMaterialOriTotal) + product.getOriginalPrice());
// 要添加的半价行数量,该字段从促销返回
Integer num = 0;
// 商品优惠的金额
......@@ -277,9 +338,11 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
// 第二件优惠活动,在点餐页需要给优惠商品单独显示一行
// 复制商品加到购物车
discountAmount = discount.getDiscount();
Long newPrice = product.getOriginalPrice() - discountAmount;
// 现单价 = 商品原单价+小料原单价-商品现单价小料现单价
Long newPrice = originalPrice - discountAmount - halfSmallMaterialOriTotal;
// 构建半价行
CartGoods cartGoods = buildNewLine(product,ActivityTypeEnum.TYPE_53.getCode(),1,newPrice,product.getGoodsId());
CartGoods cartGoods = buildNewLine(product,ActivityTypeEnum.TYPE_53.getCode(),1,newPrice,product.getGoodsId(),originalPrice);
halfProduct.add(cartGoods);
}
}
......@@ -292,7 +355,7 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
product.setQty(newQty);
// 商品是否参加特价
// 商品是否参加立减
boolean cutFlag = hashCutActive(goodsDiscountsMap,product);
if(cutFlag){
product.setFinalPrice(goodsDiscountsMap.get(product.getCartGoodsUid()).getNowPrice());
......@@ -313,6 +376,14 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
product.setGoodsId(null);
}
// 商品的单价 = 商品单价+小料单价
product.setOriginalPrice(originalPrice);
// 如果是赠品行,这行的价格就不用算了
if(!gifeProductIds.contains(product.getGoodsId()) && product.getActivityType() == null){
// 商品现单价 = 商品现单价+小料现单价
smallMaterialOriTotal = smallMaterialOriTotal == null ? 0 : smallMaterialOriTotal;
product.setFinalPrice(new Long(smallMaterialOriTotal) + (product.getFinalPrice() == null ? 0L : product.getFinalPrice()));
}
newProducts.add(product);
}
......@@ -325,7 +396,7 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
}
/**
* 判断商品是否参加了限时特价
* 判断商品是否参加了立减
* @param goodsDiscountsMap
* @param product
* @return
......@@ -339,7 +410,7 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
List<CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount> goodsDiscountsList = goods.getDiscounts();
if(goodsDiscountsList != null && !goodsDiscountsList.isEmpty()){
for(CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount gd : goodsDiscountsList){
if(ObjectUtils.equals(gd.getType(),ActivityTypeEnum.TYPE_2.getCode())){
if(ObjectUtils.equals(gd.getType(),ActivityTypeEnum.TYPE_22.getCode())){
cutFlag = true;
break;
}
......
......@@ -23,4 +23,3 @@ management.endpoint.shutdown.enabled=true
management.security.enabled=false
management.health.rabbit.enabled=false
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