正在显示
8 个修改的文件
包含
187 行增加
和
26 行删除
| @@ -686,6 +686,35 @@ func (this *ChanceController) SiftingPool() { | @@ -686,6 +686,35 @@ func (this *ChanceController) SiftingPool() { | ||
| 686 | msg = m | 686 | msg = m |
| 687 | return | 687 | return |
| 688 | } | 688 | } |
| 689 | + if request.SubmitStatus == protocol.Submiting { | ||
| 690 | + request.SiftedStatus = protocol.None | ||
| 691 | + } else if request.SubmitStatus == protocol.Submited { | ||
| 692 | + request.SiftedStatus = protocol.Waiting | ||
| 693 | + } else { | ||
| 694 | + msg = protocol.BadRequestParamWithMessage(2, "obj.SubmitStatus must in (0,1)") | ||
| 695 | + return | ||
| 696 | + } | ||
| 689 | header := controllers.GetRequestHeader(this.Ctx) | 697 | header := controllers.GetRequestHeader(this.Ctx) |
| 690 | msg = protocol.NewReturnResponse(chance.SiftingPool(header, request)) | 698 | msg = protocol.NewReturnResponse(chance.SiftingPool(header, request)) |
| 691 | } | 699 | } |
| 700 | + | ||
| 701 | +//SiftingResults 筛选结果 | ||
| 702 | +//@router /siftingResults [post] | ||
| 703 | +func (this *ChanceController) SiftingResults() { | ||
| 704 | + var msg *protocol.ResponseMessage | ||
| 705 | + defer func() { | ||
| 706 | + this.Resp(msg) | ||
| 707 | + }() | ||
| 708 | + var request *protocol.SiftingResultsRequest | ||
| 709 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
| 710 | + log.Error(err) | ||
| 711 | + msg = protocol.BadRequestParam(1) | ||
| 712 | + return | ||
| 713 | + } | ||
| 714 | + if b, m := this.Valid(request); !b { | ||
| 715 | + msg = m | ||
| 716 | + return | ||
| 717 | + } | ||
| 718 | + header := controllers.GetRequestHeader(this.Ctx) | ||
| 719 | + msg = protocol.NewReturnResponse(chance.SiftingResults(header, request)) | ||
| 720 | +} |
| @@ -687,23 +687,21 @@ and department_id in (%v)`, | @@ -687,23 +687,21 @@ and department_id in (%v)`, | ||
| 687 | func GetSiftingChance(uid int64, submitStatus int, checkResultStatus int, offset int, pageSize int, v interface{}) (total int, err error) { | 687 | func GetSiftingChance(uid int64, submitStatus int, checkResultStatus int, offset int, pageSize int, v interface{}) (total int, err error) { |
| 688 | var where string | 688 | var where string |
| 689 | if submitStatus == 1 { | 689 | if submitStatus == 1 { |
| 690 | - where = fmt.Sprintf(`where length(self_checks)>5 | ||
| 691 | -order by a.submit_check_time desc`) | 690 | + where = fmt.Sprintf(`order by a.submit_check_time desc`) |
| 692 | } else { | 691 | } else { |
| 693 | - where = fmt.Sprintf(`where length(self_checks)>5 | ||
| 694 | -order by a.chance_approve_time desc`) | 692 | + where = fmt.Sprintf(`order by a.chance_approve_time desc`) |
| 695 | } | 693 | } |
| 696 | sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos | 694 | sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos |
| 697 | from ( | 695 | from ( |
| 698 | select a.*,b.user_id chance_user_id,b.source_content,b.enable_status,b.review_status,b.audit_template_id,b.chance_type_id,b.create_at, | 696 | select a.*,b.user_id chance_user_id,b.source_content,b.enable_status,b.review_status,b.audit_template_id,b.chance_type_id,b.create_at, |
| 699 | - b.update_at,b.approve_time chance_approve_time,b.status,b.self_checks,b.check_result_status | 697 | + b.update_at,b.approve_time chance_approve_time,b.status,b.self_checks,b.check_result_status,b.check_time |
| 700 | from ( | 698 | from ( |
| 701 | select max(id) id,approve_time,approve_data,uid,chance_id,submit_check_status,submit_check_time,level | 699 | select max(id) id,approve_time,approve_data,uid,chance_id,submit_check_status,submit_check_time,level |
| 702 | from audit_flow_process a,(select MAX(id) AS max_id from audit_flow_process as t where t.uid=%v group by chance_id) b | 700 | from audit_flow_process a,(select MAX(id) AS max_id from audit_flow_process as t where t.uid=%v group by chance_id) b |
| 703 | where a.uid=%v and b.max_id=a.id and a.submit_check_status=%v and level>0 | 701 | where a.uid=%v and b.max_id=a.id and a.submit_check_status=%v and level>0 |
| 704 | GROUP BY chance_id | 702 | GROUP BY chance_id |
| 705 | )a left outer join chance b on a.chance_id = b.id | 703 | )a left outer join chance b on a.chance_id = b.id |
| 706 | - where b.review_status=3 and b.enable_status=1 and b.status=1 and b.check_result_status =%v and a.level=b.audit_level | 704 | + where b.review_status=3 and b.enable_status=1 and b.status=1 and b.check_result_status =%v and a.level=b.audit_level and length(b.self_checks)>5 |
| 707 | )a left outer join chance_data b on a.chance_id =b.chance_id | 705 | )a left outer join chance_data b on a.chance_id =b.chance_id |
| 708 | %v | 706 | %v |
| 709 | limit %v,%v`, uid, uid, submitStatus, checkResultStatus, where, offset, pageSize) //,update_at process_create_time | 707 | limit %v,%v`, uid, uid, submitStatus, checkResultStatus, where, offset, pageSize) //,update_at process_create_time |
| @@ -718,9 +716,51 @@ from ( | @@ -718,9 +716,51 @@ from ( | ||
| 718 | where a.uid=%v and b.max_id=a.id and a.submit_check_status=%v and level>0 | 716 | where a.uid=%v and b.max_id=a.id and a.submit_check_status=%v and level>0 |
| 719 | GROUP BY chance_id | 717 | GROUP BY chance_id |
| 720 | )a left outer join chance b on a.chance_id = b.id | 718 | )a left outer join chance b on a.chance_id = b.id |
| 719 | + where b.review_status=3 and b.enable_status=1 and b.status=1 and b.check_result_status =%v and a.level=b.audit_level and length(b.self_checks)>5 | ||
| 720 | +)a | ||
| 721 | +`, uid, uid, submitStatus, checkResultStatus) //and enable_status =1 | ||
| 722 | + if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil { | ||
| 723 | + return | ||
| 724 | + } | ||
| 725 | + if v != nil { | ||
| 726 | + if err = utils.ExecuteQueryAll(v, sql); err != nil { | ||
| 727 | + return | ||
| 728 | + } | ||
| 729 | + } | ||
| 730 | + return | ||
| 731 | +} | ||
| 732 | + | ||
| 733 | +//获取筛选结果的机会 | ||
| 734 | +//@submitStatus 提交状态:已提交 未提交 | ||
| 735 | +//@checkResultStatus 筛选结果状态:通过 / 不通过 | ||
| 736 | +func GetSiftingResults(uid int64, submitStatus, checkResultStatus int, offset int, pageSize int, v interface{}) (total int, err error) { | ||
| 737 | + sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos | ||
| 738 | +from ( | ||
| 739 | + select a.*,b.user_id chance_user_id,b.source_content,b.enable_status,b.review_status,b.audit_template_id,b.chance_type_id,b.create_at, | ||
| 740 | + b.update_at,b.approve_time chance_approve_time,b.status,b.self_checks,b.check_result_status,b.check_time | ||
| 741 | + from ( | ||
| 742 | + select max(id) id,approve_time,approve_data,uid,chance_id,submit_check_status,submit_check_time,level | ||
| 743 | + from audit_flow_process a,(select MAX(id) AS max_id from audit_flow_process as t where t.uid=%v group by chance_id) b | ||
| 744 | + where a.uid=%v and b.max_id=a.id and a.submit_check_status=%v and level>0 | ||
| 745 | + GROUP BY chance_id | ||
| 746 | + )a left outer join chance b on a.chance_id = b.id | ||
| 747 | + where b.review_status=3 and b.enable_status=1 and b.status=1 and b.check_result_status =%v and a.level=b.audit_level | ||
| 748 | +)a left outer join chance_data b on a.chance_id =b.chance_id | ||
| 749 | +order by a.check_time desc | ||
| 750 | +limit %v,%v`, uid, uid, submitStatus, checkResultStatus, offset, pageSize) //,update_at process_create_time | ||
| 751 | + | ||
| 752 | + sqlCount := fmt.Sprintf(`select count(0) | ||
| 753 | +from ( | ||
| 754 | + select a.*,b.user_id chance_user_id,b.source_content,b.enable_status,b.review_status,b.create_at, | ||
| 755 | + b.update_at,b.approve_time chance_approve_time,b.status,b.self_checks,b.check_result_status | ||
| 756 | + from ( | ||
| 757 | + select max(id) id,approve_time,approve_data,uid,chance_id,submit_check_status,submit_check_time,level | ||
| 758 | + from audit_flow_process a,(select MAX(id) AS max_id from audit_flow_process as t where t.uid=%v group by chance_id) b | ||
| 759 | + where a.uid=%v and b.max_id=a.id and a.submit_check_status=%v and level>0 | ||
| 760 | + GROUP BY chance_id | ||
| 761 | + )a left outer join chance b on a.chance_id = b.id | ||
| 721 | where b.review_status=3 and b.enable_status=1 and b.status=1 and b.check_result_status =%v and a.level=b.audit_level | 762 | where b.review_status=3 and b.enable_status=1 and b.status=1 and b.check_result_status =%v and a.level=b.audit_level |
| 722 | )a | 763 | )a |
| 723 | -where length(self_checks)>5 | ||
| 724 | `, uid, uid, submitStatus, checkResultStatus) //and enable_status =1 | 764 | `, uid, uid, submitStatus, checkResultStatus) //and enable_status =1 |
| 725 | if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil { | 765 | if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil { |
| 726 | return | 766 | return |
| @@ -377,6 +377,9 @@ type CommChanceItemOrm struct { | @@ -377,6 +377,9 @@ type CommChanceItemOrm struct { | ||
| 377 | CommentTotal int `orm:"column(comment_total)"` | 377 | CommentTotal int `orm:"column(comment_total)"` |
| 378 | ZanTotal int `orm:"column(zan_total)"` | 378 | ZanTotal int `orm:"column(zan_total)"` |
| 379 | ViewTotal int `orm:"column(view_total)"` | 379 | ViewTotal int `orm:"column(view_total)"` |
| 380 | + | ||
| 381 | + TemplateId int `orm:"column(audit_template_id)"` | ||
| 382 | + ChanceTypeId int `orm:"column(chance_type_id)"` | ||
| 380 | } | 383 | } |
| 381 | 384 | ||
| 382 | /*ChanceDetail 机会详情*/ | 385 | /*ChanceDetail 机会详情*/ |
| @@ -671,3 +674,14 @@ type ChanceSiftItemOrm struct { | @@ -671,3 +674,14 @@ type ChanceSiftItemOrm struct { | ||
| 671 | 674 | ||
| 672 | SubmitCheckTime time.Time `orm:"column(submit_check_time)"` //提交自查时间 | 675 | SubmitCheckTime time.Time `orm:"column(submit_check_time)"` //提交自查时间 |
| 673 | } | 676 | } |
| 677 | + | ||
| 678 | +//机会池筛选项 | ||
| 679 | +type ChanceSiftResultOrm struct { | ||
| 680 | + CommChanceItemOrm | ||
| 681 | + | ||
| 682 | + //ApproveData string `json:"approveData"` //审核数据 | ||
| 683 | + TemplateId int `orm:"column(audit_template_id)"` | ||
| 684 | + ChanceTypeId int `orm:"column(chance_type_id)"` | ||
| 685 | + | ||
| 686 | + CheckTime time.Time `orm:"column(check_time)"` //通过时间时间 | ||
| 687 | +} |
| @@ -10,8 +10,8 @@ import ( | @@ -10,8 +10,8 @@ import ( | ||
| 10 | ) | 10 | ) |
| 11 | 11 | ||
| 12 | const ( | 12 | const ( |
| 13 | - TypeSubmit = iota + 1 | ||
| 14 | - TypeApprove | 13 | + TypeSubmit = iota + 1 //提交者类型 |
| 14 | + TypeApprove //审核人类型 | ||
| 15 | ) | 15 | ) |
| 16 | 16 | ||
| 17 | //提交状态 | 17 | //提交状态 |
| @@ -23,7 +23,7 @@ const ( | @@ -23,7 +23,7 @@ const ( | ||
| 23 | //通过状态 | 23 | //通过状态 |
| 24 | const ( | 24 | const ( |
| 25 | None = iota //未提交 | 25 | None = iota //未提交 |
| 26 | - Waiting //已提交待审核 | 26 | + Waiting //已提交待处理 |
| 27 | Reject //退回 | 27 | Reject //退回 |
| 28 | Pass //通过 | 28 | Pass //通过 |
| 29 | ) | 29 | ) |
| @@ -200,3 +200,14 @@ type SiftingPoolRequest struct { | @@ -200,3 +200,14 @@ type SiftingPoolRequest struct { | ||
| 200 | type SiftingPoolResponse struct { | 200 | type SiftingPoolResponse struct { |
| 201 | ChancePoolResponse | 201 | ChancePoolResponse |
| 202 | } | 202 | } |
| 203 | + | ||
| 204 | +/*筛选结果 SiftingResults */ | ||
| 205 | +type SiftingResultsRequest struct { | ||
| 206 | + PageInfo | ||
| 207 | + Uid int64 `json:"uid"` //注入用户 测试使用 | ||
| 208 | + //SubmitStatus int `json:"submitStatus"` //0:待我提交 1:提交 | ||
| 209 | + SiftedStatus int `json:"siftedStatus"` //筛选状态 1:待处理 2:通过 3:不通过 | ||
| 210 | +} | ||
| 211 | +type SiftingResultsResponse struct { | ||
| 212 | + ChancePoolResponse | ||
| 213 | +} |
| @@ -108,6 +108,12 @@ func BadRequestParam(code int) *ResponseMessage { | @@ -108,6 +108,12 @@ func BadRequestParam(code int) *ResponseMessage { | ||
| 108 | return NewMesage(code) | 108 | return NewMesage(code) |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | +func BadRequestParamWithMessage(code int, message string) *ResponseMessage { | ||
| 112 | + msg := NewMesage(code) | ||
| 113 | + msg.Errmsg = message | ||
| 114 | + return msg | ||
| 115 | +} | ||
| 116 | + | ||
| 111 | func NewSuccessWithMessage(msg string) *ErrWithMessage { | 117 | func NewSuccessWithMessage(msg string) *ErrWithMessage { |
| 112 | return &ErrWithMessage{ | 118 | return &ErrWithMessage{ |
| 113 | Err: nil, | 119 | Err: nil, |
| @@ -265,6 +265,14 @@ func init() { | @@ -265,6 +265,14 @@ func init() { | ||
| 265 | 265 | ||
| 266 | beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], | 266 | beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], |
| 267 | beego.ControllerComments{ | 267 | beego.ControllerComments{ |
| 268 | + Method: "SiftingResults", | ||
| 269 | + Router: `/siftingResults`, | ||
| 270 | + AllowHTTPMethods: []string{"post"}, | ||
| 271 | + MethodParams: param.Make(), | ||
| 272 | + Params: nil}) | ||
| 273 | + | ||
| 274 | + beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], | ||
| 275 | + beego.ControllerComments{ | ||
| 268 | Method: "ChanceStatistics", | 276 | Method: "ChanceStatistics", |
| 269 | Router: `/statistics`, | 277 | Router: `/statistics`, |
| 270 | AllowHTTPMethods: []string{"post"}, | 278 | AllowHTTPMethods: []string{"post"}, |
| @@ -430,3 +430,44 @@ func NewChanceSelfCheck(header *protocol.RequestHeader, check protocol.SelfCheck | @@ -430,3 +430,44 @@ func NewChanceSelfCheck(header *protocol.RequestHeader, check protocol.SelfCheck | ||
| 430 | Type: checkerType, | 430 | Type: checkerType, |
| 431 | } | 431 | } |
| 432 | } | 432 | } |
| 433 | + | ||
| 434 | +//新建通用列表项 | ||
| 435 | +func NewCommonListItem(header *protocol.RequestHeader, ormItem protocol.CommChanceItemOrm) protocol.CommonListItem { | ||
| 436 | + commItem := protocol.CommonListItem{} | ||
| 437 | + commItem.Chance, commItem.ChanceStatus = SetChanceItem(header, ormItem) | ||
| 438 | + commItem.ReviewStatus = ormItem.ReviewStatus | ||
| 439 | + commItem.ChanceId = ormItem.ChanceId | ||
| 440 | + | ||
| 441 | + ////模板数据 | ||
| 442 | + commItem.ChanceTemplate = GetTemplate(ormItem.TemplateId) | ||
| 443 | + commItem.ChanceType = GetChanceType(ormItem.ChanceTypeId) | ||
| 444 | + return commItem | ||
| 445 | +} | ||
| 446 | + | ||
| 447 | +//获取模板 | ||
| 448 | +func GetTemplate(templateId int) protocol.NameItem { | ||
| 449 | + if template, e := models.GetAuditTemplateById(int64(templateId)); e == nil { | ||
| 450 | + item := protocol.NameItem{ | ||
| 451 | + Id: int(template.Id), | ||
| 452 | + Name: template.Name, | ||
| 453 | + } | ||
| 454 | + return item | ||
| 455 | + } else { | ||
| 456 | + log.Error(templateId, e) | ||
| 457 | + } | ||
| 458 | + return protocol.NameItem{} | ||
| 459 | +} | ||
| 460 | + | ||
| 461 | +//获取机会一级分类 | ||
| 462 | +func GetChanceType(chanceTypeId int) protocol.NameItem { | ||
| 463 | + if template, e := models.GetChanceTypeById(chanceTypeId); e == nil { | ||
| 464 | + item := protocol.NameItem{ | ||
| 465 | + Id: int(template.Id), | ||
| 466 | + Name: template.Name, | ||
| 467 | + } | ||
| 468 | + return item | ||
| 469 | + } else { | ||
| 470 | + log.Error(chanceTypeId, e) | ||
| 471 | + } | ||
| 472 | + return protocol.NameItem{} | ||
| 473 | +} |
| @@ -2234,14 +2234,6 @@ func SiftingPool(header *protocol.RequestHeader, request *protocol.SiftingPoolRe | @@ -2234,14 +2234,6 @@ func SiftingPool(header *protocol.RequestHeader, request *protocol.SiftingPoolRe | ||
| 2234 | if request.Uid != 0 { | 2234 | if request.Uid != 0 { |
| 2235 | header.UserId = request.Uid | 2235 | header.UserId = request.Uid |
| 2236 | } | 2236 | } |
| 2237 | - if request.SubmitStatus == protocol.Submiting { | ||
| 2238 | - request.SiftedStatus = protocol.None | ||
| 2239 | - } else if request.SubmitStatus == protocol.Submited { | ||
| 2240 | - request.SiftedStatus = protocol.Waiting | ||
| 2241 | - } else { | ||
| 2242 | - err = protocol.NewCustomMessage(2, "obj.SubmitStatus must in (0,1)") | ||
| 2243 | - return | ||
| 2244 | - } | ||
| 2245 | if rsp.Total, err = models.GetSiftingChance(header.UserId, request.SubmitStatus, request.SiftedStatus, request.Offset(), request.PageSize, &ormItems); err != nil { | 2237 | if rsp.Total, err = models.GetSiftingChance(header.UserId, request.SubmitStatus, request.SiftedStatus, request.Offset(), request.PageSize, &ormItems); err != nil { |
| 2246 | if err == orm.ErrNoRows { | 2238 | if err == orm.ErrNoRows { |
| 2247 | err = nil | 2239 | err = nil |
| @@ -2252,21 +2244,41 @@ func SiftingPool(header *protocol.RequestHeader, request *protocol.SiftingPoolRe | @@ -2252,21 +2244,41 @@ func SiftingPool(header *protocol.RequestHeader, request *protocol.SiftingPoolRe | ||
| 2252 | } | 2244 | } |
| 2253 | for i := 0; i < len(ormItems); i++ { | 2245 | for i := 0; i < len(ormItems); i++ { |
| 2254 | ormItem := ormItems[i] | 2246 | ormItem := ormItems[i] |
| 2255 | - commItem := protocol.CommonListItem{} | ||
| 2256 | - commItem.Chance, commItem.ChanceStatus = agg.SetChanceItem(header, ormItem.CommChanceItemOrm) | ||
| 2257 | - commItem.ReviewStatus = ormItem.ReviewStatus | ||
| 2258 | - commItem.ChanceId = ormItem.ChanceId | 2247 | + commItem := agg.NewCommonListItem(header, ormItem.CommChanceItemOrm) |
| 2259 | commItem.Chance.CreateTime = ormItem.ChanceApproveTime.Unix() * 1000 | 2248 | commItem.Chance.CreateTime = ormItem.ChanceApproveTime.Unix() * 1000 |
| 2260 | if request.SubmitStatus == protocol.Submited { | 2249 | if request.SubmitStatus == protocol.Submited { |
| 2261 | commItem.Chance.CreateTime = ormItem.SubmitCheckTime.Unix() * 1000 | 2250 | commItem.Chance.CreateTime = ormItem.SubmitCheckTime.Unix() * 1000 |
| 2262 | } | 2251 | } |
| 2252 | + rsp.List = append(rsp.List, commItem) | ||
| 2253 | + } | ||
| 2263 | 2254 | ||
| 2264 | - //模板数据 | ||
| 2265 | - commItem.ChanceTemplate = getTemplate(ormItem.TemplateId) | ||
| 2266 | - commItem.ChanceType = getChanceType(ormItem.ChanceTypeId) | 2255 | + return |
| 2256 | +} | ||
| 2267 | 2257 | ||
| 2258 | +//筛选结果 | ||
| 2259 | +func SiftingResults(header *protocol.RequestHeader, request *protocol.SiftingResultsRequest) (rsp *protocol.SiftingResultsResponse, err error) { | ||
| 2260 | + var ( | ||
| 2261 | + ormItems []protocol.ChanceSiftResultOrm | ||
| 2262 | + ) | ||
| 2263 | + rsp = &protocol.SiftingResultsResponse{} | ||
| 2264 | + rsp.List = make([]protocol.CommonListItem, 0) | ||
| 2265 | + //测试使用 | ||
| 2266 | + if request.Uid != 0 { | ||
| 2267 | + header.UserId = request.Uid | ||
| 2268 | + } | ||
| 2269 | + if rsp.Total, err = models.GetSiftingResults(header.UserId, protocol.Submited, request.SiftedStatus, request.Offset(), request.PageSize, &ormItems); err != nil { | ||
| 2270 | + if err == orm.ErrNoRows { | ||
| 2271 | + err = nil | ||
| 2272 | + return | ||
| 2273 | + } | ||
| 2274 | + log.Error(err) | ||
| 2275 | + return | ||
| 2276 | + } | ||
| 2277 | + for i := 0; i < len(ormItems); i++ { | ||
| 2278 | + ormItem := ormItems[i] | ||
| 2279 | + commItem := agg.NewCommonListItem(header, ormItem.CommChanceItemOrm) | ||
| 2280 | + commItem.Chance.CreateTime = ormItem.CheckTime.Unix() * 1000 | ||
| 2268 | rsp.List = append(rsp.List, commItem) | 2281 | rsp.List = append(rsp.List, commItem) |
| 2269 | } | 2282 | } |
| 2270 | - | ||
| 2271 | return | 2283 | return |
| 2272 | } | 2284 | } |
-
请 注册 或 登录 后发表评论