feat: Implement customer order management, including package listing, price calculation, and order creation.
This commit is contained in:
1 parent
5fdbe4b023
commit
b903af8402
3 files changed
+38
-24
No files matched your search
@@ -53,14 +53,16 @@ func (h *CuOrderHandler) GetPackages(c *gin.Context) {
|
|||||||
result := make([]map[string]interface{}, len(packages))
|
result := make([]map[string]interface{}, len(packages))
|
||||||
for i, pkg := range packages {
|
for i, pkg := range packages {
|
||||||
result[i] = map[string]interface{}{
|
result[i] = map[string]interface{}{
|
||||||
"id": pkg.ID,
|
"id": pkg.ID,
|
||||||
"name": pkg.Name,
|
"name": pkg.Name,
|
||||||
"type": pkg.Type,
|
"type": pkg.Type,
|
||||||
"price": pkg.Price,
|
"price": pkg.Price,
|
||||||
"max_devices": pkg.MaxDevices,
|
"display_price": pkg.DisplayPrice,
|
||||||
"description": pkg.Description,
|
"price_description": pkg.PriceDescription,
|
||||||
"features": pkg.Features,
|
"max_devices": pkg.MaxDevices,
|
||||||
"details": pkg.Details,
|
"description": pkg.Description,
|
||||||
|
"features": pkg.Features,
|
||||||
|
"details": pkg.Details,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -139,12 +139,14 @@ type PackageListResponse struct {
|
|||||||
|
|
||||||
// CuPackageResponse 用户端套餐响应(兼容原有结构)
|
// CuPackageResponse 用户端套餐响应(兼容原有结构)
|
||||||
type CuPackageResponse struct {
|
type CuPackageResponse struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Price float64 `json:"price"`
|
Price float64 `json:"price"`
|
||||||
MaxDevices int `json:"max_devices"` // 从features中解析
|
DisplayPrice string `json:"display_price"`
|
||||||
Description string `json:"description"`
|
PriceDescription string `json:"price_description"`
|
||||||
Features string `json:"features"`
|
MaxDevices int `json:"max_devices"` // 从features中解析
|
||||||
Details string `json:"details"`
|
Description string `json:"description"`
|
||||||
|
Features string `json:"features"`
|
||||||
|
Details string `json:"details"`
|
||||||
}
|
}
|
||||||
@@ -207,14 +207,24 @@ func (s *packageService) toCuPackageResponse(pkg *models.Package) *models.CuPack
|
|||||||
details += fmt.Sprintf("%d个许可", maxDevices)
|
details += fmt.Sprintf("%d个许可", maxDevices)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 计算 display_price
|
||||||
|
displayPrice := ""
|
||||||
|
if pkg.Price != 0 {
|
||||||
|
displayPrice = fmt.Sprintf("¥%g", pkg.Price)
|
||||||
|
} else {
|
||||||
|
displayPrice = pkg.PriceDescription
|
||||||
|
}
|
||||||
|
|
||||||
return &models.CuPackageResponse{
|
return &models.CuPackageResponse{
|
||||||
ID: pkg.ID,
|
ID: pkg.ID,
|
||||||
Name: pkg.Name,
|
Name: pkg.Name,
|
||||||
Type: pkg.Type,
|
Type: pkg.Type,
|
||||||
Price: pkg.Price,
|
Price: pkg.Price,
|
||||||
MaxDevices: maxDevices,
|
DisplayPrice: displayPrice,
|
||||||
Description: pkg.Description,
|
PriceDescription: pkg.PriceDescription,
|
||||||
Features: pkg.Features,
|
MaxDevices: maxDevices,
|
||||||
Details: details,
|
Description: pkg.Description,
|
||||||
|
Features: pkg.Features,
|
||||||
|
Details: details,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user