Merge branch 'company_server' of https://gitee.com/doc_wei01/skyeye into company_server

This commit is contained in:
sdhkjh 2024-09-08 20:33:11 +08:00
commit 26a0ddf7c9
15 changed files with 128 additions and 78 deletions

View file

@ -1,53 +0,0 @@
/*******************************************************************************
* Copyright 卫志强 QQ598748873@qq.com Inc. All rights reserved. 开源地址https://gitee.com/doc_wei01/skyeye
******************************************************************************/
package com.skyeye.material.classenum;
import cn.hutool.core.map.MapUtil;
import com.skyeye.common.base.classenum.SkyeyeEnumClass;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import java.util.HashMap;
import java.util.Map;
/**
* @ClassName: MaterialNormsShelvesState
* @Description: 商品规格上下架状态枚举类
* @author: skyeye云系列--卫志强
* @date: 2024/9/4 8:48
* @Copyright: 2024 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved.
* 注意本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的
*/
@Getter
@NoArgsConstructor
@AllArgsConstructor
public enum MaterialNormsShelvesState implements SkyeyeEnumClass {
NOT_ON_SHELVE(1, "未上架", "red", true, false),
ON_SHELVE(2, "已上架", "green", true, false);
private Integer key;
private String value;
private String color;
private Boolean show;
private Boolean isDefault;
public static Map<String, Object> getMation(Integer type) {
for (MaterialNormsShelvesState bean : MaterialNormsShelvesState.values()) {
if (type == bean.getKey()) {
Map<String, Object> result = new HashMap<>();
result.put("id", bean.getKey());
result.put("name", bean.getValue());
return result;
}
}
return MapUtil.newHashMap();
}
}

View file

@ -113,7 +113,7 @@ public class Material extends BaseGeneralInfo {
private Integer isUsed;
@TableField(value = "shelves_state")
@Property(value = "上下架状态")
@Property(value = "上下架状态,参考#MaterialShelvesState")
private Integer shelvesState;
@TableField(value = "brand_id")

View file

@ -95,8 +95,4 @@ public class MaterialNorms extends OperatorUserInfo {
@Property(value = "指定仓库的库存")
private NormsCalcStock depotTock;
@TableField(value = "shelves_state")
@Property(value = "上下架状态")
private Integer shelvesState;
}

View file

@ -35,4 +35,6 @@ public interface MaterialService extends SkyeyeBusinessService<Material> {
* @param id
*/
void setUsed(String id);
void setShelvesState(String id, Integer shelvesState);
}

View file

@ -16,7 +16,6 @@ import com.skyeye.common.object.InputObject;
import com.skyeye.common.object.OutputObject;
import com.skyeye.common.util.mybatisplus.MybatisPlusUtil;
import com.skyeye.exception.CustomException;
import com.skyeye.material.classenum.MaterialNormsShelvesState;
import com.skyeye.material.classenum.MaterialNormsStockType;
import com.skyeye.material.dao.MaterialNormsDao;
import com.skyeye.material.entity.Material;
@ -147,13 +146,6 @@ public class MaterialNormsServiceImpl extends SkyeyeBusinessServiceImpl<Material
return result;
}
@Override
public void createPrepose(List<MaterialNorms> entity) {
entity.forEach(item -> {
item.setShelvesState(MaterialNormsShelvesState.NOT_ON_SHELVE.getKey());
});
}
/**
* 根据商品id删除规格信息
*

View file

@ -369,4 +369,14 @@ public class MaterialServiceImpl extends SkyeyeBusinessServiceImpl<MaterialDao,
}
}
@Override
public void setShelvesState(String id, Integer shelvesState) {
UpdateWrapper<Material> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq(CommonConstants.ID, id);
updateWrapper.set(MybatisPlusUtil.toColumns(Material::getShelvesState), shelvesState);
updateWrapper.set(MybatisPlusUtil.toColumns(Material::getIsUsed), IsUsedEnum.IN_USE.getKey());
update(updateWrapper);
refreshCache(id);
}
}

View file

@ -8,6 +8,7 @@ import com.skyeye.annotation.api.Api;
import com.skyeye.annotation.api.ApiImplicitParam;
import com.skyeye.annotation.api.ApiImplicitParams;
import com.skyeye.annotation.api.ApiOperation;
import com.skyeye.common.entity.search.CommonPageInfo;
import com.skyeye.common.object.InputObject;
import com.skyeye.common.object.OutputObject;
import com.skyeye.shopmaterial.entity.ShopMaterial;
@ -46,4 +47,27 @@ 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.selectById(inputObject, outputObject);
}
@ApiOperation(id = "queryShopMaterialList", value = "获取商城商品信息列表", method = "POST", allUse = "0")
@ApiImplicitParams(classBean = CommonPageInfo.class)
@RequestMapping("/post/ShopMaterialController/queryShopMaterialList")
public void queryShopMaterialList(InputObject inputObject, OutputObject outputObject) {
shopMaterialService.queryShopMaterialList(inputObject, outputObject);
}
@ApiOperation(id = "queryShopMaterialByNormsIdList", value = "根据规格id获取商城商品信息", method = "POST", allUse = "0")
@ApiImplicitParams(value = {
@ApiImplicitParam(id = "normsIds", name = "normsIds", value = "规格id多个逗号隔开", required = "required")})
@RequestMapping("/post/ShopMaterialController/queryShopMaterialByNormsIdList")
public void queryShopMaterialByNormsIdList(InputObject inputObject, OutputObject outputObject) {
shopMaterialService.queryShopMaterialByNormsIdList(inputObject, outputObject);
}
}

View file

@ -58,7 +58,7 @@ public class ShopMaterial extends OperatorUserInfo {
private String logo;
@TableField(value = "carousel_img")
@ApiModelProperty(value = "商品轮播图,多个逗号隔开", required = "required")
@ApiModelProperty(value = "商品轮播图,多个逗号隔开")
private String carouselImg;
@TableField(value = "distribution_type")
@ -86,7 +86,7 @@ public class ShopMaterial extends OperatorUserInfo {
private String realSales;
@TableField(exist = false)
@ApiModelProperty(value = "上架的规格信息", required = "required,json")
@ApiModelProperty(value = "上架的规格信息", required = "json")
private List<ShopMaterialNorms> shopMaterialNormsList;
}

View file

@ -69,7 +69,7 @@ public class ShopMaterialNorms extends OperatorUserInfo {
private String logo;
@TableField(value = "carousel_img")
@ApiModelProperty(value = "商品轮播图,多个逗号隔开", required = "required")
@ApiModelProperty(value = "商品轮播图,多个逗号隔开")
private String carouselImg;
@TableField(value = "real_sales")

View file

@ -22,7 +22,7 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
public enum ShopMaterialDeliveryMethod implements SkyeyeEnumClass {
DEFAULT_SET(1, "快递发货", true, true),
DEFAULT_SET(1, "快递发货", true, false),
SINGLE_SET(2, "用户自提", true, false),
LOCAL_SET(3, "同城配送", true, false);

View file

@ -28,4 +28,6 @@ public interface ShopMaterialNormsService extends SkyeyeBusinessService<ShopMate
void saveList(String materialId, List<ShopMaterialNorms> shopMaterialNormsList);
List<ShopMaterialNorms> queryShopMaterialByNormsIdList(List<String> normsIdList);
}

View file

@ -21,4 +21,7 @@ public interface ShopMaterialService extends SkyeyeBusinessService<ShopMaterial>
void queryTransMaterialById(InputObject inputObject, OutputObject outputObject);
void queryShopMaterialList(InputObject inputObject, OutputObject outputObject);
void queryShopMaterialByNormsIdList(InputObject inputObject, OutputObject outputObject);
}

View file

@ -10,6 +10,7 @@ import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.skyeye.annotation.service.SkyeyeService;
import com.skyeye.base.business.service.impl.SkyeyeBusinessServiceImpl;
import com.skyeye.common.constans.CommonNumConstants;
import com.skyeye.common.util.mybatisplus.MybatisPlusUtil;
import com.skyeye.shopmaterial.dao.ShopMaterialNormsDao;
import com.skyeye.shopmaterial.entity.ShopMaterialNorms;
@ -65,8 +66,20 @@ public class ShopMaterialNormsServiceImpl extends SkyeyeBusinessServiceImpl<Shop
if (CollectionUtil.isNotEmpty(shopMaterialNormsList)) {
for (ShopMaterialNorms shopMaterialNorms : shopMaterialNormsList) {
shopMaterialNorms.setMaterialId(materialId);
shopMaterialNorms.setRealSales(CommonNumConstants.NUM_ZERO.toString());
}
createEntity(shopMaterialNormsList, StrUtil.EMPTY);
}
}
@Override
public List<ShopMaterialNorms> queryShopMaterialByNormsIdList(List<String> normsIdList) {
if (CollectionUtil.isEmpty(normsIdList)) {
return CollectionUtil.newArrayList();
}
QueryWrapper<ShopMaterialNorms> queryWrapper = new QueryWrapper<>();
queryWrapper.in(MybatisPlusUtil.toColumns(ShopMaterialNorms::getNormsId), normsIdList);
List<ShopMaterialNorms> shopMaterialNormsList = list(queryWrapper);
return shopMaterialNormsList;
}
}

View file

@ -7,11 +7,19 @@ package com.skyeye.shopmaterial.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.Page;
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.classenum.MaterialShelvesState;
import com.skyeye.material.entity.Material;
import com.skyeye.material.service.MaterialService;
import com.skyeye.shopmaterial.dao.ShopMaterialDao;
@ -50,18 +58,25 @@ public class ShopMaterialServiceImpl extends SkyeyeBusinessServiceImpl<ShopMater
}
@Override
public void createPostpose(ShopMaterial entity, String userId) {
List<ShopMaterialNorms> shopMaterialNormsList = entity.getShopMaterialNormsList();
shopMaterialNormsList.forEach(shopMaterialNorms -> {
shopMaterialNorms.setRealSales(CommonNumConstants.NUM_ZERO.toString());
});
shopMaterialNormsService.saveList(entity.getMaterialId(), shopMaterialNormsList);
public void writePostpose(ShopMaterial entity, String userId) {
// 保存商城商品规格
shopMaterialNormsService.saveList(entity.getMaterialId(), entity.getShopMaterialNormsList());
// 更新商品的上架状态
Material material = materialService.selectById(entity.getMaterialId());
if (CollectionUtil.isEmpty(entity.getShopMaterialNormsList())) {
materialService.setShelvesState(material.getId(), MaterialShelvesState.NOT_ON_SHELVE.getKey());
} else if (material.getMaterialNorms().size() > entity.getShopMaterialNormsList().size()) {
materialService.setShelvesState(material.getId(), MaterialShelvesState.PART_ON_SHELVE.getKey());
} else if (material.getMaterialNorms().size() == entity.getShopMaterialNormsList().size()) {
materialService.setShelvesState(material.getId(), MaterialShelvesState.ON_SHELVE.getKey());
}
}
@Override
public void queryTransMaterialById(InputObject inputObject, OutputObject outputObject) {
String materialId = inputObject.getParams().get("id").toString();
ShopMaterial shopMaterial = selectById(materialId);
ShopMaterial shopMaterial = selectByMaterialId(materialId);
if (ObjectUtil.isEmpty(shopMaterial) || StrUtil.isEmpty(shopMaterial.getId())) {
shopMaterial = new ShopMaterial();
Material material = materialService.selectById(materialId);
@ -78,11 +93,21 @@ public class ShopMaterialServiceImpl extends SkyeyeBusinessServiceImpl<ShopMater
if (ObjectUtil.isEmpty(shopMaterial) || StrUtil.isEmpty(shopMaterial.getId())) {
return shopMaterial;
}
List<ShopMaterialNorms> shopMaterialNormsList = shopMaterialNormsService.selectByMaterialId(id);
List<ShopMaterialNorms> shopMaterialNormsList = shopMaterialNormsService.selectByMaterialId(shopMaterial.getMaterialId());
shopMaterial.setShopMaterialNormsList(shopMaterialNormsList);
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);
@ -107,4 +132,34 @@ public class ShopMaterialServiceImpl extends SkyeyeBusinessServiceImpl<ShopMater
return shopMaterialList;
}
@Override
public List<ShopMaterial> selectByIds(String... ids) {
List<ShopMaterial> shopMaterialList = super.selectByIds(ids);
materialService.setDataMation(shopMaterialList, ShopMaterial::getMaterialId);
return shopMaterialList;
}
@Override
public void queryShopMaterialList(InputObject inputObject, OutputObject outputObject) {
CommonPageInfo commonPageInfo = inputObject.getParams(CommonPageInfo.class);
Page pages = PageHelper.startPage(commonPageInfo.getPage(), commonPageInfo.getLimit());
MPJLambdaWrapper<ShopMaterial> wrapper = new MPJLambdaWrapper<ShopMaterial>()
.innerJoin(Material.class, Material::getId, ShopMaterial::getMaterialId)
.like(StrUtil.isNotBlank(commonPageInfo.getKeyword()), Material::getName, commonPageInfo.getKeyword());
List<ShopMaterial> shopMaterialList = skyeyeBaseMapper.selectJoinList(ShopMaterial.class, wrapper);
List<String> idList = shopMaterialList.stream().map(ShopMaterial::getId).collect(Collectors.toList());
List<ShopMaterial> shopMaterials = selectByIds(idList.toArray(new String[]{}));
outputObject.setBeans(shopMaterials);
outputObject.settotal(pages.getTotal());
}
@Override
public void queryShopMaterialByNormsIdList(InputObject inputObject, OutputObject outputObject) {
List<String> normsIdList = JSONUtil.toList(inputObject.getParams().get("normsIds").toString(), null);
List<ShopMaterialNorms> shopMaterialNormsList = shopMaterialNormsService.queryShopMaterialByNormsIdList(normsIdList);
outputObject.setBeans(shopMaterialNormsList);
outputObject.settotal(shopMaterialNormsList.size());
}
}

View file

@ -4,7 +4,9 @@
package com.skyeye.db.config;
import com.baomidou.mybatisplus.core.config.GlobalConfig;
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import com.github.yulichang.injector.MPJSqlInjector;
import com.skyeye.common.constans.CommonConstants;
import com.skyeye.exception.CustomException;
import org.apache.commons.collections.CollectionUtils;
@ -77,6 +79,10 @@ public class BaseDataSourceConfig {
public SqlSessionFactory baseSqlSessionFactory(@Qualifier("baseDataSource") DataSource dataSource) {
MybatisSqlSessionFactoryBean mybatisSqlSessionFactoryBean = new MybatisSqlSessionFactoryBean();
GlobalConfig globalConfig = new GlobalConfig();
globalConfig.setSqlInjector(new MPJSqlInjector());
mybatisSqlSessionFactoryBean.setGlobalConfig(globalConfig);
mybatisSqlSessionFactoryBean.setDataSource(dataSource);
String databaseType = this.initDatabaseType(dataSource);
if (databaseType == null) {