feat: MBTI头像与用户规则链路升级,三端页面与接口同步
Made-with: Cursor
This commit is contained in:
@@ -172,6 +172,18 @@ func RunSyncOrders(ctx context.Context, days int) (synced, total int, err error)
|
||||
).Delete(&model.Order{})
|
||||
|
||||
processReferralCommission(db, o.UserID, totalAmount, o.OrderSN, &o)
|
||||
if pushErr := pushPaidOrderWebhook(db, &o); pushErr != nil {
|
||||
syncOrdersLogf("订单 %s webhook 推送失败: %v", o.OrderSN, pushErr)
|
||||
markOrderWebhookResult(db, o.OrderSN, false, pushErr)
|
||||
} else {
|
||||
markOrderWebhookResult(db, o.OrderSN, true, nil)
|
||||
}
|
||||
}
|
||||
// 兜底补偿:服务器卡顿/回调异常导致的未推送订单,统一补推
|
||||
if retried, sentCount, rerr := RetryPendingPaidOrderWebhooks(ctx, 500); rerr != nil {
|
||||
syncOrdersLogf("补推未发送订单失败: %v", rerr)
|
||||
} else if retried > 0 {
|
||||
syncOrdersLogf("补推未发送订单: 扫描 %d 笔,成功 %d 笔", retried, sentCount)
|
||||
}
|
||||
return synced, total, nil
|
||||
}
|
||||
@@ -199,6 +211,28 @@ func CronSyncOrders(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
// CronRetryOrderWebhooks GET/POST /api/cron/retry-order-webhooks
|
||||
// 手动补偿重推:仅推送未成功推送过的已支付订单。
|
||||
func CronRetryOrderWebhooks(c *gin.Context) {
|
||||
limit := 500
|
||||
if s := strings.TrimSpace(c.Query("limit")); s != "" {
|
||||
if n, err := strconv.Atoi(s); err == nil && n > 0 && n <= 2000 {
|
||||
limit = n
|
||||
}
|
||||
}
|
||||
retried, sent, err := RetryPendingPaidOrderWebhooks(c.Request.Context(), limit)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{"success": false, "error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": true,
|
||||
"retried": retried,
|
||||
"sent": sent,
|
||||
"limit": limit,
|
||||
})
|
||||
}
|
||||
|
||||
// CronUnbindExpired GET/POST /api/cron/unbind-expired
|
||||
func CronUnbindExpired(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"success": true})
|
||||
|
||||
Reference in New Issue
Block a user