feat(pricing): 新增打印小票和查询券码批次配置功能

- 新增 AppClaimController 控制器处理移动设备端的领券请求
- 实现 ClaimReq 和 ClaimResp 模型类用于领券请求和响应
- 在 VoucherPrintService 接口中新增打印小票方法
- 在VoucherPrintServiceImpl 中实现打印小票和查询券码批次配置的逻辑
- 更新 PriceVoucherBatchConfigMapper 接口和 XML 文件,添加查询券码批次配置的方法
This commit is contained in:
2025-08-30 11:41:37 +08:00
parent 1ac375e491
commit b1deabc7c1
9 changed files with 337 additions and 13 deletions

View File

@@ -0,0 +1,84 @@
<?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="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,
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.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>