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
+14
No files matched your search
@@ -57,6 +57,8 @@ func (h *CuOrderHandler) GetPackages(c *gin.Context) {
|
|||||||
"name": pkg.Name,
|
"name": pkg.Name,
|
||||||
"type": pkg.Type,
|
"type": pkg.Type,
|
||||||
"price": pkg.Price,
|
"price": pkg.Price,
|
||||||
|
"display_price": pkg.DisplayPrice,
|
||||||
|
"price_description": pkg.PriceDescription,
|
||||||
"max_devices": pkg.MaxDevices,
|
"max_devices": pkg.MaxDevices,
|
||||||
"description": pkg.Description,
|
"description": pkg.Description,
|
||||||
"features": pkg.Features,
|
"features": pkg.Features,
|
||||||
|
|||||||
@@ -143,6 +143,8 @@ type CuPackageResponse struct {
|
|||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Price float64 `json:"price"`
|
Price float64 `json:"price"`
|
||||||
|
DisplayPrice string `json:"display_price"`
|
||||||
|
PriceDescription string `json:"price_description"`
|
||||||
MaxDevices int `json:"max_devices"` // 从features中解析
|
MaxDevices int `json:"max_devices"` // 从features中解析
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Features string `json:"features"`
|
Features string `json:"features"`
|
||||||
|
|||||||
@@ -207,11 +207,21 @@ 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,
|
||||||
|
DisplayPrice: displayPrice,
|
||||||
|
PriceDescription: pkg.PriceDescription,
|
||||||
MaxDevices: maxDevices,
|
MaxDevices: maxDevices,
|
||||||
Description: pkg.Description,
|
Description: pkg.Description,
|
||||||
Features: pkg.Features,
|
Features: pkg.Features,
|
||||||
|
|||||||
Reference in new issue
Block a user