|
@@ -20,11 +20,10 @@ type SqlData struct { |
|
@@ -20,11 +20,10 @@ type SqlData struct { |
20
|
PublishStatus int `orm:"column(publish_status)"`
|
20
|
PublishStatus int `orm:"column(publish_status)"`
|
21
|
CreateAt time.Time `orm:"column(create_at);type(timestamp)"`
|
21
|
CreateAt time.Time `orm:"column(create_at);type(timestamp)"`
|
22
|
ReviewStatus int `orm:"column(review_status)"`
|
22
|
ReviewStatus int `orm:"column(review_status)"`
|
23
|
- EnableStatus int `orm:"column(enable_status)"`
|
23
|
+ EnableStatus int8 `orm:"column(enable_status)"`
|
24
|
DiscoveryScore string `orm:"column(discovery_score)"`
|
24
|
DiscoveryScore string `orm:"column(discovery_score)"`
|
25
|
CommentTotal string `orm:"column(comment_total)"`
|
25
|
CommentTotal string `orm:"column(comment_total)"`
|
26
|
Code string `orm:"column(code)"`
|
26
|
Code string `orm:"column(code)"`
|
27
|
- TemplateName string `orm:"column(template_name)"`
|
|
|
28
|
}
|
27
|
}
|
29
|
|
28
|
|
30
|
func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64) (protocol.ResponseAuditList, error) {
|
29
|
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 |
|
@@ -46,13 +45,13 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64 |
46
|
}
|
45
|
}
|
47
|
datasql.WriteString(`SELECT a.id,a.user_id,a.department_id,a.audit_template_id,a.chance_type_id
|
46
|
datasql.WriteString(`SELECT a.id,a.user_id,a.department_id,a.audit_template_id,a.chance_type_id
|
48
|
,a.publish_status,a.create_at,a.review_status,a.enable_status
|
47
|
,a.publish_status,a.create_at,a.review_status,a.enable_status
|
49
|
- ,a.discovery_score,a.comment_total,b.name AS template_name ,b.code
|
48
|
+ ,a.discovery_score,a.comment_total ,a.code,d.nick_name
|
50
|
FROM chance AS a
|
49
|
FROM chance AS a
|
51
|
- JOIN audit_template AS b on a.audit_template_id = b.id
|
50
|
+ JOIN user_company AS c ON c.id = a.user_id
|
|
|
51
|
+ JOIN user AS d ON c.user_id = d.id
|
52
|
where a.company_id=? `)
|
52
|
where a.company_id=? `)
|
53
|
|
53
|
|
54
|
- countsql.WriteString(`SELECT count(*) FROM chance as a
|
|
|
55
|
- JOIN audit_template AS b on a.audit_template_id = b.id
|
54
|
+ countsql.WriteString(`SELECT count(*) FROM chance as a
|
56
|
where a.company_id=? `)
|
55
|
where a.company_id=? `)
|
57
|
cond = append(cond, companyid)
|
56
|
cond = append(cond, companyid)
|
58
|
if param.ChanceTypeId > 0 {
|
57
|
if param.ChanceTypeId > 0 {
|
|
@@ -99,8 +98,14 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64 |
|
@@ -99,8 +98,14 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64 |
99
|
countsql.WriteString(s)
|
98
|
countsql.WriteString(s)
|
100
|
}
|
99
|
}
|
101
|
if len(param.Code) > 0 {
|
100
|
if len(param.Code) > 0 {
|
102
|
- cond = append(cond, param.Code)
|
|
|
103
|
- s := ` And b.code=? `
|
101
|
+ cond = append(cond, "%"+param.Code+"%")
|
|
|
102
|
+ s := ` And a.code like ? `
|
|
|
103
|
+ datasql.WriteString(s)
|
|
|
104
|
+ countsql.WriteString(s)
|
|
|
105
|
+ }
|
|
|
106
|
+ if len(param.UserName) > 0 {
|
|
|
107
|
+ cond = append(cond, "%"+param.UserName+"%")
|
|
|
108
|
+ s := ` And d.nick_name like ? `
|
104
|
datasql.WriteString(s)
|
109
|
datasql.WriteString(s)
|
105
|
countsql.WriteString(s)
|
110
|
countsql.WriteString(s)
|
106
|
}
|
111
|
}
|
|
@@ -129,8 +134,7 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64 |
|
@@ -129,8 +134,7 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64 |
129
|
PublishStatusName: models.ChancePublishStatusMap[v.PublishStatus],
|
134
|
PublishStatusName: models.ChancePublishStatusMap[v.PublishStatus],
|
130
|
ReviewStatus: v.ReviewStatus,
|
135
|
ReviewStatus: v.ReviewStatus,
|
131
|
ReviewStatusName: models.ChanceReviewStatusMap[v.ReviewStatus],
|
136
|
ReviewStatusName: models.ChanceReviewStatusMap[v.ReviewStatus],
|
132
|
- TemplateCode: v.Code,
|
|
|
133
|
- TemplateName: v.TemplateName,
|
137
|
+ Code: v.Code,
|
134
|
}
|
138
|
}
|
135
|
|
139
|
|
136
|
if t < 0 {
|
140
|
if t < 0 {
|
|
@@ -146,7 +150,9 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64 |
|
@@ -146,7 +150,9 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64 |
146
|
}
|
150
|
}
|
147
|
if ct, err := models.GetChanceTypeById(v.ChanceTypeId); err == nil {
|
151
|
if ct, err := models.GetChanceTypeById(v.ChanceTypeId); err == nil {
|
148
|
item.ChanceType = ct.Name
|
152
|
item.ChanceType = ct.Name
|
149
|
- item.ChanceTypeCode = ct.Code
|
153
|
+ }
|
|
|
154
|
+ if tp, err := models.GetAuditTemplateById(v.AuditTemplateId); err == nil {
|
|
|
155
|
+ item.TemplateName = tp.Name
|
150
|
}
|
156
|
}
|
151
|
returnData.List = append(returnData.List, item)
|
157
|
returnData.List = append(returnData.List, item)
|
152
|
|
158
|
|
|
@@ -268,3 +274,51 @@ func getAuditFlowLog(chanceid int64) ([]protocol.ChanceFlowLog, error) { |
|
@@ -268,3 +274,51 @@ func getAuditFlowLog(chanceid int64) ([]protocol.ChanceFlowLog, error) { |
268
|
err = utils.ExecuteQueryAll(&flowLogs, datasql, chanceid)
|
274
|
err = utils.ExecuteQueryAll(&flowLogs, datasql, chanceid)
|
269
|
return flowLogs, err
|
275
|
return flowLogs, err
|
270
|
}
|
276
|
}
|
|
|
277
|
+
|
|
|
278
|
+func AllowChanceEnableStatus(chanceid int64, companyid int64) error {
|
|
|
279
|
+ var (
|
|
|
280
|
+ err error
|
|
|
281
|
+ chanceinfo *models.Chance
|
|
|
282
|
+ )
|
|
|
283
|
+ chanceinfo, err = models.GetChanceById(chanceid)
|
|
|
284
|
+ if err != nil {
|
|
|
285
|
+ log.Error("获取机会数据失败:%s", err)
|
|
|
286
|
+ return protocol.NewErrWithMessage("1")
|
|
|
287
|
+ }
|
|
|
288
|
+ if chanceinfo.CompanyId != companyid {
|
|
|
289
|
+ log.Error("机会的公司不匹配")
|
|
|
290
|
+ return protocol.NewErrWithMessage("1")
|
|
|
291
|
+ }
|
|
|
292
|
+ chanceinfo.EnableStatus = models.ChanceEnableStatusYes
|
|
|
293
|
+ chanceinfo.UpdateAt = time.Now()
|
|
|
294
|
+ err = models.UpdateChanceById(chanceinfo, []string{"EnableStatus", "UpdateAt"})
|
|
|
295
|
+ if err != nil {
|
|
|
296
|
+ log.Error("更新机会数据失败:%s", err)
|
|
|
297
|
+ return protocol.NewErrWithMessage("1")
|
|
|
298
|
+ }
|
|
|
299
|
+ return nil
|
|
|
300
|
+}
|
|
|
301
|
+
|
|
|
302
|
+func ForbidChanceEnableStatus(chanceid int64, companyid int64) error {
|
|
|
303
|
+ var (
|
|
|
304
|
+ err error
|
|
|
305
|
+ chanceinfo *models.Chance
|
|
|
306
|
+ )
|
|
|
307
|
+ chanceinfo, err = models.GetChanceById(chanceid)
|
|
|
308
|
+ if err != nil {
|
|
|
309
|
+ log.Error("获取机会数据失败:%s", err)
|
|
|
310
|
+ return protocol.NewErrWithMessage("1")
|
|
|
311
|
+ }
|
|
|
312
|
+ if chanceinfo.CompanyId != companyid {
|
|
|
313
|
+ log.Error("机会的公司不匹配")
|
|
|
314
|
+ return protocol.NewErrWithMessage("1")
|
|
|
315
|
+ }
|
|
|
316
|
+ chanceinfo.EnableStatus = models.ChanceEnableStatusNo
|
|
|
317
|
+ chanceinfo.UpdateAt = time.Now()
|
|
|
318
|
+ err = models.UpdateChanceById(chanceinfo, []string{"EnableStatus", "UpdateAt"})
|
|
|
319
|
+ if err != nil {
|
|
|
320
|
+ log.Error("更新机会数据失败:%s", err)
|
|
|
321
|
+ return protocol.NewErrWithMessage("1")
|
|
|
322
|
+ }
|
|
|
323
|
+ return nil
|
|
|
324
|
+} |