商品已完成优化
This commit is contained in:
@@ -63,6 +63,13 @@ func archiveAssets(listing *model.RentalListing, account *model.GameAccount) {
|
||||
account.Status = accountStatusOffline
|
||||
}
|
||||
|
||||
func completeAssets(listing *model.RentalListing, account *model.GameAccount) {
|
||||
listing.Status = listingStatusCompleted
|
||||
listing.InTransaction = false
|
||||
listing.PublishedAt = nil
|
||||
account.Status = accountStatusOffline
|
||||
}
|
||||
|
||||
func markAssetsAbnormal(listing *model.RentalListing, account *model.GameAccount) {
|
||||
listing.Status = listingStatusAbnormal
|
||||
listing.InTransaction = false
|
||||
|
||||
@@ -21,7 +21,7 @@ func (r *Repository) finalizeCheckout(tx *gorm.DB, order *model.RentalOrder, che
|
||||
order.SettlementStatus = settlementStatusSettled
|
||||
order.SettledAt = &now
|
||||
order.OwnerSettledAt = &now
|
||||
archiveAssets(listing, account)
|
||||
completeAssets(listing, account)
|
||||
|
||||
settlement := buildCheckoutSettlement(*order, checkout)
|
||||
if err := appendCheckoutOwnerIncome(tx, order, settlement); err != nil {
|
||||
|
||||
@@ -47,6 +47,7 @@ const (
|
||||
listingStatusPublished = "published"
|
||||
listingStatusRented = "rented"
|
||||
listingStatusOffline = "offline"
|
||||
listingStatusCompleted = "completed"
|
||||
listingStatusAbnormal = "abnormal"
|
||||
|
||||
accountStatusPublished = "published"
|
||||
|
||||
@@ -165,6 +165,31 @@ func TestArchiveAssetsMovesListingOffline(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCompleteAssetsMovesListingCompleted(t *testing.T) {
|
||||
now := time.Now()
|
||||
listing := model.RentalListing{
|
||||
Status: listingStatusRented,
|
||||
InTransaction: true,
|
||||
PublishedAt: &now,
|
||||
}
|
||||
account := model.GameAccount{Status: accountStatusRented}
|
||||
|
||||
completeAssets(&listing, &account)
|
||||
|
||||
if listing.Status != listingStatusCompleted {
|
||||
t.Fatalf("listing.Status = %q, want %q", listing.Status, listingStatusCompleted)
|
||||
}
|
||||
if listing.InTransaction {
|
||||
t.Fatal("listing.InTransaction = true, want false")
|
||||
}
|
||||
if listing.PublishedAt != nil {
|
||||
t.Fatal("listing.PublishedAt is not nil")
|
||||
}
|
||||
if account.Status != accountStatusOffline {
|
||||
t.Fatalf("account.Status = %q, want %q", account.Status, accountStatusOffline)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewOrderNoUsesShanghaiTimeWhenLocalIsUTC(t *testing.T) {
|
||||
oldLocal := time.Local
|
||||
time.Local = time.UTC
|
||||
|
||||
Reference in New Issue
Block a user