fix
fix search criteria to quotaion
| | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | |
| | | // checkMasterOrderParams |
| | | // 检查主订单参数 |
| | | func checkMasterOrderParams(masterOrder request.MasterOrder) (errCode int, masterOrderModel model.MasterOrder) { |
| | |
| | | return |
| | | } |
| | | |
| | | masterOrders, total, errCode := masterOrderService.GetMasterOrderList(params.Page, params.PageSize, params.Keyword) |
| | | masterOrders, total, errCode := masterOrderService.GetMasterOrderList(params.Page, params.PageSize, params.SearchMap) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.OkWithDetailed(response.MasterOrderResponse{ |
| | | List: masterOrders, |
| | | List: masterOrders, |
| | | Count: int(total), |
| | | }) |
| | | } |
| | | } |
| | |
| | | "serviceOrderStatus": { |
| | | "$ref": "#/definitions/model.ServiceOrderStatus" |
| | | }, |
| | | "serviceOrderStatusId": { |
| | | "description": "处理状态", |
| | | "type": "integer" |
| | | }, |
| | | "serviceType": { |
| | | "$ref": "#/definitions/model.ServiceType" |
| | | }, |
| | |
| | | "solutionRemark": { |
| | | "description": "内部备注", |
| | | "type": "string" |
| | | }, |
| | | "status": { |
| | | "description": "处理状态", |
| | | "type": "integer" |
| | | }, |
| | | "subject": { |
| | | "description": "主题", |
| | |
| | | "description": "服务单编号", |
| | | "type": "string" |
| | | }, |
| | | "serviceOrderStatusId": { |
| | | "description": "处理状态", |
| | | "type": "integer" |
| | | }, |
| | | "serviceTypeId": { |
| | | "description": "服务方式id", |
| | | "type": "integer" |
| | |
| | | "solutionRemark": { |
| | | "description": "内部备注", |
| | | "type": "string" |
| | | }, |
| | | "status": { |
| | | "description": "处理状态", |
| | | "type": "integer" |
| | | }, |
| | | "subject": { |
| | | "description": "主题", |
| | |
| | | "request.GetMasterOrderList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "keyword": { |
| | | "type": "string" |
| | | }, |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | }, |
| | | "search_map": { |
| | | "description": "搜索条件: map[string]interface{}{\"name\": \"xxx\"}; {\"number\": \"销售总单号\", \"client_name\": \"客户名称\", \"member_name\": \"销售负责人\", \"start_time\": \"开始时间\", \"end_time\": \"结束时间\", \"money\": \"总金额\", \"member_name\": \"负责人\"}", |
| | | "type": "object", |
| | | "additionalProperties": true |
| | | } |
| | | } |
| | | }, |
| | |
| | | "type": "integer" |
| | | }, |
| | | "searchMap": { |
| | | "description": "搜索条件: map[string]interface{}{\"name\": \"xxx\"}; {\"sale_chance_id\": 销售线索id}", |
| | | "description": "搜索条件: map[string]interface{}{\"name\": \"xxx\"}; {\"sale_chance_id\": 销售线索id, \"client_name\": \"客户名称\", \"member_name\": \"销售负责人\", \"contact_name\": \"联系人\", \"validity_date\": \"有效期\"}", |
| | | "type": "object", |
| | | "additionalProperties": true |
| | | } |
| | |
| | | "description": "服务单编号", |
| | | "type": "string" |
| | | }, |
| | | "serviceOrderStatusId": { |
| | | "description": "处理状态", |
| | | "type": "integer" |
| | | }, |
| | | "serviceTypeId": { |
| | | "description": "服务方式id", |
| | | "type": "integer" |
| | |
| | | "solutionRemark": { |
| | | "description": "内部备注", |
| | | "type": "string" |
| | | }, |
| | | "status": { |
| | | "description": "处理状态", |
| | | "type": "integer" |
| | | }, |
| | | "subject": { |
| | | "description": "主题", |
| | |
| | | "serviceOrderStatus": { |
| | | "$ref": "#/definitions/model.ServiceOrderStatus" |
| | | }, |
| | | "serviceOrderStatusId": { |
| | | "description": "处理状态", |
| | | "type": "integer" |
| | | }, |
| | | "serviceType": { |
| | | "$ref": "#/definitions/model.ServiceType" |
| | | }, |
| | |
| | | "solutionRemark": { |
| | | "description": "内部备注", |
| | | "type": "string" |
| | | }, |
| | | "status": { |
| | | "description": "处理状态", |
| | | "type": "integer" |
| | | }, |
| | | "subject": { |
| | | "description": "主题", |
| | |
| | | "description": "服务单编号", |
| | | "type": "string" |
| | | }, |
| | | "serviceOrderStatusId": { |
| | | "description": "处理状态", |
| | | "type": "integer" |
| | | }, |
| | | "serviceTypeId": { |
| | | "description": "服务方式id", |
| | | "type": "integer" |
| | |
| | | "solutionRemark": { |
| | | "description": "内部备注", |
| | | "type": "string" |
| | | }, |
| | | "status": { |
| | | "description": "处理状态", |
| | | "type": "integer" |
| | | }, |
| | | "subject": { |
| | | "description": "主题", |
| | |
| | | "request.GetMasterOrderList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "keyword": { |
| | | "type": "string" |
| | | }, |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | }, |
| | | "search_map": { |
| | | "description": "搜索条件: map[string]interface{}{\"name\": \"xxx\"}; {\"number\": \"销售总单号\", \"client_name\": \"客户名称\", \"member_name\": \"销售负责人\", \"start_time\": \"开始时间\", \"end_time\": \"结束时间\", \"money\": \"总金额\", \"member_name\": \"负责人\"}", |
| | | "type": "object", |
| | | "additionalProperties": true |
| | | } |
| | | } |
| | | }, |
| | |
| | | "type": "integer" |
| | | }, |
| | | "searchMap": { |
| | | "description": "搜索条件: map[string]interface{}{\"name\": \"xxx\"}; {\"sale_chance_id\": 销售线索id}", |
| | | "description": "搜索条件: map[string]interface{}{\"name\": \"xxx\"}; {\"sale_chance_id\": 销售线索id, \"client_name\": \"客户名称\", \"member_name\": \"销售负责人\", \"contact_name\": \"联系人\", \"validity_date\": \"有效期\"}", |
| | | "type": "object", |
| | | "additionalProperties": true |
| | | } |
| | |
| | | "description": "服务单编号", |
| | | "type": "string" |
| | | }, |
| | | "serviceOrderStatusId": { |
| | | "description": "处理状态", |
| | | "type": "integer" |
| | | }, |
| | | "serviceTypeId": { |
| | | "description": "服务方式id", |
| | | "type": "integer" |
| | |
| | | "solutionRemark": { |
| | | "description": "内部备注", |
| | | "type": "string" |
| | | }, |
| | | "status": { |
| | | "description": "处理状态", |
| | | "type": "integer" |
| | | }, |
| | | "subject": { |
| | | "description": "主题", |
| | |
| | | type: string |
| | | serviceOrderStatus: |
| | | $ref: '#/definitions/model.ServiceOrderStatus' |
| | | serviceOrderStatusId: |
| | | description: 处理状态 |
| | | type: integer |
| | | serviceType: |
| | | $ref: '#/definitions/model.ServiceType' |
| | | serviceTypeId: |
| | |
| | | solutionRemark: |
| | | description: 内部备注 |
| | | type: string |
| | | status: |
| | | description: 处理状态 |
| | | type: integer |
| | | subject: |
| | | description: 主题 |
| | | type: string |
| | |
| | | serviceNumber: |
| | | description: 服务单编号 |
| | | type: string |
| | | serviceOrderStatusId: |
| | | description: 处理状态 |
| | | type: integer |
| | | serviceTypeId: |
| | | description: 服务方式id |
| | | type: integer |
| | |
| | | solutionRemark: |
| | | description: 内部备注 |
| | | type: string |
| | | status: |
| | | description: 处理状态 |
| | | type: integer |
| | | subject: |
| | | description: 主题 |
| | | type: string |
| | |
| | | type: object |
| | | request.GetMasterOrderList: |
| | | properties: |
| | | keyword: |
| | | type: string |
| | | page: |
| | | description: 页码 |
| | | type: integer |
| | | pageSize: |
| | | description: 每页大小 |
| | | type: integer |
| | | search_map: |
| | | additionalProperties: true |
| | | description: '搜索条件: map[string]interface{}{"name": "xxx"}; {"number": "销售总单号", |
| | | "client_name": "客户名称", "member_name": "销售负责人", "start_time": "开始时间", "end_time": |
| | | "结束时间", "money": "总金额", "member_name": "负责人"}' |
| | | type: object |
| | | type: object |
| | | request.GetOrderManageList: |
| | | properties: |
| | |
| | | searchMap: |
| | | additionalProperties: true |
| | | description: '搜索条件: map[string]interface{}{"name": "xxx"}; {"sale_chance_id": |
| | | 销售线索id}' |
| | | 销售线索id, "client_name": "客户名称", "member_name": "销售负责人", "contact_name": "联系人", |
| | | "validity_date": "有效期"}' |
| | | type: object |
| | | type: object |
| | | request.GetSaleChanceList: |
| | |
| | | serviceNumber: |
| | | description: 服务单编号 |
| | | type: string |
| | | serviceOrderStatusId: |
| | | description: 处理状态 |
| | | type: integer |
| | | serviceTypeId: |
| | | description: 服务方式id |
| | | type: integer |
| | |
| | | solutionRemark: |
| | | description: 内部备注 |
| | | type: string |
| | | status: |
| | | description: 处理状态 |
| | | type: integer |
| | | subject: |
| | | description: 主题 |
| | | type: string |
| | |
| | | MasterOrderSearch struct { |
| | | MasterOrder |
| | | |
| | | Orm *gorm.DB |
| | | Keyword string |
| | | OrderBy string |
| | | PageNum int |
| | | PageSize int |
| | | Orm *gorm.DB |
| | | SearchMap map[string]interface{} |
| | | OrderBy string |
| | | PageNum int |
| | | PageSize int |
| | | } |
| | | ) |
| | | |
| | |
| | | |
| | | func (slf *MasterOrderSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&MasterOrder{}) |
| | | if slf.Keyword != "" { |
| | | db = db.Where("name LIKE ?", "%"+slf.Keyword+"%") |
| | | } |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | | |
| | | if len(slf.SearchMap) > 0 { |
| | | for key, value := range slf.SearchMap { |
| | | switch v := value.(type) { |
| | | case string: |
| | | if key == "number" || key == "start_time" || key == "end_time" { |
| | | db = db.Where(key+" = ?", v) |
| | | } |
| | | |
| | | if key == "client_name" { |
| | | db = db.Joins("Client").Where("client.name = ?", v) |
| | | } |
| | | |
| | | if key == "member_name" { |
| | | db = db.Joins("User").Where("User.username = ?", v) |
| | | } |
| | | case int: |
| | | case float64: |
| | | if key == "client_id" || key == "member_id" || key == "money" { |
| | | db = db.Where(key+" = ?", v) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | return db |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *MasterOrderSearch) SetKeyword(keyword string) *MasterOrderSearch { |
| | | slf.Keyword = keyword |
| | | return slf |
| | | } |
| | | |
| | | func (slf *MasterOrderSearch) SetPage(page, size int) *MasterOrderSearch { |
| | | slf.PageNum, slf.PageSize = page, size |
| | | return slf |
| | |
| | | slf.OrderBy = order |
| | | return slf |
| | | } |
| | | |
| | | func (slf *MasterOrderSearch) SetSearchMap(searchMap map[string]interface{}) *MasterOrderSearch { |
| | | slf.SearchMap = searchMap |
| | | return slf |
| | | } |
| | |
| | | for key, value := range slf.SearchMap { |
| | | switch v := value.(type) { |
| | | case string: |
| | | if key == "validity_date" || key == "number" { |
| | | db = db.Where(key+" = ?", v) |
| | | } |
| | | |
| | | if key == "client_name" { |
| | | db = db.Joins("Client").Where("client.name = ?", v) |
| | | } |
| | | |
| | | if key == "contact_name" { |
| | | db = db.Joins("Contact").Where("contact.name = ?", v) |
| | | } |
| | | |
| | | if key == "validity_date" { |
| | | db = db.Where(key+" = ?", v) |
| | | } |
| | | |
| | | case int: |
| | | if key == "client_id" || key == "sale_chance_id" { |
| | | db = db.Where(key+" = ?", v) |
| | |
| | | |
| | | type GetMasterOrderList struct { |
| | | PageInfo |
| | | Keyword string `json:"keyword"` |
| | | SearchMap map[string]interface{} `json:"search_map"` // 搜索条件: map[string]interface{}{"name": "xxx"}; {"number": "销售总单号", "client_name": "客户名称", "member_name": "销售负责人", "start_time": "开始时间", "end_time": "结束时间", "money": "总金额", "member_name": "负责人"} |
| | | } |
| | |
| | | |
| | | type GetQuotationList struct { |
| | | PageInfo |
| | | SearchMap map[string]interface{} // 搜索条件: map[string]interface{}{"name": "xxx"}; {"sale_chance_id": 销售线索id} |
| | | SearchMap map[string]interface{} // 搜索条件: map[string]interface{}{"name": "xxx"}; {"sale_chance_id": 销售线索id, "client_name": "客户名称", "member_name": "销售负责人", "contact_name": "联系人", "validity_date": "有效期"} |
| | | } |
| | |
| | | } |
| | | |
| | | if key == "member_name" { |
| | | db = db.Joins("User").Where("User.name LIKE ?", "%"+v+"%") |
| | | db = db.Joins("User").Where("User.username LIKE ?", "%"+v+"%") |
| | | } |
| | | |
| | | if key == "sale_stage" { |
| | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (MasterOrderService) GetMasterOrderList(page, pageSize int, keyword string) ([]*model.MasterOrder, int64, int) { |
| | | func (MasterOrderService) GetMasterOrderList(page, pageSize int, data map[string]interface{}) ([]*model.MasterOrder, int64, int) { |
| | | // get contact list |
| | | contacts, total, err := model.NewMasterOrderSearch().SetKeyword(keyword).SetPage(page, pageSize).FindAll() |
| | | contacts, total, err := model.NewMasterOrderSearch().SetPage(page, pageSize).SetSearchMap(data).FindAll() |
| | | if err != nil { |
| | | return nil, 0, ecode.MasterOrderListErr |
| | | } |