Merge branch 'master' of https://codeup.aliyun.com/bsdtec/biz-api-cloud
This commit is contained in:
commit
8e2479c4b5
10 files changed
+344
-13
No files matched your search
+5
@@ -90,4 +90,9 @@ public class SmErpAuxiliaryCodeEntity extends Model<SmErpAuxiliaryCodeEntity> {
|
||||
@Schema(description="包装单位")
|
||||
@TableField(exist = false)
|
||||
private String unit;
|
||||
|
||||
|
||||
@Schema(description="口味")
|
||||
@TableField(exist = false)
|
||||
private String taste;
|
||||
}
|
||||
+1
-1
@@ -45,7 +45,7 @@ public class SmErpSpuEntity extends Model<SmErpSpuEntity> {
|
||||
* 自编码/条码
|
||||
*/
|
||||
@Schema(description="自编码/条码")
|
||||
private String barcode;
|
||||
private String barCode;
|
||||
|
||||
/**
|
||||
* 商品名称
|
||||
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
package com.bsd.pjcloud.supermarket.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.supermarket.entity.ShopCategoryEntity;
|
||||
import com.bsd.pjcloud.supermarket.service.ShopCategoryService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 在线商品分类
|
||||
*
|
||||
* @author zjf
|
||||
* @date 2025-06-18 16:49:20
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/shopCategory" )
|
||||
@Tag(description = "shopCategory" , name = "在线商品分类管理" )
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class ShopCategoryController {
|
||||
|
||||
private final ShopCategoryService shopCategoryService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page 分页对象
|
||||
* @param shopCategory 在线商品分类
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分页查询" , description = "分页查询" )
|
||||
@GetMapping("/page" )
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_shopCategory_view')" )
|
||||
public R getShopCategoryPage(@ParameterObject Page page, @ParameterObject ShopCategoryEntity shopCategory) {
|
||||
LambdaQueryWrapper<ShopCategoryEntity> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(StrUtil.isNotBlank(shopCategory.getName()),ShopCategoryEntity::getName,shopCategory.getName());
|
||||
return R.ok(shopCategoryService.page(page, wrapper));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过id查询在线商品分类
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id查询" , description = "通过id查询" )
|
||||
@GetMapping("/{id}" )
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_shopCategory_view')" )
|
||||
public R getById(@PathVariable("id" ) Integer id) {
|
||||
return R.ok(shopCategoryService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增在线商品分类
|
||||
* @param shopCategory 在线商品分类
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "新增在线商品分类" , description = "新增在线商品分类" )
|
||||
@SysLog("新增在线商品分类" )
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_shopCategory_add')" )
|
||||
public R save(@RequestBody ShopCategoryEntity shopCategory) {
|
||||
return R.ok(shopCategoryService.save(shopCategory));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改在线商品分类
|
||||
* @param shopCategory 在线商品分类
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "修改在线商品分类" , description = "修改在线商品分类" )
|
||||
@SysLog("修改在线商品分类" )
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_shopCategory_edit')" )
|
||||
public R updateById(@RequestBody ShopCategoryEntity shopCategory) {
|
||||
return R.ok(shopCategoryService.updateById(shopCategory));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除在线商品分类
|
||||
* @param ids id列表
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id删除在线商品分类" , description = "通过id删除在线商品分类" )
|
||||
@SysLog("通过id删除在线商品分类" )
|
||||
@DeleteMapping
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_shopCategory_del')" )
|
||||
public R removeById(@RequestBody Integer[] ids) {
|
||||
return R.ok(shopCategoryService.removeBatchByIds(CollUtil.toList(ids)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
* @param shopCategory 查询条件
|
||||
* @param ids 导出指定ID
|
||||
* @return excel 文件流
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_shopCategory_export')" )
|
||||
public List<ShopCategoryEntity> export(ShopCategoryEntity shopCategory,Integer[] ids) {
|
||||
return shopCategoryService.list(Wrappers.lambdaQuery(shopCategory).in(ArrayUtil.isNotEmpty(ids), ShopCategoryEntity::getId, ids));
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -82,7 +82,7 @@ public class SmErpSpuController {
|
||||
public R getSupermarketSpuPage(@ParameterObject Page page, @ParameterObject SmErpSpuEntity supermarketSpu) {
|
||||
LambdaQueryWrapper<SmErpSpuEntity> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(StringUtils.isNotBlank(supermarketSpu.getProductCode()), SmErpSpuEntity::getProductCode,supermarketSpu.getProductCode());
|
||||
wrapper.eq(StringUtils.isNotBlank(supermarketSpu.getBarcode()), SmErpSpuEntity::getBarcode,supermarketSpu.getBarcode());
|
||||
wrapper.eq(StringUtils.isNotBlank(supermarketSpu.getBarCode()), SmErpSpuEntity::getBarCode,supermarketSpu.getBarCode());
|
||||
wrapper.like(StringUtils.isNotBlank(supermarketSpu.getProductName()), SmErpSpuEntity::getProductName,supermarketSpu.getProductName());
|
||||
wrapper.orderByDesc(SmErpSpuEntity::getCreateTime);
|
||||
return R.ok(smErpSpuService.pageScope(page, wrapper));
|
||||
@@ -101,7 +101,7 @@ public class SmErpSpuController {
|
||||
LambdaQueryWrapper<SmErpSpuEntity> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(SmErpSpuEntity::getStatus,"0");
|
||||
wrapper.eq(StringUtils.isNotBlank(supermarketSpu.getProductCode()), SmErpSpuEntity::getProductCode,supermarketSpu.getProductCode());
|
||||
wrapper.eq(StringUtils.isNotBlank(supermarketSpu.getBarcode()), SmErpSpuEntity::getBarcode,supermarketSpu.getBarcode());
|
||||
wrapper.eq(StringUtils.isNotBlank(supermarketSpu.getBarCode()), SmErpSpuEntity::getBarCode,supermarketSpu.getBarCode());
|
||||
wrapper.eq(StringUtils.isNotBlank(supermarketSpu.getProductName()), SmErpSpuEntity::getProductName,supermarketSpu.getProductName());
|
||||
wrapper.eq(null!=supermarketSpu.getCategoryId(), SmErpSpuEntity::getCategoryId,supermarketSpu.getCategoryId());
|
||||
return R.ok(smErpSpuService.OnlineSpuPageScope(page, wrapper));
|
||||
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
package com.bsd.pjcloud.supermarket.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import com.bsd.pjcloud.common.core.util.TenantTable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 在线商品分类
|
||||
*
|
||||
* @author zjf
|
||||
* @date 2025-06-18 16:49:20
|
||||
*/
|
||||
@Data
|
||||
@TenantTable
|
||||
@TableName("shop_category")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "在线商品分类")
|
||||
public class ShopCategoryEntity extends Model<ShopCategoryEntity> {
|
||||
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description="id")
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 父级分类ID,0为顶级
|
||||
*/
|
||||
@Schema(description="父级分类ID,0为顶级")
|
||||
private Integer parentId;
|
||||
|
||||
/**
|
||||
* 分类名称
|
||||
*/
|
||||
@Schema(description="分类名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 层级(1/2/3)
|
||||
*/
|
||||
@Schema(description="层级(1/2/3)")
|
||||
private Integer level;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@Schema(description="排序")
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 状态(0正常,1下架)
|
||||
*/
|
||||
@Schema(description="状态(0正常,1下架)")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 分类图片
|
||||
*/
|
||||
@Schema(description="分类图片")
|
||||
private String picUrl;
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
@Schema(description="部门ID")
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description="创建者")
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description="创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description="更新者")
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description="更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 是否删除(0=正常 1=删除)
|
||||
*/
|
||||
@TableLogic
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description="是否删除(0=正常 1=删除)")
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 租户编号
|
||||
*/
|
||||
@Schema(description="租户编号")
|
||||
private Long tenantId;
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.bsd.pjcloud.supermarket.mapper;
|
||||
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import com.bsd.pjcloud.supermarket.entity.ShopCategoryEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface ShopCategoryMapper extends PjcloudBaseMapper<ShopCategoryEntity> {
|
||||
|
||||
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.bsd.pjcloud.supermarket.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.supermarket.entity.ShopCategoryEntity;
|
||||
|
||||
public interface ShopCategoryService extends IService<ShopCategoryEntity> {
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.bsd.pjcloud.supermarket.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.supermarket.entity.ShopCategoryEntity;
|
||||
import com.bsd.pjcloud.supermarket.mapper.ShopCategoryMapper;
|
||||
import com.bsd.pjcloud.supermarket.service.ShopCategoryService;
|
||||
import org.springframework.stereotype.Service;
|
||||
/**
|
||||
* 在线商品分类
|
||||
*
|
||||
* @author zjf
|
||||
* @date 2025-06-18 16:49:20
|
||||
*/
|
||||
@Service
|
||||
public class ShopCategoryServiceImpl extends ServiceImpl<ShopCategoryMapper, ShopCategoryEntity> implements ShopCategoryService {
|
||||
}
|
||||
+43
-10
@@ -241,23 +241,56 @@ public class SmErpSpuServiceImpl extends ServiceImpl<SmErpSpuMapper, SmErpSpuEnt
|
||||
} else {
|
||||
return R.failed("包装类型不能为空");
|
||||
}
|
||||
|
||||
//辅助条码
|
||||
List<SmErpAuxiliaryCodeEntity> smErpAuxiliaryCodeEntityList = supermarketSpu.getSmErpAuxiliaryCodeEntityList();
|
||||
if (CollectionUtils.isNotEmpty(smErpAuxiliaryCodeEntityList)) {
|
||||
List<SmErpAuxiliaryCodeEntity> insertCollect = smErpAuxiliaryCodeEntityList.stream().filter(supermarketAuxiliaryCodeEntity -> supermarketAuxiliaryCodeEntity.getId() == null).collect(Collectors.toList());
|
||||
List<SmErpAuxiliaryCodeEntity> updateCollect = smErpAuxiliaryCodeEntityList.stream().filter(supermarketAuxiliaryCodeEntity -> supermarketAuxiliaryCodeEntity.getId() != null).collect(Collectors.toList());
|
||||
Map<String, SmErpUnitEntity> unitMap;
|
||||
if (CollectionUtils.isNotEmpty(insertUnits)){
|
||||
unitMap = insertUnits.stream().collect(Collectors.toMap(smErpUnitEntity -> smErpUnitEntity.getUnit(), smErpUnitEntity -> smErpUnitEntity));
|
||||
}else {
|
||||
unitMap = updateUnits.stream().collect(Collectors.toMap(smErpUnitEntity -> smErpUnitEntity.getUnit(), smErpUnitEntity -> smErpUnitEntity));
|
||||
|
||||
// 构建包装单位映射:根据单位名称和口味分组
|
||||
Map<String, SmErpUnitEntity> unitMap = new HashMap<>();
|
||||
|
||||
// 先处理已存在的包装单位
|
||||
if (CollectionUtils.isNotEmpty(updateUnits)) {
|
||||
unitMap.putAll(updateUnits.stream()
|
||||
.collect(Collectors.toMap(
|
||||
unit -> unit.getUnit() + "_" + (unit.getTaste() != null ? unit.getTaste() : ""),
|
||||
unit -> unit
|
||||
)));
|
||||
}
|
||||
for (int i = 0; i < insertCollect.size(); i++) {
|
||||
SmErpAuxiliaryCodeEntity smErpAuxiliaryCodeEntity = insertCollect.get(i);
|
||||
smErpAuxiliaryCodeEntity.setSpuId(supermarketSpu.getId());
|
||||
smErpAuxiliaryCodeEntity.setUnitId(unitMap.get(smErpAuxiliaryCodeEntity.getUnit()).getId());
|
||||
|
||||
// 再处理新增的包装单位
|
||||
if (CollectionUtils.isNotEmpty(insertUnits)) {
|
||||
unitMap.putAll(insertUnits.stream()
|
||||
.collect(Collectors.toMap(
|
||||
unit -> unit.getUnit() + "_" + (unit.getTaste() != null ? unit.getTaste() : ""),
|
||||
unit -> unit
|
||||
)));
|
||||
}
|
||||
|
||||
// 为新增的辅助条码设置包装单位ID
|
||||
for (SmErpAuxiliaryCodeEntity auxiliaryCode : insertCollect) {
|
||||
String unitKey = auxiliaryCode.getUnit() + "_" + (auxiliaryCode.getTaste() != null ? auxiliaryCode.getTaste() : "");
|
||||
SmErpUnitEntity unit = unitMap.get(unitKey);
|
||||
if (unit != null) {
|
||||
auxiliaryCode.setSpuId(supermarketSpu.getId());
|
||||
auxiliaryCode.setUnitId(unit.getId());
|
||||
} else {
|
||||
return R.failed("找不到对应的包装单位:" + auxiliaryCode.getUnit() + ",口味:" + (auxiliaryCode.getTaste() != null ? auxiliaryCode.getTaste() : "无"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 为更新的辅助条码设置包装单位ID(如果单位发生变化)
|
||||
for (SmErpAuxiliaryCodeEntity auxiliaryCode : updateCollect) {
|
||||
String unitKey = auxiliaryCode.getUnit() + "_" + (auxiliaryCode.getTaste() != null ? auxiliaryCode.getTaste() : "");
|
||||
SmErpUnitEntity unit = unitMap.get(unitKey);
|
||||
if (unit != null) {
|
||||
auxiliaryCode.setUnitId(unit.getId());
|
||||
} else {
|
||||
return R.failed("找不到对应的包装单位:" + auxiliaryCode.getUnit() + ",口味:" + (auxiliaryCode.getTaste() != null ? auxiliaryCode.getTaste() : "无"));
|
||||
}
|
||||
}
|
||||
|
||||
smErpAuxiliaryCodeService.saveBatch(insertCollect);
|
||||
smErpAuxiliaryCodeService.updateBatchById(updateCollect);
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.bsd.pjcloud.supermarket.mapper.ShopCategoryMapper">
|
||||
|
||||
<resultMap id="shopCategoryMap" type="com.bsd.pjcloud.supermarket.entity.ShopCategoryEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="parentId" column="parent_id"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="level" column="level"/>
|
||||
<result property="sort" column="sort"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="picUrl" column="pic_url"/>
|
||||
<result property="deptId" column="dept_id"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="tenantId" column="tenant_id"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
Reference in new issue
Block a user