liujiandao
2024-01-03 bd379cf89e0091f931cd1db569560dd4fe63ad3b
报价单统计
6个文件已修改
134 ■■■■■ 已修改文件
api/v1/quotation.go 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/quotation.go 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/quotation.go 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/quotation.go
@@ -209,3 +209,30 @@
        Count: int(total),
    })
}
// Statistics
//
//    @Tags        Quotation
//    @Summary    报价单统计
//    @Produce    application/json
//    @Success    200        {object}    contextx.Response{data=map[string]int64}
//    @Router        /api/quotation/statistics [get]
func (con *QuotationApi) Statistics(c *gin.Context) {
    ctx, ok := contextx.NewContext(c, nil)
    if !ok {
        return
    }
    m := make(map[string]int64)
    total, _ := model.NewQuotationSearch(nil).Count()
    m["total"] = total
    //已创建
    created, _ := model.NewQuotationSearch(nil).SetQuotationStatusId(1).Count()
    m["created"] = created
    //已审批
    approved, _ := model.NewQuotationSearch(nil).SetQuotationStatusId(3).Count()
    m["approved"] = approved
    //已接受
    accepted, _ := model.NewQuotationSearch(nil).SetQuotationStatusId(5).Count()
    m["accepted"] = accepted
    ctx.OkWithDetailed(m)
}
docs/docs.go
@@ -5323,6 +5323,40 @@
                }
            }
        },
        "/api/quotation/statistics": {
            "get": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Quotation"
                ],
                "summary": "报价单统计",
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/contextx.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "object",
                                            "additionalProperties": {
                                                "type": "integer"
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/api/quotation/update": {
            "put": {
                "produces": [
docs/swagger.json
@@ -5311,6 +5311,40 @@
                }
            }
        },
        "/api/quotation/statistics": {
            "get": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Quotation"
                ],
                "summary": "报价单统计",
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/contextx.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "object",
                                            "additionalProperties": {
                                                "type": "integer"
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/api/quotation/update": {
            "put": {
                "produces": [
docs/swagger.yaml
@@ -9687,6 +9687,25 @@
      summary: 报价单列表
      tags:
      - Quotation
  /api/quotation/statistics:
    get:
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            allOf:
            - $ref: '#/definitions/contextx.Response'
            - properties:
                data:
                  additionalProperties:
                    type: integer
                  type: object
              type: object
      summary: 报价单统计
      tags:
      - Quotation
  /api/quotation/update:
    put:
      parameters:
model/quotation.go
@@ -65,6 +65,9 @@
    if slf.Number != "" {
        db = db.Where("number = ?", slf.Number)
    }
    if slf.QuotationStatusId != 0 {
        db = db.Where("quotation_status_id = ?", slf.QuotationStatusId)
    }
    if len(slf.SearchMap) > 0 {
        for key, value := range slf.SearchMap {
@@ -134,7 +137,7 @@
        db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize)
    }
    err := db.Preload("Products").Preload("Member").Preload("QuotationStatus").Preload("Client").Preload("Contact").Order("id desc").Find(&records).Error
    err := db.Preload("Products").Preload("Member").Preload("QuotationStatus").Preload("Client").Preload("Contact").Preload("SaleChance").Order("id desc").Find(&records).Error
    return records, total, err
}
@@ -191,7 +194,13 @@
    slf.Number = number
    return slf
}
func (slf *QuotationSearch) SetIds(ids []int) *QuotationSearch {
    slf.Orm = slf.Orm.Where("id in (?)", ids)
    return slf
}
func (slf *QuotationSearch) SetQuotationStatusId(id int) *QuotationSearch {
    slf.QuotationStatusId = id
    return slf
}
router/quotation.go
@@ -11,9 +11,10 @@
    quotationRouter := router.Group("quotation")
    quotationApi := v1.ApiGroup.QuotationApi
    {
        quotationRouter.POST("add", quotationApi.Add)         // 添加报价单
        quotationRouter.DELETE("delete", quotationApi.Delete) // 删除报价单
        quotationRouter.PUT("update", quotationApi.Update)    // 更新报价单
        quotationRouter.POST("list", quotationApi.List)       // 获取报价单列表
        quotationRouter.POST("add", quotationApi.Add)              // 添加报价单
        quotationRouter.DELETE("delete", quotationApi.Delete)      // 删除报价单
        quotationRouter.PUT("update", quotationApi.Update)         // 更新报价单
        quotationRouter.POST("list", quotationApi.List)            // 获取报价单列表
        quotationRouter.GET("statistics", quotationApi.Statistics) // 报价单统计
    }
}