Commit 8f5c5e47 by 张洪旺

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

parents 6fa35f93 241e9d35
......@@ -323,12 +323,14 @@ public class OrderCenterSdkServiceImpl implements OrderCenterSdkService {
BaseResponse<GetMemberExtendInfoResponse> extendInfo = new BaseResponse();
try {
QueryByCodeResponse codeResponse = orderSdkService.getOrderInfo(confirmOrderRequest.getProductOrderCode(), 0, confirmOrderRequest.getTrackingNo());
orderByIdResponse = orderSdkAdapter.convent2QueryOrderByIdResponse(codeResponse);
GetMemberExtendInfoRequest extendInfoRequest = new GetMemberExtendInfoRequest();
extendInfoRequest.setMemberId(orderByIdResponse.getData().getUserId());
extendInfoRequest.setPartnerId(orderByIdResponse.getData().getCompanyId());
extendInfo = memberCenterService.getMemberExtendInfo(extendInfoRequest, confirmOrderRequest.getTrackingNo());
OrderExtInfoDto extInfoDTO = JSONObject.parseObject(orderByIdResponse.getData().getExtInfo(),OrderExtInfoDto.class);
extInfoDTO.setMemberLevel(extendInfo.getData().getMemberGrade()!=null?extendInfo.getData().getMemberGrade().getRuleName():"");
extInfoDTO.setPaidMember(CollectionUtils.isNotEmpty(extendInfo.getData().getMemberPaids()));
......@@ -341,8 +343,10 @@ public class OrderCenterSdkServiceImpl implements OrderCenterSdkService {
ErrorLog.printErrorLog("getMemberExtendInfoError",MEMBER_EXTEND_INFO,confirmOrderRequest,e);
}
com.freemud.application.sdk.api.ordercenter.response.BaseResponse<PaySuccessResp> response = orderSdkService.paySuccess(request, confirmOrderRequest.getTrackingNo());
//获取会员信息失败直接返回,非空判断
if(extendInfo.getData() == null){
return orderSdkAdapter.convent2PayAccessResponse(response);
}
......
......@@ -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());
}
......
......@@ -471,6 +471,7 @@ public class OrderServiceImpl implements Orderservice {
}
// 如果订单状态不是未支付,返回信息
if (!PayStatus.NOT_PAY.getCode().equals(orderBean.getPayStatus()) || !OrderStatus.WAIT_PAY.getCode().equals(orderBean.getStatus())) {
return sendPaySuccessNoticeMessage();
}
//若该订单使用了优惠券,则移除卡包,移除失败也不退款,现在支付成功个调用核销,无需调用此功能
......
......@@ -27,7 +27,7 @@ public interface OrderRelationService {
/**
* 创建订单的时间检查
* 订单详情编辑
* @param
*/
void queryOrdrBuild(QueryOrderResponseVo queryOrderResponseVo,QueryOrderByIdResponse response);
......
......@@ -17,17 +17,22 @@ import cn.freemud.entities.dto.order.BusinessDate;
import cn.freemud.entities.vo.CreateOrderVo;
import cn.freemud.entities.vo.ProductVo;
import cn.freemud.entities.vo.QueryOrderResponseVo;
import cn.freemud.enums.ActivityTypeEnum;
import cn.freemud.enums.CreateOrderType;
import cn.freemud.enums.ResponseResult;
import cn.freemud.interceptor.ServiceException;
import cn.freemud.service.impl.CheckOrder;
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.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.response.order.QueryOrderByIdResponse;
import com.freemud.sdk.api.assortment.order.response.order.QueryOrdersResponse;
import io.swagger.models.auth.In;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -101,6 +106,12 @@ public class CocoOrderRelationServiceImpl implements OrderRelationService {
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();
......@@ -119,13 +130,35 @@ public class CocoOrderRelationServiceImpl implements OrderRelationService {
}
if(null != masterProducts && !masterProducts.isEmpty()){
masterProducts.forEach(product -> {
for(ProductVo product : masterProducts){
Integer giftQty = giftMap.get(product.getCid()) == null ? 0 : giftMap.get(product.getCid());
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);
}
}
......@@ -65,7 +65,7 @@
<dependency>
<groupId>cn.freemud</groupId>
<artifactId>assortment-ordercenter-sdk</artifactId>
<version>2.2.15-SNAPSHOT</version>
<version>2.2.20-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
......
......@@ -3,6 +3,7 @@ package com.freemud.application.sdk.api.ordercenter.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
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.constant.InterfaceAddressConstant;
import com.freemud.application.sdk.api.ordercenter.constant.ResponseConstant;
......
......@@ -871,14 +871,15 @@ public class ShoppingCartConvertAdapter {
//套餐可选商品
if (CollectionUtils.isNotEmpty(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()) ){
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods productGroup : cartGoods.getProductGroupList()) {
updateComboxGoodsInfoForMCoffee(productGroup, spuProduct, false);
updateComboxGoodsInfoForMCoffee(productGroup, productBeanDTO, false);
}
}else {
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 {
* 拼单发起人userId(拼单)
*/
private String createCollageUserId;
/**
* 收货地址ID、svc卡支付外卖订单必传
*/
private String receiveId;
}
......@@ -745,6 +745,10 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
shoppingCartGoodsResponseVo.setActivityTip(activityTip);
shoppingCartGoodsResponseVo.setProducts(new ArrayList<>());
shoppingCartGoodsResponseVo.setProductsCount(0);
ShoppingCartRelationService shoppingCartRelationService = shoppingCartRelationFactory.cleanAfter(shoppingCartClearRequestVo.getPartnerId());
shoppingCartRelationService.cleanAfter(shoppingCartGoodsResponseVo,shoppingCartClearRequestVo);
return ResponseUtil.success(shoppingCartGoodsResponseVo);
}
......@@ -1890,7 +1894,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
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;
// 如果订单的收获地址为空,且订单是外卖单,返回运费
// 主要是为了兼容coco不传收获地址,需要获取固定运费的情况
......
......@@ -270,8 +270,10 @@ public class ShoppingCartMCoffeeServiceImpl {
isContinue= false;
}
if(StringUtils.isNotEmpty(goodsId) && StringUtils.isNotEmpty(couponCode) && isContinue
&& cartGoods.getName().equals("啡常搭") && CollectionUtils.isNotEmpty(cartGoods.getProductComboList()) && cartGoods.getProductComboList().size() == 1
&& CollectionUtils.isEmpty(cartGoods.getProductGroupList()) && cartGoods.getProductComboList().get(0).getSkuId().equals(goodsId)) {
&& (cartGoods.getName().equals("拿铁") || cartGoods.getName().equals("美式")) && cartGoods.getGoodsType().equals(GoodsTypeEnum.SET_MEAL_GOODS.getGoodsType())
&& 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())) {
addShoppingCartGoodsRequestVo.setSpecialExtra(cartGoods.getProductComboList().get(0).getSpecialExtra());
......
......@@ -20,4 +20,11 @@ public interface ShoppingCartRelationFactory {
*/
ShoppingCartRelationService getBuildShoppingCartGoodsResponseService(String partnerId);
/**
* 获取购物车清空后的操作实现
* @param partnerId
* @return
*/
ShoppingCartRelationService cleanAfter(String partnerId);
}
......@@ -13,6 +13,7 @@
package cn.freemud.service.shoppingCart;
import cn.freemud.entities.dto.calculate.CalculationSharingDiscountResponseDto;
import cn.freemud.entities.vo.ShoppingCartClearRequestVo;
import cn.freemud.entities.vo.ShoppingCartGoodsResponseVo;
public interface ShoppingCartRelationService {
......@@ -24,5 +25,10 @@ public interface ShoppingCartRelationService {
CalculationSharingDiscountResponseDto.CalculationDiscountResult discountResult,
Integer flag);
/**
* 购物车清空后的扩展操作
*/
void cleanAfter(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ShoppingCartClearRequestVo shoppingCartClearRequestVo);
}
......@@ -13,16 +13,20 @@
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.vo.CartGoods;
import cn.freemud.entities.vo.ShoppingCartGoodsResponseVo;
import cn.freemud.entities.vo.*;
import cn.freemud.enums.ActivityTypeEnum;
import cn.freemud.service.impl.ShoppingCartNewServiceImpl;
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.LogThreadLocal;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
......@@ -31,6 +35,9 @@ import java.util.stream.Collectors;
@Service("cocoShoppingCartRelationService")
public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelationService {
@Autowired
private ShoppingCartNewServiceImpl shoppingCartNewServiceImpl;
@Override
public void buildShoppingCartGoodsResponse(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo,
......@@ -86,80 +93,54 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
});
});
List<CartGoods> newProducts = new ArrayList<>();
if(!Objects.equals(flag,1)){// 非结算页
if(products == null || products.isEmpty()){
return;
}
if(!Objects.equals(flag,1)){
// 非结算页
orderingFoodPage(products,halfDiscountsMap,goodsDiscountsMap,gifeProductIds,shoppingCartGoodsResponseVo);
}else {// 结算页
settlementPage(products,halfDiscountsMap,goodsDiscountsMap,shoppingCartGoodsResponseVo);
}
}
List<CartGoods> halfProduct = new ArrayList<>();
for(int x = 0 ; x < products.size() ; x ++){
CartGoods product = products.get(x);
// 要添加的半价行数量,该字段从促销返回
Integer num = 0;
// 商品优惠的金额
Long discountAmount = 0L;
if(halfDiscountsMap.get(product.getCartGoodsUid() + "-" + product.getGoodsId()) != null){
CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount discount = halfDiscountsMap.get(product.getCartGoodsUid() + "-" + product.getGoodsId());
if(discount == null){
return;
}
num = discount.getActualGoodsNumber();
for(int i = 0 ; i < num ; i++){
// 第二件优惠活动,在点餐页需要给优惠商品单独显示一行
// 复制商品加到购物车
discountAmount = discount.getDiscount();
Long newPrice = product.getOriginalPrice() - discountAmount;
// 构建半价行
CartGoods cartGoods = buildNewLine(product,ActivityTypeEnum.TYPE_53.getCode(),1,newPrice);
halfProduct.add(cartGoods);
}
}
Integer newQty = product.getQty() - num;
// 数量减去购物车行之后如果为0就不加入购物车
// 主商品行要数量,价格
if(!Objects.equals(newQty,0)){
product.setAmount(product.getAmount() - discountAmount * num);
product.setOriginalAmount(product.getOriginalAmount() - product.getOriginalPrice() * num);
product.setQty(newQty);
// 商品的现单价使用促销返回的现单价
// 但是要排除赠品行、半价行
if(!ObjectUtils.equals(product.getActivityType(),ActivityTypeEnum.TYPE_63.getCode()) && !ObjectUtils.equals(product.getActivityType(),ActivityTypeEnum.TYPE_53.getCode())){
product.setFinalPrice(goodsDiscountsMap.get(product.getCartGoodsUid()).getNowPrice());
}
// num代表拆出来的半价行数量,gifeProductIds代表赠品
// 只要符合条件就需要设置为空
// 因为前端指挥在半价行、赠品行上打标
// 前端是从商品活动信息中查找活动,在商品列表中找商品
if((gifeProductIds.contains(product.getGoodsId()) && product.getActivityType() == null) || !Objects.equals(num,0)){
product.setGoodsId(null);
}
// num代表拆出来的半价行数量
// 所以只要不等于0就需要把ActivityType设置为空
// 因为前端用这个判断是否能加减
if(!Objects.equals(num,0)){
product.setActivityType(null);
}
newProducts.add(product);
}
}
// 购物车顶部的提示不只是满减的提示,只要用户参加了活动,就应该把优惠的金额放到上面
// 获取用户的优惠金额,重新编辑用户提示语
// 这里比较暴力的做法直接把已经编辑的结合直接删了,重新用一个新的
// 并且把tip类型设置为5,因为前端针对5直接显示立减文案
if(!ObjectUtils.equals(shoppingCartGoodsResponseVo.getTotalDiscountAmount(),0L)){
// 半价商品加到购物车
newProducts.addAll(halfProduct);
ArrayList<ActivityList> activityList = new ArrayList<>();
shoppingCartGoodsResponseVo.setProducts(newProducts);
}
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();
public CartGoods buildNewLine(CartGoods cgs,Integer activityType,Integer qty,Long newPrice){
// 获取基础运费
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();
// 购物车的行设置和原来的行一致,便于前端在更新商品数量的时候。能够根据购物车行聚合商品数量
// 因为半价行是从主行中拆出来的
......@@ -167,7 +148,7 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
// 这个地方不要放置商品id,因为半价行的商品不打活动标签
// 前端会根据这个活动检索
newCartGoods.setGoodsType(cgs.getGoodsType());
newCartGoods.setGoodsId(cgs.getGoodsId());
newCartGoods.setGoodsId(goodsId);
newCartGoods.setSpuId(cgs.getSpuId());
newCartGoods.setSkuId(cgs.getSkuId());
newCartGoods.setSpecProductId(cgs.getSpecProductId());
......@@ -209,4 +190,164 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
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<>();
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);
}
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()){
return;
}
List<CartGoods> halfProduct = new ArrayList<>();
for(int x = 0 ; x < products.size() ; x ++){
CartGoods product = products.get(x);
// 要添加的半价行数量,该字段从促销返回
Integer num = 0;
// 商品优惠的金额
Long discountAmount = 0L;
if(halfDiscountsMap.get(product.getCartGoodsUid() + "-" + product.getGoodsId()) != null){
CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount discount = halfDiscountsMap.get(product.getCartGoodsUid() + "-" + product.getGoodsId());
if(discount == null){
return;
}
num = discount.getActualGoodsNumber();
for(int i = 0 ; i < num ; i++){
// 第二件优惠活动,在点餐页需要给优惠商品单独显示一行
// 复制商品加到购物车
discountAmount = discount.getDiscount();
Long newPrice = product.getOriginalPrice() - discountAmount;
// 构建半价行
CartGoods cartGoods = buildNewLine(product,ActivityTypeEnum.TYPE_53.getCode(),1,newPrice,product.getGoodsId());
halfProduct.add(cartGoods);
}
}
Integer newQty = product.getQty() - num;
// 数量减去购物车行之后如果为0就不加入购物车
// 主商品行要数量,价格
if(!Objects.equals(newQty,0)){
product.setAmount(product.getAmount() - discountAmount * num);
product.setOriginalAmount(product.getOriginalAmount() - product.getOriginalPrice() * num);
product.setQty(newQty);
// 商品是否参加特价
boolean cutFlag = hashCutActive(goodsDiscountsMap,product);
if(cutFlag){
product.setFinalPrice(goodsDiscountsMap.get(product.getCartGoodsUid()).getNowPrice());
}
// num代表拆出来的半价行数量
// 所以只要不等于0就需要把ActivityType设置为空
// 因为前端用这个判断是否能加减
if(!Objects.equals(num,0)){
product.setActivityType(null);
}
// num代表拆出来的半价行数量,gifeProductIds代表赠品
// 只要符合条件就需要设置为空
// 因为前端指挥在半价行、赠品行上打标
// 前端是从商品活动信息中查找活动,在商品列表中找商品
if((gifeProductIds.contains(product.getGoodsId()) && product.getActivityType() == null) || !Objects.equals(num,0)){
product.setGoodsId(null);
}
newProducts.add(product);
}
}
// 半价商品加到购物车
newProducts.addAll(halfProduct);
shoppingCartGoodsResponseVo.setProducts(newProducts);
}
/**
* 判断商品是否参加了限时特价
* @param goodsDiscountsMap
* @param product
* @return
*/
public Boolean hashCutActive(Map<String,CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods> goodsDiscountsMap,
CartGoods product){
boolean cutFlag = false;
if(goodsDiscountsMap.get(product.getCartGoodsUid()) != null){
CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods goods = goodsDiscountsMap.get(product.getCartGoodsUid());
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())){
cutFlag = true;
break;
}
}
}
}
return cutFlag;
}
}
......@@ -13,6 +13,7 @@
package cn.freemud.service.shoppingCart.impl;
import cn.freemud.entities.dto.calculate.CalculationSharingDiscountResponseDto;
import cn.freemud.entities.vo.ShoppingCartClearRequestVo;
import cn.freemud.entities.vo.ShoppingCartGoodsResponseVo;
import cn.freemud.service.shoppingCart.ShoppingCartRelationService;
import org.springframework.stereotype.Service;
......@@ -26,4 +27,9 @@ public class PlatformShoppingCartRelationServiceImpl implements ShoppingCartRela
Integer flag) {
}
@Override
public void cleanAfter(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ShoppingCartClearRequestVo shoppingCartClearRequestVo) {
}
}
......@@ -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