diff --git a/mallinkService/src/main/resources/mapper/WxCreditHistoryMapper.xml b/mallinkService/src/main/resources/mapper/WxCreditHistoryMapper.xml
index 4e6e3deb8..c43c83900 100644
--- a/mallinkService/src/main/resources/mapper/WxCreditHistoryMapper.xml
+++ b/mallinkService/src/main/resources/mapper/WxCreditHistoryMapper.xml
@@ -311,51 +311,55 @@
) wm
left join
(
- select merchant_id,sum(credit_num) sum_credit_num from wx_credit_history${shardFinalTableSuffix}
- where merchant_id is not null and merchant_id != -1 and credit_num > 0
+ select credit.merchant_id,sum(credit.credit_num) sum_credit_num from wx_credit_history${shardFinalTableSuffix} credit
+ INNER JOIN wx_c_user_basic_info${shardFinalTableSuffix} basic ON basic.id = credit.c_user_id
+ where credit.merchant_id is not null and credit.merchant_id != -1 and credit.credit_num > 0
- and create_date >= #{startTime}
+ and credit.create_date >= #{startTime}
- and create_date < #{endTime}
+ and credit.create_date < #{endTime}
- GROUP BY merchant_id
+ GROUP BY credit.merchant_id
) a on a.merchant_id = wm.id
left join
(
- select merchant_id,sum(credit_num) sum_credit_num from wx_credit_history${shardFinalTableSuffix}
- where merchant_id is not null and merchant_id != -1 and credit_num < 0
+ select credit.merchant_id,sum(credit.credit_num) sum_credit_num from wx_credit_history${shardFinalTableSuffix} credit
+ INNER JOIN wx_c_user_basic_info${shardFinalTableSuffix} basic ON basic.id = credit.c_user_id
+ where credit.merchant_id is not null and credit.merchant_id != -1 and credit.credit_num < 0
- and create_date >= #{startTime}
+ and credit.create_date >= #{startTime}
- and create_date < #{endTime}
+ and credit.create_date < #{endTime}
- GROUP BY merchant_id
+ GROUP BY credit.merchant_id
) b on b.merchant_id = wm.id
left join
(
- select merchant_id,count(distinct c_user_id) count_c_user_id from wx_credit_history${shardFinalTableSuffix}
- where merchant_id is not null and merchant_id != -1 and credit_num > 0
+ select credit.merchant_id,count(distinct credit.c_user_id) count_c_user_id from wx_credit_history${shardFinalTableSuffix} credit
+ INNER JOIN wx_c_user_basic_info${shardFinalTableSuffix} basic ON basic.id = credit.c_user_id
+ where credit.merchant_id is not null and credit.merchant_id != -1 and credit.credit_num > 0
- and create_date >= #{startTime}
+ and credit.create_date >= #{startTime}
- and create_date < #{endTime}
+ and credit.create_date < #{endTime}
- GROUP BY merchant_id
+ GROUP BY credit.merchant_id
) c on c.merchant_id = wm.id
left join
(
- select merchant_id,count(distinct c_user_id) count_c_user_id from wx_credit_history${shardFinalTableSuffix}
- where merchant_id is not null and merchant_id != -1 and credit_num < 0
+ select credit.merchant_id,count(distinct credit.c_user_id) count_c_user_id from wx_credit_history${shardFinalTableSuffix} credit
+ INNER JOIN wx_c_user_basic_info${shardFinalTableSuffix} basic ON basic.id = credit.c_user_id
+ where credit.merchant_id is not null and credit.merchant_id != -1 and credit.credit_num < 0
- and create_date >= #{startTime}
+ and credit.create_date >= #{startTime}
- and create_date <= #{endTime}
+ and credit.create_date <= #{endTime}
- GROUP BY merchant_id
+ GROUP BY credit.merchant_id
) d on d.merchant_id = wm.id
where (IFNULL(a.sum_credit_num,0) > 0 or IFNULL(b.sum_credit_num,0) < 0)
ORDER BY sumAddCredit desc