mirror of
https://github.com/weizhiqiang1995/erp-pro.git
synced 2025-02-01 04:00:54 +08:00
feat: 商城商品信息修改
This commit is contained in:
parent
213d784e7e
commit
6af1c2b1e2
7 changed files with 89 additions and 41 deletions
|
@ -47,14 +47,6 @@ public class ShopMaterialController {
|
|||
shopMaterialService.saveOrUpdateEntity(inputObject, outputObject);
|
||||
}
|
||||
|
||||
@ApiOperation(id = "queryShopMaterialById", value = "根据id获取商城商品信息", method = "GET", allUse = "0")
|
||||
@ApiImplicitParams(value = {
|
||||
@ApiImplicitParam(id = "id", name = "id", value = "主键id", required = "required")})
|
||||
@RequestMapping("/post/ShopMaterialController/queryShopMaterialById")
|
||||
public void queryShopMaterialById(InputObject inputObject, OutputObject outputObject) {
|
||||
shopMaterialService.queryShopMaterialById(inputObject, outputObject);
|
||||
}
|
||||
|
||||
@ApiOperation(id = "queryShopMaterialList", value = "获取商城商品信息列表", method = "POST", allUse = "0")
|
||||
@ApiImplicitParams(classBean = CommonPageInfo.class)
|
||||
@RequestMapping("/post/ShopMaterialController/queryShopMaterialList")
|
||||
|
|
|
@ -38,4 +38,12 @@ public class ShopMaterialStoreController {
|
|||
shopMaterialStoreService.saveShopMaterialStore(inputObject, outputObject);
|
||||
}
|
||||
|
||||
@ApiOperation(id = "queryShopMaterialById", value = "根据id获取商城商品信息", method = "GET", allUse = "0")
|
||||
@ApiImplicitParams(value = {
|
||||
@ApiImplicitParam(id = "id", name = "id", value = "主键id", required = "required")})
|
||||
@RequestMapping("/post/ShopMaterialStoreController/queryShopMaterialById")
|
||||
public void queryShopMaterialById(InputObject inputObject, OutputObject outputObject) {
|
||||
shopMaterialStoreService.queryShopMaterialById(inputObject, outputObject);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -85,6 +85,14 @@ public class ShopMaterial extends OperatorUserInfo {
|
|||
@Property(value = "实际销量")
|
||||
private String realSales;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Property("默认门店id")
|
||||
private String defaultStoreId;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Property("该商品随机支持的门店信息")
|
||||
private ShopMaterialStore shopMaterialStore;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "上架的规格信息", required = "json")
|
||||
private List<ShopMaterialNorms> shopMaterialNormsList;
|
||||
|
|
|
@ -25,7 +25,7 @@ public interface ShopMaterialService extends SkyeyeBusinessService<ShopMaterial>
|
|||
|
||||
void queryShopMaterialByNormsIdList(InputObject inputObject, OutputObject outputObject);
|
||||
|
||||
void queryShopMaterialById(InputObject inputObject, OutputObject outputObject);
|
||||
|
||||
void queryBrandShopMaterialList(InputObject inputObject, OutputObject outputObject);
|
||||
|
||||
ShopMaterial queryShopMaterialByMaterialId(String materialId);
|
||||
}
|
||||
|
|
|
@ -41,4 +41,8 @@ public interface ShopMaterialStoreService extends SkyeyeBusinessService<ShopMate
|
|||
|
||||
List<ShopMaterialStore> queryShopMaterialList(InputObject inputObject, OutputObject outputObject);
|
||||
|
||||
Map<String, ShopMaterialStore> queryShopMaterialStoreByMaterialIds(String... materialIds);
|
||||
|
||||
void queryShopMaterialById(InputObject inputObject, OutputObject outputObject);
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import com.skyeye.common.object.OutputObject;
|
|||
import com.skyeye.common.util.mybatisplus.MybatisPlusUtil;
|
||||
import com.skyeye.material.classenum.MaterialShelvesState;
|
||||
import com.skyeye.material.entity.Material;
|
||||
import com.skyeye.material.service.MaterialNormsService;
|
||||
import com.skyeye.material.service.MaterialService;
|
||||
import com.skyeye.shopmaterial.dao.ShopMaterialDao;
|
||||
import com.skyeye.shopmaterial.entity.ShopMaterial;
|
||||
|
@ -54,9 +53,6 @@ public class ShopMaterialServiceImpl extends SkyeyeBusinessServiceImpl<ShopMater
|
|||
@Autowired
|
||||
private MaterialService materialService;
|
||||
|
||||
@Autowired
|
||||
private MaterialNormsService materialNormsService;
|
||||
|
||||
@Autowired
|
||||
private ShopMaterialNormsService shopMaterialNormsService;
|
||||
|
||||
|
@ -93,7 +89,7 @@ public class ShopMaterialServiceImpl extends SkyeyeBusinessServiceImpl<ShopMater
|
|||
@Override
|
||||
public void queryTransMaterialById(InputObject inputObject, OutputObject outputObject) {
|
||||
String materialId = inputObject.getParams().get("id").toString();
|
||||
ShopMaterial shopMaterial = selectByMaterialId(materialId);
|
||||
ShopMaterial shopMaterial = queryShopMaterialByMaterialId(materialId);
|
||||
if (ObjectUtil.isEmpty(shopMaterial) || StrUtil.isEmpty(shopMaterial.getId())) {
|
||||
shopMaterial = new ShopMaterial();
|
||||
Material material = materialService.selectById(materialId);
|
||||
|
@ -115,16 +111,6 @@ public class ShopMaterialServiceImpl extends SkyeyeBusinessServiceImpl<ShopMater
|
|||
return shopMaterial;
|
||||
}
|
||||
|
||||
private ShopMaterial selectByMaterialId(String materialId) {
|
||||
QueryWrapper<ShopMaterial> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq(MybatisPlusUtil.toColumns(ShopMaterial::getMaterialId), materialId);
|
||||
ShopMaterial shopMaterial = super.getOne(queryWrapper);
|
||||
if (ObjectUtil.isEmpty(shopMaterial)) {
|
||||
return null;
|
||||
}
|
||||
return selectById(shopMaterial.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShopMaterial selectById(String id) {
|
||||
ShopMaterial shopMaterial = super.selectById(id);
|
||||
|
@ -190,22 +176,6 @@ public class ShopMaterialServiceImpl extends SkyeyeBusinessServiceImpl<ShopMater
|
|||
outputObject.settotal(shopMaterialNormsList.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void queryShopMaterialById(InputObject inputObject, OutputObject outputObject) {
|
||||
String id = inputObject.getParams().get("id").toString();
|
||||
ShopMaterial shopMaterial = selectById(id);
|
||||
shopMaterial.getMaterialMation().setMaterialNorms(null);
|
||||
shopMaterial.getMaterialMation().setUnitGroupMation(null);
|
||||
shopMaterial.getMaterialMation().setMaterialProcedure(null);
|
||||
shopMaterial.getMaterialMation().setNormsSpec(null);
|
||||
materialNormsService.setDataMation(shopMaterial.getShopMaterialNormsList(), ShopMaterialNorms::getNormsId);
|
||||
shopMaterial.getShopMaterialNormsList().forEach(shopMaterialNorms -> {
|
||||
shopMaterialNorms.setEstimatePurchasePrice(null);
|
||||
});
|
||||
outputObject.setBean(shopMaterial);
|
||||
outputObject.settotal(CommonNumConstants.NUM_ONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void queryBrandShopMaterialList(InputObject inputObject, OutputObject outputObject) {
|
||||
MPJLambdaWrapper<ShopMaterial> wrapper = new MPJLambdaWrapper<ShopMaterial>()
|
||||
|
@ -216,12 +186,20 @@ public class ShopMaterialServiceImpl extends SkyeyeBusinessServiceImpl<ShopMater
|
|||
List<ShopMaterial> shopMaterialList = skyeyeBaseMapper.selectJoinList(ShopMaterial.class, wrapper);
|
||||
// 根据id批量查询详细的商品信息
|
||||
List<String> idList = shopMaterialList.stream().map(ShopMaterial::getId).collect(Collectors.toList());
|
||||
// 批量查询商品所属门店信息(门店随机)
|
||||
List<String> materialIds = shopMaterialList.stream().map(ShopMaterial::getMaterialId).distinct().collect(Collectors.toList());
|
||||
Map<String, ShopMaterialStore> stringShopMaterialStoreMap = shopMaterialStoreService.queryShopMaterialStoreByMaterialIds(materialIds.toArray(new String[]{}));
|
||||
shopMaterialList = selectByIds(idList.toArray(new String[]{}));
|
||||
shopMaterialList.forEach(shopMaterial -> {
|
||||
shopMaterial.getMaterialMation().setMaterialNorms(null);
|
||||
shopMaterial.getMaterialMation().setUnitGroupMation(null);
|
||||
shopMaterial.getMaterialMation().setMaterialProcedure(null);
|
||||
shopMaterial.getMaterialMation().setNormsSpec(null);
|
||||
// 设置门店信息
|
||||
shopMaterial.setShopMaterialStore(stringShopMaterialStoreMap.get(shopMaterial.getMaterialId()));
|
||||
if (ObjectUtil.isNotEmpty(shopMaterial.getShopMaterialStore())) {
|
||||
shopMaterial.setDefaultStoreId(shopMaterial.getShopMaterialStore().getStoreId());
|
||||
}
|
||||
});
|
||||
|
||||
// 根据品牌id进行分组,并且每个品牌下只取8条数据
|
||||
|
@ -247,4 +225,15 @@ public class ShopMaterialServiceImpl extends SkyeyeBusinessServiceImpl<ShopMater
|
|||
outputObject.settotal(CommonNumConstants.NUM_ONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShopMaterial queryShopMaterialByMaterialId(String materialId) {
|
||||
QueryWrapper<ShopMaterial> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq(MybatisPlusUtil.toColumns(ShopMaterial::getMaterialId), materialId);
|
||||
ShopMaterial shopMaterial = getOne(queryWrapper, false);
|
||||
if (ObjectUtil.isEmpty(shopMaterial)) {
|
||||
return null;
|
||||
}
|
||||
return selectById(shopMaterial.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,18 +13,25 @@ import com.github.pagehelper.PageHelper;
|
|||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.skyeye.annotation.service.SkyeyeService;
|
||||
import com.skyeye.base.business.service.impl.SkyeyeBusinessServiceImpl;
|
||||
import com.skyeye.common.constans.CommonNumConstants;
|
||||
import com.skyeye.common.entity.search.CommonPageInfo;
|
||||
import com.skyeye.common.object.InputObject;
|
||||
import com.skyeye.common.object.OutputObject;
|
||||
import com.skyeye.common.util.mybatisplus.MybatisPlusUtil;
|
||||
import com.skyeye.material.entity.Material;
|
||||
import com.skyeye.material.service.MaterialNormsService;
|
||||
import com.skyeye.rest.shop.service.IShopStoreService;
|
||||
import com.skyeye.shopmaterial.dao.ShopMaterialStoreDao;
|
||||
import com.skyeye.shopmaterial.entity.ShopMaterial;
|
||||
import com.skyeye.shopmaterial.entity.ShopMaterialNorms;
|
||||
import com.skyeye.shopmaterial.entity.ShopMaterialStore;
|
||||
import com.skyeye.shopmaterial.service.ShopMaterialService;
|
||||
import com.skyeye.shopmaterial.service.ShopMaterialStoreService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -44,6 +51,12 @@ public class ShopMaterialStoreServiceImpl extends SkyeyeBusinessServiceImpl<Shop
|
|||
@Autowired
|
||||
private IShopStoreService iShopStoreService;
|
||||
|
||||
@Autowired
|
||||
private MaterialNormsService materialNormsService;
|
||||
|
||||
@Autowired
|
||||
private ShopMaterialService shopMaterialService;
|
||||
|
||||
@Override
|
||||
public void deleteByMaterialId(String materialId) {
|
||||
QueryWrapper<ShopMaterialStore> queryWrapper = new QueryWrapper<>();
|
||||
|
@ -156,4 +169,38 @@ public class ShopMaterialStoreServiceImpl extends SkyeyeBusinessServiceImpl<Shop
|
|||
return shopMaterialStoreList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ShopMaterialStore> queryShopMaterialStoreByMaterialIds(String... materialIds) {
|
||||
List<String> idList = Arrays.asList(materialIds).stream()
|
||||
.filter(materialId -> StrUtil.isNotEmpty(materialId)).distinct().collect(Collectors.toList());
|
||||
if (CollectionUtil.isEmpty(idList)) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
QueryWrapper<ShopMaterialStore> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in(MybatisPlusUtil.toColumns(ShopMaterialStore::getMaterialId), idList);
|
||||
List<ShopMaterialStore> shopMaterialStoreList = list(queryWrapper);
|
||||
Map<String, ShopMaterialStore> collect = shopMaterialStoreList.stream()
|
||||
.collect(Collectors.toMap(ShopMaterialStore::getMaterialId, shopMaterialStore -> shopMaterialStore, (existingValue, newValue) -> existingValue));
|
||||
return collect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void queryShopMaterialById(InputObject inputObject, OutputObject outputObject) {
|
||||
String id = inputObject.getParams().get("id").toString();
|
||||
ShopMaterialStore shopMaterialStore = selectById(id);
|
||||
ShopMaterial shopMaterial = shopMaterialService.queryShopMaterialByMaterialId(shopMaterialStore.getMaterialId());
|
||||
shopMaterial.getMaterialMation().setMaterialNorms(null);
|
||||
shopMaterial.getMaterialMation().setUnitGroupMation(null);
|
||||
shopMaterial.getMaterialMation().setMaterialProcedure(null);
|
||||
shopMaterial.getMaterialMation().setNormsSpec(null);
|
||||
materialNormsService.setDataMation(shopMaterial.getShopMaterialNormsList(), ShopMaterialNorms::getNormsId);
|
||||
shopMaterial.getShopMaterialNormsList().forEach(shopMaterialNorms -> {
|
||||
shopMaterialNorms.setEstimatePurchasePrice(null);
|
||||
});
|
||||
shopMaterial.setShopMaterialStore(shopMaterialStore);
|
||||
shopMaterial.setDefaultStoreId(shopMaterialStore.getStoreId());
|
||||
outputObject.setBean(shopMaterialStore);
|
||||
outputObject.settotal(CommonNumConstants.NUM_ONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue