From 1d0c686d7894463770b2412d37dec11568e35e5a Mon Sep 17 00:00:00 2001
From: wzy <wzy19931122ai@163.com>
Date: Sat, 20 Nov 2021 21:18:48 +0800
Subject: [PATCH] fix
---
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopProduct.java | 52 +++++++++++++++++++++++++++++++++-------------------
1 files changed, 33 insertions(+), 19 deletions(-)
diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopProduct.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopProduct.java
index 2b06093..96b7711 100644
--- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopProduct.java
+++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopProduct.java
@@ -1,26 +1,27 @@
package com.matrix.system.shopXcx.api.action;
import com.matrix.core.pojo.AjaxResult;
-import com.matrix.core.pojo.PaginationVO;
import com.matrix.core.tools.StringUtils;
-import com.matrix.biz.bean.BizUser;
-import com.matrix.system.common.bean.CustomerDataDictionary;
-import com.matrix.system.common.dao.CustomerDataDictionaryDao;
-import com.matrix.component.redis.RedisUserLoginUtils;
import com.matrix.system.common.constance.AppConstance;
-
+import com.matrix.system.common.dao.CustomerDataDictionaryDao;
+import com.matrix.system.common.init.UserCacheManager;
import com.matrix.system.common.interceptor.HostInterceptor;
+import com.matrix.system.fenxiao.dao.ShopSalesmanGradeDao;
+import com.matrix.system.fenxiao.entity.ShopSalesmanGrade;
+import com.matrix.system.hive.bean.SysVipInfo;
+import com.matrix.system.shopXcx.api.service.WxShopCouponService;
import com.matrix.system.shopXcx.bean.*;
import com.matrix.system.shopXcx.dao.*;
-import com.matrix.system.shopXcx.api.service.WxShopCouponService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
+import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Objects;
/**
* @author pengliang
@@ -64,7 +65,7 @@
private ShopArticleDao shopArticleDao;
@Autowired
- private RedisUserLoginUtils redisUserLoginUtils;
+ private UserCacheManager userCacheManager;
@Autowired
WxShopCouponService shopCouponService;
@@ -75,6 +76,9 @@
@Autowired
private ShopProductCommentDao productCommentDao;
+ @Autowired
+ private ShopSalesmanGradeDao shopSalesmanGradeDao;
+
/**
* 根据id查询商品信息
*
@@ -84,16 +88,29 @@
@RequestMapping(value = "/getProductById/{shopId}/{id}")
@ResponseBody
public AjaxResult getProductById(@PathVariable Long shopId, @PathVariable("id") Integer id) {
-
+ SysVipInfo sysVipInfo = userCacheManager.getLoginUser();
ShopProduct shopProduct = shopProductDao.selectById(id);
if (shopProduct == null) {
return new AjaxResult(AjaxResult.STATUS_FAIL, "没有查询到商品");
}
-
List<ShopProductAttrRef> shopProductAttrRefs = shopProductAttrRefDao.selectByPid(id);
List<ShopProductImg> shopProductImgs = shopProductImgDao.selectByPid(id);
List<ShopSku> shopSkus = shopSkuDao.selectByPid(id);
-// List<ShopSku> shopSkus = shopSkuDao.selectByPidAndShopid(id, shopId);
+ if(SysVipInfo.IS_SALES==sysVipInfo.getIsSales()){
+ ShopSalesmanGrade shopSalesmanGrade = shopSalesmanGradeDao.selectById(sysVipInfo.getSalesmanGrade());
+ //计算产品佣金
+ shopSkus.forEach(shopSku -> {
+ if(Objects.isNull(shopSku.getInvitationPrice())){
+ shopSku.setInvitationPrice(shopSku.getPrice().multiply(BigDecimal.valueOf(shopSalesmanGrade.getInvitationCommission())).divide(BigDecimal.valueOf(100)));
+ }
+ if(Objects.isNull(shopSku.getSealesPrice())){
+ shopSku.setSealesPrice(shopSku.getPrice().multiply(BigDecimal.valueOf(shopSalesmanGrade.getSealesCommission())).divide(BigDecimal.valueOf(100)));
+ }
+ if(Objects.isNull(shopSku.getSelfPrice())){
+ shopSku.setSelfPrice(shopSku.getPrice().multiply(BigDecimal.valueOf(shopSalesmanGrade.getSelfCommission())).divide(BigDecimal.valueOf(100)));
+ }
+ });
+ }
List<ShopProductParamRef> shopProductParamRefs = shopProductParamRefDao.selectByPid(id);
shopProduct.setAttrRefs(shopProductAttrRefs);
shopProduct.setProductImgs(shopProductImgs);
@@ -111,11 +128,12 @@
- if (redisUserLoginUtils.isUserLogin()) {
+ if (userCacheManager.isUserLogin()) {
//查询产品适配的优惠券
result.putInMap("couponList", shopCouponService.getCouponListByProductId(id));
//查询产品是否被用户收藏
- result.putInMap("checkCollect", CollectionUtils.isNotEmpty(collectionDao.selectByUserIdAndProid(id, redisUserLoginUtils.getLoginUser(BizUser.class).getOpenId())));
+ SysVipInfo user=userCacheManager.getLoginUser();
+ result.putInMap("checkCollect", CollectionUtils.isNotEmpty(collectionDao.selectByUserIdAndProid(id, user.getOpenId())));
} else {
result.putInMap("checkCollect", false);
}
@@ -150,7 +168,6 @@
@ResponseBody
public AjaxResult getShopProductShowList(@RequestBody ShopProduct shopProduct) {
List<ShopProduct> shopProducts = null;
-
//查询是否匹配优惠条件
ShopCoupon shopCoupon = shopCouponDao.getCouponByTitle(shopProduct.getTitle(),HostInterceptor.getCompanyId());
if (shopCoupon != null && shopProduct.getOffset() < 1) {
@@ -161,9 +178,6 @@
if (CollectionUtils.isEmpty(shopProducts)) {
shopProduct.setDelFlag(AppConstance.DATA_USEABLE);
shopProduct.setStatus(AppConstance.IS_PUTAWAY);
- if(shopProduct.getIsService()==null){
- shopProduct.setIsService(2);
- }
shopProduct.setCompanyId(HostInterceptor.getCompanyId());
shopProducts = shopProductDao.selectByModelWx(shopProduct);
}
@@ -217,13 +231,13 @@
* @param shopProduct
*/
private void saveSearchHistroy(@RequestBody ShopProduct shopProduct) {
- BizUser bigUser = redisUserLoginUtils.getLoginUser(BizUser.class);
+ SysVipInfo bigUser = userCacheManager.getLoginUser();
ShopSearchRecord searchBean = new ShopSearchRecord();
if (StringUtils.isNotBlank(shopProduct.getTitle())) {
searchBean.setSearchType(AppConstance.SEARCH_TYPE);
searchBean.setSearchContent(shopProduct.getTitle());
}
- searchBean.setUserId(bigUser.getOpenId());
+ searchBean.setUserId(bigUser.getId());
searchBean.setSearchPriceStart(shopProduct.getStartPrice());
searchBean.setSearchPriceEnd(shopProduct.getEndPrice());
searchBean.setSearchDel(AppConstance.DATA_USEABLE);
--
Gitblit v1.9.1