From a5ccc6b321a3127ca064b935e42db44428c41305 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期六, 05 八月 2023 17:00:50 +0800
Subject: [PATCH] 服务合同收款计划增删改查接口

---
 api/v1/faq.go                          |    4 
 service/serviceCollectionPlan.go       |   80 +++
 api/v1/serviceCollectionPlan.go        |  112 +++++
 model/request/serviceCollectionPlan.go |   18 
 router/index.go                        |    3 
 router/serviceCollectionPlan.go        |   17 
 constvar/serviceCollectionPlan.go      |   12 
 docs/swagger.yaml                      |  199 +++++++++
 docs/docs.go                           |  299 ++++++++++++++
 docs/swagger.json                      |  299 ++++++++++++++
 model/serviceCollectionPlan.go         |  159 +++++++
 service/faq.go                         |    4 
 12 files changed, 1,203 insertions(+), 3 deletions(-)

diff --git a/api/v1/faq.go b/api/v1/faq.go
index 44dc341..350dae2 100644
--- a/api/v1/faq.go
+++ b/api/v1/faq.go
@@ -89,10 +89,12 @@
 // @Tags		甯歌闂绠$悊
 // @Summary	鑾峰彇甯歌闂鍒楄〃
 // @Produce	application/json
+// @Param		object	body		request.GetFaqList	true	"鍙傛暟"
 // @Success	200	{object}	response.ListResponse{data=[]model.Faq}
 // @Router		/api/faq/list [get]
 func (s *FaqApi) List(c *gin.Context) {
-	ctx, ok := contextx.NewContext(c, nil)
+	var params request.GetFaqList
+	ctx, ok := contextx.NewContext(c, params)
 	if !ok {
 		return
 	}
diff --git a/api/v1/serviceCollectionPlan.go b/api/v1/serviceCollectionPlan.go
new file mode 100644
index 0000000..7476dd7
--- /dev/null
+++ b/api/v1/serviceCollectionPlan.go
@@ -0,0 +1,112 @@
+package v1
+
+import (
+	"aps_crm/model/request"
+	"aps_crm/model/response"
+	"aps_crm/pkg/contextx"
+	"aps_crm/pkg/ecode"
+	"aps_crm/service"
+	"github.com/gin-gonic/gin"
+	"strconv"
+)
+
+type ServiceCollectionPlanApi struct{}
+
+// Add
+// @Tags		鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊
+// @Summary	娣诲姞鏈嶅姟鍚堝悓鏀舵璁″垝
+// @Produce	application/json
+// @Param		object	body		request.AddServiceCollectionPlan	true	"鏌ヨ鍙傛暟"
+// @Success	200		{object}	contextx.Response{}
+// @Router		/api/serviceCollectionPlan/add [post]
+func (s *ServiceCollectionPlanApi) Add(c *gin.Context) {
+	var params request.AddServiceCollectionPlan
+	ctx, ok := contextx.NewContext(c, &params)
+	if !ok {
+		return
+	}
+
+	errCode := service.NewServiceCollectionPlanService().AddServiceCollectionPlan(params.List)
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	ctx.Ok()
+}
+
+// Delete
+// @Tags		鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊
+// @Summary	鍒犻櫎鏈嶅姟鍚堝悓鏀舵璁″垝
+// @Produce	application/json
+// @Param		id	path		int	true	"鏌ヨ鍙傛暟"
+// @Success	200	{object}	contextx.Response{}
+// @Router		/api/serviceCollectionPlan/delete/{id} [delete]
+func (s *ServiceCollectionPlanApi) Delete(c *gin.Context) {
+	ctx, ok := contextx.NewContext(c, nil)
+	if !ok {
+		return
+	}
+
+	id, _ := strconv.Atoi(c.Param("id"))
+	errCode := service.NewServiceCollectionPlanService().DeleteServiceCollectionPlan(id)
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	ctx.Ok()
+}
+
+// Update
+// @Tags		鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊
+// @Summary	鏇存柊鏈嶅姟鍚堝悓鏀舵璁″垝
+// @Produce	application/json
+// @Param		object	body		request.UpdateServiceCollectionPlan	true	"鏌ヨ鍙傛暟"
+// @Success	200		{object}	contextx.Response{}
+// @Router		/api/serviceCollectionPlan/update [put]
+func (s *ServiceCollectionPlanApi) Update(c *gin.Context) {
+	var params request.UpdateServiceCollectionPlan
+	ctx, ok := contextx.NewContext(c, &params)
+	if !ok {
+		return
+	}
+	if params.Id == 0 {
+		ctx.Fail(ecode.ParamsErr)
+	}
+	params.ServiceCollectionPlan.Id = params.Id
+
+	errCode := service.NewServiceCollectionPlanService().UpdateServiceCollectionPlan(&params.ServiceCollectionPlan)
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	ctx.Ok()
+}
+
+// List
+// @Tags		鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊
+// @Summary	鑾峰彇鏈嶅姟鍚堝悓鏀舵璁″垝鍒楄〃
+// @Produce	application/json
+// @Param		object	query		request.GetServiceCollectionPlanList	true	"鍙傛暟"
+// @Success	200	{object}	response.ListResponse{data=[]model.ServiceCollectionPlan}
+// @Router		/api/serviceCollectionPlan/list [get]
+func (s *ServiceCollectionPlanApi) List(c *gin.Context) {
+	var params request.GetServiceCollectionPlanList
+	ctx, ok := contextx.NewContext(c, &params)
+	if !ok {
+		return
+	}
+
+	serviceCollectionPlan, total, errCode := service.NewServiceCollectionPlanService().GetServiceCollectionPlanList(params.ServiceContractId)
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	ctx.OkWithDetailed(response.ListResponse{
+		Data:  serviceCollectionPlan,
+		Count: total,
+	})
+}
diff --git a/constvar/serviceCollectionPlan.go b/constvar/serviceCollectionPlan.go
new file mode 100644
index 0000000..32450ec
--- /dev/null
+++ b/constvar/serviceCollectionPlan.go
@@ -0,0 +1,12 @@
+package constvar
+type ServiceCollectionPlanQueryClass string
+
+const (
+	ServiceCollectionPlanQueryClassExpireLessThen60Days ServiceCollectionPlanQueryClass = ""
+)
+
+type ServiceCollectionPlanKeywordType string
+
+const (
+	ServiceCollectionPlanKeywordCustomerName   ServiceCollectionPlanKeywordType = ""
+)
diff --git a/docs/docs.go b/docs/docs.go
index 181b30a..1c6480c 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -2141,6 +2141,17 @@
                     "甯歌闂绠$悊"
                 ],
                 "summary": "鑾峰彇甯歌闂鍒楄〃",
+                "parameters": [
+                    {
+                        "description": "鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/request.GetFaqList"
+                        }
+                    }
+                ],
                 "responses": {
                     "200": {
                         "description": "OK",
@@ -6024,6 +6035,136 @@
                 }
             }
         },
+        "/api/serviceCollectionPlan/add": {
+            "post": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊"
+                ],
+                "summary": "娣诲姞鏈嶅姟鍚堝悓鏀舵璁″垝",
+                "parameters": [
+                    {
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/request.AddServiceCollectionPlan"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/api/serviceCollectionPlan/delete/{id}": {
+            "delete": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊"
+                ],
+                "summary": "鍒犻櫎鏈嶅姟鍚堝悓鏀舵璁″垝",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "id",
+                        "in": "path",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/api/serviceCollectionPlan/list": {
+            "get": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊"
+                ],
+                "summary": "鑾峰彇鏈嶅姟鍚堝悓鏀舵璁″垝鍒楄〃",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "鏈嶅姟鍚堝悓id",
+                        "name": "serviceContractId",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "allOf": [
+                                {
+                                    "$ref": "#/definitions/response.ListResponse"
+                                },
+                                {
+                                    "type": "object",
+                                    "properties": {
+                                        "data": {
+                                            "type": "array",
+                                            "items": {
+                                                "$ref": "#/definitions/model.ServiceCollectionPlan"
+                                            }
+                                        }
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                }
+            }
+        },
+        "/api/serviceCollectionPlan/update": {
+            "put": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊"
+                ],
+                "summary": "鏇存柊鏈嶅姟鍚堝悓鏀舵璁″垝",
+                "parameters": [
+                    {
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/request.UpdateServiceCollectionPlan"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/api/serviceContract/add": {
             "post": {
                 "produces": [
@@ -7930,6 +8071,24 @@
         }
     },
     "definitions": {
+        "constvar.FaqKeywordType": {
+            "type": "string",
+            "enum": [
+                ""
+            ],
+            "x-enum-varnames": [
+                "FaqKeywordCustomerName"
+            ]
+        },
+        "constvar.FaqQueryClass": {
+            "type": "string",
+            "enum": [
+                ""
+            ],
+            "x-enum-varnames": [
+                "FaqQueryClassExpireLessThen60Days"
+            ]
+        },
         "constvar.SalesStatus": {
             "type": "integer",
             "enum": [
@@ -9395,6 +9554,58 @@
                 }
             }
         },
+        "model.ServiceCollectionPlan": {
+            "type": "object",
+            "properties": {
+                "amount": {
+                    "description": "閲戦",
+                    "type": "number"
+                },
+                "collectionDate": {
+                    "description": "璁″垝鏀舵鏃ユ湡",
+                    "type": "string"
+                },
+                "collectionType": {
+                    "description": "绫诲瀷锛�1 璁″垝鏀舵鏃ユ湡 2 椤圭洰鐘舵�侊級",
+                    "type": "integer"
+                },
+                "fileId": {
+                    "description": "闄勪欢id",
+                    "type": "integer"
+                },
+                "id": {
+                    "type": "integer"
+                },
+                "moneyType": {
+                    "description": "甯佺",
+                    "type": "string"
+                },
+                "percent": {
+                    "description": "姣斾緥",
+                    "type": "number"
+                },
+                "principal": {
+                    "description": "鏀舵璐熻矗浜篒D",
+                    "type": "integer"
+                },
+                "remark": {
+                    "description": "澶囨敞",
+                    "type": "string"
+                },
+                "serviceContractId": {
+                    "description": "鏈嶅姟鍚堝悓id",
+                    "type": "integer"
+                },
+                "status": {
+                    "description": "鐘舵�侊紙1鏈敹2宸叉敹锛�",
+                    "type": "integer"
+                },
+                "term": {
+                    "description": "鏈熸",
+                    "type": "integer"
+                }
+            }
+        },
         "model.ServiceContract": {
             "type": "object",
             "properties": {
@@ -9543,6 +9754,9 @@
                 },
                 "serviceId": {
                     "type": "integer"
+                },
+                "serviceOrder": {
+                    "$ref": "#/definitions/model.ServiceOrder"
                 },
                 "solveRateId": {
                     "type": "integer"
@@ -10681,6 +10895,17 @@
                 }
             }
         },
+        "request.AddServiceCollectionPlan": {
+            "type": "object",
+            "properties": {
+                "list": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.ServiceCollectionPlan"
+                    }
+                }
+            }
+        },
         "request.AddServiceContract": {
             "type": "object",
             "properties": {
@@ -11386,6 +11611,28 @@
                 "pageSize": {
                     "description": "姣忛〉澶у皬",
                     "type": "integer"
+                }
+            }
+        },
+        "request.GetFaqList": {
+            "type": "object",
+            "properties": {
+                "keyword": {
+                    "type": "string"
+                },
+                "keywordType": {
+                    "$ref": "#/definitions/constvar.FaqKeywordType"
+                },
+                "page": {
+                    "description": "椤电爜",
+                    "type": "integer"
+                },
+                "pageSize": {
+                    "description": "姣忛〉澶у皬",
+                    "type": "integer"
+                },
+                "queryClass": {
+                    "$ref": "#/definitions/constvar.FaqQueryClass"
                 }
             }
         },
@@ -13296,6 +13543,58 @@
                 }
             }
         },
+        "request.UpdateServiceCollectionPlan": {
+            "type": "object",
+            "properties": {
+                "amount": {
+                    "description": "閲戦",
+                    "type": "number"
+                },
+                "collectionDate": {
+                    "description": "璁″垝鏀舵鏃ユ湡",
+                    "type": "string"
+                },
+                "collectionType": {
+                    "description": "绫诲瀷锛�1 璁″垝鏀舵鏃ユ湡 2 椤圭洰鐘舵�侊級",
+                    "type": "integer"
+                },
+                "fileId": {
+                    "description": "闄勪欢id",
+                    "type": "integer"
+                },
+                "id": {
+                    "type": "integer"
+                },
+                "moneyType": {
+                    "description": "甯佺",
+                    "type": "string"
+                },
+                "percent": {
+                    "description": "姣斾緥",
+                    "type": "number"
+                },
+                "principal": {
+                    "description": "鏀舵璐熻矗浜篒D",
+                    "type": "integer"
+                },
+                "remark": {
+                    "description": "澶囨敞",
+                    "type": "string"
+                },
+                "serviceContractId": {
+                    "description": "鏈嶅姟鍚堝悓id",
+                    "type": "integer"
+                },
+                "status": {
+                    "description": "鐘舵�侊紙1鏈敹2宸叉敹锛�",
+                    "type": "integer"
+                },
+                "term": {
+                    "description": "鏈熸",
+                    "type": "integer"
+                }
+            }
+        },
         "request.UpdateServiceContract": {
             "type": "object",
             "properties": {
diff --git a/docs/swagger.json b/docs/swagger.json
index 5513bae..7aa19d5 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -2129,6 +2129,17 @@
                     "甯歌闂绠$悊"
                 ],
                 "summary": "鑾峰彇甯歌闂鍒楄〃",
+                "parameters": [
+                    {
+                        "description": "鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/request.GetFaqList"
+                        }
+                    }
+                ],
                 "responses": {
                     "200": {
                         "description": "OK",
@@ -6012,6 +6023,136 @@
                 }
             }
         },
+        "/api/serviceCollectionPlan/add": {
+            "post": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊"
+                ],
+                "summary": "娣诲姞鏈嶅姟鍚堝悓鏀舵璁″垝",
+                "parameters": [
+                    {
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/request.AddServiceCollectionPlan"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/api/serviceCollectionPlan/delete/{id}": {
+            "delete": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊"
+                ],
+                "summary": "鍒犻櫎鏈嶅姟鍚堝悓鏀舵璁″垝",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "id",
+                        "in": "path",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/api/serviceCollectionPlan/list": {
+            "get": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊"
+                ],
+                "summary": "鑾峰彇鏈嶅姟鍚堝悓鏀舵璁″垝鍒楄〃",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "鏈嶅姟鍚堝悓id",
+                        "name": "serviceContractId",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "allOf": [
+                                {
+                                    "$ref": "#/definitions/response.ListResponse"
+                                },
+                                {
+                                    "type": "object",
+                                    "properties": {
+                                        "data": {
+                                            "type": "array",
+                                            "items": {
+                                                "$ref": "#/definitions/model.ServiceCollectionPlan"
+                                            }
+                                        }
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                }
+            }
+        },
+        "/api/serviceCollectionPlan/update": {
+            "put": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊"
+                ],
+                "summary": "鏇存柊鏈嶅姟鍚堝悓鏀舵璁″垝",
+                "parameters": [
+                    {
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/request.UpdateServiceCollectionPlan"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/api/serviceContract/add": {
             "post": {
                 "produces": [
@@ -7918,6 +8059,24 @@
         }
     },
     "definitions": {
+        "constvar.FaqKeywordType": {
+            "type": "string",
+            "enum": [
+                ""
+            ],
+            "x-enum-varnames": [
+                "FaqKeywordCustomerName"
+            ]
+        },
+        "constvar.FaqQueryClass": {
+            "type": "string",
+            "enum": [
+                ""
+            ],
+            "x-enum-varnames": [
+                "FaqQueryClassExpireLessThen60Days"
+            ]
+        },
         "constvar.SalesStatus": {
             "type": "integer",
             "enum": [
@@ -9383,6 +9542,58 @@
                 }
             }
         },
+        "model.ServiceCollectionPlan": {
+            "type": "object",
+            "properties": {
+                "amount": {
+                    "description": "閲戦",
+                    "type": "number"
+                },
+                "collectionDate": {
+                    "description": "璁″垝鏀舵鏃ユ湡",
+                    "type": "string"
+                },
+                "collectionType": {
+                    "description": "绫诲瀷锛�1 璁″垝鏀舵鏃ユ湡 2 椤圭洰鐘舵�侊級",
+                    "type": "integer"
+                },
+                "fileId": {
+                    "description": "闄勪欢id",
+                    "type": "integer"
+                },
+                "id": {
+                    "type": "integer"
+                },
+                "moneyType": {
+                    "description": "甯佺",
+                    "type": "string"
+                },
+                "percent": {
+                    "description": "姣斾緥",
+                    "type": "number"
+                },
+                "principal": {
+                    "description": "鏀舵璐熻矗浜篒D",
+                    "type": "integer"
+                },
+                "remark": {
+                    "description": "澶囨敞",
+                    "type": "string"
+                },
+                "serviceContractId": {
+                    "description": "鏈嶅姟鍚堝悓id",
+                    "type": "integer"
+                },
+                "status": {
+                    "description": "鐘舵�侊紙1鏈敹2宸叉敹锛�",
+                    "type": "integer"
+                },
+                "term": {
+                    "description": "鏈熸",
+                    "type": "integer"
+                }
+            }
+        },
         "model.ServiceContract": {
             "type": "object",
             "properties": {
@@ -9531,6 +9742,9 @@
                 },
                 "serviceId": {
                     "type": "integer"
+                },
+                "serviceOrder": {
+                    "$ref": "#/definitions/model.ServiceOrder"
                 },
                 "solveRateId": {
                     "type": "integer"
@@ -10669,6 +10883,17 @@
                 }
             }
         },
+        "request.AddServiceCollectionPlan": {
+            "type": "object",
+            "properties": {
+                "list": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.ServiceCollectionPlan"
+                    }
+                }
+            }
+        },
         "request.AddServiceContract": {
             "type": "object",
             "properties": {
@@ -11374,6 +11599,28 @@
                 "pageSize": {
                     "description": "姣忛〉澶у皬",
                     "type": "integer"
+                }
+            }
+        },
+        "request.GetFaqList": {
+            "type": "object",
+            "properties": {
+                "keyword": {
+                    "type": "string"
+                },
+                "keywordType": {
+                    "$ref": "#/definitions/constvar.FaqKeywordType"
+                },
+                "page": {
+                    "description": "椤电爜",
+                    "type": "integer"
+                },
+                "pageSize": {
+                    "description": "姣忛〉澶у皬",
+                    "type": "integer"
+                },
+                "queryClass": {
+                    "$ref": "#/definitions/constvar.FaqQueryClass"
                 }
             }
         },
@@ -13284,6 +13531,58 @@
                 }
             }
         },
+        "request.UpdateServiceCollectionPlan": {
+            "type": "object",
+            "properties": {
+                "amount": {
+                    "description": "閲戦",
+                    "type": "number"
+                },
+                "collectionDate": {
+                    "description": "璁″垝鏀舵鏃ユ湡",
+                    "type": "string"
+                },
+                "collectionType": {
+                    "description": "绫诲瀷锛�1 璁″垝鏀舵鏃ユ湡 2 椤圭洰鐘舵�侊級",
+                    "type": "integer"
+                },
+                "fileId": {
+                    "description": "闄勪欢id",
+                    "type": "integer"
+                },
+                "id": {
+                    "type": "integer"
+                },
+                "moneyType": {
+                    "description": "甯佺",
+                    "type": "string"
+                },
+                "percent": {
+                    "description": "姣斾緥",
+                    "type": "number"
+                },
+                "principal": {
+                    "description": "鏀舵璐熻矗浜篒D",
+                    "type": "integer"
+                },
+                "remark": {
+                    "description": "澶囨敞",
+                    "type": "string"
+                },
+                "serviceContractId": {
+                    "description": "鏈嶅姟鍚堝悓id",
+                    "type": "integer"
+                },
+                "status": {
+                    "description": "鐘舵�侊紙1鏈敹2宸叉敹锛�",
+                    "type": "integer"
+                },
+                "term": {
+                    "description": "鏈熸",
+                    "type": "integer"
+                }
+            }
+        },
         "request.UpdateServiceContract": {
             "type": "object",
             "properties": {
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 3b5e678..6fb9f7b 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -1,4 +1,16 @@
 definitions:
+  constvar.FaqKeywordType:
+    enum:
+    - ""
+    type: string
+    x-enum-varnames:
+    - FaqKeywordCustomerName
+  constvar.FaqQueryClass:
+    enum:
+    - ""
+    type: string
+    x-enum-varnames:
+    - FaqQueryClassExpireLessThen60Days
   constvar.SalesStatus:
     enum:
     - 1
@@ -987,6 +999,44 @@
       name:
         type: string
     type: object
+  model.ServiceCollectionPlan:
+    properties:
+      amount:
+        description: 閲戦
+        type: number
+      collectionDate:
+        description: 璁″垝鏀舵鏃ユ湡
+        type: string
+      collectionType:
+        description: 绫诲瀷锛�1 璁″垝鏀舵鏃ユ湡 2 椤圭洰鐘舵�侊級
+        type: integer
+      fileId:
+        description: 闄勪欢id
+        type: integer
+      id:
+        type: integer
+      moneyType:
+        description: 甯佺
+        type: string
+      percent:
+        description: 姣斾緥
+        type: number
+      principal:
+        description: 鏀舵璐熻矗浜篒D
+        type: integer
+      remark:
+        description: 澶囨敞
+        type: string
+      serviceContractId:
+        description: 鏈嶅姟鍚堝悓id
+        type: integer
+      status:
+        description: 鐘舵�侊紙1鏈敹2宸叉敹锛�
+        type: integer
+      term:
+        description: 鏈熸
+        type: integer
+    type: object
   model.ServiceContract:
     properties:
       clientId:
@@ -1085,6 +1135,8 @@
         type: integer
       serviceId:
         type: integer
+      serviceOrder:
+        $ref: '#/definitions/model.ServiceOrder'
       solveRateId:
         type: integer
       timelyRateId:
@@ -1849,6 +1901,13 @@
     required:
     - name
     type: object
+  request.AddServiceCollectionPlan:
+    properties:
+      list:
+        items:
+          $ref: '#/definitions/model.ServiceCollectionPlan'
+        type: array
+    type: object
   request.AddServiceContract:
     properties:
       clientId:
@@ -2339,6 +2398,21 @@
       pageSize:
         description: 姣忛〉澶у皬
         type: integer
+    type: object
+  request.GetFaqList:
+    properties:
+      keyword:
+        type: string
+      keywordType:
+        $ref: '#/definitions/constvar.FaqKeywordType'
+      page:
+        description: 椤电爜
+        type: integer
+      pageSize:
+        description: 姣忛〉澶у皬
+        type: integer
+      queryClass:
+        $ref: '#/definitions/constvar.FaqQueryClass'
     type: object
   request.GetFollowRecordList:
     properties:
@@ -3618,6 +3692,44 @@
         type: array
     required:
     - satisfactions
+    type: object
+  request.UpdateServiceCollectionPlan:
+    properties:
+      amount:
+        description: 閲戦
+        type: number
+      collectionDate:
+        description: 璁″垝鏀舵鏃ユ湡
+        type: string
+      collectionType:
+        description: 绫诲瀷锛�1 璁″垝鏀舵鏃ユ湡 2 椤圭洰鐘舵�侊級
+        type: integer
+      fileId:
+        description: 闄勪欢id
+        type: integer
+      id:
+        type: integer
+      moneyType:
+        description: 甯佺
+        type: string
+      percent:
+        description: 姣斾緥
+        type: number
+      principal:
+        description: 鏀舵璐熻矗浜篒D
+        type: integer
+      remark:
+        description: 澶囨敞
+        type: string
+      serviceContractId:
+        description: 鏈嶅姟鍚堝悓id
+        type: integer
+      status:
+        description: 鐘舵�侊紙1鏈敹2宸叉敹锛�
+        type: integer
+      term:
+        description: 鏈熸
+        type: integer
     type: object
   request.UpdateServiceContract:
     properties:
@@ -5887,6 +5999,13 @@
       - 甯歌闂绠$悊
   /api/faq/list:
     get:
+      parameters:
+      - description: 鍙傛暟
+        in: body
+        name: object
+        required: true
+        schema:
+          $ref: '#/definitions/request.GetFaqList'
       produces:
       - application/json
       responses:
@@ -8274,6 +8393,86 @@
       summary: 鏇存柊婊℃剰搴�
       tags:
       - Satisfaction
+  /api/serviceCollectionPlan/add:
+    post:
+      parameters:
+      - description: 鏌ヨ鍙傛暟
+        in: body
+        name: object
+        required: true
+        schema:
+          $ref: '#/definitions/request.AddServiceCollectionPlan'
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/contextx.Response'
+      summary: 娣诲姞鏈嶅姟鍚堝悓鏀舵璁″垝
+      tags:
+      - 鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊
+  /api/serviceCollectionPlan/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:
+      - 鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊
+  /api/serviceCollectionPlan/list:
+    get:
+      parameters:
+      - description: 鏈嶅姟鍚堝悓id
+        in: query
+        name: serviceContractId
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            allOf:
+            - $ref: '#/definitions/response.ListResponse'
+            - properties:
+                data:
+                  items:
+                    $ref: '#/definitions/model.ServiceCollectionPlan'
+                  type: array
+              type: object
+      summary: 鑾峰彇鏈嶅姟鍚堝悓鏀舵璁″垝鍒楄〃
+      tags:
+      - 鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊
+  /api/serviceCollectionPlan/update:
+    put:
+      parameters:
+      - description: 鏌ヨ鍙傛暟
+        in: body
+        name: object
+        required: true
+        schema:
+          $ref: '#/definitions/request.UpdateServiceCollectionPlan'
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/contextx.Response'
+      summary: 鏇存柊鏈嶅姟鍚堝悓鏀舵璁″垝
+      tags:
+      - 鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊
   /api/serviceContract/add:
     post:
       parameters:
diff --git a/model/request/serviceCollectionPlan.go b/model/request/serviceCollectionPlan.go
new file mode 100644
index 0000000..b8e4f35
--- /dev/null
+++ b/model/request/serviceCollectionPlan.go
@@ -0,0 +1,18 @@
+package request
+
+import (
+	"aps_crm/model"
+)
+
+type AddServiceCollectionPlan struct {
+	List []*model.ServiceCollectionPlan
+}
+
+type UpdateServiceCollectionPlan struct {
+	Id int `json:"id"`
+	model.ServiceCollectionPlan
+}
+
+type GetServiceCollectionPlanList struct {
+	ServiceContractId int `gorm:"service_contract_id" form:"serviceContractId"` // 鏈嶅姟鍚堝悓id
+}
diff --git a/model/serviceCollectionPlan.go b/model/serviceCollectionPlan.go
new file mode 100644
index 0000000..be9da1b
--- /dev/null
+++ b/model/serviceCollectionPlan.go
@@ -0,0 +1,159 @@
+package model
+
+import (
+	"aps_crm/constvar"
+	"aps_crm/pkg/mysqlx"
+	"errors"
+	"fmt"
+	"gorm.io/gorm"
+)
+
+type (
+	// ServiceCollectionPlan 鏈嶅姟鍚堝悓鏀舵璁″垝
+	ServiceCollectionPlan struct {
+		Id                int     `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
+		CollectionType    int     `gorm:"collection_type" json:"collectionType"`        // 绫诲瀷锛�1 璁″垝鏀舵鏃ユ湡 2 椤圭洰鐘舵�侊級
+		ServiceContractId int     `gorm:"service_contract_id" json:"serviceContractId"` // 鏈嶅姟鍚堝悓id
+		PrincipalId       int     `gorm:"principal_id" json:"principalId"`              // 鏀舵璐熻矗浜篒D
+		Term              int     `gorm:"term" json:"term"`                             // 鏈熸
+		Percent           float64 `gorm:"percent" json:"percent"`                       // 姣斾緥
+		Amount            float64 `gorm:"amount" json:"amount"`                         // 閲戦
+		MoneyType         string  `gorm:"money_type" json:"moneyType"`                  // 甯佺
+		CollectionDate    string  `gorm:"collection_date" json:"collectionDate"`        // 璁″垝鏀舵鏃ユ湡
+		Remark            string  `gorm:"remark" json:"remark"`                         // 澶囨敞
+		Status            int     `gorm:"status" json:"status"`                         // 鐘舵�侊紙1鏈敹2宸叉敹锛�
+		FileId            int     `gorm:"file_id" json:"fileId"`                        // 闄勪欢id
+	}
+
+	// ServiceCollectionPlanSearch 鏈嶅姟鍚堝悓鏀舵璁″垝鎼滅储鏉′欢
+	ServiceCollectionPlanSearch struct {
+		ServiceCollectionPlan
+		Orm         *gorm.DB
+		QueryClass  constvar.ServiceCollectionPlanQueryClass
+		KeywordType constvar.ServiceCollectionPlanKeywordType
+		Keyword     string
+		PageNum     int
+		PageSize    int
+	}
+)
+
+func (ServiceCollectionPlan) TableName() string {
+	return "service_collection_plan"
+}
+
+func NewServiceCollectionPlanSearch() *ServiceCollectionPlanSearch {
+	return &ServiceCollectionPlanSearch{
+		Orm: mysqlx.GetDB(),
+	}
+}
+
+func (slf *ServiceCollectionPlanSearch) build() *gorm.DB {
+	var db = slf.Orm.Model(&ServiceCollectionPlan{})
+	if slf.Id != 0 {
+		db = db.Where("id = ?", slf.Id)
+	}
+
+	if slf.ServiceContractId != 0 {
+		db = db.Where("service_contract_id = ?", slf.ServiceContractId)
+	}
+
+	return db
+}
+
+func (slf *ServiceCollectionPlanSearch) Create(record *ServiceCollectionPlan) error {
+	var db = slf.build()
+	return db.Create(record).Error
+}
+
+func (slf *ServiceCollectionPlanSearch) CreateBatch(records []*ServiceCollectionPlan) error {
+	var db = slf.build()
+	return db.Create(records).Error
+}
+
+func (slf *ServiceCollectionPlanSearch) Delete() error {
+	var db = slf.build()
+	return db.Delete(&ServiceCollectionPlan{}).Error
+}
+
+func (slf *ServiceCollectionPlanSearch) Update(record *ServiceCollectionPlan) error {
+	var db = slf.build()
+	return db.Updates(record).Error
+}
+
+func (slf *ServiceCollectionPlanSearch) FindAll() ([]*ServiceCollectionPlan, error) {
+	var db = slf.build()
+	var record = make([]*ServiceCollectionPlan, 0)
+	err := db.Find(&record).Error
+	return record, err
+}
+
+func (slf *ServiceCollectionPlanSearch) SetId(id int) *ServiceCollectionPlanSearch {
+	slf.Id = id
+	return slf
+}
+
+func (slf *ServiceCollectionPlanSearch) SetOrm(tx *gorm.DB) *ServiceCollectionPlanSearch {
+	slf.Orm = tx
+	return slf
+}
+
+func (slf *ServiceCollectionPlanSearch) SetServiceContractId(id int) *ServiceCollectionPlanSearch {
+	slf.ServiceContractId = id
+	return slf
+}
+
+func (slf *ServiceCollectionPlanSearch) First() (*ServiceCollectionPlan, error) {
+	var db = slf.build()
+	var record = new(ServiceCollectionPlan)
+	err := db.First(record).Error
+	return record, err
+}
+
+func (slf *ServiceCollectionPlanSearch) Updates(values interface{}) error {
+	var db = slf.build()
+	return db.Updates(values).Error
+}
+
+func (slf *ServiceCollectionPlanSearch) Save(record *ServiceCollectionPlan) error {
+	if record.Id == 0 {
+		return errors.New("id涓虹┖")
+	}
+	var db = slf.build()
+
+	if err := db.Save(record).Error; err != nil {
+		return fmt.Errorf("save err: %v, record: %+v", err, record)
+	}
+
+	return nil
+}
+
+func (slf *ServiceCollectionPlanSearch) Find() ([]*ServiceCollectionPlan, int64, error) {
+	var db = slf.build()
+	var records = make([]*ServiceCollectionPlan, 0)
+	var total int64
+	if err := db.Count(&total).Error; err != nil {
+		return records, total, err
+	}
+	if slf.PageNum > 0 && slf.PageSize > 0 {
+		db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize)
+	}
+
+	err := db.Find(&records).Error
+	return records, total, err
+}
+
+// InitDefaultData 鍒濆鍖栨暟鎹�
+func (slf *ServiceCollectionPlanSearch) InitDefaultData() error {
+	var (
+		db          = slf.Orm.Table(slf.TableName())
+		total int64 = 0
+	)
+	if err := db.Count(&total).Error; err != nil {
+		return err
+	}
+	if total != 0 {
+		return nil
+	}
+	records := []*ServiceCollectionPlan{}
+	return slf.CreateBatch(records)
+}
diff --git a/router/index.go b/router/index.go
index 506b4ab..635352f 100644
--- a/router/index.go
+++ b/router/index.go
@@ -164,6 +164,9 @@
 		InitPriorityLevelRouter(PrivateGroup)
 		InitServiceTypeRouter(PrivateGroup)
 		InitSeverityRouter(PrivateGroup)
+		InitTimeSpentRouter(PrivateGroup)
+		InitFaultTypeRouter(PrivateGroup)
+		InitServiceCollectionPlanRouter(PrivateGroup)
 	}
 	return Router
 }
diff --git a/router/serviceCollectionPlan.go b/router/serviceCollectionPlan.go
new file mode 100644
index 0000000..68c20f7
--- /dev/null
+++ b/router/serviceCollectionPlan.go
@@ -0,0 +1,17 @@
+package router
+
+import (
+	v1 "aps_crm/api/v1"
+	"github.com/gin-gonic/gin"
+)
+
+func InitServiceCollectionPlanRouter(router *gin.RouterGroup) {
+	ServiceCollectionPlanRouter := router.Group("serviceCollectionPlan")
+	ServiceCollectionPlanApi := v1.ServiceCollectionPlanApi{}
+	{
+		ServiceCollectionPlanRouter.POST("add", ServiceCollectionPlanApi.Add)             // 娣诲姞鏈嶅姟鍚堝悓鏀舵璁″垝
+		ServiceCollectionPlanRouter.DELETE("delete/:id", ServiceCollectionPlanApi.Delete) // 鍒犻櫎鏈嶅姟鍚堝悓鏀舵璁″垝
+		ServiceCollectionPlanRouter.PUT("update", ServiceCollectionPlanApi.Update)        // 鏇存柊鏈嶅姟鍚堝悓鏀舵璁″垝
+		ServiceCollectionPlanRouter.GET("list", ServiceCollectionPlanApi.List)            // 鑾峰彇鏈嶅姟鍚堝悓鏀舵璁″垝鍒楄〃
+	}
+}
diff --git a/service/faq.go b/service/faq.go
index fc9e7ea..bd01165 100644
--- a/service/faq.go
+++ b/service/faq.go
@@ -12,8 +12,8 @@
 	return FaqService{}
 }
 
-func (FaqService) AddFaq(Faq *model.Faq) int {
-	err := model.NewFaqSearch().Create(Faq)
+func (FaqService) AddFaq(faq *model.Faq) int {
+	err := model.NewFaqSearch().Create(faq)
 	if err != nil {
 		return ecode.DBErr
 	}
diff --git a/service/serviceCollectionPlan.go b/service/serviceCollectionPlan.go
new file mode 100644
index 0000000..fdaa235
--- /dev/null
+++ b/service/serviceCollectionPlan.go
@@ -0,0 +1,80 @@
+package service
+
+import (
+	"aps_crm/model"
+	"aps_crm/model/request"
+	"aps_crm/pkg/ecode"
+	"gorm.io/gorm"
+)
+
+type ServiceCollectionPlanService struct{}
+
+func NewServiceCollectionPlanService() ServiceCollectionPlanService {
+	return ServiceCollectionPlanService{}
+}
+
+func (ServiceCollectionPlanService) AddServiceCollectionPlan(serviceCollectionPlan []*model.ServiceCollectionPlan) int {
+	if len(serviceCollectionPlan) == 0 {
+		return ecode.ParamsErr
+	}
+	contractId := serviceCollectionPlan[0].ServiceContractId
+	err := model.WithTransaction(func(db *gorm.DB) error {
+		err := model.NewServiceCollectionPlanSearch().SetOrm(db).SetServiceContractId(contractId).Delete()
+		if err != nil {
+			return err
+		}
+		err = model.NewServiceCollectionPlanSearch().SetOrm(db).CreateBatch(serviceCollectionPlan)
+		if err != nil {
+			return err
+		}
+		return nil
+	})
+
+	if err != nil {
+		return ecode.DBErr
+	}
+
+	return ecode.OK
+}
+
+func (ServiceCollectionPlanService) DeleteServiceCollectionPlan(id int) int {
+	err := model.NewServiceCollectionPlanSearch().SetId(id).Delete()
+	if err != nil {
+		return ecode.DBErr
+	}
+	return ecode.OK
+}
+
+func (ServiceCollectionPlanService) GetServiceCollectionPlanList(contractId int) ([]*model.ServiceCollectionPlan, int64, int) {
+	list, total, err := model.NewServiceCollectionPlanSearch().SetServiceContractId(contractId).Find()
+	if err != nil {
+		return nil, 0, ecode.DBErr
+	}
+
+	return list, total, ecode.OK
+}
+
+func (ServiceCollectionPlanService) UpdateServiceCollectionPlans(ServiceCollectionPlans []*request.UpdateServiceCollectionPlan) int {
+	for _, v := range ServiceCollectionPlans {
+		// check ServiceCollectionPlan exist
+		_, err := model.NewServiceCollectionPlanSearch().SetId(v.Id).First()
+		if err != nil {
+			return ecode.DBErr
+		}
+
+		err = model.NewServiceCollectionPlanSearch().SetId(v.Id).Updates(map[string]interface{}{})
+		if err != nil {
+			return ecode.DBErr
+		}
+	}
+
+	return ecode.OK
+}
+
+func (ServiceCollectionPlanService) UpdateServiceCollectionPlan(serviceCollectionPlan *model.ServiceCollectionPlan) int {
+	err := model.NewServiceCollectionPlanSearch().SetId(serviceCollectionPlan.Id).Save(serviceCollectionPlan)
+	if err != nil {
+		return ecode.DBErr
+	}
+	return ecode.OK
+}

--
Gitblit v1.8.0