代喂改走真实订单,并补上打卡纪律与地址明文清除
支付原来是个占位:调一下接口任务就算"已付"。现在任务和喂养者保证金都 走会员那套订单与支付网关,一笔订单买到什么由 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
@@ -183,10 +183,10 @@ func (a *App) settlePayment(ctx context.Context, notice paymentNotifyRequest, ra
|
||||
return tx.Commit()
|
||||
}
|
||||
|
||||
var orderID, userID, planID int64
|
||||
var orderID, userID, productID int64
|
||||
var amountCent int
|
||||
var status, channel string
|
||||
if err = tx.QueryRowContext(ctx, `SELECT id,user_id,product_id,amount_cent,status,channel FROM orders WHERE order_no=? AND deleted_at IS NULL FOR UPDATE`, notice.OrderNo).Scan(&orderID, &userID, &planID, &amountCent, &status, &channel); err != nil {
|
||||
var status, channel, productType string
|
||||
if err = tx.QueryRowContext(ctx, `SELECT id,user_id,product_type,product_id,amount_cent,status,channel FROM orders WHERE order_no=? AND deleted_at IS NULL FOR UPDATE`, notice.OrderNo).Scan(&orderID, &userID, &productType, &productID, &amountCent, &status, &channel); err != nil {
|
||||
return fmt.Errorf("order does not exist")
|
||||
}
|
||||
if channel != notice.Channel || amountCent != notice.AmountCent {
|
||||
@@ -202,10 +202,7 @@ func (a *App) settlePayment(ctx context.Context, notice paymentNotifyRequest, ra
|
||||
if _, err = tx.ExecContext(ctx, `UPDATE orders SET status='REFUNDED',payment_notified_at=NOW(3) WHERE id=?`, orderID); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err = tx.ExecContext(ctx, `UPDATE subscriptions SET status=0 WHERE user_id=? AND status=1 AND source IN (?,?)`, userID, fmt.Sprintf("order:%d", orderID), fmt.Sprintf("admin_order:%d", orderID)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = a.recomputeMembershipTx(ctx, tx, userID); err != nil {
|
||||
if err = a.revokePaidOrderTx(ctx, tx, orderID, userID, productType, productID, amountCent); err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.Commit()
|
||||
@@ -228,14 +225,10 @@ func (a *App) settlePayment(ctx context.Context, notice paymentNotifyRequest, ra
|
||||
return tx.Commit()
|
||||
}
|
||||
|
||||
var durationDays, level int
|
||||
if err = tx.QueryRowContext(ctx, `SELECT duration_days,level FROM membership_plans WHERE id=? AND deleted_at IS NULL`, planID).Scan(&durationDays, &level); err != nil {
|
||||
return fmt.Errorf("membership plan does not exist")
|
||||
}
|
||||
if _, err = tx.ExecContext(ctx, `UPDATE orders SET status='PAID',paid_at=NOW(3),paid_amount_cent=?,provider_order_no=?,payment_notified_at=NOW(3) WHERE id=?`, notice.AmountCent, notice.ProviderOrderNo, orderID); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = grantOrderMembershipTx(ctx, tx, orderID, userID, planID, durationDays, level); err != nil {
|
||||
if err = a.applyPaidOrderTx(ctx, tx, orderID, userID, productType, productID, notice.AmountCent); err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.Commit()
|
||||
|
||||
Reference in New Issue
Block a user