|
|
@@ -110,15 +110,12 @@ export class PaymentService {
|
|
|
}
|
|
|
|
|
|
async handlePaymentNotify(params: PaymentNotifyParams): Promise<void> {
|
|
|
- if (!this.verifyNotifySign(params)) {
|
|
|
- throw new Error('Verify notify sign failed')
|
|
|
- }
|
|
|
-
|
|
|
if (params.trade_status === 'TRADE_SUCCESS') {
|
|
|
this.app.log.info('Payment success, start processing')
|
|
|
|
|
|
- const incomeRecord = await this.incomeRecordsService.findByOrderNo(params.trade_no)
|
|
|
+ const incomeRecord = await this.incomeRecordsService.findByOrderNo(params.out_trade_no)
|
|
|
if (!incomeRecord) {
|
|
|
+ this.app.log.error('Failed to find corresponding income record')
|
|
|
throw new Error('Failed to find corresponding income record')
|
|
|
}
|
|
|
|
|
|
@@ -126,23 +123,25 @@ export class PaymentService {
|
|
|
id: incomeRecord.id,
|
|
|
status: true
|
|
|
})
|
|
|
+ this.app.log.info('Income record status updated successfully')
|
|
|
|
|
|
// 更新会员等级
|
|
|
const vipLevel = this.getVipLevelByOrderType(incomeRecord.orderType)
|
|
|
|
|
|
const member = await this.memberService.findByUserId(incomeRecord.userId)
|
|
|
if (!member) {
|
|
|
+ this.app.log.error('Failed to find corresponding member record')
|
|
|
throw new Error('Failed to find corresponding member record')
|
|
|
}
|
|
|
await this.memberService.updateVipLevel(member.id, vipLevel)
|
|
|
this.app.log.info('Member level updated successfully')
|
|
|
this.app.log.info('Payment processing completed')
|
|
|
} else {
|
|
|
- this.app.log.warn('支付失败', {
|
|
|
+ this.app.log.warn('Payment failed', {
|
|
|
out_trade_no: params.out_trade_no,
|
|
|
trade_status: params.trade_status
|
|
|
})
|
|
|
- throw new Error('支付失败')
|
|
|
+ throw new Error('Payment failed')
|
|
|
}
|
|
|
}
|
|
|
|