Pu Zhibing
2025-03-28 8b09fbc19a96b57bf1d0e4d7c79b51a76aeca554
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/UserCouponRecordMapper.xml
@@ -74,7 +74,7 @@
        SELECT
            c.id,
            c.money,
            c.expirationTime,
            c.endTime as expirationTime,
            c.insertTime,
            c.companyId,
            c.state,
@@ -161,7 +161,10 @@
        </if>
    </select>
    <select id="getDiscountStatic" resultType="map">
        SELECT IFNULL(SUM(discountMoney),0) money,COUNT(id) number FROM t_order_taxi WHERE activityId=#{activityId}
        SELECT IFNULL(SUM(discountMoney),0) money,COUNT(id) number FROM t_order_private_car WHERE activityId=#{activityId}
    </select>
    <select id="getDiscountStatic1" resultType="map">
        SELECT IFNULL(SUM(discountMoney),0) money,COUNT(id) number FROM t_order_logistics WHERE activityId=#{activityId}
    </select>
    <select id="getRegStatic" resultType="map">
        SELECT
@@ -380,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>
@@ -405,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
@@ -427,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">
@@ -465,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
@@ -531,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
@@ -553,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">
@@ -591,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
@@ -667,8 +732,8 @@
        select
        aa.time,
        aa.userId,
        aa.userName,
        aa.phone,
        any_value(aa.userName) as userName,
        any_value(aa.phone) as phone,
        sum(aa.amount) as amount,
        sum(aa.tyNum) as tyNum,
        sum(aa.tyUseNum) as tyUseNum,
@@ -681,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,
@@ -700,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)
@@ -737,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)
@@ -775,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)
@@ -812,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)
@@ -849,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)
@@ -886,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)
@@ -923,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)
@@ -960,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)
@@ -977,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}