feat: add limit owner
This commit is contained in:
@@ -405,6 +405,9 @@ func ProductAnalyticsPerParentCategoryModelToContract(resp *models.ProductAnalyt
|
||||
data = append(data, contract.ProductAnalyticsPerParentCategoryData{
|
||||
ParentCategoryID: item.ParentCategoryID,
|
||||
ParentCategoryName: item.ParentCategoryName,
|
||||
OwnerFeePercent: item.OwnerFeePercent,
|
||||
TopProduct: parentCategoryTopProductModelToContract(item.TopProduct),
|
||||
SDL: item.SDL,
|
||||
TotalRevenue: item.TotalRevenue,
|
||||
TotalQuantity: item.TotalQuantity,
|
||||
CategoryCount: item.CategoryCount,
|
||||
@@ -427,6 +430,19 @@ func ProductAnalyticsPerParentCategoryModelToContract(resp *models.ProductAnalyt
|
||||
}
|
||||
}
|
||||
|
||||
// parentCategoryTopProductModelToContract converts the top product of a parent category to contract
|
||||
func parentCategoryTopProductModelToContract(product *models.ParentCategoryTopProduct) *contract.ParentCategoryTopProduct {
|
||||
if product == nil {
|
||||
return nil
|
||||
}
|
||||
return &contract.ParentCategoryTopProduct{
|
||||
ProductID: product.ProductID,
|
||||
ProductName: product.ProductName,
|
||||
QuantitySold: product.QuantitySold,
|
||||
Revenue: product.Revenue,
|
||||
}
|
||||
}
|
||||
|
||||
// budgetPeriodModelToContract converts one budget period to contract
|
||||
func budgetPeriodModelToContract(period models.BudgetPeriod) contract.BudgetPeriod {
|
||||
return contract.BudgetPeriod{
|
||||
@@ -435,7 +451,7 @@ func budgetPeriodModelToContract(period models.BudgetPeriod) contract.BudgetPeri
|
||||
Revenue: period.Revenue,
|
||||
OrderCount: period.OrderCount,
|
||||
LimitPurchase: period.LimitPurchase,
|
||||
LimitOwner: period.LimitOwner,
|
||||
SDL: period.SDL,
|
||||
LimitTeam: period.LimitTeam,
|
||||
}
|
||||
}
|
||||
@@ -548,6 +564,9 @@ func ParentCategoryAnalyticsDetailModelToContract(resp *models.ParentCategoryAna
|
||||
ParentCategoryID: resp.ParentCategoryID,
|
||||
ParentCategoryName: resp.ParentCategoryName,
|
||||
Summary: contract.ParentCategoryAnalyticsDetailSummary{
|
||||
OwnerFeePercent: resp.Summary.OwnerFeePercent,
|
||||
TopProduct: parentCategoryTopProductModelToContract(resp.Summary.TopProduct),
|
||||
SDL: resp.Summary.SDL,
|
||||
TotalRevenue: resp.Summary.TotalRevenue,
|
||||
TotalQuantity: resp.Summary.TotalQuantity,
|
||||
CategoryCount: resp.Summary.CategoryCount,
|
||||
|
||||
@@ -12,25 +12,30 @@ func CreateCategoryRequestToModel(apctx *appcontext.ContextInfo, req *contract.C
|
||||
order = *req.Order
|
||||
}
|
||||
return &models.CreateCategoryRequest{
|
||||
OrganizationID: apctx.OrganizationID,
|
||||
OutletID: req.OutletID,
|
||||
ParentID: req.ParentID,
|
||||
Name: req.Name,
|
||||
Description: req.Description,
|
||||
ImageURL: nil,
|
||||
Order: order,
|
||||
OrganizationID: apctx.OrganizationID,
|
||||
OutletID: req.OutletID,
|
||||
ParentID: req.ParentID,
|
||||
Name: req.Name,
|
||||
Description: req.Description,
|
||||
ImageURL: nil,
|
||||
Order: order,
|
||||
OwnerFeePercent: req.OwnerFeePercent,
|
||||
}
|
||||
}
|
||||
|
||||
func UpdateCategoryRequestToModel(req *contract.UpdateCategoryRequest) *models.UpdateCategoryRequest {
|
||||
return &models.UpdateCategoryRequest{
|
||||
Name: req.Name,
|
||||
Description: req.Description,
|
||||
ImageURL: nil,
|
||||
OutletID: req.OutletID,
|
||||
ParentID: req.ParentID,
|
||||
Order: req.Order,
|
||||
IsActive: nil,
|
||||
Name: req.Name,
|
||||
Description: req.Description,
|
||||
ImageURL: nil,
|
||||
OutletID: req.OutletID,
|
||||
ParentID: req.ParentID,
|
||||
Order: req.Order,
|
||||
OwnerFeePercent: req.OwnerFeePercent,
|
||||
IsActive: nil,
|
||||
|
||||
ClearParentID: req.ClearParentID,
|
||||
ClearOwnerFeePercent: req.ClearOwnerFeePercent,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,18 +45,19 @@ func CategoryModelResponseToResponse(cat *models.CategoryResponse) *contract.Cat
|
||||
}
|
||||
|
||||
return &contract.CategoryResponse{
|
||||
ID: cat.ID,
|
||||
OrganizationID: cat.OrganizationID,
|
||||
OutletID: cat.OutletID,
|
||||
ParentID: cat.ParentID,
|
||||
ParentName: cat.ParentName,
|
||||
Name: cat.Name,
|
||||
Description: cat.Description,
|
||||
BusinessType: "restaurant",
|
||||
Order: cat.Order,
|
||||
Metadata: map[string]interface{}{},
|
||||
CreatedAt: cat.CreatedAt,
|
||||
UpdatedAt: cat.UpdatedAt,
|
||||
ID: cat.ID,
|
||||
OrganizationID: cat.OrganizationID,
|
||||
OutletID: cat.OutletID,
|
||||
ParentID: cat.ParentID,
|
||||
ParentName: cat.ParentName,
|
||||
Name: cat.Name,
|
||||
Description: cat.Description,
|
||||
BusinessType: "restaurant",
|
||||
Order: cat.Order,
|
||||
OwnerFeePercent: cat.OwnerFeePercent,
|
||||
Metadata: map[string]interface{}{},
|
||||
CreatedAt: cat.CreatedAt,
|
||||
UpdatedAt: cat.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user