作者 唐旭辉

bug 修改

@@ -59,13 +59,13 @@ func (c *AuditController) AuditListBefore() { @@ -59,13 +59,13 @@ func (c *AuditController) AuditListBefore() {
59 chanceTypeList := servecommon.SeleteGetChanceTypeList(companyId) 59 chanceTypeList := servecommon.SeleteGetChanceTypeList(companyId)
60 departmentList := servecommon.SelectorDepartment(companyId, -1) 60 departmentList := servecommon.SelectorDepartment(companyId, -1)
61 publicStatus := models.ChancePublishStatusMap 61 publicStatus := models.ChancePublishStatusMap
62 - enableStatus := models.ChanceEnableStatusMap 62 + Status := models.ChanceStatusMap
63 reviewStatus := models.ChanceReviewStatusMap 63 reviewStatus := models.ChanceReviewStatusMap
64 data := map[string]interface{}{ 64 data := map[string]interface{}{
65 "template": templatelist, 65 "template": templatelist,
66 "chance_type": chanceTypeList, 66 "chance_type": chanceTypeList,
67 "public_status": publicStatus, 67 "public_status": publicStatus,
68 - "enable_status": enableStatus, 68 + "enable_status": Status,
69 "review_status": reviewStatus, 69 "review_status": reviewStatus,
70 "department": departmentList, 70 "department": departmentList,
71 } 71 }
@@ -32,6 +32,7 @@ type Chance struct { @@ -32,6 +32,7 @@ type Chance struct {
32 AuditLevel int `orm:"column(audit_level)" description:"当前审批步骤"` 32 AuditLevel int `orm:"column(audit_level)" description:"当前审批步骤"`
33 ApproveData string `orm:"column(approve_data);size(500);null" description:"公开数据 (公开状态 公开对象)"` 33 ApproveData string `orm:"column(approve_data);size(500);null" description:"公开数据 (公开状态 公开对象)"`
34 Code string `orm:"column(code)" description:"机会编码"` 34 Code string `orm:"column(code)" description:"机会编码"`
  35 + Status int8 `orm:"column(status)" description:"机会状态 1:开启 2:关闭"`
35 } 36 }
36 37
37 func (t *Chance) TableName() string { 38 func (t *Chance) TableName() string {
@@ -58,12 +59,12 @@ var ChancePublishStatusMap = map[int]string{ @@ -58,12 +59,12 @@ var ChancePublishStatusMap = map[int]string{
58 // 审核状态 0:待处理 1:待审核 2:被退回 3:已通过 59 // 审核状态 0:待处理 1:待审核 2:被退回 3:已通过
59 const ( 60 const (
60 // ChanceReviewStatusWait int = 0 61 // ChanceReviewStatusWait int = 0
61 - ChanceReviewStatusIng int = 1  
62 - ChanceReviewStatusNo int = 2  
63 - ChanceReviewStatusYes int = 3 62 + ChanceReviewStatusIng int8 = 1
  63 + ChanceReviewStatusNo int8 = 2
  64 + ChanceReviewStatusYes int8 = 3
64 ) 65 )
65 66
66 -var ChanceReviewStatusMap = map[int]string{ 67 +var ChanceReviewStatusMap = map[int8]string{
67 // ChanceReviewStatusWait: "待处理", 68 // ChanceReviewStatusWait: "待处理",
68 ChanceReviewStatusIng: "待审核", 69 ChanceReviewStatusIng: "待审核",
69 ChanceReviewStatusNo: "被退回", 70 ChanceReviewStatusNo: "被退回",
@@ -81,6 +82,17 @@ var ChanceEnableStatusMap = map[int8]string{ @@ -81,6 +82,17 @@ var ChanceEnableStatusMap = map[int8]string{
81 ChanceEnableStatusYes: "有效", 82 ChanceEnableStatusYes: "有效",
82 } 83 }
83 84
  85 +//机会的开启关闭状态 1:已开启 2:已关闭
  86 +const (
  87 + ChanceStatusAllow int8 = 1
  88 + ChanceStatusForbid int8 = 2
  89 +)
  90 +
  91 +var ChanceStatusMap = map[int8]string{
  92 + ChanceStatusAllow: "已开启",
  93 + ChanceStatusForbid: "已关闭",
  94 +}
  95 +
84 // AddChance insert a new Chance into database and returns 96 // AddChance insert a new Chance into database and returns
85 // last inserted Id on success. 97 // last inserted Id on success.
86 func AddChance(m *Chance) (id int64, err error) { 98 func AddChance(m *Chance) (id int64, err error) {
@@ -262,10 +262,10 @@ type RspAuditList struct { @@ -262,10 +262,10 @@ type RspAuditList struct {
262 CreateTime int64 `json:"create_time"` //提交时间 262 CreateTime int64 `json:"create_time"` //提交时间
263 PublishStatus int `json:"publish_status"` //公开状态 263 PublishStatus int `json:"publish_status"` //公开状态
264 PublishStatusName string `json:"publish_status_name"` // 264 PublishStatusName string `json:"publish_status_name"` //
265 - ReviewStatus int `json:"review_status"` //审批状态 265 + ReviewStatus int8 `json:"review_status"` //审批状态
266 ReviewStatusName string `json:"review_status_name"` 266 ReviewStatusName string `json:"review_status_name"`
267 - EnableStatus int8 `json:"enable_status"`  
268 - EnableStatusName string `json:"enable_status_name"` 267 + Status int8 `json:"status"` //开启、关闭状态
  268 + StatusName string `json:"status_name"`
269 DiscoveryScore string `json:"discovery_score"` 269 DiscoveryScore string `json:"discovery_score"`
270 CommentTotal string `json:"comment_total"` 270 CommentTotal string `json:"comment_total"`
271 } 271 }
@@ -22,8 +22,8 @@ type SqlData struct { @@ -22,8 +22,8 @@ type SqlData struct {
22 ChanceTypeId int `orm:"column(chance_type_id)"` 22 ChanceTypeId int `orm:"column(chance_type_id)"`
23 PublishStatus int `orm:"column(publish_status)"` 23 PublishStatus int `orm:"column(publish_status)"`
24 CreateAt time.Time `orm:"column(create_at);type(timestamp)"` 24 CreateAt time.Time `orm:"column(create_at);type(timestamp)"`
25 - ReviewStatus int `orm:"column(review_status)"`  
26 - EnableStatus int8 `orm:"column(enable_status)"` 25 + ReviewStatus int8 `orm:"column(review_status)"`
  26 + Status int8 `orm:"column(status)"`
27 DiscoveryScore string `orm:"column(discovery_score)"` 27 DiscoveryScore string `orm:"column(discovery_score)"`
28 CommentTotal string `orm:"column(comment_total)"` 28 CommentTotal string `orm:"column(comment_total)"`
29 Code string `orm:"column(code)"` 29 Code string `orm:"column(code)"`
@@ -39,22 +39,24 @@ func buildSqlForAuditList(usercompanyid int64, companyid int64, userid int64) st @@ -39,22 +39,24 @@ func buildSqlForAuditList(usercompanyid int64, companyid int64, userid int64) st
39 */ 39 */
40 var ( 40 var (
41 //自己提交的 41 //自己提交的
42 - sql1 string = fmt.Sprintf(` SELECT id FROM chance WHERE user_id=%d `, usercompanyid) 42 + sql1 string = fmt.Sprintf(` SELECT id FROM chance WHERE AND enable_status=1 AND user_id=%d `, usercompanyid)
43 //自己可审核的 43 //自己可审核的
44 sql2 string = fmt.Sprintf(` SELECT a.id FROM chance AS a 44 sql2 string = fmt.Sprintf(` SELECT a.id FROM chance AS a
45 JOIN audit_flow_process AS b ON a.id=b.chance_id 45 JOIN audit_flow_process AS b ON a.id=b.chance_id
46 - WHERE b.uid=%d `, usercompanyid) 46 + WHERE b.uid=%d AND a.enable_status=1 `, usercompanyid)
47 //公开到自己部门的 47 //公开到自己部门的
48 sql3 string = ` SELECT a.id FROM chance AS a 48 sql3 string = ` SELECT a.id FROM chance AS a
49 JOIN chance_department AS b ON a.id=b.chance_id 49 JOIN chance_department AS b ON a.id=b.chance_id
50 - WHERE b.department_id IN (%s) AND a.review_status = 3 AND a.publish_status=` + fmt.Sprint(models.ChancePublishStatus1) 50 + WHERE b.department_id IN (%s) AND a.review_status = 3
  51 + AND a.enable_status=1
  52 + AND a.publish_status=` + fmt.Sprint(models.ChancePublishStatus1)
51 //指定提交的部门 53 //指定提交的部门
52 - sql4 string = ` SELECT id FROM chance WHERE department_id IN (%s) and review_status =3 ` 54 + sql4 string = ` SELECT id FROM chance WHERE department_id IN (%s) and review_status =3 AND enable_status=1 `
53 55
54 //全公司公开的 56 //全公司公开的
55 - sql5 string = fmt.Sprintf(` SELECT id FROM chance where publish_status = %d AND review_status = 3 AND company_id=%d `, models.ChancePublishStatus2, companyid) 57 + sql5 string = fmt.Sprintf(` SELECT id FROM chance where publish_status = %d AND enable_status=1 AND review_status = 3 AND company_id=%d `, models.ChancePublishStatus2, companyid)
56 //查看所有公开的 58 //查看所有公开的
57 - sql6 string = fmt.Sprintf(`SELECT id FROM chance WHERE review_status =3 And company_id=%d `, companyid) 59 + sql6 string = fmt.Sprintf(`SELECT id FROM chance WHERE review_status =3 AND enable_status=1 And company_id=%d `, companyid)
58 60
59 allsql string = ` SELECT t.id FROM (%s) as t ` 61 allsql string = ` SELECT t.id FROM (%s) as t `
60 unionsql string = `` 62 unionsql string = ``
@@ -174,12 +176,12 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64 @@ -174,12 +176,12 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64
174 JOIN user_company AS c ON c.id = a.user_id 176 JOIN user_company AS c ON c.id = a.user_id
175 JOIN user AS d ON c.user_id = d.id 177 JOIN user AS d ON c.user_id = d.id
176 %s 178 %s
177 - where a.company_id=? ` 179 + where a.company_id=? AND a.enable_status=1 `
178 s2 := ` SELECT count(*) FROM chance as a 180 s2 := ` SELECT count(*) FROM chance as a
179 JOIN user_company AS c ON c.id = a.user_id 181 JOIN user_company AS c ON c.id = a.user_id
180 JOIN user AS d ON c.user_id = d.id 182 JOIN user AS d ON c.user_id = d.id
181 %s 183 %s
182 - where a.company_id=? ` 184 + where a.company_id=? AND a.enable_status=1 `
183 if companyinfo, err := models.GetCompanyById(companyid); err == nil { 185 if companyinfo, err := models.GetCompanyById(companyid); err == nil {
184 //非主管进行权限过滤 186 //非主管进行权限过滤
185 if companyinfo.AdminId != userid { 187 if companyinfo.AdminId != userid {
@@ -278,8 +280,8 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64 @@ -278,8 +280,8 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64
278 t := v.CreateAt.Unix() 280 t := v.CreateAt.Unix()
279 item := protocol.RspAuditList{ 281 item := protocol.RspAuditList{
280 Id: fmt.Sprint(v.Id), 282 Id: fmt.Sprint(v.Id),
281 - EnableStatus: v.EnableStatus,  
282 - EnableStatusName: models.ChanceEnableStatusMap[v.EnableStatus], 283 + Status: v.Status,
  284 + StatusName: models.ChanceStatusMap[v.Status],
283 PublishStatus: v.PublishStatus, 285 PublishStatus: v.PublishStatus,
284 PublishStatusName: models.ChancePublishStatusMap[v.PublishStatus], 286 PublishStatusName: models.ChancePublishStatusMap[v.PublishStatus],
285 ReviewStatus: v.ReviewStatus, 287 ReviewStatus: v.ReviewStatus,
@@ -439,9 +441,13 @@ func AllowChanceEnableStatus(chanceid int64, companyid int64) error { @@ -439,9 +441,13 @@ func AllowChanceEnableStatus(chanceid int64, companyid int64) error {
439 log.Error("机会的公司不匹配") 441 log.Error("机会的公司不匹配")
440 return protocol.NewErrWithMessage("1") 442 return protocol.NewErrWithMessage("1")
441 } 443 }
442 - chanceinfo.EnableStatus = models.ChanceEnableStatusYes 444 + //判定机会状态
  445 + if chanceinfo.ReviewStatus != models.ChanceReviewStatusYes {
  446 + return nil
  447 + }
  448 + chanceinfo.Status = models.ChanceStatusAllow
443 chanceinfo.UpdateAt = time.Now() 449 chanceinfo.UpdateAt = time.Now()
444 - err = models.UpdateChanceById(chanceinfo, []string{"EnableStatus", "UpdateAt"}) 450 + err = models.UpdateChanceById(chanceinfo, []string{"Status", "UpdateAt"})
445 if err != nil { 451 if err != nil {
446 log.Error("更新机会数据失败:%s", err) 452 log.Error("更新机会数据失败:%s", err)
447 return protocol.NewErrWithMessage("1") 453 return protocol.NewErrWithMessage("1")
@@ -463,9 +469,9 @@ func ForbidChanceEnableStatus(chanceid int64, companyid int64) error { @@ -463,9 +469,9 @@ func ForbidChanceEnableStatus(chanceid int64, companyid int64) error {
463 log.Error("机会的公司不匹配") 469 log.Error("机会的公司不匹配")
464 return protocol.NewErrWithMessage("1") 470 return protocol.NewErrWithMessage("1")
465 } 471 }
466 - chanceinfo.EnableStatus = models.ChanceEnableStatusNo 472 + chanceinfo.Status = models.ChanceStatusForbid
467 chanceinfo.UpdateAt = time.Now() 473 chanceinfo.UpdateAt = time.Now()
468 - err = models.UpdateChanceById(chanceinfo, []string{"EnableStatus", "UpdateAt"}) 474 + err = models.UpdateChanceById(chanceinfo, []string{"Status", "UpdateAt"})
469 if err != nil { 475 if err != nil {
470 log.Error("更新机会数据失败:%s", err) 476 log.Error("更新机会数据失败:%s", err)
471 return protocol.NewErrWithMessage("1") 477 return protocol.NewErrWithMessage("1")