代喂改走真实订单,并补上打卡纪律与地址明文清除
支付原来是个占位:调一下接口任务就算"已付"。现在任务和喂养者保证金都 走会员那套订单与支付网关,一笔订单买到什么由 applyPaidOrderTx 统一决定, 沙箱和真实回调走同一段逻辑。退款能释放托管中的任务,但不会去动已经结算 的那一笔——钱已经在喂养者账上,那种情况必须有人看过再说。 通道接通之前,客服可以在管理端手工标记已托管,必须写明钱怎么收的,进审计日志。 另外补上三件方案里写了但代码没做的事:打卡必须按到达、喂食、离开的顺序, 喂食离到达太近视为摆拍;地址新增紧急联系人与常去医院,随门牌一起只发给 被选中的喂养者;任务结束七天后由后台任务抹掉地址明文,只留城市与街道。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
97351777ec
commit
9345805133
@@ -193,11 +193,10 @@ func (a *App) payOrder(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
var userID, planID int64
|
||||
var userID, productID int64
|
||||
var amountCent int
|
||||
var orderNo string
|
||||
var status string
|
||||
err = tx.QueryRowContext(r.Context(), `SELECT user_id,product_id,amount_cent,order_no,status FROM orders WHERE id=? AND user_id=? AND deleted_at IS NULL FOR UPDATE`, id, current(r).ID).Scan(&userID, &planID, &amountCent, &orderNo, &status)
|
||||
var orderNo, productType, status string
|
||||
err = tx.QueryRowContext(r.Context(), `SELECT user_id,product_type,product_id,amount_cent,order_no,status FROM orders WHERE id=? AND user_id=? AND deleted_at IS NULL FOR UPDATE`, id, current(r).ID).Scan(&userID, &productType, &productID, &amountCent, &orderNo, &status)
|
||||
if err != nil {
|
||||
fail(w, 404, 30001, "订单不存在")
|
||||
return
|
||||
@@ -210,13 +209,9 @@ func (a *App) payOrder(w http.ResponseWriter, r *http.Request) {
|
||||
fail(w, 400, 20001, "当前订单状态无法支付")
|
||||
return
|
||||
}
|
||||
var durationDays, level int
|
||||
if err = tx.QueryRowContext(r.Context(), `SELECT duration_days,level FROM membership_plans WHERE id=? AND status=1 AND deleted_at IS NULL`, planID).Scan(&durationDays, &level); err != nil {
|
||||
fail(w, 400, 20001, "会员套餐已下架")
|
||||
return
|
||||
}
|
||||
if _, err = tx.ExecContext(r.Context(), `UPDATE orders SET status='PAID',paid_at=NOW(3),paid_amount_cent=?,provider_order_no=?,payment_notified_at=NOW(3) WHERE id=?`, amountCent, "sandbox:"+orderNo, id); err == nil {
|
||||
err = grantOrderMembershipTx(r.Context(), tx, id, userID, planID, durationDays, level)
|
||||
// 一笔订单买到什么,沙箱和真实回调走同一段逻辑,免得两边跑偏。
|
||||
err = a.applyPaidOrderTx(r.Context(), tx, id, userID, productType, productID, amountCent)
|
||||
}
|
||||
if err != nil || tx.Commit() != nil {
|
||||
fail(w, 500, 50001, "支付入账失败")
|
||||
|
||||
Reference in New Issue
Block a user