feat(tenant): 增加双站共享货架与跨站下单
This commit is contained in:
@@ -22,6 +22,7 @@ func (r *Repository) Create(ctx context.Context, ownerID uint64, req CreateReque
|
||||
if err := r.ensureCreateCooldown(tx, ownerID, publishCooldown, now); err != nil {
|
||||
return err
|
||||
}
|
||||
sourceTenantID := userTenantID(ctx, tx, ownerID)
|
||||
|
||||
var site model.DistributionSite
|
||||
var siteID *uint64
|
||||
@@ -53,6 +54,7 @@ func (r *Repository) Create(ctx context.Context, ownerID uint64, req CreateReque
|
||||
listingStatus, reviewStatus, publishedAt := initialPublishState(reviewRequired)
|
||||
|
||||
account := model.GameAccount{
|
||||
SourceTenantID: sourceTenantID,
|
||||
OwnerID: ownerID,
|
||||
GameName: "delta_force",
|
||||
ServerRegion: req.ServerRegion,
|
||||
@@ -71,6 +73,7 @@ func (r *Repository) Create(ctx context.Context, ownerID uint64, req CreateReque
|
||||
|
||||
priceCent := normalizedListingPriceCent(req)
|
||||
listing := model.RentalListing{
|
||||
SourceTenantID: sourceTenantID,
|
||||
ListingNo: listingNo,
|
||||
AccountID: account.ID,
|
||||
OwnerID: ownerID,
|
||||
@@ -193,6 +196,7 @@ func (r *Repository) CreateFromExternalUpload(ctx context.Context, upload extern
|
||||
return err
|
||||
}
|
||||
account := model.GameAccount{
|
||||
SourceTenantID: owner.TenantID,
|
||||
OwnerID: owner.ID,
|
||||
GameName: "delta_force",
|
||||
ServerRegion: req.ServerRegion,
|
||||
@@ -210,6 +214,7 @@ func (r *Repository) CreateFromExternalUpload(ctx context.Context, upload extern
|
||||
}
|
||||
priceCent := normalizedListingPriceCent(req)
|
||||
listing := model.RentalListing{
|
||||
SourceTenantID: owner.TenantID,
|
||||
ListingNo: listingNo,
|
||||
AccountID: account.ID,
|
||||
OwnerID: owner.ID,
|
||||
@@ -385,7 +390,12 @@ func (r *Repository) ensureUploadOwnerUser(tx *gorm.DB, admin *model.AdminUser)
|
||||
nickname = admin.Username
|
||||
}
|
||||
var user model.User
|
||||
err := tx.Where("phone = ?", phone).First(&user).Error
|
||||
tenantID := userTenantID(tx.Statement.Context, tx, 0)
|
||||
userQuery := tx.Where("phone = ?", phone)
|
||||
if tenantID > 0 {
|
||||
userQuery = userQuery.Where("tenant_id = ?", tenantID)
|
||||
}
|
||||
err := userQuery.First(&user).Error
|
||||
if err == nil {
|
||||
updates := map[string]any{
|
||||
"nickname": nickname,
|
||||
@@ -404,6 +414,7 @@ func (r *Repository) ensureUploadOwnerUser(tx *gorm.DB, admin *model.AdminUser)
|
||||
return nil, err
|
||||
}
|
||||
user = model.User{
|
||||
TenantID: tenantID,
|
||||
Phone: phone,
|
||||
Nickname: nickname,
|
||||
RealnameStatus: "verified",
|
||||
|
||||
Reference in New Issue
Block a user