add groovy script

This commit is contained in:
Timi
2026-09-04 20:38:17 +08:00
parent df16ac3c8e
commit 41f692aad9
53 changed files with 1708 additions and 541 deletions
@@ -0,0 +1,20 @@
<?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.GaoCustomerConsumptionRecordMapper">
<select id="selectBySource" resultType="com.imyeyu.api.modules.gao.entity.GaoCustomerConsumptionRecord">
SELECT * FROM `gao_customer_consumption_record`
WHERE `source_type` = #{sourceType} AND `source_id` = #{sourceId} AND `deleted_at` IS NULL
LIMIT 1
</select>
<select id="selectActiveByWindow" resultType="com.imyeyu.api.modules.gao.entity.GaoCustomerConsumptionRecord">
SELECT * FROM `gao_customer_consumption_record`
WHERE `store_id` = #{storeId} AND `customer_id` = #{customerId} AND `status` = 'ACTIVE'
AND `effective_at` &gt;= #{beginAt} AND `effective_at` &lt;= #{endAt} AND `deleted_at` IS NULL
ORDER BY `effective_at` ASC, `id` ASC
</select>
<update id="revokeBySource">
UPDATE `gao_customer_consumption_record`
SET `status` = 'REVOKED', `revoked_at` = #{revokedAt}, `revoke_reason` = #{revokeReason}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
WHERE `source_type` = #{sourceType} AND `source_id` = #{sourceId} AND `status` = 'ACTIVE' AND `deleted_at` IS NULL
</update>
</mapper>
@@ -26,6 +26,7 @@
WHERE
`store_id` = #{storeId}
AND `status` = '${@com.imyeyu.api.modules.gao.entity.GaoEvent$Status@ACTIVE.name()}'
AND (`biz_type` IS NULL OR `biz_type` != 'LEGACY_CONSUMPTION')
AND (`begin_at` IS NULL OR `begin_at` &lt;= #{now})
AND (`end_at` IS NULL OR #{now} &lt;= `end_at`)
AND `deleted_at` IS NULL
@@ -119,6 +119,12 @@
#{eventId}
</foreach>
</if>
<if test="eventIdList == null or eventIdList.size() == 0">
AND NOT EXISTS (
SELECT 1 FROM `gao_event` re
WHERE re.`id` = r.`event_id` AND re.`biz_type` = 'LEGACY_CONSUMPTION' AND re.`deleted_at` IS NULL
)
</if>
<if test="optionIdList != null and optionIdList.size() > 0">
<foreach collection="optionIdList" item="optionId">
AND EXISTS (
@@ -212,6 +218,12 @@
#{eventId}
</foreach>
</if>
<if test="eventIdList == null or eventIdList.size() == 0">
AND NOT EXISTS (
SELECT 1 FROM `gao_event` re
WHERE re.`id` = r.`event_id` AND re.`biz_type` = 'LEGACY_CONSUMPTION' AND re.`deleted_at` IS NULL
)
</if>
<if test="rankType != null and rankType.name() == 'TOTAL_NUMBER_VALUE'">
AND r.`number_value` IS NOT NULL
</if>
@@ -386,6 +398,12 @@
#{eventId}
</foreach>
</if>
<if test="eventIdList == null or eventIdList.size() == 0">
AND NOT EXISTS (
SELECT 1 FROM `gao_event` re
WHERE re.`id` = r.`event_id` AND re.`biz_type` = 'LEGACY_CONSUMPTION' AND re.`deleted_at` IS NULL
)
</if>
</sql>
<select id="stateDailyByRange" resultType="com.imyeyu.api.modules.gao.vo.GaoEventRecordDailyStatView">
SELECT
@@ -447,6 +465,12 @@
#{eventId}
</foreach>
</if>
<if test="eventIdList == null or eventIdList.size() == 0">
AND NOT EXISTS (
SELECT 1 FROM `gao_event` re
WHERE re.`id` = r.`event_id` AND re.`biz_type` = 'LEGACY_CONSUMPTION' AND re.`deleted_at` IS NULL
)
</if>
</sql>
<select id="stateCustomerDailyByRange" resultType="com.imyeyu.api.modules.gao.vo.GaoEventRecordDailyStatView">
SELECT
@@ -9,15 +9,26 @@
LIMIT 1
</select>
<select id="selectRuleChangeByEventRecordId" resultType="com.imyeyu.api.modules.gao.entity.GaoPointLedger">
<select id="selectRuleChangeByTriggerSource" resultType="com.imyeyu.api.modules.gao.entity.GaoPointLedger">
SELECT *
FROM `gao_point_ledger`
WHERE `event_record_id` = #{eventRecordId}
WHERE `trigger_source_type` = #{triggerSourceType}
AND `trigger_source_id` = #{triggerSourceId}
AND `change_type` IN ('EARN', 'CONSUME')
AND `deleted_at` IS NULL
ORDER BY `created_at` ASC, `id` ASC
</select>
<select id="selectRuleChangeByConsumptionRecordId" resultType="com.imyeyu.api.modules.gao.entity.GaoPointLedger">
SELECT l.*
FROM `gao_point_ledger` l
INNER JOIN `gao_point_ledger_consumption_record` d ON d.`point_ledger_id` = l.`id`
WHERE d.`consumption_record_id` = #{consumptionRecordId}
AND l.`change_type` IN ('EARN', 'CONSUME')
AND l.`deleted_at` IS NULL
ORDER BY l.`created_at` ASC, l.`id` ASC
</select>
<select id="selectByIdempotencyKeyList" resultType="com.imyeyu.api.modules.gao.entity.GaoPointLedger">
SELECT *
FROM `gao_point_ledger`
@@ -11,11 +11,16 @@
</foreach>
</select>
<select id="selectActiveByStoreIdAndEventId" resultType="com.imyeyu.api.modules.gao.entity.GaoPointRule">
<select id="selectActiveByTrigger" resultType="com.imyeyu.api.modules.gao.entity.GaoPointRule">
SELECT *
FROM `gao_point_rule`
WHERE `store_id` = #{storeId}
AND `event_id` = #{eventId}
AND `trigger_source_type` = #{triggerSourceType}
AND (`trigger_ref_id` IS NULL
<if test="triggerRefId != null and triggerRefId != ''">
OR `trigger_ref_id` = #{triggerRefId}
</if>
)
AND `status` = 'ACTIVE'
AND (`begin_at` IS NULL OR `begin_at` &lt;= #{now})
AND (`end_at` IS NULL OR #{now} &lt;= `end_at`)
@@ -33,7 +33,7 @@
</select>
<update id="updatePayment">
UPDATE `gao_sales_order`
SET `pending_paid_amount` = #{pendingPaidAmount}, `paid_amount` = #{paidAmount}, `refunded_amount` = #{refundedAmount},
SET `pending_paid_amount` = #{pendingPaidAmount}, `paid_amount` = #{paidAmount}, `paid_at` = #{paidAt}, `refunded_amount` = #{refundedAmount},
`payment_status` = #{paymentStatus}, `refund_status` = #{refundStatus}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
WHERE `id` = #{id} AND `deleted_at` IS NULL
</update>
@@ -43,11 +43,6 @@
`cancel_reason` = #{cancelReason}, `refund_status` = #{refundStatus}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
WHERE `id` = #{id} AND `status` = #{fromStatus} AND `deleted_at` IS NULL
</update>
<update id="updateSourceEventRecordId">
UPDATE `gao_sales_order`
SET `source_event_record_id` = #{sourceEventRecordId}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
WHERE `id` = #{id} AND `source_event_record_id` IS NULL AND `deleted_at` IS NULL
</update>
<update id="updateStatus">
UPDATE `gao_sales_order`
SET `status` = #{status}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)