作者 唐旭辉

bug 修改

... ... @@ -59,13 +59,13 @@ func (c *AuditController) AuditListBefore() {
chanceTypeList := servecommon.SeleteGetChanceTypeList(companyId)
departmentList := servecommon.SelectorDepartment(companyId, -1)
publicStatus := models.ChancePublishStatusMap
enableStatus := models.ChanceEnableStatusMap
Status := models.ChanceStatusMap
reviewStatus := models.ChanceReviewStatusMap
data := map[string]interface{}{
"template": templatelist,
"chance_type": chanceTypeList,
"public_status": publicStatus,
"enable_status": enableStatus,
"enable_status": Status,
"review_status": reviewStatus,
"department": departmentList,
}
... ...
... ... @@ -32,6 +32,7 @@ type Chance struct {
AuditLevel int `orm:"column(audit_level)" description:"当前审批步骤"`
ApproveData string `orm:"column(approve_data);size(500);null" description:"公开数据 (公开状态 公开对象)"`
Code string `orm:"column(code)" description:"机会编码"`
Status int8 `orm:"column(status)" description:"机会状态 1:开启 2:关闭"`
}
func (t *Chance) TableName() string {
... ... @@ -58,12 +59,12 @@ var ChancePublishStatusMap = map[int]string{
// 审核状态 0:待处理 1:待审核 2:被退回 3:已通过
const (
// ChanceReviewStatusWait int = 0
ChanceReviewStatusIng int = 1
ChanceReviewStatusNo int = 2
ChanceReviewStatusYes int = 3
ChanceReviewStatusIng int8 = 1
ChanceReviewStatusNo int8 = 2
ChanceReviewStatusYes int8 = 3
)
var ChanceReviewStatusMap = map[int]string{
var ChanceReviewStatusMap = map[int8]string{
// ChanceReviewStatusWait: "待处理",
ChanceReviewStatusIng: "待审核",
ChanceReviewStatusNo: "被退回",
... ... @@ -81,6 +82,17 @@ var ChanceEnableStatusMap = map[int8]string{
ChanceEnableStatusYes: "有效",
}
//机会的开启关闭状态 1:已开启 2:已关闭
const (
ChanceStatusAllow int8 = 1
ChanceStatusForbid int8 = 2
)
var ChanceStatusMap = map[int8]string{
ChanceStatusAllow: "已开启",
ChanceStatusForbid: "已关闭",
}
// AddChance insert a new Chance into database and returns
// last inserted Id on success.
func AddChance(m *Chance) (id int64, err error) {
... ...
... ... @@ -262,10 +262,10 @@ type RspAuditList struct {
CreateTime int64 `json:"create_time"` //提交时间
PublishStatus int `json:"publish_status"` //公开状态
PublishStatusName string `json:"publish_status_name"` //
ReviewStatus int `json:"review_status"` //审批状态
ReviewStatus int8 `json:"review_status"` //审批状态
ReviewStatusName string `json:"review_status_name"`
EnableStatus int8 `json:"enable_status"`
EnableStatusName string `json:"enable_status_name"`
Status int8 `json:"status"` //开启、关闭状态
StatusName string `json:"status_name"`
DiscoveryScore string `json:"discovery_score"`
CommentTotal string `json:"comment_total"`
}
... ...
... ... @@ -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")
... ...