zhangqian
2023-08-02 5906a2067ff026db4a54817e479222a7e766ae1b
服务费管理增加查询条件
8个文件已修改
272 ■■■■■ 已修改文件
api/v1/serviceFeeManage.go 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
constvar/const.go 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/serviceFeeManage.go 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/serviceFeeManage.go 83 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/serviceFeeManage.go 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/serviceFeeManage.go
@@ -113,7 +113,6 @@
    ctx.Ok()
}
// checkServiceFeeManageParams
func checkServiceFeeManageParams(serviceFeeManage request.ServiceFeeManage) (errCode int, result model.ServiceFeeManage) {
    //if serviceFeeManage.ClientId == 0 {
@@ -154,14 +153,14 @@
        return
    }
    serviceFeeManages, total, errCode := serviceFeeManageService.GetServiceFeeManageList(params.Page, params.PageSize, params.Keyword)
    serviceFeeManages, total, errCode := serviceFeeManageService.GetServiceFeeManageList(params.Page, params.PageSize, params.QueryClass, params.KeywordType, params.Keyword)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    ctx.OkWithDetailed(response.ServiceFeeManageResponse{
        List: serviceFeeManages,
        List:  serviceFeeManages,
        Count: int(total),
    })
}
}
constvar/const.go
@@ -102,3 +102,28 @@
    ServiceFollowupKeywordVisitor            ServiceFollowupKeywordType = "回访人"
    ServiceFollowupKeywordSatisfactionDegree ServiceFollowupKeywordType = "满意度"
)
type ServiceFeeQueryClass string
const (
    ServiceFeeQueryClassExpireLessThen60Days ServiceFeeQueryClass = "过期未满60天"
    ServiceFeeQueryClassExpireLessThen30Days ServiceFeeQueryClass = "过期未满30天"
    ServiceFeeQueryClassExpireAboutTo60Day   ServiceFeeQueryClass = "即将过期60天"
    ServiceFeeQueryClassExpireAboutTo30Day   ServiceFeeQueryClass = "即将过期30天"
    ServiceFeeQueryClassExpired              ServiceFeeQueryClass = "已过期"
    ServiceFeeQueryClassNoService            ServiceFeeQueryClass = "无服务"
)
type ServiceFeeKeywordType string
const (
    ServiceFeeKeywordCustomerName   ServiceFeeKeywordType = "客户名称"
    ServiceFeeKeywordCustomerType   ServiceFeeKeywordType = "客户类型"
    ServiceFeeKeywordSalesPrincipal ServiceFeeKeywordType = "销售负责人"
    ServiceFeeKeywordCustomerScale  ServiceFeeKeywordType = "客户规模"
    ServiceFeeKeywordClientLevel    ServiceFeeKeywordType = "重要级别"
    ServiceFeeKeywordCustomerNo     ServiceFeeKeywordType = "客户编号"
    ServiceFeeKeywordCustomerStatus ServiceFeeKeywordType = "客户状态"
    ServiceFeeKeywordProductName    ServiceFeeKeywordType = "产品名称"
    ServiceFeeKeywordServiceEndDate ServiceFeeKeywordType = "服务到期日"
)
docs/docs.go
@@ -7144,6 +7144,50 @@
                "ServiceContractQueryClassExpiredBefore60Day"
            ]
        },
        "constvar.ServiceFeeKeywordType": {
            "type": "string",
            "enum": [
                "客户名称",
                "客户类型",
                "销售负责人",
                "客户规模",
                "重要级别",
                "客户编号",
                "客户状态",
                "产品名称",
                "服务到期日"
            ],
            "x-enum-varnames": [
                "ServiceFeeKeywordCustomerName",
                "ServiceFeeKeywordCustomerType",
                "ServiceFeeKeywordSalesPrincipal",
                "ServiceFeeKeywordCustomerScale",
                "ServiceFeeKeywordClientLevel",
                "ServiceFeeKeywordCustomerNo",
                "ServiceFeeKeywordCustomerStatus",
                "ServiceFeeKeywordProductName",
                "ServiceFeeKeywordServiceEndDate"
            ]
        },
        "constvar.ServiceFeeQueryClass": {
            "type": "string",
            "enum": [
                "过期未满60天",
                "过期未满30天",
                "即将过期60天",
                "即将过期30天",
                "已过期",
                "无服务"
            ],
            "x-enum-varnames": [
                "ServiceFeeQueryClassExpireLessThen60Days",
                "ServiceFeeQueryClassExpireLessThen30Days",
                "ServiceFeeQueryClassExpireAboutTo60Day",
                "ServiceFeeQueryClassExpireAboutTo30Day",
                "ServiceFeeQueryClassExpired",
                "ServiceFeeQueryClassNoService"
            ]
        },
        "constvar.ServiceFollowupKeywordType": {
            "type": "string",
            "enum": [
@@ -10294,6 +10338,9 @@
                "keyword": {
                    "type": "string"
                },
                "keywordType": {
                    "$ref": "#/definitions/constvar.ServiceFeeKeywordType"
                },
                "page": {
                    "description": "页码",
                    "type": "integer"
@@ -10301,6 +10348,9 @@
                "pageSize": {
                    "description": "每页大小",
                    "type": "integer"
                },
                "queryClass": {
                    "$ref": "#/definitions/constvar.ServiceFeeQueryClass"
                }
            }
        },
docs/swagger.json
@@ -7132,6 +7132,50 @@
                "ServiceContractQueryClassExpiredBefore60Day"
            ]
        },
        "constvar.ServiceFeeKeywordType": {
            "type": "string",
            "enum": [
                "客户名称",
                "客户类型",
                "销售负责人",
                "客户规模",
                "重要级别",
                "客户编号",
                "客户状态",
                "产品名称",
                "服务到期日"
            ],
            "x-enum-varnames": [
                "ServiceFeeKeywordCustomerName",
                "ServiceFeeKeywordCustomerType",
                "ServiceFeeKeywordSalesPrincipal",
                "ServiceFeeKeywordCustomerScale",
                "ServiceFeeKeywordClientLevel",
                "ServiceFeeKeywordCustomerNo",
                "ServiceFeeKeywordCustomerStatus",
                "ServiceFeeKeywordProductName",
                "ServiceFeeKeywordServiceEndDate"
            ]
        },
        "constvar.ServiceFeeQueryClass": {
            "type": "string",
            "enum": [
                "过期未满60天",
                "过期未满30天",
                "即将过期60天",
                "即将过期30天",
                "已过期",
                "无服务"
            ],
            "x-enum-varnames": [
                "ServiceFeeQueryClassExpireLessThen60Days",
                "ServiceFeeQueryClassExpireLessThen30Days",
                "ServiceFeeQueryClassExpireAboutTo60Day",
                "ServiceFeeQueryClassExpireAboutTo30Day",
                "ServiceFeeQueryClassExpired",
                "ServiceFeeQueryClassNoService"
            ]
        },
        "constvar.ServiceFollowupKeywordType": {
            "type": "string",
            "enum": [
@@ -10282,6 +10326,9 @@
                "keyword": {
                    "type": "string"
                },
                "keywordType": {
                    "$ref": "#/definitions/constvar.ServiceFeeKeywordType"
                },
                "page": {
                    "description": "页码",
                    "type": "integer"
@@ -10289,6 +10336,9 @@
                "pageSize": {
                    "description": "每页大小",
                    "type": "integer"
                },
                "queryClass": {
                    "$ref": "#/definitions/constvar.ServiceFeeQueryClass"
                }
            }
        },
docs/swagger.yaml
@@ -57,6 +57,44 @@
    - ServiceContractQueryClassExpireAfter60Day
    - ServiceContractQueryClassExpiredBefore15Day
    - ServiceContractQueryClassExpiredBefore60Day
  constvar.ServiceFeeKeywordType:
    enum:
    - 客户名称
    - 客户类型
    - 销售负责人
    - 客户规模
    - 重要级别
    - 客户编号
    - 客户状态
    - 产品名称
    - 服务到期日
    type: string
    x-enum-varnames:
    - ServiceFeeKeywordCustomerName
    - ServiceFeeKeywordCustomerType
    - ServiceFeeKeywordSalesPrincipal
    - ServiceFeeKeywordCustomerScale
    - ServiceFeeKeywordClientLevel
    - ServiceFeeKeywordCustomerNo
    - ServiceFeeKeywordCustomerStatus
    - ServiceFeeKeywordProductName
    - ServiceFeeKeywordServiceEndDate
  constvar.ServiceFeeQueryClass:
    enum:
    - 过期未满60天
    - 过期未满30天
    - 即将过期60天
    - 即将过期30天
    - 已过期
    - 无服务
    type: string
    x-enum-varnames:
    - ServiceFeeQueryClassExpireLessThen60Days
    - ServiceFeeQueryClassExpireLessThen30Days
    - ServiceFeeQueryClassExpireAboutTo60Day
    - ServiceFeeQueryClassExpireAboutTo30Day
    - ServiceFeeQueryClassExpired
    - ServiceFeeQueryClassNoService
  constvar.ServiceFollowupKeywordType:
    enum:
    - 回访单编号
@@ -2162,12 +2200,16 @@
    properties:
      keyword:
        type: string
      keywordType:
        $ref: '#/definitions/constvar.ServiceFeeKeywordType'
      page:
        description: 页码
        type: integer
      pageSize:
        description: 每页大小
        type: integer
      queryClass:
        $ref: '#/definitions/constvar.ServiceFeeQueryClass'
    type: object
  request.GetServiceFollowupList:
    properties:
model/request/serviceFeeManage.go
@@ -1,5 +1,7 @@
package request
import "aps_crm/constvar"
type AddServiceFeeManage struct {
    ServiceFeeManage
    Client
@@ -20,5 +22,7 @@
type GetServiceFeeManageList struct {
    PageInfo
    Keyword string `json:"keyword"`
    QueryClass  constvar.ServiceFeeQueryClass  `json:"queryClass"`
    KeywordType constvar.ServiceFeeKeywordType `json:"keywordType"`
    Keyword     string                         `json:"keyword"`
}
model/serviceFeeManage.go
@@ -1,6 +1,7 @@
package model
import (
    "aps_crm/constvar"
    "aps_crm/pkg/mysqlx"
    "gorm.io/gorm"
    "time"
@@ -20,13 +21,13 @@
    ServiceFeeManageSearch struct {
        ServiceFeeManage
                Orm      *gorm.DB
        Keyword  string
        OrderBy  string
        PageNum  int
        PageSize int
        Orm         *gorm.DB
        QueryClass  constvar.ServiceFeeQueryClass
        KeywordType constvar.ServiceFeeKeywordType
        Keyword     string
        OrderBy     string
        PageNum     int
        PageSize    int
    }
)
@@ -46,14 +47,54 @@
func (slf *ServiceFeeManageSearch) build() *gorm.DB {
    var db = slf.Orm.Model(&ServiceFeeManage{})
    if slf.Keyword != "" {
        db = db.Where("name LIKE ?", "%"+slf.Keyword+"%")
    }
    if slf.Id != 0 {
        db.Where("id = ?", slf.Id)
    }
    if slf.ClientId != 0 {
        db.Where("client_id = ?", slf.ClientId)
    }
    switch slf.QueryClass {
    case constvar.ServiceFeeQueryClassExpireLessThen60Days:
        db = db.Where("latest_date > ? and latest_date < ?", time.Now(), time.Now().AddDate(0, 0, 60))
    case constvar.ServiceFeeQueryClassExpireLessThen30Days:
        db = db.Where("latest_date > ? and latest_date < ?", time.Now(), time.Now().AddDate(0, 0, 30))
    case constvar.ServiceFeeQueryClassExpireAboutTo60Day:
        db = db.Where("latest_date = ?", time.Now().AddDate(0, 0, -60))
    case constvar.ServiceFeeQueryClassExpireAboutTo30Day:
        db = db.Where("latest_date = ?", time.Now().AddDate(0, 0, -30))
    case constvar.ServiceFeeQueryClassExpired:
        db = db.Where("latest_date < ?", time.Now())
    case constvar.ServiceFeeQueryClassNoService:
        db = db.Where("latest_date < ?", time.Now().AddDate(0, 0, -60))
    }
    switch slf.KeywordType {
    case constvar.ServiceFeeKeywordCustomerName:
        db.Joins("left join clients on clients.id = service_fee_manage.client_id")
        db = db.Where("clients.name = ?", slf.Keyword)
    case constvar.ServiceFeeKeywordCustomerType:
        db.Joins("left join clients on clients.id = service_fee_manage.client_id")
        db = db.Where("clients.client_type_id = ?", slf.Keyword)
    case constvar.ServiceFeeKeywordSalesPrincipal:
        db.Joins("left join clients on clients.id = service_fee_manage.client_id")
        db = db.Where("clients.member_id = ?", slf.Keyword)
    case constvar.ServiceFeeKeywordCustomerScale:
        db.Joins("left join clients on clients.id = service_fee_manage.client_id")
        db = db.Where("clients.enterprise_scale_id = ?", slf.Keyword)
    case constvar.ServiceFeeKeywordClientLevel:
        db.Joins("left join clients on clients.id = service_fee_manage.client_id")
        db = db.Where("clients.client_level_id = ?", slf.Keyword)
    case constvar.ServiceFeeKeywordCustomerNo:
        db.Joins("left join clients on clients.id = service_fee_manage.client_id")
        db = db.Where("clients.number = ?", slf.Keyword)
    case constvar.ServiceFeeKeywordCustomerStatus:
        db.Joins("left join clients on clients.id = service_fee_manage.client_id")
        db = db.Where("clients.client_status_id = ?", slf.Keyword)
    case constvar.ServiceFeeKeywordServiceEndDate:
        db = db.Where("latest_date = ?", slf.Keyword)
    case constvar.ServiceFeeKeywordProductName:
        //todo
    }
    return db
@@ -76,6 +117,21 @@
func (slf *ServiceFeeManageSearch) SetId(id int) *ServiceFeeManageSearch {
    slf.Id = id
    return slf
}
func (slf *ServiceFeeManageSearch) SetKeywordType(keyword constvar.ServiceFeeKeywordType) *ServiceFeeManageSearch {
    slf.KeywordType = keyword
    return slf
}
func (slf *ServiceFeeManageSearch) SetQueryClass(queryClass constvar.ServiceFeeQueryClass) *ServiceFeeManageSearch {
    slf.QueryClass = queryClass
    return slf
}
func (slf *ServiceFeeManageSearch) SetKeyword(keyword string) *ServiceFeeManageSearch {
    slf.Keyword = keyword
    return slf
}
@@ -105,11 +161,6 @@
    return records, total, err
}
func (slf *ServiceFeeManageSearch) SetKeyword(keyword string) *ServiceFeeManageSearch {
    slf.Keyword = keyword
    return slf
}
func (slf *ServiceFeeManageSearch) SetPage(page, size int) *ServiceFeeManageSearch {
    slf.PageNum, slf.PageSize = page, size
    return slf
@@ -118,4 +169,4 @@
func (slf *ServiceFeeManageSearch) SetOrder(order string) *ServiceFeeManageSearch {
    slf.OrderBy = order
    return slf
}
}
service/serviceFeeManage.go
@@ -1,6 +1,7 @@
package service
import (
    "aps_crm/constvar"
    "aps_crm/model"
    "aps_crm/pkg/ecode"
    "aps_crm/pkg/mysqlx"
@@ -70,9 +71,13 @@
    return ecode.OK
}
func (FeeManageService) GetServiceFeeManageList(page, pageSize int, keyword string) ([]*model.ServiceFeeManage, int64, int) {
func (FeeManageService) GetServiceFeeManageList(page, pageSize int, queryClass constvar.ServiceFeeQueryClass, keywordType constvar.ServiceFeeKeywordType, keyword string) ([]*model.ServiceFeeManage, int64, int) {
    // get contact list
    contacts, total, err := model.NewServiceFeeManageSearch(nil).SetKeyword(keyword).SetPage(page, pageSize).FindAll()
    contacts, total, err := model.NewServiceFeeManageSearch(nil).
        SetQueryClass(queryClass).
        SetKeywordType(keywordType).
        SetKeyword(keyword).
        SetPage(page, pageSize).FindAll()
    if err != nil {
        return nil, 0, ecode.ServiceFeeManageListErr
    }