mirror of
https://gitee.com/dromara/dax-pay.git
synced 2025-09-26 05:37:59 +00:00
feat 云闪付对账处理
This commit is contained in:
@@ -4,10 +4,8 @@
|
|||||||
- [x] 第一排: (数字格式)显示今日收入、支出金额,支付总订单数量、退款总订单数, 时间分支分为: 今日金额/昨日金额/七天内金额
|
- [x] 第一排: (数字格式)显示今日收入、支出金额,支付总订单数量、退款总订单数, 时间分支分为: 今日金额/昨日金额/七天内金额
|
||||||
- [x] 第二排: (饼图)显示各通道各支付方式数量和占比, 时间分为: 今日金额/昨日金额/七天内金额
|
- [x] 第二排: (饼图)显示各通道各支付方式数量和占比, 时间分为: 今日金额/昨日金额/七天内金额
|
||||||
- [x] 第三排: (折线图)显示各通道支付分为支付金额和退款,时间分为: 今日金额/昨日金额/七天内金额
|
- [x] 第三排: (折线图)显示各通道支付分为支付金额和退款,时间分为: 今日金额/昨日金额/七天内金额
|
||||||
- [ ] 增加转账功能
|
- [x] 云闪付支持对账功能
|
||||||
- [ ] 支付宝
|
- [ ] 对账文件支持手动导入
|
||||||
- [ ] 微信
|
|
||||||
- [ ] 云闪付支持对账功能
|
|
||||||
- [x] 结算台DEMO增加云闪付示例
|
- [x] 结算台DEMO增加云闪付示例
|
||||||
- [x] 增加支付限额
|
- [x] 增加支付限额
|
||||||
- [x] 各通道(异步支付)支持单独的限额
|
- [x] 各通道(异步支付)支持单独的限额
|
||||||
|
@@ -56,6 +56,12 @@ public interface UnionPayCode {
|
|||||||
/** 对账单下载类型编码 */
|
/** 对账单下载类型编码 */
|
||||||
String RECONCILE_BILL_TYPE = "00";
|
String RECONCILE_BILL_TYPE = "00";
|
||||||
|
|
||||||
|
/** 文件内容 */
|
||||||
|
String FILE_CONTENT = "fileContent";
|
||||||
|
|
||||||
|
/** 明细对账单文件前缀 */
|
||||||
|
String RECONCILE_FILE_PREFIX = "INN";
|
||||||
|
|
||||||
/* 对账单交易代码 */
|
/* 对账单交易代码 */
|
||||||
/** 消费 */
|
/** 消费 */
|
||||||
String RECONCILE_TYPE_PAY = "S22";
|
String RECONCILE_TYPE_PAY = "S22";
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
package cn.bootx.platform.daxpay.service.common.context;
|
package cn.bootx.platform.daxpay.service.common.context;
|
||||||
|
|
||||||
import cn.bootx.platform.daxpay.service.core.order.reconcile.entity.ReconcileDetail;
|
import cn.bootx.platform.daxpay.service.core.order.reconcile.entity.ReconcileDetail;
|
||||||
|
import cn.bootx.platform.daxpay.service.core.order.reconcile.entity.ReconcileOrder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
@@ -15,6 +16,9 @@ import java.util.List;
|
|||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
public class ReconcileLocal {
|
public class ReconcileLocal {
|
||||||
|
|
||||||
|
/** 对账订单 */
|
||||||
|
private ReconcileOrder reconcileOrder;
|
||||||
|
|
||||||
/** 通用支付对账记录 */
|
/** 通用支付对账记录 */
|
||||||
private List<ReconcileDetail> reconcileDetails;
|
private List<ReconcileDetail> reconcileDetails;
|
||||||
|
|
||||||
|
@@ -0,0 +1,18 @@
|
|||||||
|
package cn.bootx.platform.daxpay.service.core.channel.union.dao;
|
||||||
|
|
||||||
|
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
|
||||||
|
import cn.bootx.platform.daxpay.service.core.channel.union.entity.UnionReconcileBillDetail;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author xxm
|
||||||
|
* @since 2024/3/25
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Repository
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class UnionReconcileBillDetailManager extends BaseManager<UnionReconcileBillDetailMapper, UnionReconcileBillDetail> {
|
||||||
|
}
|
@@ -0,0 +1,14 @@
|
|||||||
|
package cn.bootx.platform.daxpay.service.core.channel.union.dao;
|
||||||
|
|
||||||
|
import cn.bootx.platform.daxpay.service.core.channel.union.entity.UnionReconcileBillDetail;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author xxm
|
||||||
|
* @since 2024/3/25
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface UnionReconcileBillDetailMapper extends BaseMapper<UnionReconcileBillDetail> {
|
||||||
|
}
|
@@ -1,6 +1,8 @@
|
|||||||
package cn.bootx.platform.daxpay.service.core.channel.union.entity;
|
package cn.bootx.platform.daxpay.service.core.channel.union.entity;
|
||||||
|
|
||||||
import cn.bootx.table.modify.annotation.DbColumn;
|
import cn.bootx.table.modify.annotation.DbColumn;
|
||||||
|
import cn.bootx.table.modify.annotation.DbTable;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
@@ -11,27 +13,34 @@ import lombok.experimental.Accessors;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
|
@DbTable(comment = "云闪付业务明细对账单")
|
||||||
|
@TableName("pay_union_reconcile_bill_detail")
|
||||||
public class UnionReconcileBillDetail {
|
public class UnionReconcileBillDetail {
|
||||||
|
|
||||||
/** 关联对账订单ID */
|
/** 关联对账订单ID */
|
||||||
@DbColumn(comment = "关联对账订单ID")
|
@DbColumn(comment = "关联对账订单ID")
|
||||||
private Long recordOrderId;
|
private Long recordOrderId;
|
||||||
/** 交易代码 */
|
/** 交易代码 */
|
||||||
|
@DbColumn(comment = "交易代码")
|
||||||
private String tradeType;
|
private String tradeType;
|
||||||
/** 代理机构标识码 */
|
/** 代理机构标识码 */
|
||||||
/** 发送机构标识码 */
|
/** 发送机构标识码 */
|
||||||
/** 系统跟踪号 */
|
/** 系统跟踪号 */
|
||||||
/** 交易传输时间 */
|
/** 交易传输时间 */
|
||||||
|
@DbColumn(comment = "交易传输时间")
|
||||||
private String txnTime;
|
private String txnTime;
|
||||||
/** 帐号 */
|
/** 帐号 */
|
||||||
/** 交易金额 */
|
/** 交易金额 */
|
||||||
|
@DbColumn(comment = "交易金额")
|
||||||
private String txnAmt;
|
private String txnAmt;
|
||||||
/** 商户类别 */
|
/** 商户类别 */
|
||||||
/** 终端类型 */
|
/** 终端类型 */
|
||||||
/** 查询流水号 */
|
/** 查询流水号 */
|
||||||
|
@DbColumn(comment = "查询流水号")
|
||||||
private String queryId;
|
private String queryId;
|
||||||
/** 支付方式(旧) */
|
/** 支付方式(旧) */
|
||||||
/** 商户订单号 */
|
/** 商户订单号 */
|
||||||
|
@DbColumn(comment = "商户订单号")
|
||||||
private String orderId;
|
private String orderId;
|
||||||
/** 支付卡类型 */
|
/** 支付卡类型 */
|
||||||
/** 原始交易的系统跟踪号 */
|
/** 原始交易的系统跟踪号 */
|
||||||
|
@@ -2,11 +2,14 @@ package cn.bootx.platform.daxpay.service.core.channel.union.service;
|
|||||||
|
|
||||||
import cn.bootx.platform.common.core.util.LocalDateTimeUtil;
|
import cn.bootx.platform.common.core.util.LocalDateTimeUtil;
|
||||||
import cn.bootx.platform.daxpay.code.ReconcileTradeEnum;
|
import cn.bootx.platform.daxpay.code.ReconcileTradeEnum;
|
||||||
|
import cn.bootx.platform.daxpay.exception.pay.PayFailureException;
|
||||||
import cn.bootx.platform.daxpay.service.code.UnionPayCode;
|
import cn.bootx.platform.daxpay.service.code.UnionPayCode;
|
||||||
import cn.bootx.platform.daxpay.service.code.UnionReconcileFieldEnum;
|
import cn.bootx.platform.daxpay.service.code.UnionReconcileFieldEnum;
|
||||||
import cn.bootx.platform.daxpay.service.common.local.PaymentContextLocal;
|
import cn.bootx.platform.daxpay.service.common.local.PaymentContextLocal;
|
||||||
|
import cn.bootx.platform.daxpay.service.core.channel.union.dao.UnionReconcileBillDetailManager;
|
||||||
import cn.bootx.platform.daxpay.service.core.channel.union.entity.UnionReconcileBillDetail;
|
import cn.bootx.platform.daxpay.service.core.channel.union.entity.UnionReconcileBillDetail;
|
||||||
import cn.bootx.platform.daxpay.service.core.order.reconcile.entity.ReconcileDetail;
|
import cn.bootx.platform.daxpay.service.core.order.reconcile.entity.ReconcileDetail;
|
||||||
|
import cn.bootx.platform.daxpay.service.core.order.reconcile.entity.ReconcileOrder;
|
||||||
import cn.bootx.platform.daxpay.service.sdk.union.api.UnionPayKit;
|
import cn.bootx.platform.daxpay.service.sdk.union.api.UnionPayKit;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.Base64;
|
||||||
@@ -14,6 +17,7 @@ import cn.hutool.core.compress.Deflate;
|
|||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.egzosn.pay.union.bean.SDKConstants;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
|
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
|
||||||
@@ -21,12 +25,12 @@ import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static cn.bootx.platform.daxpay.service.code.UnionPayCode.RECONCILE_BILL_SPLIT;
|
import static cn.bootx.platform.daxpay.service.code.UnionPayCode.*;
|
||||||
import static cn.bootx.platform.daxpay.service.code.UnionPayCode.RECONCILE_BILL_TYPE;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 云闪付对账
|
* 云闪付对账
|
||||||
@@ -38,16 +42,22 @@ import static cn.bootx.platform.daxpay.service.code.UnionPayCode.RECONCILE_BILL_
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class UnionPayReconcileService {
|
public class UnionPayReconcileService {
|
||||||
|
|
||||||
|
private final UnionReconcileBillDetailManager unionReconcileBillDetailManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 下载对账单
|
* 下载对账单
|
||||||
*/
|
*/
|
||||||
public void downAndSave(Date date, Long recordOrderId, UnionPayKit unionPayKit){
|
public void downAndSave(Date date, Long recordOrderId, UnionPayKit unionPayKit){
|
||||||
// 下载对账单
|
// 下载对账单
|
||||||
Map<String, Object> stringObjectMap = unionPayKit.downloadBill(date, RECONCILE_BILL_TYPE);
|
Map<String, Object> map = unionPayKit.downloadBill(date, RECONCILE_BILL_TYPE);
|
||||||
|
String fileContent = map.get(FILE_CONTENT).toString();
|
||||||
|
// 判断是否成功
|
||||||
|
if (!SDKConstants.OK_RESP_CODE.equals(map.get(SDKConstants.param_respCode))) {
|
||||||
|
log.warn("云闪付获取对账文件失败");
|
||||||
|
throw new PayFailureException("云闪付获取对账文件失败");
|
||||||
|
}
|
||||||
|
|
||||||
String fileContent = stringObjectMap.get("fileContent").toString();
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// 先解base64,再DEFLATE解压为zip流
|
// 先解base64,再DEFLATE解压为zip流
|
||||||
byte[] decode = Base64.decode(fileContent);
|
byte[] decode = Base64.decode(fileContent);
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
@@ -61,9 +71,8 @@ public class UnionPayReconcileService {
|
|||||||
ZipArchiveEntry entry;
|
ZipArchiveEntry entry;
|
||||||
List<UnionReconcileBillDetail> billDetails = new ArrayList<>();
|
List<UnionReconcileBillDetail> billDetails = new ArrayList<>();
|
||||||
while ((entry= zipArchiveInputStream.getNextZipEntry()) != null){
|
while ((entry= zipArchiveInputStream.getNextZipEntry()) != null){
|
||||||
System.out.println(StrUtil.startWith(entry.getName(), "INN"));
|
|
||||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(zipArchiveInputStream,"GBK"));
|
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(zipArchiveInputStream,"GBK"));
|
||||||
if (StrUtil.startWith(entry.getName(), "INN")){
|
if (StrUtil.startWith(entry.getName(), RECONCILE_FILE_PREFIX)){
|
||||||
// 明细解析
|
// 明细解析
|
||||||
List<String> strings = IoUtil.readLines(bufferedReader, new ArrayList<>());
|
List<String> strings = IoUtil.readLines(bufferedReader, new ArrayList<>());
|
||||||
billDetails = this.parseDetail(strings);
|
billDetails = this.parseDetail(strings);
|
||||||
@@ -73,13 +82,8 @@ public class UnionPayReconcileService {
|
|||||||
}
|
}
|
||||||
// 保存原始对账记录
|
// 保存原始对账记录
|
||||||
this.save(billDetails, recordOrderId);
|
this.save(billDetails, recordOrderId);
|
||||||
|
// 转换为通用对账记录对象
|
||||||
// 将原始交易明细对账记录转换通用结构并保存到上下文中
|
|
||||||
this.convertAndSave(billDetails);
|
this.convertAndSave(billDetails);
|
||||||
// Reader bufferedReader = new BufferedReader(new InputStreamReader(Files.newInputStream(Paths.get("D:/data/INN24031100ZM_777290058206553.txt"))));
|
|
||||||
// List<String> strings = IoUtil.readLines(bufferedReader, new ArrayList<>());
|
|
||||||
// List<UnionReconcileBillDetail> unionReconcileBillDetails = this.parseDetail(strings);
|
|
||||||
// System.out.println(unionReconcileBillDetails);
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@@ -102,13 +106,12 @@ public class UnionPayReconcileService {
|
|||||||
Map<String,String> zmDataMap = new HashMap<>();
|
Map<String,String> zmDataMap = new HashMap<>();
|
||||||
//左侧游标
|
//左侧游标
|
||||||
int leftIndex = 0;
|
int leftIndex = 0;
|
||||||
//右侧游标
|
|
||||||
int rightIndex = 0;
|
|
||||||
for(int i=0;i<RECONCILE_BILL_SPLIT.length;i++){
|
for(int i=0;i<RECONCILE_BILL_SPLIT.length;i++){
|
||||||
rightIndex = leftIndex + RECONCILE_BILL_SPLIT[i];
|
//右侧游标
|
||||||
|
int rightIndex = leftIndex + RECONCILE_BILL_SPLIT[i];
|
||||||
String filed = StrUtil.sub(line, leftIndex, rightIndex);
|
String filed = StrUtil.sub(line, leftIndex, rightIndex);
|
||||||
leftIndex = rightIndex+1;
|
leftIndex = rightIndex+1;
|
||||||
|
// 映射到数据对象
|
||||||
UnionReconcileFieldEnum fieldEnum = UnionReconcileFieldEnum.findByNo(i);
|
UnionReconcileFieldEnum fieldEnum = UnionReconcileFieldEnum.findByNo(i);
|
||||||
if (Objects.nonNull(fieldEnum)){
|
if (Objects.nonNull(fieldEnum)){
|
||||||
zmDataMap.put(fieldEnum.getFiled(), filed.trim());
|
zmDataMap.put(fieldEnum.getFiled(), filed.trim());
|
||||||
@@ -123,17 +126,20 @@ public class UnionPayReconcileService {
|
|||||||
private void convertAndSave(List<UnionReconcileBillDetail> billDetails){
|
private void convertAndSave(List<UnionReconcileBillDetail> billDetails){
|
||||||
List<ReconcileDetail> collect = billDetails.stream()
|
List<ReconcileDetail> collect = billDetails.stream()
|
||||||
.map(this::convert)
|
.map(this::convert)
|
||||||
|
// 只处理支付和退款的对账记录
|
||||||
|
.filter(Objects::nonNull)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
// 写入到上下文中
|
// 写入到上下文中
|
||||||
PaymentContextLocal.get().getReconcileInfo().setReconcileDetails(collect);
|
PaymentContextLocal.get().getReconcileInfo().setReconcileDetails(collect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换为通用对账记录对象
|
* 转换为通用对账记录对象
|
||||||
*/
|
*/
|
||||||
private ReconcileDetail convert(UnionReconcileBillDetail billDetail){
|
private ReconcileDetail convert(UnionReconcileBillDetail billDetail){
|
||||||
|
ReconcileOrder reconcileOrder = PaymentContextLocal.get()
|
||||||
|
.getReconcileInfo()
|
||||||
|
.getReconcileOrder();
|
||||||
// 金额
|
// 金额
|
||||||
String orderAmount = billDetail.getTxnAmt();
|
String orderAmount = billDetail.getTxnAmt();
|
||||||
int amount = Integer.parseInt(orderAmount);
|
int amount = Integer.parseInt(orderAmount);
|
||||||
@@ -146,10 +152,13 @@ public class UnionPayReconcileService {
|
|||||||
.setAmount(amount)
|
.setAmount(amount)
|
||||||
.setGatewayOrderNo(billDetail.getQueryId());
|
.setGatewayOrderNo(billDetail.getQueryId());
|
||||||
|
|
||||||
// 时间
|
// 时间, 从对账订单获取年份
|
||||||
String txnTime = billDetail.getTxnTime();
|
LocalDate date = reconcileOrder.getDate();
|
||||||
|
String year = LocalDateTimeUtil.format(date, DatePattern.NORM_YEAR_PATTERN);
|
||||||
|
|
||||||
|
String txnTime = year + billDetail.getTxnTime();
|
||||||
if (StrUtil.isNotBlank(txnTime)) {
|
if (StrUtil.isNotBlank(txnTime)) {
|
||||||
LocalDateTime time = LocalDateTimeUtil.parse(txnTime, DatePattern.NORM_DATETIME_PATTERN);
|
LocalDateTime time = LocalDateTimeUtil.parse(txnTime, DatePattern.PURE_DATETIME_PATTERN);
|
||||||
reconcileDetail.setOrderTime(time);
|
reconcileDetail.setOrderTime(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,6 +174,6 @@ public class UnionPayReconcileService {
|
|||||||
*/
|
*/
|
||||||
private void save(List<UnionReconcileBillDetail> billDetails, Long recordOrderId){
|
private void save(List<UnionReconcileBillDetail> billDetails, Long recordOrderId){
|
||||||
billDetails.forEach(o->o.setRecordOrderId(recordOrderId));
|
billDetails.forEach(o->o.setRecordOrderId(recordOrderId));
|
||||||
|
unionReconcileBillDetailManager.saveAll(billDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -7,6 +7,8 @@ import cn.bootx.platform.daxpay.service.dto.order.reconcile.ReconcileOrderDto;
|
|||||||
import cn.bootx.table.modify.annotation.DbColumn;
|
import cn.bootx.table.modify.annotation.DbColumn;
|
||||||
import cn.bootx.table.modify.annotation.DbTable;
|
import cn.bootx.table.modify.annotation.DbTable;
|
||||||
import cn.bootx.table.modify.mysql.annotation.DbMySqlIndex;
|
import cn.bootx.table.modify.mysql.annotation.DbMySqlIndex;
|
||||||
|
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
@@ -53,6 +55,7 @@ public class ReconcileOrder extends MpCreateEntity implements EntityBaseFunction
|
|||||||
|
|
||||||
/** 错误信息 */
|
/** 错误信息 */
|
||||||
@DbColumn(comment = "错误信息")
|
@DbColumn(comment = "错误信息")
|
||||||
|
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||||
private String errorMsg;
|
private String errorMsg;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -21,7 +21,6 @@ import java.util.Optional;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class ReconcileOrderService {
|
public class ReconcileOrderService {
|
||||||
private final ReconcileOrderManager reconcileOrderManager;
|
private final ReconcileOrderManager reconcileOrderManager;
|
||||||
private final Sequence sequence;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新, 开启一个新事务进行更新
|
* 更新, 开启一个新事务进行更新
|
||||||
|
@@ -89,13 +89,17 @@ public class ReconcileService {
|
|||||||
* 下载对账单并进行保存
|
* 下载对账单并进行保存
|
||||||
*/
|
*/
|
||||||
public void downAndSave(ReconcileOrder reconcileOrder) {
|
public void downAndSave(ReconcileOrder reconcileOrder) {
|
||||||
|
// 将对账订单写入到上下文中
|
||||||
|
PaymentContextLocal.get().getReconcileInfo().setReconcileOrder(reconcileOrder);
|
||||||
|
|
||||||
// 构建对账策略
|
// 构建对账策略
|
||||||
AbsReconcileStrategy reconcileStrategy = ReconcileStrategyFactory.create(reconcileOrder.getChannel());
|
AbsReconcileStrategy reconcileStrategy = ReconcileStrategyFactory.create(reconcileOrder.getChannel());
|
||||||
reconcileStrategy.setRecordOrder(reconcileOrder);
|
reconcileStrategy.setRecordOrder(reconcileOrder);
|
||||||
reconcileStrategy.doBeforeHandler();
|
reconcileStrategy.doBeforeHandler();
|
||||||
try {
|
try {
|
||||||
reconcileStrategy.downAndSave();
|
reconcileStrategy.downAndSave();
|
||||||
reconcileOrder.setDown(true);
|
reconcileOrder.setDown(true)
|
||||||
|
.setErrorMsg(null);
|
||||||
reconcileOrderService.update(reconcileOrder);
|
reconcileOrderService.update(reconcileOrder);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("下载对账单异常", e);
|
log.error("下载对账单异常", e);
|
||||||
|
@@ -11,11 +11,10 @@ import cn.bootx.platform.daxpay.service.core.channel.alipay.service.AliPayConfig
|
|||||||
import cn.bootx.platform.daxpay.service.core.channel.alipay.service.AliPayReconcileService;
|
import cn.bootx.platform.daxpay.service.core.channel.alipay.service.AliPayReconcileService;
|
||||||
import cn.bootx.platform.daxpay.service.core.payment.reconcile.domain.GeneralReconcileRecord;
|
import cn.bootx.platform.daxpay.service.core.payment.reconcile.domain.GeneralReconcileRecord;
|
||||||
import cn.bootx.platform.daxpay.service.func.AbsReconcileStrategy;
|
import cn.bootx.platform.daxpay.service.func.AbsReconcileStrategy;
|
||||||
|
import cn.bootx.platform.daxpay.service.handler.sequence.DaxPaySequenceHandler;
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -43,9 +42,7 @@ public class AlipayReconcileStrategy extends AbsReconcileStrategy {
|
|||||||
|
|
||||||
private final AliPayConfigService configService;
|
private final AliPayConfigService configService;
|
||||||
|
|
||||||
@Getter
|
private final DaxPaySequenceHandler daxPaySequenceHandler;
|
||||||
@Qualifier("alipayReconcileSequence")
|
|
||||||
private final Sequence sequence;
|
|
||||||
|
|
||||||
private AliPayConfig config;
|
private AliPayConfig config;
|
||||||
|
|
||||||
@@ -67,8 +64,10 @@ public class AlipayReconcileStrategy extends AbsReconcileStrategy {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String generateSequence(LocalDate date) {
|
public String generateSequence(LocalDate date) {
|
||||||
|
|
||||||
String prefix = getChannel().getReconcilePrefix();
|
String prefix = getChannel().getReconcilePrefix();
|
||||||
String dateStr = LocalDateTimeUtil.format(date, DatePattern.PURE_DATE_PATTERN);
|
String dateStr = LocalDateTimeUtil.format(date, DatePattern.PURE_DATE_PATTERN);
|
||||||
|
Sequence sequence = daxPaySequenceHandler.alipayReconcileSequence(dateStr);
|
||||||
String key = String.format("%02d", sequence.next());
|
String key = String.format("%02d", sequence.next());
|
||||||
return prefix + dateStr + key;
|
return prefix + dateStr + key;
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
package cn.bootx.platform.daxpay.service.core.payment.reconcile.strategy;
|
package cn.bootx.platform.daxpay.service.core.payment.reconcile.strategy;
|
||||||
|
|
||||||
import cn.bootx.platform.common.core.exception.BizException;
|
|
||||||
import cn.bootx.platform.common.core.util.LocalDateTimeUtil;
|
import cn.bootx.platform.common.core.util.LocalDateTimeUtil;
|
||||||
import cn.bootx.platform.common.sequence.func.Sequence;
|
import cn.bootx.platform.common.sequence.func.Sequence;
|
||||||
import cn.bootx.platform.daxpay.code.PayChannelEnum;
|
import cn.bootx.platform.daxpay.code.PayChannelEnum;
|
||||||
@@ -12,12 +11,12 @@ import cn.bootx.platform.daxpay.service.core.channel.union.service.UnionPayConfi
|
|||||||
import cn.bootx.platform.daxpay.service.core.channel.union.service.UnionPayReconcileService;
|
import cn.bootx.platform.daxpay.service.core.channel.union.service.UnionPayReconcileService;
|
||||||
import cn.bootx.platform.daxpay.service.core.payment.reconcile.domain.GeneralReconcileRecord;
|
import cn.bootx.platform.daxpay.service.core.payment.reconcile.domain.GeneralReconcileRecord;
|
||||||
import cn.bootx.platform.daxpay.service.func.AbsReconcileStrategy;
|
import cn.bootx.platform.daxpay.service.func.AbsReconcileStrategy;
|
||||||
|
import cn.bootx.platform.daxpay.service.handler.sequence.DaxPaySequenceHandler;
|
||||||
import cn.bootx.platform.daxpay.service.sdk.union.api.UnionPayKit;
|
import cn.bootx.platform.daxpay.service.sdk.union.api.UnionPayKit;
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -46,8 +45,7 @@ public class UnionPayReconcileStrategy extends AbsReconcileStrategy {
|
|||||||
|
|
||||||
private final UnionPayRecordManager recordManager;
|
private final UnionPayRecordManager recordManager;
|
||||||
|
|
||||||
@Qualifier("unionPayReconcileSequence")
|
private final DaxPaySequenceHandler daxPaySequenceHandler;
|
||||||
private final Sequence sequence;
|
|
||||||
|
|
||||||
private UnionPayKit unionPayKit;
|
private UnionPayKit unionPayKit;
|
||||||
|
|
||||||
@@ -58,6 +56,7 @@ public class UnionPayReconcileStrategy extends AbsReconcileStrategy {
|
|||||||
public String generateSequence(LocalDate date) {
|
public String generateSequence(LocalDate date) {
|
||||||
String prefix = getChannel().getReconcilePrefix();
|
String prefix = getChannel().getReconcilePrefix();
|
||||||
String dateStr = LocalDateTimeUtil.format(date, DatePattern.PURE_DATE_PATTERN);
|
String dateStr = LocalDateTimeUtil.format(date, DatePattern.PURE_DATE_PATTERN);
|
||||||
|
Sequence sequence = daxPaySequenceHandler.unionPayReconcileSequence(dateStr);
|
||||||
String key = String.format("%02d", sequence.next());
|
String key = String.format("%02d", sequence.next());
|
||||||
return prefix + dateStr + key;
|
return prefix + dateStr + key;
|
||||||
}
|
}
|
||||||
@@ -82,7 +81,6 @@ public class UnionPayReconcileStrategy extends AbsReconcileStrategy {
|
|||||||
public void downAndSave() {
|
public void downAndSave() {
|
||||||
Date date = DateUtil.date(this.getRecordOrder().getDate());
|
Date date = DateUtil.date(this.getRecordOrder().getDate());
|
||||||
reconcileService.downAndSave(date, this.getRecordOrder().getId(), this.unionPayKit);
|
reconcileService.downAndSave(date, this.getRecordOrder().getId(), this.unionPayKit);
|
||||||
throw new BizException("123");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -11,10 +11,10 @@ import cn.bootx.platform.daxpay.service.core.channel.wechat.service.WeChatPayCon
|
|||||||
import cn.bootx.platform.daxpay.service.core.channel.wechat.service.WechatPayReconcileService;
|
import cn.bootx.platform.daxpay.service.core.channel.wechat.service.WechatPayReconcileService;
|
||||||
import cn.bootx.platform.daxpay.service.core.payment.reconcile.domain.GeneralReconcileRecord;
|
import cn.bootx.platform.daxpay.service.core.payment.reconcile.domain.GeneralReconcileRecord;
|
||||||
import cn.bootx.platform.daxpay.service.func.AbsReconcileStrategy;
|
import cn.bootx.platform.daxpay.service.func.AbsReconcileStrategy;
|
||||||
|
import cn.bootx.platform.daxpay.service.handler.sequence.DaxPaySequenceHandler;
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -42,8 +42,7 @@ public class WechatPayReconcileStrategy extends AbsReconcileStrategy {
|
|||||||
|
|
||||||
private final WeChatPayRecordManager recordManager;
|
private final WeChatPayRecordManager recordManager;
|
||||||
|
|
||||||
@Qualifier("wechatReconcileSequence")
|
private final DaxPaySequenceHandler daxPaySequenceHandler;
|
||||||
private final Sequence sequence;
|
|
||||||
|
|
||||||
private WeChatPayConfig config;
|
private WeChatPayConfig config;
|
||||||
|
|
||||||
@@ -67,6 +66,7 @@ public class WechatPayReconcileStrategy extends AbsReconcileStrategy {
|
|||||||
public String generateSequence(LocalDate date) {
|
public String generateSequence(LocalDate date) {
|
||||||
String prefix = getChannel().getReconcilePrefix();
|
String prefix = getChannel().getReconcilePrefix();
|
||||||
String dateStr = LocalDateTimeUtil.format(date, DatePattern.PURE_DATE_PATTERN);
|
String dateStr = LocalDateTimeUtil.format(date, DatePattern.PURE_DATE_PATTERN);
|
||||||
|
Sequence sequence = daxPaySequenceHandler.wechatReconcileSequence(dateStr);
|
||||||
String key = String.format("%02d", sequence.next());
|
String key = String.format("%02d", sequence.next());
|
||||||
return prefix + dateStr + key;
|
return prefix + dateStr + key;
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,8 @@
|
|||||||
package cn.bootx.platform.daxpay.service.configuration.sequence;
|
package cn.bootx.platform.daxpay.service.handler.sequence;
|
||||||
|
|
||||||
import cn.bootx.platform.common.sequence.func.Sequence;
|
import cn.bootx.platform.common.sequence.func.Sequence;
|
||||||
import cn.bootx.platform.common.sequence.range.SeqRangeManager;
|
|
||||||
import cn.bootx.platform.common.sequence.util.SequenceUtil;
|
import cn.bootx.platform.common.sequence.util.SequenceUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,29 +12,26 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class DaxPaySequenceConfiguration {
|
public class DaxPaySequenceHandler {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付宝对账单序列生成器
|
* 支付宝对账单序列生成器
|
||||||
*/
|
*/
|
||||||
@Bean
|
public Sequence alipayReconcileSequence(String date) {
|
||||||
public Sequence alipayReconcileSequence(SeqRangeManager seqRangeManager) {
|
return SequenceUtil.create(1,1,1,"AlipayReconcileSequence"+date);
|
||||||
return SequenceUtil.create(1,1,1,"AlipayReconcileSequence");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信对账单序列生成器
|
* 微信对账单序列生成器
|
||||||
*/
|
*/
|
||||||
@Bean
|
public Sequence wechatReconcileSequence(String date) {
|
||||||
public Sequence wechatReconcileSequence(SeqRangeManager seqRangeManager) {
|
return SequenceUtil.create(1,1,1,"WechatReconcileSequence"+date);
|
||||||
return SequenceUtil.create(1,1,1,"WechatReconcileSequence");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 云闪付对账单序列生成器
|
* 云闪付对账单序列生成器
|
||||||
*/
|
*/
|
||||||
@Bean
|
public Sequence unionPayReconcileSequence(String date) {
|
||||||
public Sequence unionPayReconcileSequence(SeqRangeManager seqRangeManager) {
|
return SequenceUtil.create(1,1,1,"UnionPayReconcileSequence"+date);
|
||||||
return SequenceUtil.create(1,1,1,"UnionPayReconcileSequence");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -194,8 +194,6 @@ public class UnionPayKit extends UnionPayService {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public boolean verify(Map<String, Object> result) {
|
public boolean verify(Map<String, Object> result) {
|
||||||
|
|
||||||
|
|
||||||
return verify(new NoticeParams(result));
|
return verify(new NoticeParams(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user