From 8b09fbc19a96b57bf1d0e4d7c79b51a76aeca554 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期五, 28 三月 2025 19:57:56 +0800 Subject: [PATCH] 修改bug --- ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/UserCouponRecordMapper.xml | 201 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 185 insertions(+), 16 deletions(-) diff --git a/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/UserCouponRecordMapper.xml b/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/UserCouponRecordMapper.xml index 9160b5d..d742bb3 100644 --- a/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/UserCouponRecordMapper.xml +++ b/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/UserCouponRecordMapper.xml @@ -383,7 +383,7 @@ left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4) left join t_user_activity c on (b.userActivityId = c.id) </if> - where activityType = #{type} + where a.activityType = #{type} <if test="null != name and '' != name"> and c.`name` like CONCAT('%', #{name}, '%') </if> @@ -408,7 +408,7 @@ sum(aa.receiveMoney) as useMoney from ( select - DATE_FORMAT(a.insertTime, '%Y-%m-%d') as time, + DATE_FORMAT(a.endTime, '%Y-%m-%d') as time, a.userId, count(a.id) as receive, sum(a.money) as receiveMoney @@ -430,12 +430,12 @@ and c.`name` like CONCAT('%', #{name}, '%') </if> <if test="null != start and '' != start and null != end and '' != end"> - and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end} + and DATE_FORMAT(a.endTime, '%Y-%m-%d') between #{start} and #{end} </if> <if test="null != companyId"> and c.companyId = #{companyId} </if> - GROUP BY DATE_FORMAT(insertTime, '%Y-%m-%d'),userId + GROUP BY DATE_FORMAT(a.endTime, '%Y-%m-%d'),userId ) as aa GROUP BY aa.time <if test="2 == type"> @@ -468,6 +468,37 @@ and b.companyId = #{companyId} </if> GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d'),userId + ) as aa GROUP BY aa.time + + union all + + select + aa.time, + 0, + 0, + 0, + count(aa.userId) as usePeople, + sum(aa.receive) as `use`, + sum(aa.receiveMoney) as useMoney + from ( + select + DATE_FORMAT(a.endTime, '%Y-%m-%d') as time, + a.userId, + count(a.id) as receive, + sum(a.money) as receiveMoney + from t_user_coupon_record a + left join t_sys_coupon_record b on (a.couponActivityId = b.id and a.activityType = 1) + where a.activityType = 1 and a.state = 2 + <if test="null != name and '' != name"> + and b.`name` like CONCAT('%', #{name}, '%') + </if> + <if test="null != start and '' != start and null != end and '' != end"> + and DATE_FORMAT(a.endTime, '%Y-%m-%d') between #{start} and #{end} + </if> + <if test="null != companyId"> + and b.companyId = #{companyId} + </if> + GROUP BY DATE_FORMAT(a.endTime, '%Y-%m-%d'),userId ) as aa GROUP BY aa.time </if> ) as da GROUP BY da.time order by da.time desc @@ -534,7 +565,7 @@ sum(aa.receiveMoney) as useMoney from ( select - DATE_FORMAT(a.insertTime, '%Y-%m-%d') as time, + DATE_FORMAT(a.endTime, '%Y-%m-%d') as time, a.userId, count(a.id) as receive, sum(a.money) as receiveMoney @@ -556,12 +587,12 @@ and c.`name` like CONCAT('%', #{name}, '%') </if> <if test="null != start and '' != start and null != end and '' != end"> - and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end} + and DATE_FORMAT(a.endTime, '%Y-%m-%d') between #{start} and #{end} </if> <if test="null != companyId"> and c.companyId = #{companyId} </if> - GROUP BY DATE_FORMAT(insertTime, '%Y-%m-%d'),userId + GROUP BY DATE_FORMAT(endTime, '%Y-%m-%d'),userId ) as aa GROUP BY aa.time <if test="2 == type"> @@ -594,6 +625,37 @@ and b.companyId = #{companyId} </if> GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d'),userId + ) as aa GROUP BY aa.time + + union all + + select + aa.time, + 0, + 0, + 0, + count(aa.userId) as usePeople, + sum(aa.receive) as `use`, + sum(aa.receiveMoney) as useMoney + from ( + select + DATE_FORMAT(a.endTime, '%Y-%m-%d') as time, + a.userId, + count(a.id) as receive, + sum(a.money) as receiveMoney + from t_user_coupon_record a + left join t_sys_coupon_record b on (a.couponActivityId = b.id and a.activityType = 1) + where a.activityType = 1 and a.state = 2 + <if test="null != name and '' != name"> + and b.`name` like CONCAT('%', #{name}, '%') + </if> + <if test="null != start and '' != start and null != end and '' != end"> + and DATE_FORMAT(a.endTime, '%Y-%m-%d') between #{start} and #{end} + </if> + <if test="null != companyId"> + and b.companyId = #{companyId} + </if> + GROUP BY DATE_FORMAT(a.endTime, '%Y-%m-%d'),userId ) as aa GROUP BY aa.time </if> ) as da GROUP BY da.time @@ -684,7 +746,10 @@ sum(aa.czcUseMoney) as czcUseMoney, sum(aa.kcNum) as kcNum, sum(aa.kcUseNum) as kcUseNum, - sum(aa.kcUseMoney) as kcUseMoney + sum(aa.kcUseMoney) as kcUseMoney, + sum(aa.xjNum) as xjNum, + sum(aa.xjUseNum) as xjUseNum, + sum(aa.xjUseMoney) as xjUseMoney from ( select DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time, @@ -703,7 +768,10 @@ 0 as czcUseMoney, 0 as kcNum, 0 as kcUseNum, - 0 as kcUseMoney + 0 as kcUseMoney, + 0 as xjNum, + 0 as xjUseNum, + 0 as xjUseMoney from t_user_coupon_record a left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4) left join t_user_activity c on (b.userActivityId = c.id) @@ -740,7 +808,10 @@ 0 as czcUseMoney, 0 as kcNum, 0 as kcUseNum, - 0 as kcUseMoney + 0 as kcUseMoney, + 0 as xjNum, + 0 as xjUseNum, + 0 as xjUseMoney from t_user_coupon_record a left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4) left join t_user_activity c on (b.userActivityId = c.id) @@ -778,7 +849,10 @@ 0 as czcUseMoney, 0 as kcNum, 0 as kcUseNum, - 0 as kcUseMoney + 0 as kcUseMoney, + 0 as xjNum, + 0 as xjUseNum, + 0 as xjUseMoney from t_user_coupon_record a left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4) left join t_user_activity c on (b.userActivityId = c.id) @@ -815,7 +889,10 @@ 0 as czcUseMoney, 0 as kcNum, 0 as kcUseNum, - 0 as kcUseMoney + 0 as kcUseMoney, + 0 as xjNum, + 0 as xjUseNum, + 0 as xjUseMoney from t_user_coupon_record a left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4) left join t_user_activity c on (b.userActivityId = c.id) @@ -852,7 +929,10 @@ 0 as czcUseMoney, 0 as kcNum, 0 as kcUseNum, - 0 as kcUseMoney + 0 as kcUseMoney, + 0 as xjNum, + 0 as xjUseNum, + 0 as xjUseMoney from t_user_coupon_record a left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4) left join t_user_activity c on (b.userActivityId = c.id) @@ -889,7 +969,10 @@ sum(a.money) as czcUseMoney, 0 as kcNum, 0 as kcUseNum, - 0 as kcUseMoney + 0 as kcUseMoney, + 0 as xjNum, + 0 as xjUseNum, + 0 as xjUseMoney from t_user_coupon_record a left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4) left join t_user_activity c on (b.userActivityId = c.id) @@ -926,7 +1009,10 @@ 0 as czcUseMoney, count(a.id) as kcNum, 0 as kcUseNum, - 0 as kcUseMoney + 0 as kcUseMoney, + 0 as xjNum, + 0 as xjUseNum, + 0 as xjUseMoney from t_user_coupon_record a left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4) left join t_user_activity c on (b.userActivityId = c.id) @@ -963,7 +1049,10 @@ 0 as czcUseMoney, 0 as kcNum, count(a.id) as kcUseNum, - sum(a.money) as kcUseMoney + sum(a.money) as kcUseMoney, + 0 as xjNum, + 0 as xjUseNum, + 0 as xjUseMoney from t_user_coupon_record a left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4) left join t_user_activity c on (b.userActivityId = c.id) @@ -980,6 +1069,86 @@ and c.companyId = #{companyId} </if> GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId + + union all + + select + DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time, + a.userId as userId, + d.nickName as userName, + d.phone as phone, + 0 as amount, + 0 as tyNum, + 0 as tyUseNum, + 0 as tyUseMoney, + 0 as zcNum, + 0 as zcUseNum, + 0 as zcUseMoney, + 0 as czcNum, + 0 as czcUseNum, + 0 as czcUseMoney, + 0 as kcNum, + 0 as kcUseNum, + 0 as kcUseMoney, + count(a.id) as xjNum, + 0 as xjUseNum, + 0 as xjUseMoney + from t_user_coupon_record a + left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4) + left join t_user_activity c on (b.userActivityId = c.id) + left join t_user d on (a.userId = d.id) + left join t_payment_record e on (a.paymentRecordId = e.id) + where a.activityType = 4 and a.couponUseType = 4 + <if test="null != name and '' != name"> + and c.`name` like CONCAT('%', #{name}, '%') + </if> + <if test="null != start and '' != start and null != end and '' != end"> + and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end} + </if> + <if test="null != companyId"> + and c.companyId = #{companyId} + </if> + GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId + + union all + + select + DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time, + a.userId as userId, + d.nickName as userName, + d.phone as phone, + 0 as amount, + 0 as tyNum, + 0 as tyUseNum, + 0 as tyUseMoney, + 0 as zcNum, + 0 as zcUseNum, + 0 as zcUseMoney, + 0 as czcNum, + 0 as czcUseNum, + 0 as czcUseMoney, + 0 as kcNum, + 0 as kcUseNum, + 0 as kcUseMoney, + 0 as xjNum, + count(a.id) as xjUseNum, + sum(a.money) as xjUseMoney + from t_user_coupon_record a + left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4) + left join t_user_activity c on (b.userActivityId = c.id) + left join t_user d on (a.userId = d.id) + left join t_payment_record e on (a.paymentRecordId = e.id) + where a.activityType = 4 and a.couponUseType = 4 and a.state = 2 + <if test="null != name and '' != name"> + and c.`name` like CONCAT('%', #{name}, '%') + </if> + <if test="null != start and '' != start and null != end and '' != end"> + and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end} + </if> + <if test="null != companyId"> + and c.companyId = #{companyId} + </if> + GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId ) as aa GROUP BY aa.time,aa.userId order by aa.time desc <if test="null != offset and null != limit"> limit #{offset}, #{limit} -- Gitblit v1.7.1