引入在线商城spu sku

This commit is contained in:
zjf committed 2025-06-19 13:47:50 +08:00
1 parent b8ceb0403c
commit 5e2d1f4b8e
14 files changed
+792 -15

No files matched your search

@@ -6,10 +6,14 @@ 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.BeanUtils;
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.entity.SmErpSupplierEntity;
import com.bsd.pjcloud.supermarket.service.ShopCategoryService;
import com.bsd.pjcloud.supermarket.vo.ShopCategoryTreeVo;
import com.bsd.pjcloud.supermarket.vo.erp.SmErpSupplierSimpleVo;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
@@ -118,4 +122,38 @@ public class ShopCategoryController {
public List<ShopCategoryEntity> export(ShopCategoryEntity shopCategory,Integer[] ids) {
return shopCategoryService.list(Wrappers.lambdaQuery(shopCategory).in(ArrayUtil.isNotEmpty(ids), ShopCategoryEntity::getId, ids));
}
/**
* 分类树结构
*/
@GetMapping("/tree")
@Operation(summary = "分类树", description = "获取所有分类的树结构")
public R<List<ShopCategoryTreeVo>> tree() {
List<ShopCategoryEntity> all = shopCategoryService.list();
List<ShopCategoryTreeVo> tree = buildCategoryTree(all, 0);
return R.ok(tree);
}
private List<ShopCategoryTreeVo> buildCategoryTree(List<ShopCategoryEntity> all, Integer parentId) {
List<ShopCategoryTreeVo> result = new java.util.ArrayList<>();
for (ShopCategoryEntity cat : all) {
if (Objects.equals(cat.getParentId(), parentId)) {
ShopCategoryTreeVo vo = com.bsd.pjcloud.common.core.util.BeanUtils.toBean(cat, ShopCategoryTreeVo.class);
vo.setChildren(buildCategoryTree(all, cat.getId()));
result.add(vo);
}
}
return result;
}
/**
* 根据父级ID查子分类
*/
@GetMapping("/listByParent/{parentId}")
@Operation(summary = "根据父级ID查子分类", description = "根据父级ID查子分类")
public R<List<ShopCategoryEntity>> listByParent(@PathVariable("parentId") Integer parentId) {
List<ShopCategoryEntity> list = shopCategoryService.list(Wrappers.<ShopCategoryEntity>lambdaQuery().eq(ShopCategoryEntity::getParentId, parentId));
return R.ok(list);
}
}
@@ -0,0 +1,119 @@
package com.bsd.pjcloud.supermarket.controller;
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.ShopSkuEntity;
import com.bsd.pjcloud.supermarket.service.ShopSkuService;
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;
/**
* sku
*
* @author zjf
* @date 2025-06-19 12:43:40
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/shopSku" )
@Tag(description = "shopSku" , name = "sku管理" )
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class ShopSkuController {
private final ShopSkuService shopSkuService;
/**
* 分页查询
* @param page 分页对象
* @param shopSku sku
* @return
*/
@Operation(summary = "分页查询" , description = "分页查询" )
@GetMapping("/page" )
@PreAuthorize("@pms.hasPermission('supermarket_shopSku_view')" )
public R getShopSkuPage(@ParameterObject Page page, @ParameterObject ShopSkuEntity shopSku) {
LambdaQueryWrapper<ShopSkuEntity> wrapper = Wrappers.lambdaQuery();
return R.ok(shopSkuService.page(page, wrapper));
}
/**
* 通过id查询sku
* @param id id
* @return R
*/
@Operation(summary = "通过id查询" , description = "通过id查询" )
@GetMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('supermarket_shopSku_view')" )
public R getById(@PathVariable("id" ) Long id) {
return R.ok(shopSkuService.getById(id));
}
/**
* 新增sku
* @param shopSku sku
* @return R
*/
@Operation(summary = "新增sku" , description = "新增sku" )
@SysLog("新增sku" )
@PostMapping
@PreAuthorize("@pms.hasPermission('supermarket_shopSku_add')" )
public R save(@RequestBody ShopSkuEntity shopSku) {
return R.ok(shopSkuService.save(shopSku));
}
/**
* 修改sku
* @param shopSku sku
* @return R
*/
@Operation(summary = "修改sku" , description = "修改sku" )
@SysLog("修改sku" )
@PutMapping
@PreAuthorize("@pms.hasPermission('supermarket_shopSku_edit')" )
public R updateById(@RequestBody ShopSkuEntity shopSku) {
return R.ok(shopSkuService.updateById(shopSku));
}
/**
* 通过id删除sku
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除sku" , description = "通过id删除sku" )
@SysLog("通过id删除sku" )
@DeleteMapping
@PreAuthorize("@pms.hasPermission('supermarket_shopSku_del')" )
public R removeById(@RequestBody Long[] ids) {
return R.ok(shopSkuService.removeBatchByIds(CollUtil.toList(ids)));
}
/**
* 导出excel 表格
* @param shopSku 查询条件
* @param ids 导出指定ID
* @return excel 文件流
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('supermarket_shopSku_export')" )
public List<ShopSkuEntity> export(ShopSkuEntity shopSku,Long[] ids) {
return shopSkuService.list(Wrappers.lambdaQuery(shopSku).in(ArrayUtil.isNotEmpty(ids), ShopSkuEntity::getId, ids));
}
}
@@ -0,0 +1,132 @@
package com.bsd.pjcloud.supermarket.controller;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.ArrayUtil;
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.ShopSpuEntity;
import com.bsd.pjcloud.supermarket.entity.ShopSkuEntity;
import com.bsd.pjcloud.supermarket.service.ShopSpuService;
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;
/**
* 商品spu
*
* @author zjf
* @date 2025-06-19 12:58:05
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/shopSpu" )
@Tag(description = "shopSpu" , name = "商品spu管理" )
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class ShopSpuController {
private final ShopSpuService shopSpuService;
/**
* 分页查询
* @param page 分页对象
* @param shopSpu 商品spu
* @return
*/
@Operation(summary = "分页查询" , description = "分页查询" )
@GetMapping("/page" )
@PreAuthorize("@pms.hasPermission('supermarket_shopSpu_view')" )
public R getShopSpuPage(@ParameterObject Page page, @ParameterObject ShopSpuEntity shopSpu) {
LambdaQueryWrapper<ShopSpuEntity> wrapper = Wrappers.lambdaQuery();
wrapper.like(StrUtil.isNotBlank(shopSpu.getProductName()),ShopSpuEntity::getProductName,shopSpu.getProductName());
return R.ok(shopSpuService.page(page, wrapper));
}
/**
* 通过id查询商品spu
* @param id id
* @return R
*/
@Operation(summary = "通过id查询" , description = "通过id查询" )
@GetMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('supermarket_shopSpu_view')" )
public R getById(@PathVariable("id" ) Long id) {
return R.ok(shopSpuService.getByIdDeep(id));
}
/**
* 新增商品spu
* @param shopSpu 商品spu
* @return R
*/
@Operation(summary = "新增商品spu" , description = "新增商品spu" )
@SysLog("新增商品spu" )
@PostMapping
@PreAuthorize("@pms.hasPermission('supermarket_shopSpu_add')" )
public R save(@RequestBody ShopSpuEntity shopSpu) {
return R.ok(shopSpuService.saveDeep(shopSpu));
}
/**
* 修改商品spu
* @param shopSpu 商品spu
* @return R
*/
@Operation(summary = "修改商品spu" , description = "修改商品spu" )
@SysLog("修改商品spu" )
@PutMapping
@PreAuthorize("@pms.hasPermission('supermarket_shopSpu_edit')" )
public R updateById(@RequestBody ShopSpuEntity shopSpu) {
return R.ok(shopSpuService.updateDeep(shopSpu));
}
/**
* 通过id删除商品spu
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除商品spu" , description = "通过id删除商品spu" )
@SysLog("通过id删除商品spu" )
@DeleteMapping
@PreAuthorize("@pms.hasPermission('supermarket_shopSpu_del')" )
public R removeById(@RequestBody Long[] ids) {
return R.ok(shopSpuService.removeDeep(ids));
}
/**
* 通过id删除商品spu子表数据
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除商品spu子表数据" , description = "通过id删除商品spu子表数据" )
@SysLog("通过id删除商品spu子表数据" )
@DeleteMapping("/child")
@PreAuthorize("@pms.hasPermission('supermarket_shopSpu_del')" )
public R removeChild(@RequestBody Long[] ids) {
return R.ok(shopSpuService.removeChild(ids));
}
/**
* 导出excel 表格
* @param shopSpu 查询条件
* @param ids 导出指定ID
* @return excel 文件流
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('supermarket_shopSpu_export')" )
public List<ShopSpuEntity> export(ShopSpuEntity shopSpu,Long[] ids) {
return shopSpuService.list(Wrappers.lambdaQuery(shopSpu).in(ArrayUtil.isNotEmpty(ids), ShopSpuEntity::getId, ids));
}
}
@@ -0,0 +1,116 @@
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 com.bsd.pjcloud.common.core.util.TenantTable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDateTime;
/**
* 商品spu
*
* @author zjf
* @date 2025-06-19 12:58:05
*/
@Data
@TenantTable
@TableName("shop_sku")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "shop_sku")
public class ShopSkuEntity extends Model<ShopSkuEntity> {
/**
* 包装单位id
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description="包装单位id")
private Long id;
/**
* 条码
*/
@Schema(description="条码")
private String barCode;
/**
* 规格
*/
@Schema(description="规格")
private String spec;
/**
* 单位
*/
@Schema(description="单位")
private String unit;
/**
* 状态(0正常,1停销)
*/
@Schema(description="状态(0正常,1停销)")
private Integer status;
/**
* 创建者
*/
@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;
/**
* 是否删除
*/
@TableLogic
@TableField(fill = FieldFill.INSERT)
@Schema(description="是否删除")
private String delFlag;
/**
* 租户编号
*/
@Schema(description="租户编号")
private Long tenantId;
/**
* 进价/单位分
*/
@Schema(description="进价/单位分")
private Integer purchasePrice;
/**
* 零售价/单位分
*/
@Schema(description="零售价/单位分")
private Integer retailPrice;
/**
* spuID
*/
@Schema(description="spuID")
private Long spuId;
/**
* 促销价
*/
@Schema(description="促销价")
private Integer promotionPrice;
/**
* 库存
*/
@Schema(description="库存")
private Double stock;
/**
* sku属性
*/
@Schema(description="sku属性")
private String attribute;
}
@@ -0,0 +1,178 @@
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;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.github.yulichang.annotation.EntityMapping;
import java.util.List;
/**
* 商品spu
*
* @author zjf
* @date 2025-06-19 12:58:05
*/
@Data
@TenantTable
@TableName("shop_spu")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "商品spu")
public class ShopSpuEntity extends Model<ShopSpuEntity> {
/**
* 商品 SPU 编号,自增
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description="商品 SPU 编号,自增")
private Long id;
/**
* 货号
*/
@Schema(description="货号")
private String productCode;
/**
* 商品名称
*/
@Schema(description="商品名称")
private String productName;
/**
* 商品简介
*/
@Schema(description="商品简介")
private String introduction;
/**
* 商品详情
*/
@Schema(description="商品详情")
private String description;
/**
* 商品分类编号
*/
@Schema(description="商品分类编号")
private Long categoryId;
/**
* 商品封面图
*/
@Schema(description="商品封面图")
private String picUrl;
/**
* 商品轮播图地址
数组,以逗号分隔
最多上传15张
*/
@Schema(description="商品轮播图地址")
private String sliderPicUrls;
/**
* 排序字段
*/
@Schema(description="排序字段")
private Integer sort;
/**
* 商品状态: 1 上架(开启) 0 下架(禁用) -1 回收
*/
@Schema(description="商品状态: 1 上架(开启) 0 下架(禁用) -1 回收")
private String status;
/**
* 库存
*/
@Schema(description="库存")
private Integer stock;
/**
* 赠送积分
*/
@Schema(description="赠送积分")
private Integer giveIntegral;
/**
* 商户关系表
*/
@Schema(description="商户关系表")
private Long merchantRelationId;
/**
* 部门id
*/
@Schema(description="部门id")
private Long deptId;
/**
* skuid
*/
@Schema(description="skuid")
private Long shopSkuId;
/**
* 销量
*/
@Schema(description="销量")
private Integer salesCount;
/**
* 单人限购数量
*/
@Schema(description="单人限购数量")
private Integer limitNum;
/**
* 创建人
*/
@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;
/**
* 是否删除
*/
@TableLogic
@TableField(fill = FieldFill.INSERT)
@Schema(description="是否删除")
private String delFlag;
/**
* 租户编号
*/
@Schema(description="租户编号")
private Long tenantId;
@ExcelIgnore
@TableField(exist = false)
@EntityMapping(thisField = "id", joinField = "spuId")
private List<ShopSkuEntity> shopSkuList;
}
@@ -0,0 +1,10 @@
package com.bsd.pjcloud.supermarket.mapper;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.supermarket.entity.ShopSkuEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ShopSkuMapper extends PjcloudBaseMapper<ShopSkuEntity> {
}
@@ -0,0 +1,11 @@
package com.bsd.pjcloud.supermarket.mapper;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.supermarket.entity.ShopSpuEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ShopSpuMapper extends PjcloudBaseMapper<ShopSpuEntity> {
}
@@ -0,0 +1,8 @@
package com.bsd.pjcloud.supermarket.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.supermarket.entity.ShopSkuEntity;
public interface ShopSkuService extends IService<ShopSkuEntity> {
}
@@ -0,0 +1,16 @@
package com.bsd.pjcloud.supermarket.service;
import com.github.yulichang.extension.mapping.base.MPJDeepService;
import com.bsd.pjcloud.supermarket.entity.ShopSkuEntity;
import com.bsd.pjcloud.supermarket.entity.ShopSpuEntity;
public interface ShopSpuService extends MPJDeepService<ShopSpuEntity> {
Boolean saveDeep(ShopSpuEntity shopSpu);
Boolean updateDeep(ShopSpuEntity shopSpu);
Boolean removeDeep(Long[] ids);
Boolean removeChild(Long[] ids);
}
@@ -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.ShopSkuEntity;
import com.bsd.pjcloud.supermarket.mapper.ShopSkuMapper;
import com.bsd.pjcloud.supermarket.service.ShopSkuService;
import org.springframework.stereotype.Service;
/**
* sku
*
* @author zjf
* @date 2025-06-19 12:43:40
*/
@Service
public class ShopSkuServiceImpl extends ServiceImpl<ShopSkuMapper, ShopSkuEntity> implements ShopSkuService {
}
@@ -0,0 +1,67 @@
package com.bsd.pjcloud.supermarket.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.supermarket.entity.ShopSpuEntity;
import com.bsd.pjcloud.supermarket.mapper.ShopSpuMapper;
import com.bsd.pjcloud.supermarket.service.ShopSpuService;
import org.springframework.stereotype.Service;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.bsd.pjcloud.supermarket.entity.ShopSkuEntity;
import com.bsd.pjcloud.supermarket.mapper.ShopSkuMapper;
import org.springframework.transaction.annotation.Transactional;
import lombok.RequiredArgsConstructor;
import java.util.Objects;
/**
* 商品spu
*
* @author zjf
* @date 2025-06-19 12:58:05
*/
@Service
@RequiredArgsConstructor
public class ShopSpuServiceImpl extends ServiceImpl<ShopSpuMapper, ShopSpuEntity> implements ShopSpuService {
private final ShopSkuMapper shopSkuMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean saveDeep(ShopSpuEntity shopSpu) {
baseMapper.insert(shopSpu);
for (ShopSkuEntity shopSku : shopSpu.getShopSkuList()) {
shopSku.setSpuId(shopSpu.getId());
shopSkuMapper.insert( shopSku);
}
return Boolean.TRUE;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean updateDeep(ShopSpuEntity shopSpu) {
baseMapper.updateById(shopSpu);
for (ShopSkuEntity shopSku : shopSpu.getShopSkuList()) {
if (Objects.isNull(shopSku.getId())) {
shopSku.setSpuId(shopSpu.getId());
shopSkuMapper.insert(shopSku);
} else {
shopSkuMapper.updateById(shopSku);
}
}
return Boolean.TRUE;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean removeDeep(Long[] ids) {
baseMapper.deleteBatchIds(CollUtil.toList(ids));
shopSkuMapper.delete(Wrappers.<ShopSkuEntity>lambdaQuery().in(ShopSkuEntity::getSpuId, ids));
return Boolean.TRUE;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean removeChild(Long[] ids) {
shopSkuMapper.deleteBatchIds(CollUtil.toList(ids));
return Boolean.TRUE;
}
}
@@ -270,25 +270,35 @@ public class SmErpSpuServiceImpl extends ServiceImpl<SmErpSpuMapper, SmErpSpuEnt
}
// 为新增的辅助条码设置包装单位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() : "无"));
if (CollectionUtils.isNotEmpty(insertCollect)) {
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() : "无"));
if (CollectionUtils.isNotEmpty(updateCollect)) {
for (SmErpAuxiliaryCodeEntity auxiliaryCode : updateCollect) {
// 优先用unitId
if (auxiliaryCode.getUnitId() != null) {
continue; // 已有unitId,直接跳过
}
// 只有unitId为空时,才用unit+口味查找
String unitKey = (auxiliaryCode.getUnit() != null ? auxiliaryCode.getUnit().trim() : "") + "_" +
(auxiliaryCode.getTaste() != null ? auxiliaryCode.getTaste().trim() : "");
SmErpUnitEntity unit = unitMap.get(unitKey);
if (unit != null) {
auxiliaryCode.setUnitId(unit.getId());
} else {
return R.failed("找不到对应的包装单位:" + auxiliaryCode.getUnit() + ",口味:" + (auxiliaryCode.getTaste() != null ? auxiliaryCode.getTaste() : "无"));
}
}
}
@@ -0,0 +1,25 @@
<?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.ShopSkuMapper">
<resultMap id="shopSkuMap" type="com.bsd.pjcloud.supermarket.entity.ShopSkuEntity">
<id property="id" column="id"/>
<result property="barCode" column="bar_code"/>
<result property="spec" column="spec"/>
<result property="unit" column="unit"/>
<result property="status" column="status"/>
<result property="purchasePrice" column="purchase_price"/>
<result property="retailPrice" column="retail_price"/>
<result property="spuId" column="spu_id"/>
<result property="promotionPrice" column="promotion_price"/>
<result property="stock" column="stock"/>
<result property="attribute" column="attribute"/>
<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>
@@ -0,0 +1,31 @@
<?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.ShopSpuMapper">
<resultMap id="shopSpuMap" type="com.bsd.pjcloud.supermarket.entity.ShopSpuEntity">
<id property="id" column="id"/>
<result property="productCode" column="product_code"/>
<result property="productName" column="product_name"/>
<result property="introduction" column="introduction"/>
<result property="description" column="description"/>
<result property="categoryId" column="category_id"/>
<result property="picUrl" column="pic_url"/>
<result property="sliderPicUrls" column="slider_pic_urls"/>
<result property="sort" column="sort"/>
<result property="status" column="status"/>
<result property="stock" column="stock"/>
<result property="giveIntegral" column="give_integral"/>
<result property="merchantRelationId" column="merchant_relation_id"/>
<result property="deptId" column="dept_id"/>
<result property="shopSkuId" column="shop_sku_id"/>
<result property="salesCount" column="sales_count"/>
<result property="limitNum" column="limit_num"/>
<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>