From 393d296e43f0e5f11e524cab5446bcd3eee94e89 Mon Sep 17 00:00:00 2001 From: jyy <jyy> Date: Sat, 12 Jun 2021 17:47:38 +0800 Subject: [PATCH] 新增赠送项目是否计算消耗控制 --- zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShoppingCartAction.java | 36 ++++++++++++++++++++---------------- 1 files changed, 20 insertions(+), 16 deletions(-) diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShoppingCartAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShoppingCartAction.java index 91eeace..3b17f08 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShoppingCartAction.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShoppingCartAction.java @@ -1,6 +1,6 @@ package com.matrix.system.shopXcx.api.action; -import com.matrix.biz.bean.BizUser; +import com.matrix.system.hive.bean.SysVipInfo; import com.matrix.component.redis.RedisUserLoginUtils; import com.matrix.core.constance.SystemErrorCode; import com.matrix.core.constance.SystemMessageCode; @@ -9,6 +9,7 @@ import com.matrix.core.tools.StringUtils; import com.matrix.system.common.constance.AppConstance; import com.matrix.system.common.interceptor.HostInterceptor; +import com.matrix.system.shopXcx.api.service.OrderCouponGroupService; import com.matrix.system.shopXcx.api.service.ShoppingCartService; import com.matrix.system.shopXcx.api.service.WxShopCouponService; import com.matrix.system.shopXcx.api.vo.ShopCartBillVo; @@ -51,7 +52,8 @@ @Autowired ShopSkuDao skuDao; - + @Autowired + OrderCouponGroupService orderCouponGroupService; @ApiOperation(value = "根据ID删除购物车", notes = "") @PostMapping("/deleteByCartId/{cartId}") @@ -69,9 +71,11 @@ @PostMapping("/findShoppingCart") @ResponseBody public AjaxResult getShoppingCartByUserId(@RequestBody ShopShoppingCart shoppingCart) { - List<ShopCartVo> cartList = shoppingCartService.findUserCartList(shoppingCart.getShopId(),ShopShoppingCart.CAR_TYPE_MICRO); - AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, cartList, cartList.size()); - ShopCartBillVo shopCartBill = shoppingCartService.buildShopCartBillVo(cartList); + SysVipInfo loginUser = redisUserLoginUtils.getLoginUser(SysVipInfo.class); + List<ShopShoppingCart> list = shoppingCartDao.selectByCartUserId(shoppingCart.getShopId(),loginUser.getId()); + List<ShopCartVo> shopCartVoList = shoppingCartService.buildShopCart(list); + AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, shopCartVoList, shopCartVoList.size()); + ShopCartBillVo shopCartBill = shoppingCartService.buildShopCartBillVo(shopCartVoList); result.putInMap("billTotal", shopCartBill.getBillTotal().stripTrailingZeros().toPlainString()); result.putInMap("selectCount", shopCartBill.getSelectCount()); result.putInMap("cartCount", shopCartBill.getCartCount()); @@ -100,8 +104,8 @@ public @ResponseBody AjaxResult getUserCartCount(@PathVariable("shopId") Long shopId) { - BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class); - Integer userCartCount = shoppingCartDao.selectUserCartCount(shopId, loginUser.getOpenId()); + SysVipInfo loginUser = redisUserLoginUtils.getLoginUser(SysVipInfo.class); + Integer userCartCount = shoppingCartDao.selectUserCartCount(shopId, loginUser.getId()); if (userCartCount == null) { userCartCount = 0; } @@ -119,17 +123,17 @@ AjaxResult saveShoppingCart(@RequestBody ShopShoppingCart shoppingCart) { //查询到sku设置对应的产品id - ShopSku sku= skuDao.selectById(shoppingCart.getCartSkuId()); - if(sku==null){ - return new AjaxResult(AjaxResult.STATUS_FAIL,"无效的产品id"); + ShopSku sku = skuDao.selectById(shoppingCart.getCartSkuId()); + if (sku == null) { + return new AjaxResult(AjaxResult.STATUS_FAIL, "无效的产品id"); } shoppingCart.setCartProductId(sku.getpId()); - BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class); + SysVipInfo loginUser = redisUserLoginUtils.getLoginUser(SysVipInfo.class); shoppingCart.setCreateBy(loginUser.getOpenId()); shoppingCart.setUpdateBy(loginUser.getOpenId()); - shoppingCart.setCartUserId(loginUser.getOpenId()); + shoppingCart.setCartUserId(loginUser.getId()); shoppingCart.setCompanyId(HostInterceptor.getCompanyId()); ShopShoppingCart shoppCartLimt = shoppingCartDao.selectBuyLimit(shoppingCart.getCartProductId(), shoppingCart.getCartSkuId()); @@ -156,7 +160,7 @@ ShopShoppingCart shopShoppingCart = new ShopShoppingCart(); shopShoppingCart.setCartProductId(cartProductId); shopShoppingCart.setCartSkuId(cartSkuId); - shopShoppingCart.setCartUserId(loginUser.getOpenId()); + shopShoppingCart.setCartUserId(loginUser.getId()); shopShoppingCart.setShopId(shoppingCart.getShopId()); List<ShopShoppingCart> shopShoppingCarts = shoppingCartDao.selectByModel(shopShoppingCart); int i = 0; @@ -189,7 +193,7 @@ return new AjaxResult(AjaxResult.STATUS_FAIL, "保存失败"); } int userCartCount = shoppingCartDao.selectUserCartCount(shoppingCart.getShopId(), - loginUser.getOpenId()); + loginUser.getId()); AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, "保存成功"); result.putInMap("userCartCount", userCartCount); return result; @@ -273,8 +277,8 @@ @ResponseBody public AjaxResult updateCartAllSelected(@PathVariable("isSelected") Integer isSelected, @PathVariable("shopId") Long shopId) { - BizUser user = redisUserLoginUtils.getLoginUser(BizUser.class); - shoppingCartDao.updateAllSelected(user.getOpenId(),shopId, isSelected); + SysVipInfo user = redisUserLoginUtils.getLoginUser(SysVipInfo.class); + shoppingCartDao.updateAllSelected(user.getOpenId(), shopId, isSelected); return new AjaxResult(AjaxResult.STATUS_SUCCESS, "修改成功"); } } -- Gitblit v1.9.1