This commit is contained in:
雷欧(林平凡)
2025-08-18 17:55:16 +08:00
parent 3d9d43f1eb
commit 691ac6798e
13 changed files with 878 additions and 2 deletions

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"java.compile.nullAnalysis.mode": "automatic"
}

View File

@@ -5,6 +5,11 @@ import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.domain.R;
import com.ruoyi.erp.domain.*; import com.ruoyi.erp.domain.*;
import com.ruoyi.jarvis.service.IOuterIdGeneratorService;
import org.springframework.beans.factory.annotation.Autowired;
import com.ruoyi.common.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ruoyi.erp.request.ERPAccount; import com.ruoyi.erp.request.ERPAccount;
import com.ruoyi.erp.request.ProductCreateRequest; import com.ruoyi.erp.request.ProductCreateRequest;
import com.ruoyi.erp.request.ProductCategoryListQueryRequest; import com.ruoyi.erp.request.ProductCategoryListQueryRequest;
@@ -27,6 +32,11 @@ import java.util.List;
@Validated @Validated
public class ProductController extends BaseController { public class ProductController extends BaseController {
@Autowired
private IOuterIdGeneratorService outerIdGeneratorService;
private static final Logger log = LoggerFactory.getLogger(ProductController.class);
@PostMapping("/createByPromotion") @PostMapping("/createByPromotion")
public R<?> createByPromotion(@RequestBody @Validated CreateProductFromPromotionRequest req) { public R<?> createByPromotion(@RequestBody @Validated CreateProductFromPromotionRequest req) {
try { try {
@@ -39,7 +49,16 @@ public class ProductController extends BaseController {
erpShop.setPrice(req.getPrice()); erpShop.setPrice(req.getPrice());
erpShop.setExpressFee(req.getExpressFee()); erpShop.setExpressFee(req.getExpressFee());
erpShop.setStock(req.getStock()); erpShop.setStock(req.getStock());
erpShop.setOuterid(req.getOuterId());
// 处理商家编码:如果为空则自动生成
String outerId = req.getOuterId();
if (StringUtils.isEmpty(outerId) && StringUtils.isNotEmpty(req.getSkuid())) {
outerId = outerIdGeneratorService.generateOuterId(req.getSkuid());
if (StringUtils.isNotEmpty(outerId)) {
log.info("自动生成商家编码: skuid={}, outerId={}", req.getSkuid(), outerId);
}
}
erpShop.setOuterid(outerId);
erpShop.setStuffStatus(req.getStuffStatus()); erpShop.setStuffStatus(req.getStuffStatus());
// 发布店铺(必填) // 发布店铺(必填)
@@ -90,7 +109,27 @@ public class ProductController extends BaseController {
JSONObject body = JSONObject.parseObject(JSON.toJSONString(erpShop)); JSONObject body = JSONObject.parseObject(JSON.toJSONString(erpShop));
createRequest.setRequestBody(body); createRequest.setRequestBody(body);
String resp = createRequest.getResponseBody(); String resp = createRequest.getResponseBody();
return R.ok(JSONObject.parse(resp));
// 解析响应并添加生成的outerId
JSONObject responseData = JSONObject.parseObject(resp);
if (responseData != null && responseData.getInteger("code") == 0) {
// 如果发品成功在响应中添加生成的outerId
if (StringUtils.isNotEmpty(outerId)) {
if (responseData.get("data") instanceof JSONObject) {
JSONObject data = responseData.getJSONObject("data");
data.put("outer_id", outerId);
data.put("outerId", outerId);
} else {
// 如果没有data字段创建一个
JSONObject data = new JSONObject();
data.put("outer_id", outerId);
data.put("outerId", outerId);
responseData.put("data", data);
}
}
}
return R.ok(responseData);
} catch (Exception e) { } catch (Exception e) {
return R.fail("创建失败: " + e.getMessage()); return R.fail("创建失败: " + e.getMessage());
} }
@@ -374,6 +413,7 @@ public class ProductController extends BaseController {
private String whiteImages; private String whiteImages;
private String serviceSupport; // 多个用逗号分隔 private String serviceSupport; // 多个用逗号分隔
private String outerId; private String outerId;
private String skuid; // SKUID用于自动生成商家编码
private Integer stuffStatus; private Integer stuffStatus;
private List<SkuItemDto> skuItems; private List<SkuItemDto> skuItems;
@@ -412,6 +452,8 @@ public class ProductController extends BaseController {
public void setServiceSupport(String serviceSupport) { this.serviceSupport = serviceSupport; } public void setServiceSupport(String serviceSupport) { this.serviceSupport = serviceSupport; }
public String getOuterId() { return outerId; } public String getOuterId() { return outerId; }
public void setOuterId(String outerId) { this.outerId = outerId; } public void setOuterId(String outerId) { this.outerId = outerId; }
public String getSkuid() { return skuid; }
public void setSkuid(String skuid) { this.skuid = skuid; }
public Integer getStuffStatus() { return stuffStatus; } public Integer getStuffStatus() { return stuffStatus; }
public void setStuffStatus(Integer stuffStatus) { this.stuffStatus = stuffStatus; } public void setStuffStatus(Integer stuffStatus) { this.stuffStatus = stuffStatus; }
public List<SkuItemDto> getSkuItems() { return skuItems; } public List<SkuItemDto> getSkuItems() { return skuItems; }

View File

@@ -185,4 +185,14 @@ public class FavoriteProductController extends BaseController
{ {
return toAjax(favoriteProductService.updateUseCountAndTime(id)); return toAjax(favoriteProductService.updateUseCountAndTime(id));
} }
/**
* 更新发品信息
*/
@PreAuthorize("@ss.hasPermi('jarvis:favoriteProduct:edit')")
@PutMapping("/updateProductInfo")
public AjaxResult updateProductInfo(@RequestBody FavoriteProduct favoriteProduct)
{
return toAjax(favoriteProductService.updateProductInfo(favoriteProduct));
}
} }

View File

@@ -0,0 +1,106 @@
package com.ruoyi.web.controller.jarvis;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jarvis.domain.PrdErrorTip;
import com.ruoyi.jarvis.service.IPrdErrorTipService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 商品错误提示Controller
*
* @author ruoyi
* @date 2024-01-01
*/
@RestController
@RequestMapping("/jarvis/prdErrorTip")
public class PrdErrorTipController extends BaseController
{
@Autowired
private IPrdErrorTipService prdErrorTipService;
/**
* 查询商品错误提示列表
*/
@GetMapping("/list")
public TableDataInfo list(PrdErrorTip prdErrorTip)
{
startPage();
List<PrdErrorTip> list = prdErrorTipService.selectPrdErrorTipList(prdErrorTip);
return getDataTable(list);
}
/**
* 导出商品错误提示列表
*/
@Log(title = "商品错误提示", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(PrdErrorTip prdErrorTip)
{
List<PrdErrorTip> list = prdErrorTipService.selectPrdErrorTipList(prdErrorTip);
ExcelUtil<PrdErrorTip> util = new ExcelUtil<PrdErrorTip>(PrdErrorTip.class);
return util.exportExcel(list, "商品错误提示数据");
}
/**
* 获取商品错误提示详细信息
*/
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(prdErrorTipService.selectPrdErrorTipById(id));
}
/**
* 新增商品错误提示
*/
@Log(title = "商品错误提示", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody PrdErrorTip prdErrorTip)
{
return toAjax(prdErrorTipService.insertPrdErrorTip(prdErrorTip));
}
/**
* 修改商品错误提示
*/
@Log(title = "商品错误提示", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody PrdErrorTip prdErrorTip)
{
return toAjax(prdErrorTipService.updatePrdErrorTip(prdErrorTip));
}
/**
* 删除商品错误提示
*/
@Log(title = "商品错误提示", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(prdErrorTipService.deletePrdErrorTipByIds(ids));
}
/**
* 根据错误代码和子代码查询错误提示
*/
@GetMapping("/getByCode/{errCode}/{errSubCode}")
public AjaxResult getByCode(@PathVariable String errCode, @PathVariable String errSubCode)
{
return success(prdErrorTipService.selectPrdErrorTipByCode(errCode, errSubCode));
}
}

View File

@@ -0,0 +1,114 @@
package com.ruoyi.jarvis.domain;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 商品错误提示对象 prd_error_tip
*
* @author ruoyi
* @date 2024-01-01
*/
public class PrdErrorTip extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键ID */
private Long id;
/** 错误代码 */
@Excel(name = "错误代码")
private String errCode;
/** 错误子代码 */
@Excel(name = "错误子代码")
private String errSubCode;
/** 错误消息 */
@Excel(name = "错误消息")
private String errMsg;
/** 错误内容 */
@Excel(name = "错误内容")
private String content;
/** 状态 */
@Excel(name = "状态", readConverterExp = "0=禁用,1=启用")
private Integer status;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setErrCode(String errCode)
{
this.errCode = errCode;
}
public String getErrCode()
{
return errCode;
}
public void setErrSubCode(String errSubCode)
{
this.errSubCode = errSubCode;
}
public String getErrSubCode()
{
return errSubCode;
}
public void setErrMsg(String errMsg)
{
this.errMsg = errMsg;
}
public String getErrMsg()
{
return errMsg;
}
public void setContent(String content)
{
this.content = content;
}
public String getContent()
{
return content;
}
public void setStatus(Integer status)
{
this.status = status;
}
public Integer getStatus()
{
return status;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("errCode", getErrCode())
.append("errSubCode", getErrSubCode())
.append("errMsg", getErrMsg())
.append("content", getContent())
.append("status", getStatus())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@@ -0,0 +1,70 @@
package com.ruoyi.jarvis.mapper;
import java.util.List;
import com.ruoyi.jarvis.domain.PrdErrorTip;
/**
* 商品错误提示Mapper接口
*
* @author ruoyi
* @date 2024-01-01
*/
public interface PrdErrorTipMapper
{
/**
* 查询商品错误提示
*
* @param id 商品错误提示主键
* @return 商品错误提示
*/
public PrdErrorTip selectPrdErrorTipById(Long id);
/**
* 查询商品错误提示列表
*
* @param prdErrorTip 商品错误提示
* @return 商品错误提示集合
*/
public List<PrdErrorTip> selectPrdErrorTipList(PrdErrorTip prdErrorTip);
/**
* 新增商品错误提示
*
* @param prdErrorTip 商品错误提示
* @return 结果
*/
public int insertPrdErrorTip(PrdErrorTip prdErrorTip);
/**
* 修改商品错误提示
*
* @param prdErrorTip 商品错误提示
* @return 结果
*/
public int updatePrdErrorTip(PrdErrorTip prdErrorTip);
/**
* 删除商品错误提示
*
* @param id 商品错误提示主键
* @return 结果
*/
public int deletePrdErrorTipById(Long id);
/**
* 批量删除商品错误提示
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deletePrdErrorTipByIds(Long[] ids);
/**
* 根据错误代码和子代码查询错误提示
*
* @param errCode 错误代码
* @param errSubCode 错误子代码
* @return 商品错误提示
*/
public PrdErrorTip selectPrdErrorTipByCode(String errCode, String errSubCode);
}

View File

@@ -0,0 +1,43 @@
package com.ruoyi.jarvis.service;
/**
* 商家编码自动生成服务接口
*
* @author ruoyi
* @date 2024-01-01
*/
public interface IOuterIdGeneratorService
{
/**
* 根据SKUID生成商家编码
*
* @param skuid SKUID
* @return 生成的商家编码
*/
public String generateOuterId(String skuid);
/**
* 根据SKUID和自定义前缀生成商家编码
*
* @param skuid SKUID
* @param prefix 自定义前缀
* @return 生成的商家编码
*/
public String generateOuterId(String skuid, String prefix);
/**
* 重置SKUID的计数器
*
* @param skuid SKUID
* @return 是否成功
*/
public boolean resetCounter(String skuid);
/**
* 获取SKUID的当前计数器值
*
* @param skuid SKUID
* @return 当前计数器值
*/
public Long getCurrentCounter(String skuid);
}

View File

@@ -0,0 +1,70 @@
package com.ruoyi.jarvis.service;
import java.util.List;
import com.ruoyi.jarvis.domain.PrdErrorTip;
/**
* 商品错误提示Service接口
*
* @author ruoyi
* @date 2024-01-01
*/
public interface IPrdErrorTipService
{
/**
* 查询商品错误提示
*
* @param id 商品错误提示主键
* @return 商品错误提示
*/
public PrdErrorTip selectPrdErrorTipById(Long id);
/**
* 查询商品错误提示列表
*
* @param prdErrorTip 商品错误提示
* @return 商品错误提示集合
*/
public List<PrdErrorTip> selectPrdErrorTipList(PrdErrorTip prdErrorTip);
/**
* 新增商品错误提示
*
* @param prdErrorTip 商品错误提示
* @return 结果
*/
public int insertPrdErrorTip(PrdErrorTip prdErrorTip);
/**
* 修改商品错误提示
*
* @param prdErrorTip 商品错误提示
* @return 结果
*/
public int updatePrdErrorTip(PrdErrorTip prdErrorTip);
/**
* 批量删除商品错误提示
*
* @param ids 需要删除的商品错误提示主键集合
* @return 结果
*/
public int deletePrdErrorTipByIds(Long[] ids);
/**
* 删除商品错误提示信息
*
* @param id 商品错误提示主键
* @return 结果
*/
public int deletePrdErrorTipById(Long id);
/**
* 根据错误代码和子代码查询错误提示
*
* @param errCode 错误代码
* @param errSubCode 错误子代码
* @return 商品错误提示
*/
public PrdErrorTip selectPrdErrorTipByCode(String errCode, String errSubCode);
}

View File

@@ -0,0 +1,141 @@
package com.ruoyi.jarvis.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import com.ruoyi.jarvis.service.IOuterIdGeneratorService;
import com.ruoyi.common.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* 商家编码自动生成服务实现类
*
* @author ruoyi
* @date 2024-01-01
*/
@Service
public class OuterIdGeneratorServiceImpl implements IOuterIdGeneratorService
{
private static final Logger log = LoggerFactory.getLogger(OuterIdGeneratorServiceImpl.class);
@Autowired
private RedisTemplate<String, Object> redisTemplate;
// Redis key前缀
private static final String REDIS_KEY_PREFIX = "outer_id_counter:";
// 默认编号长度
private static final int DEFAULT_NUMBER_LENGTH = 3;
// 默认编号格式
private static final String DEFAULT_NUMBER_FORMAT = "%03d";
/**
* 根据SKUID生成商家编码
*
* @param skuid SKUID
* @return 生成的商家编码
*/
@Override
public String generateOuterId(String skuid) {
if (StringUtils.isEmpty(skuid)) {
log.warn("SKUID为空无法生成商家编码");
return null;
}
return generateOuterId(skuid, skuid);
}
/**
* 根据SKUID和自定义前缀生成商家编码
*
* @param skuid SKUID
* @param prefix 自定义前缀
* @return 生成的商家编码
*/
@Override
public String generateOuterId(String skuid, String prefix) {
if (StringUtils.isEmpty(skuid) || StringUtils.isEmpty(prefix)) {
log.warn("SKUID或前缀为空无法生成商家编码");
return null;
}
try {
// 生成Redis key
String redisKey = REDIS_KEY_PREFIX + skuid;
// 递增计数器
Long counter = redisTemplate.opsForValue().increment(redisKey);
// 格式化编号
String formattedNumber = String.format(DEFAULT_NUMBER_FORMAT, counter);
// 生成商家编码
String outerId = prefix + formattedNumber;
log.info("成功生成商家编码: skuid={}, counter={}, outerId={}", skuid, counter, outerId);
return outerId;
} catch (Exception e) {
log.error("生成商家编码失败: skuid={}, prefix={}", skuid, prefix, e);
return null;
}
}
/**
* 重置SKUID的计数器
*
* @param skuid SKUID
* @return 是否成功
*/
@Override
public boolean resetCounter(String skuid) {
if (StringUtils.isEmpty(skuid)) {
log.warn("SKUID为空无法重置计数器");
return false;
}
try {
String redisKey = REDIS_KEY_PREFIX + skuid;
redisTemplate.delete(redisKey);
log.info("成功重置计数器: skuid={}", skuid);
return true;
} catch (Exception e) {
log.error("重置计数器失败: skuid={}", skuid, e);
return false;
}
}
/**
* 获取SKUID的当前计数器值
*
* @param skuid SKUID
* @return 当前计数器值
*/
@Override
public Long getCurrentCounter(String skuid) {
if (StringUtils.isEmpty(skuid)) {
log.warn("SKUID为空无法获取计数器值");
return 0L;
}
try {
String redisKey = REDIS_KEY_PREFIX + skuid;
Object value = redisTemplate.opsForValue().get(redisKey);
if (value == null) {
return 0L;
}
if (value instanceof Number) {
return ((Number) value).longValue();
}
return Long.valueOf(value.toString());
} catch (Exception e) {
log.error("获取计数器值失败: skuid={}", skuid, e);
return 0L;
}
}
}

View File

@@ -0,0 +1,106 @@
package com.ruoyi.jarvis.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.jarvis.mapper.PrdErrorTipMapper;
import com.ruoyi.jarvis.domain.PrdErrorTip;
import com.ruoyi.jarvis.service.IPrdErrorTipService;
/**
* 商品错误提示Service业务层处理
*
* @author ruoyi
* @date 2024-01-01
*/
@Service
public class PrdErrorTipServiceImpl implements IPrdErrorTipService
{
@Autowired
private PrdErrorTipMapper prdErrorTipMapper;
/**
* 查询商品错误提示
*
* @param id 商品错误提示主键
* @return 商品错误提示
*/
@Override
public PrdErrorTip selectPrdErrorTipById(Long id)
{
return prdErrorTipMapper.selectPrdErrorTipById(id);
}
/**
* 查询商品错误提示列表
*
* @param prdErrorTip 商品错误提示
* @return 商品错误提示
*/
@Override
public List<PrdErrorTip> selectPrdErrorTipList(PrdErrorTip prdErrorTip)
{
return prdErrorTipMapper.selectPrdErrorTipList(prdErrorTip);
}
/**
* 新增商品错误提示
*
* @param prdErrorTip 商品错误提示
* @return 结果
*/
@Override
public int insertPrdErrorTip(PrdErrorTip prdErrorTip)
{
return prdErrorTipMapper.insertPrdErrorTip(prdErrorTip);
}
/**
* 修改商品错误提示
*
* @param prdErrorTip 商品错误提示
* @return 结果
*/
@Override
public int updatePrdErrorTip(PrdErrorTip prdErrorTip)
{
return prdErrorTipMapper.updatePrdErrorTip(prdErrorTip);
}
/**
* 批量删除商品错误提示
*
* @param ids 需要删除的商品错误提示主键
* @return 结果
*/
@Override
public int deletePrdErrorTipByIds(Long[] ids)
{
return prdErrorTipMapper.deletePrdErrorTipByIds(ids);
}
/**
* 删除商品错误提示信息
*
* @param id 商品错误提示主键
* @return 结果
*/
@Override
public int deletePrdErrorTipById(Long id)
{
return prdErrorTipMapper.deletePrdErrorTipById(id);
}
/**
* 根据错误代码和子代码查询错误提示
*
* @param errCode 错误代码
* @param errSubCode 错误子代码
* @return 商品错误提示
*/
@Override
public PrdErrorTip selectPrdErrorTipByCode(String errCode, String errSubCode)
{
return prdErrorTipMapper.selectPrdErrorTipByCode(errCode, errSubCode);
}
}

View File

@@ -0,0 +1,89 @@
<?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.ruoyi.jarvis.mapper.PrdErrorTipMapper">
<resultMap type="PrdErrorTip" id="PrdErrorTipResult">
<result property="id" column="id" />
<result property="errCode" column="err_code" />
<result property="errSubCode" column="err_sub_code" />
<result property="errMsg" column="err_msg" />
<result property="content" column="content" />
<result property="status" column="status" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectPrdErrorTipVo">
select id, err_code, err_sub_code, err_msg, content, status, create_time, update_time
from prd_error_tip
</sql>
<select id="selectPrdErrorTipList" parameterType="PrdErrorTip" resultMap="PrdErrorTipResult">
<include refid="selectPrdErrorTipVo"/>
<where>
<if test="errCode != null and errCode != ''"> and err_code = #{errCode}</if>
<if test="errSubCode != null and errSubCode != ''"> and err_sub_code = #{errSubCode}</if>
<if test="errMsg != null and errMsg != ''"> and err_msg like concat('%', #{errMsg}, '%')</if>
<if test="content != null and content != ''"> and content like concat('%', #{content}, '%')</if>
<if test="status != null "> and status = #{status}</if>
</where>
order by create_time desc
</select>
<select id="selectPrdErrorTipById" parameterType="Long" resultMap="PrdErrorTipResult">
<include refid="selectPrdErrorTipVo"/>
where id = #{id}
</select>
<select id="selectPrdErrorTipByCode" resultMap="PrdErrorTipResult">
<include refid="selectPrdErrorTipVo"/>
where err_code = #{errCode} and err_sub_code = #{errSubCode} and status = 1
</select>
<insert id="insertPrdErrorTip" parameterType="PrdErrorTip" useGeneratedKeys="true" keyProperty="id">
insert into prd_error_tip
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="errCode != null and errCode != ''">err_code,</if>
<if test="errSubCode != null and errSubCode != ''">err_sub_code,</if>
<if test="errMsg != null and errMsg != ''">err_msg,</if>
<if test="content != null and content != ''">content,</if>
<if test="status != null">status,</if>
create_time,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="errCode != null and errCode != ''">#{errCode},</if>
<if test="errSubCode != null and errSubCode != ''">#{errSubCode},</if>
<if test="errMsg != null and errMsg != ''">#{errMsg},</if>
<if test="content != null and content != ''">#{content},</if>
<if test="status != null">#{status},</if>
sysdate(),
</trim>
</insert>
<update id="updatePrdErrorTip" parameterType="PrdErrorTip">
update prd_error_tip
<trim prefix="SET" suffixOverrides=",">
<if test="errCode != null and errCode != ''">err_code = #{errCode},</if>
<if test="errSubCode != null and errSubCode != ''">err_sub_code = #{errSubCode},</if>
<if test="errMsg != null and errMsg != ''">err_msg = #{errMsg},</if>
<if test="content != null and content != ''">content = #{content},</if>
<if test="status != null">status = #{status},</if>
update_time = sysdate(),
</trim>
where id = #{id}
</update>
<delete id="deletePrdErrorTipById" parameterType="Long">
delete from prd_error_tip where id = #{id}
</delete>
<delete id="deletePrdErrorTipByIds" parameterType="String">
delete from prd_error_tip where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

29
sql/prd_error_tip表.sql Normal file
View File

@@ -0,0 +1,29 @@
-- 商品错误提示表
DROP TABLE IF EXISTS `prd_error_tip`;
CREATE TABLE `prd_error_tip` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`err_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '错误代码',
`err_sub_code` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '错误子代码',
`err_msg` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '错误消息',
`content` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '错误内容',
`status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '状态0=禁用,1=启用',
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uk_err_code_sub` (`err_code`, `err_sub_code`),
KEY `idx_status` (`status`),
KEY `idx_create_time` (`create_time`)
) ENGINE = InnoDB AUTO_INCREMENT = 30002 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Compact COMMENT = '商品错误提示表';
-- 插入示例数据
INSERT INTO `prd_error_tip` (`err_code`, `err_sub_code`, `err_msg`, `content`, `status`) VALUES
('PRODUCT_CREATE', 'INVALID_PRICE', '价格无效', '商品价格必须大于0', 1),
('PRODUCT_CREATE', 'INVALID_STOCK', '库存无效', '商品库存必须大于0', 1),
('PRODUCT_CREATE', 'MISSING_TITLE', '标题缺失', '商品标题不能为空', 1),
('PRODUCT_CREATE', 'MISSING_CONTENT', '内容缺失', '商品描述内容不能为空', 1),
('PRODUCT_CREATE', 'INVALID_CATEGORY', '类目无效', '商品类目ID无效', 1),
('PRODUCT_CREATE', 'INVALID_IMAGES', '图片无效', '商品图片不能为空', 1),
('PRODUCT_CREATE', 'DUPLICATE_OUTER_ID', '商家编码重复', '商家编码已存在,请使用其他编码', 1),
('PRODUCT_CREATE', 'INVALID_OUTER_ID', '商家编码无效', '商家编码格式不正确', 1),
('PRODUCT_CREATE', 'MISSING_USERNAME', '会员名缺失', '闲鱼会员名不能为空', 1),
('PRODUCT_CREATE', 'INVALID_REGION', '地区信息无效', '省市区信息不完整', 1);

53
sql/常用商品表.sql Normal file
View File

@@ -0,0 +1,53 @@
-- 常用商品表
CREATE TABLE `favorite_product` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`skuid` varchar(100) NOT NULL COMMENT 'SKUID',
`product_name` varchar(500) NOT NULL COMMENT '商品名称',
`shop_name` varchar(200) DEFAULT NULL COMMENT '店铺名称',
`shop_id` varchar(100) DEFAULT NULL COMMENT '店铺ID',
`product_url` varchar(1000) DEFAULT NULL COMMENT '商品链接',
`product_image` varchar(1000) DEFAULT NULL COMMENT '商品图片',
`price` varchar(50) DEFAULT NULL COMMENT '商品价格',
`commission_info` varchar(200) DEFAULT NULL COMMENT '佣金信息',
`is_top` tinyint(1) DEFAULT '0' COMMENT '是否置顶(0:否,1:是)',
`sort_weight` int(11) DEFAULT '0' COMMENT '排序权重',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
`create_user_id` bigint(20) DEFAULT NULL COMMENT '创建用户ID',
`create_user_name` varchar(100) DEFAULT NULL COMMENT '创建用户名',
`erp_product_ids` text COMMENT 'ERP商品ID列表(JSON格式)',
`category` varchar(200) DEFAULT NULL COMMENT '商品分类',
`brand` varchar(200) DEFAULT NULL COMMENT '商品品牌',
`last_used_time` datetime DEFAULT NULL COMMENT '最后使用时间',
`use_count` int(11) DEFAULT '0' COMMENT '使用次数',
`product_id` varchar(100) DEFAULT NULL COMMENT '发品后的商品ID',
`product_status` int(11) DEFAULT NULL COMMENT '发品状态',
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_skuid` (`skuid`),
KEY `idx_create_user_id` (`create_user_id`),
KEY `idx_is_top_sort` (`is_top`, `sort_weight`),
KEY `idx_product_name` (`product_name`),
KEY `idx_shop_name` (`shop_name`),
KEY `idx_product_id` (`product_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='常用商品表';
-- ERP商品关联表
CREATE TABLE `erp_product_relation` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`favorite_product_id` bigint(20) NOT NULL COMMENT '常用商品ID',
`appid` varchar(100) NOT NULL COMMENT 'ERP应用ID',
`erp_product_id` varchar(100) NOT NULL COMMENT 'ERP商品ID',
`erp_product_title` varchar(500) DEFAULT NULL COMMENT 'ERP商品标题',
`erp_product_url` varchar(1000) DEFAULT NULL COMMENT 'ERP商品链接',
`erp_product_status` varchar(50) DEFAULT 'active' COMMENT 'ERP商品状态',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_favorite_appid_erp` (`favorite_product_id`, `appid`, `erp_product_id`),
KEY `idx_favorite_product_id` (`favorite_product_id`),
KEY `idx_appid` (`appid`),
KEY `idx_erp_product_id` (`erp_product_id`),
CONSTRAINT `fk_erp_favorite_product` FOREIGN KEY (`favorite_product_id`) REFERENCES `favorite_product` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='ERP商品关联表';