|
|
@@ -1,6 +1,8 @@
|
|
|
package com.gree.mall.manager.logic.goods;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
@@ -19,6 +21,7 @@ import com.gree.mall.manager.logic.user.UserLogic;
|
|
|
import com.gree.mall.manager.plus.entity.*;
|
|
|
import com.gree.mall.manager.plus.service.*;
|
|
|
import com.gree.mall.manager.utils.DateUtils;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringEscapeUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
@@ -32,34 +35,27 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.ParseException;
|
|
|
import java.util.*;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Slf4j
|
|
|
@Component
|
|
|
+@RequiredArgsConstructor
|
|
|
public class GoodsLogic {
|
|
|
- @Resource
|
|
|
- CommonLogic commonLogic;
|
|
|
-
|
|
|
- @Resource
|
|
|
- CustomGoodsMapper customGoodsMapper;
|
|
|
- @Resource
|
|
|
- GoodsService goodsService;
|
|
|
- @Resource
|
|
|
- GoodsSpecService goodsSpecService;
|
|
|
- @Autowired
|
|
|
- GoodsTagRelaService goodsTagRelaService;
|
|
|
- @Autowired
|
|
|
- private CarouselMapService carouselMapService;
|
|
|
- @Autowired
|
|
|
- private GoodsTemplateService goodsTemplateService;
|
|
|
- @Autowired
|
|
|
- private CommonFileService commonFileService;
|
|
|
- @Autowired
|
|
|
- GoodsMaterialService goodsMaterialService;
|
|
|
- @Autowired
|
|
|
- UserLogic userLogic;
|
|
|
- @Autowired
|
|
|
- GoodsMaterialStorageService goodsMaterialStorageService;
|
|
|
+
|
|
|
+ private final CommonLogic commonLogic;
|
|
|
+ private final CustomGoodsMapper customGoodsMapper;
|
|
|
+ private final GoodsService goodsService;
|
|
|
+ private final GoodsDetailService goodsDetailService;
|
|
|
+ private final GoodsSpecService goodsSpecService;
|
|
|
+ private final GoodsCategoryService goodsCategoryService;
|
|
|
+ private final GoodsTagRelaService goodsTagRelaService;
|
|
|
+ private final CarouselMapService carouselMapService;
|
|
|
+ private final GoodsTemplateService goodsTemplateService;
|
|
|
+ private final CommonFileService commonFileService;
|
|
|
+ private final GoodsMaterialService goodsMaterialService;
|
|
|
+ private final UserLogic userLogic;
|
|
|
+ private final GoodsMaterialStorageService goodsMaterialStorageService;
|
|
|
|
|
|
/**
|
|
|
* 商品列表
|
|
|
@@ -76,9 +72,9 @@ public class GoodsLogic {
|
|
|
* @return
|
|
|
*/
|
|
|
public IPage<GoodsSpecBean> page(String flag, String keyword, BigDecimal startPrice, BigDecimal endPrice,
|
|
|
- String goodsSortJson, String categoryId, Boolean status, List<String> goodsTypes,
|
|
|
+ String goodsSortJson, String categoryId, Boolean status,
|
|
|
Integer pageNum, Integer pageSize, HttpServletRequest request) {
|
|
|
-
|
|
|
+ System.out.println("开始" + DateUtil.formatDateTime(DateUtil.date()));
|
|
|
//获取当前登录微信企业微信id
|
|
|
AdminUserCom adminUser = commonLogic.getAdminUser(request);
|
|
|
List<String> companyWechatIds = adminUser.getCompanyWechatIds();
|
|
|
@@ -92,14 +88,10 @@ public class GoodsLogic {
|
|
|
if (StringUtils.isNotBlank(categoryId)) {
|
|
|
categoryIds.add(categoryId);
|
|
|
}
|
|
|
- if (CollectionUtils.isEmpty(goodsTypes)) {
|
|
|
- goodsTypes = new ArrayList<>();
|
|
|
- goodsTypes.add(GoodsTypeEnum.COMMON.toString());
|
|
|
- }
|
|
|
|
|
|
- IPage<GoodsSpecBean> goodsSpecBeanIPage = customGoodsMapper.pageList(new Page<>(pageNum, pageSize), flag, keyword, startPrice,
|
|
|
- endPrice, sortStr, categoryIds, status, goodsTypes, companyWechatIds);
|
|
|
|
|
|
+ IPage<GoodsSpecBean> goodsSpecBeanIPage = customGoodsMapper.pageList(new Page<>(pageNum, pageSize), flag, keyword, startPrice,
|
|
|
+ endPrice, sortStr, categoryIds, status, companyWechatIds);
|
|
|
//商品规格
|
|
|
List<GoodsSpecBean> records = new ArrayList<>();
|
|
|
for (GoodsSpecBean goodsSpecBean : goodsSpecBeanIPage.getRecords()) {
|
|
|
@@ -143,7 +135,7 @@ public class GoodsLogic {
|
|
|
|
|
|
|
|
|
IPage<GoodsSpecBean> goodsSpecBeanIPage = customGoodsMapper.pageList(new Page<>(1, -1), null, null, null, null,
|
|
|
- null, categoryIds, null, null, companyWechatIds);
|
|
|
+ null, categoryIds, null, companyWechatIds);
|
|
|
//添加规格
|
|
|
List<GoodsSpecBean> records = goodsSpecBeanIPage.getRecords();
|
|
|
for (GoodsSpecBean record : records) {
|
|
|
@@ -217,12 +209,12 @@ public class GoodsLogic {
|
|
|
*/
|
|
|
public GoodsSpecBean detail(String goodsId) throws RemoteServiceException {
|
|
|
Goods goods = goodsService.getById(goodsId);
|
|
|
+ final GoodsDetail goodsDetail = goodsDetailService.getById(goodsId);
|
|
|
List<GoodsSpec> goodsSpecs = goodsSpecService.lambdaQuery()
|
|
|
.eq(GoodsSpec::getGoodsId, goodsId)
|
|
|
.eq(GoodsSpec::getDel, false)
|
|
|
.list();
|
|
|
|
|
|
-
|
|
|
//商品库存
|
|
|
Integer goodsStock = goodsSpecs.stream().collect(Collectors.summingInt(x -> x.getStockNum()));
|
|
|
|
|
|
@@ -232,6 +224,11 @@ public class GoodsLogic {
|
|
|
}
|
|
|
BeanUtils.copyProperties(goods, goodsBean);
|
|
|
|
|
|
+ if (Objects.nonNull(goodsDetail)) {
|
|
|
+ goodsBean.setContent(goodsDetail.getContent());
|
|
|
+ goodsBean.setImgUrl(goodsDetail.getImgUrl());
|
|
|
+ goodsBean.setVedio(goodsDetail.getVedio());
|
|
|
+ }
|
|
|
|
|
|
List<GoodsSpecVO> goodsSpecVOS = BeanUtil.copyToList(goodsSpecs, GoodsSpecVO.class);
|
|
|
for (GoodsSpecVO goodsSpecVO : goodsSpecVOS) {
|
|
|
@@ -331,6 +328,13 @@ public class GoodsLogic {
|
|
|
|
|
|
goodsService.save(goodsBean);
|
|
|
|
|
|
+ GoodsDetail goodsDetail = new GoodsDetail();
|
|
|
+ goodsDetail.setGoodsId(goodsBean.getGoodsId())
|
|
|
+ .setContent(goodsBean.getContent())
|
|
|
+ .setImgUrl(goodsBean.getImgUrl())
|
|
|
+ .setVedio(goodsBean.getVedio())
|
|
|
+ .insert();
|
|
|
+
|
|
|
if (StringUtils.isNotBlank(goodsBean.getTemplateId())) {
|
|
|
GoodsTemplate goodsTemplate = new GoodsTemplate();
|
|
|
goodsTemplate.setGoodsId(goodsBean.getGoodsId());
|
|
|
@@ -427,6 +431,17 @@ public class GoodsLogic {
|
|
|
}
|
|
|
goodsService.updateById(goodsBean);
|
|
|
|
|
|
+ GoodsDetail goodsDetail = goodsDetailService.getById(goodsBean.getGoodsId());
|
|
|
+ if (Objects.isNull(goodsDetail)) {
|
|
|
+ goodsDetail = new GoodsDetail();
|
|
|
+ }
|
|
|
+ goodsDetail.setGoodsId(goodsBean.getGoodsId())
|
|
|
+ .setContent(goodsBean.getContent())
|
|
|
+ .setImgUrl(goodsBean.getImgUrl())
|
|
|
+ .setVedio(goodsBean.getVedio())
|
|
|
+ .insertOrUpdate();
|
|
|
+
|
|
|
+
|
|
|
//未删除的规格id
|
|
|
List<String> goodsSpecIds = notRemoveList.stream().map(GoodsSpec::getGoodsSpecId).collect(Collectors.toList());
|
|
|
|