| | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | |
| | | // checkServiceFeeManageParams |
| | | func checkServiceFeeManageParams(serviceFeeManage request.ServiceFeeManage) (errCode int, result model.ServiceFeeManage) { |
| | | //if serviceFeeManage.ClientId == 0 { |
| | |
| | | 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), |
| | | }) |
| | | } |
| | | } |
| | |
| | | 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 = "服务到期日" |
| | | ) |
| | |
| | | "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": [ |
| | |
| | | "keyword": { |
| | | "type": "string" |
| | | }, |
| | | "keywordType": { |
| | | "$ref": "#/definitions/constvar.ServiceFeeKeywordType" |
| | | }, |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | }, |
| | | "queryClass": { |
| | | "$ref": "#/definitions/constvar.ServiceFeeQueryClass" |
| | | } |
| | | } |
| | | }, |
| | |
| | | "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": [ |
| | |
| | | "keyword": { |
| | | "type": "string" |
| | | }, |
| | | "keywordType": { |
| | | "$ref": "#/definitions/constvar.ServiceFeeKeywordType" |
| | | }, |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | }, |
| | | "queryClass": { |
| | | "$ref": "#/definitions/constvar.ServiceFeeQueryClass" |
| | | } |
| | | } |
| | | }, |
| | |
| | | - 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: |
| | | - 回访单编号 |
| | |
| | | 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: |
| | |
| | | package request |
| | | |
| | | import "aps_crm/constvar" |
| | | |
| | | type AddServiceFeeManage struct { |
| | | ServiceFeeManage |
| | | Client |
| | |
| | | |
| | | type GetServiceFeeManageList struct { |
| | | PageInfo |
| | | Keyword string `json:"keyword"` |
| | | QueryClass constvar.ServiceFeeQueryClass `json:"queryClass"` |
| | | KeywordType constvar.ServiceFeeKeywordType `json:"keywordType"` |
| | | Keyword string `json:"keyword"` |
| | | } |
| | |
| | | package model |
| | | |
| | | import ( |
| | | "aps_crm/constvar" |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | "time" |
| | |
| | | |
| | | 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 |
| | | } |
| | | ) |
| | | |
| | |
| | | |
| | | 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 |
| | |
| | | |
| | | 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 |
| | | } |
| | | |
| | |
| | | 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 |
| | |
| | | func (slf *ServiceFeeManageSearch) SetOrder(order string) *ServiceFeeManageSearch { |
| | | slf.OrderBy = order |
| | | return slf |
| | | } |
| | | } |
| | |
| | | package service |
| | | |
| | | import ( |
| | | "aps_crm/constvar" |
| | | "aps_crm/model" |
| | | "aps_crm/pkg/ecode" |
| | | "aps_crm/pkg/mysqlx" |
| | |
| | | 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 |
| | | } |