From bbe0a2fd03063316e50cf141986bda984599bbda Mon Sep 17 00:00:00 2001 From: 935090232@qq.com <ak473600000> Date: Tue, 22 Feb 2022 23:41:42 +0800 Subject: [PATCH] Merge branch 'developer' --- zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/ShoppingCartService.java | 66 +++++++++----------------------- 1 files changed, 19 insertions(+), 47 deletions(-) diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/ShoppingCartService.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/ShoppingCartService.java index 4f9f35a..aed6be7 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/ShoppingCartService.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/ShoppingCartService.java @@ -1,19 +1,13 @@ package com.matrix.system.shopXcx.api.service; +import com.matrix.system.common.init.UserCacheManager; import com.matrix.core.tools.LogUtil; -import com.matrix.biz.bean.BizUser; -import com.matrix.system.common.bean.BusParameterSettings; -import com.matrix.system.common.bean.CustomerDataDictionary; import com.matrix.system.common.dao.BusParameterSettingsDao; -import com.matrix.system.common.dao.CustomerDataDictionaryDao; -import com.matrix.component.redis.RedisUserLoginUtils; -import com.matrix.system.common.constance.AppConstance; - +import com.matrix.system.shopXcx.api.vo.ShopCartBillVo; +import com.matrix.system.shopXcx.api.vo.ShopCartVo; import com.matrix.system.shopXcx.bean.ShopCoupon; import com.matrix.system.shopXcx.bean.ShopShoppingCart; import com.matrix.system.shopXcx.dao.ShopShoppingCartDao; -import com.matrix.system.shopXcx.api.vo.ShopCartBillVo; -import com.matrix.system.shopXcx.api.vo.ShopCartVo; import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -27,7 +21,7 @@ @Autowired private ShopShoppingCartDao shoppingCartDao; @Autowired - private RedisUserLoginUtils redisUserLoginUtils; + private UserCacheManager userCacheManager; @Autowired WxShopCouponService shopCouponService; @@ -37,15 +31,11 @@ @Autowired BusParameterSettingsDao busParameterSettingsDao; - + //计算购车选中项总价以及优惠金额 public ShopCartBillVo buildShopCartBillVo(List<ShopCartVo> cartList) { ShopCartBillVo shopCartBillVo = new ShopCartBillVo(); - //计算购车选中项总价以及优惠金额 - BigDecimal billTotal = BigDecimal.ZERO; - BigDecimal billCouponTotal = BigDecimal.ZERO; - //未优惠之前的金额 - BigDecimal srcTotal = BigDecimal.ZERO; + //计算是否存在选中的产品 Integer selectCount = 0; @@ -64,8 +54,6 @@ shopCartBillVo.setBillCouponTotal(shopCartBillVo.getBillCouponTotal().add(shopCartVo.getCouponPrice())); } } - - for (ShopShoppingCart shopCart : shopCartVo.getCartList()) { if (shopCart.getIsSelected() == 1) { selectCount += shopCart.getCartNumber(); @@ -78,19 +66,7 @@ return shopCartBillVo; } - /** - * 计算用户的购物车产品优惠分组 - * - * @return - * @param shopId - */ - public List<ShopCartVo> findUserCartList(Long shopId) { - BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class); - String userId = loginUser.getOpenId(); - List<ShopShoppingCart> list = shoppingCartDao.selectByCartUserId(shopId,userId); - List<ShopCartVo> cartList = buildShopCart(list); - return cartList; - } + /** @@ -100,7 +76,7 @@ * @return */ @SuppressWarnings("unchecked") - private List<ShopCartVo> buildShopCart(List<ShopShoppingCart> list) { + public List<ShopCartVo> buildShopCart(List<ShopShoppingCart> list) { //定义购物车优惠分组 @@ -108,13 +84,9 @@ // 1表示没有优惠的默认分组 ShopCartVo def = new ShopCartVo(); - /** - * 同城配送标题 - * //DataDictionary qsfy = dataDictionaryDao.selectByTypeCode(AppConstance.QSFY); - * //def.setMsg("2公里内满" + qsfy.getValue() + "元免配送费"); - */ - def.setMsg("肽研官方商城"); + + def.setMsg("商城"); def.setCartList(new ArrayList<>()); // 组合默认分组 cartList.add(def); @@ -284,8 +256,14 @@ for (ShopShoppingCart shopShoppingCart : cartList) { sum = sum.add(shopShoppingCart.getPrice().multiply(BigDecimal.valueOf(shopShoppingCart.getCartNumber()))); if (shopShoppingCart.getIsSelected() == 1) { - selectSum = selectSum - .add(shopShoppingCart.getPrice().multiply(BigDecimal.valueOf(shopShoppingCart.getCartNumber()))); + if(shopShoppingCart.getCartType()==ShopShoppingCart.CAR_TYPE_MICRO){ + selectSum = selectSum + .add(shopShoppingCart.getPrice().multiply(BigDecimal.valueOf(shopShoppingCart.getCartNumber()))); + }else { + selectSum = selectSum + .add(shopShoppingCart.getScorePrice().multiply(BigDecimal.valueOf(shopShoppingCart.getCartNumber()))); + } + } } @@ -316,15 +294,9 @@ } } } else { - BusParameterSettings qsfy= busParameterSettingsDao.selectCompanyParamByCode(AppConstance.IN_PROVINCE_PACKAGE_LIST,17L); - shopCartVo.setSubtotal(selectSum); shopCartVo.setSrcPrice(selectSum); - if (selectSum.compareTo(new BigDecimal(qsfy.getParamValue())) < 0) { - shopCartVo.setSatisfactionCoupon(false); - } else { - shopCartVo.setSatisfactionCoupon(true); - } + shopCartVo.setSatisfactionCoupon(true); } } } -- Gitblit v1.9.1