rename GaoStockRecord to GaoProductStockRecord

This commit is contained in:
Timi
2026-09-04 10:37:43 +08:00
parent 913dc3d278
commit df16ac3c8e
23 changed files with 377 additions and 197 deletions
@@ -1,18 +1,28 @@
<?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.imyeyu.api.modules.gao.mapper.GaoStockRecordMapper">
<select id="selectByRequestNo" resultType="com.imyeyu.api.modules.gao.entity.GaoStockRecord">
SELECT * FROM `gao_stock_record`
<mapper namespace="com.imyeyu.api.modules.gao.mapper.GaoProductStockRecordMapper">
<select id="selectByRequestNo" resultType="com.imyeyu.api.modules.gao.entity.GaoProductStockRecord">
SELECT * FROM `gao_product_stock_record`
WHERE `store_id` = #{storeId} AND `request_no` = #{requestNo}
ORDER BY `product_id`, `id`
</select>
<select id="selectByBiz" resultType="com.imyeyu.api.modules.gao.entity.GaoStockRecord">
SELECT * FROM `gao_stock_record`
<select id="selectForUpdate" resultType="com.imyeyu.api.modules.gao.entity.GaoProductStockRecord">
SELECT * FROM `gao_product_stock_record`
WHERE `id` = #{id}
FOR UPDATE
</select>
<select id="selectRevokeBySourceRecordId" resultType="com.imyeyu.api.modules.gao.entity.GaoProductStockRecord">
SELECT * FROM `gao_product_stock_record`
WHERE `source_record_id` = #{sourceRecordId}
LIMIT 1
</select>
<select id="selectByBiz" resultType="com.imyeyu.api.modules.gao.entity.GaoProductStockRecord">
SELECT * FROM `gao_product_stock_record`
WHERE `biz_type` = #{bizType} AND `biz_id` = #{bizId}
ORDER BY `occurred_at`, `id`
</select>
<select id="selectByBizProduct" resultType="com.imyeyu.api.modules.gao.entity.GaoStockRecord">
SELECT * FROM `gao_stock_record`
<select id="selectByBizProduct" resultType="com.imyeyu.api.modules.gao.entity.GaoProductStockRecord">
SELECT * FROM `gao_product_stock_record`
WHERE `biz_type` = #{bizType} AND `biz_id` = #{bizId} AND `product_id` = #{productId} AND `operation_type` = #{operationType}
ORDER BY `occurred_at`, `id`
LIMIT 1
@@ -21,6 +31,7 @@
1 = 1
<if test="storeId != null and storeId != ''">AND r.`store_id` = #{storeId}</if>
<if test="productId != null and productId != ''">AND r.`product_id` = #{productId}</if>
<if test="keyword != null and keyword.trim() != ''">AND (r.`product_name_snapshot` LIKE CONCAT('%', #{keyword}, '%') OR p.`name` LIKE CONCAT('%', #{keyword}, '%') OR p.`code` LIKE CONCAT('%', #{keyword}, '%'))</if>
<if test="bizType != null">AND r.`biz_type` = #{bizType}</if>
<if test="bizId != null and bizId != ''">AND r.`biz_id` = #{bizId}</if>
<if test="operationType != null">AND r.`operation_type` = #{operationType}</if>
@@ -28,10 +39,10 @@
<if test="endAt != null">AND r.`occurred_at` &lt;= #{endAt}</if>
</sql>
<select id="countByQuery" resultType="long">
SELECT COUNT(1) FROM `gao_stock_record` r WHERE <include refid="queryWhere"/>
SELECT COUNT(1) FROM `gao_product_stock_record` r LEFT JOIN `gao_product` p ON p.`id` = r.`product_id` AND p.`store_id` = r.`store_id` WHERE <include refid="queryWhere"/>
</select>
<select id="selectByQuery" resultType="com.imyeyu.api.modules.gao.entity.GaoStockRecord">
SELECT r.* FROM `gao_stock_record` r WHERE <include refid="queryWhere"/>
<select id="selectByQuery" resultType="com.imyeyu.api.modules.gao.entity.GaoProductStockRecord">
SELECT r.* FROM `gao_product_stock_record` r LEFT JOIN `gao_product` p ON p.`id` = r.`product_id` AND p.`store_id` = r.`store_id` WHERE <include refid="queryWhere"/>
ORDER BY r.`occurred_at` DESC, r.`id` DESC
LIMIT #{offset}, #{limit}
</select>