Commit 9bbd71c9 by 刘鹏飞

Merge remote-tracking branch 'remotes/origin/feature/coco-payGift-刘鹏飞' into qa

parents 7e6c2517 1bee447e
...@@ -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,10 +130,33 @@ public class CocoOrderRelationServiceImpl implements OrderRelationService { ...@@ -119,10 +130,33 @@ 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(), OldOrderAccountType.SECOND_DISCOUNT.getCode())){
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);
......
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