refactor mapper xml
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?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.GaoCustomerMapper">
|
||||
<select id="selectByIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoCustomer">
|
||||
SELECT
|
||||
*
|
||||
FROM `gao_customer`
|
||||
WHERE
|
||||
TRUE
|
||||
<if test="idList != null and !idList.isEmpty()">
|
||||
AND `id` IN
|
||||
<foreach collection="idList" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="idList == null or idList.isEmpty()">
|
||||
AND FALSE
|
||||
</if>
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
|
||||
<select id="stateDailyNewCustomer" resultType="com.imyeyu.api.modules.gao.vo.GaoCustomerDailyStateView">
|
||||
SELECT
|
||||
CAST(DATE_FORMAT(FROM_UNIXTIME(`created_at` / 1000), '%Y%m%d') AS UNSIGNED) AS `dateValue`,
|
||||
COUNT(1) AS `newCustomerCount`
|
||||
FROM `gao_customer`
|
||||
WHERE
|
||||
`store_id` = #{storeId}
|
||||
AND `created_at` >= #{beginCreatedAt}
|
||||
AND `created_at` <= #{endCreatedAt}
|
||||
AND `deleted_at` IS NULL
|
||||
GROUP BY DATE_FORMAT(FROM_UNIXTIME(`created_at` / 1000), '%Y%m%d')
|
||||
ORDER BY `dateValue` ASC
|
||||
</select>
|
||||
|
||||
<select id="countCreatedBefore" resultType="java.lang.Long">
|
||||
SELECT
|
||||
COUNT(1)
|
||||
FROM `gao_customer`
|
||||
WHERE
|
||||
`store_id` = #{storeId}
|
||||
AND `created_at` < #{beginCreatedAt}
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
|
||||
<select id="stateGender" resultType="com.imyeyu.api.modules.gao.vo.GaoCustomerGenderStatView">
|
||||
SELECT
|
||||
IFNULL(CAST(`gender` AS CHAR), 'UNKNOWN') AS `genderCode`,
|
||||
COUNT(1) AS `count`
|
||||
FROM `gao_customer`
|
||||
WHERE
|
||||
`store_id` = #{storeId}
|
||||
AND `deleted_at` IS NULL
|
||||
GROUP BY IFNULL(CAST(`gender` AS CHAR), 'UNKNOWN')
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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.GaoEventMapper">
|
||||
<select id="selectByIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoEvent">
|
||||
SELECT
|
||||
*
|
||||
FROM `gao_event`
|
||||
WHERE
|
||||
TRUE
|
||||
<if test="idList != null and !idList.isEmpty()">
|
||||
AND `id` IN
|
||||
<foreach collection="idList" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="idList == null or idList.isEmpty()">
|
||||
AND FALSE
|
||||
</if>
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
|
||||
<select id="selectValidList" resultType="com.imyeyu.api.modules.gao.entity.GaoEvent">
|
||||
SELECT
|
||||
*
|
||||
FROM `gao_event`
|
||||
WHERE
|
||||
`store_id` = #{storeId}
|
||||
AND `status` = '${@com.imyeyu.api.modules.gao.entity.GaoEvent$Status@ACTIVE.name()}'
|
||||
AND (`begin_at` IS NULL OR `begin_at` <= #{now})
|
||||
AND (`end_at` IS NULL OR #{now} <= `end_at`)
|
||||
AND `deleted_at` IS NULL
|
||||
ORDER BY `sort`, `created_at`
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,295 @@
|
||||
<?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.GaoEventRecordMapper">
|
||||
<select id="count" resultType="java.lang.Long">
|
||||
SELECT
|
||||
COUNT(1)
|
||||
FROM
|
||||
`gao_event_record`
|
||||
WHERE
|
||||
TRUE
|
||||
<if test="storeId != null">
|
||||
AND `store_id` = #{storeId}
|
||||
</if>
|
||||
<if test="customerId != null">
|
||||
AND `customer_id` = #{customerId}
|
||||
</if>
|
||||
<if test="eventId != null">
|
||||
AND `event_id` = #{eventId}
|
||||
</if>
|
||||
<if test="beginAt != null">
|
||||
AND `registered_at` >= #{beginAt}
|
||||
</if>
|
||||
<if test="endAt != null">
|
||||
AND `registered_at` <= #{endAt}
|
||||
</if>
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
|
||||
<select id="countByStoreIdAndRegisteredDateValue" resultType="java.lang.Long">
|
||||
SELECT
|
||||
COUNT(1)
|
||||
FROM `gao_event_record`
|
||||
WHERE
|
||||
`store_id` = #{storeId}
|
||||
AND `registered_date_value` = #{registeredDateValue}
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
|
||||
<update id="updateBusinessDayNoByStoreIdAndRegisteredDateValue">
|
||||
UPDATE `gao_event_record`
|
||||
SET
|
||||
`business_day_no` = #{businessDayNo},
|
||||
`updated_at` = ROUND(UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000)
|
||||
WHERE
|
||||
`store_id` = #{storeId}
|
||||
AND `registered_date_value` = #{registeredDateValue}
|
||||
AND `deleted_at` IS NULL
|
||||
</update>
|
||||
|
||||
<sql id="rangeFrom">
|
||||
FROM `gao_event_record` r
|
||||
LEFT JOIN `gao_customer` c ON r.`customer_id` = c.`id`
|
||||
</sql>
|
||||
<sql id="rangeWhere">
|
||||
TRUE
|
||||
<if test="beginAt != null">
|
||||
AND r.`registered_at` >= #{beginAt}
|
||||
</if>
|
||||
<if test="endAt != null">
|
||||
AND r.`registered_at` <= #{endAt}
|
||||
</if>
|
||||
AND r.`deleted_at` IS NULL
|
||||
<if test="storeId != null and storeId != ''">
|
||||
AND r.`store_id` = #{storeId}
|
||||
</if>
|
||||
<if test="customerId != null">
|
||||
AND r.`customer_id` = #{customerId}
|
||||
</if>
|
||||
<if test="eventIdList != null and eventIdList.size() > 0">
|
||||
AND r.`event_id` IN
|
||||
<foreach collection="eventIdList" item="eventId" open="(" separator="," close=")">
|
||||
#{eventId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="keyword != null and keyword.trim() != ''">
|
||||
AND (
|
||||
c.`code` LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR c.`name` LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR r.`remark` LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR r.`operator_user_id` LIKE CONCAT('%', #{keyword}, '%')
|
||||
)
|
||||
</if>
|
||||
</sql>
|
||||
<select id="countByRange" resultType="long">
|
||||
SELECT
|
||||
COUNT(1)
|
||||
<include refid="rangeFrom"/>
|
||||
WHERE
|
||||
<include refid="rangeWhere"/>
|
||||
</select>
|
||||
<select id="selectByRange" resultType="com.imyeyu.api.modules.gao.entity.GaoEventRecord">
|
||||
SELECT
|
||||
r.*
|
||||
<include refid="rangeFrom"/>
|
||||
WHERE
|
||||
<include refid="rangeWhere"/>
|
||||
ORDER BY r.`registered_at` DESC, r.`created_at` DESC
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
|
||||
<sql id="rankWhere">
|
||||
r.`deleted_at` IS NULL
|
||||
AND c.`deleted_at` IS NULL
|
||||
<if test="storeId != null and storeId != ''">
|
||||
AND r.`store_id` = #{storeId}
|
||||
</if>
|
||||
<if test="customerId != null and customerId != ''">
|
||||
AND r.`customer_id` = #{customerId}
|
||||
</if>
|
||||
<if test="beginAt != null">
|
||||
AND r.`registered_at` >= #{beginAt}
|
||||
</if>
|
||||
<if test="endAt != null">
|
||||
AND r.`registered_at` <= #{endAt}
|
||||
</if>
|
||||
<if test="eventIdList != null and eventIdList.size() > 0">
|
||||
AND r.`event_id` IN
|
||||
<foreach collection="eventIdList" item="eventId" open="(" separator="," close=")">
|
||||
#{eventId}
|
||||
</foreach>
|
||||
</if>
|
||||
</sql>
|
||||
<select id="countRankByRange" resultType="long">
|
||||
SELECT
|
||||
COUNT(DISTINCT r.`customer_id`)
|
||||
FROM `gao_event_record` r
|
||||
LEFT JOIN `gao_customer` c ON r.`customer_id` = c.`id`
|
||||
WHERE
|
||||
<include refid="rankWhere"/>
|
||||
</select>
|
||||
<select id="selectRankByRange" resultType="com.imyeyu.api.modules.gao.vo.GaoCustomerEventRankView">
|
||||
WITH `daily_stat` AS (
|
||||
SELECT
|
||||
r.`customer_id` AS `customerId`,
|
||||
r.`business_day_no` AS `businessDayNo`,
|
||||
COUNT(1) AS `dailyCount`,
|
||||
MAX(r.`registered_at`) AS `latestRegisteredAt`
|
||||
FROM `gao_event_record` r
|
||||
LEFT JOIN `gao_customer` c ON r.`customer_id` = c.`id`
|
||||
WHERE
|
||||
<include refid="rankWhere"/>
|
||||
GROUP BY
|
||||
r.`customer_id`,
|
||||
r.`business_day_no`
|
||||
),
|
||||
`rank_stat` AS (
|
||||
SELECT
|
||||
`customerId`,
|
||||
COUNT(1) AS `totalEventDays`,
|
||||
SUM(`dailyCount`) AS `totalEventCount`,
|
||||
MAX(`latestRegisteredAt`) AS `latestRegisteredAt`
|
||||
FROM `daily_stat`
|
||||
GROUP BY `customerId`
|
||||
),
|
||||
`continuous_ordered` AS (
|
||||
SELECT
|
||||
`customerId`,
|
||||
`businessDayNo`,
|
||||
ROW_NUMBER() OVER (PARTITION BY `customerId` ORDER BY `businessDayNo` DESC) AS `dayIndex`
|
||||
FROM `daily_stat`
|
||||
),
|
||||
`latest_date` AS (
|
||||
SELECT
|
||||
`customerId`,
|
||||
MAX(`businessDayNo`) AS `latestBusinessDayNo`
|
||||
FROM `daily_stat`
|
||||
GROUP BY `customerId`
|
||||
),
|
||||
`continuous_stat` AS (
|
||||
SELECT
|
||||
o.`customerId`,
|
||||
COUNT(1) AS `recentContinuousEventDays`
|
||||
FROM `continuous_ordered` o
|
||||
LEFT JOIN `latest_date` l ON o.`customerId` = l.`customerId`
|
||||
WHERE o.`businessDayNo` + o.`dayIndex` = l.`latestBusinessDayNo` + 1
|
||||
GROUP BY o.`customerId`
|
||||
),
|
||||
`ranked` AS (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (
|
||||
ORDER BY
|
||||
r.`totalEventDays` DESC,
|
||||
r.`totalEventCount` DESC,
|
||||
r.`latestRegisteredAt` DESC,
|
||||
r.`customerId`
|
||||
) AS `rank`,
|
||||
r.`customerId`,
|
||||
r.`totalEventDays`,
|
||||
r.`totalEventCount`,
|
||||
COALESCE(c.`recentContinuousEventDays`, 0) AS `recentContinuousEventDays`,
|
||||
r.`latestRegisteredAt`
|
||||
FROM `rank_stat` r
|
||||
LEFT JOIN `continuous_stat` c ON r.`customerId` = c.`customerId`
|
||||
)
|
||||
SELECT
|
||||
`rank`,
|
||||
`customerId`,
|
||||
`totalEventDays`,
|
||||
`totalEventCount`,
|
||||
`recentContinuousEventDays`,
|
||||
`latestRegisteredAt`
|
||||
FROM `ranked`
|
||||
ORDER BY `rank`
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
|
||||
<sql id="storeChartRangeWhere">
|
||||
r.`store_id` = #{storeId}
|
||||
AND r.`registered_at` >= #{beginAt}
|
||||
AND r.`registered_at` <= #{endAt}
|
||||
AND r.`deleted_at` IS NULL
|
||||
<if test="eventIdList != null and eventIdList.size() > 0">
|
||||
AND r.`event_id` IN
|
||||
<foreach collection="eventIdList" item="eventId" open="(" separator="," close=")">
|
||||
#{eventId}
|
||||
</foreach>
|
||||
</if>
|
||||
</sql>
|
||||
<select id="stateDailyByRange" resultType="com.imyeyu.api.modules.gao.vo.GaoEventRecordDailyStatView">
|
||||
SELECT
|
||||
r.`event_id` AS `eventId`,
|
||||
r.`registered_date_value` AS `dateValue`,
|
||||
COUNT(1) AS `dailyCount`
|
||||
FROM `gao_event_record` r
|
||||
WHERE
|
||||
<include refid="storeChartRangeWhere"/>
|
||||
GROUP BY
|
||||
r.`event_id`,
|
||||
r.`registered_date_value`
|
||||
ORDER BY
|
||||
r.`registered_date_value` ASC,
|
||||
r.`event_id` ASC
|
||||
</select>
|
||||
<select id="selectCalendarByRange" resultType="com.imyeyu.api.modules.gao.vo.GaoEventRecordCalendarView">
|
||||
SELECT
|
||||
r.`id`,
|
||||
r.`customer_id` AS `customerId`,
|
||||
c.`code` AS `customerCode`,
|
||||
c.`name` AS `customerName`,
|
||||
r.`event_id` AS `eventId`,
|
||||
r.`registered_at` AS `registeredAt`
|
||||
FROM `gao_event_record` r
|
||||
LEFT JOIN `gao_customer` c ON r.`customer_id` = c.`id` AND c.`deleted_at` IS NULL
|
||||
WHERE
|
||||
<include refid="storeChartRangeWhere"/>
|
||||
ORDER BY
|
||||
r.`registered_at` ASC,
|
||||
r.`created_at` ASC
|
||||
</select>
|
||||
|
||||
<sql id="customerChartRangeWhere">
|
||||
r.`store_id` = #{storeId}
|
||||
AND r.`customer_id` = #{customerId}
|
||||
AND r.`registered_at` >= #{beginAt}
|
||||
AND r.`registered_at` <= #{endAt}
|
||||
AND r.`deleted_at` IS NULL
|
||||
<if test="eventIdList != null and eventIdList.size() > 0">
|
||||
AND r.`event_id` IN
|
||||
<foreach collection="eventIdList" item="eventId" open="(" separator="," close=")">
|
||||
#{eventId}
|
||||
</foreach>
|
||||
</if>
|
||||
</sql>
|
||||
<select id="stateCustomerDailyByRange" resultType="com.imyeyu.api.modules.gao.vo.GaoEventRecordDailyStatView">
|
||||
SELECT
|
||||
r.`event_id` AS `eventId`,
|
||||
r.`registered_date_value` AS `dateValue`,
|
||||
COUNT(1) AS `dailyCount`
|
||||
FROM `gao_event_record` r
|
||||
WHERE
|
||||
<include refid="customerChartRangeWhere"/>
|
||||
GROUP BY
|
||||
r.`event_id`,
|
||||
r.`registered_date_value`
|
||||
ORDER BY
|
||||
r.`registered_date_value` ASC,
|
||||
r.`event_id` ASC
|
||||
</select>
|
||||
<select id="selectCustomerCalendarByRange" resultType="com.imyeyu.api.modules.gao.vo.GaoEventRecordCalendarView">
|
||||
SELECT
|
||||
r.`id`,
|
||||
r.`customer_id` AS `customerId`,
|
||||
c.`code` AS `customerCode`,
|
||||
c.`name` AS `customerName`,
|
||||
r.`event_id` AS `eventId`,
|
||||
r.`registered_at` AS `registeredAt`
|
||||
FROM `gao_event_record` r
|
||||
LEFT JOIN `gao_customer` c ON r.`customer_id` = c.`id` AND c.`deleted_at` IS NULL
|
||||
WHERE
|
||||
<include refid="customerChartRangeWhere"/>
|
||||
ORDER BY
|
||||
r.`registered_at` DESC,
|
||||
r.`created_at` DESC
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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.GaoEventRoleRelationMapper">
|
||||
<select id="selectAllByEventIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoEventRoleRelation">
|
||||
SELECT
|
||||
*
|
||||
FROM `gao_event_role_relation`
|
||||
WHERE
|
||||
TRUE
|
||||
<if test="idList != null and !idList.isEmpty()">
|
||||
AND `event_id` IN
|
||||
<foreach collection="idList" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="idList == null or idList.isEmpty()">
|
||||
AND FALSE
|
||||
</if>
|
||||
AND `deleted_at` IS NULL
|
||||
ORDER BY `created_at`
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,44 @@
|
||||
<?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.GaoPointAccountMapper">
|
||||
<select id="selectByStoreIdAndCustomerId" resultType="com.imyeyu.api.modules.gao.entity.GaoPointAccount">
|
||||
SELECT *
|
||||
FROM `gao_point_account`
|
||||
WHERE `store_id` = #{storeId}
|
||||
AND `customer_id` = #{customerId}
|
||||
AND `deleted_at` IS NULL
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<insert id="insertIfAbsent">
|
||||
INSERT INTO `gao_point_account` (
|
||||
`id`, `store_id`, `customer_id`, `balance`, `total_earned`, `total_revoked`, `total_adjusted`, `version`, `created_at`, `updated_at`, `deleted_at`
|
||||
) VALUES (
|
||||
#{account.id}, #{account.storeId}, #{account.customerId}, #{account.balance}, #{account.totalEarned}, #{account.totalRevoked}, #{account.totalAdjusted}, #{account.version}, #{account.createdAt}, #{account.updatedAt}, #{account.deletedAt}
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE `id` = `id`
|
||||
</insert>
|
||||
|
||||
<select id="selectForUpdate" resultType="com.imyeyu.api.modules.gao.entity.GaoPointAccount">
|
||||
SELECT *
|
||||
FROM `gao_point_account`
|
||||
WHERE `id` = #{id}
|
||||
AND `deleted_at` IS NULL
|
||||
LIMIT 1
|
||||
FOR UPDATE
|
||||
</select>
|
||||
|
||||
<update id="updateBalance">
|
||||
UPDATE `gao_point_account`
|
||||
SET
|
||||
`balance` = `balance` + #{delta},
|
||||
`total_earned` = `total_earned` + #{totalEarnedDelta},
|
||||
`total_revoked` = `total_revoked` + #{totalRevokedDelta},
|
||||
`total_adjusted` = `total_adjusted` + #{totalAdjustedDelta},
|
||||
`version` = `version` + 1,
|
||||
`updated_at` = #{updatedAt}
|
||||
WHERE `id` = #{id}
|
||||
AND `balance` + #{delta} >= 0
|
||||
AND `deleted_at` IS NULL
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,68 @@
|
||||
<?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="selectEarnByEventRecordId" resultType="com.imyeyu.api.modules.gao.entity.GaoPointLedger">
|
||||
SELECT *
|
||||
FROM `gao_point_ledger`
|
||||
WHERE `event_record_id` = #{eventRecordId}
|
||||
AND `change_type` = 'EARN'
|
||||
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` >= #{beginAt}
|
||||
</if>
|
||||
<if test="endAt != null">
|
||||
AND `occurred_at` <= #{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>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?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.GaoPointRuleMapper">
|
||||
<select id="selectActiveByStoreIdAndEventId" resultType="com.imyeyu.api.modules.gao.entity.GaoPointRule">
|
||||
SELECT *
|
||||
FROM `gao_point_rule`
|
||||
WHERE `store_id` = #{storeId}
|
||||
AND `event_id` = #{eventId}
|
||||
AND `status` = 'ACTIVE'
|
||||
AND (`begin_at` IS NULL OR `begin_at` <= #{now})
|
||||
AND (`end_at` IS NULL OR #{now} <= `end_at`)
|
||||
AND `deleted_at` IS NULL
|
||||
ORDER BY `priority` ASC, `created_at` ASC, `id` ASC
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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.GaoStoreMapper">
|
||||
<select id="selectByIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoStore">
|
||||
SELECT
|
||||
*
|
||||
FROM `gao_store`
|
||||
WHERE
|
||||
TRUE
|
||||
<if test="idList != null and !idList.isEmpty()">
|
||||
AND `id` IN
|
||||
<foreach collection="idList" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="idList == null or idList.isEmpty()">
|
||||
AND FALSE
|
||||
</if>
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
<select id="selectByUserId" resultType="com.imyeyu.api.modules.gao.entity.GaoStore">
|
||||
SELECT
|
||||
s.*
|
||||
FROM `gao_user` u
|
||||
INNER JOIN `gao_store` s ON u.`store_id` = s.`id`
|
||||
WHERE
|
||||
u.`user_id` = #{userId}
|
||||
AND u.`enabled` = TRUE
|
||||
AND u.`deleted_at` IS NULL
|
||||
AND s.`status` = 'ACTIVE'
|
||||
AND s.`deleted_at` IS NULL
|
||||
LIMIT 1
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user