|
@@ -91,9 +91,9 @@ public class GoodsLogic {
|
|
|
* @param pageSize
|
|
* @param pageSize
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public IPage<GoodsSpecBean> page(String isTrade,String flag, String keyword, BigDecimal startPrice, BigDecimal endPrice,
|
|
|
|
|
|
|
+ public IPage<GoodsSpecBean> page(String isTrade, String flag, String keyword, BigDecimal startPrice, BigDecimal endPrice,
|
|
|
BigDecimal startShare, BigDecimal endShare,
|
|
BigDecimal startShare, BigDecimal endShare,
|
|
|
- String goodsSortJson, String categoryId, Boolean status,List<String> goodsTypes,
|
|
|
|
|
|
|
+ String goodsSortJson, String categoryId, Boolean status, List<String> goodsTypes,
|
|
|
Integer pageNum, Integer pageSize, HttpServletRequest request) {
|
|
Integer pageNum, Integer pageSize, HttpServletRequest request) {
|
|
|
|
|
|
|
|
//获取当前登录微信企业微信id
|
|
//获取当前登录微信企业微信id
|
|
@@ -109,13 +109,13 @@ public class GoodsLogic {
|
|
|
if (StringUtils.isNotBlank(categoryId)) {
|
|
if (StringUtils.isNotBlank(categoryId)) {
|
|
|
categoryIds.add(categoryId);
|
|
categoryIds.add(categoryId);
|
|
|
}
|
|
}
|
|
|
- if(CollectionUtils.isEmpty(goodsTypes)){
|
|
|
|
|
|
|
+ if (CollectionUtils.isEmpty(goodsTypes)) {
|
|
|
goodsTypes = new ArrayList<>();
|
|
goodsTypes = new ArrayList<>();
|
|
|
goodsTypes.add(GoodsTypeEnum.COMMON.toString());
|
|
goodsTypes.add(GoodsTypeEnum.COMMON.toString());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- IPage<GoodsSpecBean> goodsSpecBeanIPage = customGoodsMapper.pageList(new Page<>(pageNum, pageSize),isTrade, flag, keyword, startPrice,
|
|
|
|
|
- endPrice, startShare, endShare, sortStr, categoryIds, status, goodsTypes,companyWechatIds);
|
|
|
|
|
|
|
+ IPage<GoodsSpecBean> goodsSpecBeanIPage = customGoodsMapper.pageList(new Page<>(pageNum, pageSize), isTrade, flag, keyword, startPrice,
|
|
|
|
|
+ endPrice, startShare, endShare, sortStr, categoryIds, status, goodsTypes, companyWechatIds);
|
|
|
|
|
|
|
|
//商品规格
|
|
//商品规格
|
|
|
List<GoodsSpecBean> records = new ArrayList<>();
|
|
List<GoodsSpecBean> records = new ArrayList<>();
|
|
@@ -123,17 +123,17 @@ public class GoodsLogic {
|
|
|
String goodsId = goodsSpecBean.getGoodsId();
|
|
String goodsId = goodsSpecBean.getGoodsId();
|
|
|
List<GoodsSpec> list = goodsSpecService.lambdaQuery().eq(GoodsSpec::getGoodsId, goodsId).list();
|
|
List<GoodsSpec> list = goodsSpecService.lambdaQuery().eq(GoodsSpec::getGoodsId, goodsId).list();
|
|
|
List<GoodsSpecVO> goodsSpecVOS = BeanUtil.copyToList(list, GoodsSpecVO.class);
|
|
List<GoodsSpecVO> goodsSpecVOS = BeanUtil.copyToList(list, GoodsSpecVO.class);
|
|
|
- for(GoodsSpecVO goodsSpecVO : goodsSpecVOS){
|
|
|
|
|
|
|
+ for (GoodsSpecVO goodsSpecVO : goodsSpecVOS) {
|
|
|
GoodsMaterial goodsMaterial = goodsMaterialService.getById(goodsSpecVO.getGoodsCode());
|
|
GoodsMaterial goodsMaterial = goodsMaterialService.getById(goodsSpecVO.getGoodsCode());
|
|
|
|
|
|
|
|
List<GoodsMaterialStorage> goodsMaterialStorages = goodsMaterialStorageService.lambdaQuery().eq(GoodsMaterialStorage::getGoodsMaterialId, goodsSpecVO.getGoodsCode())
|
|
List<GoodsMaterialStorage> goodsMaterialStorages = goodsMaterialStorageService.lambdaQuery().eq(GoodsMaterialStorage::getGoodsMaterialId, goodsSpecVO.getGoodsCode())
|
|
|
.list();
|
|
.list();
|
|
|
- if(goodsMaterial != null){
|
|
|
|
|
|
|
+ if (goodsMaterial != null) {
|
|
|
goodsSpecVO.setGoodsMaterialName(goodsMaterial.getGoodsName());
|
|
goodsSpecVO.setGoodsMaterialName(goodsMaterial.getGoodsName());
|
|
|
|
|
|
|
|
goodsSpecVO.setGoodsMaterialStock(goodsMaterialStorages.stream().map(GoodsMaterialStorage::getStockQty).reduce(Integer::sum).orElse(0));
|
|
goodsSpecVO.setGoodsMaterialStock(goodsMaterialStorages.stream().map(GoodsMaterialStorage::getStockQty).reduce(Integer::sum).orElse(0));
|
|
|
|
|
|
|
|
- goodsSpecBean.setAllStockNum(goodsSpecBean.getAllStockNum() != null?goodsSpecBean.getAllStockNum()+goodsMaterialStorages.stream().map(GoodsMaterialStorage::getStockQty).reduce(Integer::sum).orElse(0):
|
|
|
|
|
|
|
+ goodsSpecBean.setAllStockNum(goodsSpecBean.getAllStockNum() != null ? goodsSpecBean.getAllStockNum() + goodsMaterialStorages.stream().map(GoodsMaterialStorage::getStockQty).reduce(Integer::sum).orElse(0) :
|
|
|
goodsMaterialStorages.stream().map(GoodsMaterialStorage::getStockQty).reduce(Integer::sum).orElse(0));
|
|
goodsMaterialStorages.stream().map(GoodsMaterialStorage::getStockQty).reduce(Integer::sum).orElse(0));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -147,6 +147,7 @@ public class GoodsLogic {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 套购商品列表
|
|
* 套购商品列表
|
|
|
|
|
+ *
|
|
|
* @param keyword
|
|
* @param keyword
|
|
|
* @param startPrice
|
|
* @param startPrice
|
|
|
* @param endPrice
|
|
* @param endPrice
|
|
@@ -160,10 +161,10 @@ public class GoodsLogic {
|
|
|
* @param request
|
|
* @param request
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public IPage<GoodsPackageList> packageList( String keyword, BigDecimal startPrice, BigDecimal endPrice,
|
|
|
|
|
- BigDecimal startShare, BigDecimal endShare,
|
|
|
|
|
- String goodsSortJson, String categoryId, Boolean status,
|
|
|
|
|
- Integer pageNum, Integer pageSize, HttpServletRequest request) {
|
|
|
|
|
|
|
+ public IPage<GoodsPackageList> packageList(String keyword, BigDecimal startPrice, BigDecimal endPrice,
|
|
|
|
|
+ BigDecimal startShare, BigDecimal endShare,
|
|
|
|
|
+ String goodsSortJson, String categoryId, Boolean status,
|
|
|
|
|
+ Integer pageNum, Integer pageSize, HttpServletRequest request) {
|
|
|
|
|
|
|
|
//获取当前登录微信企业微信id
|
|
//获取当前登录微信企业微信id
|
|
|
AdminUserCom adminUser = commonLogic.getAdminUser(request);
|
|
AdminUserCom adminUser = commonLogic.getAdminUser(request);
|
|
@@ -188,6 +189,7 @@ public class GoodsLogic {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 根据类型查询商品
|
|
* 根据类型查询商品
|
|
|
|
|
+ *
|
|
|
* @param categoryIds
|
|
* @param categoryIds
|
|
|
* @param request
|
|
* @param request
|
|
|
* @return
|
|
* @return
|
|
@@ -199,8 +201,8 @@ public class GoodsLogic {
|
|
|
List<String> companyWechatIds = adminUser.getCompanyWechatIds();
|
|
List<String> companyWechatIds = adminUser.getCompanyWechatIds();
|
|
|
|
|
|
|
|
|
|
|
|
|
- IPage<GoodsSpecBean> goodsSpecBeanIPage = customGoodsMapper.pageList(new Page<>(1, -1), null,null, null, null,
|
|
|
|
|
- null, null, null, null, categoryIds, null, null,companyWechatIds);
|
|
|
|
|
|
|
+ IPage<GoodsSpecBean> goodsSpecBeanIPage = customGoodsMapper.pageList(new Page<>(1, -1), null, null, null, null,
|
|
|
|
|
+ null, null, null, null, categoryIds, null, null, companyWechatIds);
|
|
|
//添加规格
|
|
//添加规格
|
|
|
List<GoodsSpecBean> records = goodsSpecBeanIPage.getRecords();
|
|
List<GoodsSpecBean> records = goodsSpecBeanIPage.getRecords();
|
|
|
for (GoodsSpecBean record : records) {
|
|
for (GoodsSpecBean record : records) {
|
|
@@ -210,9 +212,9 @@ public class GoodsLogic {
|
|
|
.list();
|
|
.list();
|
|
|
|
|
|
|
|
List<GoodsSpecVO> goodsSpecVOS = BeanUtil.copyToList(goodsSpecs, GoodsSpecVO.class);
|
|
List<GoodsSpecVO> goodsSpecVOS = BeanUtil.copyToList(goodsSpecs, GoodsSpecVO.class);
|
|
|
- for(GoodsSpecVO goodsSpecVO : goodsSpecVOS){
|
|
|
|
|
|
|
+ for (GoodsSpecVO goodsSpecVO : goodsSpecVOS) {
|
|
|
GoodsMaterial goodsMaterial = goodsMaterialService.getById(goodsSpecVO.getGoodsCode());
|
|
GoodsMaterial goodsMaterial = goodsMaterialService.getById(goodsSpecVO.getGoodsCode());
|
|
|
- if(goodsMaterial != null){
|
|
|
|
|
|
|
+ if (goodsMaterial != null) {
|
|
|
goodsSpecVO.setGoodsMaterialName(goodsMaterial.getGoodsName());
|
|
goodsSpecVO.setGoodsMaterialName(goodsMaterial.getGoodsName());
|
|
|
goodsSpecVO.setGoodsMaterialStock(goodsMaterial.getStockQty());
|
|
goodsSpecVO.setGoodsMaterialStock(goodsMaterial.getStockQty());
|
|
|
goodsSpecVO.setCostAmount(goodsMaterial.getCostAmount());
|
|
goodsSpecVO.setCostAmount(goodsMaterial.getCostAmount());
|
|
@@ -306,6 +308,7 @@ public class GoodsLogic {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 商品详情
|
|
* 商品详情
|
|
|
|
|
+ *
|
|
|
* @param goodsId
|
|
* @param goodsId
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
@@ -317,7 +320,6 @@ public class GoodsLogic {
|
|
|
.list();
|
|
.list();
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
//商品库存
|
|
//商品库存
|
|
|
Integer goodsStock = goodsSpecs.stream().collect(Collectors.summingInt(x -> x.getStockNum()));
|
|
Integer goodsStock = goodsSpecs.stream().collect(Collectors.summingInt(x -> x.getStockNum()));
|
|
|
|
|
|
|
@@ -329,13 +331,13 @@ public class GoodsLogic {
|
|
|
|
|
|
|
|
|
|
|
|
|
List<GoodsSpecVO> goodsSpecVOS = BeanUtil.copyToList(goodsSpecs, GoodsSpecVO.class);
|
|
List<GoodsSpecVO> goodsSpecVOS = BeanUtil.copyToList(goodsSpecs, GoodsSpecVO.class);
|
|
|
- for(GoodsSpecVO goodsSpecVO : goodsSpecVOS){
|
|
|
|
|
|
|
+ for (GoodsSpecVO goodsSpecVO : goodsSpecVOS) {
|
|
|
GoodsMaterial goodsMaterial = goodsMaterialService.getById(goodsSpecVO.getGoodsCode());
|
|
GoodsMaterial goodsMaterial = goodsMaterialService.getById(goodsSpecVO.getGoodsCode());
|
|
|
|
|
|
|
|
List<GoodsMaterialStorage> goodsMaterialStorages = goodsMaterialStorageService.lambdaQuery().eq(GoodsMaterialStorage::getGoodsMaterialId, goodsSpecVO.getGoodsCode())
|
|
List<GoodsMaterialStorage> goodsMaterialStorages = goodsMaterialStorageService.lambdaQuery().eq(GoodsMaterialStorage::getGoodsMaterialId, goodsSpecVO.getGoodsCode())
|
|
|
.list();
|
|
.list();
|
|
|
|
|
|
|
|
- if(goodsMaterial != null){
|
|
|
|
|
|
|
+ if (goodsMaterial != null) {
|
|
|
goodsSpecVO.setGoodsMaterialName(goodsMaterial.getGoodsName());
|
|
goodsSpecVO.setGoodsMaterialName(goodsMaterial.getGoodsName());
|
|
|
goodsSpecVO.setGoodsMaterialStock(goodsMaterial.getStockQty());
|
|
goodsSpecVO.setGoodsMaterialStock(goodsMaterial.getStockQty());
|
|
|
goodsSpecVO.setCostAmount(goodsMaterial.getCostAmount());
|
|
goodsSpecVO.setCostAmount(goodsMaterial.getCostAmount());
|
|
@@ -359,19 +361,19 @@ public class GoodsLogic {
|
|
|
}
|
|
}
|
|
|
//查询商品标签
|
|
//查询商品标签
|
|
|
List<GoodsTagRela> goodsTagRela = goodsTagRelaService.lambdaQuery().eq(GoodsTagRela::getGoodsId, goodsId)
|
|
List<GoodsTagRela> goodsTagRela = goodsTagRelaService.lambdaQuery().eq(GoodsTagRela::getGoodsId, goodsId)
|
|
|
- .eq(GoodsTagRela::getType,1).list();
|
|
|
|
|
- if(goodsTagRela.size() > 0){
|
|
|
|
|
|
|
+ .eq(GoodsTagRela::getType, 1).list();
|
|
|
|
|
+ if (goodsTagRela.size() > 0) {
|
|
|
List<String> tagList = goodsTagRela.stream().map(GoodsTagRela::getGoodsTagName).collect(Collectors.toList());
|
|
List<String> tagList = goodsTagRela.stream().map(GoodsTagRela::getGoodsTagName).collect(Collectors.toList());
|
|
|
goodsBean.setTags(tagList);
|
|
goodsBean.setTags(tagList);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
List<GoodsTagRela> goodsTagRelas = goodsTagRelaService.lambdaQuery().eq(GoodsTagRela::getGoodsId, goodsId)
|
|
List<GoodsTagRela> goodsTagRelas = goodsTagRelaService.lambdaQuery().eq(GoodsTagRela::getGoodsId, goodsId)
|
|
|
- .eq(GoodsTagRela::getType,2).list();
|
|
|
|
|
- if(goodsTagRelas.size() > 0){
|
|
|
|
|
|
|
+ .eq(GoodsTagRela::getType, 2).list();
|
|
|
|
|
+ if (goodsTagRelas.size() > 0) {
|
|
|
List<String> tagList = goodsTagRelas.stream().map(GoodsTagRela::getGoodsTagName).collect(Collectors.toList());
|
|
List<String> tagList = goodsTagRelas.stream().map(GoodsTagRela::getGoodsTagName).collect(Collectors.toList());
|
|
|
goodsBean.setTagsLabel(tagList);
|
|
goodsBean.setTagsLabel(tagList);
|
|
|
}
|
|
}
|
|
|
- if(StringUtils.equals(goodsBean.getGoodsType(),GoodsTypeEnum.PACKAGE.toString())) {
|
|
|
|
|
|
|
+ if (StringUtils.equals(goodsBean.getGoodsType(), GoodsTypeEnum.PACKAGE.toString())) {
|
|
|
//套购商品--指定人员列表
|
|
//套购商品--指定人员列表
|
|
|
goodsBean.setUsers(this.getPackageUseUserList(goodsBean.getGoodsId(), null));
|
|
goodsBean.setUsers(this.getPackageUseUserList(goodsBean.getGoodsId(), null));
|
|
|
}
|
|
}
|
|
@@ -382,26 +384,26 @@ public class GoodsLogic {
|
|
|
/**
|
|
/**
|
|
|
* 套购商品-商品配置列表
|
|
* 套购商品-商品配置列表
|
|
|
*/
|
|
*/
|
|
|
- public List<GoodsPackageBean> popList(String goodsId,Integer type){
|
|
|
|
|
|
|
+ public List<GoodsPackageBean> popList(String goodsId, Integer type) {
|
|
|
//套购商品
|
|
//套购商品
|
|
|
Goods goods = goodsService.getById(goodsId);
|
|
Goods goods = goodsService.getById(goodsId);
|
|
|
- if(!StringUtils.equals(goods.getGoodsType(),GoodsTypeEnum.PACKAGE.toString())){
|
|
|
|
|
|
|
+ if (!StringUtils.equals(goods.getGoodsType(), GoodsTypeEnum.PACKAGE.toString())) {
|
|
|
throw new RemoteServiceException("非套餐商品");
|
|
throw new RemoteServiceException("非套餐商品");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//套购商品--商品配置
|
|
//套购商品--商品配置
|
|
|
List<GoodsPackagePop> list = goodsPackagePopService.lambdaQuery()
|
|
List<GoodsPackagePop> list = goodsPackagePopService.lambdaQuery()
|
|
|
.eq(GoodsPackagePop::getGoodsPackageId, goodsId)
|
|
.eq(GoodsPackagePop::getGoodsPackageId, goodsId)
|
|
|
- .eq(GoodsPackagePop::getType,type).list();
|
|
|
|
|
|
|
+ .eq(GoodsPackagePop::getType, type).list();
|
|
|
|
|
|
|
|
- Map<String,List<GoodsPackagePopBean>> map = new LinkedHashMap<>();
|
|
|
|
|
|
|
+ Map<String, List<GoodsPackagePopBean>> map = new LinkedHashMap<>();
|
|
|
for (GoodsPackagePop bean : list) {
|
|
for (GoodsPackagePop bean : list) {
|
|
|
List<GoodsPackagePopBean> goodsPackagePops = map.get(bean.getGoodsId());
|
|
List<GoodsPackagePopBean> goodsPackagePops = map.get(bean.getGoodsId());
|
|
|
- if(goodsPackagePops == null){
|
|
|
|
|
|
|
+ if (goodsPackagePops == null) {
|
|
|
goodsPackagePops = new ArrayList<>();
|
|
goodsPackagePops = new ArrayList<>();
|
|
|
}
|
|
}
|
|
|
GoodsPackagePopBean newBean = new GoodsPackagePopBean();
|
|
GoodsPackagePopBean newBean = new GoodsPackagePopBean();
|
|
|
- BeanUtils.copyProperties(bean,newBean);
|
|
|
|
|
|
|
+ BeanUtils.copyProperties(bean, newBean);
|
|
|
|
|
|
|
|
GoodsSpec goodsSpec = goodsSpecService.getById(bean.getGoodsSpecId());
|
|
GoodsSpec goodsSpec = goodsSpecService.getById(bean.getGoodsSpecId());
|
|
|
newBean.setSpecName(goodsSpec.getName());
|
|
newBean.setSpecName(goodsSpec.getName());
|
|
@@ -409,11 +411,11 @@ public class GoodsLogic {
|
|
|
newBean.setStock(goodsSpec.getStockNum());
|
|
newBean.setStock(goodsSpec.getStockNum());
|
|
|
|
|
|
|
|
goodsPackagePops.add(newBean);
|
|
goodsPackagePops.add(newBean);
|
|
|
- map.put(bean.getGoodsId(),goodsPackagePops);
|
|
|
|
|
|
|
+ map.put(bean.getGoodsId(), goodsPackagePops);
|
|
|
}
|
|
}
|
|
|
//商品
|
|
//商品
|
|
|
List<GoodsPackageBean> goodsList = new ArrayList<>();
|
|
List<GoodsPackageBean> goodsList = new ArrayList<>();
|
|
|
- for(String gdsId : map.keySet()){
|
|
|
|
|
|
|
+ for (String gdsId : map.keySet()) {
|
|
|
|
|
|
|
|
Goods nGoods = goodsService.getById(gdsId);
|
|
Goods nGoods = goodsService.getById(gdsId);
|
|
|
|
|
|
|
@@ -425,11 +427,10 @@ public class GoodsLogic {
|
|
|
bean.setSortNum(goodsPackagePop.getSortNum());
|
|
bean.setSortNum(goodsPackagePop.getSortNum());
|
|
|
goodsList.add(bean);
|
|
goodsList.add(bean);
|
|
|
}
|
|
}
|
|
|
- return goodsList;
|
|
|
|
|
|
|
+ return goodsList;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 添加商品
|
|
* 添加商品
|
|
|
*
|
|
*
|
|
@@ -437,22 +438,25 @@ public class GoodsLogic {
|
|
|
*/
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void add(GoodsBean goodsBean, HttpServletRequest request) throws RemoteServiceException {
|
|
public void add(GoodsBean goodsBean, HttpServletRequest request) throws RemoteServiceException {
|
|
|
- if (StringUtils.equals(goodsBean.getGoodsType(),GoodsTypeEnum.COMMON.toString())
|
|
|
|
|
|
|
+ if (StringUtils.equals(goodsBean.getGoodsType(), GoodsTypeEnum.COMMON.toString())
|
|
|
&& (goodsBean.getGoodsSpecs() == null || goodsBean.getGoodsSpecs().size() == 0)) {
|
|
&& (goodsBean.getGoodsSpecs() == null || goodsBean.getGoodsSpecs().size() == 0)) {
|
|
|
//如果是规格没有抛出异常
|
|
//如果是规格没有抛出异常
|
|
|
throw new RemoteServiceException("至少要有一个规格!");
|
|
throw new RemoteServiceException("至少要有一个规格!");
|
|
|
}
|
|
}
|
|
|
//设置企业微信id
|
|
//设置企业微信id
|
|
|
AdminUserCom adminUser = commonLogic.getAdminUser(request);
|
|
AdminUserCom adminUser = commonLogic.getAdminUser(request);
|
|
|
|
|
+// if (StringUtils.isBlank(goodsBean.getCompanyWechatId())) {
|
|
|
|
|
+// throw new RemoteServiceException("请选择商户信息");
|
|
|
|
|
+// }
|
|
|
if (StringUtils.isBlank(adminUser.getCompanyWechatId())) {
|
|
if (StringUtils.isBlank(adminUser.getCompanyWechatId())) {
|
|
|
- throw new RemoteServiceException("非租户账号不可操作当前信息");
|
|
|
|
|
|
|
+ throw new RemoteServiceException("非商户账号不可操作当前信息");
|
|
|
}
|
|
}
|
|
|
goodsBean.setCompanyWechatId(adminUser.getCompanyWechatId());
|
|
goodsBean.setCompanyWechatId(adminUser.getCompanyWechatId());
|
|
|
goodsBean.setCompanyName(adminUser.getCompanyName());
|
|
goodsBean.setCompanyName(adminUser.getCompanyName());
|
|
|
|
|
|
|
|
Date creatDate = new Date();
|
|
Date creatDate = new Date();
|
|
|
List<GoodsSpec> goodsSpecList = goodsBean.getGoodsSpecs();
|
|
List<GoodsSpec> goodsSpecList = goodsBean.getGoodsSpecs();
|
|
|
- if(CollectionUtils.isNotEmpty(goodsSpecList)) {
|
|
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(goodsSpecList)) {
|
|
|
Collections.sort(goodsSpecList, (o1, o2) -> o1.getPrice().compareTo(o2.getPrice()));
|
|
Collections.sort(goodsSpecList, (o1, o2) -> o1.getPrice().compareTo(o2.getPrice()));
|
|
|
goodsBean.setGoodsPrice(goodsSpecList.get(0).getPrice());
|
|
goodsBean.setGoodsPrice(goodsSpecList.get(0).getPrice());
|
|
|
goodsBean.setOrgGoodsPrice(goodsSpecList.get(0).getOrgPrice());
|
|
goodsBean.setOrgGoodsPrice(goodsSpecList.get(0).getOrgPrice());
|
|
@@ -460,13 +464,13 @@ public class GoodsLogic {
|
|
|
goodsBean.setCreateTime(creatDate);
|
|
goodsBean.setCreateTime(creatDate);
|
|
|
goodsService.save(goodsBean);
|
|
goodsService.save(goodsBean);
|
|
|
|
|
|
|
|
- if(CollectionUtils.isNotEmpty(goodsBean.getGoodsSpecs())) {
|
|
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(goodsBean.getGoodsSpecs())) {
|
|
|
|
|
|
|
|
List<GoodsSpec> goodsSpecs = goodsBean.getGoodsSpecs();
|
|
List<GoodsSpec> goodsSpecs = goodsBean.getGoodsSpecs();
|
|
|
- for(GoodsSpec goodsSpec:goodsSpecs){
|
|
|
|
|
|
|
+ for (GoodsSpec goodsSpec : goodsSpecs) {
|
|
|
|
|
|
|
|
GoodsMaterial goodsMaterial = goodsMaterialService.getById(goodsSpec.getGoodsCode());
|
|
GoodsMaterial goodsMaterial = goodsMaterialService.getById(goodsSpec.getGoodsCode());
|
|
|
- if(goodsMaterial != null){
|
|
|
|
|
|
|
+ if (goodsMaterial != null) {
|
|
|
goodsSpec.setSpecValue(goodsMaterial.getSpecsName());
|
|
goodsSpec.setSpecValue(goodsMaterial.getSpecsName());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -499,7 +503,7 @@ public class GoodsLogic {
|
|
|
//查询物料信息
|
|
//查询物料信息
|
|
|
fucaiLogic.getWuliao(goodsSpecList);
|
|
fucaiLogic.getWuliao(goodsSpecList);
|
|
|
//批量保存商品规格
|
|
//批量保存商品规格
|
|
|
- if(CollectionUtils.isNotEmpty(goodsSpecList))
|
|
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(goodsSpecList))
|
|
|
goodsSpecService.saveBatch(goodsSpecList);
|
|
goodsSpecService.saveBatch(goodsSpecList);
|
|
|
|
|
|
|
|
//保存轮播图
|
|
//保存轮播图
|
|
@@ -508,8 +512,8 @@ public class GoodsLogic {
|
|
|
commonLogic.bindFile(goodsBean.getGoodsId(), Constant.Img.GOODS_IMG, imageIdList);
|
|
commonLogic.bindFile(goodsBean.getGoodsId(), Constant.Img.GOODS_IMG, imageIdList);
|
|
|
}
|
|
}
|
|
|
//save tags
|
|
//save tags
|
|
|
- this.saveGoodsTagRela(goodsBean.getTags(),goodsBean.getGoodsId(),1);
|
|
|
|
|
- this.saveGoodsTagRela(goodsBean.getTagsLabel(),goodsBean.getGoodsId(),2);
|
|
|
|
|
|
|
+ this.saveGoodsTagRela(goodsBean.getTags(), goodsBean.getGoodsId(), 1);
|
|
|
|
|
+ this.saveGoodsTagRela(goodsBean.getTagsLabel(), goodsBean.getGoodsId(), 2);
|
|
|
|
|
|
|
|
//套购商品处理
|
|
//套购商品处理
|
|
|
//this.saveGoodsPackage(goodsBean);
|
|
//this.saveGoodsPackage(goodsBean);
|
|
@@ -518,15 +522,15 @@ public class GoodsLogic {
|
|
|
/**
|
|
/**
|
|
|
* 保存标签
|
|
* 保存标签
|
|
|
*/
|
|
*/
|
|
|
- public void saveGoodsTagRela(List<String> tags,String goodsId,Integer type){
|
|
|
|
|
|
|
+ public void saveGoodsTagRela(List<String> tags, String goodsId, Integer type) {
|
|
|
|
|
|
|
|
- if(CollectionUtils.isEmpty(tags)){
|
|
|
|
|
- goodsTagRelaService.lambdaUpdate().eq(GoodsTagRela::getGoodsId,goodsId).eq(GoodsTagRela::getType,type).remove();
|
|
|
|
|
|
|
+ if (CollectionUtils.isEmpty(tags)) {
|
|
|
|
|
+ goodsTagRelaService.lambdaUpdate().eq(GoodsTagRela::getGoodsId, goodsId).eq(GoodsTagRela::getType, type).remove();
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
//先删后加
|
|
//先删后加
|
|
|
- goodsTagRelaService.lambdaUpdate().eq(GoodsTagRela::getGoodsId,goodsId).eq(GoodsTagRela::getType,type).remove();
|
|
|
|
|
- for(String tag:tags){
|
|
|
|
|
|
|
+ goodsTagRelaService.lambdaUpdate().eq(GoodsTagRela::getGoodsId, goodsId).eq(GoodsTagRela::getType, type).remove();
|
|
|
|
|
+ for (String tag : tags) {
|
|
|
GoodsTagRela goodsTagRela = new GoodsTagRela();
|
|
GoodsTagRela goodsTagRela = new GoodsTagRela();
|
|
|
goodsTagRela.setGoodsTagName(tag);
|
|
goodsTagRela.setGoodsTagName(tag);
|
|
|
goodsTagRela.setCreateTime(new Date());
|
|
goodsTagRela.setCreateTime(new Date());
|
|
@@ -539,16 +543,17 @@ public class GoodsLogic {
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 限制最大分账
|
|
|
|
|
|
|
+ * 限制最大分账
|
|
|
|
|
+ *
|
|
|
* @param price
|
|
* @param price
|
|
|
* @param shareAmount
|
|
* @param shareAmount
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
private BigDecimal limitShareAmount(BigDecimal price, BigDecimal shareAmount) {
|
|
private BigDecimal limitShareAmount(BigDecimal price, BigDecimal shareAmount) {
|
|
|
- if(price == null){
|
|
|
|
|
|
|
+ if (price == null) {
|
|
|
throw new RemoteServiceException("销售价不能为空");
|
|
throw new RemoteServiceException("销售价不能为空");
|
|
|
}
|
|
}
|
|
|
- if(shareAmount == null){
|
|
|
|
|
|
|
+ if (shareAmount == null) {
|
|
|
throw new RemoteServiceException("佣金或分销金额不能为空");
|
|
throw new RemoteServiceException("佣金或分销金额不能为空");
|
|
|
}
|
|
}
|
|
|
return shareAmount;
|
|
return shareAmount;
|
|
@@ -588,7 +593,7 @@ public class GoodsLogic {
|
|
|
public void update(GoodsBean goodsBean, HttpServletRequest request) throws RemoteServiceException {
|
|
public void update(GoodsBean goodsBean, HttpServletRequest request) throws RemoteServiceException {
|
|
|
|
|
|
|
|
//检查是否存在秒杀活动
|
|
//检查是否存在秒杀活动
|
|
|
- if (StringUtils.equals(goodsBean.getGoodsType(),GoodsTypeEnum.COMMON.toString())
|
|
|
|
|
|
|
+ if (StringUtils.equals(goodsBean.getGoodsType(), GoodsTypeEnum.COMMON.toString())
|
|
|
&& (goodsBean.getGoodsSpecs() == null || goodsBean.getGoodsSpecs().size() == 0)) {
|
|
&& (goodsBean.getGoodsSpecs() == null || goodsBean.getGoodsSpecs().size() == 0)) {
|
|
|
throw new RemoteServiceException("至少要有一个规格!");
|
|
throw new RemoteServiceException("至少要有一个规格!");
|
|
|
}
|
|
}
|
|
@@ -602,10 +607,9 @@ public class GoodsLogic {
|
|
|
goodsBean.setCompanyName(adminUser.getCompanyName());
|
|
goodsBean.setCompanyName(adminUser.getCompanyName());
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
List<GoodsSpec> notRemoveList = new ArrayList<>();
|
|
List<GoodsSpec> notRemoveList = new ArrayList<>();
|
|
|
//查找未删除的规格
|
|
//查找未删除的规格
|
|
|
- if(CollectionUtils.isNotEmpty(goodsBean.getGoodsSpecs())) {
|
|
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(goodsBean.getGoodsSpecs())) {
|
|
|
notRemoveList = goodsBean.getGoodsSpecs().stream()
|
|
notRemoveList = goodsBean.getGoodsSpecs().stream()
|
|
|
.filter(goodsSpec -> StringUtils.isNotBlank(goodsSpec.getGoodsSpecId()))
|
|
.filter(goodsSpec -> StringUtils.isNotBlank(goodsSpec.getGoodsSpecId()))
|
|
|
.map(goodsSpec -> goodsSpec.setGoodsId(goodsBean.getGoodsId())
|
|
.map(goodsSpec -> goodsSpec.setGoodsId(goodsBean.getGoodsId())
|
|
@@ -624,7 +628,7 @@ public class GoodsLogic {
|
|
|
|
|
|
|
|
//更新主表信息
|
|
//更新主表信息
|
|
|
List<GoodsSpec> goodsSpecList = goodsBean.getGoodsSpecs();
|
|
List<GoodsSpec> goodsSpecList = goodsBean.getGoodsSpecs();
|
|
|
- if(CollectionUtils.isNotEmpty(goodsSpecList)) {
|
|
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(goodsSpecList)) {
|
|
|
Collections.sort(goodsSpecList, (o1, o2) -> o1.getPrice().compareTo(o2.getPrice()));
|
|
Collections.sort(goodsSpecList, (o1, o2) -> o1.getPrice().compareTo(o2.getPrice()));
|
|
|
goodsBean.setGoodsPrice(goodsSpecList.get(0).getPrice());
|
|
goodsBean.setGoodsPrice(goodsSpecList.get(0).getPrice());
|
|
|
goodsBean.setOrgGoodsPrice(goodsSpecList.get(0).getOrgPrice());
|
|
goodsBean.setOrgGoodsPrice(goodsSpecList.get(0).getOrgPrice());
|
|
@@ -654,13 +658,13 @@ public class GoodsLogic {
|
|
|
goodsSpecService.updateBatchById(notRemoveList);
|
|
goodsSpecService.updateBatchById(notRemoveList);
|
|
|
}
|
|
}
|
|
|
//查找规格id为空的 添加到从表
|
|
//查找规格id为空的 添加到从表
|
|
|
- if(CollectionUtils.isNotEmpty(goodsBean.getGoodsSpecs())) {
|
|
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(goodsBean.getGoodsSpecs())) {
|
|
|
|
|
|
|
|
List<GoodsSpec> addGoodsSpecList = goodsBean.getGoodsSpecs();
|
|
List<GoodsSpec> addGoodsSpecList = goodsBean.getGoodsSpecs();
|
|
|
- for(GoodsSpec goodsSpec:addGoodsSpecList){
|
|
|
|
|
|
|
+ for (GoodsSpec goodsSpec : addGoodsSpecList) {
|
|
|
|
|
|
|
|
GoodsMaterial goodsMaterial = goodsMaterialService.getById(goodsSpec.getGoodsCode());
|
|
GoodsMaterial goodsMaterial = goodsMaterialService.getById(goodsSpec.getGoodsCode());
|
|
|
- if(goodsMaterial != null){
|
|
|
|
|
|
|
+ if (goodsMaterial != null) {
|
|
|
goodsSpec.setSpecValue(goodsMaterial.getSpecsName());
|
|
goodsSpec.setSpecValue(goodsMaterial.getSpecsName());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -682,8 +686,8 @@ public class GoodsLogic {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
//save tags
|
|
//save tags
|
|
|
- this.saveGoodsTagRela(goodsBean.getTags(),goodsBean.getGoodsId(),1);
|
|
|
|
|
- this.saveGoodsTagRela(goodsBean.getTagsLabel(),goodsBean.getGoodsId(),2);
|
|
|
|
|
|
|
+ this.saveGoodsTagRela(goodsBean.getTags(), goodsBean.getGoodsId(), 1);
|
|
|
|
|
+ this.saveGoodsTagRela(goodsBean.getTagsLabel(), goodsBean.getGoodsId(), 2);
|
|
|
|
|
|
|
|
//套购商品处理
|
|
//套购商品处理
|
|
|
//this.saveGoodsPackage(goodsBean);
|
|
//this.saveGoodsPackage(goodsBean);
|
|
@@ -783,6 +787,7 @@ public class GoodsLogic {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 商品上下架
|
|
* 商品上下架
|
|
|
|
|
+ *
|
|
|
* @param goodsIdList
|
|
* @param goodsIdList
|
|
|
* @param action
|
|
* @param action
|
|
|
*/
|
|
*/
|
|
@@ -798,6 +803,7 @@ public class GoodsLogic {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 商品模板
|
|
* 商品模板
|
|
|
|
|
+ *
|
|
|
* @param goodsTemplateBean
|
|
* @param goodsTemplateBean
|
|
|
* @param request
|
|
* @param request
|
|
|
*/
|
|
*/
|
|
@@ -905,9 +911,9 @@ public class GoodsLogic {
|
|
|
/**
|
|
/**
|
|
|
* 用 商品规格的 分销金额 覆盖其 为null的 内部分销金额
|
|
* 用 商品规格的 分销金额 覆盖其 为null的 内部分销金额
|
|
|
*/
|
|
*/
|
|
|
- public void syncGoodsSpecInnerShareMsg(HttpServletRequest request){
|
|
|
|
|
|
|
+ public void syncGoodsSpecInnerShareMsg(HttpServletRequest request) {
|
|
|
String companyWechatId = commonLogic.getAdminUser(request).getCompanyWechatId();
|
|
String companyWechatId = commonLogic.getAdminUser(request).getCompanyWechatId();
|
|
|
- if(StringUtils.isBlank(companyWechatId)){
|
|
|
|
|
|
|
+ if (StringUtils.isBlank(companyWechatId)) {
|
|
|
throw new RemoteServiceException("运营账号暂无权限操作");
|
|
throw new RemoteServiceException("运营账号暂无权限操作");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -919,23 +925,23 @@ public class GoodsLogic {
|
|
|
/**
|
|
/**
|
|
|
* 修改商品水印和有效时间
|
|
* 修改商品水印和有效时间
|
|
|
*/
|
|
*/
|
|
|
- public void updateGoodsLogo(List<String> goodsIds,String logo,String logoStartTime,String logoEndTime) throws ParseException {
|
|
|
|
|
|
|
+ public void updateGoodsLogo(List<String> goodsIds, String logo, String logoStartTime, String logoEndTime) throws ParseException {
|
|
|
goodsService.lambdaUpdate()
|
|
goodsService.lambdaUpdate()
|
|
|
- .set(Goods::getLogo,logo)
|
|
|
|
|
- .set(Goods::getLogoStartTime,DateUtils.parseDate(logoStartTime))
|
|
|
|
|
- .set(Goods::getLogoEndTime,DateUtils.parseDate(logoEndTime))
|
|
|
|
|
- .in(Goods::getGoodsId,goodsIds)
|
|
|
|
|
|
|
+ .set(Goods::getLogo, logo)
|
|
|
|
|
+ .set(Goods::getLogoStartTime, DateUtils.parseDate(logoStartTime))
|
|
|
|
|
+ .set(Goods::getLogoEndTime, DateUtils.parseDate(logoEndTime))
|
|
|
|
|
+ .in(Goods::getGoodsId, goodsIds)
|
|
|
.update();
|
|
.update();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 套购商品指定人员列表
|
|
|
|
|
|
|
+ * 套购商品指定人员列表
|
|
|
*/
|
|
*/
|
|
|
- public List<User> getPackageUseUserList(String goodsId,String mobile){
|
|
|
|
|
|
|
+ public List<User> getPackageUseUserList(String goodsId, String mobile) {
|
|
|
List<GoodsPackageUserRela> list = goodsPackageUserRelaService.lambdaQuery()
|
|
List<GoodsPackageUserRela> list = goodsPackageUserRelaService.lambdaQuery()
|
|
|
.eq(GoodsPackageUserRela::getGoodsId, goodsId)
|
|
.eq(GoodsPackageUserRela::getGoodsId, goodsId)
|
|
|
.like(StringUtils.isNotBlank(mobile), GoodsPackageUserRela::getMobile, mobile).list();
|
|
.like(StringUtils.isNotBlank(mobile), GoodsPackageUserRela::getMobile, mobile).list();
|
|
|
- if(CollectionUtils.isEmpty(list)){
|
|
|
|
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
return new ArrayList<>();
|
|
return new ArrayList<>();
|
|
|
}
|
|
}
|
|
|
List<String> userIds = list.stream().map(GoodsPackageUserRela::getUserId).collect(Collectors.toList());
|
|
List<String> userIds = list.stream().map(GoodsPackageUserRela::getUserId).collect(Collectors.toList());
|
|
@@ -946,32 +952,32 @@ public class GoodsLogic {
|
|
|
/**
|
|
/**
|
|
|
* 套购商品-导入指定人员
|
|
* 套购商品-导入指定人员
|
|
|
*/
|
|
*/
|
|
|
- public List<User> importPackageUser(List<Object> list){
|
|
|
|
|
- if(CollectionUtils.isEmpty(list)){
|
|
|
|
|
|
|
+ public List<User> importPackageUser(List<Object> list) {
|
|
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
return new ArrayList<>();
|
|
return new ArrayList<>();
|
|
|
}
|
|
}
|
|
|
List<String> mobiles = new ArrayList<>();
|
|
List<String> mobiles = new ArrayList<>();
|
|
|
- for(Object o : list){
|
|
|
|
|
|
|
+ for (Object o : list) {
|
|
|
List<Object> row = (List<Object>) o;
|
|
List<Object> row = (List<Object>) o;
|
|
|
- mobiles.add((String)row.get(1));
|
|
|
|
|
|
|
+ mobiles.add((String) row.get(1));
|
|
|
}
|
|
}
|
|
|
List<User> users = userLogic.getByMobile(mobiles);
|
|
List<User> users = userLogic.getByMobile(mobiles);
|
|
|
return users;
|
|
return users;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public List<Goods> getById(List<String> goodsIds){
|
|
|
|
|
|
|
+ public List<Goods> getById(List<String> goodsIds) {
|
|
|
List<Goods> goodsList = goodsService.lambdaQuery().in(Goods::getGoodsId, goodsIds).list();
|
|
List<Goods> goodsList = goodsService.lambdaQuery().in(Goods::getGoodsId, goodsIds).list();
|
|
|
return goodsList;
|
|
return goodsList;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public List<GoodsSpec> getSpec(List<String> goodsIds){
|
|
|
|
|
|
|
+ public List<GoodsSpec> getSpec(List<String> goodsIds) {
|
|
|
List<GoodsSpec> goodsSpecs = goodsSpecService.lambdaQuery().in(GoodsSpec::getGoodsId, goodsIds).list();
|
|
List<GoodsSpec> goodsSpecs = goodsSpecService.lambdaQuery().in(GoodsSpec::getGoodsId, goodsIds).list();
|
|
|
return goodsSpecs;
|
|
return goodsSpecs;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void batchUp(List<String> goodsIds, String isTrade) {
|
|
public void batchUp(List<String> goodsIds, String isTrade) {
|
|
|
goodsService.lambdaUpdate()
|
|
goodsService.lambdaUpdate()
|
|
|
- .in(Goods::getGoodsId,goodsIds)
|
|
|
|
|
- .set(Goods::getIsTrade,isTrade).update();
|
|
|
|
|
|
|
+ .in(Goods::getGoodsId, goodsIds)
|
|
|
|
|
+ .set(Goods::getIsTrade, isTrade).update();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|