You've already forked FrameTour-BE
Merge branch 'price_inquery'
This commit is contained in:
126
src/main/resources/mapper/PriceVoucherCodeMapper.xml
Normal file
126
src/main/resources/mapper/PriceVoucherCodeMapper.xml
Normal file
@@ -0,0 +1,126 @@
|
||||
<?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="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,
|
||||
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>
|
||||
|
||||
<update id="useVoucher">
|
||||
UPDATE price_voucher_code
|
||||
SET status = 2,
|
||||
used_time = #{usedTime},
|
||||
remark = #{remark},
|
||||
update_time = NOW()
|
||||
WHERE code = #{code}
|
||||
AND status = 1
|
||||
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>
|
51
src/main/resources/mapper/VoucherPrintRecordMapper.xml
Normal file
51
src/main/resources/mapper/VoucherPrintRecordMapper.xml
Normal file
@@ -0,0 +1,51 @@
|
||||
<?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