mirror of
https://gitee.com/dromara/dax-pay.git
synced 2025-09-02 10:36:57 +00:00
feat 微信支付宝流水记录
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
<version>${bootx-platform.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 支付SDK 结算台 -->
|
||||
<!-- 支付SDK -->
|
||||
<dependency>
|
||||
<groupId>cn.bootx.platform</groupId>
|
||||
<artifactId>daxpay-single-sdk</artifactId>
|
||||
|
@@ -0,0 +1,43 @@
|
||||
package cn.bootx.platform.daxpay.admin.controller.channel;
|
||||
|
||||
import cn.bootx.platform.common.core.rest.PageResult;
|
||||
import cn.bootx.platform.common.core.rest.Res;
|
||||
import cn.bootx.platform.common.core.rest.ResResult;
|
||||
import cn.bootx.platform.common.core.rest.param.PageParam;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.alipay.service.AliPayRecordService;
|
||||
import cn.bootx.platform.daxpay.service.dto.channel.alipay.AliPayRecordDto;
|
||||
import cn.bootx.platform.daxpay.service.param.channel.alipay.AliPayRecordQuery;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 支付宝控制器
|
||||
* @author xxm
|
||||
* @since 2024/2/20
|
||||
*/
|
||||
@Tag(name = "支付宝控制器")
|
||||
@RestController
|
||||
@RequestMapping("/alipay")
|
||||
@RequiredArgsConstructor
|
||||
public class AlipayController {
|
||||
private final AliPayRecordService aliPayRecordService;
|
||||
|
||||
|
||||
@Operation(summary = "记录分页")
|
||||
@GetMapping("/record/page")
|
||||
public ResResult<PageResult<AliPayRecordDto>> recordPage(PageParam pageParam, AliPayRecordQuery query){
|
||||
return Res.ok(aliPayRecordService.page(pageParam, query));
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "查询记录详情")
|
||||
@GetMapping("/record/findById")
|
||||
public ResResult<AliPayRecordDto> findById(Long id){
|
||||
return Res.ok(aliPayRecordService.findById(id));
|
||||
}
|
||||
|
||||
}
|
@@ -39,5 +39,4 @@ public class CashController {
|
||||
return Res.ok(cashRecordService.findById(id));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,43 @@
|
||||
package cn.bootx.platform.daxpay.admin.controller.channel;
|
||||
|
||||
import cn.bootx.platform.common.core.rest.PageResult;
|
||||
import cn.bootx.platform.common.core.rest.Res;
|
||||
import cn.bootx.platform.common.core.rest.ResResult;
|
||||
import cn.bootx.platform.common.core.rest.param.PageParam;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.wechat.service.WeChatPayRecordService;
|
||||
import cn.bootx.platform.daxpay.service.dto.channel.wechat.WeChatPayRecordDto;
|
||||
import cn.bootx.platform.daxpay.service.param.channel.wechat.WeChatPayRecordQuery;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 微信支付控制器
|
||||
* @author xxm
|
||||
* @since 2024/2/20
|
||||
*/
|
||||
@Tag(name = "微信支付控制器")
|
||||
@RestController
|
||||
@RequestMapping("/wechat/pay")
|
||||
@RequiredArgsConstructor
|
||||
public class WeChatPayController {
|
||||
private final WeChatPayRecordService weChatPayRecordService;
|
||||
|
||||
|
||||
@Operation(summary = "记录分页")
|
||||
@GetMapping("/record/page")
|
||||
public ResResult<PageResult<WeChatPayRecordDto>> recordPage(PageParam pageParam, WeChatPayRecordQuery query){
|
||||
return Res.ok(weChatPayRecordService.page(pageParam, query));
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "查询记录详情")
|
||||
@GetMapping("/record/findById")
|
||||
public ResResult<WeChatPayRecordDto> findById(Long id){
|
||||
return Res.ok(weChatPayRecordService.findById(id));
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package cn.bootx.platform.daxpay.service.code;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 支付宝流水记录类型
|
||||
* @author xxm
|
||||
* @since 2024/2/20
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum AliPayRecordTypeEnum {
|
||||
|
||||
/** 支付 */
|
||||
PAY("pay", "支付")
|
||||
,
|
||||
/** 退款 */
|
||||
REFUND("refund", "退款");
|
||||
|
||||
private final String code;
|
||||
private final String name;
|
||||
}
|
@@ -1,7 +1,9 @@
|
||||
package cn.bootx.platform.daxpay.service.core.channel.alipay.convert;
|
||||
|
||||
import cn.bootx.platform.daxpay.service.core.channel.alipay.entity.AliPayConfig;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.alipay.entity.AliPayRecord;
|
||||
import cn.bootx.platform.daxpay.service.dto.channel.alipay.AliPayConfigDto;
|
||||
import cn.bootx.platform.daxpay.service.dto.channel.alipay.AliPayRecordDto;
|
||||
import cn.bootx.platform.daxpay.service.param.channel.alipay.AliPayConfigParam;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
@@ -19,6 +21,8 @@ public interface AlipayConvert {
|
||||
|
||||
AliPayConfig convert(AliPayConfigDto in);
|
||||
|
||||
AliPayRecordDto convert(AliPayRecord in);
|
||||
|
||||
AliPayConfig convert(AliPayConfigParam in);
|
||||
|
||||
AliPayConfigDto convert(AliPayConfig in);
|
||||
|
@@ -1,7 +1,13 @@
|
||||
package cn.bootx.platform.daxpay.service.core.channel.alipay.dao;
|
||||
|
||||
import cn.bootx.platform.common.core.rest.param.PageParam;
|
||||
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
|
||||
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
|
||||
import cn.bootx.platform.common.query.generator.QueryGenerator;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.alipay.entity.AliPayRecord;
|
||||
import cn.bootx.platform.daxpay.service.param.channel.alipay.AliPayRecordQuery;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@@ -15,4 +21,14 @@ import org.springframework.stereotype.Repository;
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
public class AliPayRecordManager extends BaseManager<AliPayRecordMapper, AliPayRecord> {
|
||||
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
public Page<AliPayRecord> page(PageParam pageParam, AliPayRecordQuery param){
|
||||
Page<AliPayRecord> mpPage = MpUtil.getMpPage(pageParam, AliPayRecord.class);
|
||||
QueryWrapper<AliPayRecord> generator = QueryGenerator.generator(param);
|
||||
return this.page(mpPage, generator);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,11 @@
|
||||
package cn.bootx.platform.daxpay.service.core.channel.alipay.entity;
|
||||
|
||||
import cn.bootx.platform.common.core.function.EntityBaseFunction;
|
||||
import cn.bootx.platform.common.mybatisplus.base.MpCreateEntity;
|
||||
import cn.bootx.platform.daxpay.service.code.AliPayRecordTypeEnum;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.alipay.convert.AlipayConvert;
|
||||
import cn.bootx.platform.daxpay.service.dto.channel.alipay.AliPayRecordDto;
|
||||
import cn.bootx.table.modify.annotation.DbColumn;
|
||||
import cn.bootx.table.modify.annotation.DbTable;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
@@ -17,15 +22,33 @@ import lombok.experimental.Accessors;
|
||||
@Accessors(chain = true)
|
||||
@DbTable(comment = "支付宝流水记录")
|
||||
@TableName("pay_alipay_record")
|
||||
public class AliPayRecord extends MpCreateEntity {
|
||||
public class AliPayRecord extends MpCreateEntity implements EntityBaseFunction<AliPayRecordDto> {
|
||||
|
||||
/** 标题 */
|
||||
@DbColumn(comment = "标题")
|
||||
private String title;
|
||||
|
||||
/** 金额 */
|
||||
@DbColumn(comment = "金额")
|
||||
private Integer amount;
|
||||
|
||||
/** 业务类型 */
|
||||
/**
|
||||
* 业务类型
|
||||
* @see AliPayRecordTypeEnum
|
||||
*/
|
||||
@DbColumn(comment = "业务类型")
|
||||
private String type;
|
||||
|
||||
/** 本地订单号 */
|
||||
@DbColumn(comment = "本地订单号")
|
||||
private Long orderId;
|
||||
|
||||
/** 网关订单号 */
|
||||
@DbColumn(comment = "网关订单号")
|
||||
private String gatewayOrderNo;
|
||||
|
||||
@Override
|
||||
public AliPayRecordDto toDto() {
|
||||
return AlipayConvert.CONVERT.convert(this);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,18 @@
|
||||
package cn.bootx.platform.daxpay.service.core.channel.alipay.service;
|
||||
|
||||
|
||||
import cn.bootx.platform.common.core.exception.DataNotExistException;
|
||||
import cn.bootx.platform.common.core.rest.PageResult;
|
||||
import cn.bootx.platform.common.core.rest.param.PageParam;
|
||||
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
|
||||
import cn.bootx.platform.daxpay.service.code.AliPayRecordTypeEnum;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.alipay.dao.AliPayRecordManager;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.alipay.entity.AliPayRecord;
|
||||
import cn.bootx.platform.daxpay.service.core.order.pay.entity.PayChannelOrder;
|
||||
import cn.bootx.platform.daxpay.service.core.order.pay.entity.PayOrder;
|
||||
import cn.bootx.platform.daxpay.service.core.order.refund.entity.PayRefundChannelOrder;
|
||||
import cn.bootx.platform.daxpay.service.core.order.refund.entity.PayRefundOrder;
|
||||
import cn.bootx.platform.daxpay.service.dto.channel.alipay.AliPayRecordDto;
|
||||
import cn.bootx.platform.daxpay.service.param.channel.alipay.AliPayRecordQuery;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -14,4 +26,46 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AliPayRecordService {
|
||||
|
||||
private final AliPayRecordManager aliPayRecordManager;
|
||||
|
||||
/**
|
||||
* 支付
|
||||
*/
|
||||
public void pay(PayOrder order, PayChannelOrder channelOrder){
|
||||
AliPayRecord aliPayRecord = new AliPayRecord()
|
||||
.setType(AliPayRecordTypeEnum.PAY.getCode())
|
||||
.setTitle(order.getTitle())
|
||||
.setOrderId(order.getId())
|
||||
.setGatewayOrderNo(order.getGatewayOrderNo())
|
||||
.setAmount(channelOrder.getAmount());
|
||||
aliPayRecordManager.save(aliPayRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款
|
||||
*/
|
||||
public void refund(PayRefundOrder order, PayRefundChannelOrder channelOrder){
|
||||
AliPayRecord aliPayRecord = new AliPayRecord()
|
||||
.setType(AliPayRecordTypeEnum.PAY.getCode())
|
||||
.setTitle(order.getTitle())
|
||||
.setOrderId(order.getId())
|
||||
.setGatewayOrderNo(order.getGatewayOrderNo())
|
||||
.setAmount(channelOrder.getAmount());
|
||||
aliPayRecordManager.save(aliPayRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
public PageResult<AliPayRecordDto> page(PageParam pageParam, AliPayRecordQuery param){
|
||||
return MpUtil.convert2DtoPageResult(aliPayRecordManager.page(pageParam, param));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询详情
|
||||
*/
|
||||
public AliPayRecordDto findById(Long id){
|
||||
return aliPayRecordManager.findById(id).map(AliPayRecord::toDto).orElseThrow(DataNotExistException::new);
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,11 @@ package cn.bootx.platform.daxpay.service.core.channel.wallet.convert;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.wallet.entity.Wallet;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.wallet.entity.WalletConfig;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.wallet.entity.WalletRecord;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.wechat.entity.WeChatPayRecord;
|
||||
import cn.bootx.platform.daxpay.service.dto.channel.wallet.WalletConfigDto;
|
||||
import cn.bootx.platform.daxpay.service.dto.channel.wallet.WalletDto;
|
||||
import cn.bootx.platform.daxpay.service.dto.channel.wallet.WalletRecordDto;
|
||||
import cn.bootx.platform.daxpay.service.dto.channel.wechat.WeChatPayRecordDto;
|
||||
import cn.bootx.platform.daxpay.service.param.channel.wechat.WalletConfigParam;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
@@ -1,7 +1,9 @@
|
||||
package cn.bootx.platform.daxpay.service.core.channel.wechat.convert;
|
||||
|
||||
import cn.bootx.platform.daxpay.service.core.channel.wechat.entity.WeChatPayConfig;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.wechat.entity.WeChatPayRecord;
|
||||
import cn.bootx.platform.daxpay.service.dto.channel.wechat.WeChatPayConfigDto;
|
||||
import cn.bootx.platform.daxpay.service.dto.channel.wechat.WeChatPayRecordDto;
|
||||
import cn.bootx.platform.daxpay.service.param.channel.wechat.WeChatPayConfigParam;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
@@ -19,6 +21,8 @@ public interface WeChatConvert {
|
||||
|
||||
WeChatPayConfig convert(WeChatPayConfigParam in);
|
||||
|
||||
WeChatPayRecordDto convert(WeChatPayRecord in);
|
||||
|
||||
WeChatPayConfigDto convert(WeChatPayConfig in);
|
||||
|
||||
}
|
||||
|
@@ -1,5 +1,13 @@
|
||||
package cn.bootx.platform.daxpay.service.core.channel.wechat.dao;
|
||||
|
||||
import cn.bootx.platform.common.core.rest.param.PageParam;
|
||||
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
|
||||
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
|
||||
import cn.bootx.platform.common.query.generator.QueryGenerator;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.wechat.entity.WeChatPayRecord;
|
||||
import cn.bootx.platform.daxpay.service.param.channel.wechat.WeChatPayRecordQuery;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@@ -12,5 +20,14 @@ import org.springframework.stereotype.Repository;
|
||||
@Slf4j
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
public class WeChatPayRecordManager {
|
||||
public class WeChatPayRecordManager extends BaseManager<WeChatPayRecordMapper, WeChatPayRecord> {
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
public Page<WeChatPayRecord> page(PageParam pageParam, WeChatPayRecordQuery param){
|
||||
Page<WeChatPayRecord> mpPage = MpUtil.getMpPage(pageParam, WeChatPayRecord.class);
|
||||
QueryWrapper<WeChatPayRecord> generator = QueryGenerator.generator(param);
|
||||
return this.page(mpPage, generator);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,11 @@
|
||||
package cn.bootx.platform.daxpay.service.core.channel.wechat.entity;
|
||||
|
||||
import cn.bootx.platform.common.core.function.EntityBaseFunction;
|
||||
import cn.bootx.platform.common.mybatisplus.base.MpCreateEntity;
|
||||
import cn.bootx.platform.daxpay.service.code.AliPayRecordTypeEnum;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.wechat.convert.WeChatConvert;
|
||||
import cn.bootx.platform.daxpay.service.dto.channel.wechat.WeChatPayRecordDto;
|
||||
import cn.bootx.table.modify.annotation.DbColumn;
|
||||
import cn.bootx.table.modify.annotation.DbTable;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
@@ -17,5 +22,33 @@ import lombok.experimental.Accessors;
|
||||
@DbTable(comment = "微信支付记录")
|
||||
@Accessors(chain = true)
|
||||
@TableName("pay_wechat_pay_record")
|
||||
public class WeChatPayRecord extends MpCreateEntity {
|
||||
public class WeChatPayRecord extends MpCreateEntity implements EntityBaseFunction<WeChatPayRecordDto> {
|
||||
|
||||
/** 标题 */
|
||||
@DbColumn(comment = "标题")
|
||||
private String title;
|
||||
|
||||
/** 金额 */
|
||||
@DbColumn(comment = "金额")
|
||||
private Integer amount;
|
||||
|
||||
/**
|
||||
* 业务类型
|
||||
* @see AliPayRecordTypeEnum
|
||||
*/
|
||||
@DbColumn(comment = "业务类型")
|
||||
private String type;
|
||||
|
||||
/** 本地订单号 */
|
||||
@DbColumn(comment = "本地订单号")
|
||||
private Long orderId;
|
||||
|
||||
/** 网关订单号 */
|
||||
@DbColumn(comment = "网关订单号")
|
||||
private String gatewayOrderNo;
|
||||
|
||||
@Override
|
||||
public WeChatPayRecordDto toDto() {
|
||||
return WeChatConvert.CONVERT.convert(this);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,18 @@
|
||||
package cn.bootx.platform.daxpay.service.core.channel.wechat.service;
|
||||
|
||||
import cn.bootx.platform.common.core.exception.DataNotExistException;
|
||||
import cn.bootx.platform.common.core.rest.PageResult;
|
||||
import cn.bootx.platform.common.core.rest.param.PageParam;
|
||||
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
|
||||
import cn.bootx.platform.daxpay.service.code.AliPayRecordTypeEnum;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.wechat.dao.WeChatPayRecordManager;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.wechat.entity.WeChatPayRecord;
|
||||
import cn.bootx.platform.daxpay.service.core.order.pay.entity.PayChannelOrder;
|
||||
import cn.bootx.platform.daxpay.service.core.order.pay.entity.PayOrder;
|
||||
import cn.bootx.platform.daxpay.service.core.order.refund.entity.PayRefundChannelOrder;
|
||||
import cn.bootx.platform.daxpay.service.core.order.refund.entity.PayRefundOrder;
|
||||
import cn.bootx.platform.daxpay.service.dto.channel.wechat.WeChatPayRecordDto;
|
||||
import cn.bootx.platform.daxpay.service.param.channel.wechat.WeChatPayRecordQuery;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -15,4 +27,46 @@ import org.springframework.stereotype.Service;
|
||||
@RequiredArgsConstructor
|
||||
public class WeChatPayRecordService {
|
||||
private final WeChatPayRecordManager weChatPayRecordManager;
|
||||
|
||||
/**
|
||||
* 支付
|
||||
*/
|
||||
public void pay(PayOrder order, PayChannelOrder channelOrder){
|
||||
WeChatPayRecord weChatPayRecord = new WeChatPayRecord()
|
||||
.setType(AliPayRecordTypeEnum.PAY.getCode())
|
||||
.setTitle(order.getTitle())
|
||||
.setOrderId(order.getId())
|
||||
.setGatewayOrderNo(order.getGatewayOrderNo())
|
||||
.setAmount(channelOrder.getAmount());
|
||||
weChatPayRecordManager.save(weChatPayRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款
|
||||
*/
|
||||
public void refund(PayRefundOrder order, PayRefundChannelOrder channelOrder){
|
||||
WeChatPayRecord weChatPayRecord = new WeChatPayRecord()
|
||||
.setType(AliPayRecordTypeEnum.PAY.getCode())
|
||||
.setTitle(order.getTitle())
|
||||
.setOrderId(order.getId())
|
||||
.setGatewayOrderNo(order.getGatewayOrderNo())
|
||||
.setAmount(channelOrder.getAmount());
|
||||
weChatPayRecordManager.save(weChatPayRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
public PageResult<WeChatPayRecordDto> page(PageParam pageParam, WeChatPayRecordQuery param){
|
||||
return MpUtil.convert2DtoPageResult(weChatPayRecordManager.page(pageParam, param));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询详情
|
||||
*/
|
||||
public WeChatPayRecordDto findById(Long id){
|
||||
return weChatPayRecordManager.findById(id).map(WeChatPayRecord::toDto).orElseThrow(DataNotExistException::new);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -201,8 +201,7 @@ public class WeChatPayService {
|
||||
String errCode = result.get(WeChatPayCode.ERR_CODE);
|
||||
// 支付成功处理,
|
||||
if (Objects.equals(resultCode, WeChatPayCode.PAY_SUCCESS)) {
|
||||
asyncPayInfo.setGatewayOrderNo(result.get(WeChatPayCode.TRANSACTION_ID))
|
||||
.setPayComplete(true);
|
||||
asyncPayInfo.setGatewayOrderNo(result.get(WeChatPayCode.TRANSACTION_ID)).setPayComplete(true);
|
||||
return;
|
||||
}
|
||||
// 支付中, 发起轮训同步
|
||||
|
@@ -77,7 +77,7 @@ public class PayCallbackService {
|
||||
*/
|
||||
private void success(PayOrder payOrder) {
|
||||
CallbackLocal callbackInfo = PaymentContextLocal.get().getCallbackInfo();
|
||||
// 回调时间超出了支付单超时时间, 记录一下, 不做处理 TODO 这块应该把订单给当成正常结束给处理了,
|
||||
// 回调时间超出了支付单超时时间, 记录一下, 不做处理 TODO 考虑不全, 需要做退款or人工处理
|
||||
if (Objects.nonNull(payOrder.getExpiredTime())
|
||||
&& LocalDateTimeUtil.ge(LocalDateTime.now(), payOrder.getExpiredTime())) {
|
||||
callbackInfo.setCallbackStatus(PayCallbackStatusEnum.EXCEPTION).setMsg("回调时间超出了支付单支付有效时间");
|
||||
|
@@ -5,8 +5,11 @@ import cn.bootx.platform.daxpay.exception.pay.PayAmountAbnormalException;
|
||||
import cn.bootx.platform.daxpay.exception.pay.PayFailureException;
|
||||
import cn.bootx.platform.daxpay.param.channel.AliPayParam;
|
||||
import cn.bootx.platform.daxpay.param.pay.PayChannelParam;
|
||||
import cn.bootx.platform.daxpay.service.common.context.AsyncPayLocal;
|
||||
import cn.bootx.platform.daxpay.service.common.local.PaymentContextLocal;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.alipay.entity.AliPayConfig;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.alipay.service.AliPayConfigService;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.alipay.service.AliPayRecordService;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.alipay.service.AliPayService;
|
||||
import cn.bootx.platform.daxpay.service.core.order.pay.service.PayChannelOrderService;
|
||||
import cn.bootx.platform.daxpay.service.func.AbsPayStrategy;
|
||||
@@ -38,6 +41,8 @@ public class AliPayStrategy extends AbsPayStrategy {
|
||||
|
||||
private final AliPayConfigService alipayConfigService;
|
||||
|
||||
private final AliPayRecordService aliRecordService;
|
||||
|
||||
private AliPayConfig alipayConfig;
|
||||
|
||||
private AliPayParam aliPayParam;
|
||||
@@ -88,15 +93,12 @@ public class AliPayStrategy extends AbsPayStrategy {
|
||||
*/
|
||||
@Override
|
||||
public void doSuccessHandler() {
|
||||
AsyncPayLocal asyncPayInfo = PaymentContextLocal.get().getAsyncPayInfo();
|
||||
channelOrderService.switchAsyncPayChannel(this.getOrder(), this.getPayChannelParam());
|
||||
this.getOrder().setAsyncChannel(this.getChannel().getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 不使用默认的生成通道支付单方法, 异步支付通道的支付订单自己管理
|
||||
*/
|
||||
@Override
|
||||
public void generateChannelOrder() {
|
||||
// 支付完成, 保存记录
|
||||
if (asyncPayInfo.isPayComplete()) {
|
||||
aliRecordService.pay(this.getOrder(), this.getChannelOrder());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -3,8 +3,11 @@ package cn.bootx.platform.daxpay.service.core.payment.pay.strategy;
|
||||
import cn.bootx.platform.daxpay.code.PayChannelEnum;
|
||||
import cn.bootx.platform.daxpay.exception.pay.PayAmountAbnormalException;
|
||||
import cn.bootx.platform.daxpay.param.pay.PayChannelParam;
|
||||
import cn.bootx.platform.daxpay.service.common.context.AsyncPayLocal;
|
||||
import cn.bootx.platform.daxpay.service.common.local.PaymentContextLocal;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.wechat.entity.WeChatPayConfig;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.wechat.service.WeChatPayConfigService;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.wechat.service.WeChatPayRecordService;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.wechat.service.WeChatPayService;
|
||||
import cn.bootx.platform.daxpay.service.core.order.pay.service.PayChannelOrderService;
|
||||
import cn.bootx.platform.daxpay.service.func.AbsPayStrategy;
|
||||
@@ -36,6 +39,8 @@ public class WeChatPayStrategy extends AbsPayStrategy {
|
||||
|
||||
private final WeChatPayService weChatPayService;
|
||||
|
||||
private final WeChatPayRecordService weChatPayRecordService;
|
||||
|
||||
private WeChatPayConfig weChatPayConfig;
|
||||
|
||||
private WeChatPayParam weChatPayParam;
|
||||
@@ -87,6 +92,11 @@ public class WeChatPayStrategy extends AbsPayStrategy {
|
||||
public void doSuccessHandler() {
|
||||
channelOrderService.switchAsyncPayChannel(this.getOrder(), this.getPayChannelParam());
|
||||
this.getOrder().setAsyncChannel(this.getChannel().getCode());
|
||||
AsyncPayLocal asyncPayInfo = PaymentContextLocal.get().getAsyncPayInfo();
|
||||
// 是否支付完成, 保存流水记录
|
||||
if (asyncPayInfo.isPayComplete()){
|
||||
weChatPayRecordService.pay(this.getOrder(), this.getChannelOrder());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -5,6 +5,7 @@ import cn.bootx.platform.daxpay.code.RefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.service.common.local.PaymentContextLocal;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.alipay.entity.AliPayConfig;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.alipay.service.AliPayConfigService;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.alipay.service.AliPayRecordService;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.alipay.service.AliPayRefundService;
|
||||
import cn.bootx.platform.daxpay.service.core.order.pay.service.PayChannelOrderService;
|
||||
import cn.bootx.platform.daxpay.service.func.AbsRefundStrategy;
|
||||
@@ -12,6 +13,8 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;
|
||||
|
||||
/**
|
||||
@@ -26,6 +29,7 @@ public class AliPayRefundStrategy extends AbsRefundStrategy {
|
||||
|
||||
private final AliPayConfigService alipayConfigService;
|
||||
private final AliPayRefundService aliRefundService;
|
||||
private final AliPayRecordService aliRecordService;;
|
||||
private final PayChannelOrderService payChannelOrderService;
|
||||
/**
|
||||
* 策略标识
|
||||
@@ -68,5 +72,9 @@ public class AliPayRefundStrategy extends AbsRefundStrategy {
|
||||
|
||||
// 更新支付通道订单中的属性
|
||||
payChannelOrderService.updateAsyncPayRefund(this.getPayChannelOrder(), this.getRefundChannelOrder());
|
||||
// 如果退款完成, 保存流水记录
|
||||
if (Objects.equals(RefundStatusEnum.SUCCESS.getCode(), refundStatusEnum.getCode())) {
|
||||
aliRecordService.refund(this.getRefundOrder(), this.getRefundChannelOrder());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@ import cn.bootx.platform.daxpay.code.RefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.service.common.local.PaymentContextLocal;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.wechat.entity.WeChatPayConfig;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.wechat.service.WeChatPayConfigService;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.wechat.service.WeChatPayRecordService;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.wechat.service.WechatRefundService;
|
||||
import cn.bootx.platform.daxpay.service.core.order.pay.service.PayChannelOrderService;
|
||||
import cn.bootx.platform.daxpay.service.func.AbsRefundStrategy;
|
||||
@@ -12,6 +13,8 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;
|
||||
|
||||
/**
|
||||
@@ -28,6 +31,8 @@ public class WeChatPayRefundStrategy extends AbsRefundStrategy {
|
||||
|
||||
private final WechatRefundService wechatRefundService;
|
||||
|
||||
private final WeChatPayRecordService weChatPayRecordService;
|
||||
|
||||
private final PayChannelOrderService payChannelOrderService;
|
||||
|
||||
private WeChatPayConfig weChatPayConfig;
|
||||
@@ -72,5 +77,9 @@ public class WeChatPayRefundStrategy extends AbsRefundStrategy {
|
||||
|
||||
// 更新支付通道订单中的属性
|
||||
payChannelOrderService.updateAsyncPayRefund(this.getPayChannelOrder(), this.getRefundChannelOrder());
|
||||
// 如果退款完成, 保存流水记录
|
||||
if (Objects.equals(RefundStatusEnum.SUCCESS.getCode(), refundStatusEnum.getCode())) {
|
||||
weChatPayRecordService.refund(this.getRefundOrder(), this.getRefundChannelOrder());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ import cn.bootx.platform.daxpay.service.common.local.PaymentContextLocal;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.alipay.entity.AliPayConfig;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.alipay.service.AliPayCloseService;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.alipay.service.AliPayConfigService;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.alipay.service.AliPayRecordService;
|
||||
import cn.bootx.platform.daxpay.service.core.order.pay.dao.PayChannelOrderManager;
|
||||
import cn.bootx.platform.daxpay.service.func.AbsPayRepairStrategy;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -31,6 +32,8 @@ public class AliPayRepairStrategy extends AbsPayRepairStrategy {
|
||||
|
||||
private final AliPayConfigService aliPayConfigService;
|
||||
|
||||
private final AliPayRecordService aliRecordService;
|
||||
|
||||
private final PayChannelOrderManager payChannelOrderManager;
|
||||
|
||||
/**
|
||||
@@ -61,6 +64,8 @@ public class AliPayRepairStrategy extends AbsPayRepairStrategy {
|
||||
this.getChannelOrder().setStatus(PayStatusEnum.SUCCESS.getCode())
|
||||
.setPayTime(payTime);
|
||||
payChannelOrderManager.updateById(this.getChannelOrder());
|
||||
// 支付完成, 保存记录
|
||||
aliRecordService.pay(this.getOrder(), this.getChannelOrder());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -6,6 +6,7 @@ import cn.bootx.platform.daxpay.service.common.local.PaymentContextLocal;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.wechat.entity.WeChatPayConfig;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.wechat.service.WeChatPayCloseService;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.wechat.service.WeChatPayConfigService;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.wechat.service.WeChatPayRecordService;
|
||||
import cn.bootx.platform.daxpay.service.core.order.pay.dao.PayChannelOrderManager;
|
||||
import cn.bootx.platform.daxpay.service.func.AbsPayRepairStrategy;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -33,6 +34,8 @@ public class WeChatPayRepairStrategy extends AbsPayRepairStrategy {
|
||||
|
||||
private final PayChannelOrderManager payChannelOrderManager;
|
||||
|
||||
private final WeChatPayRecordService weChatPayRecordService;
|
||||
|
||||
private WeChatPayConfig weChatPayConfig;
|
||||
|
||||
/**
|
||||
@@ -62,6 +65,8 @@ public class WeChatPayRepairStrategy extends AbsPayRepairStrategy {
|
||||
this.getChannelOrder().setStatus(PayStatusEnum.SUCCESS.getCode())
|
||||
.setPayTime(payTime);
|
||||
payChannelOrderManager.updateById(this.getChannelOrder());
|
||||
// 保存流水记录
|
||||
weChatPayRecordService.pay(this.getOrder(), this.getChannelOrder());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -2,6 +2,7 @@ package cn.bootx.platform.daxpay.service.core.payment.repair.strategy.refund;
|
||||
|
||||
import cn.bootx.platform.daxpay.code.PayChannelEnum;
|
||||
import cn.bootx.platform.daxpay.service.common.local.PaymentContextLocal;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.alipay.service.AliPayRecordService;
|
||||
import cn.bootx.platform.daxpay.service.func.AbsRefundRepairStrategy;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -23,6 +24,8 @@ import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROT
|
||||
@RequiredArgsConstructor
|
||||
public class AliRefundRepairStrategy extends AbsRefundRepairStrategy {
|
||||
|
||||
private final AliPayRecordService aliPayRecordService;
|
||||
|
||||
/**
|
||||
* 策略标识
|
||||
*/
|
||||
@@ -43,5 +46,7 @@ public class AliRefundRepairStrategy extends AbsRefundRepairStrategy {
|
||||
super.doSuccessHandler();
|
||||
// 异步支付需要追加完成时间
|
||||
this.getRefundChannelOrder().setRefundTime(finishTime);
|
||||
// 记录退款成功记录
|
||||
aliPayRecordService.refund(this.getRefundOrder(), this.getRefundChannelOrder());
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package cn.bootx.platform.daxpay.service.core.payment.repair.strategy.refund;
|
||||
|
||||
import cn.bootx.platform.daxpay.code.PayChannelEnum;
|
||||
import cn.bootx.platform.daxpay.service.common.local.PaymentContextLocal;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.wechat.service.WeChatPayRecordService;
|
||||
import cn.bootx.platform.daxpay.service.func.AbsRefundRepairStrategy;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -22,6 +23,9 @@ import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROT
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class WeChatRefundRepairStrategy extends AbsRefundRepairStrategy {
|
||||
|
||||
private final WeChatPayRecordService wechatPayRecordService;
|
||||
|
||||
/**
|
||||
* 策略标识
|
||||
*/
|
||||
@@ -42,5 +46,7 @@ public class WeChatRefundRepairStrategy extends AbsRefundRepairStrategy {
|
||||
super.doSuccessHandler();
|
||||
// 异步支付需要追加完成时间
|
||||
this.getRefundChannelOrder().setRefundTime(finishTime);
|
||||
// 记录退款成功记录
|
||||
wechatPayRecordService.refund(this.getRefundOrder(), this.getRefundChannelOrder());
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,44 @@
|
||||
package cn.bootx.platform.daxpay.service.dto.channel.alipay;
|
||||
|
||||
import cn.bootx.platform.common.core.rest.dto.BaseDto;
|
||||
import cn.bootx.platform.daxpay.service.code.AliPayRecordTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 微信支付记录
|
||||
* @author xxm
|
||||
* @since 2024/2/20
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "微信支付记录")
|
||||
public class AliPayRecordDto extends BaseDto {
|
||||
|
||||
/** 标题 */
|
||||
@Schema(description = "标题")
|
||||
private String title;
|
||||
|
||||
/** 金额 */
|
||||
@Schema(description = "金额")
|
||||
private Integer amount;
|
||||
|
||||
/**
|
||||
* 业务类型
|
||||
* @see AliPayRecordTypeEnum
|
||||
*/
|
||||
@Schema(description = "业务类型")
|
||||
private String type;
|
||||
|
||||
/** 本地订单号 */
|
||||
@Schema(description = "本地订单号")
|
||||
private Long orderId;
|
||||
|
||||
/** 网关订单号 */
|
||||
@Schema(description = "网关订单号")
|
||||
private String gatewayOrderNo;
|
||||
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
package cn.bootx.platform.daxpay.service.dto.channel.wechat;
|
||||
|
||||
import cn.bootx.platform.common.core.rest.dto.BaseDto;
|
||||
import cn.bootx.platform.daxpay.service.code.AliPayRecordTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 微信支付记录
|
||||
* @author xxm
|
||||
* @since 2024/2/20
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "微信支付记录")
|
||||
public class WeChatPayRecordDto extends BaseDto {
|
||||
|
||||
/** 标题 */
|
||||
@Schema(description = "标题")
|
||||
private String title;
|
||||
|
||||
/** 金额 */
|
||||
@Schema(description = "金额")
|
||||
private Integer amount;
|
||||
|
||||
/**
|
||||
* 业务类型
|
||||
* @see AliPayRecordTypeEnum
|
||||
*/
|
||||
@Schema(description = "业务类型")
|
||||
private String type;
|
||||
|
||||
/** 本地订单号 */
|
||||
@Schema(description = "本地订单号")
|
||||
private Long orderId;
|
||||
|
||||
/** 网关订单号 */
|
||||
@Schema(description = "网关订单号")
|
||||
private String gatewayOrderNo;
|
||||
|
||||
}
|
@@ -32,7 +32,6 @@ public abstract class AbsCallbackStrategy implements PayStrategy {
|
||||
|
||||
/**
|
||||
* 回调处理入口
|
||||
* TODO 需要处理异常情况进行保存
|
||||
*/
|
||||
public String callback(Map<String, String> params) {
|
||||
CallbackLocal callbackInfo = PaymentContextLocal.get().getCallbackInfo();
|
||||
|
@@ -0,0 +1,36 @@
|
||||
package cn.bootx.platform.daxpay.service.param.channel.alipay;
|
||||
|
||||
import cn.bootx.platform.common.core.annotation.QueryParam;
|
||||
import cn.bootx.platform.common.core.rest.param.QueryOrder;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 支付宝支付记录查询参数
|
||||
* @author xxm
|
||||
* @since 2024/2/20
|
||||
*/
|
||||
@QueryParam
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "支付宝支付记录查询参数")
|
||||
public class AliPayRecordQuery extends QueryOrder {
|
||||
|
||||
@QueryParam(type = QueryParam.CompareTypeEnum.LIKE)
|
||||
@Schema(description = "标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "类型")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "本地订单ID")
|
||||
private Long orderId;
|
||||
|
||||
@Schema(description = "网关订单号")
|
||||
private String gatewayOrderNo;
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
package cn.bootx.platform.daxpay.service.param.channel.wechat;
|
||||
|
||||
import cn.bootx.platform.common.core.annotation.QueryParam;
|
||||
import cn.bootx.platform.common.core.rest.param.QueryOrder;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 微信支付记录查询参数
|
||||
* @author xxm
|
||||
* @since 2024/2/20
|
||||
*/
|
||||
@QueryParam
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "微信支付记录查询参数")
|
||||
public class WeChatPayRecordQuery extends QueryOrder {
|
||||
|
||||
@QueryParam(type = QueryParam.CompareTypeEnum.LIKE)
|
||||
@Schema(description = "标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "类型")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "本地订单ID")
|
||||
private Long orderId;
|
||||
|
||||
@Schema(description = "网关订单号")
|
||||
private String gatewayOrderNo;
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user