Commit 8f5c5e47 by 张洪旺

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

parents 6fa35f93 241e9d35
...@@ -323,12 +323,14 @@ public class OrderCenterSdkServiceImpl implements OrderCenterSdkService { ...@@ -323,12 +323,14 @@ public class OrderCenterSdkServiceImpl implements OrderCenterSdkService {
BaseResponse<GetMemberExtendInfoResponse> extendInfo = new BaseResponse(); BaseResponse<GetMemberExtendInfoResponse> extendInfo = new BaseResponse();
try { try {
QueryByCodeResponse codeResponse = orderSdkService.getOrderInfo(confirmOrderRequest.getProductOrderCode(), 0, confirmOrderRequest.getTrackingNo()); QueryByCodeResponse codeResponse = orderSdkService.getOrderInfo(confirmOrderRequest.getProductOrderCode(), 0, confirmOrderRequest.getTrackingNo());
orderByIdResponse = orderSdkAdapter.convent2QueryOrderByIdResponse(codeResponse); orderByIdResponse = orderSdkAdapter.convent2QueryOrderByIdResponse(codeResponse);
GetMemberExtendInfoRequest extendInfoRequest = new GetMemberExtendInfoRequest(); GetMemberExtendInfoRequest extendInfoRequest = new GetMemberExtendInfoRequest();
extendInfoRequest.setMemberId(orderByIdResponse.getData().getUserId()); extendInfoRequest.setMemberId(orderByIdResponse.getData().getUserId());
extendInfoRequest.setPartnerId(orderByIdResponse.getData().getCompanyId()); extendInfoRequest.setPartnerId(orderByIdResponse.getData().getCompanyId());
extendInfo = memberCenterService.getMemberExtendInfo(extendInfoRequest, confirmOrderRequest.getTrackingNo()); extendInfo = memberCenterService.getMemberExtendInfo(extendInfoRequest, confirmOrderRequest.getTrackingNo());
OrderExtInfoDto extInfoDTO = JSONObject.parseObject(orderByIdResponse.getData().getExtInfo(),OrderExtInfoDto.class); OrderExtInfoDto extInfoDTO = JSONObject.parseObject(orderByIdResponse.getData().getExtInfo(),OrderExtInfoDto.class);
extInfoDTO.setMemberLevel(extendInfo.getData().getMemberGrade()!=null?extendInfo.getData().getMemberGrade().getRuleName():""); extInfoDTO.setMemberLevel(extendInfo.getData().getMemberGrade()!=null?extendInfo.getData().getMemberGrade().getRuleName():"");
extInfoDTO.setPaidMember(CollectionUtils.isNotEmpty(extendInfo.getData().getMemberPaids())); extInfoDTO.setPaidMember(CollectionUtils.isNotEmpty(extendInfo.getData().getMemberPaids()));
...@@ -341,8 +343,10 @@ public class OrderCenterSdkServiceImpl implements OrderCenterSdkService { ...@@ -341,8 +343,10 @@ public class OrderCenterSdkServiceImpl implements OrderCenterSdkService {
ErrorLog.printErrorLog("getMemberExtendInfoError",MEMBER_EXTEND_INFO,confirmOrderRequest,e); ErrorLog.printErrorLog("getMemberExtendInfoError",MEMBER_EXTEND_INFO,confirmOrderRequest,e);
} }
com.freemud.application.sdk.api.ordercenter.response.BaseResponse<PaySuccessResp> response = orderSdkService.paySuccess(request, confirmOrderRequest.getTrackingNo()); com.freemud.application.sdk.api.ordercenter.response.BaseResponse<PaySuccessResp> response = orderSdkService.paySuccess(request, confirmOrderRequest.getTrackingNo());
//获取会员信息失败直接返回,非空判断 //获取会员信息失败直接返回,非空判断
if(extendInfo.getData() == null){ if(extendInfo.getData() == null){
return orderSdkAdapter.convent2PayAccessResponse(response); return orderSdkAdapter.convent2PayAccessResponse(response);
} }
......
...@@ -1220,7 +1220,7 @@ public class OrderAdapter { ...@@ -1220,7 +1220,7 @@ public class OrderAdapter {
responseVo.setOidBase64Image(oidBase64Image); 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.setHasThirdDelivery(true);
responseVo.setDeliveryId(ordersBean.getAddInfo().getDeliveryId()); responseVo.setDeliveryId(ordersBean.getAddInfo().getDeliveryId());
} }
......
...@@ -471,6 +471,7 @@ public class OrderServiceImpl implements Orderservice { ...@@ -471,6 +471,7 @@ public class OrderServiceImpl implements Orderservice {
} }
// 如果订单状态不是未支付,返回信息 // 如果订单状态不是未支付,返回信息
if (!PayStatus.NOT_PAY.getCode().equals(orderBean.getPayStatus()) || !OrderStatus.WAIT_PAY.getCode().equals(orderBean.getStatus())) { if (!PayStatus.NOT_PAY.getCode().equals(orderBean.getPayStatus()) || !OrderStatus.WAIT_PAY.getCode().equals(orderBean.getStatus())) {
return sendPaySuccessNoticeMessage(); return sendPaySuccessNoticeMessage();
} }
//若该订单使用了优惠券,则移除卡包,移除失败也不退款,现在支付成功个调用核销,无需调用此功能 //若该订单使用了优惠券,则移除卡包,移除失败也不退款,现在支付成功个调用核销,无需调用此功能
......
...@@ -27,7 +27,7 @@ public interface OrderRelationService { ...@@ -27,7 +27,7 @@ public interface OrderRelationService {
/** /**
* 创建订单的时间检查 * 订单详情编辑
* @param * @param
*/ */
void queryOrdrBuild(QueryOrderResponseVo queryOrderResponseVo,QueryOrderByIdResponse response); void queryOrdrBuild(QueryOrderResponseVo queryOrderResponseVo,QueryOrderByIdResponse response);
......
...@@ -17,17 +17,22 @@ import cn.freemud.entities.dto.order.BusinessDate; ...@@ -17,17 +17,22 @@ import cn.freemud.entities.dto.order.BusinessDate;
import cn.freemud.entities.vo.CreateOrderVo; import cn.freemud.entities.vo.CreateOrderVo;
import cn.freemud.entities.vo.ProductVo; import cn.freemud.entities.vo.ProductVo;
import cn.freemud.entities.vo.QueryOrderResponseVo; import cn.freemud.entities.vo.QueryOrderResponseVo;
import cn.freemud.enums.ActivityTypeEnum;
import cn.freemud.enums.CreateOrderType; import cn.freemud.enums.CreateOrderType;
import cn.freemud.enums.ResponseResult; import cn.freemud.enums.ResponseResult;
import cn.freemud.interceptor.ServiceException; import cn.freemud.interceptor.ServiceException;
import cn.freemud.service.impl.CheckOrder; import cn.freemud.service.impl.CheckOrder;
import cn.freemud.service.order.OrderRelationService; import cn.freemud.service.order.OrderRelationService;
import com.alibaba.fastjson.JSONObject;
import com.freemud.application.sdk.api.ordercenter.response.orderInfo.OrderSendCouponResp; import com.freemud.application.sdk.api.ordercenter.response.orderInfo.OrderSendCouponResp;
import com.freemud.application.sdk.api.storecenter.response.StoreResponse; import com.freemud.application.sdk.api.storecenter.response.StoreResponse;
import com.freemud.application.sdk.api.storecenter.service.StoreCenterService; 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.response.order.QueryOrderByIdResponse; 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; import io.swagger.models.auth.In;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -101,6 +106,12 @@ public class CocoOrderRelationServiceImpl implements OrderRelationService { ...@@ -101,6 +106,12 @@ public class CocoOrderRelationServiceImpl implements OrderRelationService {
queryOrderResponseVo.setChooseGoods(chooseGoods); queryOrderResponseVo.setChooseGoods(chooseGoods);
} }
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));
}
// 赠品合并到主商品 // 赠品合并到主商品
List<ProductVo> products = queryOrderResponseVo.getProducts(); List<ProductVo> products = queryOrderResponseVo.getProducts();
...@@ -119,13 +130,35 @@ public class CocoOrderRelationServiceImpl implements OrderRelationService { ...@@ -119,13 +130,35 @@ public class CocoOrderRelationServiceImpl implements OrderRelationService {
} }
if(null != masterProducts && !masterProducts.isEmpty()){ if(null != masterProducts && !masterProducts.isEmpty()){
masterProducts.forEach(product -> { for(ProductVo product : masterProducts){
Integer giftQty = giftMap.get(product.getCid()) == null ? 0 : giftMap.get(product.getCid()); Integer giftQty = giftMap.get(product.getCid()) == null ? 0 : giftMap.get(product.getCid());
product.setQty(product.getQty() + giftQty); product.setQty(product.getQty() + giftQty);
}); // 如果商品参加了第二件半价活动,要把该行拆成数量为1的多行
QueryOrdersResponse.DataBean.OrderBean.ProductBean productBean = productMap.get(product.getCid());
if(productBean == null || productBean.getDiscountList() == null || productBean.getDiscountList().isEmpty()){
continue;
}
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)){
halfFlag = true;
break;
}
}
if(halfFlag){
Integer num = product.getQty();
for(int i = 0 ; i < num-1 ; i++){
ProductVo newProduct = JSONObject.parseObject(JSONObject.toJSONString(product),ProductVo.class);
newProduct.setQty(1);
}
product.setQty(1);
}
} }
queryOrderResponseVo.setProducts(masterProducts);
} }
queryOrderResponseVo.setProducts(masterProducts);
}
} }
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
<dependency> <dependency>
<groupId>cn.freemud</groupId> <groupId>cn.freemud</groupId>
<artifactId>assortment-ordercenter-sdk</artifactId> <artifactId>assortment-ordercenter-sdk</artifactId>
<version>2.2.15-SNAPSHOT</version> <version>2.2.20-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
......
...@@ -3,6 +3,7 @@ package com.freemud.application.sdk.api.ordercenter.service; ...@@ -3,6 +3,7 @@ package com.freemud.application.sdk.api.ordercenter.service;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.freemud.application.sdk.api.base.BaseRequest; import com.freemud.application.sdk.api.base.BaseRequest;
import com.freemud.application.sdk.api.log.ApiLog;
import com.freemud.application.sdk.api.ordercenter.config.OrderCenterProperties; import com.freemud.application.sdk.api.ordercenter.config.OrderCenterProperties;
import com.freemud.application.sdk.api.ordercenter.constant.InterfaceAddressConstant; import com.freemud.application.sdk.api.ordercenter.constant.InterfaceAddressConstant;
import com.freemud.application.sdk.api.ordercenter.constant.ResponseConstant; import com.freemud.application.sdk.api.ordercenter.constant.ResponseConstant;
......
...@@ -871,14 +871,15 @@ public class ShoppingCartConvertAdapter { ...@@ -871,14 +871,15 @@ public class ShoppingCartConvertAdapter {
//套餐可选商品 //套餐可选商品
if (CollectionUtils.isNotEmpty(cartGoods.getProductGroupList())) { if (CollectionUtils.isNotEmpty(cartGoods.getProductGroupList())) {
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods comboxGoods : cartGoods.getProductGroupList()){ for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods comboxGoods : cartGoods.getProductGroupList()){
ProductTypeBeanDTO productBeanDTO = subProductTypeMap.get(comboxGoods.getSpuId());
//套餐子商品多规格商品 //套餐子商品多规格商品
if(comboxGoods.getSpuId() != null && !comboxGoods.getSkuId().equals(comboxGoods.getSpuId()) ){ if(comboxGoods.getSpuId() != null && !comboxGoods.getSkuId().equals(comboxGoods.getSpuId()) ){
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods productGroup : cartGoods.getProductGroupList()) { for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods productGroup : cartGoods.getProductGroupList()) {
updateComboxGoodsInfoForMCoffee(productGroup, spuProduct, false); updateComboxGoodsInfoForMCoffee(productGroup, productBeanDTO, false);
} }
}else { }else {
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods productGroup : cartGoods.getProductGroupList()) { for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods productGroup : cartGoods.getProductGroupList()) {
updateComboxGoodsInfoForMCoffee(productGroup, spuProduct, false); updateComboxGoodsInfoForMCoffee(productGroup, productBeanDTO, false);
} }
} }
} }
......
...@@ -36,4 +36,10 @@ public class ShoppingCartClearRequestVo extends BaseRequestVo { ...@@ -36,4 +36,10 @@ public class ShoppingCartClearRequestVo extends BaseRequestVo {
* 拼单发起人userId(拼单) * 拼单发起人userId(拼单)
*/ */
private String createCollageUserId; private String createCollageUserId;
/**
* 收货地址ID、svc卡支付外卖订单必传
*/
private String receiveId;
} }
...@@ -745,6 +745,10 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -745,6 +745,10 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
shoppingCartGoodsResponseVo.setActivityTip(activityTip); shoppingCartGoodsResponseVo.setActivityTip(activityTip);
shoppingCartGoodsResponseVo.setProducts(new ArrayList<>()); shoppingCartGoodsResponseVo.setProducts(new ArrayList<>());
shoppingCartGoodsResponseVo.setProductsCount(0); shoppingCartGoodsResponseVo.setProductsCount(0);
ShoppingCartRelationService shoppingCartRelationService = shoppingCartRelationFactory.cleanAfter(shoppingCartClearRequestVo.getPartnerId());
shoppingCartRelationService.cleanAfter(shoppingCartGoodsResponseVo,shoppingCartClearRequestVo);
return ResponseUtil.success(shoppingCartGoodsResponseVo); return ResponseUtil.success(shoppingCartGoodsResponseVo);
} }
...@@ -1890,7 +1894,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -1890,7 +1894,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
return calculationDiscountResult; return calculationDiscountResult;
} }
private Long calculateDeliveryAmount(String receiveId, String partnerId, String storeId, String wxappid, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo,Integer orderType) { public Long calculateDeliveryAmount(String receiveId, String partnerId, String storeId, String wxappid, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo,Integer orderType) {
Long deliveryAmount = 0L; Long deliveryAmount = 0L;
// 如果订单的收获地址为空,且订单是外卖单,返回运费 // 如果订单的收获地址为空,且订单是外卖单,返回运费
// 主要是为了兼容coco不传收获地址,需要获取固定运费的情况 // 主要是为了兼容coco不传收获地址,需要获取固定运费的情况
......
...@@ -270,8 +270,10 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -270,8 +270,10 @@ public class ShoppingCartMCoffeeServiceImpl {
isContinue= false; isContinue= false;
} }
if(StringUtils.isNotEmpty(goodsId) && StringUtils.isNotEmpty(couponCode) && isContinue if(StringUtils.isNotEmpty(goodsId) && StringUtils.isNotEmpty(couponCode) && isContinue
&& cartGoods.getName().equals("啡常搭") && CollectionUtils.isNotEmpty(cartGoods.getProductComboList()) && cartGoods.getProductComboList().size() == 1 && (cartGoods.getName().equals("拿铁") || cartGoods.getName().equals("美式")) && cartGoods.getGoodsType().equals(GoodsTypeEnum.SET_MEAL_GOODS.getGoodsType())
&& CollectionUtils.isEmpty(cartGoods.getProductGroupList()) && cartGoods.getProductComboList().get(0).getSkuId().equals(goodsId)) { && CollectionUtils.isNotEmpty(cartGoods.getProductComboList()) && cartGoods.getProductComboList().size() == 1
&& cartGoods.getProductComboList().get(0).getSkuId().equals(goodsId)
&& CollectionUtils.isEmpty(cartGoods.getProductGroupList())) {
// 如果购物车商品存在商品规格,替换时复制规格信息 // 如果购物车商品存在商品规格,替换时复制规格信息
if (CollectionUtils.isNotEmpty(cartGoods.getProductComboList().get(0).getSpecialExtra())) { if (CollectionUtils.isNotEmpty(cartGoods.getProductComboList().get(0).getSpecialExtra())) {
addShoppingCartGoodsRequestVo.setSpecialExtra(cartGoods.getProductComboList().get(0).getSpecialExtra()); addShoppingCartGoodsRequestVo.setSpecialExtra(cartGoods.getProductComboList().get(0).getSpecialExtra());
......
...@@ -20,4 +20,11 @@ public interface ShoppingCartRelationFactory { ...@@ -20,4 +20,11 @@ public interface ShoppingCartRelationFactory {
*/ */
ShoppingCartRelationService getBuildShoppingCartGoodsResponseService(String partnerId); ShoppingCartRelationService getBuildShoppingCartGoodsResponseService(String partnerId);
/**
* 获取购物车清空后的操作实现
* @param partnerId
* @return
*/
ShoppingCartRelationService cleanAfter(String partnerId);
} }
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
package cn.freemud.service.shoppingCart; package cn.freemud.service.shoppingCart;
import cn.freemud.entities.dto.calculate.CalculationSharingDiscountResponseDto; import cn.freemud.entities.dto.calculate.CalculationSharingDiscountResponseDto;
import cn.freemud.entities.vo.ShoppingCartClearRequestVo;
import cn.freemud.entities.vo.ShoppingCartGoodsResponseVo; import cn.freemud.entities.vo.ShoppingCartGoodsResponseVo;
public interface ShoppingCartRelationService { public interface ShoppingCartRelationService {
...@@ -24,5 +25,10 @@ public interface ShoppingCartRelationService { ...@@ -24,5 +25,10 @@ public interface ShoppingCartRelationService {
CalculationSharingDiscountResponseDto.CalculationDiscountResult discountResult, CalculationSharingDiscountResponseDto.CalculationDiscountResult discountResult,
Integer flag); Integer flag);
/**
* 购物车清空后的扩展操作
*/
void cleanAfter(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ShoppingCartClearRequestVo shoppingCartClearRequestVo);
} }
...@@ -13,16 +13,20 @@ ...@@ -13,16 +13,20 @@
package cn.freemud.service.shoppingCart.impl; package cn.freemud.service.shoppingCart.impl;
import cn.freemud.adapter.ActivityAdapter;
import cn.freemud.entities.dto.PromotionMessageDto;
import cn.freemud.entities.dto.calculate.CalculationSharingDiscountResponseDto; import cn.freemud.entities.dto.calculate.CalculationSharingDiscountResponseDto;
import cn.freemud.entities.vo.CartGoods; import cn.freemud.entities.vo.*;
import cn.freemud.entities.vo.ShoppingCartGoodsResponseVo;
import cn.freemud.enums.ActivityTypeEnum; import cn.freemud.enums.ActivityTypeEnum;
import cn.freemud.service.impl.ShoppingCartNewServiceImpl;
import cn.freemud.service.shoppingCart.ShoppingCartRelationService; import cn.freemud.service.shoppingCart.ShoppingCartRelationService;
import cn.freemud.utils.WebUtil;
import com.freemud.application.sdk.api.log.ApiLog; import com.freemud.application.sdk.api.log.ApiLog;
import com.freemud.application.sdk.api.log.LogThreadLocal; import com.freemud.application.sdk.api.log.LogThreadLocal;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
...@@ -31,6 +35,9 @@ import java.util.stream.Collectors; ...@@ -31,6 +35,9 @@ import java.util.stream.Collectors;
@Service("cocoShoppingCartRelationService") @Service("cocoShoppingCartRelationService")
public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelationService { public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelationService {
@Autowired
private ShoppingCartNewServiceImpl shoppingCartNewServiceImpl;
@Override @Override
public void buildShoppingCartGoodsResponse(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, public void buildShoppingCartGoodsResponse(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo,
...@@ -86,9 +93,168 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation ...@@ -86,9 +93,168 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
}); });
}); });
if(!Objects.equals(flag,1)){
// 非结算页
orderingFoodPage(products,halfDiscountsMap,goodsDiscountsMap,gifeProductIds,shoppingCartGoodsResponseVo);
}else {// 结算页
settlementPage(products,halfDiscountsMap,goodsDiscountsMap,shoppingCartGoodsResponseVo);
}
}
// 购物车顶部的提示不只是满减的提示,只要用户参加了活动,就应该把优惠的金额放到上面
// 获取用户的优惠金额,重新编辑用户提示语
// 这里比较暴力的做法直接把已经编辑的结合直接删了,重新用一个新的
// 并且把tip类型设置为5,因为前端针对5直接显示立减文案
if(!ObjectUtils.equals(shoppingCartGoodsResponseVo.getTotalDiscountAmount(),0L)){
ArrayList<ActivityList> activityList = new ArrayList<>();
ActivityList notInShopping = new ActivityList();
notInShopping.setTipType(5);
// 直接取出整车的优惠
notInShopping.setDeduct(WebUtil.formatAmount(shoppingCartGoodsResponseVo.getTotalDiscountAmount() * 1.00 / 100).toString());
activityList.add(notInShopping);
ActivityTip activityTip = shoppingCartGoodsResponseVo.getActivityTip();
activityTip.setActivityList(activityList);
activityTip.setActivityList(activityList);
shoppingCartGoodsResponseVo.setActivityTip(activityTip);
}
}
@Override
public void cleanAfter(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ShoppingCartClearRequestVo shoppingCartClearRequestVo) {
String receiveId = shoppingCartClearRequestVo.getReceiveId();
String partnerId = shoppingCartClearRequestVo.getPartnerId();
String storeId = shoppingCartClearRequestVo.getShopId();
// 获取基础运费
Long deliveryAmount = shoppingCartNewServiceImpl.calculateDeliveryAmount(receiveId, partnerId, storeId, null, shoppingCartGoodsResponseVo,shoppingCartClearRequestVo.getOrderType());
shoppingCartGoodsResponseVo.setDeliveryAmount(deliveryAmount);
shoppingCartGoodsResponseVo.setDiscountDeliveryAmount(deliveryAmount);
}
public CartGoods buildNewLine(CartGoods cgs,Integer activityType,Integer qty,Long newPrice,String goodsId){
CartGoods newCartGoods = new CartGoods();
// 购物车的行设置和原来的行一致,便于前端在更新商品数量的时候。能够根据购物车行聚合商品数量
// 因为半价行是从主行中拆出来的
newCartGoods.setCartGoodsUid(cgs.getCartGoodsUid());
// 这个地方不要放置商品id,因为半价行的商品不打活动标签
// 前端会根据这个活动检索
newCartGoods.setGoodsType(cgs.getGoodsType());
newCartGoods.setGoodsId(goodsId);
newCartGoods.setSpuId(cgs.getSpuId());
newCartGoods.setSkuId(cgs.getSkuId());
newCartGoods.setSpecProductId(cgs.getSpecProductId());
// 价格只用一个商品的价格
newCartGoods.setOriginalPrice(cgs.getOriginalPrice());
// 价格只用一个商品的价格
newCartGoods.setPackPrice(cgs.getPackPrice());
// 价格只用一个商品的价格
newCartGoods.setOriginalAmount(cgs.getOriginalPrice());
// 价格只用一个商品的价格
newCartGoods.setFinalPrice(newPrice);
// 价格只用一个商品的价格
newCartGoods.setAmount(newPrice);
newCartGoods.setName(cgs.getName());
newCartGoods.setSpuName(cgs.getSpuName());
newCartGoods.setSubName(cgs.getSubName());
newCartGoods.setNodeId(cgs.getNodeId());
newCartGoods.setCategoryName(cgs.getCategoryName());
List<CartGoods.CartGoodsExtra> extra = Lists.newArrayList();
List<CartGoods.CartGoodsExtra> cartGoodsExtras = cgs.getExtra();
if (CollectionUtils.isNotEmpty(cartGoodsExtras)) {
cartGoodsExtras.forEach(cartGoodsExtra -> {
CartGoods.CartGoodsExtra goodsExtra = new CartGoods.CartGoodsExtra();
goodsExtra.setAttributeId(cartGoodsExtra.getAttributeId());
goodsExtra.setAttributeName(cartGoodsExtra.getAttributeName());
extra.add(goodsExtra);
});
}
newCartGoods.setExtra(extra);
newCartGoods.setPic(cgs.getPic());
newCartGoods.setCreateTimeMili(cgs.getCreateTimeMili());
newCartGoods.setSkuName(cgs.getSkuName());
newCartGoods.setSkuName(cgs.getSkuName());
newCartGoods.setClassificationId(cgs.getClassificationId());
newCartGoods.setClassificationName(cgs.getClassificationName());
newCartGoods.setActivityType(activityType);
newCartGoods.setQty(qty);
return newCartGoods;
}
/**
* 结算页
* @param products
* @param halfDiscountsMap
* @param goodsDiscountsMap
* @param shoppingCartGoodsResponseVo
*/
public void settlementPage(List<CartGoods> products,
Map<String,CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount> halfDiscountsMap,
Map<String,CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods> goodsDiscountsMap,
ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo){
// 第二件优惠活动(单品优惠)要把一行商品分成多行,且每行商品数量是1,同时要有两行是打活动标的
List<CartGoods> newProducts = new ArrayList<>(); List<CartGoods> newProducts = new ArrayList<>();
if(products == null || products.isEmpty()){
return;
}
for(int x = 0 ; x < products.size() ; x ++){
CartGoods product = products.get(x);
// 这一行的商品参加了第二件优惠活动(单品优惠)
if( halfDiscountsMap.get(product.getCartGoodsUid() + "-" + product.getGoodsId()) != null){
// 行商品数量
Integer num = product.getQty();
for(int i = 0 ; i < num ; i++){
// 构建半价行
CartGoods cartGoods = new CartGoods();
if(i < 2){
cartGoods = buildNewLine(product,ActivityTypeEnum.TYPE_53.getCode(),1,product.getFinalPrice(),product.getGoodsId());
}else{
cartGoods = buildNewLine(product,ActivityTypeEnum.TYPE_53.getCode(),1,product.getFinalPrice(),null);
}
if(!Objects.equals(flag,1)){// 非结算页 newProducts.add(cartGoods);
}
continue;
}
// 限时特检的现单价获取促销的现单价
// 商品是否参加特价
boolean cutFlag = hashCutActive(goodsDiscountsMap,product);
if(cutFlag){
product.setFinalPrice(goodsDiscountsMap.get(product.getCartGoodsUid()).getNowPrice());
}
newProducts.add(product);
}
shoppingCartGoodsResponseVo.setProducts(newProducts);
}
/**
* 点餐页
* @param products
* @param halfDiscountsMap
* @param goodsDiscountsMap
* @param gifeProductIds
* @param shoppingCartGoodsResponseVo
*/
public void orderingFoodPage(List<CartGoods> products,
Map<String,CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount> halfDiscountsMap,
Map<String,CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods> goodsDiscountsMap,
List<String> gifeProductIds,
ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo){
List<CartGoods> newProducts = new ArrayList<>();
if(products == null || products.isEmpty()){ if(products == null || products.isEmpty()){
return; return;
} }
...@@ -113,7 +279,7 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation ...@@ -113,7 +279,7 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
discountAmount = discount.getDiscount(); discountAmount = discount.getDiscount();
Long newPrice = product.getOriginalPrice() - discountAmount; Long newPrice = product.getOriginalPrice() - discountAmount;
// 构建半价行 // 构建半价行
CartGoods cartGoods = buildNewLine(product,ActivityTypeEnum.TYPE_53.getCode(),1,newPrice); CartGoods cartGoods = buildNewLine(product,ActivityTypeEnum.TYPE_53.getCode(),1,newPrice,product.getGoodsId());
halfProduct.add(cartGoods); halfProduct.add(cartGoods);
} }
} }
...@@ -125,12 +291,20 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation ...@@ -125,12 +291,20 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
product.setOriginalAmount(product.getOriginalAmount() - product.getOriginalPrice() * num); product.setOriginalAmount(product.getOriginalAmount() - product.getOriginalPrice() * num);
product.setQty(newQty); product.setQty(newQty);
// 商品的现单价使用促销返回的现单价
// 但是要排除赠品行、半价行 // 商品是否参加特价
if(!ObjectUtils.equals(product.getActivityType(),ActivityTypeEnum.TYPE_63.getCode()) && !ObjectUtils.equals(product.getActivityType(),ActivityTypeEnum.TYPE_53.getCode())){ boolean cutFlag = hashCutActive(goodsDiscountsMap,product);
if(cutFlag){
product.setFinalPrice(goodsDiscountsMap.get(product.getCartGoodsUid()).getNowPrice()); product.setFinalPrice(goodsDiscountsMap.get(product.getCartGoodsUid()).getNowPrice());
} }
// num代表拆出来的半价行数量
// 所以只要不等于0就需要把ActivityType设置为空
// 因为前端用这个判断是否能加减
if(!Objects.equals(num,0)){
product.setActivityType(null);
}
// num代表拆出来的半价行数量,gifeProductIds代表赠品 // num代表拆出来的半价行数量,gifeProductIds代表赠品
// 只要符合条件就需要设置为空 // 只要符合条件就需要设置为空
// 因为前端指挥在半价行、赠品行上打标 // 因为前端指挥在半价行、赠品行上打标
...@@ -139,12 +313,6 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation ...@@ -139,12 +313,6 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
product.setGoodsId(null); product.setGoodsId(null);
} }
// num代表拆出来的半价行数量
// 所以只要不等于0就需要把ActivityType设置为空
// 因为前端用这个判断是否能加减
if(!Objects.equals(num,0)){
product.setActivityType(null);
}
newProducts.add(product); newProducts.add(product);
} }
...@@ -155,58 +323,31 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation ...@@ -155,58 +323,31 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
shoppingCartGoodsResponseVo.setProducts(newProducts); shoppingCartGoodsResponseVo.setProducts(newProducts);
} }
}
}
/**
* 判断商品是否参加了限时特价
* @param goodsDiscountsMap
* @param product
* @return
*/
public Boolean hashCutActive(Map<String,CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods> goodsDiscountsMap,
CartGoods product){
public CartGoods buildNewLine(CartGoods cgs,Integer activityType,Integer qty,Long newPrice){ boolean cutFlag = false;
CartGoods newCartGoods = new CartGoods(); if(goodsDiscountsMap.get(product.getCartGoodsUid()) != null){
// 购物车的行设置和原来的行一致,便于前端在更新商品数量的时候。能够根据购物车行聚合商品数量 CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods goods = goodsDiscountsMap.get(product.getCartGoodsUid());
// 因为半价行是从主行中拆出来的 List<CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount> goodsDiscountsList = goods.getDiscounts();
newCartGoods.setCartGoodsUid(cgs.getCartGoodsUid()); if(goodsDiscountsList != null && !goodsDiscountsList.isEmpty()){
// 这个地方不要放置商品id,因为半价行的商品不打活动标签 for(CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount gd : goodsDiscountsList){
// 前端会根据这个活动检索 if(ObjectUtils.equals(gd.getType(),ActivityTypeEnum.TYPE_2.getCode())){
newCartGoods.setGoodsType(cgs.getGoodsType()); cutFlag = true;
newCartGoods.setGoodsId(cgs.getGoodsId()); break;
newCartGoods.setSpuId(cgs.getSpuId()); }
newCartGoods.setSkuId(cgs.getSkuId()); }
newCartGoods.setSpecProductId(cgs.getSpecProductId()); }
// 价格只用一个商品的价格
newCartGoods.setOriginalPrice(cgs.getOriginalPrice());
// 价格只用一个商品的价格
newCartGoods.setPackPrice(cgs.getPackPrice());
// 价格只用一个商品的价格
newCartGoods.setOriginalAmount(cgs.getOriginalPrice());
// 价格只用一个商品的价格
newCartGoods.setFinalPrice(newPrice);
// 价格只用一个商品的价格
newCartGoods.setAmount(newPrice);
newCartGoods.setName(cgs.getName());
newCartGoods.setSpuName(cgs.getSpuName());
newCartGoods.setSubName(cgs.getSubName());
newCartGoods.setNodeId(cgs.getNodeId());
newCartGoods.setCategoryName(cgs.getCategoryName());
List<CartGoods.CartGoodsExtra> extra = Lists.newArrayList();
List<CartGoods.CartGoodsExtra> cartGoodsExtras = cgs.getExtra();
if (CollectionUtils.isNotEmpty(cartGoodsExtras)) {
cartGoodsExtras.forEach(cartGoodsExtra -> {
CartGoods.CartGoodsExtra goodsExtra = new CartGoods.CartGoodsExtra();
goodsExtra.setAttributeId(cartGoodsExtra.getAttributeId());
goodsExtra.setAttributeName(cartGoodsExtra.getAttributeName());
extra.add(goodsExtra);
});
} }
newCartGoods.setExtra(extra);
newCartGoods.setPic(cgs.getPic());
newCartGoods.setCreateTimeMili(cgs.getCreateTimeMili());
newCartGoods.setSkuName(cgs.getSkuName());
newCartGoods.setSkuName(cgs.getSkuName());
newCartGoods.setClassificationId(cgs.getClassificationId());
newCartGoods.setClassificationName(cgs.getClassificationName());
newCartGoods.setActivityType(activityType);
newCartGoods.setQty(qty);
return newCartGoods; return cutFlag;
} }
} }
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
package cn.freemud.service.shoppingCart.impl; package cn.freemud.service.shoppingCart.impl;
import cn.freemud.entities.dto.calculate.CalculationSharingDiscountResponseDto; import cn.freemud.entities.dto.calculate.CalculationSharingDiscountResponseDto;
import cn.freemud.entities.vo.ShoppingCartClearRequestVo;
import cn.freemud.entities.vo.ShoppingCartGoodsResponseVo; import cn.freemud.entities.vo.ShoppingCartGoodsResponseVo;
import cn.freemud.service.shoppingCart.ShoppingCartRelationService; import cn.freemud.service.shoppingCart.ShoppingCartRelationService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -26,4 +27,9 @@ public class PlatformShoppingCartRelationServiceImpl implements ShoppingCartRela ...@@ -26,4 +27,9 @@ public class PlatformShoppingCartRelationServiceImpl implements ShoppingCartRela
Integer flag) { Integer flag) {
} }
@Override
public void cleanAfter(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ShoppingCartClearRequestVo shoppingCartClearRequestVo) {
}
} }
...@@ -54,4 +54,13 @@ public class ShoppingCartRelationFactoryImpl implements ShoppingCartRelationFact ...@@ -54,4 +54,13 @@ public class ShoppingCartRelationFactoryImpl implements ShoppingCartRelationFact
} }
} }
@Override
public ShoppingCartRelationService cleanAfter(String partnerId) {
if(cocoPartnerId.contains(partnerId)){
return cocoShoppingCartRelationService;
}else{
return platformShoppingCartRelationService;
}
}
} }
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