| | |
| | | |
| | | import ( |
| | | "aps_crm/conf" |
| | | "aps_crm/model" |
| | | "aps_crm/model/request" |
| | | "aps_crm/model/response" |
| | | "aps_crm/pkg/contextx" |
| | |
| | | "aps_crm/proto/product" |
| | | "fmt" |
| | | "github.com/gin-gonic/gin" |
| | | "github.com/shopspring/decimal" |
| | | "github.com/spf13/cast" |
| | | "google.golang.org/grpc" |
| | | "google.golang.org/grpc/credentials/insecure" |
| | |
| | | ProductNumber: params.ProductNumber, |
| | | ProductName: params.ProductName, |
| | | }) |
| | | rawProductList := getProductListResponse.List |
| | | productList := make([]model.Product, len(rawProductList)) |
| | | |
| | | for k, v := range rawProductList { |
| | | productList[k].Number = v.Number |
| | | productList[k].Name = v.Name |
| | | productList[k].Price = decimal.NewFromFloat(v.SalePrice).Round(2) |
| | | productList[k].Amount = decimal.NewFromFloat(1) |
| | | productList[k].Total = productList[k].Price.Mul(productList[k].Amount).Round(2) |
| | | } |
| | | |
| | | if err != nil { |
| | | logx.Errorf("GetProductList err: %v", err.Error()) |
| | | ctx.FailWithMsg(ecode.UnknownErr, "内部错误") |
| | |
| | | return |
| | | } |
| | | ctx.OkWithDetailed(response.ListResponse{ |
| | | Data: getProductListResponse.List, |
| | | Data: productList, |
| | | Count: getProductListResponse.Total, |
| | | }) |
| | | } |