提交代码

yy_dev
胡锐 1 year ago
parent 7843654179
commit a7e635f2a0
  1. 163
      bweb/src/main/java/com/bweb/controller/BsTradeOrderController.java
  2. 107
      service/src/main/java/com/hfkj/dao/BsTradeOrderMapperExt.java
  3. 94
      service/src/main/java/com/hfkj/dao/BsTradeSettleMapperExt.java
  4. 63
      service/src/main/java/com/hfkj/model/TradeSettleBillsModel.java
  5. 106
      service/src/main/java/com/hfkj/model/TradeSettleDetailBillsModel.java
  6. 8
      service/src/main/java/com/hfkj/service/BsTradeOrderService.java
  7. 14
      service/src/main/java/com/hfkj/service/BsTradeSettleService.java
  8. 7
      service/src/main/java/com/hfkj/service/impl/BsTradeOrderServiceImpl.java
  9. 45
      service/src/main/java/com/hfkj/service/impl/BsTradeSettleServiceImpl.java
  10. 13
      service/src/main/java/com/hfkj/sysenum/TradeSettleTradeType.java

@ -1,7 +1,6 @@
package com.bweb.controller; package com.bweb.controller;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.bweb.config.SysConst;
import com.bweb.excel.model.ExportTradeOrderModel; import com.bweb.excel.model.ExportTradeOrderModel;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
@ -9,13 +8,15 @@ import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode; import com.hfkj.common.exception.SysCode;
import com.hfkj.common.security.UserCenter; import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.EasyExcelUtil; import com.hfkj.common.utils.DateUtil;
import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.config.CommonSysConst; import com.hfkj.config.CommonSysConst;
import com.hfkj.entity.BsMer; import com.hfkj.entity.BsMer;
import com.hfkj.entity.BsPayQrCode;
import com.hfkj.entity.BsTradeOrder; import com.hfkj.entity.BsTradeOrder;
import com.hfkj.entity.BsTradeSettle;
import com.hfkj.model.ResponseData; import com.hfkj.model.ResponseData;
import com.hfkj.model.TradeSettleBillsModel;
import com.hfkj.model.TradeSettleDetailBillsModel;
import com.hfkj.model.UserInfoModel; import com.hfkj.model.UserInfoModel;
import com.hfkj.service.*; import com.hfkj.service.*;
import com.hfkj.sysenum.*; import com.hfkj.sysenum.*;
@ -28,7 +29,6 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.File;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -48,6 +48,9 @@ public class BsTradeOrderController {
@Resource @Resource
private BsTradeOrderService tradeOrderService; private BsTradeOrderService tradeOrderService;
@Resource
private BsTradeSettleService tradeSettleService;
@Resource @Resource
private BsTradeOrderRefundService tradeOrderRefundService; private BsTradeOrderRefundService tradeOrderRefundService;
@ -288,10 +291,14 @@ public class BsTradeOrderController {
@RequestMapping(value="/queryCheckingDetail",method = RequestMethod.GET) @RequestMapping(value="/queryCheckingDetail",method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "根据交易订单号 查询订单信息") @ApiOperation(value = "查询交易对账详情")
public ResponseData queryCheckingDetail(@RequestParam(value = "merNo" , required = true) String merNo, public ResponseData queryCheckingDetail(@RequestParam(value = "merNo" , required = true) String merNo,
@RequestParam(value = "settleTimeS" , required = true) Long settleTimeS, @RequestParam(value = "settleTimeS" , required = true) Long settleTimeS,
@RequestParam(value = "settleTimeE" , required = true) Long settleTimeE) { @RequestParam(value = "settleTimeE" , required = true) Long settleTimeE,
@RequestParam(value = "outTradeNo" , required = false) String outTradeNo,
@RequestParam(value = "accTradeNo" , required = false) String accTradeNo,
@RequestParam(value = "pageNum" , required = true) Integer pageNum,
@RequestParam(value = "pageSize" , required = true) Integer pageSize) {
try { try {
// 查询商户 // 查询商户
BsMer mer = merService.getMer(merNo); BsMer mer = merService.getMer(merNo);
@ -303,30 +310,81 @@ public class BsTradeOrderController {
param.put("merNo", merNo); param.put("merNo", merNo);
param.put("settleTimeS", settleTimeS); param.put("settleTimeS", settleTimeS);
param.put("settleTimeE", settleTimeE); param.put("settleTimeE", settleTimeE);
// 查询交易详情 param.put("outTradeNo", outTradeNo);
List<Map<String, Object>> mapList = tradeOrderService.getTradeOrderDetailCount(param); param.put("accTradeNo", accTradeNo);
int totalTradeNum = 0; Map<String, Object> returnParam = new HashMap<>();
BigDecimal totalTradeAmount = new BigDecimal("0"); PageHelper.startPage(pageNum,pageSize);
BigDecimal totalSettleAmount = new BigDecimal("0"); // 交易结算
BigDecimal totalShdFeeAmount = new BigDecimal("0"); returnParam.put("settleDetailList", new PageInfo<>(tradeSettleService.getTradeSettleList(param)));
// 汇总
Map<String, Object> tradeSettleCount = tradeSettleService.getTradeSettleCount(param);
returnParam.put("totalTradeNum", tradeSettleCount.get("tradeNum"));
returnParam.put("totalTradeAmount", tradeSettleCount.get("tradeAmount"));
returnParam.put("totalSettleAmount", tradeSettleCount.get("settleAmount"));
returnParam.put("totalShdFeeAmount", tradeSettleCount.get("shdFeeAmount"));
for (Map<String,Object> map : mapList) { return ResponseMsgUtil.success(returnParam);
map.put("merName", mer.getMerName());
map.put("merAbbreviate", mer.getMerAbbreviate()); } catch (Exception e) {
totalTradeNum += MapUtils.getInteger(map, "tradeNum").intValue(); log.error(e.getMessage(), e);
totalTradeAmount = totalTradeAmount.add(new BigDecimal(MapUtils.getString(map, "tradeAmount"))); return ResponseMsgUtil.exception(e);
totalSettleAmount = totalSettleAmount.add(new BigDecimal(MapUtils.getString(map, "settleAmount"))); }
totalShdFeeAmount = totalShdFeeAmount.add(new BigDecimal(MapUtils.getString(map, "shdFeeAmount")));
} }
Map<String, Object> returnParam = new HashMap<>(); @RequestMapping(value="/exportCheckingDetail",method = RequestMethod.GET)
returnParam.put("totalTradeNum", totalTradeNum); @ResponseBody
returnParam.put("totalTradeAmount", totalTradeAmount); @ApiOperation(value = "导出查询交易对账详情")
returnParam.put("totalSettleAmount", totalSettleAmount); public ResponseData exportCheckingDetail(@RequestParam(value = "merNo" , required = true) String merNo,
returnParam.put("totalShdFeeAmount", totalShdFeeAmount); @RequestParam(value = "settleTimeS" , required = true) Long settleTimeS,
returnParam.put("settleDetailList", mapList); @RequestParam(value = "settleTimeE" , required = true) Long settleTimeE,
return ResponseMsgUtil.success(returnParam); @RequestParam(value = "outTradeNo" , required = false) String outTradeNo,
@RequestParam(value = "accTradeNo" , required = false) String accTradeNo) {
try {
// 查询商户
BsMer mer = merService.getMer(merNo);
if (mer == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的商户");
}
Map<String, Object> param = new HashMap<>();
param.put("merNo", merNo);
param.put("settleTimeS", settleTimeS);
param.put("settleTimeE", settleTimeE);
param.put("outTradeNo", outTradeNo);
param.put("accTradeNo", accTradeNo);
List<BsTradeSettle> list = tradeSettleService.getTradeSettleList(param);
List<TradeSettleDetailBillsModel> billsModelList = new ArrayList<>();
TradeSettleDetailBillsModel billsModel;
Long serialNumber = 1L;
for (BsTradeSettle tradeSettle : list) {
billsModel = new TradeSettleDetailBillsModel();
billsModel.setSerialNumber(serialNumber++);
billsModel.setMerchantNo(mer.getMerNo());
billsModel.setMerchantName(mer.getMerName());
billsModel.setTradeTime(tradeSettle.getTradeTime());
billsModel.setTradeAmount(tradeSettle.getTradeType().equals(TradeSettleTradeType.type2.getNumber())?"-"+tradeSettle.getTradeAmount():tradeSettle.getTradeAmount().toString());
billsModel.setShdFeeAmt(tradeSettle.getTradeType().equals(TradeSettleTradeType.type2.getNumber())?"-"+tradeSettle.getShdFeeAmt():tradeSettle.getShdFeeAmt().toString());
billsModel.setSettleAmount(tradeSettle.getTradeType().equals(TradeSettleTradeType.type2.getNumber())?"-"+tradeSettle.getSettleAmount():tradeSettle.getSettleAmount().toString());
billsModel.setTradeType(TradeSettleTradeType.getNameByCode(tradeSettle.getTradeType()).getName());
billsModel.setPayMode(TradeOrderPayModeEnum.getNameByCode(tradeSettle.getPayMode()).getName());
billsModel.setOutTradeNo(tradeSettle.getOutTradeNo());
billsModel.setAccTradeNo(tradeSettle.getAccTradeNo());
billsModel.setSettleDate(DateUtil.date2String(tradeSettle.getSettleDate(), DateUtil.Y_M_D));
billsModel.setFeeRate(tradeSettle.getFeeRate() + "%");
billsModel.setOrgOutTradeNo(tradeSettle.getOrgOutTradeNo());
billsModelList.add(billsModel);
}
String fileName = "/temporary/" + System.currentTimeMillis() + ".xlsx";
EasyExcel.write(CommonSysConst.getSysConfig().getFilesystem() + fileName, TradeSettleDetailBillsModel.class)
.sheet("交易明细")
.doWrite(billsModelList);
return ResponseMsgUtil.success(fileName);
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
@ -336,7 +394,7 @@ public class BsTradeOrderController {
@RequestMapping(value="/queryChecking",method = RequestMethod.GET) @RequestMapping(value="/queryChecking",method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "根据交易订单号 查询订单信息") @ApiOperation(value = "查询交易结算汇总")
public ResponseData queryChecking(@RequestParam(value = "merNo" , required = true) String merNo, public ResponseData queryChecking(@RequestParam(value = "merNo" , required = true) String merNo,
@RequestParam(value = "settleTimeS" , required = true) Long settleTimeS, @RequestParam(value = "settleTimeS" , required = true) Long settleTimeS,
@RequestParam(value = "settleTimeE" , required = true) Long settleTimeE) { @RequestParam(value = "settleTimeE" , required = true) Long settleTimeE) {
@ -352,7 +410,7 @@ public class BsTradeOrderController {
param.put("settleTimeS", settleTimeS); param.put("settleTimeS", settleTimeS);
param.put("settleTimeE", settleTimeE); param.put("settleTimeE", settleTimeE);
// 查询交易详情 // 查询交易详情
List<Map<String, Object>> mapList = tradeOrderService.getTradeOrderDetailCount(param); List<Map<String, Object>> mapList = tradeSettleService.getTradeSettleDayCount(param);
int totalTradeNum = 0; int totalTradeNum = 0;
BigDecimal totalTradeAmount = new BigDecimal("0"); BigDecimal totalTradeAmount = new BigDecimal("0");
@ -360,6 +418,8 @@ public class BsTradeOrderController {
BigDecimal totalShdFeeAmount = new BigDecimal("0"); BigDecimal totalShdFeeAmount = new BigDecimal("0");
for (Map<String,Object> map : mapList) { for (Map<String,Object> map : mapList) {
map.put("merName", mer.getMerName());
map.put("merAbbreviate", mer.getMerAbbreviate());
totalTradeNum += MapUtils.getInteger(map, "tradeNum").intValue(); totalTradeNum += MapUtils.getInteger(map, "tradeNum").intValue();
totalTradeAmount = totalTradeAmount.add(new BigDecimal(MapUtils.getString(map, "tradeAmount"))); totalTradeAmount = totalTradeAmount.add(new BigDecimal(MapUtils.getString(map, "tradeAmount")));
totalSettleAmount = totalSettleAmount.add(new BigDecimal(MapUtils.getString(map, "settleAmount"))); totalSettleAmount = totalSettleAmount.add(new BigDecimal(MapUtils.getString(map, "settleAmount")));
@ -373,6 +433,7 @@ public class BsTradeOrderController {
returnParam.put("totalTradeAmount", totalTradeAmount); returnParam.put("totalTradeAmount", totalTradeAmount);
returnParam.put("totalSettleAmount", totalSettleAmount); returnParam.put("totalSettleAmount", totalSettleAmount);
returnParam.put("totalShdFeeAmount", totalShdFeeAmount); returnParam.put("totalShdFeeAmount", totalShdFeeAmount);
returnParam.put("settleList", mapList);
return ResponseMsgUtil.success(returnParam); return ResponseMsgUtil.success(returnParam);
} catch (Exception e) { } catch (Exception e) {
@ -381,4 +442,50 @@ public class BsTradeOrderController {
} }
} }
@RequestMapping(value="/exportChecking",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "导出交易结算汇总")
public ResponseData exportChecking(@RequestParam(value = "merNo" , required = true) String merNo,
@RequestParam(value = "settleTimeS" , required = true) Long settleTimeS,
@RequestParam(value = "settleTimeE" , required = true) Long settleTimeE) {
try {
// 查询商户
BsMer mer = merService.getMer(merNo);
if (mer == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的商户");
}
Map<String, Object> param = new HashMap<>();
param.put("merNo", merNo);
param.put("settleTimeS", settleTimeS);
param.put("settleTimeE", settleTimeE);
// 查询交易详情
List<Map<String, Object>> list = tradeSettleService.getTradeSettleDayCount(param);
List<TradeSettleBillsModel> settleBillsList = new ArrayList<>();
TradeSettleBillsModel settleBills;
for (Map<String,Object> map : list) {
settleBills = new TradeSettleBillsModel();
settleBills.setSettleDate(MapUtils.getString(map,"settleDay"));
settleBills.setMerchantNo(MapUtils.getString(map,"merNo"));
settleBills.setMerchantName(mer.getMerName());
settleBills.setTradeNum(MapUtils.getLong(map,"tradeNum"));
settleBills.setTradeAmount(MapUtils.getString(map,"tradeAmount"));
settleBills.setShdFeeAmt(MapUtils.getString(map,"shdFeeAmount"));
settleBills.setSettleAmount(MapUtils.getString(map,"settleAmount"));
settleBillsList.add(settleBills);
}
String fileName = "/temporary/" + System.currentTimeMillis() + ".xlsx";
EasyExcel.write(CommonSysConst.getSysConfig().getFilesystem() + fileName, TradeSettleBillsModel.class)
.sheet("交易汇总")
.doWrite(settleBillsList);
return ResponseMsgUtil.success(fileName);
} catch (Exception e) {
log.error(e.getMessage(), e);
return ResponseMsgUtil.exception(e);
}
}
} }

@ -32,111 +32,4 @@ public interface BsTradeOrderMapperExt {
"</script>") "</script>")
Map<String,Object> countTradeOrderPrice(@Param("param") Map<String, Object> param); Map<String,Object> countTradeOrderPrice(@Param("param") Map<String, Object> param);
/* @Select("<script>" +
" select " +
" a.days settleDay," +
" #{param.merNo} merNo, " +
" case when b.tradeNum is null then 0 else b.tradeNum end tradeNum, " +
" case when b.tradeAmount is null then 0 else b.tradeAmount end tradeAmount, " +
" case when b.settleAmount is null then 0 else b.settleAmount end settleAmount, " +
" case when b.shdFeeAmount is null then 0 else b.shdFeeAmount end shdFeeAmount " +
" from ( " +
" SELECT date_add(date_sub(#{param.settleTimeS},interval 1 day), INTERVAL ( cast( help_topic_id AS signed INTEGER ) + 1 ) day) days " +
" FROM mysql.help_topic " +
" WHERE help_topic_id <![CDATA[ < ]]> DATEDIFF(#{param.settleTimeE},date_sub(#{param.settleTimeS},interval 1 day)) ORDER BY help_topic_id) a " +
" LEFT JOIN (" +
" select " +
" a.settle_date settle_date," +
" (a.tradeNum + b.tradeNum) tradeNum," +
" (a.tradeAmount - b.tradeAmount) tradeAmount, " +
" (a.settleAmount - b.settleAmount) settleAmount, " +
" (a.shdFeeAmount - b.shdFeeAmount) shdFeeAmount " +
" from (select " +
" settle_date, " +
" count(1) tradeNum, " +
" sum(trade_amount) tradeAmount, " +
" sum(settle_amount) settleAmount, " +
" sum(shd_fee_amt) shdFeeAmount " +
" from bs_trade_settle " +
" where settle_date between #{param.settleTimeS} and #{param.settleTimeE} " +
" and mer_no = #{param.merNo} " +
" and trade_type = 1" +
" and `status` = 1" +
" GROUP BY settle_date) a," +
" (select " +
" settle_date, " +
" count(1) tradeNum, " +
" sum(trade_amount) tradeAmount, " +
" sum(settle_amount) settleAmount, " +
" sum(shd_fee_amt) shdFeeAmount " +
" from bs_trade_settle " +
" where settle_date between #{param.settleTimeS} and #{param.settleTimeE} " +
" and mer_no = #{param.merNo} " +
" and trade_type = 2" +
" and `status` = 1" +
" GROUP BY settle_date) b where a.settle_date = b.settle_date GROUP BY a.settle_date" +
" ) b on b.settle_date = a.days " +
" ORDER BY a.days desc;" +
" </script>")
*/
@Select("<script>" +
" select " +
" a.settleDay, " +
" #{param.merNo} merNo, " +
" (a.tradeNum + b.tradeNum) tradeNum, " +
" (a.tradeAmount - b.tradeAmount) tradeAmount, " +
" (a.settleAmount - b.settleAmount) settleAmount, " +
" (a.shdFeeAmount - b.shdFeeAmount) shdFeeAmount " +
" from " +
" (select " +
" a.days settleDay, " +
" case when b.tradeNum is null then 0 else b.tradeNum end tradeNum, " +
" case when b.tradeAmount is null then 0 else b.tradeAmount end tradeAmount, " +
" case when b.settleAmount is null then 0 else b.settleAmount end settleAmount, " +
" case when b.shdFeeAmount is null then 0 else b.shdFeeAmount end shdFeeAmount " +
" from ( " +
" SELECT date_add(date_sub(#{param.settleTimeS},interval 1 day), INTERVAL ( cast( help_topic_id AS signed INTEGER ) + 1 ) day) days " +
" FROM mysql.help_topic " +
" WHERE help_topic_id <![CDATA[ < ]]> DATEDIFF(#{param.settleTimeE},date_sub(#{param.settleTimeS},interval 1 day)) ORDER BY help_topic_id) a " +
" LEFT JOIN (select " +
" settle_date, " +
" count(1) tradeNum, " +
" sum(trade_amount) tradeAmount, " +
" sum(settle_amount) settleAmount, " +
" sum(shd_fee_amt) shdFeeAmount " +
" from bs_trade_settle " +
" where settle_date between #{param.settleTimeS} and #{param.settleTimeE} " +
" and mer_no = #{param.merNo} " +
" and trade_type = 1 " +
" and `status` = 1 " +
" GROUP BY settle_date " +
" ) b on b.settle_date = a.days) a, " +
" (select " +
" a.days settleDay, " +
" case when b.tradeNum is null then 0 else b.tradeNum end tradeNum, " +
" case when b.tradeAmount is null then 0 else b.tradeAmount end tradeAmount, " +
" case when b.settleAmount is null then 0 else b.settleAmount end settleAmount, " +
" case when b.shdFeeAmount is null then 0 else b.shdFeeAmount end shdFeeAmount " +
" from ( " +
" SELECT date_add(date_sub(#{param.settleTimeS},interval 1 day), INTERVAL ( cast( help_topic_id AS signed INTEGER ) + 1 ) day) days " +
" FROM mysql.help_topic " +
" WHERE help_topic_id <![CDATA[ < ]]> DATEDIFF(#{param.settleTimeE},date_sub(#{param.settleTimeS},interval 1 day)) ORDER BY help_topic_id) a " +
" LEFT JOIN (select " +
" settle_date, " +
" count(1) tradeNum, " +
" sum(trade_amount) tradeAmount, " +
" sum(settle_amount) settleAmount, " +
" sum(shd_fee_amt) shdFeeAmount " +
" from bs_trade_settle " +
" where settle_date between #{param.settleTimeS} and #{param.settleTimeE} " +
" and mer_no = #{param.merNo} " +
" and trade_type = 2 " +
" and `status` = 1 " +
" GROUP BY settle_date " +
" ) b on b.settle_date = a.days) b where b.settleDay = a.settleDay " +
" ORDER BY a.settleDay desc" +
"</script>")
List<Map<String,Object>> queryTradeOrderDetailCount(@Param("param") Map<String, Object> param);
} }

@ -1,7 +1,101 @@
package com.hfkj.dao; package com.hfkj.dao;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
/** /**
* mapper扩展类 * mapper扩展类
*/ */
public interface BsTradeSettleMapperExt { public interface BsTradeSettleMapperExt {
@Select("<script>" +
" select " +
" a.settleDay, " +
" #{param.merNo} merNo, " +
" (a.tradeNum + b.tradeNum) tradeNum, " +
" (a.tradeAmount - b.tradeAmount) tradeAmount, " +
" (a.settleAmount - b.settleAmount) settleAmount, " +
" (a.shdFeeAmount - b.shdFeeAmount) shdFeeAmount " +
" from " +
" (select " +
" a.days settleDay, " +
" case when b.tradeNum is null then 0 else b.tradeNum end tradeNum, " +
" case when b.tradeAmount is null then 0 else b.tradeAmount end tradeAmount, " +
" case when b.settleAmount is null then 0 else b.settleAmount end settleAmount, " +
" case when b.shdFeeAmount is null then 0 else b.shdFeeAmount end shdFeeAmount " +
" from ( " +
" SELECT date_add(date_sub(#{param.settleTimeS},interval 1 day), INTERVAL ( cast( help_topic_id AS signed INTEGER ) + 1 ) day) days " +
" FROM mysql.help_topic " +
" WHERE help_topic_id <![CDATA[ < ]]> DATEDIFF(#{param.settleTimeE},date_sub(#{param.settleTimeS},interval 1 day)) ORDER BY help_topic_id) a " +
" LEFT JOIN (select " +
" settle_date, " +
" count(1) tradeNum, " +
" sum(trade_amount) tradeAmount, " +
" sum(settle_amount) settleAmount, " +
" sum(shd_fee_amt) shdFeeAmount " +
" from bs_trade_settle " +
" where settle_date between #{param.settleTimeS} and #{param.settleTimeE} " +
" and mer_no = #{param.merNo} " +
" and trade_type = 1 " +
" and `status` = 1 " +
" GROUP BY settle_date " +
" ) b on b.settle_date = a.days) a, " +
" (select " +
" a.days settleDay, " +
" case when b.tradeNum is null then 0 else b.tradeNum end tradeNum, " +
" case when b.tradeAmount is null then 0 else b.tradeAmount end tradeAmount, " +
" case when b.settleAmount is null then 0 else b.settleAmount end settleAmount, " +
" case when b.shdFeeAmount is null then 0 else b.shdFeeAmount end shdFeeAmount " +
" from ( " +
" SELECT date_add(date_sub(#{param.settleTimeS},interval 1 day), INTERVAL ( cast( help_topic_id AS signed INTEGER ) + 1 ) day) days " +
" FROM mysql.help_topic " +
" WHERE help_topic_id <![CDATA[ < ]]> DATEDIFF(#{param.settleTimeE},date_sub(#{param.settleTimeS},interval 1 day)) ORDER BY help_topic_id) a " +
" LEFT JOIN (select " +
" settle_date, " +
" count(1) tradeNum, " +
" sum(trade_amount) tradeAmount, " +
" sum(settle_amount) settleAmount, " +
" sum(shd_fee_amt) shdFeeAmount " +
" from bs_trade_settle " +
" where settle_date between #{param.settleTimeS} and #{param.settleTimeE} " +
" and mer_no = #{param.merNo} " +
" and trade_type = 2 " +
" and `status` = 1 " +
" GROUP BY settle_date " +
" ) b on b.settle_date = a.days) b where b.settleDay = a.settleDay " +
" ORDER BY a.settleDay desc" +
"</script>")
List<Map<String,Object>> queryTradeSettleDayCount(@Param("param") Map<String, Object> param);
@Select({"<script>" +
" select " +
" sum(a.tradeNum) tradeNum," +
" sum(CAST(a.tradeAmount as decimal(10,2))) tradeAmount, " +
" sum(CAST(a.settleAmount as decimal(10,2))) settleAmount, " +
" sum(CAST(a.shdFeeAmount as decimal(10,2))) shdFeeAmount " +
" from (select " +
" count(1) tradeNum," +
" case when sum(trade_amount) is null then 0 else sum(trade_amount) end tradeAmount," +
" case when sum(settle_amount) is null then 0 else sum(settle_amount) end settleAmount," +
" case when sum(shd_fee_amt) is null then 0 else sum(shd_fee_amt) end shdFeeAmount" +
" from bs_trade_settle " +
" where mer_no = #{param.merNo} and settle_date between #{param.settleTimeS} and #{param.settleTimeE} and trade_type = 1 and status = 1" +
" <if test='param.outTradeNo != null'> and out_trade_no = #{param.outTradeNo} </if>" +
" <if test='param.accTradeNo != null'> and acc_trade_no = #{param.accTradeNo} </if>" +
" UNION" +
" select " +
" count(1) tradeNum," +
" CONCAT('-', case when sum(trade_amount) is null then 0 else sum(trade_amount) end) tradeAmount," +
" CONCAT('-', case when sum(settle_amount) is null then 0 else sum(settle_amount) end) settleAmount," +
" CONCAT('-', case when sum(shd_fee_amt) is null then 0 else sum(shd_fee_amt) end) shdFeeAmount" +
" from bs_trade_settle " +
" where mer_no = #{param.merNo} and settle_date between #{param.settleTimeS} and #{param.settleTimeE} and trade_type = 2 and status = 1" +
" <if test='param.outTradeNo != null'> and out_trade_no = #{param.outTradeNo} </if>" +
" <if test='param.accTradeNo != null'> and acc_trade_no = #{param.accTradeNo} </if>" +
") a" +
" </script>"})
Map<String,Object> queryTradeSettleCount(@Param("param") Map<String, Object> param);
} }

@ -0,0 +1,63 @@
package com.hfkj.model;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentStyle;
import com.alibaba.excel.annotation.write.style.HeadFontStyle;
import lombok.Data;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import java.util.Date;
/**
* 交易账单模型
* @className: TradeBillsModel
* @author: HuRui
* @date: 2023/5/25
**/
@Data
public class TradeSettleBillsModel {
@ColumnWidth(15)
@ExcelProperty("清算日期")
@HeadFontStyle(bold = true)
@ContentStyle(horizontalAlignment = HorizontalAlignment.CENTER)
private String settleDate;
@ColumnWidth(25)
@ExcelProperty("商户号")
@HeadFontStyle(bold = true)
@ContentStyle(horizontalAlignment = HorizontalAlignment.CENTER)
private String merchantNo;
@ColumnWidth(30)
@ExcelProperty("商户名称")
@HeadFontStyle(bold = true)
@ContentStyle(horizontalAlignment = HorizontalAlignment.CENTER)
private String merchantName;
@ColumnWidth(15)
@ExcelProperty("交易笔数")
@HeadFontStyle(bold = true)
@ContentStyle(horizontalAlignment = HorizontalAlignment.CENTER)
private Long tradeNum;
@ColumnWidth(15)
@ExcelProperty("交易金额")
@HeadFontStyle(bold = true)
@ContentStyle(horizontalAlignment = HorizontalAlignment.CENTER)
private String tradeAmount;
@ColumnWidth(15)
@ExcelProperty("手续费")
@HeadFontStyle(bold = true)
@ContentStyle(horizontalAlignment = HorizontalAlignment.CENTER)
private String shdFeeAmt;
@ColumnWidth(15)
@ExcelProperty("应结算金额")
@HeadFontStyle(bold = true)
@ContentStyle(horizontalAlignment = HorizontalAlignment.CENTER)
private String settleAmount;
}

@ -0,0 +1,106 @@
package com.hfkj.model;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentStyle;
import com.alibaba.excel.annotation.write.style.HeadFontStyle;
import lombok.Data;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import java.util.Date;
/**
* 交易账单模型
* @className: TradeBillsModel
* @author: HuRui
* @date: 2023/5/25
**/
@Data
public class TradeSettleDetailBillsModel {
@ColumnWidth(10)
@ExcelProperty("序号")
@HeadFontStyle(bold = true)
@ContentStyle(horizontalAlignment = HorizontalAlignment.CENTER)
private Long serialNumber;
@ColumnWidth(25)
@ExcelProperty("商户号")
@HeadFontStyle(bold = true)
@ContentStyle(horizontalAlignment = HorizontalAlignment.CENTER)
private String merchantNo;
@ColumnWidth(30)
@ExcelProperty("商户名称")
@HeadFontStyle(bold = true)
@ContentStyle(horizontalAlignment = HorizontalAlignment.CENTER)
private String merchantName;
@ColumnWidth(25)
@ExcelProperty("交易日期")
@HeadFontStyle(bold = true)
@ContentStyle(horizontalAlignment = HorizontalAlignment.CENTER)
private Date tradeTime;
@ColumnWidth(15)
@ExcelProperty("交易金额")
@HeadFontStyle(bold = true)
@ContentStyle(horizontalAlignment = HorizontalAlignment.CENTER)
private String tradeAmount;
@ColumnWidth(15)
@ExcelProperty("交易手续费")
@HeadFontStyle(bold = true)
@ContentStyle(horizontalAlignment = HorizontalAlignment.CENTER)
private String shdFeeAmt;
@ColumnWidth(15)
@ExcelProperty("结算金额")
@HeadFontStyle(bold = true)
@ContentStyle(horizontalAlignment = HorizontalAlignment.CENTER)
private String settleAmount;
@ColumnWidth(15)
@ExcelProperty("交易类型")
@HeadFontStyle(bold = true)
@ContentStyle(horizontalAlignment = HorizontalAlignment.CENTER)
private String tradeType;
@ColumnWidth(15)
@ExcelProperty("支付渠道")
@HeadFontStyle(bold = true)
@ContentStyle(horizontalAlignment = HorizontalAlignment.CENTER)
private String payMode;
@ColumnWidth(35)
@ExcelProperty("商户订单号")
@HeadFontStyle(bold = true)
@ContentStyle(horizontalAlignment = HorizontalAlignment.CENTER)
private String outTradeNo;
@ColumnWidth(35)
@ExcelProperty("渠道订单号")
@HeadFontStyle(bold = true)
@ContentStyle(horizontalAlignment = HorizontalAlignment.CENTER)
private String accTradeNo;
@ColumnWidth(15)
@ExcelProperty("清算日期")
@HeadFontStyle(bold = true)
@ContentStyle(horizontalAlignment = HorizontalAlignment.CENTER)
private String settleDate;
@ColumnWidth(15)
@ExcelProperty("手续费率")
@HeadFontStyle(bold = true)
@ContentStyle(horizontalAlignment = HorizontalAlignment.CENTER)
private String feeRate;
@ColumnWidth(35)
@ExcelProperty("原商户订单号")
@HeadFontStyle(bold = true)
@ContentStyle(horizontalAlignment = HorizontalAlignment.CENTER)
private String orgOutTradeNo;
}

@ -74,12 +74,4 @@ public interface BsTradeOrderService {
*/ */
Map<String,Object> countTradeOrderPrice(Map<String, Object> param); Map<String,Object> countTradeOrderPrice(Map<String, Object> param);
/**
* 交易详情统计
* @param param
* @return
*/
List<Map<String,Object>> getTradeOrderDetailCount(Map<String, Object> param);
} }

@ -32,4 +32,18 @@ public interface BsTradeSettleService {
* @return * @return
*/ */
List<BsTradeSettle> getTradeSettleList(Map<String,Object> param); List<BsTradeSettle> getTradeSettleList(Map<String,Object> param);
/**
* 交易结算统计
* @param param
* @return
*/
Map<String,Object> getTradeSettleCount(Map<String, Object> param);
/**
* 交易清算统计结算日
* @param param
* @return
*/
List<Map<String,Object>> getTradeSettleDayCount(Map<String, Object> param);
} }

@ -435,11 +435,4 @@ public class BsTradeOrderServiceImpl implements BsTradeOrderService {
return tradeOrderMapper.countTradeOrderPrice(paramMap); return tradeOrderMapper.countTradeOrderPrice(paramMap);
} }
@Override
public List<Map<String, Object>> getTradeOrderDetailCount(Map<String, Object> param) {
param.put("settleTimeS", DateUtil.date2String(new Date(MapUtils.getLong(param, "settleTimeS")), DateUtil.Y_M_D));
param.put("settleTimeE", DateUtil.date2String(new Date(MapUtils.getLong(param, "settleTimeE")), DateUtil.Y_M_D));
return tradeOrderMapper.queryTradeOrderDetailCount(param);
}
} }

@ -1,8 +1,12 @@
package com.hfkj.service.impl; package com.hfkj.service.impl;
import com.hfkj.common.utils.DateUtil;
import com.hfkj.dao.BsTradeSettleMapper; import com.hfkj.dao.BsTradeSettleMapper;
import com.hfkj.entity.BsTradeSettle; import com.hfkj.entity.BsTradeSettle;
import com.hfkj.entity.BsTradeSettleExample;
import com.hfkj.service.BsTradeSettleService; import com.hfkj.service.BsTradeSettleService;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -39,6 +43,45 @@ public class BsTradeSettleServiceImpl implements BsTradeSettleService {
@Override @Override
public List<BsTradeSettle> getTradeSettleList(Map<String, Object> param) { public List<BsTradeSettle> getTradeSettleList(Map<String, Object> param) {
return null; BsTradeSettleExample example = new BsTradeSettleExample();
BsTradeSettleExample.Criteria criteria = example.createCriteria().andStatusNotEqualTo(0);
if (StringUtils.isNotBlank(MapUtils.getString(param, "merNo"))) {
criteria.andMerNoEqualTo(MapUtils.getString(param, "merNo"));
}
if (MapUtils.getLong(param, "settleTimeS") != null) {
criteria.andSettleDateGreaterThanOrEqualTo(new Date(MapUtils.getLong(param, "settleTimeS")));
}
if (MapUtils.getLong(param, "settleTimeE") != null) {
criteria.andSettleDateLessThanOrEqualTo(new Date(MapUtils.getLong(param, "settleTimeS")));
}
if (StringUtils.isNotBlank(MapUtils.getString(param, "outTradeNo"))) {
criteria.andOutTradeNoLike("%" + MapUtils.getString(param, "outTradeNo") + "%");
}
if (StringUtils.isNotBlank(MapUtils.getString(param, "accTradeNo"))) {
criteria.andAccTradeNoLike("%" + MapUtils.getString(param, "accTradeNo") + "%");
}
example.setOrderByClause("trade_time desc");
return tradeSettleMapper.selectByExample(example);
}
@Override
public Map<String, Object> getTradeSettleCount(Map<String, Object> param) {
param.put("settleTimeS", DateUtil.date2String(new Date(MapUtils.getLong(param, "settleTimeS")), DateUtil.Y_M_D));
param.put("settleTimeE", DateUtil.date2String(new Date(MapUtils.getLong(param, "settleTimeE")), DateUtil.Y_M_D));
return tradeSettleMapper.queryTradeSettleCount(param);
}
@Override
public List<Map<String, Object>> getTradeSettleDayCount(Map<String, Object> param) {
param.put("settleTimeS", DateUtil.date2String(new Date(MapUtils.getLong(param, "settleTimeS")), DateUtil.Y_M_D));
param.put("settleTimeE", DateUtil.date2String(new Date(MapUtils.getLong(param, "settleTimeE")), DateUtil.Y_M_D));
return tradeSettleMapper.queryTradeSettleDayCount(param);
} }
} }

@ -1,12 +1,14 @@
package com.hfkj.sysenum; package com.hfkj.sysenum;
import java.util.Objects;
/** /**
* @className: TradeSettleTradeType * @className: TradeSettleTradeType
* @author: HuRui * @author: HuRui
* @date: 2023/8/4 * @date: 2023/8/4
**/ **/
public enum TradeSettleTradeType { public enum TradeSettleTradeType {
type1(1, "支付"), type1(1, "交易支付"),
type2(2, "交易退款"), type2(2, "交易退款"),
; ;
@ -19,6 +21,15 @@ public enum TradeSettleTradeType {
this.name = name; this.name = name;
} }
public static TradeSettleTradeType getNameByCode(Integer code) {
for (TradeSettleTradeType ele : values()) {
if (Objects.equals(code,ele.getNumber())) {
return ele;
}
}
return null;
}
public Integer getNumber() { public Integer getNumber() {
return number; return number;
} }

Loading…
Cancel
Save