From c32c0fd9d07d669b0e03509b502fd5fda6adcca9 Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期三, 12 七月 2023 09:44:58 +0800
Subject: [PATCH] add

---
 api/v1/index.go              |    2 
 service/salesDetails.go      |   54 ++
 api/v1/subOrder.go           |    2 
 pkg/ecode/code.go            |    7 
 router/salesDetails.go       |   19 
 docs/swagger.yaml            |  193 +++++++++
 docs/docs.go                 |  306 +++++++++++++++
 docs/swagger.json            |  306 +++++++++++++++
 model/response/response.go   |    4 
 model/salesDetails.go        |   85 ++++
 service/index.go             |    1 
 api/v1/salesDetails.go       |  166 ++++++++
 model/index.go               |    1 
 router/index.go              |    2 
 model/request/saleDetails.go |   32 +
 15 files changed, 1,176 insertions(+), 4 deletions(-)

diff --git a/api/v1/index.go b/api/v1/index.go
index af7f83b..9c6b130 100644
--- a/api/v1/index.go
+++ b/api/v1/index.go
@@ -34,6 +34,7 @@
 	QuotationApi
 	MasterOrderApi
 	SubOrderApi
+	SalesDetailsApi
 }
 
 var ApiGroup = new(Group)
@@ -67,4 +68,5 @@
 	quotationService         = service.ServiceGroup.QuotationService
 	masterOrderService       = service.ServiceGroup.MasterOrderService
 	subOrderService          = service.ServiceGroup.SubOrderService
+	salesDetailsService      = service.ServiceGroup.SalesDetailsService
 )
diff --git a/api/v1/salesDetails.go b/api/v1/salesDetails.go
new file mode 100644
index 0000000..2f57c93
--- /dev/null
+++ b/api/v1/salesDetails.go
@@ -0,0 +1,166 @@
+package v1
+
+import (
+	"aps_crm/model"
+	"aps_crm/model/request"
+	"aps_crm/model/response"
+	"aps_crm/pkg/contextx"
+	"aps_crm/pkg/ecode"
+	"github.com/gin-gonic/gin"
+	"strconv"
+)
+
+type SalesDetailsApi struct{}
+
+// Add
+//
+//	@Tags		SalesDetails
+//	@Summary	娣诲姞閿�鍞槑缁�
+//	@Produce	application/json
+//	@Param		object	body		request.AddSalesDetails	true	"鏌ヨ鍙傛暟"
+//	@Success	200		{object}	contextx.Response{}
+//	@Router		/api/salesDetails/add [post]
+func (s *SalesDetailsApi) Add(c *gin.Context) {
+	var params request.AddSalesDetails
+	ctx, ok := contextx.NewContext(c, &params)
+	if !ok {
+		return
+	}
+
+	errCode, salesDetails := checkSalesDetailsParams(params.SalesDetails)
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	errCode = salesDetailsService.AddSalesDetails(&salesDetails)
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	ctx.Ok()
+}
+
+// Delete
+//
+//	@Tags		SalesDetails
+//	@Summary	鍒犻櫎閿�鍞槑缁�
+//	@Produce	application/json
+//	@Param		id	path		int	true	"鏌ヨ鍙傛暟"
+//	@Success	200	{object}	contextx.Response{}
+//	@Router		/api/salesDetails/delete/{id} [delete]
+func (s *SalesDetailsApi) Delete(c *gin.Context) {
+	ctx, ok := contextx.NewContext(c, nil)
+	if !ok {
+		return
+	}
+
+	id, _ := strconv.Atoi(c.Param("id"))
+	errCode := salesDetailsService.DeleteSalesDetails(id)
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	ctx.Ok()
+}
+
+// Update
+//
+//	@Tags		SalesDetails
+//	@Summary	鏇存柊閿�鍞槑缁�
+//	@Produce	application/json
+//	@Param		object	body		request.UpdateSalesDetails	true	"鏌ヨ鍙傛暟"
+//	@Success	200		{object}	contextx.Response{}
+//	@Router		/api/salesDetails/update [put]
+func (s *SalesDetailsApi) Update(c *gin.Context) {
+	var params request.UpdateSalesDetails
+	ctx, ok := contextx.NewContext(c, &params)
+	if !ok {
+		return
+	}
+
+	errCode, salesDetails := checkSalesDetailsParams(params.SalesDetails)
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	errCode = salesDetailsService.UpdateSalesDetails(&salesDetails)
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	ctx.Ok()
+}
+
+// List
+//
+//	@Tags		SalesDetails
+//	@Summary	鑾峰彇閿�鍞槑缁嗗垪琛�
+//	@Produce	application/json
+//	@Success	200	{object}	contextx.Response{data=response.SalesDetailsResponse}
+//	@Router		/api/salesDetails/list [get]
+func (s *SalesDetailsApi) List(c *gin.Context) {
+	ctx, ok := contextx.NewContext(c, nil)
+	if !ok {
+		return
+	}
+
+	list, errCode := salesDetailsService.GetSalesDetailsList()
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	ctx.OkWithDetailed(response.SalesDetailsResponse{
+		List: list,
+	})
+}
+
+func checkSalesDetailsParams(salesDetails request.SalesDetails) (errCode int, salesDetailsModel model.SalesDetails) {
+	if salesDetails.ClientId == 0 {
+		return ecode.InvalidParams, salesDetailsModel
+	}
+
+	if salesDetails.Number == "" {
+		return ecode.InvalidParams, salesDetailsModel
+	}
+
+	if salesDetails.MemberId == 0 {
+		return ecode.InvalidParams, salesDetailsModel
+	}
+
+	if salesDetails.SignTime == "" {
+		return ecode.InvalidParams, salesDetailsModel
+	}
+
+	t, err := checkTimeFormat(salesDetails.SignTime)
+	if err != nil {
+		return ecode.InvalidParams, salesDetailsModel
+	}
+
+	t, err = checkTimeFormat(salesDetails.DeliveryDate)
+	if err != nil {
+		return ecode.InvalidParams, salesDetailsModel
+	}
+
+	salesDetailsModel.ClientId = salesDetails.ClientId
+	salesDetailsModel.Number = salesDetails.Number
+	salesDetailsModel.SaleChanceId = salesDetails.SaleChanceId
+	salesDetailsModel.SaleType = salesDetails.SaleType
+	salesDetailsModel.SignTime = t
+	salesDetailsModel.MemberId = salesDetails.MemberId
+	salesDetailsModel.DeliveryDate = t
+	salesDetailsModel.WechatOrderStatus = salesDetails.WechatOrderStatus
+	salesDetailsModel.Address = salesDetails.Address
+	salesDetailsModel.Phone = salesDetails.Phone
+	salesDetailsModel.Remark = salesDetails.Remark
+	salesDetailsModel.Addressee = salesDetails.Addressee
+	salesDetailsModel.Conditions = salesDetails.Conditions
+	salesDetailsModel.Products = salesDetails.Products
+
+	return ecode.OK, salesDetailsModel
+}
diff --git a/api/v1/subOrder.go b/api/v1/subOrder.go
index 2ec0fd3..41e74cd 100644
--- a/api/v1/subOrder.go
+++ b/api/v1/subOrder.go
@@ -101,7 +101,7 @@
 //	@Tags		SubOrder
 //	@Summary	鑾峰彇瀛愯鍗曞垪琛�
 //	@Produce	application/json
-//	@Success	200	{object}	contextx.Response{}
+//	@Success	200	{object}	contextx.Response{data=response.SubOrderResponse}
 //	@Router		/api/subOrder/list [get]
 func (s *SubOrderApi) List(c *gin.Context) {
 	ctx, ok := contextx.NewContext(c, nil)
diff --git a/docs/docs.go b/docs/docs.go
index 1ef0d67..849e893 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -2818,6 +2818,125 @@
                 }
             }
         },
+        "/api/salesDetails/add": {
+            "post": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "SalesDetails"
+                ],
+                "summary": "娣诲姞閿�鍞槑缁�",
+                "parameters": [
+                    {
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/request.AddSalesDetails"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/api/salesDetails/delete/{id}": {
+            "delete": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "SalesDetails"
+                ],
+                "summary": "鍒犻櫎閿�鍞槑缁�",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "id",
+                        "in": "path",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/api/salesDetails/list": {
+            "get": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "SalesDetails"
+                ],
+                "summary": "鑾峰彇閿�鍞槑缁嗗垪琛�",
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "allOf": [
+                                {
+                                    "$ref": "#/definitions/contextx.Response"
+                                },
+                                {
+                                    "type": "object",
+                                    "properties": {
+                                        "data": {
+                                            "$ref": "#/definitions/response.SalesDetailsResponse"
+                                        }
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                }
+            }
+        },
+        "/api/salesDetails/update": {
+            "put": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "SalesDetails"
+                ],
+                "summary": "鏇存柊閿�鍞槑缁�",
+                "parameters": [
+                    {
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/request.UpdateSalesDetails"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/api/salesLeads/add": {
             "post": {
                 "produces": [
@@ -3234,7 +3353,19 @@
                     "200": {
                         "description": "OK",
                         "schema": {
-                            "$ref": "#/definitions/contextx.Response"
+                            "allOf": [
+                                {
+                                    "$ref": "#/definitions/contextx.Response"
+                                },
+                                {
+                                    "type": "object",
+                                    "properties": {
+                                        "data": {
+                                            "$ref": "#/definitions/response.SubOrderResponse"
+                                        }
+                                    }
+                                }
+                            ]
                         }
                     }
                 }
@@ -4316,6 +4447,59 @@
                 }
             }
         },
+        "model.SalesDetails": {
+            "type": "object",
+            "properties": {
+                "address": {
+                    "type": "string"
+                },
+                "addressee": {
+                    "type": "string"
+                },
+                "clientId": {
+                    "type": "integer"
+                },
+                "conditions": {
+                    "type": "string"
+                },
+                "deliveryDate": {
+                    "type": "string"
+                },
+                "id": {
+                    "type": "integer"
+                },
+                "memberId": {
+                    "type": "integer"
+                },
+                "number": {
+                    "type": "string"
+                },
+                "phone": {
+                    "type": "string"
+                },
+                "products": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.Product"
+                    }
+                },
+                "remark": {
+                    "type": "string"
+                },
+                "saleChanceId": {
+                    "type": "integer"
+                },
+                "saleType": {
+                    "type": "integer"
+                },
+                "signTime": {
+                    "type": "string"
+                },
+                "wechatOrderStatus": {
+                    "type": "integer"
+                }
+            }
+        },
         "model.SalesLeads": {
             "type": "object",
             "properties": {
@@ -4389,6 +4573,32 @@
                 },
                 "name": {
                     "type": "string"
+                }
+            }
+        },
+        "model.SubOrder": {
+            "type": "object",
+            "properties": {
+                "clientId": {
+                    "type": "integer"
+                },
+                "id": {
+                    "type": "integer"
+                },
+                "masterOrderId": {
+                    "type": "integer"
+                },
+                "memberId": {
+                    "type": "integer"
+                },
+                "number": {
+                    "type": "string"
+                },
+                "products": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.Product"
+                    }
                 }
             }
         },
@@ -4943,6 +5153,14 @@
                 }
             }
         },
+        "request.AddSalesDetails": {
+            "type": "object",
+            "properties": {
+                "salesDetails": {
+                    "$ref": "#/definitions/request.SalesDetails"
+                }
+            }
+        },
         "request.AddSalesLeads": {
             "type": "object",
             "properties": {
@@ -5259,6 +5477,59 @@
                 "userName": {
                     "type": "string",
                     "example": "鐢ㄦ埛鍚�"
+                }
+            }
+        },
+        "request.SalesDetails": {
+            "type": "object",
+            "properties": {
+                "address": {
+                    "type": "string"
+                },
+                "addressee": {
+                    "type": "string"
+                },
+                "clientId": {
+                    "type": "integer"
+                },
+                "conditions": {
+                    "type": "string"
+                },
+                "deliveryDate": {
+                    "type": "string"
+                },
+                "id": {
+                    "type": "integer"
+                },
+                "memberId": {
+                    "type": "integer"
+                },
+                "number": {
+                    "type": "string"
+                },
+                "phone": {
+                    "type": "string"
+                },
+                "products": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.Product"
+                    }
+                },
+                "remark": {
+                    "type": "string"
+                },
+                "saleChanceId": {
+                    "type": "integer"
+                },
+                "saleType": {
+                    "type": "integer"
+                },
+                "signTime": {
+                    "type": "string"
+                },
+                "wechatOrderStatus": {
+                    "type": "integer"
                 }
             }
         },
@@ -6104,6 +6375,17 @@
                 }
             }
         },
+        "request.UpdateSalesDetails": {
+            "type": "object",
+            "properties": {
+                "id": {
+                    "type": "integer"
+                },
+                "salesDetails": {
+                    "$ref": "#/definitions/request.SalesDetails"
+                }
+            }
+        },
         "request.UpdateSalesLeads": {
             "type": "object",
             "properties": {
@@ -6497,6 +6779,17 @@
                 }
             }
         },
+        "response.SalesDetailsResponse": {
+            "type": "object",
+            "properties": {
+                "list": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.SalesDetails"
+                    }
+                }
+            }
+        },
         "response.SalesLeadsResponse": {
             "type": "object",
             "properties": {
@@ -6519,6 +6812,17 @@
                 }
             }
         },
+        "response.SubOrderResponse": {
+            "type": "object",
+            "properties": {
+                "list": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.SubOrder"
+                    }
+                }
+            }
+        },
         "response.UserResponse": {
             "type": "object",
             "properties": {
diff --git a/docs/swagger.json b/docs/swagger.json
index ab980ca..6434c7b 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -2806,6 +2806,125 @@
                 }
             }
         },
+        "/api/salesDetails/add": {
+            "post": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "SalesDetails"
+                ],
+                "summary": "娣诲姞閿�鍞槑缁�",
+                "parameters": [
+                    {
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/request.AddSalesDetails"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/api/salesDetails/delete/{id}": {
+            "delete": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "SalesDetails"
+                ],
+                "summary": "鍒犻櫎閿�鍞槑缁�",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "id",
+                        "in": "path",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/api/salesDetails/list": {
+            "get": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "SalesDetails"
+                ],
+                "summary": "鑾峰彇閿�鍞槑缁嗗垪琛�",
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "allOf": [
+                                {
+                                    "$ref": "#/definitions/contextx.Response"
+                                },
+                                {
+                                    "type": "object",
+                                    "properties": {
+                                        "data": {
+                                            "$ref": "#/definitions/response.SalesDetailsResponse"
+                                        }
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                }
+            }
+        },
+        "/api/salesDetails/update": {
+            "put": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "SalesDetails"
+                ],
+                "summary": "鏇存柊閿�鍞槑缁�",
+                "parameters": [
+                    {
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/request.UpdateSalesDetails"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/api/salesLeads/add": {
             "post": {
                 "produces": [
@@ -3222,7 +3341,19 @@
                     "200": {
                         "description": "OK",
                         "schema": {
-                            "$ref": "#/definitions/contextx.Response"
+                            "allOf": [
+                                {
+                                    "$ref": "#/definitions/contextx.Response"
+                                },
+                                {
+                                    "type": "object",
+                                    "properties": {
+                                        "data": {
+                                            "$ref": "#/definitions/response.SubOrderResponse"
+                                        }
+                                    }
+                                }
+                            ]
                         }
                     }
                 }
@@ -4304,6 +4435,59 @@
                 }
             }
         },
+        "model.SalesDetails": {
+            "type": "object",
+            "properties": {
+                "address": {
+                    "type": "string"
+                },
+                "addressee": {
+                    "type": "string"
+                },
+                "clientId": {
+                    "type": "integer"
+                },
+                "conditions": {
+                    "type": "string"
+                },
+                "deliveryDate": {
+                    "type": "string"
+                },
+                "id": {
+                    "type": "integer"
+                },
+                "memberId": {
+                    "type": "integer"
+                },
+                "number": {
+                    "type": "string"
+                },
+                "phone": {
+                    "type": "string"
+                },
+                "products": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.Product"
+                    }
+                },
+                "remark": {
+                    "type": "string"
+                },
+                "saleChanceId": {
+                    "type": "integer"
+                },
+                "saleType": {
+                    "type": "integer"
+                },
+                "signTime": {
+                    "type": "string"
+                },
+                "wechatOrderStatus": {
+                    "type": "integer"
+                }
+            }
+        },
         "model.SalesLeads": {
             "type": "object",
             "properties": {
@@ -4377,6 +4561,32 @@
                 },
                 "name": {
                     "type": "string"
+                }
+            }
+        },
+        "model.SubOrder": {
+            "type": "object",
+            "properties": {
+                "clientId": {
+                    "type": "integer"
+                },
+                "id": {
+                    "type": "integer"
+                },
+                "masterOrderId": {
+                    "type": "integer"
+                },
+                "memberId": {
+                    "type": "integer"
+                },
+                "number": {
+                    "type": "string"
+                },
+                "products": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.Product"
+                    }
                 }
             }
         },
@@ -4931,6 +5141,14 @@
                 }
             }
         },
+        "request.AddSalesDetails": {
+            "type": "object",
+            "properties": {
+                "salesDetails": {
+                    "$ref": "#/definitions/request.SalesDetails"
+                }
+            }
+        },
         "request.AddSalesLeads": {
             "type": "object",
             "properties": {
@@ -5247,6 +5465,59 @@
                 "userName": {
                     "type": "string",
                     "example": "鐢ㄦ埛鍚�"
+                }
+            }
+        },
+        "request.SalesDetails": {
+            "type": "object",
+            "properties": {
+                "address": {
+                    "type": "string"
+                },
+                "addressee": {
+                    "type": "string"
+                },
+                "clientId": {
+                    "type": "integer"
+                },
+                "conditions": {
+                    "type": "string"
+                },
+                "deliveryDate": {
+                    "type": "string"
+                },
+                "id": {
+                    "type": "integer"
+                },
+                "memberId": {
+                    "type": "integer"
+                },
+                "number": {
+                    "type": "string"
+                },
+                "phone": {
+                    "type": "string"
+                },
+                "products": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.Product"
+                    }
+                },
+                "remark": {
+                    "type": "string"
+                },
+                "saleChanceId": {
+                    "type": "integer"
+                },
+                "saleType": {
+                    "type": "integer"
+                },
+                "signTime": {
+                    "type": "string"
+                },
+                "wechatOrderStatus": {
+                    "type": "integer"
                 }
             }
         },
@@ -6092,6 +6363,17 @@
                 }
             }
         },
+        "request.UpdateSalesDetails": {
+            "type": "object",
+            "properties": {
+                "id": {
+                    "type": "integer"
+                },
+                "salesDetails": {
+                    "$ref": "#/definitions/request.SalesDetails"
+                }
+            }
+        },
         "request.UpdateSalesLeads": {
             "type": "object",
             "properties": {
@@ -6485,6 +6767,17 @@
                 }
             }
         },
+        "response.SalesDetailsResponse": {
+            "type": "object",
+            "properties": {
+                "list": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.SalesDetails"
+                    }
+                }
+            }
+        },
         "response.SalesLeadsResponse": {
             "type": "object",
             "properties": {
@@ -6507,6 +6800,17 @@
                 }
             }
         },
+        "response.SubOrderResponse": {
+            "type": "object",
+            "properties": {
+                "list": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.SubOrder"
+                    }
+                }
+            }
+        },
         "response.UserResponse": {
             "type": "object",
             "properties": {
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 3d30a6b..0b2fc53 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -528,6 +528,41 @@
       name:
         type: string
     type: object
+  model.SalesDetails:
+    properties:
+      address:
+        type: string
+      addressee:
+        type: string
+      clientId:
+        type: integer
+      conditions:
+        type: string
+      deliveryDate:
+        type: string
+      id:
+        type: integer
+      memberId:
+        type: integer
+      number:
+        type: string
+      phone:
+        type: string
+      products:
+        items:
+          $ref: '#/definitions/model.Product'
+        type: array
+      remark:
+        type: string
+      saleChanceId:
+        type: integer
+      saleType:
+        type: integer
+      signTime:
+        type: string
+      wechatOrderStatus:
+        type: integer
+    type: object
   model.SalesLeads:
     properties:
       city:
@@ -577,6 +612,23 @@
         type: integer
       name:
         type: string
+    type: object
+  model.SubOrder:
+    properties:
+      clientId:
+        type: integer
+      id:
+        type: integer
+      masterOrderId:
+        type: integer
+      memberId:
+        type: integer
+      number:
+        type: string
+      products:
+        items:
+          $ref: '#/definitions/model.Product'
+        type: array
     type: object
   model.User:
     properties:
@@ -952,6 +1004,11 @@
     required:
     - name
     type: object
+  request.AddSalesDetails:
+    properties:
+      salesDetails:
+        $ref: '#/definitions/request.SalesDetails'
+    type: object
   request.AddSalesLeads:
     properties:
       city_id:
@@ -1175,6 +1232,41 @@
       userName:
         example: 鐢ㄦ埛鍚�
         type: string
+    type: object
+  request.SalesDetails:
+    properties:
+      address:
+        type: string
+      addressee:
+        type: string
+      clientId:
+        type: integer
+      conditions:
+        type: string
+      deliveryDate:
+        type: string
+      id:
+        type: integer
+      memberId:
+        type: integer
+      number:
+        type: string
+      phone:
+        type: string
+      products:
+        items:
+          $ref: '#/definitions/model.Product'
+        type: array
+      remark:
+        type: string
+      saleChanceId:
+        type: integer
+      saleType:
+        type: integer
+      signTime:
+        type: string
+      wechatOrderStatus:
+        type: integer
     type: object
   request.SetCity:
     properties:
@@ -1745,6 +1837,13 @@
     required:
     - sale_types
     type: object
+  request.UpdateSalesDetails:
+    properties:
+      id:
+        type: integer
+      salesDetails:
+        $ref: '#/definitions/request.SalesDetails'
+    type: object
   request.UpdateSalesLeads:
     properties:
       city_id:
@@ -2001,6 +2100,13 @@
           $ref: '#/definitions/model.SaleType'
         type: array
     type: object
+  response.SalesDetailsResponse:
+    properties:
+      list:
+        items:
+          $ref: '#/definitions/model.SalesDetails'
+        type: array
+    type: object
   response.SalesLeadsResponse:
     properties:
       list:
@@ -2013,6 +2119,13 @@
       list:
         items:
           $ref: '#/definitions/model.SalesSources'
+        type: array
+    type: object
+  response.SubOrderResponse:
+    properties:
+      list:
+        items:
+          $ref: '#/definitions/model.SubOrder'
         type: array
     type: object
   response.UserResponse:
@@ -3740,6 +3853,79 @@
       summary: 鏇存柊閿�鍞被鍨�
       tags:
       - SaleType
+  /api/salesDetails/add:
+    post:
+      parameters:
+      - description: 鏌ヨ鍙傛暟
+        in: body
+        name: object
+        required: true
+        schema:
+          $ref: '#/definitions/request.AddSalesDetails'
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/contextx.Response'
+      summary: 娣诲姞閿�鍞槑缁�
+      tags:
+      - SalesDetails
+  /api/salesDetails/delete/{id}:
+    delete:
+      parameters:
+      - description: 鏌ヨ鍙傛暟
+        in: path
+        name: id
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/contextx.Response'
+      summary: 鍒犻櫎閿�鍞槑缁�
+      tags:
+      - SalesDetails
+  /api/salesDetails/list:
+    get:
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            allOf:
+            - $ref: '#/definitions/contextx.Response'
+            - properties:
+                data:
+                  $ref: '#/definitions/response.SalesDetailsResponse'
+              type: object
+      summary: 鑾峰彇閿�鍞槑缁嗗垪琛�
+      tags:
+      - SalesDetails
+  /api/salesDetails/update:
+    put:
+      parameters:
+      - description: 鏌ヨ鍙傛暟
+        in: body
+        name: object
+        required: true
+        schema:
+          $ref: '#/definitions/request.UpdateSalesDetails'
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/contextx.Response'
+      summary: 鏇存柊閿�鍞槑缁�
+      tags:
+      - SalesDetails
   /api/salesLeads/add:
     post:
       parameters:
@@ -3999,7 +4185,12 @@
         "200":
           description: OK
           schema:
-            $ref: '#/definitions/contextx.Response'
+            allOf:
+            - $ref: '#/definitions/contextx.Response'
+            - properties:
+                data:
+                  $ref: '#/definitions/response.SubOrderResponse'
+              type: object
       summary: 鑾峰彇瀛愯鍗曞垪琛�
       tags:
       - SubOrder
diff --git a/model/index.go b/model/index.go
index 91a30b1..2d29e86 100644
--- a/model/index.go
+++ b/model/index.go
@@ -50,6 +50,7 @@
 		MasterOrder{},
 		SubOrder{},
 		Product{},
+		SalesDetails{},
 	)
 	return err
 }
diff --git a/model/request/saleDetails.go b/model/request/saleDetails.go
new file mode 100644
index 0000000..c8966aa
--- /dev/null
+++ b/model/request/saleDetails.go
@@ -0,0 +1,32 @@
+package request
+
+import (
+	"aps_crm/model"
+)
+
+type AddSalesDetails struct {
+	SalesDetails SalesDetails `json:"salesDetails"`
+}
+
+type SalesDetails struct {
+	Id                int             `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
+	ClientId          int             `json:"clientId" gorm:"column:client_id;type:int;comment:瀹㈡埛id"`
+	Number            string          `json:"number" gorm:"column:number;type:varchar(255);comment:閿�鍞瓙鍗曞彿"`
+	SaleChanceId      int             `json:"saleChanceId" gorm:"column:sale_chance_id;type:int;comment:閿�鍞満浼歩d"`
+	SaleType          int             `json:"saleType" gorm:"column:sale_type;type:int;comment:閿�鍞被鍨�"`
+	SignTime          string          `json:"signTime" gorm:"column:sign_time;type:datetime;comment:绛惧崟鏃堕棿"`
+	MemberId          int             `json:"memberId" gorm:"column:member_id;type:int;comment:璐熻矗浜篿d"`
+	DeliveryDate      string          `json:"deliveryDate" gorm:"column:delivery_date;type:datetime;comment:浜よ揣鏃ユ湡"`
+	WechatOrderStatus int             `json:"wechatOrderStatus" gorm:"column:wechat_order_status;type:int;comment:寰俊璁㈠崟鐘舵��"`
+	Address           string          `json:"address" gorm:"column:address;type:varchar(255);comment:鍦板潃"`
+	Phone             string          `json:"phone" gorm:"column:phone;type:varchar(255);comment:鐢佃瘽"`
+	Addressee         string          `json:"addressee" gorm:"column:addressee;type:varchar(255);comment:鏀朵欢浜�"`
+	Conditions        string          `json:"conditions" gorm:"column:conditions;type:text;comment:鏉′欢"`
+	Remark            string          `json:"remark" gorm:"column:remark;type:text;comment:澶囨敞"`
+	Products          []model.Product `json:"products" gorm:"many2many:salesDetails_product;"`
+}
+
+type UpdateSalesDetails struct {
+	Id           int          `json:"id"`
+	SalesDetails SalesDetails `json:"salesDetails"`
+}
diff --git a/model/response/response.go b/model/response/response.go
index 842c0f3..ef188e4 100644
--- a/model/response/response.go
+++ b/model/response/response.go
@@ -133,4 +133,8 @@
 	SubOrderResponse struct {
 		List []*model.SubOrder `json:"list"`
 	}
+
+	SalesDetailsResponse struct {
+		List []*model.SalesDetails `json:"list"`
+	}
 )
diff --git a/model/salesDetails.go b/model/salesDetails.go
new file mode 100644
index 0000000..bcc0528
--- /dev/null
+++ b/model/salesDetails.go
@@ -0,0 +1,85 @@
+package model
+
+import (
+	"aps_crm/pkg/mysqlx"
+	"gorm.io/gorm"
+	"time"
+)
+
+type (
+	SalesDetails struct {
+		Id                int       `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
+		ClientId          int       `json:"clientId" gorm:"column:client_id;type:int;comment:瀹㈡埛id"`
+		Number            string    `json:"number" gorm:"column:number;type:varchar(255);comment:閿�鍞瓙鍗曞彿"`
+		SaleChanceId      int       `json:"saleChanceId" gorm:"column:sale_chance_id;type:int;comment:閿�鍞満浼歩d"`
+		SaleType          int       `json:"saleType" gorm:"column:sale_type;type:int;comment:閿�鍞被鍨�"`
+		SignTime          time.Time `json:"signTime" gorm:"column:sign_time;type:datetime;comment:绛惧崟鏃堕棿"`
+		MemberId          int       `json:"memberId" gorm:"column:member_id;type:int;comment:璐熻矗浜篿d"`
+		DeliveryDate      time.Time `json:"deliveryDate" gorm:"column:delivery_date;type:datetime;comment:浜よ揣鏃ユ湡"`
+		WechatOrderStatus int       `json:"wechatOrderStatus" gorm:"column:wechat_order_status;type:int;comment:寰俊璁㈠崟鐘舵��"`
+		Address           string    `json:"address" gorm:"column:address;type:varchar(255);comment:鍦板潃"`
+		Phone             string    `json:"phone" gorm:"column:phone;type:varchar(255);comment:鐢佃瘽"`
+		Addressee         string    `json:"addressee" gorm:"column:addressee;type:varchar(255);comment:鏀朵欢浜�"`
+		Conditions        string    `json:"conditions" gorm:"column:conditions;type:text;comment:鏉′欢"`
+		Remark            string    `json:"remark" gorm:"column:remark;type:text;comment:澶囨敞"`
+		Products          []Product `json:"products" gorm:"many2many:salesDetails_product;"`
+	}
+
+	SalesDetailsSearch struct {
+		SalesDetails
+		Orm *gorm.DB
+	}
+)
+
+func (SalesDetails) TableName() string {
+	return "sales_details"
+}
+
+func NewSalesDetailsSearch() *SalesDetailsSearch {
+	return &SalesDetailsSearch{
+		Orm: mysqlx.GetDB(),
+	}
+}
+
+func (slf *SalesDetailsSearch) build() *gorm.DB {
+	var db = slf.Orm.Model(&SalesDetails{})
+	if slf.Id != 0 {
+		db = db.Where("id = ?", slf.Id)
+	}
+
+	return db
+}
+
+func (slf *SalesDetailsSearch) Create(record *SalesDetails) error {
+	var db = slf.build()
+	return db.Create(record).Error
+}
+
+func (slf *SalesDetailsSearch) Delete() error {
+	var db = slf.build()
+	return db.Delete(&SalesDetails{}).Error
+}
+
+func (slf *SalesDetailsSearch) Update(record *SalesDetails) error {
+	var db = slf.build()
+	return db.Updates(record).Error
+}
+
+func (slf *SalesDetailsSearch) SetId(id int) *SalesDetailsSearch {
+	slf.Id = id
+	return slf
+}
+
+func (slf *SalesDetailsSearch) Find() (*SalesDetails, error) {
+	var db = slf.build()
+	var record = new(SalesDetails)
+	err := db.First(record).Error
+	return record, err
+}
+
+func (slf *SalesDetailsSearch) FindAll() ([]*SalesDetails, error) {
+	var db = slf.build()
+	var records = make([]*SalesDetails, 0)
+	err := db.Find(&records).Error
+	return records, err
+}
diff --git a/pkg/ecode/code.go b/pkg/ecode/code.go
index 867c208..b4008d2 100644
--- a/pkg/ecode/code.go
+++ b/pkg/ecode/code.go
@@ -198,4 +198,11 @@
 	SubOrderUpdateErr = 2700005 // 鏇存柊瀛愯鍗曞け璐�
 	SubOrderDeleteErr = 2700006 // 鍒犻櫎瀛愯鍗曞け璐�
 
+	SalesDetailsExist     = 2800001 // 閿�鍞槑缁嗗凡瀛樺湪
+	SalesDetailsNotExist  = 2800002 // 閿�鍞槑缁嗕笉瀛樺湪
+	SalesDetailsListErr   = 2800003 // 鑾峰彇閿�鍞槑缁嗗垪琛ㄥけ璐�
+	SalesDetailsSetErr    = 2800004 // 璁剧疆閿�鍞槑缁嗗け璐�
+	SalesDetailsUpdateErr = 2800005 // 鏇存柊閿�鍞槑缁嗗け璐�
+	SalesDetailsDeleteErr = 2800006 // 鍒犻櫎閿�鍞槑缁嗗け璐�
+
 )
diff --git a/router/index.go b/router/index.go
index 2cf4c1b..6b96a23 100644
--- a/router/index.go
+++ b/router/index.go
@@ -40,6 +40,7 @@
 	QuotationRouter
 	MasterOrderRouter
 	SubOrderRouter
+	SalesDetailsRouter
 }
 
 func InitRouter() *gin.Engine {
@@ -97,6 +98,7 @@
 		routerGroup.InitQuotationRouter(PrivateGroup)         // 娉ㄥ唽quotation璺敱
 		routerGroup.InitMasterOrderRouter(PrivateGroup)       // 娉ㄥ唽masterOrder璺敱
 		routerGroup.InitSubOrderRouter(PrivateGroup)          // 娉ㄥ唽subOrder璺敱
+		routerGroup.InitSalesDetailsRouter(PrivateGroup)      // 娉ㄥ唽salesDetails璺敱
 	}
 	return Router
 }
diff --git a/router/salesDetails.go b/router/salesDetails.go
new file mode 100644
index 0000000..e892a26
--- /dev/null
+++ b/router/salesDetails.go
@@ -0,0 +1,19 @@
+package router
+
+import (
+	v1 "aps_crm/api/v1"
+	"github.com/gin-gonic/gin"
+)
+
+type SalesDetailsRouter struct{}
+
+func (s *SalesDetailsRouter) InitSalesDetailsRouter(router *gin.RouterGroup) {
+	salesDetailsRouter := router.Group("salesDetails")
+	salesDetailsApi := v1.ApiGroup.SalesDetailsApi
+	{
+		salesDetailsRouter.POST("add", salesDetailsApi.Add)             // 娣诲姞閿�鍞槑缁�
+		salesDetailsRouter.DELETE("delete/:id", salesDetailsApi.Delete) // 鍒犻櫎閿�鍞槑缁�
+		salesDetailsRouter.PUT("update", salesDetailsApi.Update)        // 鏇存柊閿�鍞槑缁�
+		salesDetailsRouter.GET("list", salesDetailsApi.List)            // 鑾峰彇閿�鍞槑缁嗗垪琛�
+	}
+}
diff --git a/service/index.go b/service/index.go
index d8ab5e1..fd6af9f 100644
--- a/service/index.go
+++ b/service/index.go
@@ -29,6 +29,7 @@
 	QuotationService
 	MasterOrderService
 	SubOrderService
+	SalesDetailsService
 }
 
 var ServiceGroup = new(Group)
diff --git a/service/salesDetails.go b/service/salesDetails.go
new file mode 100644
index 0000000..cde3653
--- /dev/null
+++ b/service/salesDetails.go
@@ -0,0 +1,54 @@
+package service
+
+import (
+	"aps_crm/model"
+	"aps_crm/pkg/ecode"
+)
+
+type SalesDetailsService struct{}
+
+func (SalesDetailsService) AddSalesDetails(salesDetails *model.SalesDetails) int {
+	err := model.NewSalesDetailsSearch().Create(salesDetails)
+	if err != nil {
+		return ecode.SalesDetailsExist
+	}
+
+	return ecode.OK
+}
+
+func (SalesDetailsService) DeleteSalesDetails(id int) int {
+	_, err := model.NewSalesDetailsSearch().SetId(id).Find()
+	if err != nil {
+		return ecode.SalesDetailsNotExist
+	}
+
+	err = model.NewSalesDetailsSearch().SetId(id).Delete()
+	if err != nil {
+		return ecode.SalesDetailsNotExist
+	}
+	return ecode.OK
+}
+
+func (SalesDetailsService) GetSalesDetailsList() ([]*model.SalesDetails, int) {
+	list, err := model.NewSalesDetailsSearch().FindAll()
+	if err != nil {
+		return nil, ecode.SalesDetailsListErr
+	}
+
+	return list, ecode.OK
+}
+
+func (SalesDetailsService) UpdateSalesDetails(salesDetails *model.SalesDetails) int {
+	// check salesDetails exist
+	_, err := model.NewSalesDetailsSearch().SetId(salesDetails.Id).Find()
+	if err != nil {
+		return ecode.SalesDetailsNotExist
+	}
+
+	err = model.NewSalesDetailsSearch().SetId(salesDetails.Id).Update(salesDetails)
+	if err != nil {
+		return ecode.SalesDetailsSetErr
+	}
+
+	return ecode.OK
+}

--
Gitblit v1.8.0