修复完成订单自动回显
This commit is contained in:
@@ -973,9 +973,7 @@ func (r *Repository) finalizeCheckout(tx *gorm.DB, order *model.RentalOrder, che
|
|||||||
order.SettlementStatus = "settled"
|
order.SettlementStatus = "settled"
|
||||||
order.SettledAt = &now
|
order.SettledAt = &now
|
||||||
order.OwnerSettledAt = &now
|
order.OwnerSettledAt = &now
|
||||||
listing.Status = "published"
|
archiveListingAfterCheckout(&listing, &account)
|
||||||
listing.InTransaction = false
|
|
||||||
account.Status = "published"
|
|
||||||
orderID := order.ID
|
orderID := order.ID
|
||||||
settlement := buildCheckoutSettlement(*order, checkout)
|
settlement := buildCheckoutSettlement(*order, checkout)
|
||||||
|
|
||||||
@@ -1062,6 +1060,14 @@ func (r *Repository) finalizeCheckout(tx *gorm.DB, order *model.RentalOrder, che
|
|||||||
return refund, nil
|
return refund, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 完成后的账号先下架,避免已完成订单对应的账号重新出现在公开首页。
|
||||||
|
func archiveListingAfterCheckout(listing *model.RentalListing, account *model.GameAccount) {
|
||||||
|
listing.Status = "offline"
|
||||||
|
listing.InTransaction = false
|
||||||
|
listing.PublishedAt = nil
|
||||||
|
account.Status = "offline"
|
||||||
|
}
|
||||||
|
|
||||||
func (r *Repository) prepareRefund(order *model.RentalOrder, amountCent int64, bizType string, remark string) (*refundAction, error) {
|
func (r *Repository) prepareRefund(order *model.RentalOrder, amountCent int64, bizType string, remark string) (*refundAction, error) {
|
||||||
if amountCent <= 0 {
|
if amountCent <= 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package order
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"hfb_sys/backend/internal/model"
|
"hfb_sys/backend/internal/model"
|
||||||
|
|
||||||
@@ -112,3 +113,30 @@ func TestCalculateCheckoutSettlementAddsDepositCompensation(t *testing.T) {
|
|||||||
t.Fatalf("RenterRefund = %.2f, want 120.00", settlement.RenterRefund)
|
t.Fatalf("RenterRefund = %.2f, want 120.00", settlement.RenterRefund)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestArchiveListingAfterCheckoutMovesListingOffline(t *testing.T) {
|
||||||
|
now := time.Now()
|
||||||
|
listing := model.RentalListing{
|
||||||
|
Status: "published",
|
||||||
|
InTransaction: true,
|
||||||
|
PublishedAt: &now,
|
||||||
|
}
|
||||||
|
account := model.GameAccount{
|
||||||
|
Status: "published",
|
||||||
|
}
|
||||||
|
|
||||||
|
archiveListingAfterCheckout(&listing, &account)
|
||||||
|
|
||||||
|
if listing.Status != "offline" {
|
||||||
|
t.Fatalf("listing status = %q, want offline", listing.Status)
|
||||||
|
}
|
||||||
|
if listing.InTransaction {
|
||||||
|
t.Fatal("listing in_transaction should be false")
|
||||||
|
}
|
||||||
|
if listing.PublishedAt != nil {
|
||||||
|
t.Fatal("listing published_at should be nil")
|
||||||
|
}
|
||||||
|
if account.Status != "offline" {
|
||||||
|
t.Fatalf("account status = %q, want offline", account.Status)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
- 号主修改结账后,订单状态变为 `pending_checkout_accept`,交接状态变为 `pending_renter_checkout`,必须等待租客确认修正。
|
- 号主修改结账后,订单状态变为 `pending_checkout_accept`,交接状态变为 `pending_renter_checkout`,必须等待租客确认修正。
|
||||||
- 待号主确认结账或待租客确认修正时,任一方都可以发起结账争议。
|
- 待号主确认结账或待租客确认修正时,任一方都可以发起结账争议。
|
||||||
- 结账争议后订单状态变为 `checkout_disputing`,交接状态变为 `checkout_disputed`,由客服仲裁。
|
- 结账争议后订单状态变为 `checkout_disputing`,交接状态变为 `checkout_disputed`,由客服仲裁。
|
||||||
- 订单完成后,账号和发布状态恢复为 `published`。
|
- 订单完成后,账号和发布状态改为 `offline`,不会自动回到公开首页;如需再次出租,需号主手动重新上架。
|
||||||
- 当前会生成开发态模拟钱包流水,不代表真实支付或提现。
|
- 当前会生成开发态模拟钱包流水,不代表真实支付或提现。
|
||||||
|
|
||||||
## 开发态超时任务
|
## 开发态超时任务
|
||||||
|
|||||||
Reference in New Issue
Block a user