fix
wangpengfei
2023-08-08 747e890bdae1e5f894a4959d84853e74017ff91b
fix

improve the advancement function, add the status of advancement in progress and the reason for failure of advancement
10个文件已修改
210 ■■■■■ 已修改文件
api/v1/salesLeads.go 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/client.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/salesLeads.go 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/salesLeads.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pkg/ecode/code.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/salesLeads.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/salesLeads.go 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/salesLeads.go
@@ -162,3 +162,26 @@
        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, &params)
    if !ok {
        return
    }
    errCode := salesLeadsService.PushSalesLeads(params.Id, params.Step, params.Reason)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    ctx.Ok()
}
docs/docs.go
@@ -6682,6 +6682,36 @@
                }
            }
        },
        "/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": [
@@ -11124,6 +11154,9 @@
                "province_id": {
                    "type": "integer"
                },
                "reason": {
                    "type": "string"
                },
                "region": {
                    "$ref": "#/definitions/model.Region"
                },
@@ -13539,6 +13572,7 @@
                    "type": "integer"
                },
                "search_map": {
                    "description": "搜索条件: map[string]interface{}{\"name\": \"xxx\"}; \"not_contact\": 超过15天未联系; \"public_sea\": 公海客户",
                    "type": "object",
                    "additionalProperties": true
                }
@@ -13907,6 +13941,25 @@
                }
            }
        },
        "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": {
docs/swagger.json
@@ -6670,6 +6670,36 @@
                }
            }
        },
        "/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": [
@@ -11112,6 +11142,9 @@
                "province_id": {
                    "type": "integer"
                },
                "reason": {
                    "type": "string"
                },
                "region": {
                    "$ref": "#/definitions/model.Region"
                },
@@ -13527,6 +13560,7 @@
                    "type": "integer"
                },
                "search_map": {
                    "description": "搜索条件: map[string]interface{}{\"name\": \"xxx\"}; \"not_contact\": 超过15天未联系; \"public_sea\": 公海客户",
                    "type": "object",
                    "additionalProperties": true
                }
@@ -13895,6 +13929,25 @@
                }
            }
        },
        "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": {
docs/swagger.yaml
@@ -1189,6 +1189,8 @@
        $ref: '#/definitions/model.Province'
      province_id:
        type: integer
      reason:
        type: string
      region:
        $ref: '#/definitions/model.Region'
      region_id:
@@ -2826,6 +2828,8 @@
        type: integer
      search_map:
        additionalProperties: true
        description: '搜索条件: map[string]interface{}{"name": "xxx"}; "not_contact":
          超过15天未联系; "public_sea": 公海客户'
        type: object
    type: object
  request.GetContactList:
@@ -3076,6 +3080,17 @@
        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:
@@ -9369,6 +9384,25 @@
      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:
model/request/client.go
@@ -30,7 +30,7 @@
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 {
model/request/salesLeads.go
@@ -1,5 +1,7 @@
package request
import "aps_crm/constvar"
type AddSalesLeads struct {
    SalesLeads
}
@@ -29,3 +31,10 @@
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"`
}
model/salesLeads.go
@@ -18,6 +18,7 @@
        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:"-"`
pkg/ecode/code.go
@@ -121,7 +121,7 @@
    SalesLeadsExist     = 1600001 // 销售线索已存在
    SalesLeadsNotExist  = 1600002 // 销售线索不存在
    SalesLeadsListErr   = 1600003 // 获取销售线索列表失败
    SalesLeadsSetErr    = 1600004 // 设置销售线索失败
    SalesLeadsStatusErr = 1600004 // 销售线索状态错误
    SalesLeadsUpdateErr = 1600005 // 更新销售线索失败
    SalesLeadsDeleteErr = 1600006 // 删除销售线索失败
router/salesLeads.go
@@ -15,5 +15,6 @@
        salesLeadsRouter.DELETE("delete", salesLeadsApi.Delete)     // 删除销售线索
        salesLeadsRouter.PUT("update", salesLeadsApi.Update)        // 更新销售线索
        salesLeadsRouter.POST("list", salesLeadsApi.List)            // 获取销售线索列表
        salesLeadsRouter.POST("push", salesLeadsApi.Push)       // 推进销售线索
    }
}
service/salesLeads.go
@@ -1,6 +1,7 @@
package service
import (
    "aps_crm/constvar"
    "aps_crm/model"
    "aps_crm/pkg/ecode"
)
@@ -74,3 +75,34 @@
    }
    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
}