| | |
| | | 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) |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/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": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/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": [ |
| | |
| | | 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: |
| | |
| | | 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 { |
| | |
| | | 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 |
| | | } |
| | | |
| | |
| | | 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 |
| | | } |
| | |
| | | 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) // 报价单统计 |
| | | } |
| | | } |