From 5906a2067ff026db4a54817e479222a7e766ae1b Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期三, 02 八月 2023 15:39:04 +0800 Subject: [PATCH] 服务费管理增加查询条件 --- constvar/const.go | 25 +++++ model/serviceFeeManage.go | 83 +++++++++++++--- api/v1/serviceFeeManage.go | 7 model/request/serviceFeeManage.go | 6 + docs/swagger.yaml | 42 ++++++++ docs/docs.go | 50 ++++++++++ docs/swagger.json | 50 ++++++++++ service/serviceFeeManage.go | 9 + 8 files changed, 249 insertions(+), 23 deletions(-) diff --git a/api/v1/serviceFeeManage.go b/api/v1/serviceFeeManage.go index c7b71d5..99f7cad 100644 --- a/api/v1/serviceFeeManage.go +++ b/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), }) -} \ No newline at end of file +} diff --git a/constvar/const.go b/constvar/const.go index a99d452..7ce6076 100644 --- a/constvar/const.go +++ b/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 = "閿�鍞礋璐d汉" + ServiceFeeKeywordCustomerScale ServiceFeeKeywordType = "瀹㈡埛瑙勬ā" + ServiceFeeKeywordClientLevel ServiceFeeKeywordType = "閲嶈绾у埆" + ServiceFeeKeywordCustomerNo ServiceFeeKeywordType = "瀹㈡埛缂栧彿" + ServiceFeeKeywordCustomerStatus ServiceFeeKeywordType = "瀹㈡埛鐘舵��" + ServiceFeeKeywordProductName ServiceFeeKeywordType = "浜у搧鍚嶇О" + ServiceFeeKeywordServiceEndDate ServiceFeeKeywordType = "鏈嶅姟鍒版湡鏃�" +) diff --git a/docs/docs.go b/docs/docs.go index 827d7ce..1eb2d39 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -7144,6 +7144,50 @@ "ServiceContractQueryClassExpiredBefore60Day" ] }, + "constvar.ServiceFeeKeywordType": { + "type": "string", + "enum": [ + "瀹㈡埛鍚嶇О", + "瀹㈡埛绫诲瀷", + "閿�鍞礋璐d汉", + "瀹㈡埛瑙勬ā", + "閲嶈绾у埆", + "瀹㈡埛缂栧彿", + "瀹㈡埛鐘舵��", + "浜у搧鍚嶇О", + "鏈嶅姟鍒版湡鏃�" + ], + "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" } } }, diff --git a/docs/swagger.json b/docs/swagger.json index dadcc4d..5aee0c6 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -7132,6 +7132,50 @@ "ServiceContractQueryClassExpiredBefore60Day" ] }, + "constvar.ServiceFeeKeywordType": { + "type": "string", + "enum": [ + "瀹㈡埛鍚嶇О", + "瀹㈡埛绫诲瀷", + "閿�鍞礋璐d汉", + "瀹㈡埛瑙勬ā", + "閲嶈绾у埆", + "瀹㈡埛缂栧彿", + "瀹㈡埛鐘舵��", + "浜у搧鍚嶇О", + "鏈嶅姟鍒版湡鏃�" + ], + "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" } } }, diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 606e0a6..d9bb2b2 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -57,6 +57,44 @@ - ServiceContractQueryClassExpireAfter60Day - ServiceContractQueryClassExpiredBefore15Day - ServiceContractQueryClassExpiredBefore60Day + constvar.ServiceFeeKeywordType: + enum: + - 瀹㈡埛鍚嶇О + - 瀹㈡埛绫诲瀷 + - 閿�鍞礋璐d汉 + - 瀹㈡埛瑙勬ā + - 閲嶈绾у埆 + - 瀹㈡埛缂栧彿 + - 瀹㈡埛鐘舵�� + - 浜у搧鍚嶇О + - 鏈嶅姟鍒版湡鏃� + 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: diff --git a/model/request/serviceFeeManage.go b/model/request/serviceFeeManage.go index d5713b5..1615448 100644 --- a/model/request/serviceFeeManage.go +++ b/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"` } diff --git a/model/serviceFeeManage.go b/model/serviceFeeManage.go index 16b6ab4..8ebf843 100644 --- a/model/serviceFeeManage.go +++ b/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 -} \ No newline at end of file +} diff --git a/service/serviceFeeManage.go b/service/serviceFeeManage.go index 5afaf9a..9ce313e 100644 --- a/service/serviceFeeManage.go +++ b/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 } -- Gitblit v1.8.0