贯通商品编号全流程
This commit is contained in:
@@ -12,6 +12,7 @@ type OrderDTO struct {
|
||||
ID uint64 `json:"id"`
|
||||
OrderNo string `json:"order_no"`
|
||||
ListingID uint64 `json:"listing_id"`
|
||||
ListingNo string `json:"listing_no"`
|
||||
AccountID uint64 `json:"account_id"`
|
||||
OwnerID uint64 `json:"owner_id"`
|
||||
RenterID uint64 `json:"renter_id"`
|
||||
|
||||
@@ -163,7 +163,7 @@ func (r *Repository) Create(renterID uint64, req CreateRequest) (*OrderDTO, erro
|
||||
if err := tx.Clauses(clause.Locking{Strength: "UPDATE"}).First(&account, listing.AccountID).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
snapshot, err := makeAccountSnapshot(account)
|
||||
snapshot, err := makeAccountSnapshot(account, listing)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1374,13 +1374,15 @@ func (r *Repository) findCheckout(id uint64) (*model.OrderCheckout, error) {
|
||||
|
||||
func (r *Repository) baseQuery() *gorm.DB {
|
||||
return r.db.Table("rental_orders AS o").
|
||||
Select("o.*, a.title, a.server_region, a.login_platform").
|
||||
Select("o.*, l.listing_no, a.title, a.server_region, a.login_platform").
|
||||
Joins("JOIN rental_listings AS l ON l.id = o.listing_id").
|
||||
Joins("JOIN game_accounts AS a ON a.id = o.account_id")
|
||||
}
|
||||
|
||||
func (r *Repository) adminQuery() *gorm.DB {
|
||||
return r.db.Table("rental_orders AS o").
|
||||
Select("o.*, a.title, a.server_region, a.login_platform, owner.phone AS owner_phone, renter.phone AS renter_phone").
|
||||
Select("o.*, l.listing_no, a.title, a.server_region, a.login_platform, owner.phone AS owner_phone, renter.phone AS renter_phone").
|
||||
Joins("JOIN rental_listings AS l ON l.id = o.listing_id").
|
||||
Joins("JOIN game_accounts AS a ON a.id = o.account_id").
|
||||
Joins("JOIN users AS owner ON owner.id = o.owner_id").
|
||||
Joins("JOIN users AS renter ON renter.id = o.renter_id")
|
||||
@@ -1389,6 +1391,7 @@ func (r *Repository) adminQuery() *gorm.DB {
|
||||
type orderRow struct {
|
||||
model.RentalOrder
|
||||
Title string
|
||||
ListingNo string
|
||||
ServerRegion string
|
||||
LoginPlatform string
|
||||
OwnerPhone string
|
||||
@@ -1405,6 +1408,7 @@ func (row orderRow) toAdminDTO() OrderDTO {
|
||||
ID: row.ID,
|
||||
OrderNo: row.OrderNo,
|
||||
ListingID: row.ListingID,
|
||||
ListingNo: row.ListingNo,
|
||||
AccountID: row.AccountID,
|
||||
OwnerID: row.OwnerID,
|
||||
RenterID: row.RenterID,
|
||||
@@ -1607,8 +1611,10 @@ func sanitizeOrderSnapshot(snapshot *datatypes.JSON, role string) {
|
||||
*snapshot = datatypes.JSON(raw)
|
||||
}
|
||||
|
||||
func makeAccountSnapshot(account model.GameAccount) (datatypes.JSON, error) {
|
||||
func makeAccountSnapshot(account model.GameAccount, listing model.RentalListing) (datatypes.JSON, error) {
|
||||
payload := map[string]any{
|
||||
"listing_id": listing.ID,
|
||||
"listing_no": listing.ListingNo,
|
||||
"account_id": account.ID,
|
||||
"title": account.Title,
|
||||
"game_name": account.GameName,
|
||||
|
||||
Reference in New Issue
Block a user