xhxu 4 лет назад
Родитель
Сommit
2562b43d49
3 измененных файлов: 70 добавлений и 50 удалений
  1. +7
    -1
      mallinkService/src/main/java/com/iformall/mapper/WxCreditHistoryMapper.java
  2. +15
    -1
      mallinkService/src/main/java/com/iformall/service/impl/WxCreditHistoryServiceImpl.java
  3. +48
    -48
      mallinkService/src/main/resources/mapper/WxCreditHistoryMapper.xml

+ 7
- 1
mallinkService/src/main/java/com/iformall/mapper/WxCreditHistoryMapper.java Просмотреть файл

@@ -38,7 +38,13 @@ public interface WxCreditHistoryMapper extends CommonMapper<WxCreditHistory, Lon

Integer getLesCreditSummary(WxCreditHistory wxCreditHistory);

List<MerchantCreditRankingVo> merchantCreditRanking(WxCreditHistory record);
List<MerchantCreditRankingVo> merchantCreditAdd(WxCreditHistory record);

List<MerchantCreditRankingVo> merchantCreditLes(WxCreditHistory record);

List<MerchantCreditRankingVo> merchantCreditAddUserCount(WxCreditHistory record);

List<MerchantCreditRankingVo> merchantCreditLesUserCount(WxCreditHistory record);

int monthCount(WxCreditHistory record);



+ 15
- 1
mallinkService/src/main/java/com/iformall/service/impl/WxCreditHistoryServiceImpl.java Просмотреть файл

@@ -377,7 +377,21 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService {

@Override
public PageInfo<MerchantCreditRankingVo> listAsPageMcrv(WxCreditHistory record, Integer pageIndex, Integer pageSize) {
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCreditHistoryMapper.merchantCreditRanking(record));
TenantEntity tenantEntity = new TenantEntity();
tenantEntity.setTenantId(record.getTenantId());
tenantEntity.setParentTenantId(record.getParentTenantId());

record.setTenantId(record.getFinalTenantId());
PageInfo<MerchantCreditRankingVo> pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCreditHistoryMapper.merchantCreditAdd(record));
if(pageInfo.getList() != null && pageInfo.getList().size() > 0){
List<Long> merchantIds = pageInfo.getList().stream().map(mcr -> mcr.getMerchantId()).collect(Collectors.toList());
Map<Long, String> merchantNameMap = getMerchantNameMap(tenantEntity, merchantIds);



}

return pageInfo;
}

@Override


+ 48
- 48
mallinkService/src/main/resources/mapper/WxCreditHistoryMapper.xml Просмотреть файл

@@ -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 &gt; 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 &gt; 0
and `tenant_id` = #{tenantId}
<if test=" null != startTime ">
and credit.create_date &gt;= #{startTime}
</if>
@@ -244,13 +228,20 @@
and credit.create_date &lt; #{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 &lt; 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 &lt; 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 &gt;= #{startTime}
</if>
@@ -258,13 +249,19 @@
and credit.create_date &lt; #{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 &gt; 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 &gt; 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 &gt;= #{startTime}
</if>
@@ -272,26 +269,29 @@
and credit.create_date &lt; #{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 &lt; 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 &lt; 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 &gt;= #{startTime}
</if>
<if test=" null != endTime">
and credit.create_date &lt;= #{endTime}
and credit.create_date &lt; #{endTime}
</if>
GROUP BY credit.merchant_id
) d on d.merchant_id = wm.id
where (IFNULL(a.sum_credit_num,0) &gt; 0 or IFNULL(b.sum_credit_num,0) &lt; 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


Загрузка…
Отмена
Сохранить