订单相关以及佣金相关修复
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m57s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m57s
This commit is contained in:
@@ -192,7 +192,7 @@ func (h *AutoPurchaseHandler) ProcessTask(ctx context.Context, task *asynq.Task)
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
order, orderItems, buildErr := h.buildOrderAndItems(rechargeOrder, packages, totalAmount, seriesID, sellerCostPrice, now)
|
||||
order, orderItems, buildErr := h.buildOrderAndItems(ctx, rechargeOrder, packages, totalAmount, seriesID, sellerCostPrice, now)
|
||||
if buildErr != nil {
|
||||
return buildErr
|
||||
}
|
||||
@@ -352,6 +352,7 @@ func (h *AutoPurchaseHandler) loadPackages(ctx context.Context, packageIDs []uin
|
||||
}
|
||||
|
||||
func (h *AutoPurchaseHandler) buildOrderAndItems(
|
||||
ctx context.Context,
|
||||
rechargeOrder *model.RechargeOrder,
|
||||
packages []*model.Package,
|
||||
totalAmount int64,
|
||||
@@ -376,6 +377,7 @@ func (h *AutoPurchaseHandler) buildOrderAndItems(
|
||||
}
|
||||
|
||||
paidAmount := totalAmount
|
||||
operatorAccountID, operatorAccountName := h.buildPersonalCustomerOperatorSnapshot(ctx, rechargeOrder.UserID)
|
||||
order := &model.Order{
|
||||
BaseModel: model.BaseModel{
|
||||
Creator: rechargeOrder.UserID,
|
||||
@@ -396,6 +398,9 @@ func (h *AutoPurchaseHandler) buildOrderAndItems(
|
||||
Source: constants.OrderSourceClient,
|
||||
Generation: generation,
|
||||
ActualPaidAmount: &paidAmount,
|
||||
OperatorAccountID: operatorAccountID,
|
||||
OperatorAccountType: model.OperatorAccountTypePersonalCustomer,
|
||||
OperatorAccountName: operatorAccountName,
|
||||
SellerShopID: sellerShopID,
|
||||
SeriesID: seriesID,
|
||||
SellerCostPrice: sellerCostPrice,
|
||||
@@ -422,6 +427,21 @@ func (h *AutoPurchaseHandler) buildOrderAndItems(
|
||||
return order, items, nil
|
||||
}
|
||||
|
||||
func (h *AutoPurchaseHandler) buildPersonalCustomerOperatorSnapshot(ctx context.Context, customerID uint) (*uint, string) {
|
||||
if customerID == 0 {
|
||||
return nil, ""
|
||||
}
|
||||
|
||||
var customer model.PersonalCustomer
|
||||
if err := h.db.WithContext(ctx).Where("id = ?", customerID).First(&customer).Error; err != nil {
|
||||
id := customerID
|
||||
return &id, ""
|
||||
}
|
||||
|
||||
id := customerID
|
||||
return &id, customer.Nickname
|
||||
}
|
||||
|
||||
func (h *AutoPurchaseHandler) activatePackages(
|
||||
ctx context.Context,
|
||||
tx *gorm.DB,
|
||||
@@ -596,25 +616,25 @@ func (h *AutoPurchaseHandler) activateAddonPackage(
|
||||
Creator: order.Creator,
|
||||
Updater: order.Creator,
|
||||
},
|
||||
OrderID: order.ID,
|
||||
OrderNo: order.OrderNo,
|
||||
PackageID: pkg.ID,
|
||||
PackageName: pkg.PackageName,
|
||||
UsageType: order.OrderType,
|
||||
DataLimitMB: pkg.RealDataMB,
|
||||
OrderID: order.ID,
|
||||
OrderNo: order.OrderNo,
|
||||
PackageID: pkg.ID,
|
||||
PackageName: pkg.PackageName,
|
||||
UsageType: order.OrderType,
|
||||
DataLimitMB: pkg.RealDataMB,
|
||||
VirtualTotalMBSnapshot: virtualTotalMBSnapshot,
|
||||
DisplayGainRatioSnapshot: displayGainRatioSnapshot,
|
||||
EnableVirtualDataSnapshot: enableVirtualDataSnapshot,
|
||||
Status: constants.PackageUsageStatusActive,
|
||||
Priority: priority,
|
||||
MasterUsageID: &mainPackage.ID,
|
||||
ActivatedAt: &now,
|
||||
ExpiresAt: expiresAt,
|
||||
DataResetCycle: pkg.DataResetCycle,
|
||||
Generation: order.Generation,
|
||||
PaidAmount: order.ActualPaidAmount,
|
||||
PackagePriceConfigStatus: pkg.PriceConfigStatus,
|
||||
PackageIsGift: pkg.IsGift,
|
||||
Status: constants.PackageUsageStatusActive,
|
||||
Priority: priority,
|
||||
MasterUsageID: &mainPackage.ID,
|
||||
ActivatedAt: &now,
|
||||
ExpiresAt: expiresAt,
|
||||
DataResetCycle: pkg.DataResetCycle,
|
||||
Generation: order.Generation,
|
||||
PaidAmount: order.ActualPaidAmount,
|
||||
PackagePriceConfigStatus: pkg.PriceConfigStatus,
|
||||
PackageIsGift: pkg.IsGift,
|
||||
}
|
||||
|
||||
if carrierType == constants.AssetWalletResourceTypeIotCard {
|
||||
|
||||
Reference in New Issue
Block a user