xiaoyong931011
2021-04-12 a13a93a493e7e94e28b2225c26e7e13b52d3288c
zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/ShoppingCartService.java
@@ -1,6 +1,5 @@
package com.matrix.system.shopXcx.api.service;
import com.matrix.biz.bean.BizUser;
import com.matrix.component.redis.RedisUserLoginUtils;
import com.matrix.core.tools.LogUtil;
import com.matrix.system.common.dao.BusParameterSettingsDao;
@@ -32,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;
@@ -71,19 +66,7 @@
        return shopCartBillVo;
    }
    /**
     * 计算用户的购物车产品优惠分组
     *
     * @return
     * @param shopId
     */
    public List<ShopCartVo> findUserCartList(Long shopId,Integer cartType) {
        BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class);
        String userId = loginUser.getOpenId();
        List<ShopShoppingCart> list = shoppingCartDao.selectByCartUserId(shopId,userId,cartType);
        List<ShopCartVo> cartList = buildShopCart(list);
        return cartList;
    }
    /**
@@ -93,7 +76,7 @@
     * @return
     */
    @SuppressWarnings("unchecked")
    private List<ShopCartVo> buildShopCart(List<ShopShoppingCart> list) {
    public List<ShopCartVo> buildShopCart(List<ShopShoppingCart> list) {
        //定义购物车优惠分组
@@ -273,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())));
                }
            }
        }
@@ -305,9 +294,9 @@
                }
            }
        } else {
                shopCartVo.setSubtotal(selectSum);
                shopCartVo.setSrcPrice(selectSum);
                shopCartVo.setSatisfactionCoupon(true);
            shopCartVo.setSubtotal(selectSum);
            shopCartVo.setSrcPrice(selectSum);
            shopCartVo.setSatisfactionCoupon(true);
        }
    }
}