修复支付取消与成功统计
This commit is contained in:
@@ -34,7 +34,14 @@ func (r *Repository) updateChannelStatus(ctx context.Context, paymentID uint64,
|
||||
if source == channelSourceNotify {
|
||||
updates["notified_at"] = time.Now()
|
||||
}
|
||||
return r.db.WithContext(ctx).Model(&model.PaymentOrder{}).Where("id = ?", paymentID).Updates(updates).Error
|
||||
return r.db.WithContext(ctx).Model(&model.PaymentOrder{}).
|
||||
Where("id = ? AND status NOT IN ?", paymentID, []string{"paid", "closed", "failed"}).
|
||||
Updates(updates).Error
|
||||
}
|
||||
|
||||
// isOrderPaymentTerminalStatus 判断订单支付流水是否已进入终态,终态不再被查询或普通回调刷回支付中。
|
||||
func isOrderPaymentTerminalStatus(status string) bool {
|
||||
return status == "paid" || status == "closed" || status == "failed"
|
||||
}
|
||||
func (r *Repository) confirmPaid(ctx context.Context, payment *model.PaymentOrder, status string, paidAt time.Time, raw map[string]string, source string) error {
|
||||
var newConvID uint64
|
||||
@@ -71,6 +78,11 @@ func (r *Repository) confirmPaid(ctx context.Context, payment *model.PaymentOrde
|
||||
if newConvID > 0 && r.orderRepo != nil {
|
||||
r.orderRepo.NotifyNewConversation(newConvID)
|
||||
}
|
||||
if latest, err := r.findPaymentByID(ctx, payment.ID); err == nil {
|
||||
if runtimeConfig, err := r.runtimeConfigForPayment(ctx, latest); err == nil {
|
||||
r.recordConfigUsage(ctx, runtimeConfig, latest)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (r *Repository) markPaymentFailed(ctx context.Context, paymentID uint64, raw map[string]string, message string) error {
|
||||
|
||||
Reference in New Issue
Block a user