From 90ebefc0ce4306bdc96f34ea9503ca986a59bbe7 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期三, 31 一月 2024 14:12:00 +0800
Subject: [PATCH] 客户列表grpc接口
---
api/v1/product.go | 56 +++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 41 insertions(+), 15 deletions(-)
diff --git a/api/v1/product.go b/api/v1/product.go
index 9cca9e4..ee678df 100644
--- a/api/v1/product.go
+++ b/api/v1/product.go
@@ -55,6 +55,19 @@
return
}
+ if params.QuotationNumber != "" {
+ find, err := model.NewQuotationSearch(nil).SetNumber(params.QuotationNumber).Find()
+ if err != nil {
+ ctx.FailWithMsg(ecode.UnknownErr, "鎶ヤ环鍗曚俊鎭煡璇㈠け璐�")
+ return
+ }
+ products := find.Products
+ ctx.OkWithDetailed(response.ListResponse{
+ Data: products,
+ Count: int64(len(products)),
+ })
+ return
+ }
cli := product.NewProductServiceClient(grpc_init.CrmApsGrpcServiceConn)
getProductListResponse, err := cli.GetProductList(ctx.GetCtx(), &product.GetProductListRequest{
Page: cast.ToInt32(params.Page),
@@ -62,6 +75,16 @@
ProductNumber: params.ProductNumber,
ProductName: params.ProductName,
})
+ if err != nil {
+ logx.Errorf("grpc GetProductList err: %v", err.Error())
+ ctx.FailWithMsg(ecode.UnknownErr, "鍐呴儴閿欒")
+ return
+ }
+ if getProductListResponse.Code != 0 {
+ logx.Errorf("grpc GetProductList err: %v", err.Error())
+ ctx.FailWithMsg(ecode.UnknownErr, "鍐呴儴閿欒")
+ return
+ }
rawProductList := getProductListResponse.List
productList := make([]model.Product, len(rawProductList))
@@ -74,16 +97,6 @@
productList[k].Unit = v.Unit
}
- if err != nil {
- logx.Errorf("GetProductList err: %v", err.Error())
- ctx.FailWithMsg(ecode.UnknownErr, "鍐呴儴閿欒")
- return
- }
- if getProductListResponse.Code != 0 {
- logx.Errorf("GetProductList err: %v", err.Error())
- ctx.FailWithMsg(ecode.UnknownErr, "鍐呴儴閿欒")
- return
- }
ctx.OkWithDetailed(response.ListResponse{
Data: productList,
Count: getProductListResponse.Total,
@@ -109,12 +122,12 @@
getProductInfoResponse, err := cli.GetProductInfo(ctx.GetCtx(), &product.GetProductInfoRequest{ProductId: productId})
if err != nil {
- logx.Errorf("GetProductInfo err: %v", err.Error())
+ logx.Errorf(" grpc GetProductInfo err: %v", err.Error())
ctx.FailWithMsg(ecode.UnknownErr, "鍐呴儴閿欒")
return
}
if getProductInfoResponse.Code != 0 {
- logx.Errorf("GetProductInfo err: %v", err.Error())
+ logx.Errorf("grpc GetProductInfo err: %v", err.Error())
ctx.FailWithMsg(ecode.UnknownErr, "鍐呴儴閿欒")
return
}
@@ -127,7 +140,7 @@
// @Summary 鑾峰彇浜у搧璁㈠崟淇℃伅
// @Produce application/json
// @Param number path string true "鏄庣粏缂栫爜"
-// @Success 200 {object} contextx.Response{data=[]product.WorkOrderInfo} "鎴愬姛"
+// @Success 200 {object} contextx.Response{data=response.Info} "鎴愬姛"
//
// @Router /api/product/getProductOrderInfo/{number} [get]
func (ci *ProductApi) GetProductOrderInfo(c *gin.Context) {
@@ -143,10 +156,11 @@
client := product.NewProductServiceClient(grpc_init.CrmApsGrpcServiceConn)
info, err := client.GetProductOrder(ctx.GetCtx(), &product.GetProductOrderRequest{SalesDetailsNumber: number})
if err != nil {
- logx.Errorf("GetProductOrder err: %v", err.Error())
+ logx.Errorf("grpc GetProductOrder err: %v", err.Error())
ctx.FailWithMsg(ecode.UnknownErr, "鍐呴儴閿欒")
return
}
+ var result response.Info
var list []response.WorkOrderInfo
for _, orderInfo := range info.List {
var wo response.WorkOrderInfo
@@ -159,5 +173,17 @@
wo.EndTime = orderInfo.EndTime
list = append(list, wo)
}
- ctx.OkWithDetailed(list)
+ result.MakeInfo = list
+ var purchaseInfo []response.Purchase
+ for _, pl := range info.PurchaseList {
+ var p response.Purchase
+ p.Amount = pl.Amount
+ p.Status = pl.Status
+ p.PurchaseName = pl.PurchaseName
+ p.PurchaseNumber = pl.PurchaseNumber
+ p.SupplierName = pl.SupplierName
+ purchaseInfo = append(purchaseInfo, p)
+ }
+ result.PurchaseInfo = purchaseInfo
+ ctx.OkWithDetailed(result)
}
--
Gitblit v1.8.0