| @@ -11,6 +11,7 @@ import com.iformall.domain.po.MallUserInfo; | |||||
| import com.iformall.domain.po.WxCreditHistory; | import com.iformall.domain.po.WxCreditHistory; | ||||
| import com.iformall.domain.po.WxMerchant; | import com.iformall.domain.po.WxMerchant; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.vo.MerchantCreditRankingVo; | |||||
| import com.iformall.domain.vo.WxCreditHistoryVo; | import com.iformall.domain.vo.WxCreditHistoryVo; | ||||
| import com.iformall.enums.EnumMerchantStatus; | import com.iformall.enums.EnumMerchantStatus; | ||||
| import com.iformall.enums.EnumScoreType; | import com.iformall.enums.EnumScoreType; | ||||
| @@ -173,4 +174,19 @@ public class WxCreditHistoryController extends BaseController { | |||||
| return new ResultData(Result.SUCCESS); | return new ResultData(Result.SUCCESS); | ||||
| } | } | ||||
| @ApiOperation("门店排行榜") | |||||
| @GetMapping("merchantCreditRanking") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "、-列表") | |||||
| public ResultData merchantCreditRanking(@ModelAttribute WxCreditHistory wxCreditHistory, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::merchantCreditRanking"); | |||||
| if (null == wxCreditHistory) wxCreditHistory = new WxCreditHistory(); | |||||
| TenantEntity tenantInfo = getTenantInfo(); | |||||
| wxCreditHistory.updateTenantInfo(tenantInfo); | |||||
| final PageInfo<MerchantCreditRankingVo> page = wxCreditHistoryService.listAsPageMcrv(wxCreditHistory, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| } | } | ||||
| @@ -1,6 +1,7 @@ | |||||
| package com.iformall.domain.po.base; | package com.iformall.domain.po.base; | ||||
| import com.baomidou.mybatisplus.annotation.TableField; | import com.baomidou.mybatisplus.annotation.TableField; | ||||
| import com.fasterxml.jackson.annotation.JsonIgnore; | |||||
| import com.fasterxml.jackson.annotation.JsonProperty; | import com.fasterxml.jackson.annotation.JsonProperty; | ||||
| import lombok.Data; | import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
| @@ -35,6 +36,17 @@ public class BaseTenantEntity extends BaseEntity { | |||||
| public void setFinalTenantId(String finalTenantId) { | public void setFinalTenantId(String finalTenantId) { | ||||
| this.finalTenantId = finalTenantId; | this.finalTenantId = finalTenantId; | ||||
| } | } | ||||
| @JsonIgnore | |||||
| @TableField(exist = false) | |||||
| protected String shardFinalTableSuffix; | |||||
| public String getShardFinalTableSuffix(){ | |||||
| if(StringUtils.isNotBlank(finalTenantId)){ | |||||
| shardFinalTableSuffix = "_" + Integer.parseInt(finalTenantId)%100; | |||||
| } | |||||
| return shardFinalTableSuffix; | |||||
| } | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| @JsonProperty(access = JsonProperty.Access.READ_ONLY) | @JsonProperty(access = JsonProperty.Access.READ_ONLY) | ||||
| @@ -0,0 +1,20 @@ | |||||
| package com.iformall.domain.vo; | |||||
| import lombok.Data; | |||||
| @Data | |||||
| public class MerchantCreditRankingVo { | |||||
| private Long merchantId; | |||||
| private String merchantName; | |||||
| private Integer sumAddCredit; | |||||
| private Integer sumLesCredit; | |||||
| private Integer countAddCreditUser; | |||||
| private Integer countLesCreditUser; | |||||
| } | |||||
| @@ -2,6 +2,7 @@ package com.iformall.mapper; | |||||
| import com.iformall.common.CommonMapper; | import com.iformall.common.CommonMapper; | ||||
| import com.iformall.domain.po.WxCreditHistory; | import com.iformall.domain.po.WxCreditHistory; | ||||
| import com.iformall.domain.vo.MerchantCreditRankingVo; | |||||
| import com.iformall.domain.vo.WxCreditHistoryNewIdVo; | import com.iformall.domain.vo.WxCreditHistoryNewIdVo; | ||||
| import com.iformall.domain.vo.WxCreditHistoryVo; | import com.iformall.domain.vo.WxCreditHistoryVo; | ||||
| import org.apache.ibatis.annotations.Param; | import org.apache.ibatis.annotations.Param; | ||||
| @@ -38,4 +39,6 @@ public interface WxCreditHistoryMapper extends CommonMapper<WxCreditHistory, Lon | |||||
| Integer getAddCreditSummary(WxCreditHistory wxCreditHistory); | Integer getAddCreditSummary(WxCreditHistory wxCreditHistory); | ||||
| Integer getLesCreditSummary(WxCreditHistory wxCreditHistory); | Integer getLesCreditSummary(WxCreditHistory wxCreditHistory); | ||||
| MerchantCreditRankingVo merchantCreditRanking(WxCreditHistory record); | |||||
| } | } | ||||
| @@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.po.WxCreditHistory; | import com.iformall.domain.po.WxCreditHistory; | ||||
| import com.iformall.domain.vo.MerchantCreditRankingVo; | |||||
| import com.iformall.domain.vo.WxCreditHistoryVo; | import com.iformall.domain.vo.WxCreditHistoryVo; | ||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| @@ -82,4 +83,6 @@ public interface WxCreditHistoryService { | |||||
| Integer getAddCreditSummary(WxCreditHistory wxCreditHistory); | Integer getAddCreditSummary(WxCreditHistory wxCreditHistory); | ||||
| Integer getLesCreditSummary(WxCreditHistory wxCreditHistory); | Integer getLesCreditSummary(WxCreditHistory wxCreditHistory); | ||||
| PageInfo<MerchantCreditRankingVo> listAsPageMcrv(WxCreditHistory record, Integer pageIndex, Integer pageSize); | |||||
| } | } | ||||
| @@ -11,6 +11,7 @@ import com.iformall.common.IdWorker; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.vo.MerchantCreditRankingVo; | |||||
| import com.iformall.domain.vo.WxCreditHistoryVo; | import com.iformall.domain.vo.WxCreditHistoryVo; | ||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| @@ -144,6 +145,11 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||||
| return wxCreditHistoryMapper.getLesCreditSummary(wxCreditHistory); | return wxCreditHistoryMapper.getLesCreditSummary(wxCreditHistory); | ||||
| } | } | ||||
| @Override | |||||
| public PageInfo<MerchantCreditRankingVo> listAsPageMcrv(WxCreditHistory record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCreditHistoryMapper.merchantCreditRanking(record)); | |||||
| } | |||||
| @Override | @Override | ||||
| public PageInfo<WxCreditHistory> listAsPage(WxCreditHistory record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxCreditHistory> listAsPage(WxCreditHistory record, Integer pageIndex, Integer pageSize) { | ||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCreditHistoryMapper.findList(record)); | return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCreditHistoryMapper.findList(record)); | ||||
| @@ -293,4 +293,73 @@ | |||||
| {call user_credit_clear(#{cutOffDate},#{finalTableIndex})} | {call user_credit_clear(#{cutOffDate},#{finalTableIndex})} | ||||
| </update> | </update> | ||||
| <select id="merchantCreditRanking" parameterType="com.iformall.domain.po.WxCreditHistory" resultType="com.iformall.domain.vo.MerchantCreditRankingVo"> | |||||
| select wm.id merchantId,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,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 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 | |||||
| <if test=" null != startTime "> | |||||
| and create_date >= #{startTime} | |||||
| </if> | |||||
| <if test=" null != endTime"> | |||||
| and create_date < #{endTime} | |||||
| </if> | |||||
| GROUP BY 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 | |||||
| <if test=" null != startTime "> | |||||
| and create_date >= #{startTime} | |||||
| </if> | |||||
| <if test=" null != endTime"> | |||||
| and create_date < #{endTime} | |||||
| </if> | |||||
| GROUP BY 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 | |||||
| <if test=" null != startTime "> | |||||
| and create_date >= #{startTime} | |||||
| </if> | |||||
| <if test=" null != endTime"> | |||||
| and create_date < #{endTime} | |||||
| </if> | |||||
| GROUP BY 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 | |||||
| <if test=" null != startTime "> | |||||
| and create_date >= #{startTime} | |||||
| </if> | |||||
| <if test=" null != endTime"> | |||||
| and create_date < #{endTime} | |||||
| </if> | |||||
| GROUP BY merchant_id | |||||
| ) d on d.merchant_id = wm.id | |||||
| ORDER BY sumAddCredit desc | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||
| @@ -610,4 +610,5 @@ | |||||
| order by create_date desc | order by create_date desc | ||||
| </select> | </select> | ||||
| </mapper> | </mapper> | ||||