|
|
@@ -34,7 +34,9 @@ export class PaymentMtService extends GenericCrudService<PaymentMtEntity> {
|
|
|
* 初始化微信支付SDK实例
|
|
|
*/
|
|
|
private async initializeWxPay(tenantId: number): Promise<void> {
|
|
|
+ console.debug("tenantId:",tenantId);
|
|
|
const config = await this.getPaymentConfig(tenantId);
|
|
|
+ console.debug("config:",config);
|
|
|
|
|
|
// 初始化微信支付SDK
|
|
|
this.wxPay = new WxPay({
|
|
|
@@ -119,12 +121,18 @@ export class PaymentMtService extends GenericCrudService<PaymentMtEntity> {
|
|
|
openid: string,
|
|
|
tenantId: number
|
|
|
): Promise<PaymentCreateResponse> {
|
|
|
+
|
|
|
+ console.debug("start:");
|
|
|
+ console.debug("tenantId:",tenantId);
|
|
|
// 检查是否已存在相同外部订单ID的支付记录
|
|
|
const paymentRepository = this.dataSource.getRepository(PaymentMtEntity);
|
|
|
+ console.debug("paymentRepository:",paymentRepository);
|
|
|
+
|
|
|
const existingPayment = await paymentRepository.findOne({
|
|
|
where: { externalOrderId, tenantId }
|
|
|
});
|
|
|
|
|
|
+ console.debug("existingPayment:",existingPayment);
|
|
|
if (existingPayment) {
|
|
|
// 如果支付记录状态是PAID(已支付),不允许重新支付
|
|
|
if (existingPayment.paymentStatus === PaymentStatus.PAID) {
|
|
|
@@ -147,13 +155,14 @@ export class PaymentMtService extends GenericCrudService<PaymentMtEntity> {
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
+ console.debug("initializeWxPay before");
|
|
|
// 重新初始化微信支付SDK
|
|
|
await this.initializeWxPay(tenantId);
|
|
|
|
|
|
// 获取支付配置
|
|
|
const config = await this.getPaymentConfig(tenantId);
|
|
|
|
|
|
- // console.debug('微信支付配置:', config);
|
|
|
+ console.debug('微信支付配置:', config);
|
|
|
|
|
|
// 创建商户订单号
|
|
|
const outTradeNo = `PAYMENT_${externalOrderId}_${Date.now()}`;
|