add point chart
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?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.GaoPointChartMapper">
|
||||
<select id="selectDailyTrend" resultType="com.imyeyu.api.modules.gao.vo.GaoPointDailyStatView">
|
||||
SELECT
|
||||
CAST(DATE_FORMAT(FROM_UNIXTIME(l.`occurred_at` / 1000), '%Y%m%d') AS UNSIGNED) AS `dateValue`,
|
||||
COALESCE(SUM(CASE WHEN l.`change_type` = 'EARN' THEN l.`point_delta` ELSE 0 END), 0) AS `earnedPoints`,
|
||||
COALESCE(SUM(CASE WHEN l.`change_type` = 'CONSUME' THEN -l.`point_delta` ELSE 0 END), 0) AS `consumedPoints`,
|
||||
COALESCE(SUM(l.`point_delta`), 0) AS `netChangePoints`
|
||||
FROM `gao_point_ledger` l
|
||||
WHERE l.`deleted_at` IS NULL
|
||||
AND l.`store_id` = #{storeId}
|
||||
AND l.`occurred_at` >= #{beginAt}
|
||||
AND l.`occurred_at` <= #{endAt}
|
||||
AND l.`change_type` IN ('EARN', 'CONSUME')
|
||||
GROUP BY DATE_FORMAT(FROM_UNIXTIME(l.`occurred_at` / 1000), '%Y%m%d')
|
||||
ORDER BY `dateValue` ASC
|
||||
</select>
|
||||
|
||||
<select id="selectRedemptionProductRank" resultType="com.imyeyu.api.modules.gao.vo.GaoPointRedemptionProductRankView">
|
||||
SELECT
|
||||
r.`product_id_snapshot` AS `productId`,
|
||||
COALESCE(MAX(NULLIF(r.`product_name_snapshot`, '')), '未命名产品') AS `productName`,
|
||||
COUNT(1) AS `redemptionCount`,
|
||||
COALESCE(SUM(r.`actual_point_cost`), 0) AS `pointCost`
|
||||
FROM `gao_point_redemption` r
|
||||
WHERE r.`deleted_at` IS NULL
|
||||
AND r.`store_id` = #{storeId}
|
||||
AND r.`product_id_snapshot` IS NOT NULL
|
||||
AND r.`redeemed_at` >= #{beginAt}
|
||||
AND r.`redeemed_at` <= #{endAt}
|
||||
GROUP BY r.`product_id_snapshot`
|
||||
ORDER BY `pointCost` DESC, `redemptionCount` DESC, `productName` ASC, `productId` ASC
|
||||
LIMIT 10
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user