From c16b9ffceac828840ef7ebc4827612d17906704a Mon Sep 17 00:00:00 2001
From: jyy <935090232@qq.com>
Date: Fri, 19 Mar 2021 19:56:29 +0800
Subject: [PATCH] 积分商城9
---
zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/ShoppingCartService.java | 64 ++++++++++++++++++++------------
1 files changed, 40 insertions(+), 24 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 5180721..ab83b88 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
@@ -2,6 +2,7 @@
import com.matrix.biz.bean.BizUser;
import com.matrix.component.redis.RedisUserLoginUtils;
+import com.matrix.core.exception.GlobleException;
import com.matrix.core.tools.LogUtil;
import com.matrix.system.common.dao.BusParameterSettingsDao;
import com.matrix.system.shopXcx.api.vo.ShopCartBillVo;
@@ -36,11 +37,7 @@
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;
@@ -59,8 +56,6 @@
shopCartBillVo.setBillCouponTotal(shopCartBillVo.getBillCouponTotal().add(shopCartVo.getCouponPrice()));
}
}
-
-
for (ShopShoppingCart shopCart : shopCartVo.getCartList()) {
if (shopCart.getIsSelected() == 1) {
selectCount += shopCart.getCartNumber();
@@ -70,6 +65,7 @@
}
shopCartBillVo.setCartCount(cartCount);
shopCartBillVo.setSelectCount(selectCount);
+
return shopCartBillVo;
}
@@ -79,10 +75,10 @@
* @return
* @param shopId
*/
- public List<ShopCartVo> findUserCartList(Long 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);
+ List<ShopShoppingCart> list = shoppingCartDao.selectByCartUserId(shopId,userId,cartType);
List<ShopCartVo> cartList = buildShopCart(list);
return cartList;
}
@@ -116,19 +112,23 @@
//查询购物车中的产品匹配上的所有优惠活动
for (ShopShoppingCart shoppingCart : list) {
- List<ShopCoupon> shopCoupons = shopCouponService.getHdListByProductId(shoppingCart.getCartProductId());
-
- if (CollectionUtils.isNotEmpty(shopCoupons)) {
- // 把所有的优惠券和购物车条目先关联一下,后续可以计算优惠升级的情况
- shoppingCart.setShopCoupons(shopCoupons);
- for (ShopCoupon shopCoupon : shopCoupons) {
- shopCouponMap.put(shopCoupon.getId(), shopCoupon);
- }
- } else {
- // 该产品没有参加优惠券
+ if(shoppingCart.getCartType()==ShopShoppingCart.CAR_TYPE_SCORE){
+ // 积分兑换产品不参加优惠
def.getCartList().add(shoppingCart);
-
+ }else{
+ List<ShopCoupon> shopCoupons = shopCouponService.getHdListByProductId(shoppingCart.getCartProductId());
+ if (CollectionUtils.isNotEmpty(shopCoupons)) {
+ // 把所有的优惠券和购物车条目先关联一下,后续可以计算优惠升级的情况
+ shoppingCart.setShopCoupons(shopCoupons);
+ for (ShopCoupon shopCoupon : shopCoupons) {
+ shopCouponMap.put(shopCoupon.getId(), shopCoupon);
+ }
+ } else {
+ // 该产品没有参加优惠券
+ def.getCartList().add(shoppingCart);
+ }
}
+
}
//计算没有优惠组的价格
@@ -270,13 +270,28 @@
List<ShopShoppingCart> cartList = shopCartVo.getCartList();
// 计算总价
BigDecimal sum = BigDecimal.ZERO;
+ //抵扣总积分
+ BigDecimal scoreSum = BigDecimal.ZERO;
// 选中项总价
BigDecimal selectSum = BigDecimal.ZERO;
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.CAR_TYPE_MICRO==shopShoppingCart.getCartType()){
+ //直接购买
+ sum = sum.add(shopShoppingCart.getPrice().multiply(BigDecimal.valueOf(shopShoppingCart.getCartNumber())));
+ if (shopShoppingCart.getIsSelected() == 1) {
+ selectSum = selectSum
+ .add(shopShoppingCart.getPrice().multiply(BigDecimal.valueOf(shopShoppingCart.getCartNumber())));
+ }
+ }else if(ShopShoppingCart.CAR_TYPE_SCORE==shopShoppingCart.getCartType()){
+ //积分兑换
+ sum = sum.add(shopShoppingCart.getScorePrice().multiply(BigDecimal.valueOf(shopShoppingCart.getCartNumber())));
+ if (shopShoppingCart.getIsSelected() == 1) {
+ selectSum = selectSum
+ .add(shopShoppingCart.getScorePrice().multiply(BigDecimal.valueOf(shopShoppingCart.getCartNumber())));
+ scoreSum = scoreSum.add(new BigDecimal(shopShoppingCart.getScoreCount() * shopShoppingCart.getCartNumber()));
+ }
+ }else{
+ throw new GlobleException("参数错误");
}
}
@@ -311,5 +326,6 @@
shopCartVo.setSrcPrice(selectSum);
shopCartVo.setSatisfactionCoupon(true);
}
+ shopCartVo.setScorePay(scoreSum);
}
}
--
Gitblit v1.9.1