From ec59428eacc798b8dfc617644aa9ca05066f2341 Mon Sep 17 00:00:00 2001
From: 姜友瑶 <935090232@qq.com>
Date: Sat, 02 Jul 2022 16:13:55 +0800
Subject: [PATCH] Merge branch 'developer'
---
zq-erp/src/main/java/com/matrix/system/hive/service/imp/ShoppingGoodsServiceImpl.java | 93 ++++++++++++++++++++++++++++++++++++++--------
1 files changed, 76 insertions(+), 17 deletions(-)
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/ShoppingGoodsServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/ShoppingGoodsServiceImpl.java
index 4977b14..a9adf31 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/ShoppingGoodsServiceImpl.java
+++ b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/ShoppingGoodsServiceImpl.java
@@ -1,5 +1,6 @@
package com.matrix.system.hive.service.imp;
+import cn.hutool.core.collection.CollUtil;
import com.matrix.core.constance.MatrixConstance;
import com.matrix.core.exception.GlobleException;
import com.matrix.core.pojo.PaginationVO;
@@ -7,21 +8,21 @@
import com.matrix.core.tools.StringUtils;
import com.matrix.core.tools.WebUtil;
import com.matrix.system.app.dto.ShoppingGoodsListDto;
+import com.matrix.system.app.vo.ShoppingGoodsDetailVo;
import com.matrix.system.app.vo.ShoppingGoodsListVo;
import com.matrix.system.common.bean.SysUsers;
import com.matrix.system.common.dao.UtilDao;
import com.matrix.system.common.tools.ServiceUtil;
import com.matrix.system.constance.Dictionary;
import com.matrix.system.constance.TableMapping;
-import com.matrix.system.hive.bean.MoneyCardAssemble;
import com.matrix.system.hive.bean.ShoppingGoods;
import com.matrix.system.hive.bean.ShoppingGoodsAssemble;
+import com.matrix.system.hive.bean.ShoppingGoodsCategory;
import com.matrix.system.hive.bean.SysShopInfo;
import com.matrix.system.hive.dao.MoneyCardAssembleDao;
import com.matrix.system.hive.dao.ShoppingGoodsAssembleDao;
import com.matrix.system.hive.dao.ShoppingGoodsDao;
import com.matrix.system.hive.dao.SysShopInfoDao;
-import com.matrix.system.hive.plugin.message.StringUtil;
import com.matrix.system.hive.service.ShoppingGoodsService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -29,11 +30,12 @@
import org.springframework.transaction.annotation.Transactional;
import javax.validation.constraints.NotNull;
-import java.awt.event.WindowStateListener;
-import java.time.LocalDate;
+import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
/**
@@ -60,16 +62,11 @@
-
-
-
-
@Override
@Transactional(rollbackFor = Exception.class)
public int add(ShoppingGoods shoppingGoods) {
SysUsers sysUsers = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
SysShopInfo shopInfo = shopInfoDao.selectById(sysUsers.getShopId());
-
if(shopInfo.getShopType()==SysShopInfo.SHOP_TYPE_ZONGBU){
@@ -79,10 +76,14 @@
}
shoppingGoods.setShopId(sysUsers.getShopId());
- // 校验去重
- if (serviceUtil.addCheckRepeatTowColumn("shopping_goods",
- "code", shoppingGoods.getCode(),
- "company_id", shoppingGoods.getCompanyId())) {
+
+ //去重查询
+ ShoppingGoods queryGoods=new ShoppingGoods();
+ queryGoods.setCompanyId(shoppingGoods.getCompanyId());
+ queryGoods.setCode(shoppingGoods.getCode());
+ queryGoods.setIsDel(ShoppingGoods.NORMAL);
+ List<ShoppingGoods> oldGoods=shoppingGoodsDao.selectByModel(queryGoods);
+ if(CollUtil.isNotEmpty(oldGoods)){
throw new GlobleException("编号" + shoppingGoods.getCode() + "重复");
}
@@ -129,7 +130,7 @@
private void setShoppingGoodsInvalidTime(ShoppingGoods shoppingGoods) {
// 若未设置购买有效期和消耗有效期,则默认永久有效
// if (shoppingGoods.getBuyDateNum() == null && shoppingGoods.getUseDateNum() == null) {
-// shoppingGoods.setInvalidTime(DateUtil.stringToDate("9999-12-31", DateUtil.DATE_FORMAT_DD));
+// shoppingGoods.setInvalidTime(DateUtil.stringToDate("2099-12-31", DateUtil.DATE_FORMAT_DD));
// } else {
// // 计算失效日期,判断购买有效期和消耗有效期哪个先失效,则为失效日期
// Date buyValidDate = DateUtil.calDate(shoppingGoods.getBuyDateNum(), shoppingGoods.getBuyDateUnit());
@@ -243,6 +244,17 @@
@Override
@Transactional(rollbackFor = Exception.class)
public int remove(List<Long> list) {
+ SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
+ SysShopInfo zbShop = shopInfoDao.selectZbShop(user.getCompanyId());
+ //非总部员工只能删除自己门店的产品
+ if(user.getShopId()!=zbShop.getId()){
+ //校验是否可以删除
+ List<ShoppingGoods> dataList = shoppingGoodsDao.selectByIds(list);
+ List<ShoppingGoods> collect = dataList.stream().filter(goods -> !Objects.equals(user.getShopId(), goods.getShopId())).collect(Collectors.toList());
+ if(CollUtil.isNotEmpty(collect)){
+ throw new GlobleException("非总部员工只能删除自己门店的产品");
+ }
+ }
return shoppingGoodsDao.deleteByIds(list);
}
@@ -436,7 +448,11 @@
@Override
public Date calInvalidTime(ShoppingGoods shoppingGoods, @NotNull Integer type, Date buyDate) {
if (StringUtils.isBlank(shoppingGoods.getBuyValid()) && StringUtils.isBlank(shoppingGoods.getUseValid()) && shoppingGoods.getInvalidTime() == null) {
- return DateUtil.stringToDate("9999-12-31", DateUtil.DATE_FORMAT_DD);
+ return DateUtil.stringToDate("2099-12-31", DateUtil.DATE_FORMAT_DD);
+ }
+
+ if (type == 2 && shoppingGoods.getUseDateNum() == null && StringUtils.isNotBlank(shoppingGoods.getBuyDateUnit())) {
+ return DateUtil.stringToDate("2099-12-31", DateUtil.DATE_FORMAT_DD);
}
if (type == 2 && buyDate == null) {
@@ -451,7 +467,7 @@
buyValidDate = buyDate;
}
- Date useValidDate = DateUtil.stringToDate("9999-12-31", DateUtil.DATE_FORMAT_DD);
+ Date useValidDate = DateUtil.stringToDate("2099-12-31", DateUtil.DATE_FORMAT_DD);
if (type == 2) {
useValidDate = DateUtil.calDate(shoppingGoods.getUseDateNum(), shoppingGoods.getUseDateUnit());
}
@@ -476,7 +492,7 @@
SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
shoppingGoodsListDto.setShopId(user.getShopId());
PaginationVO pageVo = new PaginationVO();
- int offset = (shoppingGoodsListDto.getPageNum() - 1) + shoppingGoodsListDto.getPageSize();
+ int offset = (shoppingGoodsListDto.getPageNum() - 1) * shoppingGoodsListDto.getPageSize();
int limit = shoppingGoodsListDto.getPageSize();
pageVo.setOffset(offset);
pageVo.setLimit(limit);
@@ -487,6 +503,49 @@
public int findShoppingGoodsListTotalForApi(ShoppingGoodsListDto shoppingGoodsListDto) {
SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
shoppingGoodsListDto.setShopId(user.getShopId());
+
return shoppingGoodsDao.selectShopppingGoodsAipTotal(shoppingGoodsListDto);
}
+
+ @Override
+ public ShoppingGoodsDetailVo findApiShoppingGoodsDetailById(Long id) {
+ ShoppingGoods shoppingGoods = shoppingGoodsDao.selectById(id);
+ ShoppingGoodsDetailVo goodsDetailVo = goodsToGoodsDetailVo(shoppingGoods);
+
+ if (ShoppingGoods.SHOPPING_GOODS_TYPE_TC.equals(shoppingGoods.getGoodType())) {
+ List<ShoppingGoodsDetailVo> products = shoppingGoodsAssembleDao.selectGoodsRelationGoodsList(shoppingGoods.getId(), ShoppingGoods.SHOPPING_GOODS_TYPE_JJCP);
+ List<ShoppingGoodsDetailVo> proj = shoppingGoodsAssembleDao.selectGoodsRelationGoodsList(shoppingGoods.getId(), ShoppingGoods.SHOPPING_GOODS_TYPE_XM);
+
+ goodsDetailVo.setAssembleTaocanProduct(products);
+ goodsDetailVo.setAssembleTaocanProj(proj);
+ } else if (ShoppingGoods.SHOPPING_GOODS_TYPE_XM.equals(shoppingGoods.getGoodType())) {
+ List<ShoppingGoodsDetailVo> products = shoppingGoodsAssembleDao.selectGoodsRelationGoodsList(shoppingGoods.getId(), null);
+ goodsDetailVo.setAssembleProj(products);
+ } else if (ShoppingGoods.SHOPPING_GOODS_TYPE_CZK.equals(shoppingGoods.getGoodType())) {
+ List<ShoppingGoodsDetailVo> cardGoods = moneyCardAssembleDao.selectCardRelationGoods(shoppingGoods.getId());
+ List<ShoppingGoodsCategory> cardCategory = moneyCardAssembleDao.selectCardRelationCategory(shoppingGoods.getId());
+
+ goodsDetailVo.setAssembleProj(cardGoods);
+ goodsDetailVo.setCardCategory(cardCategory);
+ }
+ return goodsDetailVo;
+ }
+
+ private ShoppingGoodsDetailVo goodsToGoodsDetailVo(ShoppingGoods shoppingGoods) {
+ ShoppingGoodsDetailVo goodsDetailVo = new ShoppingGoodsDetailVo();
+ goodsDetailVo.setImg(shoppingGoods.getImg());
+ goodsDetailVo.setGoodsName(shoppingGoods.getName());
+ goodsDetailVo.setGoodsNo(shoppingGoods.getCode());
+ goodsDetailVo.setGoodsType(shoppingGoods.getGoodType());
+ goodsDetailVo.setDesc(shoppingGoods.getDescription());
+ goodsDetailVo.setMaxSaleCnt(shoppingGoods.getCarMaxSaleCount());
+ goodsDetailVo.setLimitBuyCnt(shoppingGoods.getIsOnce());
+ goodsDetailVo.setMaxUseCnt(shoppingGoods.getCarUseCount());
+ goodsDetailVo.setMeasure(shoppingGoods.getMeasure());
+ goodsDetailVo.setVolume(shoppingGoods.getVolume());
+ goodsDetailVo.setSalePrice(BigDecimal.valueOf(shoppingGoods.getSealPice()));
+ goodsDetailVo.setSaleCnt(shoppingGoods.getRealSealCount());
+ goodsDetailVo.setGiftPrice(BigDecimal.valueOf(shoppingGoods.getReferencePice() == null ? 0 : shoppingGoods.getReferencePice()));
+ return goodsDetailVo;
+ }
}
--
Gitblit v1.9.1