|
|
|
@@ -215,28 +215,12 @@ |
|
|
|
{call user_credit_clear(#{cutOffDate},#{finalTableIndex})} |
|
|
|
</update> |
|
|
|
|
|
|
|
|
|
|
|
<select id="merchantCreditRanking" parameterType="com.iformall.domain.po.WxCreditHistory" resultType="com.iformall.domain.vo.MerchantCreditRankingVo"> |
|
|
|
select wm.id merchantId,wm.tenant_id tenantId,wm.parent_tenant_id parentTenantId,wm.name merchantName,IFNULL(a.sum_credit_num,0) sumAddCredit, |
|
|
|
IFNULL(b.sum_credit_num,0) sumLesCredit,IFNULL(c.count_c_user_id,0) countAddCreditUser, |
|
|
|
IFNULL(d.count_c_user_id,0) countLesCreditUser |
|
|
|
from |
|
|
|
( |
|
|
|
select id,tenant_id,parent_tenant_id,name from wx_merchant |
|
|
|
where is_del = 0 |
|
|
|
<if test=" null != tenantId and '' != tenantId"> |
|
|
|
and `tenant_id` = #{tenantId} |
|
|
|
</if> |
|
|
|
<if test=" null != parentTenantId and '' != parentTenantId"> |
|
|
|
and `parent_tenant_id` = #{parentTenantId} |
|
|
|
</if> |
|
|
|
) wm |
|
|
|
left join |
|
|
|
( |
|
|
|
select credit.merchant_id,sum(credit.credit_num) sum_credit_num |
|
|
|
from wx_credit_history${shardFinalTableSuffix} credit |
|
|
|
where credit.merchant_id is not null |
|
|
|
and credit.merchant_id != -1 and credit.credit_num > 0 |
|
|
|
<select id="merchantCreditAdd" parameterType="com.iformall.domain.po.WxCreditHistory" resultType="com.iformall.domain.vo.MerchantCreditRankingVo"> |
|
|
|
select credit.merchant_id merchantId,sum(credit.credit_num) sumAddCredit |
|
|
|
from wx_credit_history credit |
|
|
|
where credit.merchant_id is not null and credit.merchant_id != -1 |
|
|
|
and credit.credit_num > 0 |
|
|
|
and `tenant_id` = #{tenantId} |
|
|
|
<if test=" null != startTime "> |
|
|
|
and credit.create_date >= #{startTime} |
|
|
|
</if> |
|
|
|
@@ -244,13 +228,20 @@ |
|
|
|
and credit.create_date < #{endTime} |
|
|
|
</if> |
|
|
|
GROUP BY credit.merchant_id |
|
|
|
) a on a.merchant_id = wm.id |
|
|
|
left join |
|
|
|
( |
|
|
|
select credit.merchant_id,sum(credit.credit_num) sum_credit_num |
|
|
|
from wx_credit_history${shardFinalTableSuffix} credit |
|
|
|
where credit.merchant_id is not null |
|
|
|
and credit.merchant_id != -1 and credit.credit_num < 0 |
|
|
|
ORDER BY sumAddCredit desc |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="merchantCreditLes" parameterType="com.iformall.domain.po.WxCreditHistory" resultType="com.iformall.domain.vo.MerchantCreditRankingVo"> |
|
|
|
select credit.merchant_id merchantId,sum(credit.credit_num) sumLesCredit |
|
|
|
from wx_credit_history credit |
|
|
|
where credit.credit_num < 0 |
|
|
|
and `tenant_id` = #{tenantId} |
|
|
|
<if test=" null != merchantIds "> |
|
|
|
and credit.merchant_id in |
|
|
|
<foreach collection="merchantIds" index="index" item="merchantIdItem" open="(" separator="," close=")"> |
|
|
|
#{merchantIdItem} |
|
|
|
</foreach> |
|
|
|
</if> |
|
|
|
<if test=" null != startTime "> |
|
|
|
and credit.create_date >= #{startTime} |
|
|
|
</if> |
|
|
|
@@ -258,13 +249,19 @@ |
|
|
|
and credit.create_date < #{endTime} |
|
|
|
</if> |
|
|
|
GROUP BY credit.merchant_id |
|
|
|
) b on b.merchant_id = wm.id |
|
|
|
left join |
|
|
|
( |
|
|
|
select credit.merchant_id,count(distinct credit.c_user_id) count_c_user_id |
|
|
|
from wx_credit_history${shardFinalTableSuffix} credit |
|
|
|
where credit.merchant_id is not null |
|
|
|
and credit.merchant_id != -1 and credit.credit_num > 0 |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="merchantCreditAddUserCount" parameterType="com.iformall.domain.po.WxCreditHistory" resultType="com.iformall.domain.vo.MerchantCreditRankingVo"> |
|
|
|
select credit.merchant_id merchantId,count(distinct credit.c_user_id) countAddCreditUser |
|
|
|
from wx_credit_history credit |
|
|
|
where credit.credit_num > 0 |
|
|
|
and `tenant_id` = #{tenantId} |
|
|
|
<if test=" null != merchantIds "> |
|
|
|
and credit.merchant_id in |
|
|
|
<foreach collection="merchantIds" index="index" item="merchantIdItem" open="(" separator="," close=")"> |
|
|
|
#{merchantIdItem} |
|
|
|
</foreach> |
|
|
|
</if> |
|
|
|
<if test=" null != startTime "> |
|
|
|
and credit.create_date >= #{startTime} |
|
|
|
</if> |
|
|
|
@@ -272,26 +269,29 @@ |
|
|
|
and credit.create_date < #{endTime} |
|
|
|
</if> |
|
|
|
GROUP BY credit.merchant_id |
|
|
|
) c on c.merchant_id = wm.id |
|
|
|
left join |
|
|
|
( |
|
|
|
select credit.merchant_id,count(distinct credit.c_user_id) count_c_user_id |
|
|
|
from wx_credit_history${shardFinalTableSuffix} credit |
|
|
|
where credit.merchant_id is not null |
|
|
|
and credit.merchant_id != -1 and credit.credit_num < 0 |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="merchantCreditLesUserCount" parameterType="com.iformall.domain.po.WxCreditHistory" resultType="com.iformall.domain.vo.MerchantCreditRankingVo"> |
|
|
|
select credit.merchant_id merchantId,count(distinct credit.c_user_id) countLesCreditUser |
|
|
|
from wx_credit_history credit |
|
|
|
where credit.credit_num < 0 |
|
|
|
and `tenant_id` = #{tenantId} |
|
|
|
<if test=" null != merchantIds "> |
|
|
|
and credit.merchant_id in |
|
|
|
<foreach collection="merchantIds" index="index" item="merchantIdItem" open="(" separator="," close=")"> |
|
|
|
#{merchantIdItem} |
|
|
|
</foreach> |
|
|
|
</if> |
|
|
|
<if test=" null != startTime "> |
|
|
|
and credit.create_date >= #{startTime} |
|
|
|
</if> |
|
|
|
<if test=" null != endTime"> |
|
|
|
and credit.create_date <= #{endTime} |
|
|
|
and credit.create_date < #{endTime} |
|
|
|
</if> |
|
|
|
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 |
|
|
|
|
|
|
|
</select> |
|
|
|
|
|
|
|
|
|
|
|
<select id="findAddList" parameterType="com.iformall.domain.po.WxCreditHistory" |
|
|
|
resultType="com.iformall.domain.po.WxCreditHistory"> |
|
|
|
select credit.c_user_id cUserId,ifnull(sum(credit.credit_num),0) creditNum |
|
|
|
|