Commit b33504fca8135d83590d3e54060dcec02add9e01

Authored by 李杉
1 parent f7e9d839

feat(report): 中瑞新增线上支付明细报表

cashier-boss/src/main/java/com/diligrp/cashier/boss/controller/OnlinePaymentReportController.java 0 → 100644
  1 +package com.diligrp.cashier.boss.controller;
  2 +
  3 +import com.diligrp.cashier.boss.domain.OnlinePaymentReportDTO;
  4 +import com.diligrp.cashier.boss.service.IOnlinePaymentReportService;
  5 +import com.diligrp.cashier.shared.domain.PageMessage;
  6 +import com.diligrp.cashier.shared.util.AssertUtils;
  7 +import jakarta.annotation.Resource;
  8 +import org.springframework.web.bind.annotation.RequestBody;
  9 +import org.springframework.web.bind.annotation.RequestMapping;
  10 +import org.springframework.web.bind.annotation.RestController;
  11 +
  12 +/**
  13 + * 线上支付相关报表 Controller
  14 + */
  15 +@RestController
  16 +@RequestMapping(value = "/onlinePayment/report")
  17 +public class OnlinePaymentReportController {
  18 +
  19 + @Resource
  20 + private IOnlinePaymentReportService onlinePaymentReportService;
  21 +
  22 + @RequestMapping(value = "/listDetail/loadData")
  23 + public PageMessage<?> listDetailLoadData(@RequestBody OnlinePaymentReportDTO request) {
  24 + // 基本参数校验
  25 + AssertUtils.notNull(request.getMchId(), "mchId missed");
  26 + AssertUtils.notEmpty(request.getStartTime(), "startTime missed");
  27 + AssertUtils.notEmpty(request.getEndTime(), "endTime missed");
  28 +
  29 + return onlinePaymentReportService.listDetail(request);
  30 + }
  31 +}
cashier-boss/src/main/java/com/diligrp/cashier/boss/dao/IOnlinePaymentReportDao.java 0 → 100644
  1 +package com.diligrp.cashier.boss.dao;
  2 +
  3 +import com.diligrp.cashier.boss.domain.OnlinePaymentDetailVO;
  4 +import com.diligrp.cashier.boss.domain.OnlinePaymentReportDTO;
  5 +import com.diligrp.cashier.shared.mybatis.MybatisMapperSupport;
  6 +
  7 +import java.util.List;
  8 +
  9 +public interface IOnlinePaymentReportDao extends MybatisMapperSupport {
  10 + List<OnlinePaymentDetailVO> listDetail(OnlinePaymentReportDTO request);
  11 +}
cashier-boss/src/main/java/com/diligrp/cashier/boss/domain/OnlinePaymentDetailVO.java 0 → 100644
  1 +package com.diligrp.cashier.boss.domain;
  2 +
  3 +public class OnlinePaymentDetailVO {
  4 + /** 主键ID */
  5 + private Long id;
  6 + /** 商户ID */
  7 + private Long mchId;
  8 + /** 商户名称 */
  9 + private String mchName;
  10 + /** 交易ID */
  11 + private String tradeId;
  12 + /** 支付ID */
  13 + private String paymentId;
  14 + /** 外部流水号 */
  15 + private String serialNo;
  16 + /** 付款人 */
  17 + private String payerId;
  18 + /** 客户账号ID */
  19 + private Long customerAccountId;
  20 + /** 客户ID */
  21 + private Long customerId;
  22 + /** 客户编码 */
  23 + private String customerCode;
  24 + /** 客户名称 */
  25 + private String customerName;
  26 + /** 支付通道 */
  27 + private Integer channelId;
  28 + /** 支付通道名称 */
  29 + private String channelName;
  30 + /** 实际支付方式 */
  31 + private Integer outPayType;
  32 + /** 实际支付方式名称 */
  33 + private String outPayTypeName;
  34 + /** 交易类型 */
  35 + private Integer tradeType;
  36 + /** 交易类型名称 */
  37 + private String tradeTypeName;
  38 + /** 商品描述 */
  39 + private String goods;
  40 + /** 申请金额-分 */
  41 + private Long amount;
  42 + /** 申请金额-文本 */
  43 + private String amountText;
  44 + /** 费用金额-分 */
  45 + private Long fee;
  46 + /** 费用金额-文本 */
  47 + private String feeText;
  48 + /** 笔数 */
  49 + private Long countTotal;
  50 + /** 支付时间 */
  51 + private String payTime;
  52 + /** 创建时间 */
  53 + private String createdTime;
  54 + /** 修改时间 */
  55 + private String modifiedTime;
  56 + /** 申请状态 */
  57 + private Integer state;
  58 + /** 申请状态名称 */
  59 + private String stateName;
  60 + /** 订单来源 */
  61 + private Integer source;
  62 + /** 订单来源名称 */
  63 + private String sourceName;
  64 + /** 交易备注 */
  65 + private String description;
  66 + /** 申请金额-分 */
  67 + private Long totalRowAmount;
  68 + /** 申请金额-文本 */
  69 + private String totalRowAmountText;
  70 + /** 费用金额-分 */
  71 + private Long totalRowFee;
  72 + /** 费用金额-文本 */
  73 + private String totalRowFeeText;
  74 +
  75 + private Object totalRow;
  76 +
  77 + public Long getId() {
  78 + return id;
  79 + }
  80 +
  81 + public void setId(Long id) {
  82 + this.id = id;
  83 + }
  84 +
  85 + public Long getMchId() {
  86 + return mchId;
  87 + }
  88 +
  89 + public void setMchId(Long mchId) {
  90 + this.mchId = mchId;
  91 + }
  92 +
  93 + public String getMchName() {
  94 + return mchName;
  95 + }
  96 +
  97 + public void setMchName(String mchName) {
  98 + this.mchName = mchName;
  99 + }
  100 +
  101 + public String getTradeId() {
  102 + return tradeId;
  103 + }
  104 +
  105 + public void setTradeId(String tradeId) {
  106 + this.tradeId = tradeId;
  107 + }
  108 +
  109 + public String getPaymentId() {
  110 + return paymentId;
  111 + }
  112 +
  113 + public void setPaymentId(String paymentId) {
  114 + this.paymentId = paymentId;
  115 + }
  116 +
  117 + public String getSerialNo() {
  118 + return serialNo;
  119 + }
  120 +
  121 + public void setSerialNo(String serialNo) {
  122 + this.serialNo = serialNo;
  123 + }
  124 +
  125 + public String getPayerId() {
  126 + return payerId;
  127 + }
  128 +
  129 + public void setPayerId(String payerId) {
  130 + this.payerId = payerId;
  131 + }
  132 +
  133 + public Long getCustomerAccountId() {
  134 + return customerAccountId;
  135 + }
  136 +
  137 + public void setCustomerAccountId(Long customerAccountId) {
  138 + this.customerAccountId = customerAccountId;
  139 + }
  140 +
  141 + public Long getCustomerId() {
  142 + return customerId;
  143 + }
  144 +
  145 + public void setCustomerId(Long customerId) {
  146 + this.customerId = customerId;
  147 + }
  148 +
  149 + public String getCustomerCode() {
  150 + return customerCode;
  151 + }
  152 +
  153 + public void setCustomerCode(String customerCode) {
  154 + this.customerCode = customerCode;
  155 + }
  156 +
  157 + public String getCustomerName() {
  158 + return customerName;
  159 + }
  160 +
  161 + public void setCustomerName(String customerName) {
  162 + this.customerName = customerName;
  163 + }
  164 +
  165 + public Integer getChannelId() {
  166 + return channelId;
  167 + }
  168 +
  169 + public void setChannelId(Integer channelId) {
  170 + this.channelId = channelId;
  171 + }
  172 +
  173 + public String getChannelName() {
  174 + return channelName;
  175 + }
  176 +
  177 + public void setChannelName(String channelName) {
  178 + this.channelName = channelName;
  179 + }
  180 +
  181 + public Integer getOutPayType() {
  182 + return outPayType;
  183 + }
  184 +
  185 + public void setOutPayType(Integer outPayType) {
  186 + this.outPayType = outPayType;
  187 + }
  188 +
  189 + public String getOutPayTypeName() {
  190 + return outPayTypeName;
  191 + }
  192 +
  193 + public void setOutPayTypeName(String outPayTypeName) {
  194 + this.outPayTypeName = outPayTypeName;
  195 + }
  196 +
  197 + public Integer getTradeType() {
  198 + return tradeType;
  199 + }
  200 +
  201 + public void setTradeType(Integer tradeType) {
  202 + this.tradeType = tradeType;
  203 + }
  204 +
  205 + public String getTradeTypeName() {
  206 + return tradeTypeName;
  207 + }
  208 +
  209 + public void setTradeTypeName(String tradeTypeName) {
  210 + this.tradeTypeName = tradeTypeName;
  211 + }
  212 +
  213 + public String getGoods() {
  214 + return goods;
  215 + }
  216 +
  217 + public void setGoods(String goods) {
  218 + this.goods = goods;
  219 + }
  220 +
  221 + public Long getAmount() {
  222 + return amount;
  223 + }
  224 +
  225 + public void setAmount(Long amount) {
  226 + this.amount = amount;
  227 + }
  228 +
  229 + public String getAmountText() {
  230 + return amountText;
  231 + }
  232 +
  233 + public void setAmountText(String amountText) {
  234 + this.amountText = amountText;
  235 + }
  236 +
  237 + public Long getFee() {
  238 + return fee;
  239 + }
  240 +
  241 + public void setFee(Long fee) {
  242 + this.fee = fee;
  243 + }
  244 +
  245 + public String getFeeText() {
  246 + return feeText;
  247 + }
  248 +
  249 + public void setFeeText(String feeText) {
  250 + this.feeText = feeText;
  251 + }
  252 +
  253 + public Long getCountTotal() {
  254 + return countTotal;
  255 + }
  256 +
  257 + public void setCountTotal(Long countTotal) {
  258 + this.countTotal = countTotal;
  259 + }
  260 +
  261 + public String getPayTime() {
  262 + return payTime;
  263 + }
  264 +
  265 + public void setPayTime(String payTime) {
  266 + this.payTime = payTime;
  267 + }
  268 +
  269 + public String getCreatedTime() {
  270 + return createdTime;
  271 + }
  272 +
  273 + public void setCreatedTime(String createdTime) {
  274 + this.createdTime = createdTime;
  275 + }
  276 +
  277 + public String getModifiedTime() {
  278 + return modifiedTime;
  279 + }
  280 +
  281 + public void setModifiedTime(String modifiedTime) {
  282 + this.modifiedTime = modifiedTime;
  283 + }
  284 +
  285 + public Integer getState() {
  286 + return state;
  287 + }
  288 +
  289 + public void setState(Integer state) {
  290 + this.state = state;
  291 + }
  292 +
  293 + public String getStateName() {
  294 + return stateName;
  295 + }
  296 +
  297 + public void setStateName(String stateName) {
  298 + this.stateName = stateName;
  299 + }
  300 +
  301 + public Integer getSource() {
  302 + return source;
  303 + }
  304 +
  305 + public void setSource(Integer source) {
  306 + this.source = source;
  307 + }
  308 +
  309 + public String getSourceName() {
  310 + return sourceName;
  311 + }
  312 +
  313 + public void setSourceName(String sourceName) {
  314 + this.sourceName = sourceName;
  315 + }
  316 +
  317 + public String getDescription() {
  318 + return description;
  319 + }
  320 +
  321 + public void setDescription(String description) {
  322 + this.description = description;
  323 + }
  324 +
  325 + public Long getTotalRowAmount() {
  326 + return totalRowAmount;
  327 + }
  328 +
  329 + public void setTotalRowAmount(Long totalRowAmount) {
  330 + this.totalRowAmount = totalRowAmount;
  331 + }
  332 +
  333 + public String getTotalRowAmountText() {
  334 + return totalRowAmountText;
  335 + }
  336 +
  337 + public void setTotalRowAmountText(String totalRowAmountText) {
  338 + this.totalRowAmountText = totalRowAmountText;
  339 + }
  340 +
  341 + public Long getTotalRowFee() {
  342 + return totalRowFee;
  343 + }
  344 +
  345 + public void setTotalRowFee(Long totalRowFee) {
  346 + this.totalRowFee = totalRowFee;
  347 + }
  348 +
  349 + public String getTotalRowFeeText() {
  350 + return totalRowFeeText;
  351 + }
  352 +
  353 + public void setTotalRowFeeText(String totalRowFeeText) {
  354 + this.totalRowFeeText = totalRowFeeText;
  355 + }
  356 +
  357 + public Object getTotalRow() {
  358 + return totalRow;
  359 + }
  360 +
  361 + public void setTotalRow(Object totalRow) {
  362 + this.totalRow = totalRow;
  363 + }
  364 +}
cashier-boss/src/main/java/com/diligrp/cashier/boss/domain/OnlinePaymentReportDTO.java 0 → 100644
  1 +package com.diligrp.cashier.boss.domain;
  2 +
  3 +import java.util.List;
  4 +
  5 +public class OnlinePaymentReportDTO extends ReportQuery {
  6 + /** 客户 ID */
  7 + private Long customerId;
  8 + /** 客户名称 */
  9 + private String customerName;
  10 + /** 支付起始时间 */
  11 + private String startPayTime;
  12 + /** 支付截止时间 */
  13 + private String endPayTime;
  14 + /** 交易 ID */
  15 + private String tradeId;
  16 + /** 支付ID */
  17 + private String paymentId;
  18 + /** 外部流水号 */
  19 + private String serialNo;
  20 + /** 支付通道列表 */
  21 + private List<Integer> channelIdList;
  22 + /** 实际支付方式列表 */
  23 + private List<Integer> outPayTypeList;
  24 + /** 交易类型列表 */
  25 + private List<Integer> tradeTypeList;
  26 + /** 订单来源列表 */
  27 + private List<Integer> sourceList;
  28 + /** 状态列表 */
  29 + private List<Integer> stateList;
  30 +
  31 + public Long getCustomerId() {
  32 + return customerId;
  33 + }
  34 +
  35 + public void setCustomerId(Long customerId) {
  36 + this.customerId = customerId;
  37 + }
  38 +
  39 + public String getCustomerName() {
  40 + return customerName;
  41 + }
  42 +
  43 + public void setCustomerName(String customerName) {
  44 + this.customerName = customerName;
  45 + }
  46 +
  47 + public String getStartPayTime() {
  48 + return startPayTime;
  49 + }
  50 +
  51 + public void setStartPayTime(String startPayTime) {
  52 + this.startPayTime = startPayTime;
  53 + }
  54 +
  55 + public String getEndPayTime() {
  56 + return endPayTime;
  57 + }
  58 +
  59 + public void setEndPayTime(String endPayTime) {
  60 + this.endPayTime = endPayTime;
  61 + }
  62 +
  63 + public String getTradeId() {
  64 + return tradeId;
  65 + }
  66 +
  67 + public void setTradeId(String tradeId) {
  68 + this.tradeId = tradeId;
  69 + }
  70 +
  71 + public String getPaymentId() {
  72 + return paymentId;
  73 + }
  74 +
  75 + public void setPaymentId(String paymentId) {
  76 + this.paymentId = paymentId;
  77 + }
  78 +
  79 + public String getSerialNo() {
  80 + return serialNo;
  81 + }
  82 +
  83 + public void setSerialNo(String serialNo) {
  84 + this.serialNo = serialNo;
  85 + }
  86 +
  87 + public List<Integer> getChannelIdList() {
  88 + return channelIdList;
  89 + }
  90 +
  91 + public void setChannelIdList(List<Integer> channelIdList) {
  92 + this.channelIdList = channelIdList;
  93 + }
  94 +
  95 + public List<Integer> getOutPayTypeList() {
  96 + return outPayTypeList;
  97 + }
  98 +
  99 + public void setOutPayTypeList(List<Integer> outPayTypeList) {
  100 + this.outPayTypeList = outPayTypeList;
  101 + }
  102 +
  103 + public List<Integer> getTradeTypeList() {
  104 + return tradeTypeList;
  105 + }
  106 +
  107 + public void setTradeTypeList(List<Integer> tradeTypeList) {
  108 + this.tradeTypeList = tradeTypeList;
  109 + }
  110 +
  111 + public List<Integer> getSourceList() {
  112 + return sourceList;
  113 + }
  114 +
  115 + public void setSourceList(List<Integer> sourceList) {
  116 + this.sourceList = sourceList;
  117 + }
  118 +
  119 + public List<Integer> getStateList() {
  120 + return stateList;
  121 + }
  122 +
  123 + public void setStateList(List<Integer> stateList) {
  124 + this.stateList = stateList;
  125 + }
  126 +}
cashier-boss/src/main/java/com/diligrp/cashier/boss/domain/ReportQuery.java 0 → 100644
  1 +package com.diligrp.cashier.boss.domain;
  2 +
  3 +import com.diligrp.cashier.shared.domain.PageQuery;
  4 +
  5 +public class ReportQuery extends PageQuery {
  6 + /** 商户 ID */
  7 + private Long mchId;
  8 + /** 开始时间 */
  9 + private String startTime;
  10 + /** 结束时间 */
  11 + private String endTime;
  12 + /** 合计行模式 */
  13 + private Boolean totalMode;
  14 + /** 排序字段 */
  15 + private String sort;
  16 + /** 排序规则 */
  17 + private String order;
  18 +
  19 + public Long getMchId() {
  20 + return mchId;
  21 + }
  22 +
  23 + public void setMchId(Long mchId) {
  24 + this.mchId = mchId;
  25 + }
  26 +
  27 + public String getStartTime() {
  28 + return startTime;
  29 + }
  30 +
  31 + public void setStartTime(String startTime) {
  32 + this.startTime = startTime;
  33 + }
  34 +
  35 + public String getEndTime() {
  36 + return endTime;
  37 + }
  38 +
  39 + public void setEndTime(String endTime) {
  40 + this.endTime = endTime;
  41 + }
  42 +
  43 + public Boolean getTotalMode() {
  44 + return totalMode;
  45 + }
  46 +
  47 + public void setTotalMode(Boolean totalMode) {
  48 + this.totalMode = totalMode;
  49 + }
  50 +
  51 + public String getSort() {
  52 + return sort;
  53 + }
  54 +
  55 + public void setSort(String sort) {
  56 + this.sort = sort;
  57 + }
  58 +
  59 + public String getOrder() {
  60 + return order;
  61 + }
  62 +
  63 + public void setOrder(String order) {
  64 + this.order = order;
  65 + }
  66 +}
cashier-boss/src/main/java/com/diligrp/cashier/boss/service/IOnlinePaymentReportService.java 0 → 100644
  1 +package com.diligrp.cashier.boss.service;
  2 +
  3 +import com.diligrp.cashier.boss.domain.OnlinePaymentDetailVO;
  4 +import com.diligrp.cashier.boss.domain.OnlinePaymentReportDTO;
  5 +import com.diligrp.cashier.shared.domain.PageMessage;
  6 +
  7 +/**
  8 + * 线上支付相关报表 Service
  9 + */
  10 +public interface IOnlinePaymentReportService {
  11 +
  12 + PageMessage<OnlinePaymentDetailVO> listDetail(OnlinePaymentReportDTO request);
  13 +}
cashier-boss/src/main/java/com/diligrp/cashier/boss/service/impl/OnlinePaymentReportServiceImpl.java 0 → 100644
  1 +package com.diligrp.cashier.boss.service.impl;
  2 +
  3 +import com.diligrp.cashier.boss.dao.IOnlinePaymentReportDao;
  4 +import com.diligrp.cashier.boss.domain.OnlinePaymentDetailVO;
  5 +import com.diligrp.cashier.boss.domain.OnlinePaymentReportDTO;
  6 +import com.diligrp.cashier.boss.service.IOnlinePaymentReportService;
  7 +import com.diligrp.cashier.pipeline.type.ChannelType;
  8 +import com.diligrp.cashier.pipeline.type.OutPaymentType;
  9 +import com.diligrp.cashier.shared.domain.PageMessage;
  10 +import com.diligrp.cashier.shared.type.SourceType;
  11 +import com.diligrp.cashier.shared.util.CurrencyUtils;
  12 +import com.diligrp.cashier.trade.type.TradeState;
  13 +import com.diligrp.cashier.trade.type.TradeType;
  14 +import jakarta.annotation.Resource;
  15 +import org.apache.commons.collections4.CollectionUtils;
  16 +import org.springframework.stereotype.Service;
  17 +
  18 +import java.util.List;
  19 +
  20 +/**
  21 + * 线上支付相关报表 Service 实现类
  22 + */
  23 +@Service("onlinePaymentReportService")
  24 +public class OnlinePaymentReportServiceImpl implements IOnlinePaymentReportService {
  25 +
  26 + @Resource
  27 + private IOnlinePaymentReportDao onlinePaymentReportDao;
  28 +
  29 + @Override
  30 + public PageMessage<OnlinePaymentDetailVO> listDetail(OnlinePaymentReportDTO request) {
  31 + request.setTotalMode(true);
  32 + List<OnlinePaymentDetailVO> totalList = onlinePaymentReportDao.listDetail(request);
  33 + if (CollectionUtils.isEmpty(totalList)) {
  34 + return PageMessage.success(0, List.of());
  35 + }
  36 +
  37 + totalList.forEach(item -> {
  38 + item.setAmountText(CurrencyUtils.cent2TenNoSymbol(item.getAmount()));
  39 + item.setFeeText(CurrencyUtils.cent2TenNoSymbol(item.getFee()));
  40 + });
  41 +
  42 + request.setTotalMode(false);
  43 + request.from(request.getPageNo(), request.getPageSize());
  44 + List<OnlinePaymentDetailVO> dataList = onlinePaymentReportDao.listDetail(request);
  45 + dataList.forEach(item -> {
  46 + item.setOutPayTypeName(OutPaymentType.getName(item.getOutPayType()));
  47 + item.setChannelName(ChannelType.getName(item.getChannelId()));
  48 + item.setTradeTypeName(TradeType.getName(item.getTradeType()));
  49 + item.setSourceName(SourceType.getName(item.getSource()));
  50 + item.setStateName(TradeState.getName(item.getState()));
  51 +
  52 + item.setAmountText(CurrencyUtils.cent2TenNoSymbol(item.getAmount()));
  53 + item.setFeeText(CurrencyUtils.cent2TenNoSymbol(item.getFee()));
  54 + });
  55 +
  56 + // 合计行添加到首行中
  57 + OnlinePaymentDetailVO totalRow = totalList.getFirst();
  58 + dataList.getFirst().setTotalRow(totalRow);
  59 +
  60 + return PageMessage.success(totalRow.getCountTotal(), dataList);
  61 + }
  62 +}
cashier-boss/src/main/resources/com/diligrp/cashier/dao/mapper/IOnlinePaymentReportDao.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8" ?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3 + "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4 +
  5 +<mapper namespace="com.diligrp.cashier.boss.dao.IOnlinePaymentReportDao">
  6 + <!-- ################################################################################ -->
  7 + <!-- ############################ 线上支付交易记录 ############################### -->
  8 + <!-- ################################################################################ -->
  9 + <select id="listDetail"
  10 + parameterType="com.diligrp.cashier.boss.domain.OnlinePaymentReportDTO"
  11 + resultType="com.diligrp.cashier.boss.domain.OnlinePaymentDetailVO">
  12 + <choose>
  13 + <when test="totalMode != null and totalMode == true">
  14 + SELECT SUM(CASE WHEN cp.type = 20 THEN -1 WHEN cp.type = 10 THEN 1 ELSE 0 END * cp.amount) AS `amount`
  15 + , SUM(CASE WHEN cp.type = 20 THEN -1 WHEN cp.type = 10 THEN 1 ELSE 0 END * 0) AS `fee`
  16 + , COUNT(*) AS `count_total`
  17 + </when>
  18 + <otherwise>
  19 + SELECT cp.id
  20 + , o.mch_id
  21 + , cp.out_mch_id
  22 + , mer.`name` AS `mch_name`
  23 + , cp.trade_id
  24 + , cp.payment_id
  25 + <!-- ## , cp.out_trade_no -->
  26 + , o.out_trade_no AS `serial_no`
  27 + , cp.payer_id
  28 + , IF(cp.channel_id = 19, JSON_EXTRACT(cp.payer_id, '$.accountId'), NULL) AS `customer_account_id`
  29 + , IF(cp.channel_id = 19, cp.payer_id->'$.customerId', NULL) AS `customer_id`
  30 + , IF(cp.channel_id = 19, JSON_EXTRACT(cp.payer_id, '$.customerCode'), NULL) AS `customer_code`
  31 + , IF(cp.channel_id = 19, cp.payer_id->>'$.name', NULL) AS `customer_name`
  32 + , cp.channel_id
  33 + <!-- ## , cp.pay_type -->
  34 + , cp.out_pay_type
  35 + , cp.type AS `trade_type`
  36 + , cp.goods
  37 + , SUM(CASE WHEN cp.type = 20 THEN -1 WHEN cp.type = 10 THEN 1 ELSE 0 END * cp.amount) AS `amount`
  38 + , SUM(CASE WHEN cp.type = 20 THEN -1 WHEN cp.type = 10 THEN 1 ELSE 0 END * 0) AS `fee`
  39 + , COUNT(*) AS `count_total`
  40 + , cp.finish_time AS `pay_time`
  41 + , cp.created_time
  42 + , cp.modified_time
  43 + , cp.state
  44 + , o.source
  45 + , cp.description
  46 + </otherwise>
  47 + </choose>
  48 + FROM dili_cashier.upay_online_payment cp
  49 + LEFT JOIN dili_cashier.upay_trade_order o ON o.trade_id = cp.trade_id
  50 + LEFT JOIN dili_cashier.upay_merchant mer ON mer.mch_id = o.mch_id
  51 + WHERE 1 = 1
  52 + AND cp.channel_id IN (
  53 + SELECT pip.channel_id FROM dili_cashier.upay_payment_pipeline pip WHERE pip.mch_id = #{mchId}
  54 + )
  55 + AND o.mch_id = #{mchId}
  56 + AND cp.created_time &gt;= #{startTime}
  57 + AND cp.created_time &lt;= #{endTime}
  58 +
  59 + <if test="customerName != null and customerName != ''">
  60 + AND cp.channel_id = 19 AND cp.payer_id->>'$.name' LIKE CONCAT('%', #{customerName}, '%')
  61 + </if>
  62 + <if test="startPayTime != null and startPayTime != ''">
  63 + AND cp.finish_time &gt;= #{startPayTime}
  64 + </if>
  65 + <if test="endPayTime != null and endPayTime != ''">
  66 + AND cp.finish_time &lt;= #{endPayTime}
  67 + </if>
  68 + <if test="tradeId != null and tradeId != ''">
  69 + AND cp.trade_id = #{tradeId}
  70 + </if>
  71 + <if test="paymentId != null and paymentId != ''">
  72 + AND cp.payment_id = #{paymentId}
  73 + </if>
  74 + <if test="serialNo != null and serialNo != ''">
  75 + AND o.out_trade_no = #{serialNo}
  76 + </if>
  77 + <if test="channelIdList != null and channelIdList.size() > 0">
  78 + AND cp.channel_id IN
  79 + <foreach collection="channelIdList" item="item" open=" (" close=")" separator=",">#{item}</foreach>
  80 + </if>
  81 + <if test="outPayTypeList != null and outPayTypeList.size() > 0">
  82 + AND cp.out_pay_type IN
  83 + <foreach collection="outPayTypeList" item="item" open=" (" close=")" separator=",">#{item}</foreach>
  84 + </if>
  85 + <if test="tradeTypeList != null and tradeTypeList.size() > 0">
  86 + AND cp.type IN
  87 + <foreach collection="tradeTypeList" item="item" open=" (" close=")" separator=",">#{item}</foreach>
  88 + </if>
  89 + <if test="sourceList != null and sourceList.size() > 0">
  90 + AND o.source IN
  91 + <foreach collection="sourceList" item="item" open=" (" close=")" separator=",">#{item}</foreach>
  92 + </if>
  93 + <if test="stateList != null and stateList.size() > 0">
  94 + AND cp.state IN
  95 + <foreach collection="stateList" item="item" open=" (" close=")" separator=",">#{item}</foreach>
  96 + </if>
  97 + <choose>
  98 + <when test="totalMode != null and totalMode == true">
  99 + GROUP BY NULL
  100 + </when>
  101 + <otherwise>
  102 + GROUP BY cp.id
  103 + <choose>
  104 + <when test="sort != null and sort != '' and order != null and order != ''">
  105 + ORDER BY ${sort} ${order}
  106 + </when>
  107 + <otherwise>
  108 + ORDER BY cp.id DESC
  109 + </otherwise>
  110 + </choose>
  111 + LIMIT #{start}, #{limit}
  112 + </otherwise>
  113 + </choose>
  114 + </select>
  115 +</mapper>