fix
improve the advancement function, add the status of advancement in progress and the reason for failure of advancement
| | |
| | | Count: int(total),
|
| | | })
|
| | | }
|
| | | |
| | | // Push |
| | | // |
| | | // @Tags SalesLeads |
| | | // @Summary 推进销售线索 |
| | | // @Produce application/json |
| | | // @Param object body request.PushSalesLeads true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/salesLeads/push [post] |
| | | func (s *SalesLeadsApi) Push(c *gin.Context) { |
| | | var params request.PushSalesLeads |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | errCode := salesLeadsService.PushSalesLeads(params.Id, params.Step, params.Reason) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | ctx.Ok() |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesLeads/push": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SalesLeads" |
| | | ], |
| | | "summary": "推进销售线索", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.PushSalesLeads" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesLeads/update": { |
| | | "put": { |
| | | "produces": [ |
| | |
| | | "province_id": { |
| | | "type": "integer" |
| | | }, |
| | | "reason": { |
| | | "type": "string" |
| | | }, |
| | | "region": { |
| | | "$ref": "#/definitions/model.Region" |
| | | }, |
| | |
| | | "type": "integer" |
| | | }, |
| | | "search_map": { |
| | | "description": "搜索条件: map[string]interface{}{\"name\": \"xxx\"}; \"not_contact\": 超过15天未联系; \"public_sea\": 公海客户", |
| | | "type": "object", |
| | | "additionalProperties": true |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.PushSalesLeads": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "reason": { |
| | | "type": "string" |
| | | }, |
| | | "step": { |
| | | "description": "商机状态: 1: 跟进中; -1:失败", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/constvar.SalesStatus" |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | }, |
| | | "request.Register": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesLeads/push": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SalesLeads" |
| | | ], |
| | | "summary": "推进销售线索", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.PushSalesLeads" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesLeads/update": { |
| | | "put": { |
| | | "produces": [ |
| | |
| | | "province_id": { |
| | | "type": "integer" |
| | | }, |
| | | "reason": { |
| | | "type": "string" |
| | | }, |
| | | "region": { |
| | | "$ref": "#/definitions/model.Region" |
| | | }, |
| | |
| | | "type": "integer" |
| | | }, |
| | | "search_map": { |
| | | "description": "搜索条件: map[string]interface{}{\"name\": \"xxx\"}; \"not_contact\": 超过15天未联系; \"public_sea\": 公海客户", |
| | | "type": "object", |
| | | "additionalProperties": true |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.PushSalesLeads": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "reason": { |
| | | "type": "string" |
| | | }, |
| | | "step": { |
| | | "description": "商机状态: 1: 跟进中; -1:失败", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/constvar.SalesStatus" |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | }, |
| | | "request.Register": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | $ref: '#/definitions/model.Province' |
| | | province_id: |
| | | type: integer |
| | | reason: |
| | | type: string |
| | | region: |
| | | $ref: '#/definitions/model.Region' |
| | | region_id: |
| | |
| | | type: integer |
| | | search_map: |
| | | additionalProperties: true |
| | | description: '搜索条件: map[string]interface{}{"name": "xxx"}; "not_contact": |
| | | 超过15天未联系; "public_sea": 公海客户' |
| | | type: object |
| | | type: object |
| | | request.GetContactList: |
| | |
| | | type: string |
| | | subOrderId: |
| | | type: integer |
| | | type: object |
| | | request.PushSalesLeads: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | reason: |
| | | type: string |
| | | step: |
| | | allOf: |
| | | - $ref: '#/definitions/constvar.SalesStatus' |
| | | description: '商机状态: 1: 跟进中; -1:失败' |
| | | type: object |
| | | request.Register: |
| | | properties: |
| | |
| | | summary: 销售线索列表 |
| | | tags: |
| | | - SalesLeads |
| | | /api/salesLeads/push: |
| | | post: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.PushSalesLeads' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 推进销售线索 |
| | | tags: |
| | | - SalesLeads |
| | | /api/salesLeads/update: |
| | | put: |
| | | parameters: |
| | |
| | |
|
| | | type GetClientList struct {
|
| | | PageInfo
|
| | | SearchMap map[string]interface{} `json:"search_map"`
|
| | | SearchMap map[string]interface{} `json:"search_map"` // 搜索条件: map[string]interface{}{"name": "xxx"}; "not_contact": 超过15天未联系; "public_sea": 公海客户 |
| | | }
|
| | |
|
| | | type DeleteClient struct {
|
| | |
| | | package request
|
| | |
|
| | | import "aps_crm/constvar" |
| | | |
| | | type AddSalesLeads struct {
|
| | | SalesLeads
|
| | | }
|
| | |
| | | type DeleteSalesLeads struct {
|
| | | Ids []int `json:"ids"`
|
| | | }
|
| | | |
| | | // swagger:model PushSalesLeads |
| | | type PushSalesLeads struct { |
| | | Id int `json:"id"` |
| | | Step constvar.SalesStatus `json:"step"` // 商机状态: 1: 跟进中; -1:失败 |
| | | Reason string `json:"reason"` |
| | | } |
| | |
| | | MemberId int `json:"member_id" gorm:"column:member_id;type:int(11);comment:销售负责人ID"`
|
| | | SalesStatus constvar.SalesStatus `json:"sales_status" gorm:"column:sales_status;type:int(11);comment:销售状态"`
|
| | | Desc string `json:"desc" gorm:"column:desc;type:varchar(255);comment:备注"`
|
| | | Reason string `json:"reason" gorm:"column:reason;type:text;comment:失败原因"` |
| | | FollowRecord []FollowRecord `gorm:"foreignKey:SalesLeadsId"`
|
| | | Address
|
| | | gorm.Model `json:"-"`
|
| | |
| | | SalesLeadsExist = 1600001 // 销售线索已存在
|
| | | SalesLeadsNotExist = 1600002 // 销售线索不存在
|
| | | SalesLeadsListErr = 1600003 // 获取销售线索列表失败
|
| | | SalesLeadsSetErr = 1600004 // 设置销售线索失败
|
| | | SalesLeadsStatusErr = 1600004 // 销售线索状态错误 |
| | | SalesLeadsUpdateErr = 1600005 // 更新销售线索失败
|
| | | SalesLeadsDeleteErr = 1600006 // 删除销售线索失败
|
| | |
|
| | |
| | | salesLeadsRouter.DELETE("delete", salesLeadsApi.Delete) // 删除销售线索
|
| | | salesLeadsRouter.PUT("update", salesLeadsApi.Update) // 更新销售线索
|
| | | salesLeadsRouter.POST("list", salesLeadsApi.List) // 获取销售线索列表
|
| | | salesLeadsRouter.POST("push", salesLeadsApi.Push) // 推进销售线索 |
| | | }
|
| | | } |
| | |
| | | package service
|
| | |
|
| | | import (
|
| | | "aps_crm/constvar" |
| | | "aps_crm/model"
|
| | | "aps_crm/pkg/ecode"
|
| | | )
|
| | |
| | | }
|
| | | return ecode.OK
|
| | | }
|
| | | |
| | | func (SalesLeadsService) PushSalesLeads(id int, step constvar.SalesStatus, txt string) int { |
| | | // check salesLeads exist |
| | | errCode := CheckSalesLeadsExist(id) |
| | | if errCode != ecode.OK { |
| | | return errCode |
| | | } |
| | | |
| | | switch step { |
| | | case constvar.SalesStatusFail: |
| | | err := model.NewSalesLeadsSearch(nil).SetId(id).UpdateMap(map[string]interface{}{ |
| | | "sales_status": constvar.SalesStatusFail, |
| | | "reason": txt, |
| | | }) |
| | | if err != nil { |
| | | return ecode.SalesLeadsUpdateErr |
| | | } |
| | | case constvar.SalesStatusIng: |
| | | err := model.NewSalesLeadsSearch(nil).SetId(id).UpdateMap(map[string]interface{}{ |
| | | "sales_status": constvar.SalesStatusIng, |
| | | }) |
| | | if err != nil { |
| | | return ecode.SalesLeadsUpdateErr |
| | | } |
| | | return ecode.OK |
| | | default: |
| | | return ecode.SalesLeadsStatusErr |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |