| | |
| | | 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; |
| | |
| | | @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; |
| | |
| | | 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; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | * @return |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | private List<ShopCartVo> buildShopCart(List<ShopShoppingCart> list) { |
| | | public List<ShopCartVo> buildShopCart(List<ShopShoppingCart> list) { |
| | | |
| | | |
| | | //定义购物车优惠分组 |
| | |
| | | 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()))); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | } else { |
| | | shopCartVo.setSubtotal(selectSum); |
| | | shopCartVo.setSrcPrice(selectSum); |
| | | shopCartVo.setSatisfactionCoupon(true); |
| | | shopCartVo.setSubtotal(selectSum); |
| | | shopCartVo.setSrcPrice(selectSum); |
| | | shopCartVo.setSatisfactionCoupon(true); |
| | | } |
| | | } |
| | | } |