作者 yangfu

修改

机会审核(退回理由)
机会池/筛选池/筛选结果
部门统计/储备池
@@ -449,12 +449,23 @@ func (this *ChanceController) ChanceApprove() { @@ -449,12 +449,23 @@ func (this *ChanceController) ChanceApprove() {
449 return 449 return
450 } 450 }
451 } 451 }
  452 + if request.ReviewStatus != protocol.ReviewStatusReturn && len(request.Reason) > 0 {
  453 + msg = protocol.BadRequestParamWithMessage(2, "机会退回时才需要填写理由")
  454 + log.Error(msg)
  455 + return
  456 + }
452 if e := request.SelfChecks.SetSelfChecksLevel1ByRule(); e != nil { 457 if e := request.SelfChecks.SetSelfChecksLevel1ByRule(); e != nil {
453 log.Error(e) 458 log.Error(e)
454 msg = protocol.NewReturnResponse(nil, e) 459 msg = protocol.NewReturnResponse(nil, e)
455 return 460 return
456 } 461 }
  462 + if len([]rune(request.Reason)) > 100 {
  463 + msg = protocol.BadRequestParamWithMessage(2, "填写理由长度有误,最多输入100个字符")
  464 + log.Error(msg)
  465 + return
  466 + }
457 header := controllers.GetRequestHeader(this.Ctx) 467 header := controllers.GetRequestHeader(this.Ctx)
  468 + request.ApproveData.Reason = request.Reason
458 msg = protocol.NewReturnResponse(chance.ChanceApprove(header, request)) 469 msg = protocol.NewReturnResponse(chance.ChanceApprove(header, request))
459 } 470 }
460 471
@@ -14,7 +14,7 @@ type ConfigController struct { @@ -14,7 +14,7 @@ type ConfigController struct {
14 controllers.BaseController 14 controllers.BaseController
15 } 15 }
16 16
17 -//GetConfigScore 17 +//GetConfigScore 获取评分配置
18 //@router /score/get [post] 18 //@router /score/get [post]
19 func (this *ConfigController) GetConfigScore() { 19 func (this *ConfigController) GetConfigScore() {
20 var msg *protocol.ResponseMessage 20 var msg *protocol.ResponseMessage
@@ -35,6 +35,7 @@ type AuditFlowProcess struct { @@ -35,6 +35,7 @@ type AuditFlowProcess struct {
35 SelfChecks string `orm:"column(self_checks);null" description:"自查内容"` 35 SelfChecks string `orm:"column(self_checks);null" description:"自查内容"`
36 SubmitCheckTime time.Time `orm:"column(submit_check_time);type(timestamp)" description:"提交筛选时间"` 36 SubmitCheckTime time.Time `orm:"column(submit_check_time);type(timestamp)" description:"提交筛选时间"`
37 SubmitCheckStatus int `orm:"column(submit_check_status)" description:"提交筛选状态 0:未提交 1:已提交"` 37 SubmitCheckStatus int `orm:"column(submit_check_status)" description:"提交筛选状态 0:未提交 1:已提交"`
  38 + Reason string `orm:"column(reason);null" description:"理由(退回)"`
38 } 39 }
39 40
40 func (t *AuditFlowProcess) TableName() string { 41 func (t *AuditFlowProcess) TableName() string {
@@ -128,7 +129,7 @@ func GetAuditFlowProcessList(chanceId int64) (v []*AuditFlowProcess, err error) @@ -128,7 +129,7 @@ func GetAuditFlowProcessList(chanceId int64) (v []*AuditFlowProcess, err error)
128 o := orm.NewOrm() 129 o := orm.NewOrm()
129 sql := `select id ,chance_id,uid,level,is_active,IFNULL(approve_time,NOW()) approve_time,basic_score,extra_score,value_score,discovery_score, 130 sql := `select id ,chance_id,uid,level,is_active,IFNULL(approve_time,NOW()) approve_time,basic_score,extra_score,value_score,discovery_score,
130 review_status,audit_flow_type,flow_type,action_type,update_at,create_at,enable_status,approve_data,user_name,role_name,role_id,approve_message, 131 review_status,audit_flow_type,flow_type,action_type,update_at,create_at,enable_status,approve_data,user_name,role_name,role_id,approve_message,
131 -template_id,self_checks from audit_flow_process 132 +template_id,self_checks,reason from audit_flow_process
132 where chance_id =? and enable_status=1 order by approve_time,level desc` 133 where chance_id =? and enable_status=1 order by approve_time,level desc`
133 if _, err = o.Raw(sql, chanceId).QueryRows(&v); err == nil { 134 if _, err = o.Raw(sql, chanceId).QueryRows(&v); err == nil {
134 return v, nil 135 return v, nil
1 package models 1 package models
2 2
3 import ( 3 import (
  4 + "bytes"
4 "fmt" 5 "fmt"
5 "opp/internal/utils" 6 "opp/internal/utils"
6 "time" 7 "time"
@@ -16,7 +17,7 @@ type Chance struct { @@ -16,7 +17,7 @@ type Chance struct {
16 ChanceTypeId int `orm:"column(chance_type_id)" description:"表chance_type.id 机会类型 "` 17 ChanceTypeId int `orm:"column(chance_type_id)" description:"表chance_type.id 机会类型 "`
17 AuditTemplateId int64 `orm:"column(audit_template_id)" description:"表audit_template.id 所属审批模板编号"` 18 AuditTemplateId int64 `orm:"column(audit_template_id)" description:"表audit_template.id 所属审批模板编号"`
18 AuditTemplateConfig string `orm:"column(audit_template_config);size(255);null" description:"模板配置 (存旧的配置信息,对新改动的不影响)"` 19 AuditTemplateConfig string `orm:"column(audit_template_config);size(255);null" description:"模板配置 (存旧的配置信息,对新改动的不影响)"`
19 - Content string `orm:"column(content)" description:"格式化后的文本内容"` 20 + //Content string `orm:"column(content)" description:"格式化后的文本内容"`
20 SourceContent string `orm:"column(source_content)" description:"原始表单内容 json"` 21 SourceContent string `orm:"column(source_content)" description:"原始表单内容 json"`
21 ViewTotal int `orm:"column(view_total)" description:"查看总数"` 22 ViewTotal int `orm:"column(view_total)" description:"查看总数"`
22 CommentTotal int `orm:"column(comment_total)" description:"评论总数"` 23 CommentTotal int `orm:"column(comment_total)" description:"评论总数"`
@@ -39,6 +40,8 @@ type Chance struct { @@ -39,6 +40,8 @@ type Chance struct {
39 CheckTime time.Time `orm:"column(check_time);type(timestamp)" description:"时间"` 40 CheckTime time.Time `orm:"column(check_time);type(timestamp)" description:"时间"`
40 CheckResultStatus int `orm:"column(check_result_status)" description:"机会筛选状态【1:待处理】【2:通过】【3:不通过】"` 41 CheckResultStatus int `orm:"column(check_result_status)" description:"机会筛选状态【1:待处理】【2:通过】【3:不通过】"`
41 CheckResult string `orm:"column(check_result);null" description:"筛选结果"` 42 CheckResult string `orm:"column(check_result);null" description:"筛选结果"`
  43 + Type int8 `orm:"column(type)" description:"机会类别:0:机会池 1:储备池 "`
  44 + ReserveTypeId int `orm:"column(reserve_type_id)" description:"当前审批步骤"`
42 } 45 }
43 46
44 const ( 47 const (
@@ -46,6 +49,32 @@ const ( @@ -46,6 +49,32 @@ const (
46 ChanceStatusClose = 2 //关闭 49 ChanceStatusClose = 2 //关闭
47 ) 50 )
48 51
  52 +const (
  53 + ChancePool = iota //机会池
  54 + ChanceReserve //机会储备池
  55 +)
  56 +
  57 +type ChancePoolOption struct {
  58 + ChanceTypeId int //机会类型编号
  59 + DIds []int //部门编号列表
  60 + Type int8 //机会类型
  61 + ReserveTypeId int //机会储备类型编号
  62 +}
  63 +
  64 +//机会池查询选项
  65 +//@chanceTypeId 机会类型编号
  66 +//@deps 部门编号列表
  67 +//@t 机会类型
  68 +//@rt 储备类型
  69 +func NewChancePoolOption(chanceTypeId int, deps []int, t int8, rt int) *ChancePoolOption {
  70 + return &ChancePoolOption{
  71 + ChanceTypeId: chanceTypeId,
  72 + DIds: deps,
  73 + Type: t,
  74 + ReserveTypeId: rt,
  75 + }
  76 +}
  77 +
49 var ( 78 var (
50 SqlGetChanceSelfChecks = `select user_id,review_status,self_checks from chance where id =?` //机会自查数据 79 SqlGetChanceSelfChecks = `select user_id,review_status,self_checks from chance where id =?` //机会自查数据
51 ) 80 )
@@ -273,28 +302,28 @@ where user_id =?` @@ -273,28 +302,28 @@ where user_id =?`
273 } 302 }
274 303
275 //type4 查看所有机会 304 //type4 查看所有机会
276 -func GetChancePoolAll(uid, cid int64, chanceTypeId int, dIds []int, lastId int64, pageSize int, v interface{}) (total int, err error) {  
277 - var filterDepartment string = getFilterSqlByDIds(dIds) 305 +func GetChancePoolAll(uid, cid int64, option *ChancePoolOption, lastId int64, pageSize int, v interface{}) (total int, err error) {
  306 + var filter string = getFilterSql(option)
278 sql := fmt.Sprintf(`select a.*,b.images,speechs,videos 307 sql := fmt.Sprintf(`select a.*,b.images,speechs,videos
279 from ( 308 from (
280 select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total from chance 309 select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total from chance
281 -where company_id=? and review_status=3 and (?=0 or chance_type_id =?) and (?=0 or unix_timestamp(approve_time)<?) and enable_status=1 and status=1 %v 310 +where company_id=? and review_status=3 and (?=0 or unix_timestamp(approve_time)<?) and enable_status=1 and status=1 %v
282 ) a left JOIN chance_data b on a.id =b.chance_id 311 ) a left JOIN chance_data b on a.id =b.chance_id
283 order by create_at desc 312 order by create_at desc
284 limit ? 313 limit ?
285 -`, filterDepartment) 314 +`, filter)
286 315
287 //if public==protocol.pu 316 //if public==protocol.pu
288 317
289 sqlCount := fmt.Sprintf(`select count(0) from ( 318 sqlCount := fmt.Sprintf(`select count(0) from (
290 select id from chance 319 select id from chance
291 -where company_id=? and review_status=3 and (%v=0 or chance_type_id =%v) and enable_status=1 and status=1 %v  
292 -) a left JOIN chance_data b on a.id =b.chance_id`, chanceTypeId, chanceTypeId, filterDepartment) 320 +where company_id=? and review_status=3 and enable_status=1 and status=1 %v
  321 +) a left JOIN chance_data b on a.id =b.chance_id`, filter)
293 if err = utils.ExecuteQueryOne(&total, sqlCount, cid); err != nil { 322 if err = utils.ExecuteQueryOne(&total, sqlCount, cid); err != nil {
294 return 323 return
295 } 324 }
296 if v != nil { 325 if v != nil {
297 - if err = utils.ExecuteQueryAll(v, sql, cid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize); err != nil { 326 + if err = utils.ExecuteQueryAll(v, sql, cid, lastId, lastId, pageSize); err != nil {
298 return 327 return
299 } 328 }
300 } 329 }
@@ -302,61 +331,61 @@ where company_id=? and review_status=3 and (%v=0 or chance_type_id =%v) and ena @@ -302,61 +331,61 @@ where company_id=? and review_status=3 and (%v=0 or chance_type_id =%v) and ena
302 } 331 }
303 332
304 //type3 特定部门机会 333 //type3 特定部门机会
305 -func GetChancePoolSpecialDepartment(uid, cid int64, chanceTypeId int, dIds []int, lastId int64, pageSize int, v interface{}, departmentIds []int64) (total int, err error) {  
306 - var filterDepartment string = getFilterSqlByDIds(dIds) 334 +func GetChancePoolSpecialDepartment(uid, cid int64, option *ChancePoolOption, lastId int64, pageSize int, v interface{}, departmentIds []int64) (total int, err error) {
  335 + var filter string = getFilterSql(option)
307 sql := fmt.Sprintf(` 336 sql := fmt.Sprintf(`
308 select a.*,b.images,speechs,videos from ( 337 select a.*,b.images,speechs,videos from (
309 select * from ( 338 select * from (
310 ##公司公开的机会 339 ##公司公开的机会
311 - select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance 340 + select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
312 where company_id = %v and publish_status = 2 and review_status=3 341 where company_id = %v and publish_status = 2 and review_status=3
313 UNION 342 UNION
314 343
315 ##指定部门-机会提交的部门 344 ##指定部门-机会提交的部门
316 - select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance 345 + select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
317 where department_id in (%v) and review_status=3 346 where department_id in (%v) and review_status=3
318 UNION 347 UNION
319 348
320 ##本人 349 ##本人
321 - select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance 350 + select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
322 where user_id = %v and review_status=3 351 where user_id = %v and review_status=3
323 UNION 352 UNION
324 353
325 ##我审核 354 ##我审核
326 - select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from ( 355 + select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from (
327 select DISTINCT chance_id from audit_flow_process where uid =%v 356 select DISTINCT chance_id from audit_flow_process where uid =%v
328 ) a inner join chance b on a.chance_id = b.id 357 ) a inner join chance b on a.chance_id = b.id
329 358
330 -) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or unix_timestamp(create_at)<%v) and a.enable_status=1 and status=1 %v 359 +) a where review_status=3 and (0=%v or unix_timestamp(create_at)<%v) and a.enable_status=1 and status=1 %v
331 ) a left JOIN chance_data b on a.id =b.chance_id 360 ) a left JOIN chance_data b on a.id =b.chance_id
332 order by create_at desc 361 order by create_at desc
333 limit %v 362 limit %v
334 -`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, lastId, lastId, filterDepartment, pageSize) 363 +`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, lastId, lastId, filter, pageSize)
335 364
336 sqlCount := fmt.Sprintf(` 365 sqlCount := fmt.Sprintf(`
337 select count(0) from ( 366 select count(0) from (
338 ##公司公开的机会 367 ##公司公开的机会
339 - select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance 368 + select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
340 where company_id = %v and publish_status = 2 and review_status=3 369 where company_id = %v and publish_status = 2 and review_status=3
341 UNION 370 UNION
342 371
343 ##指定部门-机会提交的部门 372 ##指定部门-机会提交的部门
344 - select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance 373 + select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
345 where department_id in (%v) and review_status=3 374 where department_id in (%v) and review_status=3
346 UNION 375 UNION
347 376
348 ##本人 377 ##本人
349 - select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance 378 + select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
350 where user_id = %v and review_status=3 379 where user_id = %v and review_status=3
351 UNION 380 UNION
352 381
353 ##我审核 382 ##我审核
354 - select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from ( 383 + select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from (
355 select DISTINCT chance_id from audit_flow_process where uid =%v 384 select DISTINCT chance_id from audit_flow_process where uid =%v
356 ) a inner join chance b on a.chance_id = b.id 385 ) a inner join chance b on a.chance_id = b.id
357 386
358 -) a where review_status=3 and (0=%v or chance_type_id =%v) and a.enable_status=1 and status=1 %v  
359 -`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, filterDepartment) 387 +) a where review_status=3 and a.enable_status=1 and status=1 %v
  388 +`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, filter)
360 if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil { 389 if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
361 return 390 return
362 } 391 }
@@ -369,13 +398,13 @@ select count(0) from ( @@ -369,13 +398,13 @@ select count(0) from (
369 } 398 }
370 399
371 //type32 特定部门机会 - 多角色时包含levl2 部门公开 400 //type32 特定部门机会 - 多角色时包含levl2 部门公开
372 -func GetChancePoolDepartment(uid, cid int64, chanceTypeId int, dIds []int, lastId int64, pageSize int, v interface{}, departmentIds []int64, userDepartmetIds []int64) (total int, err error) {  
373 - var filterDepartment string = getFilterSqlByDIds(dIds) 401 +func GetChancePoolDepartment(uid, cid int64, option *ChancePoolOption, lastId int64, pageSize int, v interface{}, departmentIds []int64, userDepartmetIds []int64) (total int, err error) {
  402 + var filter string = getFilterSql(option)
374 sql := fmt.Sprintf(` 403 sql := fmt.Sprintf(`
375 select a.*,b.images,speechs,videos from ( 404 select a.*,b.images,speechs,videos from (
376 select * from ( 405 select * from (
377 ##指定部门-机会公开的部门 406 ##指定部门-机会公开的部门
378 - select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from ( 407 + select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from (
379 select DISTINCT chance_id from chance_department where department_id in (%v) 408 select DISTINCT chance_id from chance_department where department_id in (%v)
380 )a inner join chance b on a.chance_id = b.id 409 )a inner join chance b on a.chance_id = b.id
381 where review_status=3 410 where review_status=3
@@ -383,35 +412,35 @@ select * from ( @@ -383,35 +412,35 @@ select * from (
383 UNION 412 UNION
384 413
385 ##公司公开的机会 414 ##公司公开的机会
386 - select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance 415 + select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
387 where company_id = %v and publish_status = 2 and review_status=3 416 where company_id = %v and publish_status = 2 and review_status=3
388 UNION 417 UNION
389 418
390 ##指定部门-机会提交的部门 419 ##指定部门-机会提交的部门
391 - select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance 420 + select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
392 where department_id in (%v) and review_status=3 421 where department_id in (%v) and review_status=3
393 UNION 422 UNION
394 423
395 ##本人 424 ##本人
396 - select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance 425 + select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
397 where user_id = %v and review_status=3 426 where user_id = %v and review_status=3
398 UNION 427 UNION
399 428
400 ##我审核 429 ##我审核
401 - select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from ( 430 + select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from (
402 select DISTINCT chance_id from audit_flow_process where uid =%v 431 select DISTINCT chance_id from audit_flow_process where uid =%v
403 ) a inner join chance b on a.chance_id = b.id 432 ) a inner join chance b on a.chance_id = b.id
404 433
405 -) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or unix_timestamp(create_at)<%v) and a.enable_status=1 and status=1 %v 434 +) a where review_status=3 and (0=%v or unix_timestamp(create_at)<%v) and a.enable_status=1 and status=1 %v
406 ) a left JOIN chance_data b on a.id =b.chance_id 435 ) a left JOIN chance_data b on a.id =b.chance_id
407 order by create_at desc 436 order by create_at desc
408 limit %v 437 limit %v
409 -`, utils.JoinInt64s(userDepartmetIds, ","), cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, lastId, lastId, filterDepartment, pageSize) 438 +`, utils.JoinInt64s(userDepartmetIds, ","), cid, utils.JoinInt64s(departmentIds, ","), uid, uid, lastId, lastId, filter, pageSize)
410 439
411 sqlCount := fmt.Sprintf(` 440 sqlCount := fmt.Sprintf(`
412 select count(0) from ( 441 select count(0) from (
413 ##指定部门-机会公开的部门 442 ##指定部门-机会公开的部门
414 - select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from ( 443 + select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from (
415 select DISTINCT chance_id from chance_department where department_id in (%v) 444 select DISTINCT chance_id from chance_department where department_id in (%v)
416 )a inner join chance b on a.chance_id = b.id 445 )a inner join chance b on a.chance_id = b.id
417 where review_status=3 446 where review_status=3
@@ -419,27 +448,27 @@ select count(0) from ( @@ -419,27 +448,27 @@ select count(0) from (
419 UNION 448 UNION
420 449
421 ##公司公开的机会 450 ##公司公开的机会
422 - select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance 451 + select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
423 where company_id = %v and publish_status = 2 and review_status=3 452 where company_id = %v and publish_status = 2 and review_status=3
424 UNION 453 UNION
425 454
426 ##指定部门-机会提交的部门 455 ##指定部门-机会提交的部门
427 - select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance 456 + select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
428 where department_id in (%v) and review_status=3 457 where department_id in (%v) and review_status=3
429 UNION 458 UNION
430 459
431 ##本人 460 ##本人
432 - select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance 461 + select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
433 where user_id = %v and review_status=3 462 where user_id = %v and review_status=3
434 UNION 463 UNION
435 464
436 ##我审核 465 ##我审核
437 - select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from ( 466 + select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from (
438 select DISTINCT chance_id from audit_flow_process where uid =%v 467 select DISTINCT chance_id from audit_flow_process where uid =%v
439 ) a inner join chance b on a.chance_id = b.id 468 ) a inner join chance b on a.chance_id = b.id
440 469
441 -) a where review_status=3 and (0=%v or chance_type_id =%v) and a.enable_status=1 and status=1 %v  
442 -`, utils.JoinInt64s(userDepartmetIds, ","), cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, filterDepartment) 470 +) a where review_status=3 and a.enable_status=1 and status=1 %v
  471 +`, utils.JoinInt64s(userDepartmetIds, ","), cid, utils.JoinInt64s(departmentIds, ","), uid, uid, filter)
443 if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil { 472 if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
444 return 473 return
445 } 474 }
@@ -452,18 +481,18 @@ select count(0) from ( @@ -452,18 +481,18 @@ select count(0) from (
452 } 481 }
453 482
454 //type2 对我所在部门公开的机会 公司公开的机会 483 //type2 对我所在部门公开的机会 公司公开的机会
455 -func GetChancePoolPublicCompany(uid, cid int64, chanceTypeId int, dIds []int, lastId int64, pageSize int, v interface{}, departmentIds []int64) (total int, err error) {  
456 - var filterDepartment string = getFilterSqlByDIds(dIds) 484 +func GetChancePoolPublicCompany(uid, cid int64, option *ChancePoolOption, lastId int64, pageSize int, v interface{}, departmentIds []int64) (total int, err error) {
  485 + var filter string = getFilterSql(option)
457 sql := fmt.Sprintf(` 486 sql := fmt.Sprintf(`
458 select a.*,b.images,speechs,videos from ( 487 select a.*,b.images,speechs,videos from (
459 select * from ( 488 select * from (
460 ##公司公开的机会 489 ##公司公开的机会
461 - select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance 490 + select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
462 where company_id = %v and publish_status = 2 and review_status=3 491 where company_id = %v and publish_status = 2 and review_status=3
463 492
464 UNION 493 UNION
465 ##指定部门-机会公开的部门 494 ##指定部门-机会公开的部门
466 - select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from ( 495 + select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from (
467 select DISTINCT chance_id from chance_department where department_id in (%v) 496 select DISTINCT chance_id from chance_department where department_id in (%v)
468 )a inner join chance b on a.chance_id = b.id 497 )a inner join chance b on a.chance_id = b.id
469 where review_status=3 498 where review_status=3
@@ -471,30 +500,30 @@ select * from ( @@ -471,30 +500,30 @@ select * from (
471 UNION 500 UNION
472 501
473 ##本人 502 ##本人
474 - select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance 503 + select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
475 where user_id = %v and review_status=3 504 where user_id = %v and review_status=3
476 UNION 505 UNION
477 506
478 ##我审核 507 ##我审核
479 - select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from ( 508 + select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from (
480 select DISTINCT chance_id from audit_flow_process where uid =%v 509 select DISTINCT chance_id from audit_flow_process where uid =%v
481 ) a inner join chance b on a.chance_id = b.id 510 ) a inner join chance b on a.chance_id = b.id
482 511
483 -) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or unix_timestamp(create_at)<%v) and a.enable_status=1 and status=1 %v 512 +) a where review_status=3 and (0=%v or unix_timestamp(create_at)<%v) and a.enable_status=1 and status=1 %v
484 ) a left JOIN chance_data b on a.id =b.chance_id 513 ) a left JOIN chance_data b on a.id =b.chance_id
485 order by create_at desc 514 order by create_at desc
486 limit %v 515 limit %v
487 -`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, lastId, lastId, filterDepartment, pageSize) 516 +`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, lastId, lastId, filter, pageSize)
488 517
489 sqlCount := fmt.Sprintf(` 518 sqlCount := fmt.Sprintf(`
490 select count(0) from ( 519 select count(0) from (
491 ##公司公开的机会 520 ##公司公开的机会
492 - select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance 521 + select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
493 where company_id = %v and publish_status = 2 and review_status=3 522 where company_id = %v and publish_status = 2 and review_status=3
494 523
495 UNION 524 UNION
496 ##指定部门-机会公开的部门 525 ##指定部门-机会公开的部门
497 - select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from ( 526 + select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from (
498 select DISTINCT chance_id from chance_department where department_id in (%v) 527 select DISTINCT chance_id from chance_department where department_id in (%v)
499 )a inner join chance b on a.chance_id = b.id 528 )a inner join chance b on a.chance_id = b.id
500 where review_status=3 529 where review_status=3
@@ -502,17 +531,17 @@ select count(0) from ( @@ -502,17 +531,17 @@ select count(0) from (
502 UNION 531 UNION
503 532
504 ##本人 533 ##本人
505 - select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance 534 + select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
506 where user_id = %v and review_status=3 535 where user_id = %v and review_status=3
507 UNION 536 UNION
508 537
509 ##我审核 538 ##我审核
510 - select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from ( 539 + select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from (
511 select DISTINCT chance_id from audit_flow_process where uid =%v 540 select DISTINCT chance_id from audit_flow_process where uid =%v
512 ) a inner join chance b on a.chance_id = b.id 541 ) a inner join chance b on a.chance_id = b.id
513 542
514 -) a where review_status=3 and (0=%v or chance_type_id =%v) and a.enable_status=1 and status=1 %v  
515 -`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, filterDepartment) 543 +) a where review_status=3 and a.enable_status=1 and status=1 %v
  544 +`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, filter)
516 if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil { 545 if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
517 return 546 return
518 } 547 }
@@ -530,42 +559,57 @@ func getFilterSqlByDIds(dIds []int) string { @@ -530,42 +559,57 @@ func getFilterSqlByDIds(dIds []int) string {
530 return fmt.Sprintf(" and department_id in(%v) ", utils.JoinInts(dIds, ",")) 559 return fmt.Sprintf(" and department_id in(%v) ", utils.JoinInts(dIds, ","))
531 } 560 }
532 561
  562 +func getFilterSql(option *ChancePoolOption) string {
  563 + var rsp *bytes.Buffer = bytes.NewBuffer(nil)
  564 + rsp.WriteString(fmt.Sprintf(" and type =%v ", option.Type))
  565 + if option.ChanceTypeId > 0 {
  566 + rsp.WriteString(fmt.Sprintf(" and chance_type_id =%v ", option.ChanceTypeId))
  567 + }
  568 + if len(option.DIds) > 0 {
  569 + rsp.WriteString(fmt.Sprintf(" and department_id in(%v) ", utils.JoinInts(option.DIds, ",")))
  570 + }
  571 + if option.ReserveTypeId > 0 {
  572 + rsp.WriteString(fmt.Sprintf(" and reserve_type_id =%v ", option.ReserveTypeId))
  573 + }
  574 + return rsp.String()
  575 +}
  576 +
533 //type1 禁止查看所有机会 577 //type1 禁止查看所有机会
534 -func GetChancePoolMyself(uid, cid int64, chanceTypeId int, dIds []int, lastId int64, pageSize int, v interface{}) (total int, err error) {  
535 - var filterDepartment string = getFilterSqlByDIds(dIds) 578 +func GetChancePoolMyself(uid, cid int64, option *ChancePoolOption, lastId int64, pageSize int, v interface{}) (total int, err error) {
  579 + var filter string = getFilterSql(option) // getFilterSqlByDIds(dIds)
536 sql := fmt.Sprintf(` 580 sql := fmt.Sprintf(`
537 select a.*,b.images,speechs,videos from ( 581 select a.*,b.images,speechs,videos from (
538 select * from ( 582 select * from (
539 ##本人 583 ##本人
540 - select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance 584 + select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
541 where user_id = %v and review_status=3 585 where user_id = %v and review_status=3
542 UNION 586 UNION
543 587
544 ##我审核 588 ##我审核
545 - select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from ( 589 + select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from (
546 select DISTINCT chance_id from audit_flow_process where uid =%v 590 select DISTINCT chance_id from audit_flow_process where uid =%v
547 ) a inner join chance b on a.chance_id = b.id 591 ) a inner join chance b on a.chance_id = b.id
548 592
549 -) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or unix_timestamp(create_at)<%v) and a.enable_status=1 and status=1 %v 593 +) a where review_status=3 and (0=%v or unix_timestamp(create_at)<%v) and a.enable_status=1 and status=1 %v
550 ) a left JOIN chance_data b on a.id =b.chance_id 594 ) a left JOIN chance_data b on a.id =b.chance_id
551 order by create_at desc 595 order by create_at desc
552 limit %v 596 limit %v
553 -`, uid, uid, chanceTypeId, chanceTypeId, lastId, lastId, filterDepartment, pageSize) 597 +`, uid, uid, lastId, lastId, filter, pageSize)
554 598
555 sqlCount := fmt.Sprintf(` 599 sqlCount := fmt.Sprintf(`
556 select count(0) from ( 600 select count(0) from (
557 ##本人 601 ##本人
558 - select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance 602 + select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from chance
559 where user_id = %v and review_status=3 603 where user_id = %v and review_status=3
560 UNION 604 UNION
561 605
562 ##我审核 606 ##我审核
563 - select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from ( 607 + select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status,type,reserve_type_id from (
564 select DISTINCT chance_id from audit_flow_process where uid =%v 608 select DISTINCT chance_id from audit_flow_process where uid =%v
565 ) a inner join chance b on a.chance_id = b.id 609 ) a inner join chance b on a.chance_id = b.id
566 610
567 -) a where review_status=3 and (0=%v or chance_type_id =%v) and a.enable_status=1 and status=1 %v  
568 -`, uid, uid, chanceTypeId, chanceTypeId, filterDepartment) 611 +) a where review_status=3 and a.enable_status=1 and status=1 %v
  612 +`, uid, uid, filter)
569 if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil { 613 if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
570 return 614 return
571 } 615 }
@@ -577,62 +621,6 @@ select count(0) from ( @@ -577,62 +621,6 @@ select count(0) from (
577 return 621 return
578 } 622 }
579 623
580 -//type4 查看所有机会  
581 -func ValidChanceAll(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, v interface{}) (total int, err error) {  
582 -  
583 - // sql := `select a.*,b.images,speechs,videos  
584 - //from (  
585 - //select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total from chance  
586 - //where company_id=? and review_status=3 and (?=0 or chance_type_id =?) and (?=0 or id<?) and enable_status=1  
587 - //order by create_at desc  
588 - //limit ?  
589 - //) a left JOIN chance_data b on a.id =b.chance_id`  
590 - // //if public==protocol.pu  
591 - //  
592 - // sqlCount := fmt.Sprintf(`select count(0) from (  
593 - //select id from chance  
594 - //where company_id=? and review_status=3 and (%v=0 or chance_type_id =%v) and enable_status=1  
595 - //order by create_at desc  
596 - //) a left JOIN chance_data b on a.id =b.chance_id`, chanceTypeId, chanceTypeId)  
597 - // if err = utils.ExecuteQueryOne(&total, sqlCount, cid); err != nil {  
598 - // return  
599 - // }  
600 - // if v != nil {  
601 - // if err = utils.ExecuteQueryAll(v, sql, cid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize); err != nil {  
602 - // return  
603 - // }  
604 - // }  
605 - return  
606 -}  
607 -  
608 -//type3 特定部门机会  
609 -func ValidChanceSpecialDepartment(uid, chanceIds string, v interface{}) (err error) {  
610 -  
611 - sql := fmt.Sprintf(`  
612 -select * from (  
613 - ##指定部门-机会提交的部门  
614 - ##select chance_id from chance  
615 - ##where id in (v) and department_id in (v)  
616 - ##UNION  
617 -  
618 - ##本人  
619 - ##select chance_id from chance  
620 - ##where user_id = v and id in (v)  
621 - ##UNION  
622 -  
623 - ##我审核  
624 - select DISTINCT chance_id from audit_flow_process where uid =%v and chance_id in (%v)  
625 -)  
626 -`, chanceIds)  
627 -  
628 - if v != nil {  
629 - if err = utils.ExecuteQueryAll(v, sql); err != nil {  
630 - return  
631 - }  
632 - }  
633 - return  
634 -}  
635 -  
636 //是否存在按发布机会部门编号查询 624 //是否存在按发布机会部门编号查询
637 func ExitsChanceByDeparmentIds(chanceId int64, departmentIds []int64) (v *Chance, err error) { 625 func ExitsChanceByDeparmentIds(chanceId int64, departmentIds []int64) (v *Chance, err error) {
638 sql := fmt.Sprintf(`select id from chance where id=%v and department_id in (%v)`, 626 sql := fmt.Sprintf(`select id from chance where id=%v and department_id in (%v)`,
@@ -696,14 +684,14 @@ func GetSiftingChance(uid int64, submitStatus int, checkResultStatus int, offset @@ -696,14 +684,14 @@ func GetSiftingChance(uid int64, submitStatus int, checkResultStatus int, offset
696 from ( 684 from (
697 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, 685 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,
698 b.view_total, 686 b.view_total,
699 - b.update_at,b.approve_time chance_approve_time,b.status,b.self_checks,b.check_result_status,b.check_time 687 + b.update_at,b.approve_time chance_approve_time,b.status,b.self_checks,b.check_result_status,b.check_time,b.type
700 from ( 688 from (
701 select max(id) id,approve_time,approve_data,uid,chance_id,submit_check_status,submit_check_time,level 689 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 690 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 691 where a.uid=%v and b.max_id=a.id and a.submit_check_status=%v and level>0
704 GROUP BY chance_id 692 GROUP BY chance_id
705 )a left outer join chance b on a.chance_id = b.id 693 )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 length(b.self_checks)>5 694 + where b.review_status=3 and b.enable_status=1 and b.status=1 and b.type=0 and b.check_result_status <=%v and length(b.self_checks)>5
707 )a left outer join chance_data b on a.chance_id =b.chance_id 695 )a left outer join chance_data b on a.chance_id =b.chance_id
708 %v 696 %v
709 limit %v,%v`, uid, uid, submitStatus, checkResultStatus, where, offset, pageSize) //,update_at process_create_time 697 limit %v,%v`, uid, uid, submitStatus, checkResultStatus, where, offset, pageSize) //,update_at process_create_time
@@ -711,14 +699,14 @@ limit %v,%v`, uid, uid, submitStatus, checkResultStatus, where, offset, pageSize @@ -711,14 +699,14 @@ limit %v,%v`, uid, uid, submitStatus, checkResultStatus, where, offset, pageSize
711 sqlCount := fmt.Sprintf(`select count(0) 699 sqlCount := fmt.Sprintf(`select count(0)
712 from ( 700 from (
713 select a.*,b.user_id chance_user_id,b.source_content,b.enable_status,b.review_status,b.create_at, 701 select a.*,b.user_id chance_user_id,b.source_content,b.enable_status,b.review_status,b.create_at,
714 - b.update_at,b.approve_time chance_approve_time,b.status,b.self_checks,b.check_result_status 702 + b.update_at,b.approve_time chance_approve_time,b.status,b.self_checks,b.check_result_status,b.type
715 from ( 703 from (
716 select max(id) id,approve_time,approve_data,uid,chance_id,submit_check_status,submit_check_time,level 704 select max(id) id,approve_time,approve_data,uid,chance_id,submit_check_status,submit_check_time,level
717 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 705 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
718 where a.uid=%v and b.max_id=a.id and a.submit_check_status=%v and level>0 706 where a.uid=%v and b.max_id=a.id and a.submit_check_status=%v and level>0
719 GROUP BY chance_id 707 GROUP BY chance_id
720 )a left outer join chance b on a.chance_id = b.id 708 )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 length(b.self_checks)>5 709 + where b.review_status=3 and b.enable_status=1 and b.status=1 and b.type=0 and b.check_result_status <=%v and length(b.self_checks)>5
722 )a 710 )a
723 `, uid, uid, submitStatus, checkResultStatus) //and enable_status =1 711 `, uid, uid, submitStatus, checkResultStatus) //and enable_status =1
724 if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil { 712 if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
@@ -747,7 +735,7 @@ from ( @@ -747,7 +735,7 @@ from (
747 where a.uid=%v and b.max_id=a.id and a.submit_check_status=%v and level>0 735 where a.uid=%v and b.max_id=a.id and a.submit_check_status=%v and level>0
748 GROUP BY chance_id 736 GROUP BY chance_id
749 )a left outer join chance b on a.chance_id = b.id 737 )a left outer join chance b on a.chance_id = b.id
750 - where b.review_status=3 and b.enable_status=1 and b.status=1 and b.check_result_status =%v 738 + where b.review_status=3 and b.enable_status=1 and b.status=1 and b.type=0 and b.check_result_status =%v
751 )a left outer join chance_data b on a.chance_id =b.chance_id 739 )a left outer join chance_data b on a.chance_id =b.chance_id
752 order by a.check_time desc 740 order by a.check_time desc
753 limit %v,%v`, uid, uid, submitStatus, checkResultStatus, offset, pageSize) //,update_at process_create_time 741 limit %v,%v`, uid, uid, submitStatus, checkResultStatus, offset, pageSize) //,update_at process_create_time
@@ -762,7 +750,7 @@ from ( @@ -762,7 +750,7 @@ from (
762 where a.uid=%v and b.max_id=a.id and a.submit_check_status=%v and level>0 750 where a.uid=%v and b.max_id=a.id and a.submit_check_status=%v and level>0
763 GROUP BY chance_id 751 GROUP BY chance_id
764 )a left outer join chance b on a.chance_id = b.id 752 )a left outer join chance b on a.chance_id = b.id
765 - where b.review_status=3 and b.enable_status=1 and b.status=1 and b.check_result_status =%v 753 + where b.review_status=3 and b.enable_status=1 and b.status=1 and b.type=0 and b.check_result_status =%v
766 )a 754 )a
767 `, uid, uid, submitStatus, checkResultStatus) //and enable_status =1 755 `, uid, uid, submitStatus, checkResultStatus) //and enable_status =1
768 if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil { 756 if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
@@ -173,6 +173,8 @@ type ChancePoolRequest struct { @@ -173,6 +173,8 @@ type ChancePoolRequest struct {
173 ChanceTypeId int `json:"chanceTypeId"` //0:所有机会 编号:对应机会类型编号的机会 173 ChanceTypeId int `json:"chanceTypeId"` //0:所有机会 编号:对应机会类型编号的机会
174 DepartmentId int `json:"departmentId"` //部门编号 174 DepartmentId int `json:"departmentId"` //部门编号
175 IncludeSubDepartment bool 175 IncludeSubDepartment bool
  176 + Type int8 `json:"type"` //0:机会池 1:储备池
  177 + ReserveTypeId int `json:"reserveTypeId"` //储备类型编号
176 } 178 }
177 type ChancePoolResponse struct { 179 type ChancePoolResponse struct {
178 List []CommonListItem `json:"list"` 180 List []CommonListItem `json:"list"`
@@ -22,9 +22,11 @@ type ChanceApproveRequest struct { @@ -22,9 +22,11 @@ type ChanceApproveRequest struct {
22 ChanceId int64 `json:"chanceId"` //机会编号 22 ChanceId int64 `json:"chanceId"` //机会编号
23 ProcessId int64 `json:"processId"` //审批流程编号 23 ProcessId int64 `json:"processId"` //审批流程编号
24 ReviewStatus int `json:"reviewStatus"` //protocol.ReviewStatus 24 ReviewStatus int `json:"reviewStatus"` //protocol.ReviewStatus
25 - //Suggestion string `json:"suggestion"` //原因/建议  
26 ApproveData ApproveData `json:"approveData"` //审核数据 25 ApproveData ApproveData `json:"approveData"` //审核数据
27 SelfChecks SelfChecks `json:"selfChecks"` 26 SelfChecks SelfChecks `json:"selfChecks"`
  27 + Reason string `json:"reason"` //理由
  28 + Type int8 `json:"type"` //机会类型 0:机会池 1:储备池
  29 + ReserveTypeId int `json:"reserveTypeId"` //储备池类型编号
28 } 30 }
29 type ChanceApproveResponse struct { 31 type ChanceApproveResponse struct {
30 } 32 }
@@ -57,6 +59,7 @@ type ApproveAccess struct { @@ -57,6 +59,7 @@ type ApproveAccess struct {
57 type ApproveData struct { 59 type ApproveData struct {
58 PublicData PublicData `json:"publicData"` // 公开数据 60 PublicData PublicData `json:"publicData"` // 公开数据
59 Score Score `json:"score"` 61 Score Score `json:"score"`
  62 + Reason string `json:"-"`
60 } 63 }
61 64
62 //进程项 65 //进程项
@@ -71,6 +74,7 @@ type ProcessItem struct { @@ -71,6 +74,7 @@ type ProcessItem struct {
71 Name string `json:"name"` 74 Name string `json:"name"`
72 RoleName string `json:"roleName"` 75 RoleName string `json:"roleName"`
73 Role int `json:"-"` 76 Role int `json:"-"`
  77 + Reason string `json:"reason"` //退回理由
74 SelfChecks SelfChecks `json:"selfChecks"` 78 SelfChecks SelfChecks `json:"selfChecks"`
75 ApproveData *ApproveData `json:"approveData"` //审核数据 79 ApproveData *ApproveData `json:"approveData"` //审核数据
76 ApproveUsers []UserItem `json:"approveUsers"` //审核人员 //1 会签 2 或签 //审核中 1.部门长 2.角色 80 ApproveUsers []UserItem `json:"approveUsers"` //审核人员 //1 会签 2 或签 //审核中 1.部门长 2.角色
@@ -119,6 +119,7 @@ type DepartmentStatistics struct { @@ -119,6 +119,7 @@ type DepartmentStatistics struct {
119 ChanceApprovedTotal int `json:"chanceApprovedTotal"` //已审核的机会 119 ChanceApprovedTotal int `json:"chanceApprovedTotal"` //已审核的机会
120 ChanceApprovingTotal int `json:"chanceApprovingTotal"` //待审核的机会 120 ChanceApprovingTotal int `json:"chanceApprovingTotal"` //待审核的机会
121 AchievementTotal int `json:"achievementTotal"` //已创建的成果 (显示) 121 AchievementTotal int `json:"achievementTotal"` //已创建的成果 (显示)
  122 + ChanceReservedTotal int `json:"chanceReservedTotal"` //储备的机会
122 123
123 ACTotal int `json:"-"` //机会成果总数 (显示) 124 ACTotal int `json:"-"` //机会成果总数 (显示)
124 } 125 }
@@ -64,7 +64,7 @@ func init() { @@ -64,7 +64,7 @@ func init() {
64 var ApproveLog = map[int]string{ 64 var ApproveLog = map[int]string{
65 1: "提交了机会", //提交人提交机会 65 1: "提交了机会", //提交人提交机会
66 2: "删除了机会", //提交人删除机会 66 2: "删除了机会", //提交人删除机会
67 - 3: "退回了机会;%v", //审批人退回机会 67 + 3: "退回了机会%v;%v", //审批人退回机会
68 4: "通过了机会;%v\n基础评分:%v分,附加评分:%v分,价值评分:%v分,公开状态:公司公开", //审批人通过机会(公司公开) 68 4: "通过了机会;%v\n基础评分:%v分,附加评分:%v分,价值评分:%v分,公开状态:公司公开", //审批人通过机会(公司公开)
69 5: "通过了机会;%v\n基础评分:%v分,附加评分:%v分,价值评分:%v分,公开状态:%v", //审批人通过机会(部门公开) 测试部、销售部 69 5: "通过了机会;%v\n基础评分:%v分,附加评分:%v分,价值评分:%v分,公开状态:%v", //审批人通过机会(部门公开) 测试部、销售部
70 6: "系统 自动通过了机会;基础评分:%v分,附加评分:%v分,价值评分:%v分,公开状态:公司公开", //审批人通过了机会(系统自动通过) 70 6: "系统 自动通过了机会;基础评分:%v分,附加评分:%v分,价值评分:%v分,公开状态:公司公开", //审批人通过了机会(系统自动通过)
@@ -326,4 +326,5 @@ type Answer struct { @@ -326,4 +326,5 @@ type Answer struct {
326 //扩展消息附加数据 326 //扩展消息附加数据
327 type MsgData struct { 327 type MsgData struct {
328 Score *Score `json:"score,omitempty"` 328 Score *Score `json:"score,omitempty"`
  329 + Reason string `json:"-"`
329 } 330 }
@@ -171,7 +171,6 @@ func GetChance(chanceId int64, companyId int64) (v *protocol.ChanceDetail, err e @@ -171,7 +171,6 @@ func GetChance(chanceId int64, companyId int64) (v *protocol.ChanceDetail, err e
171 Id: c.Id, 171 Id: c.Id,
172 Provider: baseUserInfo, 172 Provider: baseUserInfo,
173 173
174 - Content: c.Content,  
175 ChanceType: c.ChanceTypeId, 174 ChanceType: c.ChanceTypeId,
176 ViewTotal: c.ViewTotal, 175 ViewTotal: c.ViewTotal,
177 CommentTotal: c.CommentTotal, 176 CommentTotal: c.CommentTotal,
@@ -14,7 +14,7 @@ import ( @@ -14,7 +14,7 @@ import (
14 14
15 //机会池 15 //机会池
16 //@isIncludeSubDeps 是否包含子部门编号 16 //@isIncludeSubDeps 是否包含子部门编号
17 -func GetChancePool(uid, cid int64, chanceTypeId int, departmentId int, isIncludeSubDeps bool, lastId int64, pageSize int, v interface{}) (total int, err error) { 17 +func GetChancePool(uid, cid int64, o *models.ChancePoolOption, departmentId int, isIncludeSubDeps bool, lastId int64, pageSize int, v interface{}) (total int, err error) {
18 var ( 18 var (
19 check int 19 check int
20 checkMap map[int]int 20 checkMap map[int]int
@@ -24,6 +24,7 @@ func GetChancePool(uid, cid int64, chanceTypeId int, departmentId int, isInclude @@ -24,6 +24,7 @@ func GetChancePool(uid, cid int64, chanceTypeId int, departmentId int, isInclude
24 chance *models.Chance 24 chance *models.Chance
25 dIds []int 25 dIds []int
26 ) 26 )
  27 + chanceTypeId := o.ChanceTypeId
27 if user, err = models.GetUserByCompanyId(cid); err != nil { 28 if user, err = models.GetUserByCompanyId(cid); err != nil {
28 log.Error(err) 29 log.Error(err)
29 return 30 return
@@ -54,28 +55,29 @@ func GetChancePool(uid, cid int64, chanceTypeId int, departmentId int, isInclude @@ -54,28 +55,29 @@ func GetChancePool(uid, cid int64, chanceTypeId int, departmentId int, isInclude
54 dIds, _ = GetDepartmentIds(cid, int64(departmentId), isIncludeSubDeps) 55 dIds, _ = GetDepartmentIds(cid, int64(departmentId), isIncludeSubDeps)
55 } 56 }
56 log.Debug(fmt.Sprintf("user:%v check:%v is_amdin:%v", uid, check, user.Id == uid)) 57 log.Debug(fmt.Sprintf("user:%v check:%v is_amdin:%v", uid, check, user.Id == uid))
  58 + option := models.NewChancePoolOption(chanceTypeId, dIds, o.Type, o.ReserveTypeId)
57 switch check { 59 switch check {
58 case OpportunityCheckLv1: 60 case OpportunityCheckLv1:
59 - return models.GetChancePoolMyself(uid, cid, chanceTypeId, dIds, lastId, pageSize, v) 61 + return models.GetChancePoolMyself(uid, cid, option, lastId, pageSize, v)
60 case OpportunityCheckLv2: 62 case OpportunityCheckLv2:
61 if err = models.GetUserDepartmentIds(uid, cid, &userDIds); err != nil { 63 if err = models.GetUserDepartmentIds(uid, cid, &userDIds); err != nil {
62 log.Error(err) 64 log.Error(err)
63 return 65 return
64 } 66 }
65 - return models.GetChancePoolPublicCompany(uid, cid, chanceTypeId, dIds, lastId, pageSize, v, userDIds) 67 + return models.GetChancePoolPublicCompany(uid, cid, option, lastId, pageSize, v, userDIds)
66 case OpportunityCheckLv3: 68 case OpportunityCheckLv3:
67 if _, ok := checkMap[OpportunityCheckLv2]; ok { //同时存在对部门公开的机会 69 if _, ok := checkMap[OpportunityCheckLv2]; ok { //同时存在对部门公开的机会
68 if err = models.GetUserDepartmentIds(uid, cid, &userDIds); err != nil { 70 if err = models.GetUserDepartmentIds(uid, cid, &userDIds); err != nil {
69 log.Error(err) 71 log.Error(err)
70 return 72 return
71 } 73 }
72 - return models.GetChancePoolDepartment(uid, cid, chanceTypeId, dIds, lastId, pageSize, v, specialDIds, userDIds) 74 + return models.GetChancePoolDepartment(uid, cid, option, lastId, pageSize, v, specialDIds, userDIds)
73 } 75 }
74 - return models.GetChancePoolSpecialDepartment(uid, cid, chanceTypeId, dIds, lastId, pageSize, v, specialDIds) 76 + return models.GetChancePoolSpecialDepartment(uid, cid, option, lastId, pageSize, v, specialDIds)
75 case OpportunityCheckLv4: 77 case OpportunityCheckLv4:
76 - return models.GetChancePoolAll(uid, cid, chanceTypeId, dIds, lastId, pageSize, v) 78 + return models.GetChancePoolAll(uid, cid, option, lastId, pageSize, v)
77 default: 79 default:
78 - return models.GetChancePoolAll(uid, cid, chanceTypeId, dIds, lastId, pageSize, v) 80 + return models.GetChancePoolAll(uid, cid, option, lastId, pageSize, v)
79 } 81 }
80 return 82 return
81 } 83 }
@@ -32,6 +32,9 @@ func SendApproveMsg(receiverId int64, name string, companyId int64, chanceId int @@ -32,6 +32,9 @@ func SendApproveMsg(receiverId int64, name string, companyId int64, chanceId int
32 break 32 break
33 case protocol.ReviewStatusReturn: 33 case protocol.ReviewStatusReturn:
34 format = MessageApproveReject 34 format = MessageApproveReject
  35 + if len(data.Reason) > 0 {
  36 + format += fmt.Sprintf(",退回理由:%v", data.Reason)
  37 + }
35 break 38 break
36 case protocol.ReviewStatusPass: 39 case protocol.ReviewStatusPass:
37 format = MessageApproveSuccess 40 format = MessageApproveSuccess
@@ -86,6 +89,9 @@ func sendApproveMsg(header *protocol.RequestHeader, receiverId int64, name strin @@ -86,6 +89,9 @@ func sendApproveMsg(header *protocol.RequestHeader, receiverId int64, name strin
86 case protocol.ReviewStatusReturn: 89 case protocol.ReviewStatusReturn:
87 jsonData = "" 90 jsonData = ""
88 format = MessageApproveReject 91 format = MessageApproveReject
  92 + if len(data.Reason) > 0 {
  93 + format += fmt.Sprintf(",退回理由:%v", data.Reason)
  94 + }
89 break 95 break
90 case protocol.ReviewStatusPass: 96 case protocol.ReviewStatusPass:
91 format = MessageApproveSuccess 97 format = MessageApproveSuccess
@@ -328,6 +328,7 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro @@ -328,6 +328,7 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro
328 mapProcess["IsActive"] = int8(0) 328 mapProcess["IsActive"] = int8(0)
329 mapProcess["UpdateAt"] = time.Now() 329 mapProcess["UpdateAt"] = time.Now()
330 mapProcess["SelfChecks"] = common.AssertJson(difChecks) 330 mapProcess["SelfChecks"] = common.AssertJson(difChecks)
  331 + mapProcess["Reason"] = request.Reason
331 332
332 mapChance["ApproveTime"] = time.Now() 333 mapChance["ApproveTime"] = time.Now()
333 mapChance["BasicScore"] = request.ApproveData.Score.BasicScore 334 mapChance["BasicScore"] = request.ApproveData.Score.BasicScore
@@ -371,7 +372,7 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro @@ -371,7 +372,7 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro
371 { 372 {
372 //发送审核消息给提交机会的人 373 //发送审核消息给提交机会的人
373 var nextApprovers []int64 374 var nextApprovers []int64
374 - if err = agg.SendApproveMsgWithHeader(header, chance.UserId, chance.Id, chance.ChanceTypeId, request.ReviewStatus, protocol.MsgTypeAuditBy, protocol.MsgData{Score: &request.ApproveData.Score}); err != nil { 375 + if err = agg.SendApproveMsgWithHeader(header, chance.UserId, chance.Id, chance.ChanceTypeId, request.ReviewStatus, protocol.MsgTypeAuditBy, protocol.MsgData{Score: &request.ApproveData.Score, Reason: request.Reason}); err != nil {
375 log.Error(err) 376 log.Error(err)
376 orm.Rollback() 377 orm.Rollback()
377 return 378 return
@@ -462,18 +463,6 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro @@ -462,18 +463,6 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro
462 return 463 return
463 } 464 }
464 465
465 -/*ProcessIntegrate */  
466 -type ProcessIntegrateRequest struct {  
467 -}  
468 -type ProcessIntegrateResponse struct {  
469 -}  
470 -  
471 -func ProcessIntegrate(header *protocol.RequestHeader, request *ProcessIntegrateRequest) (rsp *ProcessIntegrateResponse, err error) {  
472 - var ()  
473 - rsp = &ProcessIntegrateResponse{}  
474 - return  
475 -}  
476 -  
477 //发送审核日志 466 //发送审核日志
478 func saveApproveMsgByApproveData(header *protocol.RequestHeader, orm orm.Ormer, reviewStatus int, chance *models.Chance, approveData protocol.ApproveData, selfChecks protocol.SelfChecks) (err error) { 467 func saveApproveMsgByApproveData(header *protocol.RequestHeader, orm orm.Ormer, reviewStatus int, chance *models.Chance, approveData protocol.ApproveData, selfChecks protocol.SelfChecks) (err error) {
479 var ( 468 var (
@@ -483,7 +472,11 @@ func saveApproveMsgByApproveData(header *protocol.RequestHeader, orm orm.Ormer, @@ -483,7 +472,11 @@ func saveApproveMsgByApproveData(header *protocol.RequestHeader, orm orm.Ormer,
483 if reviewStatus == protocol.ReviewStatusReturn { 472 if reviewStatus == protocol.ReviewStatusReturn {
484 //发送退回日志 473 //发送退回日志
485 code = 3 474 code = 3
486 - parames = append(parames, selfChecks.String()) 475 + reason := ""
  476 + if len(approveData.Reason) > 0 {
  477 + reason = fmt.Sprintf(",理由:%v", approveData.Reason)
  478 + }
  479 + parames = append(parames, reason, selfChecks.String())
487 } 480 }
488 if reviewStatus == protocol.ReviewStatusPass { 481 if reviewStatus == protocol.ReviewStatusPass {
489 //发送通过日志 482 //发送通过日志
@@ -550,6 +543,7 @@ func ChanceApproveProcess(header *protocol.RequestHeader, chance *models.Chance) @@ -550,6 +543,7 @@ func ChanceApproveProcess(header *protocol.RequestHeader, chance *models.Chance)
550 ApproveType: process.AuditFlowType, 543 ApproveType: process.AuditFlowType,
551 Uid: process.Uid, 544 Uid: process.Uid,
552 Name: process.UserName, 545 Name: process.UserName,
  546 + Reason: process.Reason,
553 } 547 }
554 utils.JsonUnmarshal(process.SelfChecks, &item.SelfChecks) 548 utils.JsonUnmarshal(process.SelfChecks, &item.SelfChecks)
555 if len(item.SelfChecks) > 0 { 549 if len(item.SelfChecks) > 0 {
@@ -401,7 +401,6 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit @@ -401,7 +401,6 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit
401 ChanceTypeId: template.ChanceTypeId, 401 ChanceTypeId: template.ChanceTypeId,
402 AuditTemplateId: template.Id, 402 AuditTemplateId: template.Id,
403 AuditTemplateConfig: common.AssertJson(auditConfig), 403 AuditTemplateConfig: common.AssertJson(auditConfig),
404 - Content: request.Content,  
405 SourceContent: common.AssertJson(request.FormList), 404 SourceContent: common.AssertJson(request.FormList),
406 EnableStatus: 1, 405 EnableStatus: 1,
407 CreateAt: time.Now(), 406 CreateAt: time.Now(),
@@ -1476,7 +1475,7 @@ func ChanceStatistics(header *protocol.RequestHeader, request *protocol.ChanceSt @@ -1476,7 +1475,7 @@ func ChanceStatistics(header *protocol.RequestHeader, request *protocol.ChanceSt
1476 rsp = &protocol.ChanceStatisticsResponse{} 1475 rsp = &protocol.ChanceStatisticsResponse{}
1477 for i := range chanceType { 1476 for i := range chanceType {
1478 item := chanceType[i] 1477 item := chanceType[i]
1479 - if total, err = agg.GetChancePool(header.UserId, header.CompanyId, item.Id, 0, false, 0, 0, nil); err != nil { 1478 + if total, err = agg.GetChancePool(header.UserId, header.CompanyId, models.NewChancePoolOption(item.Id, []int{}, models.ChancePool, 0), 0, false, 0, 0, nil); err != nil {
1480 log.Error(err) 1479 log.Error(err)
1481 return 1480 return
1482 } 1481 }
@@ -1539,7 +1538,7 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ @@ -1539,7 +1538,7 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ
1539 provider *protocol.BaseUserInfo 1538 provider *protocol.BaseUserInfo
1540 flag int 1539 flag int
1541 ) 1540 )
1542 - if total, err = agg.GetChancePool(header.UserId, header.CompanyId, request.ChanceTypeId, request.DepartmentId, request.IncludeSubDepartment, request.LastId, request.PageSize, &chanceItems); err != nil { 1541 + if total, err = agg.GetChancePool(header.UserId, header.CompanyId, models.NewChancePoolOption(request.ChanceTypeId, []int{}, request.Type, request.ReserveTypeId), request.DepartmentId, request.IncludeSubDepartment, request.LastId, request.PageSize, &chanceItems); err != nil {
1543 if err == orm.ErrNoRows { 1542 if err == orm.ErrNoRows {
1544 err = nil 1543 err = nil
1545 return 1544 return
@@ -114,8 +114,9 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DepartmentStat @@ -114,8 +114,9 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DepartmentStat
114 item := &protocol.DepartmentStatistics{} 114 item := &protocol.DepartmentStatistics{}
115 dIds := departmentsResponse.GetChildDepartmentIds(d, true) 115 dIds := departmentsResponse.GetChildDepartmentIds(d, true)
116 item.AchievementTotal, _ = agg.AchievementDepartmentStatic(header, 0, dIds) 116 item.AchievementTotal, _ = agg.AchievementDepartmentStatic(header, 0, dIds)
117 - item.ChanceApprovedTotal, _ = agg.GetChancePool(header.UserId, header.CompanyId, 0, d.DepartmentId, true, 0, 0, nil)  
118 - item.ACTotal = item.AchievementTotal + item.ChanceApprovedTotal 117 + item.ChanceApprovedTotal, _ = agg.GetChancePool(header.UserId, header.CompanyId, models.NewChancePoolOption(0, []int{}, models.ChancePool, 0), d.DepartmentId, true, 0, 0, nil)
  118 + item.ChanceReservedTotal, _ = agg.GetChancePool(header.UserId, header.CompanyId, models.NewChancePoolOption(0, []int{}, models.ChanceReserve, 0), d.DepartmentId, true, 0, 0, nil)
  119 + item.ACTotal = item.AchievementTotal + item.ChanceApprovedTotal + item.ChanceReservedTotal
119 item.ChanceApprovingTotal, _ = agg.ChanceApprovingStatistic(header, departmentsResponse.GetChildDepartmentIds(d, true)) 120 item.ChanceApprovingTotal, _ = agg.ChanceApprovingStatistic(header, departmentsResponse.GetChildDepartmentIds(d, true))
120 return item 121 return item
121 } 122 }
@@ -163,8 +164,9 @@ func DepartmentStatistic(header *protocol.RequestHeader, request *protocol.Depar @@ -163,8 +164,9 @@ func DepartmentStatistic(header *protocol.RequestHeader, request *protocol.Depar
163 return 164 return
164 } 165 }
165 departmentStatistic.AchievementTotal, _ = agg.AchievementDepartmentStatic(header, 0, dIds) 166 departmentStatistic.AchievementTotal, _ = agg.AchievementDepartmentStatic(header, 0, dIds)
166 - departmentStatistic.ChanceApprovedTotal, _ = agg.GetChancePool(header.UserId, header.CompanyId, 0, int(request.DepartmentId), false, 0, 0, nil)  
167 - departmentStatistic.ACTotal = departmentStatistic.AchievementTotal + departmentStatistic.ChanceApprovedTotal 167 + departmentStatistic.ChanceApprovedTotal, _ = agg.GetChancePool(header.UserId, header.CompanyId, models.NewChancePoolOption(0, []int{}, models.ChancePool, 0), int(request.DepartmentId), false, 0, 0, nil)
  168 + departmentStatistic.ChanceReservedTotal, _ = agg.GetChancePool(header.UserId, header.CompanyId, models.NewChancePoolOption(0, []int{}, models.ChanceReserve, 0), int(request.DepartmentId), false, 0, 0, nil)
  169 + departmentStatistic.ACTotal = departmentStatistic.AchievementTotal + departmentStatistic.ChanceApprovedTotal + departmentStatistic.ChanceReservedTotal
168 departmentStatistic.ChanceApprovingTotal, _ = agg.ChanceApprovingStatistic(header, dIds) 170 departmentStatistic.ChanceApprovingTotal, _ = agg.ChanceApprovingStatistic(header, dIds)
169 rsp.DepartmentStatistic = departmentStatistic 171 rsp.DepartmentStatistic = departmentStatistic
170 return 172 return