...
|
...
|
@@ -20,11 +20,10 @@ type SqlData struct { |
|
|
PublishStatus int `orm:"column(publish_status)"`
|
|
|
CreateAt time.Time `orm:"column(create_at);type(timestamp)"`
|
|
|
ReviewStatus int `orm:"column(review_status)"`
|
|
|
EnableStatus int `orm:"column(enable_status)"`
|
|
|
EnableStatus int8 `orm:"column(enable_status)"`
|
|
|
DiscoveryScore string `orm:"column(discovery_score)"`
|
|
|
CommentTotal string `orm:"column(comment_total)"`
|
|
|
Code string `orm:"column(code)"`
|
|
|
TemplateName string `orm:"column(template_name)"`
|
|
|
}
|
|
|
|
|
|
func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64) (protocol.ResponseAuditList, error) {
|
...
|
...
|
@@ -46,13 +45,13 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64 |
|
|
}
|
|
|
datasql.WriteString(`SELECT a.id,a.user_id,a.department_id,a.audit_template_id,a.chance_type_id
|
|
|
,a.publish_status,a.create_at,a.review_status,a.enable_status
|
|
|
,a.discovery_score,a.comment_total,b.name AS template_name ,b.code
|
|
|
,a.discovery_score,a.comment_total ,a.code,d.nick_name
|
|
|
FROM chance AS a
|
|
|
JOIN audit_template AS b on a.audit_template_id = b.id
|
|
|
JOIN user_company AS c ON c.id = a.user_id
|
|
|
JOIN user AS d ON c.user_id = d.id
|
|
|
where a.company_id=? `)
|
|
|
|
|
|
countsql.WriteString(`SELECT count(*) FROM chance as a
|
|
|
JOIN audit_template AS b on a.audit_template_id = b.id
|
|
|
countsql.WriteString(`SELECT count(*) FROM chance as a
|
|
|
where a.company_id=? `)
|
|
|
cond = append(cond, companyid)
|
|
|
if param.ChanceTypeId > 0 {
|
...
|
...
|
@@ -86,15 +85,27 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64 |
|
|
datasql.WriteString(s)
|
|
|
countsql.WriteString(s)
|
|
|
}
|
|
|
if param.CreateTimeBegin > 0 && param.CreateTimeEnd > 0 {
|
|
|
cond = append(cond, param.CreateTimeBegin, param.CreateTimeEnd)
|
|
|
s := ` AND (UNIX_TIMESTAMP(a.create_at) BETWEEN ? AND ? ) `
|
|
|
if param.CreateTimeBegin > 0 {
|
|
|
cond = append(cond, param.CreateTimeBegin)
|
|
|
s := ` AND UNIX_TIMESTAMP(a.create_at)>=? `
|
|
|
datasql.WriteString(s)
|
|
|
countsql.WriteString(s)
|
|
|
}
|
|
|
if param.CreateTimeEnd > 0 {
|
|
|
cond = append(cond, param.CreateTimeEnd)
|
|
|
s := ` AND UNIX_TIMESTAMP(a.create_at)<=? `
|
|
|
datasql.WriteString(s)
|
|
|
countsql.WriteString(s)
|
|
|
}
|
|
|
if len(param.Code) > 0 {
|
|
|
cond = append(cond, param.Code)
|
|
|
s := ` And b.code=? `
|
|
|
cond = append(cond, "%"+param.Code+"%")
|
|
|
s := ` And a.code like ? `
|
|
|
datasql.WriteString(s)
|
|
|
countsql.WriteString(s)
|
|
|
}
|
|
|
if len(param.UserName) > 0 {
|
|
|
cond = append(cond, "%"+param.UserName+"%")
|
|
|
s := ` And d.nick_name like ? `
|
|
|
datasql.WriteString(s)
|
|
|
countsql.WriteString(s)
|
|
|
}
|
...
|
...
|
@@ -124,7 +135,6 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64 |
|
|
ReviewStatus: v.ReviewStatus,
|
|
|
ReviewStatusName: models.ChanceReviewStatusMap[v.ReviewStatus],
|
|
|
Code: v.Code,
|
|
|
TemplateName: v.TemplateName,
|
|
|
}
|
|
|
|
|
|
if t < 0 {
|
...
|
...
|
@@ -141,6 +151,9 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64 |
|
|
if ct, err := models.GetChanceTypeById(v.ChanceTypeId); err == nil {
|
|
|
item.ChanceType = ct.Name
|
|
|
}
|
|
|
if tp, err := models.GetAuditTemplateById(v.AuditTemplateId); err == nil {
|
|
|
item.TemplateName = tp.Name
|
|
|
}
|
|
|
returnData.List = append(returnData.List, item)
|
|
|
|
|
|
}
|
...
|
...
|
@@ -261,3 +274,51 @@ func getAuditFlowLog(chanceid int64) ([]protocol.ChanceFlowLog, error) { |
|
|
err = utils.ExecuteQueryAll(&flowLogs, datasql, chanceid)
|
|
|
return flowLogs, err
|
|
|
}
|
|
|
|
|
|
func AllowChanceEnableStatus(chanceid int64, companyid int64) error {
|
|
|
var (
|
|
|
err error
|
|
|
chanceinfo *models.Chance
|
|
|
)
|
|
|
chanceinfo, err = models.GetChanceById(chanceid)
|
|
|
if err != nil {
|
|
|
log.Error("获取机会数据失败:%s", err)
|
|
|
return protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
if chanceinfo.CompanyId != companyid {
|
|
|
log.Error("机会的公司不匹配")
|
|
|
return protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
chanceinfo.EnableStatus = models.ChanceEnableStatusYes
|
|
|
chanceinfo.UpdateAt = time.Now()
|
|
|
err = models.UpdateChanceById(chanceinfo, []string{"EnableStatus", "UpdateAt"})
|
|
|
if err != nil {
|
|
|
log.Error("更新机会数据失败:%s", err)
|
|
|
return protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func ForbidChanceEnableStatus(chanceid int64, companyid int64) error {
|
|
|
var (
|
|
|
err error
|
|
|
chanceinfo *models.Chance
|
|
|
)
|
|
|
chanceinfo, err = models.GetChanceById(chanceid)
|
|
|
if err != nil {
|
|
|
log.Error("获取机会数据失败:%s", err)
|
|
|
return protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
if chanceinfo.CompanyId != companyid {
|
|
|
log.Error("机会的公司不匹配")
|
|
|
return protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
chanceinfo.EnableStatus = models.ChanceEnableStatusNo
|
|
|
chanceinfo.UpdateAt = time.Now()
|
|
|
err = models.UpdateChanceById(chanceinfo, []string{"EnableStatus", "UpdateAt"})
|
|
|
if err != nil {
|
|
|
log.Error("更新机会数据失败:%s", err)
|
|
|
return protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
return nil
|
|
|
} |
...
|
...
|
|