更新小程序和管理后台配置,将 API 地址切换为生产环境。新增撤回打款功能,允许用户在特定状态下撤回打款请求,并优化相关页面交互。更新文档以反映新的流程图,确保用户体验一致性。
This commit is contained in:
@@ -351,6 +351,45 @@ func AdminWithdrawalsAction(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// AdminWithdrawalsCancel POST /api/admin/withdrawals/cancel 撤回打款(仅 processing/pending_confirm 可撤回)
|
||||
func AdminWithdrawalsCancel(c *gin.Context) {
|
||||
var body struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
if err := c.ShouldBindJSON(&body); err != nil || body.ID == "" {
|
||||
c.JSON(http.StatusOK, gin.H{"success": false, "error": "缺少 id"})
|
||||
return
|
||||
}
|
||||
db := database.DB()
|
||||
var w model.Withdrawal
|
||||
if err := db.Where("id = ?", body.ID).First(&w).Error; err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{"success": false, "error": "提现记录不存在"})
|
||||
return
|
||||
}
|
||||
st := ""
|
||||
if w.Status != nil {
|
||||
st = *w.Status
|
||||
}
|
||||
if st != "processing" && st != "pending_confirm" {
|
||||
c.JSON(http.StatusOK, gin.H{"success": false, "error": "当前状态不允许撤回,仅待确认收款时可撤回"})
|
||||
return
|
||||
}
|
||||
outBillNo := body.ID
|
||||
if w.DetailNo != nil && *w.DetailNo != "" {
|
||||
outBillNo = *w.DetailNo
|
||||
}
|
||||
if err := wechat.CancelTransferByOutBill(outBillNo); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{"success": false, "error": "撤回失败: " + err.Error()})
|
||||
return
|
||||
}
|
||||
now := time.Now()
|
||||
reason := "商户已撤回"
|
||||
_ = db.Model(&w).Updates(map[string]interface{}{
|
||||
"status": "failed", "fail_reason": reason, "error_message": reason, "processed_at": now,
|
||||
}).Error
|
||||
c.JSON(http.StatusOK, gin.H{"success": true, "message": "已撤回打款"})
|
||||
}
|
||||
|
||||
// AdminWithdrawalsSync POST /api/admin/withdrawals/sync 主动向微信查询转账结果并更新状态(无回调时的备选)
|
||||
// body: { "id": "提现记录id" } 同步单条;不传 id 或 id 为空则同步所有 processing/pending_confirm
|
||||
func AdminWithdrawalsSync(c *gin.Context) {
|
||||
|
||||
Reference in New Issue
Block a user