Commit df8a1489 by huiyang.chen

fix 合并随单购

parent 8a98edc7
......@@ -22,11 +22,7 @@ import cn.freemud.service.impl.AssortmentSdkService;
import cn.freemud.service.impl.FullSubtractionActivityServiceImpl;
import cn.freemud.service.impl.mcoffee.calculation.CalculationServiceImpl;
import cn.freemud.service.impl.mcoffee.calculation.CouponDiscountCalculation;
import cn.freemud.service.impl.mcoffee.entity.CopyShoppingCartRequestVo;
import cn.freemud.service.impl.mcoffee.entity.CouponState;
import cn.freemud.service.impl.mcoffee.entity.CouponAvailableReq;
import cn.freemud.service.impl.mcoffee.entity.MCoffeeAddGoodsRequestVo;
import cn.freemud.service.impl.mcoffee.entity.SwitchShoppingCartRequestVo;
import cn.freemud.service.impl.mcoffee.entity.*;
import cn.freemud.service.thirdparty.CustomerApplicationClient;
import cn.freemud.service.thirdparty.ProductClient;
import cn.freemud.utils.ResponseUtil;
......@@ -136,12 +132,14 @@ public class ShoppingCartMCoffeeServiceImpl {
String couponCode = addShoppingCartGoodsRequestVo.getCouponCode();
String spuId2 = spuId;
MCoffeeProductIdsVo vo =new MCoffeeProductIdsVo();
List<Long> productIds = new ArrayList<>();
//商品券校验
if (spuId.startsWith(CommonsConstant.COUPON_PREFIX)) {
couponCode = spuId.substring(CommonsConstant.COUPON_PREFIX.length());
spuId2 = validCoupon(partnerId, storeId, spuId, productIds, BusinessTypeEnum.getByType(addShoppingCartGoodsRequestVo.getMenuType()).getCode());
goodsId = spuId2;
vo = validCoupon(partnerId, storeId, spuId, productIds, BusinessTypeEnum.getByType(addShoppingCartGoodsRequestVo.getMenuType()).getCode());
spuId2 = vo.getSkuId();
goodsId = vo.getSkuId();
}
productIds.add(Long.parseLong(goodsId));
// 获取添加商品的详细信息
......@@ -155,7 +153,7 @@ public class ShoppingCartMCoffeeServiceImpl {
//商品券已添加情况校验
List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons = checkGoodsCoupon(oldCartGoodsList, operationType, couponCode,goodsId);
CartGoods addCartGoods = convent2CartGoods(addShoppingCartGoodsRequestVo, goodsId);
CartGoods addCartGoods = convent2CartGoods(addShoppingCartGoodsRequestVo, goodsId ,vo);
setClassificationAndPrice(addCartGoods, productBeanListSpuClass);
if(StringUtils.isNotEmpty(addShoppingCartGoodsRequestVo.getGroupName())) {
addCartGoods.setSkuName(addShoppingCartGoodsRequestVo.getGroupName());
......@@ -183,8 +181,7 @@ public class ShoppingCartMCoffeeServiceImpl {
return ResponseUtil.success(shoppingCartGoodsResponseVo);
}
private String validCoupon(String partnerId, String storeId, String spuId, List<Long> productIds, String menuType) {
String spuId2;
private MCoffeeProductIdsVo validCoupon(String partnerId, String storeId, String spuId, List<Long> productIds, String menuType) {
CheckSpqInfoRequestDto checkSpqInfoRequestDto = new CheckSpqInfoRequestDto(partnerId, storeId, spuId.substring(CommonsConstant.COUPON_PREFIX.length()), menuType);
CouponService couponService = SDKCommonBaseContextWare.getBean(CouponService.class);
CheckSpqInfoResponseDto checkSpqInfoResponseDto = couponService.checkSpqInfo(checkSpqInfoRequestDto);
......@@ -192,8 +189,12 @@ public class ShoppingCartMCoffeeServiceImpl {
throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_NOT_EXIST);
}
productIds.add(Long.parseLong(checkSpqInfoResponseDto.getSkuId()));
spuId2 = checkSpqInfoResponseDto.getSkuId();
return spuId2;
String skuId2 = checkSpqInfoResponseDto.getSkuId();
String spuId2 = checkSpqInfoResponseDto.getSpuId();
MCoffeeProductIdsVo vo =new MCoffeeProductIdsVo();
vo.setSkuId(skuId2);
vo.setSpuId(spuId2);
return vo;
}
......@@ -1042,7 +1043,7 @@ public class ShoppingCartMCoffeeServiceImpl {
}
public static CartGoods convent2CartGoods(MCoffeeAddGoodsRequestVo addShoppingCartGoodsRequestVo, String goodsId) {
public static CartGoods convent2CartGoods(MCoffeeAddGoodsRequestVo addShoppingCartGoodsRequestVo, String goodsId, MCoffeeProductIdsVo mCoffeeProductIdsVo) {
String spuId = addShoppingCartGoodsRequestVo.getSpuId();
String skuId = addShoppingCartGoodsRequestVo.getSkuId();
// String goodsId = StringUtils.isEmpty(skuId) ? spuId : skuId;
......@@ -1056,7 +1057,7 @@ public class ShoppingCartMCoffeeServiceImpl {
Integer goodsType = StringUtils.isEmpty(skuId) || ObjectUtils.equals(spuId, skuId) ? GoodsTypeEnum.SPU_GOODS.getGoodsType() : GoodsTypeEnum.SKU_GOODS.getGoodsType();
if (spuId.startsWith(CommonsConstant.COUPON_PREFIX)) {
goodsType = GoodsTypeEnum.COUPON_GOODS.getGoodsType();
cartGoods.setSpuId(goodsId);
cartGoods.setSpuId(mCoffeeProductIdsVo.getSpuId());
cartGoods.setSkuId(goodsId);
cartGoods.setCouponCode(spuId.substring(CommonsConstant.COUPON_PREFIX.length()));
// cartGoods.setCartGoodsUid(spuId);
......
package cn.freemud.service.impl.mcoffee.entity;
import lombok.Data;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title: MCoffeeAddGoodsRequestVo
* @Package cn.freemud.service.impl.mcoffee.entity
* @Description:
* @author: ping1.wu
* @date: 2020/8/8 21:04
* @Copyright: 2020 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Data
public class MCoffeeProductIdsVo {
private String spuId;
private String skuId;
}
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