Commit 9e319bbb by ping.wu

商品开票费率与超值加购

parent adecb2eb
......@@ -42,7 +42,7 @@
<dependency>
<groupId>com.freemud.application.service.sdk</groupId>
<artifactId>productcenter-sdk</artifactId>
<version>3.2.RELEASE</version>
<version>3.6.4.SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
......
......@@ -283,6 +283,7 @@ public class ShoppingCartAdapter {
cartGoods.setMemberDiscount(spuProduct.getMemberDiscountResult());
cartGoods.setClassificationId(spuProduct.getCategory());
cartGoods.setClassificationName(spuProduct.getCategoryName());
cartGoods.setTax(spuProduct.getTax());
String skuSpecName = "";
if (isSkuProduct && CollectionUtils.isNotEmpty(skuProduct.getSkuSpecValues())) {
List<String> skuSpecValus = skuProduct.getSkuSpecValues().stream().map(p -> p.getSpecValue()).collect(Collectors.toList());
......
......@@ -158,6 +158,11 @@ public class CartGoods {
private Integer memberDiscount;
/**
* 税率 缓存
*/
private Double tax;
/**
* 套餐固定商品
*/
private List<ComboxGoods> productComboList;
......
......@@ -84,7 +84,8 @@ public class ShoppingCartConvertAdapter {
public ShoppingCartGoodsDto.CartGoodsDetailDto convertCartGoods2DetailGoods(CartGoods cartGoods, List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ApportionGoods> apportionGoodsList, Map<String, String> duplicateGoodsMap) {
// 设置基础信息
ShoppingCartGoodsDto.CartGoodsDetailDto cartGoodsDetailDto = new ShoppingCartGoodsDto.CartGoodsDetailDto();
cartGoodsDetailDto.setTas(0.02d);
cartGoodsDetailDto.setTasId("1234");
cartGoodsDetailDto.setTas(cartGoods.getTax());
cartGoodsDetailDto.setSpuId(cartGoods.getSpuId());
cartGoodsDetailDto.setSpuName(cartGoods.getSpuName());
cartGoodsDetailDto.setSkuId(StringUtils.isEmpty(cartGoods.getSkuId()) ? cartGoods.getSpuId() : cartGoods.getSkuId());
......
......@@ -224,6 +224,11 @@ public class ShoppingCartGoodsDto {
private String classificationName;
/**
* 税率代码
*/
private String tasId;
/**
* 税率
*/
private Double tas;
......
......@@ -158,6 +158,12 @@ public class CartGoods {
* 例如8折为80
*/
private Integer memberDiscount;
/**
* 费率
*/
private Double tax;
/**
* 套餐固定商品
*/
......
......@@ -25,6 +25,7 @@ public enum ActivityTypeEnum {
*/
TYPE_2(2, "单品特价"),
TYPE_21(21, "单品折扣"),
TYPE_23(23, "超值加购"),
/**
* 优惠券
*/
......
......@@ -196,7 +196,8 @@ public class ShoppingCartMCoffeeServiceImpl {
return ResponseUtil.error(ResponseResult.SHOPPING_CART_ADD_ERROR);
}
ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo = new ShoppingCartGoodsResponseVo();
CustomerInfoVo assortmentCustomerInfoVo = getCustomerInfoVo(updateShoppingCartGoodsQtyRequestVo.getSessionId());
String sessionId = updateShoppingCartGoodsQtyRequestVo.getSessionId();
CustomerInfoVo assortmentCustomerInfoVo = getCustomerInfoVo(sessionId);
String userId = assortmentCustomerInfoVo.getMemberId();
String partnerId = updateShoppingCartGoodsQtyRequestVo.getPartnerId();
String storeId = updateShoppingCartGoodsQtyRequestVo.getShopId();
......@@ -226,15 +227,15 @@ public class ShoppingCartMCoffeeServiceImpl {
// checkUpdateStock(partnerId, storeId, menuType, qty, cartGoods);
// check购物车中所有商品
CheckCartRequest checkCartRequest = assortmentSdkService.checkShoppingCartSdk(cartGoodsList, partnerId, storeId, shoppingCartGoodsResponseVo, updateShoppingCartGoodsQtyRequestVo.getOrderType(), "", updateShoppingCartGoodsQtyRequestVo.getMenuType(), shoppingCartBaseService);
cartGoodsList = JSONArray.parseArray(JSONObject.toJSONString(checkCartRequest.getCartGoodsList()), CartGoods.class);
cartGoodsList = checkCartGoods(partnerId, storeId,orderType,menuType,shoppingCartGoodsResponseVo,cartGoodsList);
// 重新存储最新购物车
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, updateShoppingCartGoodsQtyRequestVo.getSessionId(), "", shoppingCartBaseService);
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, sessionId, "", shoppingCartBaseService);
// 当couponCode不为空时,需参与价格计算
List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons = getCoupon(null,null,cartGoodsList) ;
// 促销活动的优惠金额计算
calculationService.updateShoppingCartGoodsDiscount(partnerId, storeId, userId, appId, orderType, assortmentCustomerInfoVo.isMemberPaid(), menuType, receiveId,null,
cartGoodsList, new ArrayList<>(), new ArrayList<>(), shoppingCartGoodsResponseVo);
cartGoodsList, coupons, new ArrayList<>(), shoppingCartGoodsResponseVo);
//设置更新响应信息
setAddAndUpdateResponse(shoppingCartGoodsResponseVo, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), ShoppingCartConstant.ADD_AND_UPDATE, null);
return ResponseUtil.success(shoppingCartGoodsResponseVo);
......@@ -252,8 +253,9 @@ public class ShoppingCartMCoffeeServiceImpl {
throw new ServiceException(ResponseResult.SHOPPING_CART_SHOP_ID_NOT_EMPTY);
}
ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo = new ShoppingCartGoodsResponseVo();
String sessionId = shoppingCartInfoRequestVo.getSessionId();
// 获取用户信息
CustomerInfoVo assortmentCustomerInfoVo = getCustomerInfoVo(shoppingCartInfoRequestVo.getSessionId());
CustomerInfoVo assortmentCustomerInfoVo = getCustomerInfoVo(sessionId);
String userId = assortmentCustomerInfoVo.getMemberId();
String partnerId = shoppingCartInfoRequestVo.getPartnerId();
String storeId = shoppingCartInfoRequestVo.getShopId();
......@@ -265,29 +267,21 @@ public class ShoppingCartMCoffeeServiceImpl {
String receiveId = shoppingCartInfoRequestVo.getReceiveId();
// 获取购物车商品
List<CartGoods> cartGoodsList = assortmentSdkService.getShoppingCart(partnerId, storeId, userId, null, "", shoppingCartBaseService);
List<CartGoods> cartGoodsList = assortmentSdkService.getShoppingCart(partnerId, storeId, userId, sessionId, "", shoppingCartBaseService);
// 如果购物车商品不为空, 则check购物车中所有商品
if (CollectionUtils.isNotEmpty(cartGoodsList)) {
CheckCartRequest checkCartRequest = assortmentSdkService.checkShoppingCartSdk(cartGoodsList, partnerId, storeId, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo.getOrderType(), "", shoppingCartInfoRequestVo.getMenuType(), shoppingCartBaseService);
if (checkCartRequest.getShoppingCartGoodsResponseVo() != null) {
shoppingCartGoodsResponseVo.setChanged(checkCartRequest.getShoppingCartGoodsResponseVo().getChanged());
shoppingCartGoodsResponseVo.setToastMsg(checkCartRequest.getShoppingCartGoodsResponseVo().getToastMsg());
}
cartGoodsList = JSONArray.parseArray(JSONObject.toJSONString(checkCartRequest.getCartGoodsList()), CartGoods.class);
// check购物车中所有商品
cartGoodsList = checkCartGoods(partnerId, storeId,orderType,menuType,shoppingCartGoodsResponseVo,cartGoodsList);
// 重新存储最新购物车
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, assortmentCustomerInfoVo.getSessionId(), "", this.shoppingCartBaseService);
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, sessionId, "", shoppingCartBaseService);
}
List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons = new ArrayList<>();
// 当couponCode不为空时,需参与价格计算
if (StringUtils.isNotEmpty(couponCode)) {
ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon coupon = new ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon();
coupon.setCode(couponCode);
coupon.setActivityCode(activityCode);
coupons.add(coupon);
}
List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons = getCoupon(couponCode,null,cartGoodsList) ;
// 促销活动的优惠金额计算
calculationService.updateShoppingCartGoodsDiscount(partnerId, storeId, userId, appId, orderType, assortmentCustomerInfoVo.isMemberPaid(), menuType, receiveId,null,
cartGoodsList, new ArrayList<>(), new ArrayList<>(), shoppingCartGoodsResponseVo);
cartGoodsList, coupons,new ArrayList<>(), shoppingCartGoodsResponseVo);
//设置更新响应信息
setAddAndUpdateResponse(shoppingCartGoodsResponseVo, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), ShoppingCartConstant.QUERY_INFO, shoppingCartInfoRequestVo);
......@@ -302,7 +296,7 @@ public class ShoppingCartMCoffeeServiceImpl {
if (StringUtils.isEmpty(shoppingCartInfoRequestVo.getShopId())) {
return ResponseUtil.error(ResponseResult.SHOPPING_CART_SHOP_ID_NOT_EMPTY);
}
ActivityClassifyCouponBean availableCoupon = new ActivityClassifyCouponBean();
ActivityClassifyCouponBean availableCoupon ;
// 获取用户信息
CustomerInfoVo assortmentCustomerInfoVo = getCustomerInfoVo(shoppingCartInfoRequestVo.getSessionId());
String userId = assortmentCustomerInfoVo.getMemberId();
......@@ -375,70 +369,54 @@ public class ShoppingCartMCoffeeServiceImpl {
CreateOrderVo.PremiumExchangeActivity premiumExchangeActivity = requestVo.getPremiumExchangeActivity();
ShoppingCartGoodsDto shoppingCartGoodsDto = new ShoppingCartGoodsDto();
ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo = new ShoppingCartGoodsResponseVo();
String sessionId = shoppingCartInfoRequestVo.getSessionId();
// 获取用户信息
CustomerInfoVo assortmentCustomerInfoVo = getCustomerInfoVo(shoppingCartInfoRequestVo.getSessionId());
CustomerInfoVo assortmentCustomerInfoVo = getCustomerInfoVo(sessionId);
String userId = assortmentCustomerInfoVo.getMemberId();
String partnerId = shoppingCartInfoRequestVo.getPartnerId();
String storeId = shoppingCartInfoRequestVo.getShopId();
String appId = StringUtils.isEmpty(shoppingCartInfoRequestVo.getAppId())?assortmentCustomerInfoVo.getAppId():shoppingCartInfoRequestVo.getAppId();
String couponCode = shoppingCartInfoRequestVo.getCouponCode();
String activityCode = shoppingCartInfoRequestVo.getActivityCode();
// String activityCode = shoppingCartInfoRequestVo.getActivityCode();
String tableNumber = assortmentCustomerInfoVo.getTableNumber();
String menuType = shoppingCartInfoRequestVo.getMenuType();
Integer orderType = shoppingCartInfoRequestVo.getOrderType();
String receiveId = shoppingCartInfoRequestVo.getReceiveId();
List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList = shoppingCartInfoRequestVo.getSendGoods();
// 获取购物车商品
List<CartGoods> cartGoodsList = assortmentSdkService.getShoppingCart(partnerId, storeId, userId, null, tableNumber, shoppingCartBaseService);
if (cartGoodsList == null) {
if (cartGoodsList == null || CollectionUtils.isEmpty(cartGoodsList)) {
throw new ServiceException(ResponseResult.SHOPPING_CART_GETINFO_INVAILD);
}
// check购物车中所有商品(商品是否存在,价格变动,券是否支持当前点餐方式)
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()) {
return ResponseUtil.error(ResponseResult.STORE_ITEM_CHECK_INVAILD);
}
if (cartGoodsResponseVo.getCartGoodsStates() != null && cartGoodsResponseVo.getCartGoodsStates().isPriceChanged()) {
return ResponseUtil.error(ResponseResult.SHOPPING_CART_ACTIVITY_CHANGE);
}
shoppingCartGoodsResponseVo.setToastMsg(cartGoodsResponseVo.getToastMsg());
}
cartGoodsList = JSONArray.parseArray(JSONObject.toJSONString(checkCartRequest.getCartGoodsList()), CartGoods.class);
// 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()) {
// return ResponseUtil.error(ResponseResult.STORE_ITEM_CHECK_INVAILD);
// }
// if (cartGoodsResponseVo.getCartGoodsStates() != null && cartGoodsResponseVo.getCartGoodsStates().isPriceChanged()) {
// return ResponseUtil.error(ResponseResult.SHOPPING_CART_ACTIVITY_CHANGE);
// }
// shoppingCartGoodsResponseVo.setToastMsg(cartGoodsResponseVo.getToastMsg());
// }
// cartGoodsList = JSONArray.parseArray(JSONObject.toJSONString(checkCartRequest.getCartGoodsList()), CartGoods.class);
// check购物车中所有商品
cartGoodsList = checkCartGoods(partnerId, storeId,orderType,menuType,shoppingCartGoodsResponseVo,cartGoodsList);
// 重新存储最新购物车
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, assortmentCustomerInfoVo.getSessionId(), tableNumber, this.shoppingCartBaseService);
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, sessionId, tableNumber, shoppingCartBaseService);
List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons = new ArrayList<>();
// 当couponCode不为空时,需参与价格计算
if (StringUtils.isNotEmpty(couponCode)) {
ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon coupon = new ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon();
coupon.setCode(couponCode);
coupon.setActivityCode(activityCode);
coupons.add(coupon);
}
if (CollectionUtils.isNotEmpty(sendGoodsList)) {
processSendGoods(sendGoodsList, partnerId, storeId , shoppingCartInfoRequestVo.getMenuType() , shoppingCartBaseService);
} else {
//组装加价购商品
if (null != premiumExchangeActivity && CollectionUtils.isNotEmpty(premiumExchangeActivity.getProducts())) {
List<ShoppingCartInfoRequestVo.SendGoods> sendGoods = premiumExchangeActivity.getProducts().stream().map(product -> {
ShoppingCartInfoRequestVo.SendGoods sendGood = new ShoppingCartInfoRequestVo.SendGoods();
sendGood.setGoodsId(product.getSkuId());
sendGood.setQty(product.getQty());
return sendGood;
}).collect(toList());
shoppingCartInfoRequestVo.setSendGoods(sendGoods);
}
}
//加价购商品组装
packgeAdditional(shoppingCartInfoRequestVo, premiumExchangeActivity);
List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons = getCoupon(couponCode,null,cartGoodsList);
//加价购商品
List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList = shoppingCartInfoRequestVo.getSendGoods();
// //加价购商品组装
// packgeAdditional(shoppingCartInfoRequestVo, premiumExchangeActivity);
// 促销活动的优惠金额计算
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscount = calculationService.updateShoppingCartGoodsDiscount(partnerId, storeId, userId, appId, orderType, assortmentCustomerInfoVo.isMemberPaid(), menuType, receiveId,null,
cartGoodsList, coupons,sendGoodsList, shoppingCartGoodsResponseVo);
......@@ -449,17 +427,12 @@ public class ShoppingCartMCoffeeServiceImpl {
//设置均摊信息
calculationService.updateShoppingCartGoodsApportion(shoppingCartGoodsResponseVo, calculationDiscount, shoppingCartGoodsDto, premiumExchangeActivity, shoppingCartInfoRequestVo);
shoppingCartGoodsDto.setDeliveryAmount(shoppingCartGoodsResponseVo.getDeliveryAmount());
shoppingCartGoodsDto.setDiscountDeliveryAmount(shoppingCartGoodsResponseVo.getDiscountDeliveryAmount());
shoppingCartGoodsDto.setThresholdAmount(shoppingCartGoodsResponseVo.getThresholdAmount());
shoppingCartGoodsDto.setIsDiscountDelivery(shoppingCartGoodsResponseVo.getIsDiscountDelivery());
shoppingCartGoodsDto.setDiscountDeliveryActivityCode(shoppingCartGoodsResponseVo.getDiscountDeliveryActivityCode());
return ResponseUtil.success(shoppingCartGoodsDto);
}
private void packgeAdditional(ShoppingCartInfoRequestVo shoppingCartInfoRequestVo, CreateOrderVo.PremiumExchangeActivity premiumExchangeActivity) {
ArrayList<ShoppingCartInfoRequestVo.SendGoods> senGoods = new ArrayList<>();
if (premiumExchangeActivity != null && CollectionUtils.isNotEmpty(premiumExchangeActivity.getProducts())) {
for (CreateOrderVo.PremiumExchangeActivity.Product product : premiumExchangeActivity.getProducts()) {
......@@ -479,26 +452,26 @@ public class ShoppingCartMCoffeeServiceImpl {
* @param partnerId
* @param storeId
*/
private void processSendGoods(List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList
, String partnerId, String storeId,String menuType, ShoppingCartBaseService shoppingCartService) {
List<String> goodsIds = sendGoodsList.parallelStream().map(ShoppingCartInfoRequestVo.SendGoods::getGoodsId).collect(Collectors.toList());
List<ProductBeanDTO> productBeanList =
assortmentSdkService.getProductsInfoSdk(partnerId, storeId, goodsIds, menuType, shoppingCartService);
// 将productBeanList转换为Map,key为pid,即goodsId
Map<String, ProductBeanDTO> productBeanMap = productBeanList.parallelStream()
.collect(Collectors.toMap(ProductBeanDTO::getPid, Function.identity(), (k1, k2) -> k1));
// 遍历购物车进行加个更新
for (ShoppingCartInfoRequestVo.SendGoods sendGoods : sendGoodsList) {
ProductBeanDTO productBean;
if ((productBean = productBeanMap.get(sendGoods.getGoodsId())) != null) {
// 设置加价购商品原价
sendGoods.setOriginalPrice(productBean.getFinalPrice());
} else {
throw new ServiceException(ResponseResult.SHOPPING_CART_SENDGOODS_NOT_EXIST);
}
}
}
// private void processSendGoods(List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList
// , String partnerId, String storeId,String menuType, ShoppingCartBaseService shoppingCartService) {
// List<String> goodsIds = sendGoodsList.parallelStream().map(ShoppingCartInfoRequestVo.SendGoods::getGoodsId).collect(Collectors.toList());
// List<ProductBeanDTO> productBeanList =
// assortmentSdkService.getProductsInfoSdk(partnerId, storeId, goodsIds, menuType, shoppingCartService);
// // 将productBeanList转换为Map,key为pid,即goodsId
// Map<String, ProductBeanDTO> productBeanMap = productBeanList.parallelStream()
// .collect(Collectors.toMap(ProductBeanDTO::getPid, Function.identity(), (k1, k2) -> k1));
// // 遍历购物车进行加个更新
// for (ShoppingCartInfoRequestVo.SendGoods sendGoods : sendGoodsList) {
// ProductBeanDTO productBean;
// if ((productBean = productBeanMap.get(sendGoods.getGoodsId())) != null) {
// // 设置加价购商品原价
// sendGoods.setOriginalPrice(productBean.getFinalPrice());
// } else {
// throw new ServiceException(ResponseResult.SHOPPING_CART_SENDGOODS_NOT_EXIST);
// }
// }
//
// }
/**
......@@ -512,20 +485,12 @@ public class ShoppingCartMCoffeeServiceImpl {
CartGoods addCartGoods, ShoppingCartGoodsBaseResponseVo shoppingCartGoodsResponseVo, List<CartGoods> oldCartGoodsList) {
List<CartGoods> newCartGoods = new ArrayList<>();
newCartGoods.addAll(oldCartGoodsList);
//商品券单独设置一行
newCartGoods = checkNewCartGoods(newCartGoods, addCartGoods);
//筛选非加购商品--加价购商品不校验是否在菜单,不调用validateShopProduct
//当商品全部添加完毕,校验购物车商品(是否合法,上下架,点餐方式,是否在当前菜单中...),并移除非法商品
CheckCartRequest checkCartRequest = assortmentSdkService.checkShoppingCartSdk(newCartGoods, partnerId,
storeId, shoppingCartGoodsResponseVo, orderType, "", menuType, shoppingCartBaseService);
if (checkCartRequest.getShoppingCartGoodsResponseVo() != null) {
shoppingCartGoodsResponseVo.setToastMsg(checkCartRequest.getShoppingCartGoodsResponseVo().getToastMsg());
shoppingCartGoodsResponseVo.setChanged(checkCartRequest.getShoppingCartGoodsResponseVo().getChanged());
}
List<CartGoods> allCartGoodsList = JSONArray.parseArray(JSONObject.toJSONString(checkCartRequest.getCartGoodsList()), CartGoods.class);
//加购商品校验
List<CartGoods> allCartGoodsList = checkCartGoods(partnerId,storeId,orderType,menuType,shoppingCartGoodsResponseVo,newCartGoods);
//添加商品为商品券时,设置商品券号
//添加商品为商品券时,商品校验接口券号未设置,设置商品券号
if(StringUtils.isNotBlank(addCartGoods.getCouponCode())){
for (CartGoods cartGoods :allCartGoodsList){
if(cartGoods.getGoodsId().equals(addCartGoods.getGoodsId())){
......@@ -684,16 +649,32 @@ public class ShoppingCartMCoffeeServiceImpl {
}
cartGoods.setClassificationId(productBeanListSpuClass.get(0).getCategory());
cartGoods.setClassificationName(productBeanListSpuClass.get(0).getCategoryName());
cartGoods.setOriginalPrice(productBeanListSpuClass.get(0).getOriginalPrice());
// cartGoods.setFinalPrice(productBeanListSpuClass.get(0).getFinalPrice());
// cartGoods.setPackPrice(productBeanListSpuClass.get(0).getPackPrice());
// if(StringUtils.isBlank(productBeanListSpuClass.get(0).getCustomerCode())){
// productBeanListSpuClass.get(0).setCustomerCode("12345");
// }
// cartGoods.setCustomerCode(productBeanListSpuClass.get(0).getCustomerCode());
// if(StringUtils.isBlank(productBeanListSpuClass.get(0).getCustomerCode())){
// throw new ServiceException(ResponseResult.PARAMETER_MISSING,"商品键位编号为空");
// }
if(StringUtils.isBlank(productBeanListSpuClass.get(0).getCustomerCode())){
productBeanListSpuClass.get(0).setCustomerCode("12345");
cartGoods.setCustomerCode(productBeanListSpuClass.get(0).getCustomerCode());
}
if(StringUtils.isBlank(productBeanListSpuClass.get(0).getCustomerCode())){
throw new ServiceException(ResponseResult.PARAMETER_MISSING,"商品键位编号为空");
}
if(ObjectUtils.equals(GoodsTypeEnum.REDUCE_PRICE_GOODS.getGoodsType(), cartGoods.getGoodsType())){
cartGoods.setOriginalPrice(productBeanListSpuClass.get(0).getOriginalPrice());
cartGoods.setFinalPrice(productBeanListSpuClass.get(0).getFinalPrice());
cartGoods.setPackPrice(productBeanListSpuClass.get(0).getPackPrice());
cartGoods.setPackPrice(productBeanListSpuClass.get(0).getPackPrice());
cartGoods.setCustomerCode(productBeanListSpuClass.get(0).getCustomerCode());
cartGoods.setName(productBeanListSpuClass.get(0).getName());
cartGoods.setSpuName(productBeanListSpuClass.get(0).getName());
cartGoods.setSkuName(productBeanListSpuClass.get(0).getName());
cartGoods.setPic(productBeanListSpuClass.get(0).getPicture());
cartGoods.setStockLimit(productBeanListSpuClass.get(0).getStockLimit() == 1);
}
}
......@@ -749,4 +730,62 @@ public class ShoppingCartMCoffeeServiceImpl {
return cartGoods;
}
/**
* 购物车商品check,加购商品不在菜单不check
*/
private List<CartGoods> checkCartGoods(String partnerId, String storeId, Integer orderType, String menuType,
ShoppingCartGoodsBaseResponseVo shoppingCartGoodsResponseVo, List<CartGoods> cartGoodsList){
//筛选非加购商品--加价购商品不校验是否在菜单,不调用validateShopProduct
List<CartGoods> checkGoods = cartGoodsList.stream().filter(cartGoods -> cartGoods.getGoodsType() != GoodsTypeEnum.REDUCE_PRICE_GOODS.getGoodsType()).collect(Collectors.toList());
//加价购商品
List<CartGoods> reduceGoods = cartGoodsList.stream().filter(cartGoods -> cartGoods.getGoodsType() == GoodsTypeEnum.REDUCE_PRICE_GOODS.getGoodsType()).collect(Collectors.toList());
List<CartGoods> allCartGoodsList = new ArrayList<>();
if(CollectionUtils.isNotEmpty(checkGoods)){
//当商品全部添加完毕,校验购物车商品(是否合法,上下架,点餐方式,是否在当前菜单中...),并移除非法商品
CheckCartRequest checkCartRequest = assortmentSdkService.checkShoppingCartSdk(checkGoods, partnerId,
storeId, shoppingCartGoodsResponseVo, orderType, "", menuType, shoppingCartBaseService);
if (checkCartRequest.getShoppingCartGoodsResponseVo() != null) {
shoppingCartGoodsResponseVo.setToastMsg(checkCartRequest.getShoppingCartGoodsResponseVo().getToastMsg());
shoppingCartGoodsResponseVo.setChanged(checkCartRequest.getShoppingCartGoodsResponseVo().getChanged());
}
allCartGoodsList = JSONArray.parseArray(JSONObject.toJSONString(checkCartRequest.getCartGoodsList()), CartGoods.class);
}
//添加商品为加价购商品
if(CollectionUtils.isNotEmpty(reduceGoods)){
allCartGoodsList.addAll(reduceGoods);
}
return allCartGoodsList;
}
private List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> getCoupon(String couponCode,String activityCode,List<CartGoods> cartGoodsList){
List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons = new ArrayList<>();
if (StringUtils.isNotEmpty(couponCode)) {
ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon coupon = new ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon();
coupon.setCode(couponCode);
coupon.setActivityCode(activityCode);
coupons.add(coupon);
}
//购物车商品券
if(CollectionUtils.isNotEmpty(cartGoodsList)){
for (CartGoods cartGoods : cartGoodsList){
//购物车已存在商品券
if(StringUtils.isNotBlank(cartGoods.getCouponCode())){
ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon calculationDiscountCoupon = new ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon();
calculationDiscountCoupon.setCode(couponCode);
coupons.add(calculationDiscountCoupon);
}
}
}
return coupons;
}
}
......@@ -72,7 +72,6 @@ public class CalculationServiceImpl {
@Autowired
private SetMealCalculation setMealCalculation;
@Autowired
private ShoppingCartConvertAdapter shoppingCartConvertAdapter;
......@@ -80,9 +79,9 @@ public class CalculationServiceImpl {
* 更新购物车行优惠信息
*/
public ActivityCalculationDiscountResponseDto.CalculationDiscountResult updateShoppingCartGoodsDiscount(String partnerId, String storeId, String userId, String appId, Integer orderType,
boolean isMember, String menuType, String receiveId,String couponCode,
List<CartGoods> cartGoodsList, List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons,
List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo) {
boolean isMember, String menuType, String receiveId,String couponCode,
List<CartGoods> cartGoodsList, List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons,
List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo) {
Long deliveryAmount = 0L;
QueryDeliverDetailResponse response = calculateDeliveryAmount(receiveId, partnerId, storeId, appId);
......@@ -98,7 +97,7 @@ public class CalculationServiceImpl {
ActivityQueryDto activityQueryDto = fullPromotionCalculation.getActivityQueryDto(partnerId, storeId, userId, appId, orderType);
fullPromotionCalculation.updateShoppingCartGoodsDiscount(activityQueryDto, calculationDiscount, cartGoodsList, shoppingCartGoodsResponseVo);
//限时特价
//限时特价、单品特价、超值加购
timeSaleCalculation.updateShoppingCartGoodsDiscount(calculationDiscount, cartGoodsList, shoppingCartGoodsResponseVo);
//优惠券
......@@ -166,6 +165,13 @@ public class CalculationServiceImpl {
shoppingCartGoodsDto.setOriginalTotalAmount(shoppingCartGoodsResponseVo.getOriginalTotalAmount());
shoppingCartGoodsDto.setTotalAmount(shoppingCartGoodsResponseVo.getTotalAmount());
shoppingCartGoodsDto.setTotalDiscountAmount(shoppingCartGoodsResponseVo.getTotalDiscountAmount());
shoppingCartGoodsDto.setDeliveryAmount(shoppingCartGoodsResponseVo.getDeliveryAmount());
shoppingCartGoodsDto.setDiscountDeliveryAmount(shoppingCartGoodsResponseVo.getDiscountDeliveryAmount());
shoppingCartGoodsDto.setThresholdAmount(shoppingCartGoodsResponseVo.getThresholdAmount());
shoppingCartGoodsDto.setIsDiscountDelivery(shoppingCartGoodsResponseVo.getIsDiscountDelivery());
shoppingCartGoodsDto.setDiscountDeliveryActivityCode(shoppingCartGoodsResponseVo.getDiscountDeliveryActivityCode());
// todo 包装费
shoppingCartGoodsDto.setPackageAmount(shoppingCartGoodsResponseVo.getNewPackAmount());
List<CartGoods> cartGoodsList = shoppingCartGoodsResponseVo.getProducts();
......
......@@ -74,7 +74,6 @@ public class CouponDiscountCalculation {
*/
public void updateShoppingCartGoodsDiscount(CouponPromotionVO couponPromotionVO, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult, List<CartGoods> cartGoodsList, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo) {
// 当couponCode不为空时,需计算优惠价格
long couponDiscount = 0;
if (couponPromotionVO != null && StringUtils.isNotEmpty(couponPromotionVO.getCouponCode())
......@@ -155,15 +154,15 @@ public class CouponDiscountCalculation {
getMemberCouponListRequestDto.setPageSize(Integer.MAX_VALUE);
GetMemberCouponListResponseDto.Result result = getMemberCouponList(getMemberCouponListRequestDto);
LogUtil.debug("CouponServiceImpl_getMemberCouponList", JSON.toJSONString(getMemberCouponListRequestDto), JSON.toJSONString(result));
if (result == null || CollectionUtils.isEmpty(result.getMemberCoupons())) {
return null;
}
ActivityClassifyCouponBean availableCouponResponseVo = new ActivityClassifyCouponBean();
// 可用优惠券信息
List<ActivityCouponBean> usableCoupons = Lists.newArrayList();
// 不可用优惠券信息
List<ActivityCouponBean> disableCoupons = Lists.newArrayList();
if (result == null || CollectionUtils.isEmpty(result.getMemberCoupons())) {
return returnEmptyAvailableCoupon(availableCouponResponseVo, usableCoupons, disableCoupons);
}
List<GetMemberCouponListResponseDto.Result.MemberCoupon> memberCoupons = result.getMemberCoupons();
// 对象转map
Map<String, GetMemberCouponListResponseDto.Result.MemberCoupon> memberCouponMap = memberCoupons.stream().collect(
......@@ -173,13 +172,14 @@ public class CouponDiscountCalculation {
// 只筛选小于结束时间得券
// if (Objects.equals(memberCoupon.getCouponType(), CouponTypeEnum.TYPE_1.getCode())
// || Objects.equals(memberCoupon.getCouponType(), CouponTypeEnum.TYPE_3.getCode())) {
// 只筛选小于结束时间得券
if (System.currentTimeMillis() < DateUtil.convert2Date(memberCoupon.getEndTime(), DateUtil.FORMAT_YYYY_MM_DD_HHMMSS).getTime()) {
couponCodes.add(memberCoupon.getCouponCode());
}
// 只筛选小于结束时间得券
if (System.currentTimeMillis() < DateUtil.convert2Date(memberCoupon.getEndTime(), DateUtil.FORMAT_YYYY_MM_DD_HHMMSS).getTime()) {
couponCodes.add(memberCoupon.getCouponCode());
}
// }
});
//券码可用券校验
List<CouponState> couponStateList = buildAvailableCoupons(cartGoods, partnerId, storeId, couponCodes);
if (CollectionUtils.isEmpty(couponStateList)) {
return null;
......
......@@ -41,7 +41,8 @@ public class TimeSaleCalculation {
*/
public void updateShoppingCartGoodsDiscount(ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult, List<CartGoods> cartGoodsList, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo) {
if (calculationDiscountResult == null || CollectionUtils.isEmpty(calculationDiscountResult.getDiscounts())
|| !calculationDiscountResult.getDiscounts().stream().anyMatch(discount -> (ActivityTypeEnum.TYPE_2.getCode().equals(discount.getType()) || (ActivityTypeEnum.TYPE_21.getCode().equals(discount.getType()))))) {
|| !calculationDiscountResult.getDiscounts().stream().anyMatch(discount -> (ActivityTypeEnum.TYPE_2.getCode().equals(discount.getType())
||(ActivityTypeEnum.TYPE_21.getCode().equals(discount.getType())) || (ActivityTypeEnum.TYPE_23.getCode().equals(discount.getType())) ))) {
return;
}
List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods> goodsList = calculationDiscountResult.getGoods();
......@@ -53,7 +54,7 @@ public class TimeSaleCalculation {
.collect(Collectors.toMap(ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods::getGoodsId, Function.identity(), (k1, k2) -> k1));
// 存储当前享受限时特价折扣的商品数量,key:goodsId; value:可享受数量
Map<String, Integer> numberMap = new HashMap<>();
List<Integer> discounts = Arrays.asList(ActivityTypeEnum.TYPE_2.getCode(), ActivityTypeEnum.TYPE_21.getCode());
List<Integer> discounts = Arrays.asList(ActivityTypeEnum.TYPE_2.getCode(), ActivityTypeEnum.TYPE_21.getCode(),ActivityTypeEnum.TYPE_23.getCode());
for (CartGoods cartGoods : cartGoodsList) {
ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods goods;
if ((goods = goodsMap.get(cartGoods.getGoodsId())) == null) {
......
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