fix: 修复平台自营资源(未分配代理)无法线下下单的问题
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 6m56s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 6m56s
offline 支付分支新增平台自营子场景判断: - 资源 shopID 为空时(未分配给任何代理商),使用零售价直接创建订单 - 资源 shopID 不为空时(属于代理商),走原有平台代购逻辑 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -398,25 +398,44 @@ func (s *Service) CreateAdminOrder(ctx context.Context, req *dto.CreateAdminOrde
|
|||||||
|
|
||||||
// 根据支付方式分别处理
|
// 根据支付方式分别处理
|
||||||
if req.PaymentMethod == model.PaymentMethodOffline {
|
if req.PaymentMethod == model.PaymentMethodOffline {
|
||||||
// ==== 场景 1:平台代购(offline)====
|
// ==== 场景 1:offline(线下支付)====
|
||||||
purchaseBuyerID, buyerCostPrice, purchasePaidAt, err := s.resolvePurchaseOnBehalfInfo(ctx, validationResult)
|
isPlatformOwned := resourceShopID == nil || *resourceShopID == 0
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
orderBuyerType = model.BuyerTypeAgent
|
|
||||||
orderBuyerID = purchaseBuyerID
|
|
||||||
totalAmount = buyerCostPrice
|
|
||||||
paymentMethod = model.PaymentMethodOffline
|
|
||||||
paymentStatus = model.PaymentStatusPaid
|
|
||||||
paidAt = purchasePaidAt
|
|
||||||
isPurchaseOnBehalf = true
|
|
||||||
sellerCostPrice = buyerCostPrice
|
|
||||||
|
|
||||||
// 设置操作者信息(平台代购)
|
if isPlatformOwned {
|
||||||
operatorID = nil
|
// ==== 子场景 1.1:平台自营(资源未分配给代理商)====
|
||||||
operatorType = constants.OwnerTypePlatform
|
// 平台直接销售给终端用户,无代理商参与,使用零售价,无需查询分配配置
|
||||||
purchaseRole = model.PurchaseRolePurchasedByPlatform
|
orderBuyerType = model.BuyerTypePersonal
|
||||||
actualPaidAmount = nil
|
orderBuyerID = 0
|
||||||
|
paymentMethod = model.PaymentMethodOffline
|
||||||
|
paymentStatus = model.PaymentStatusPaid
|
||||||
|
paidAt = &now
|
||||||
|
isPurchaseOnBehalf = false
|
||||||
|
sellerCostPrice = 0
|
||||||
|
operatorID = nil
|
||||||
|
operatorType = constants.OwnerTypePlatform
|
||||||
|
purchaseRole = model.PurchaseRoleSelfPurchase
|
||||||
|
actualPaidAmount = nil
|
||||||
|
} else {
|
||||||
|
// ==== 子场景 1.2:平台代购(资源属于代理商,平台代为购买)====
|
||||||
|
purchaseBuyerID, buyerCostPrice, purchasePaidAt, err := s.resolvePurchaseOnBehalfInfo(ctx, validationResult)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
orderBuyerType = model.BuyerTypeAgent
|
||||||
|
orderBuyerID = purchaseBuyerID
|
||||||
|
totalAmount = buyerCostPrice
|
||||||
|
paymentMethod = model.PaymentMethodOffline
|
||||||
|
paymentStatus = model.PaymentStatusPaid
|
||||||
|
paidAt = purchasePaidAt
|
||||||
|
isPurchaseOnBehalf = true
|
||||||
|
sellerCostPrice = buyerCostPrice
|
||||||
|
|
||||||
|
// 设置操作者信息(平台代购)
|
||||||
|
operatorID = nil
|
||||||
|
operatorType = constants.OwnerTypePlatform
|
||||||
|
purchaseRole = model.PurchaseRolePurchasedByPlatform
|
||||||
|
actualPaidAmount = nil
|
||||||
|
}
|
||||||
|
|
||||||
} else if req.PaymentMethod == model.PaymentMethodWallet {
|
} else if req.PaymentMethod == model.PaymentMethodWallet {
|
||||||
// ==== 场景 2:代理钱包支付(wallet)====
|
// ==== 场景 2:代理钱包支付(wallet)====
|
||||||
|
|||||||
Reference in New Issue
Block a user