|
|
@@ -54,22 +54,18 @@
|
|
|
t3.recharge_times,
|
|
|
t3.recharge_amount,
|
|
|
t2.charge_times,
|
|
|
- t2.total_power,
|
|
|
- t2.total_money,
|
|
|
- t2.pay_amount,
|
|
|
- t2.discount_amount
|
|
|
+ t2.amount_received,
|
|
|
+ t2.discount_money
|
|
|
FROM
|
|
|
t_user t1
|
|
|
LEFT JOIN
|
|
|
(SELECT
|
|
|
user_id,
|
|
|
COUNT(IFNULL(1, 0)) charge_times,
|
|
|
- SUM(IFNULL(total_power, 0)) total_power,
|
|
|
- SUM(IFNULL(total_money, 0)) total_money,
|
|
|
- SUM(IFNULL(pay_amount, 0)) pay_amount,
|
|
|
- SUM(IFNULL(discount_amount, 0)) discount_amount
|
|
|
+ SUM(IFNULL(amount_received, 0)) amount_received,
|
|
|
+ SUM(IFNULL(discount_money, 0)) discount_money
|
|
|
FROM
|
|
|
- t_charge_order
|
|
|
+ t_wash_order
|
|
|
WHERE user_id in
|
|
|
<foreach collection="list" item="item" open="(" separator="," close=")">
|
|
|
#{item}
|
|
|
@@ -107,11 +103,9 @@
|
|
|
user.`last_login_time`,
|
|
|
t.recharge_times,
|
|
|
t.recharge_amount,
|
|
|
- t1.charge_times,
|
|
|
- t1.total_power,
|
|
|
- t1.total_money,
|
|
|
- t1.pay_amount,
|
|
|
- t1.discount_amount
|
|
|
+ t1.wash_times,
|
|
|
+ t1.amount_received,
|
|
|
+ t1.discount_money
|
|
|
FROM t_user `user`
|
|
|
LEFT JOIN
|
|
|
(SELECT user_id,
|
|
|
@@ -140,36 +134,22 @@
|
|
|
THEN 1
|
|
|
ELSE NULL
|
|
|
END
|
|
|
- ) charge_times,
|
|
|
+ ) wash_times,
|
|
|
SUM(
|
|
|
CASE
|
|
|
- WHEN o.`total_power` > 0
|
|
|
- THEN o.`total_power`
|
|
|
+ WHEN o.`amount_received` > 0
|
|
|
+ THEN o.`amount_received`
|
|
|
ELSE 0
|
|
|
END
|
|
|
- ) total_power,
|
|
|
+ ) amount_received,
|
|
|
SUM(
|
|
|
CASE
|
|
|
- WHEN o.`total_money` > 0
|
|
|
- THEN o.`total_money`
|
|
|
+ WHEN o.`discount_money` > 0
|
|
|
+ THEN o.`discount_money`
|
|
|
ELSE 0
|
|
|
END
|
|
|
- ) total_money,
|
|
|
- SUM(
|
|
|
- CASE
|
|
|
- WHEN o.`pay_amount` > 0
|
|
|
- THEN o.`pay_amount`
|
|
|
- ELSE 0
|
|
|
- END
|
|
|
- ) pay_amount,
|
|
|
- SUM(
|
|
|
- CASE
|
|
|
- WHEN o.`discount_amount` > 0
|
|
|
- THEN o.`discount_amount`
|
|
|
- ELSE 0
|
|
|
- END
|
|
|
- ) discount_amount
|
|
|
- FROM t_charge_order o
|
|
|
+ ) discount_money
|
|
|
+ FROM t_wash_order o
|
|
|
GROUP BY o.user_id) t1
|
|
|
ON t1.user_id = user.id
|
|
|
ORDER BY register_time DESC
|