You've already forked FrameTour-BE
refactor(mybatis): 移除 XML 配置,使用注解替代
- 在 PriceVoucherBatchConfigMapper、PriceVoucherCodeMapper 和 VoucherPrintRecordMapper 中添加了 @Select 和 @Update 注解 - 删除了对应的 XML 配置文件 - 优化了 SQL 查询,直接在 Java 接口中定义
This commit is contained in:
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ycwl.basic.pricing.entity.PriceVoucherBatchConfig;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -19,7 +21,12 @@ public interface PriceVoucherBatchConfigMapper extends BaseMapper<PriceVoucherBa
|
||||
* @param brokerId 推客ID
|
||||
* @return 批次列表
|
||||
*/
|
||||
List<PriceVoucherBatchConfig> selectActiveBatchesByScenicAndBroker(@Param("scenicId") Long scenicId,
|
||||
@Select("SELECT id, batch_name, scenic_id, broker_id, discount_type, discount_value, applicable_products, " +
|
||||
"total_count, used_count, claimed_count, status, create_time, update_time, " +
|
||||
"create_by, update_by, deleted, deleted_at " +
|
||||
"FROM price_voucher_batch_config WHERE scenic_id = #{scenicId} AND broker_id = #{brokerId} " +
|
||||
"AND status = 1 AND deleted = 0 ORDER BY create_time DESC")
|
||||
List<PriceVoucherBatchConfig> selectActiveBatchesByScenicAndBroker(@Param("scenicId") Long scenicId,
|
||||
@Param("brokerId") Long brokerId);
|
||||
|
||||
/**
|
||||
@@ -28,6 +35,8 @@ public interface PriceVoucherBatchConfigMapper extends BaseMapper<PriceVoucherBa
|
||||
* @param increment 增量(可为负数)
|
||||
* @return 影响行数
|
||||
*/
|
||||
@Update("UPDATE price_voucher_batch_config SET claimed_count = claimed_count + #{increment}, " +
|
||||
"update_time = NOW() WHERE id = #{batchId} AND deleted = 0")
|
||||
int updateClaimedCount(@Param("batchId") Long batchId, @Param("increment") Integer increment);
|
||||
|
||||
/**
|
||||
@@ -36,6 +45,8 @@ public interface PriceVoucherBatchConfigMapper extends BaseMapper<PriceVoucherBa
|
||||
* @param increment 增量(可为负数)
|
||||
* @return 影响行数
|
||||
*/
|
||||
@Update("UPDATE price_voucher_batch_config SET used_count = used_count + #{increment}, " +
|
||||
"update_time = NOW() WHERE id = #{batchId} AND deleted = 0")
|
||||
int updateUsedCount(@Param("batchId") Long batchId, @Param("increment") Integer increment);
|
||||
|
||||
/**
|
||||
@@ -43,6 +54,10 @@ public interface PriceVoucherBatchConfigMapper extends BaseMapper<PriceVoucherBa
|
||||
* @param batchId 批次ID
|
||||
* @return 统计信息
|
||||
*/
|
||||
@Select("SELECT id, batch_name, scenic_id, broker_id, discount_type, discount_value, applicable_products, " +
|
||||
"total_count, used_count, claimed_count, status, create_time, update_time, " +
|
||||
"create_by, update_by, deleted, deleted_at " +
|
||||
"FROM price_voucher_batch_config WHERE id = #{batchId} AND deleted = 0")
|
||||
PriceVoucherBatchConfig selectBatchStats(@Param("batchId") Long batchId);
|
||||
|
||||
/**
|
||||
@@ -50,5 +65,10 @@ public interface PriceVoucherBatchConfigMapper extends BaseMapper<PriceVoucherBa
|
||||
* @param voucherCode 券码
|
||||
* @return 券码批次配置
|
||||
*/
|
||||
@Select("SELECT b.id, b.batch_name, b.scenic_id, b.broker_id, b.discount_type, b.discount_value, b.applicable_products, " +
|
||||
"b.total_count, b.used_count, b.claimed_count, b.status, b.create_time, b.update_time, " +
|
||||
"b.create_by, b.update_by, b.deleted, b.deleted_at " +
|
||||
"FROM price_voucher_batch_config b INNER JOIN price_voucher_code c ON b.id = c.batch_id " +
|
||||
"WHERE c.code = #{voucherCode} AND b.deleted = 0 AND c.deleted = 0")
|
||||
PriceVoucherBatchConfig selectByVoucherCode(@Param("voucherCode") String voucherCode);
|
||||
}
|
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ycwl.basic.pricing.entity.PriceVoucherCode;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
@@ -19,6 +21,9 @@ public interface PriceVoucherCodeMapper extends BaseMapper<PriceVoucherCode> {
|
||||
* @param code 券码
|
||||
* @return 券码信息
|
||||
*/
|
||||
@Select("SELECT id, batch_id, scenic_id, code, status, face_id, claimed_time, used_time, " +
|
||||
"current_use_count, last_used_time, remark, create_time, update_time, deleted, deleted_at " +
|
||||
"FROM price_voucher_code WHERE code = #{code} AND deleted = 0 LIMIT 1")
|
||||
PriceVoucherCode selectByCode(@Param("code") String code);
|
||||
|
||||
/**
|
||||
@@ -27,6 +32,7 @@ public interface PriceVoucherCodeMapper extends BaseMapper<PriceVoucherCode> {
|
||||
* @param scenicId 景区ID
|
||||
* @return 数量
|
||||
*/
|
||||
@Select("SELECT COUNT(1) FROM price_voucher_code WHERE face_id = #{faceId} AND scenic_id = #{scenicId} AND deleted = 0")
|
||||
Integer countByFaceIdAndScenicId(@Param("faceId") Long faceId, @Param("scenicId") Long scenicId);
|
||||
|
||||
/**
|
||||
@@ -35,7 +41,11 @@ public interface PriceVoucherCodeMapper extends BaseMapper<PriceVoucherCode> {
|
||||
* @param scenicId 景区ID
|
||||
* @return 券码列表
|
||||
*/
|
||||
List<PriceVoucherCode> selectAvailableVouchersByFaceIdAndScenicId(@Param("faceId") Long faceId,
|
||||
@Select("SELECT id, batch_id, scenic_id, code, status, face_id, claimed_time, used_time, " +
|
||||
"current_use_count, last_used_time, remark, create_time, update_time, deleted, deleted_at " +
|
||||
"FROM price_voucher_code WHERE face_id = #{faceId} AND scenic_id = #{scenicId} AND status = 1 AND deleted = 0 " +
|
||||
"ORDER BY claimed_time DESC")
|
||||
List<PriceVoucherCode> selectAvailableVouchersByFaceIdAndScenicId(@Param("faceId") Long faceId,
|
||||
@Param("scenicId") Long scenicId);
|
||||
|
||||
/**
|
||||
@@ -44,7 +54,10 @@ public interface PriceVoucherCodeMapper extends BaseMapper<PriceVoucherCode> {
|
||||
* @param limit 限制数量
|
||||
* @return 券码列表
|
||||
*/
|
||||
List<PriceVoucherCode> selectUnclaimedVouchersByBatchId(@Param("batchId") Long batchId,
|
||||
@Select("SELECT id, batch_id, scenic_id, code, status, face_id, claimed_time, used_time, " +
|
||||
"current_use_count, last_used_time, remark, create_time, update_time, deleted, deleted_at " +
|
||||
"FROM price_voucher_code WHERE batch_id = #{batchId} AND status = 0 AND deleted = 0 LIMIT #{limit}")
|
||||
List<PriceVoucherCode> selectUnclaimedVouchersByBatchId(@Param("batchId") Long batchId,
|
||||
@Param("limit") Integer limit);
|
||||
|
||||
/**
|
||||
@@ -54,8 +67,10 @@ public interface PriceVoucherCodeMapper extends BaseMapper<PriceVoucherCode> {
|
||||
* @param claimedTime 领取时间
|
||||
* @return 影响行数
|
||||
*/
|
||||
int claimVoucher(@Param("id") Long id,
|
||||
@Param("faceId") Long faceId,
|
||||
@Update("UPDATE price_voucher_code SET status = 1, face_id = #{faceId}, claimed_time = #{claimedTime}, " +
|
||||
"update_time = NOW() WHERE id = #{id} AND status = 0 AND deleted = 0")
|
||||
int claimVoucher(@Param("id") Long id,
|
||||
@Param("faceId") Long faceId,
|
||||
@Param("claimedTime") LocalDateTime claimedTime);
|
||||
|
||||
/**
|
||||
@@ -63,6 +78,9 @@ public interface PriceVoucherCodeMapper extends BaseMapper<PriceVoucherCode> {
|
||||
* @param batchId 批次ID
|
||||
* @return 券码列表
|
||||
*/
|
||||
@Select("SELECT id, batch_id, scenic_id, code, status, face_id, claimed_time, used_time, " +
|
||||
"current_use_count, last_used_time, remark, create_time, update_time, deleted, deleted_at " +
|
||||
"FROM price_voucher_code WHERE batch_id = #{batchId} AND deleted = 0 ORDER BY create_time DESC")
|
||||
List<PriceVoucherCode> selectByBatchId(@Param("batchId") Long batchId);
|
||||
|
||||
/**
|
||||
@@ -71,7 +89,14 @@ public interface PriceVoucherCodeMapper extends BaseMapper<PriceVoucherCode> {
|
||||
* @param scenicId 景区ID(可选)
|
||||
* @return 券码列表
|
||||
*/
|
||||
List<PriceVoucherCode> selectUserVouchers(@Param("faceId") Long faceId,
|
||||
@Select("<script>" +
|
||||
"SELECT id, batch_id, scenic_id, code, status, face_id, claimed_time, used_time, " +
|
||||
"current_use_count, last_used_time, remark, create_time, update_time, deleted, deleted_at " +
|
||||
"FROM price_voucher_code WHERE face_id = #{faceId}" +
|
||||
"<if test='scenicId != null'> AND scenic_id = #{scenicId}</if>" +
|
||||
" AND deleted = 0 ORDER BY claimed_time DESC" +
|
||||
"</script>")
|
||||
List<PriceVoucherCode> selectUserVouchers(@Param("faceId") Long faceId,
|
||||
@Param("scenicId") Long scenicId);
|
||||
|
||||
/**
|
||||
@@ -79,6 +104,9 @@ public interface PriceVoucherCodeMapper extends BaseMapper<PriceVoucherCode> {
|
||||
* @param batchId 批次ID
|
||||
* @return 可用券码
|
||||
*/
|
||||
@Select("SELECT id, batch_id, scenic_id, code, status, face_id, claimed_time, used_time, " +
|
||||
"current_use_count, last_used_time, remark, create_time, update_time, deleted, deleted_at " +
|
||||
"FROM price_voucher_code WHERE batch_id = #{batchId} AND status = 0 AND deleted = 0 LIMIT 1")
|
||||
PriceVoucherCode findFirstAvailableByBatchId(@Param("batchId") Long batchId);
|
||||
|
||||
/**
|
||||
@@ -86,5 +114,10 @@ public interface PriceVoucherCodeMapper extends BaseMapper<PriceVoucherCode> {
|
||||
* @param scenicId 景区ID
|
||||
* @return 可用券码
|
||||
*/
|
||||
@Select("SELECT pvc.id, pvc.batch_id, pvc.scenic_id, pvc.code, pvc.status, pvc.face_id, pvc.claimed_time, pvc.used_time, " +
|
||||
"pvc.current_use_count, pvc.last_used_time, pvc.remark, pvc.create_time, pvc.update_time, pvc.deleted, pvc.deleted_at " +
|
||||
"FROM price_voucher_code pvc WHERE pvc.scenic_id = #{scenicId} AND pvc.status = 0 AND pvc.deleted = 0 " +
|
||||
"AND NOT EXISTS (SELECT 1 FROM voucher_print_record vpr WHERE vpr.voucher_code_id = pvc.id AND vpr.deleted = 0) " +
|
||||
"ORDER BY RAND() LIMIT 1")
|
||||
PriceVoucherCode findRandomUnprintedVoucher(@Param("scenicId") Long scenicId);
|
||||
}
|
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ycwl.basic.pricing.entity.VoucherPrintRecord;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
/**
|
||||
* 优惠券打印记录Mapper
|
||||
@@ -17,6 +19,9 @@ public interface VoucherPrintRecordMapper extends BaseMapper<VoucherPrintRecord>
|
||||
* @param scenicId 景区ID
|
||||
* @return 打印记录
|
||||
*/
|
||||
@Select("SELECT id, code, face_id, broker_id, scenic_id, voucher_code_id, voucher_code, " +
|
||||
"print_status, error_message, create_time, update_time, deleted, deleted_at " +
|
||||
"FROM voucher_print_record WHERE face_id = #{faceId} AND scenic_id = #{scenicId} AND deleted = 0 LIMIT 1")
|
||||
VoucherPrintRecord selectByFaceBrokerScenic(@Param("faceId") Long faceId,
|
||||
@Param("scenicId") Long scenicId);
|
||||
|
||||
@@ -25,6 +30,9 @@ public interface VoucherPrintRecordMapper extends BaseMapper<VoucherPrintRecord>
|
||||
* @param voucherCodeId 券码ID
|
||||
* @return 打印记录
|
||||
*/
|
||||
@Select("SELECT id, code, face_id, broker_id, scenic_id, voucher_code_id, voucher_code, " +
|
||||
"print_status, error_message, create_time, update_time, deleted, deleted_at " +
|
||||
"FROM voucher_print_record WHERE voucher_code_id = #{voucherCodeId} AND deleted = 0 LIMIT 1")
|
||||
VoucherPrintRecord selectByVoucherCodeId(@Param("voucherCodeId") Long voucherCodeId);
|
||||
|
||||
/**
|
||||
@@ -34,7 +42,9 @@ public interface VoucherPrintRecordMapper extends BaseMapper<VoucherPrintRecord>
|
||||
* @param errorMessage 错误信息(可为null)
|
||||
* @return 影响行数
|
||||
*/
|
||||
int updatePrintStatus(@Param("id") Long id,
|
||||
@Param("printStatus") Integer printStatus,
|
||||
@Update("UPDATE voucher_print_record SET print_status = #{printStatus}, error_message = #{errorMessage}, " +
|
||||
"update_time = NOW() WHERE id = #{id}")
|
||||
int updatePrintStatus(@Param("id") Long id,
|
||||
@Param("printStatus") Integer printStatus,
|
||||
@Param("errorMessage") String errorMessage);
|
||||
}
|
@@ -1,85 +0,0 @@
|
||||
<?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.ycwl.basic.pricing.mapper.PriceVoucherBatchConfigMapper">
|
||||
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="com.ycwl.basic.pricing.entity.PriceVoucherBatchConfig">
|
||||
<id column="id" property="id" />
|
||||
<result column="batch_name" property="batchName" />
|
||||
<result column="scenic_id" property="scenicId" />
|
||||
<result column="broker_id" property="brokerId" />
|
||||
<result column="discount_type" property="discountType" />
|
||||
<result column="discount_value" property="discountValue" />
|
||||
<result column="applicable_products" property="applicableProductsJson" />
|
||||
<result column="total_count" property="totalCount" />
|
||||
<result column="used_count" property="usedCount" />
|
||||
<result column="claimed_count" property="claimedCount" />
|
||||
<result column="status" property="status" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
<result column="create_by" property="createBy" />
|
||||
<result column="update_by" property="updateBy" />
|
||||
<result column="deleted" property="deleted" />
|
||||
<result column="deleted_at" property="deletedAt" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础字段 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, batch_name, scenic_id, broker_id, discount_type, discount_value, applicable_products,
|
||||
total_count, used_count, claimed_count, status, create_time, update_time,
|
||||
create_by, update_by, deleted, deleted_at
|
||||
</sql>
|
||||
|
||||
<!-- 根据景区ID和推客ID查询有效的批次列表 -->
|
||||
<select id="selectActiveBatchesByScenicAndBroker" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM price_voucher_batch_config
|
||||
WHERE scenic_id = #{scenicId}
|
||||
AND broker_id = #{brokerId}
|
||||
AND status = 1
|
||||
AND deleted = 0
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 更新批次的已领取数量 -->
|
||||
<update id="updateClaimedCount">
|
||||
UPDATE price_voucher_batch_config
|
||||
SET claimed_count = claimed_count + #{increment},
|
||||
update_time = NOW()
|
||||
WHERE id = #{batchId}
|
||||
AND deleted = 0
|
||||
</update>
|
||||
|
||||
<!-- 更新批次的已使用数量 -->
|
||||
<update id="updateUsedCount">
|
||||
UPDATE price_voucher_batch_config
|
||||
SET used_count = used_count + #{increment},
|
||||
update_time = NOW()
|
||||
WHERE id = #{batchId}
|
||||
AND deleted = 0
|
||||
</update>
|
||||
|
||||
<!-- 获取批次统计信息 -->
|
||||
<select id="selectBatchStats" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM price_voucher_batch_config
|
||||
WHERE id = #{batchId}
|
||||
AND deleted = 0
|
||||
</select>
|
||||
|
||||
<!-- 根据券码查询对应的券码批次配置 -->
|
||||
<select id="selectByVoucherCode" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
b.id, b.batch_name, b.scenic_id, b.broker_id, b.discount_type, b.discount_value, b.applicable_products,
|
||||
b.total_count, b.used_count, b.claimed_count, b.status, b.create_time, b.update_time,
|
||||
b.create_by, b.update_by, b.deleted, b.deleted_at
|
||||
FROM price_voucher_batch_config b
|
||||
INNER JOIN price_voucher_code c ON b.id = c.batch_id
|
||||
WHERE c.code = #{voucherCode}
|
||||
AND b.deleted = 0
|
||||
AND c.deleted = 0
|
||||
</select>
|
||||
|
||||
</mapper>
|
@@ -1,119 +0,0 @@
|
||||
<?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.ycwl.basic.pricing.mapper.PriceVoucherCodeMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.ycwl.basic.pricing.entity.PriceVoucherCode">
|
||||
<id column="id" property="id" jdbcType="BIGINT"/>
|
||||
<result column="batch_id" property="batchId" jdbcType="BIGINT"/>
|
||||
<result column="scenic_id" property="scenicId" jdbcType="BIGINT"/>
|
||||
<result column="code" property="code" jdbcType="VARCHAR"/>
|
||||
<result column="status" property="status" jdbcType="TINYINT"/>
|
||||
<result column="face_id" property="faceId" jdbcType="BIGINT"/>
|
||||
<result column="claimed_time" property="claimedTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="used_time" property="usedTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="current_use_count" property="currentUseCount" jdbcType="INTEGER"/>
|
||||
<result column="last_used_time" property="lastUsedTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="remark" property="remark" jdbcType="VARCHAR"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="deleted" property="deleted" jdbcType="TINYINT"/>
|
||||
<result column="deleted_at" property="deletedAt" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id, batch_id, scenic_id, code, status, face_id, claimed_time, used_time,
|
||||
current_use_count, last_used_time, remark, create_time, update_time, deleted, deleted_at
|
||||
</sql>
|
||||
|
||||
<select id="selectByCode" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM price_voucher_code
|
||||
WHERE code = #{code}
|
||||
AND deleted = 0
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="countByFaceIdAndScenicId" resultType="java.lang.Integer">
|
||||
SELECT COUNT(1)
|
||||
FROM price_voucher_code
|
||||
WHERE face_id = #{faceId}
|
||||
AND scenic_id = #{scenicId}
|
||||
AND deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="selectAvailableVouchersByFaceIdAndScenicId" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM price_voucher_code
|
||||
WHERE face_id = #{faceId}
|
||||
AND scenic_id = #{scenicId}
|
||||
AND status = 1
|
||||
AND deleted = 0
|
||||
ORDER BY claimed_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectUnclaimedVouchersByBatchId" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM price_voucher_code
|
||||
WHERE batch_id = #{batchId}
|
||||
AND status = 0
|
||||
AND deleted = 0
|
||||
LIMIT #{limit}
|
||||
</select>
|
||||
|
||||
<update id="claimVoucher">
|
||||
UPDATE price_voucher_code
|
||||
SET status = 1,
|
||||
face_id = #{faceId},
|
||||
claimed_time = #{claimedTime},
|
||||
update_time = NOW()
|
||||
WHERE id = #{id}
|
||||
AND status = 0
|
||||
AND deleted = 0
|
||||
</update>
|
||||
|
||||
|
||||
|
||||
<select id="selectByBatchId" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM price_voucher_code
|
||||
WHERE batch_id = #{batchId}
|
||||
AND deleted = 0
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectUserVouchers" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM price_voucher_code
|
||||
WHERE face_id = #{faceId}
|
||||
<if test="scenicId != null">
|
||||
AND scenic_id = #{scenicId}
|
||||
</if>
|
||||
AND deleted = 0
|
||||
ORDER BY claimed_time DESC
|
||||
</select>
|
||||
|
||||
<select id="findFirstAvailableByBatchId" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM price_voucher_code
|
||||
WHERE batch_id = #{batchId}
|
||||
AND status = 0
|
||||
AND deleted = 0
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="findRandomUnprintedVoucher" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM price_voucher_code pvc
|
||||
WHERE pvc.scenic_id = #{scenicId}
|
||||
AND pvc.status = 0
|
||||
AND pvc.deleted = 0
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM voucher_print_record vpr
|
||||
WHERE vpr.voucher_code_id = pvc.id
|
||||
AND vpr.deleted = 0
|
||||
)
|
||||
ORDER BY RAND()
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
@@ -1,51 +0,0 @@
|
||||
<?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.ycwl.basic.pricing.mapper.VoucherPrintRecordMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.ycwl.basic.pricing.entity.VoucherPrintRecord">
|
||||
<id column="id" property="id" jdbcType="BIGINT"/>
|
||||
<result column="code" property="code" jdbcType="VARCHAR"/>
|
||||
<result column="face_id" property="faceId" jdbcType="BIGINT"/>
|
||||
<result column="broker_id" property="brokerId" jdbcType="BIGINT"/>
|
||||
<result column="scenic_id" property="scenicId" jdbcType="BIGINT"/>
|
||||
<result column="voucher_code_id" property="voucherCodeId" jdbcType="BIGINT"/>
|
||||
<result column="voucher_code" property="voucherCode" jdbcType="VARCHAR"/>
|
||||
<result column="print_status" property="printStatus" jdbcType="TINYINT"/>
|
||||
<result column="error_message" property="errorMessage" jdbcType="VARCHAR"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="deleted" property="deleted" jdbcType="TINYINT"/>
|
||||
<result column="deleted_at" property="deletedAt" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id, code, face_id, broker_id, scenic_id, voucher_code_id, voucher_code,
|
||||
print_status, error_message, create_time, update_time, deleted, deleted_at
|
||||
</sql>
|
||||
|
||||
<select id="selectByFaceBrokerScenic" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM voucher_print_record
|
||||
WHERE face_id = #{faceId}
|
||||
AND scenic_id = #{scenicId}
|
||||
AND deleted = 0
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectByVoucherCodeId" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM voucher_print_record
|
||||
WHERE voucher_code_id = #{voucherCodeId}
|
||||
AND deleted = 0
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<update id="updatePrintStatus">
|
||||
UPDATE voucher_print_record
|
||||
SET print_status = #{printStatus},
|
||||
error_message = #{errorMessage},
|
||||
update_time = NOW()
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
</mapper>
|
Reference in New Issue
Block a user