zhangqian
2023-08-05 a5ccc6b321a3127ca064b935e42db44428c41305
服务合同收款计划增删改查接口
6个文件已添加
6个文件已修改
1206 ■■■■■ 已修改文件
api/v1/faq.go 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/serviceCollectionPlan.go 112 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
constvar/serviceCollectionPlan.go 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 299 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 299 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 199 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/serviceCollectionPlan.go 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/serviceCollectionPlan.go 159 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/index.go 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/serviceCollectionPlan.go 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/faq.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/serviceCollectionPlan.go 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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
    }
api/v1/serviceCollectionPlan.go
New file
@@ -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,
    })
}
constvar/serviceCollectionPlan.go
New file
@@ -0,0 +1,12 @@
package constvar
type ServiceCollectionPlanQueryClass string
const (
    ServiceCollectionPlanQueryClassExpireLessThen60Days ServiceCollectionPlanQueryClass = ""
)
type ServiceCollectionPlanKeywordType string
const (
    ServiceCollectionPlanKeywordCustomerName   ServiceCollectionPlanKeywordType = ""
)
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": "收款负责人ID",
                    "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": "收款负责人ID",
                    "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": {
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": "收款负责人ID",
                    "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": "收款负责人ID",
                    "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": {
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: 收款负责人ID
        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: 收款负责人ID
        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:
model/request/serviceCollectionPlan.go
New file
@@ -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
}
model/serviceCollectionPlan.go
New file
@@ -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"`              // 收款负责人ID
        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)
}
router/index.go
@@ -164,6 +164,9 @@
        InitPriorityLevelRouter(PrivateGroup)
        InitServiceTypeRouter(PrivateGroup)
        InitSeverityRouter(PrivateGroup)
        InitTimeSpentRouter(PrivateGroup)
        InitFaultTypeRouter(PrivateGroup)
        InitServiceCollectionPlanRouter(PrivateGroup)
    }
    return Router
}
router/serviceCollectionPlan.go
New file
@@ -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)            // 获取服务合同收款计划列表
    }
}
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
    }
service/serviceCollectionPlan.go
New file
@@ -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
}