|
@@ -1,6 +1,7 @@
|
|
|
package com.yiqi.core.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -10,6 +11,7 @@ import com.yiqi.common.enums.SourceType;
|
|
|
import com.yiqi.common.enums.StatusType;
|
|
|
import com.yiqi.common.utils.DateUtils;
|
|
|
import com.yiqi.common.utils.SecurityUtils;
|
|
|
+import com.yiqi.common.utils.StringUtils;
|
|
|
import com.yiqi.core.domain.GoodsInfo;
|
|
|
import com.yiqi.core.domain.GoodsSku;
|
|
|
import com.yiqi.core.domain.GoodsSkuSpec;
|
|
@@ -143,6 +145,13 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
|
|
if (CollUtil.isEmpty(SkuQueryVOS)) {
|
|
|
return SkuQueryVOS;
|
|
|
}
|
|
|
+ // 设置规格值
|
|
|
+ SkuQueryVOS.forEach(goodsSku_ -> {
|
|
|
+ //values字符串数组转List
|
|
|
+ if (StringUtils.isNotBlank(goodsSku_.getSpecs())) {
|
|
|
+ goodsSku_.setSpecValLists(JSONUtil.toList(JSONUtil.parseArray(goodsSku_.getSpecs()), String.class));
|
|
|
+ }
|
|
|
+ });
|
|
|
Set<Long> collect = SkuQueryVOS.stream().map(GoodsSkuQueryVO::getId).collect(Collectors.toSet());
|
|
|
List<GoodsSkuSpec> skuStoreList = goodsSkuSpecMapper.selectList(
|
|
|
new QueryWrapper<GoodsSkuSpec>().lambda()
|
|
@@ -254,40 +263,69 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
|
|
@Override
|
|
|
public int updateGoodsSku(GoodsSkuAddVO goodsSkuAddVO) {
|
|
|
SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
- GoodsSku goodsSku = new GoodsSku();
|
|
|
- BeanUtils.copyProperties(goodsSkuAddVO, goodsSku);
|
|
|
- goodsSku.setUpdateById(user.getUserId());
|
|
|
- goodsSku.setUpdateTime(DateUtils.getNowDate());
|
|
|
- goodsSku.setUpdateBy(user.getUserName());
|
|
|
- goodsSku.setSourceType("");
|
|
|
- int i = baseMapper.updateById(goodsSku);
|
|
|
-
|
|
|
- // 软删除 原来的规格
|
|
|
- QueryWrapper<GoodsSkuSpec> qw = new QueryWrapper<>();
|
|
|
- qw.eq("goods_sku_id", goodsSku.getId());
|
|
|
- goodsSkuSpecMapper.delete(qw);
|
|
|
- // 新增新的规格
|
|
|
- this.insertSpecBySku(goodsSkuAddVO, goodsSku);
|
|
|
-
|
|
|
- // 更新物料门店
|
|
|
- LambdaQueryWrapper<GoodsSkuStore> query = new QueryWrapper<GoodsSkuStore>().lambda()
|
|
|
- .eq(GoodsSkuStore::getGoodsSkuId, goodsSku.getId())
|
|
|
- .eq(GoodsSkuStore::getSourceType, user.getUserType());
|
|
|
- if ("01".equals(user.getUserType())) {
|
|
|
- query.eq(GoodsSkuStore::getTargetId, user.getFactoryId());
|
|
|
+ // 总部
|
|
|
+ if (SourceType.MANAGER.getCode().equals(user.getUserType())) {
|
|
|
+ GoodsSku goodsSku = new GoodsSku();
|
|
|
+ goodsSku.setId(goodsSkuAddVO.getId());
|
|
|
+ if (goodsSkuAddVO.getStatus() != null) {
|
|
|
+ goodsSku.setStatus(goodsSkuAddVO.getStatus());
|
|
|
+ }
|
|
|
+ if (goodsSkuAddVO.getSalePrice() != null) {
|
|
|
+ goodsSku.setSalePrice(goodsSkuAddVO.getSalePrice());
|
|
|
+ }
|
|
|
+ if (goodsSkuAddVO.getWholesalePrice() != null) {
|
|
|
+ goodsSku.setWholesalePrice(goodsSkuAddVO.getWholesalePrice());
|
|
|
+ }
|
|
|
+ if (goodsSkuAddVO.getPurchasePrice() != null) {
|
|
|
+ goodsSku.setPurchasePrice(goodsSkuAddVO.getPurchasePrice());
|
|
|
+ }
|
|
|
+ if (goodsSkuAddVO.getStock() != null) {
|
|
|
+ goodsSku.setStock(goodsSkuAddVO.getStock());
|
|
|
+ }
|
|
|
+ goodsSku.buildUpdateData();
|
|
|
+ baseMapper.updateById(goodsSku);
|
|
|
}
|
|
|
- if ("02".equals(user.getUserType())) {
|
|
|
- query.eq(GoodsSkuStore::getTargetId, user.getStoreId());
|
|
|
+ // 工厂
|
|
|
+ if (SourceType.FACTORY.getCode().equals(user.getUserType())) {
|
|
|
+ GoodsSkuStore goodsSkuStore = goodsSkuStoreService.getSkuStoreBySkuIdAndOrgId(goodsSkuAddVO.getId(), SourceType.FACTORY.getCode(), user.getFactoryId());
|
|
|
+ if (goodsSkuAddVO.getStatus() != null) {
|
|
|
+ goodsSkuStore.setStatus(goodsSkuAddVO.getStatus());
|
|
|
+ }
|
|
|
+ if (goodsSkuAddVO.getSalePrice() != null) {
|
|
|
+ goodsSkuStore.setSalePrice(goodsSkuAddVO.getSalePrice());
|
|
|
+ }
|
|
|
+ if (goodsSkuAddVO.getWholesalePrice() != null) {
|
|
|
+ goodsSkuStore.setWholesalePrice(goodsSkuAddVO.getWholesalePrice());
|
|
|
+ }
|
|
|
+ if (goodsSkuAddVO.getPurchasePrice() != null) {
|
|
|
+ goodsSkuStore.setPurchasePrice(goodsSkuAddVO.getPurchasePrice());
|
|
|
+ }
|
|
|
+ if (goodsSkuAddVO.getStock() != null) {
|
|
|
+ goodsSkuStore.setStock(goodsSkuAddVO.getStock());
|
|
|
+ }
|
|
|
+ goodsSkuStoreService.updateById(goodsSkuStore);
|
|
|
}
|
|
|
- GoodsSkuStore skuStore = goodsSkuStoreMapper.selectOne(query);
|
|
|
- skuStore.setSalePrice(goodsSkuAddVO.getSalePrice());
|
|
|
- skuStore.setPurchasePrice(goodsSkuAddVO.getPurchasePrice());
|
|
|
- skuStore.setWholesalePrice(goodsSkuAddVO.getWholesalePrice());
|
|
|
- skuStore.setUpdateById(user.getUserId());
|
|
|
- skuStore.setUpdateTime(DateUtils.getNowDate());
|
|
|
- skuStore.setUpdateBy(user.getUserName());
|
|
|
- goodsSkuStoreMapper.updateById(skuStore);
|
|
|
- return i;
|
|
|
+ // 门店
|
|
|
+ if (SourceType.STORE.getCode().equals(user.getUserType())) {
|
|
|
+ GoodsSkuStore goodsSkuStore = goodsSkuStoreService.getSkuStoreBySkuIdAndOrgId(goodsSkuAddVO.getId(), SourceType.STORE.getCode(), user.getStoreId());
|
|
|
+ if (goodsSkuAddVO.getStatus() != null) {
|
|
|
+ goodsSkuStore.setStatus(goodsSkuAddVO.getStatus());
|
|
|
+ }
|
|
|
+ if (goodsSkuAddVO.getSalePrice() != null) {
|
|
|
+ goodsSkuStore.setSalePrice(goodsSkuAddVO.getSalePrice());
|
|
|
+ }
|
|
|
+ if (goodsSkuAddVO.getWholesalePrice() != null) {
|
|
|
+ goodsSkuStore.setWholesalePrice(goodsSkuAddVO.getWholesalePrice());
|
|
|
+ }
|
|
|
+ if (goodsSkuAddVO.getPurchasePrice() != null) {
|
|
|
+ goodsSkuStore.setPurchasePrice(goodsSkuAddVO.getPurchasePrice());
|
|
|
+ }
|
|
|
+ if (goodsSkuAddVO.getStock() != null) {
|
|
|
+ goodsSkuStore.setStock(goodsSkuAddVO.getStock());
|
|
|
+ }
|
|
|
+ goodsSkuStoreService.updateById(goodsSkuStore);
|
|
|
+ }
|
|
|
+ return 1;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -412,4 +450,30 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
|
|
});
|
|
|
return SkuQueryVOS;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int updateGoodsSkuStatus(GoodsSkuAddVO goodsSkuAddVO) {
|
|
|
+ SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
+ // 总部
|
|
|
+ if (SourceType.MANAGER.getCode().equals(user.getUserType())) {
|
|
|
+ GoodsSku goodsSku = new GoodsSku();
|
|
|
+ goodsSku.setId(goodsSkuAddVO.getId());
|
|
|
+ goodsSku.setStatus(goodsSkuAddVO.getStatus());
|
|
|
+ goodsSku.buildUpdateData();
|
|
|
+ baseMapper.updateById(goodsSku);
|
|
|
+ }
|
|
|
+ // 工厂
|
|
|
+ if (SourceType.FACTORY.getCode().equals(user.getUserType())) {
|
|
|
+ GoodsSkuStore goodsSkuStore = goodsSkuStoreService.getSkuStoreBySkuIdAndOrgId(goodsSkuAddVO.getId(), SourceType.FACTORY.getCode(), user.getFactoryId());
|
|
|
+ goodsSkuStore.setStatus(goodsSkuAddVO.getStatus());
|
|
|
+ goodsSkuStoreService.updateById(goodsSkuStore);
|
|
|
+ }
|
|
|
+ // 门店
|
|
|
+ if (SourceType.STORE.getCode().equals(user.getUserType())) {
|
|
|
+ GoodsSkuStore goodsSkuStore = goodsSkuStoreService.getSkuStoreBySkuIdAndOrgId(goodsSkuAddVO.getId(), SourceType.STORE.getCode(), user.getStoreId());
|
|
|
+ goodsSkuStore.setStatus(goodsSkuAddVO.getStatus());
|
|
|
+ goodsSkuStoreService.updateById(goodsSkuStore);
|
|
|
+ }
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
}
|