Files
TimiServerAPI/src/main/resources/mapper/timi-server/gao/GaoPointLedgerMapper.xml
T
Timi 4963988ec2
CI / build-deploy (pull_request) Successful in 30s
CI / notify-on-failure (pull_request) Skipped
v1.0.20
2026-08-21 15:25:04 +08:00

69 lines
2.0 KiB
XML

<?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.GaoPointLedgerMapper">
<select id="selectByIdempotencyKey" resultType="com.imyeyu.api.modules.gao.entity.GaoPointLedger">
SELECT *
FROM `gao_point_ledger`
WHERE `idempotency_key` = #{idempotencyKey}
AND `deleted_at` IS NULL
LIMIT 1
</select>
<select id="selectRuleChangeByEventRecordId" resultType="com.imyeyu.api.modules.gao.entity.GaoPointLedger">
SELECT *
FROM `gao_point_ledger`
WHERE `event_record_id` = #{eventRecordId}
AND `change_type` IN ('EARN', 'CONSUME')
AND `deleted_at` IS NULL
ORDER BY `created_at` ASC, `id` ASC
</select>
<select id="selectByIdempotencyKeyList" resultType="com.imyeyu.api.modules.gao.entity.GaoPointLedger">
SELECT *
FROM `gao_point_ledger`
WHERE `deleted_at` IS NULL
AND `idempotency_key` IN
<foreach collection="idempotencyKeyList" item="idempotencyKey" open="(" separator="," close=")">
#{idempotencyKey}
</foreach>
</select>
<sql id="queryWhere">
`deleted_at` IS NULL
<if test="storeId != null and storeId != ''">
AND `store_id` = #{storeId}
</if>
<if test="customerId != null and customerId != ''">
AND `customer_id` = #{customerId}
</if>
<if test="accountId != null and accountId != ''">
AND `account_id` = #{accountId}
</if>
<if test="changeType != null">
AND `change_type` = #{changeType}
</if>
<if test="beginAt != null">
AND `occurred_at` &gt;= #{beginAt}
</if>
<if test="endAt != null">
AND `occurred_at` &lt;= #{endAt}
</if>
</sql>
<select id="countByQuery" resultType="long">
SELECT COUNT(1)
FROM `gao_point_ledger`
WHERE
<include refid="queryWhere"/>
</select>
<select id="selectByQuery" resultType="com.imyeyu.api.modules.gao.entity.GaoPointLedger">
SELECT *
FROM `gao_point_ledger`
WHERE
<include refid="queryWhere"/>
ORDER BY `occurred_at` DESC, `created_at` DESC
LIMIT #{offset}, #{limit}
</select>
</mapper>