...
|
...
|
@@ -22,8 +22,8 @@ type SqlData struct { |
|
|
ChanceTypeId int `orm:"column(chance_type_id)"`
|
|
|
PublishStatus int `orm:"column(publish_status)"`
|
|
|
CreateAt time.Time `orm:"column(create_at);type(timestamp)"`
|
|
|
ReviewStatus int `orm:"column(review_status)"`
|
|
|
EnableStatus int8 `orm:"column(enable_status)"`
|
|
|
ReviewStatus int8 `orm:"column(review_status)"`
|
|
|
Status int8 `orm:"column(status)"`
|
|
|
DiscoveryScore string `orm:"column(discovery_score)"`
|
|
|
CommentTotal string `orm:"column(comment_total)"`
|
|
|
Code string `orm:"column(code)"`
|
...
|
...
|
@@ -39,22 +39,24 @@ func buildSqlForAuditList(usercompanyid int64, companyid int64, userid int64) st |
|
|
*/
|
|
|
var (
|
|
|
//自己提交的
|
|
|
sql1 string = fmt.Sprintf(` SELECT id FROM chance WHERE user_id=%d `, usercompanyid)
|
|
|
sql1 string = fmt.Sprintf(` SELECT id FROM chance WHERE AND enable_status=1 AND user_id=%d `, usercompanyid)
|
|
|
//自己可审核的
|
|
|
sql2 string = fmt.Sprintf(` SELECT a.id FROM chance AS a
|
|
|
JOIN audit_flow_process AS b ON a.id=b.chance_id
|
|
|
WHERE b.uid=%d `, usercompanyid)
|
|
|
WHERE b.uid=%d AND a.enable_status=1 `, usercompanyid)
|
|
|
//公开到自己部门的
|
|
|
sql3 string = ` SELECT a.id FROM chance AS a
|
|
|
JOIN chance_department AS b ON a.id=b.chance_id
|
|
|
WHERE b.department_id IN (%s) AND a.review_status = 3 AND a.publish_status=` + fmt.Sprint(models.ChancePublishStatus1)
|
|
|
WHERE b.department_id IN (%s) AND a.review_status = 3
|
|
|
AND a.enable_status=1
|
|
|
AND a.publish_status=` + fmt.Sprint(models.ChancePublishStatus1)
|
|
|
//指定提交的部门
|
|
|
sql4 string = ` SELECT id FROM chance WHERE department_id IN (%s) and review_status =3 `
|
|
|
sql4 string = ` SELECT id FROM chance WHERE department_id IN (%s) and review_status =3 AND enable_status=1 `
|
|
|
|
|
|
//全公司公开的
|
|
|
sql5 string = fmt.Sprintf(` SELECT id FROM chance where publish_status = %d AND review_status = 3 AND company_id=%d `, models.ChancePublishStatus2, companyid)
|
|
|
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)
|
|
|
//查看所有公开的
|
|
|
sql6 string = fmt.Sprintf(`SELECT id FROM chance WHERE review_status =3 And company_id=%d `, companyid)
|
|
|
sql6 string = fmt.Sprintf(`SELECT id FROM chance WHERE review_status =3 AND enable_status=1 And company_id=%d `, companyid)
|
|
|
|
|
|
allsql string = ` SELECT t.id FROM (%s) as t `
|
|
|
unionsql string = ``
|
...
|
...
|
@@ -174,12 +176,12 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64 |
|
|
JOIN user_company AS c ON c.id = a.user_id
|
|
|
JOIN user AS d ON c.user_id = d.id
|
|
|
%s
|
|
|
where a.company_id=? `
|
|
|
where a.company_id=? AND a.enable_status=1 `
|
|
|
s2 := ` SELECT count(*) FROM chance as a
|
|
|
JOIN user_company AS c ON c.id = a.user_id
|
|
|
JOIN user AS d ON c.user_id = d.id
|
|
|
%s
|
|
|
where a.company_id=? `
|
|
|
where a.company_id=? AND a.enable_status=1 `
|
|
|
if companyinfo, err := models.GetCompanyById(companyid); err == nil {
|
|
|
//非主管进行权限过滤
|
|
|
if companyinfo.AdminId != userid {
|
...
|
...
|
@@ -278,8 +280,8 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64 |
|
|
t := v.CreateAt.Unix()
|
|
|
item := protocol.RspAuditList{
|
|
|
Id: fmt.Sprint(v.Id),
|
|
|
EnableStatus: v.EnableStatus,
|
|
|
EnableStatusName: models.ChanceEnableStatusMap[v.EnableStatus],
|
|
|
Status: v.Status,
|
|
|
StatusName: models.ChanceStatusMap[v.Status],
|
|
|
PublishStatus: v.PublishStatus,
|
|
|
PublishStatusName: models.ChancePublishStatusMap[v.PublishStatus],
|
|
|
ReviewStatus: v.ReviewStatus,
|
...
|
...
|
@@ -439,9 +441,13 @@ func AllowChanceEnableStatus(chanceid int64, companyid int64) error { |
|
|
log.Error("机会的公司不匹配")
|
|
|
return protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
chanceinfo.EnableStatus = models.ChanceEnableStatusYes
|
|
|
//判定机会状态
|
|
|
if chanceinfo.ReviewStatus != models.ChanceReviewStatusYes {
|
|
|
return nil
|
|
|
}
|
|
|
chanceinfo.Status = models.ChanceStatusAllow
|
|
|
chanceinfo.UpdateAt = time.Now()
|
|
|
err = models.UpdateChanceById(chanceinfo, []string{"EnableStatus", "UpdateAt"})
|
|
|
err = models.UpdateChanceById(chanceinfo, []string{"Status", "UpdateAt"})
|
|
|
if err != nil {
|
|
|
log.Error("更新机会数据失败:%s", err)
|
|
|
return protocol.NewErrWithMessage("1")
|
...
|
...
|
@@ -463,9 +469,9 @@ func ForbidChanceEnableStatus(chanceid int64, companyid int64) error { |
|
|
log.Error("机会的公司不匹配")
|
|
|
return protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
chanceinfo.EnableStatus = models.ChanceEnableStatusNo
|
|
|
chanceinfo.Status = models.ChanceStatusForbid
|
|
|
chanceinfo.UpdateAt = time.Now()
|
|
|
err = models.UpdateChanceById(chanceinfo, []string{"EnableStatus", "UpdateAt"})
|
|
|
err = models.UpdateChanceById(chanceinfo, []string{"Status", "UpdateAt"})
|
|
|
if err != nil {
|
|
|
log.Error("更新机会数据失败:%s", err)
|
|
|
return protocol.NewErrWithMessage("1")
|
...
|
...
|
|