正在显示
12 个修改的文件
包含
544 行增加
和
69 行删除
@@ -32,8 +32,10 @@ | @@ -32,8 +32,10 @@ | ||
32 | |机会更新| | | | | 32 | |机会更新| | | | |
33 | |机会删除| | |/v1/chance/delete| | 33 | |机会删除| | |/v1/chance/delete| |
34 | |我的机会-我的审核| | | | | 34 | |我的机会-我的审核| | | | |
35 | -|机会审核(评分/修改公开状态)| | | | | ||
36 | -|计算发现分| | | | | 35 | +|机会审核| | | /v1/chance/approve| |
36 | +|机会修改评分| | |/v1/chance/changeScore| | ||
37 | +|机会修改公开状态| | |/v1/chance/changePublish| | ||
38 | +|计算发现分| | |/v1/chance/calculateScore| | ||
37 | |用户机会权限| | | | | 39 | |用户机会权限| | | | |
38 | |机会池| | | | | 40 | |机会池| | | | |
39 | |消息-点赞| | |v1/message/msgInteractive| | 41 | |消息-点赞| | |v1/message/msgInteractive| |
@@ -54,9 +54,12 @@ func (this *BaseController) Valid(obj interface{}) (result bool, msg *protocol.R | @@ -54,9 +54,12 @@ func (this *BaseController) Valid(obj interface{}) (result bool, msg *protocol.R | ||
54 | var err error | 54 | var err error |
55 | valid := validation.Validation{} | 55 | valid := validation.Validation{} |
56 | result, err = valid.Valid(obj) | 56 | result, err = valid.Valid(obj) |
57 | + //if err != nil { | ||
58 | + // log.Error(err) | ||
59 | + // msg = protocol.BadRequestParam(2) | ||
60 | + // return | ||
61 | + //} | ||
57 | if err != nil { | 62 | if err != nil { |
58 | - msg = protocol.BadRequestParam(1) | ||
59 | - return | ||
60 | } | 63 | } |
61 | if !result { | 64 | if !result { |
62 | for _, err := range valid.Errors { | 65 | for _, err := range valid.Errors { |
@@ -4,7 +4,6 @@ import ( | @@ -4,7 +4,6 @@ import ( | ||
4 | "encoding/json" | 4 | "encoding/json" |
5 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | 5 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" |
6 | "opp/controllers" | 6 | "opp/controllers" |
7 | - "opp/internal/utils" | ||
8 | "opp/protocol" | 7 | "opp/protocol" |
9 | "opp/services/chance" | 8 | "opp/services/chance" |
10 | ) | 9 | ) |
@@ -346,7 +345,7 @@ func (this *ChanceController) ChanceApprove() { | @@ -346,7 +345,7 @@ func (this *ChanceController) ChanceApprove() { | ||
346 | var request *protocol.ChanceApproveRequest | 345 | var request *protocol.ChanceApproveRequest |
347 | if err := json.Unmarshal(this.ByteBody, &request); err != nil { | 346 | if err := json.Unmarshal(this.ByteBody, &request); err != nil { |
348 | log.Error(err) | 347 | log.Error(err) |
349 | - msg = protocol.BadRequestParam(1) | 348 | + msg = protocol.BadRequestParam(2) |
350 | return | 349 | return |
351 | } | 350 | } |
352 | if b, m := this.Valid(request); !b { | 351 | if b, m := this.Valid(request); !b { |
@@ -354,15 +353,8 @@ func (this *ChanceController) ChanceApprove() { | @@ -354,15 +353,8 @@ func (this *ChanceController) ChanceApprove() { | ||
354 | return | 353 | return |
355 | } | 354 | } |
356 | if request.ReviewStatus == protocol.ReviewStatusPass { | 355 | if request.ReviewStatus == protocol.ReviewStatusPass { |
357 | - if utils.IsNil(request.ApproveData) { | ||
358 | - msg = protocol.BadRequestParam(5204) | ||
359 | - return | ||
360 | - } | ||
361 | - if utils.IsNil(request.ApproveData.PublicData) { | ||
362 | - msg = protocol.BadRequestParam(5204) | ||
363 | - return | ||
364 | - } | ||
365 | - if utils.IsNil(request.ApproveData.PublicData) { | 356 | + status := request.ApproveData.PublicData.PublishStatus |
357 | + if !(status == protocol.NoPublic || status == protocol.PublicToDepartment || status == protocol.PublicToCompany) { | ||
366 | msg = protocol.BadRequestParam(5204) | 358 | msg = protocol.BadRequestParam(5204) |
367 | return | 359 | return |
368 | } | 360 | } |
@@ -370,3 +362,87 @@ func (this *ChanceController) ChanceApprove() { | @@ -370,3 +362,87 @@ func (this *ChanceController) ChanceApprove() { | ||
370 | header := controllers.GetRequestHeader(this.Ctx) | 362 | header := controllers.GetRequestHeader(this.Ctx) |
371 | msg = protocol.NewReturnResponse(chance.ChanceApprove(header, request)) | 363 | msg = protocol.NewReturnResponse(chance.ChanceApprove(header, request)) |
372 | } | 364 | } |
365 | + | ||
366 | +//ChanceChangePublish 修改公开状态 | ||
367 | +//@router /changePublish [post] | ||
368 | +func (this *ChanceController) ChanceChangePublish() { | ||
369 | + var msg *protocol.ResponseMessage | ||
370 | + defer func() { | ||
371 | + this.Resp(msg) | ||
372 | + }() | ||
373 | + var request *protocol.ChanceChangePublishRequest | ||
374 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
375 | + log.Error(err) | ||
376 | + msg = protocol.BadRequestParam(1) | ||
377 | + return | ||
378 | + } | ||
379 | + if b, m := this.Valid(request); !b { | ||
380 | + msg = m | ||
381 | + return | ||
382 | + } | ||
383 | + header := controllers.GetRequestHeader(this.Ctx) | ||
384 | + msg = protocol.NewReturnResponse(chance.ChanceChangePublish(header, request)) | ||
385 | +} | ||
386 | + | ||
387 | +//ChanceChangeScore 修改评分 | ||
388 | +//@router /changeScore [post] | ||
389 | +func (this *ChanceController) ChanceChangeScore() { | ||
390 | + var msg *protocol.ResponseMessage | ||
391 | + defer func() { | ||
392 | + this.Resp(msg) | ||
393 | + }() | ||
394 | + var request *protocol.ChanceChangeScoreRequest | ||
395 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
396 | + log.Error(err) | ||
397 | + msg = protocol.BadRequestParam(1) | ||
398 | + return | ||
399 | + } | ||
400 | + if b, m := this.Valid(request); !b { | ||
401 | + msg = m | ||
402 | + return | ||
403 | + } | ||
404 | + header := controllers.GetRequestHeader(this.Ctx) | ||
405 | + msg = protocol.NewReturnResponse(chance.ChanceChangeScore(header, request)) | ||
406 | +} | ||
407 | + | ||
408 | +//ChanceCalculateScore 计算发现分 | ||
409 | +//@router /calculateScore [post] | ||
410 | +func (this *ChanceController) ChanceCalculateScore() { | ||
411 | + var msg *protocol.ResponseMessage | ||
412 | + defer func() { | ||
413 | + this.Resp(msg) | ||
414 | + }() | ||
415 | + var request *protocol.ChanceCalculateScoreRequest | ||
416 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
417 | + log.Error(err) | ||
418 | + msg = protocol.BadRequestParam(1) | ||
419 | + return | ||
420 | + } | ||
421 | + if b, m := this.Valid(request); !b { | ||
422 | + msg = m | ||
423 | + return | ||
424 | + } | ||
425 | + header := controllers.GetRequestHeader(this.Ctx) | ||
426 | + msg = protocol.NewReturnResponse(chance.ChanceCalculateScore(header, request)) | ||
427 | +} | ||
428 | + | ||
429 | +//MyApproveChance 我审核的机会 | ||
430 | +//@router /myApproveChance [post] | ||
431 | +func (this *ChanceController) MyApproveChance() { | ||
432 | + var msg *protocol.ResponseMessage | ||
433 | + defer func() { | ||
434 | + this.Resp(msg) | ||
435 | + }() | ||
436 | + var request *protocol.MyApproveChanceRequest | ||
437 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
438 | + log.Error(err) | ||
439 | + msg = protocol.BadRequestParam(1) | ||
440 | + return | ||
441 | + } | ||
442 | + if b, m := this.Valid(request); !b { | ||
443 | + msg = m | ||
444 | + return | ||
445 | + } | ||
446 | + header := controllers.GetRequestHeader(this.Ctx) | ||
447 | + msg = protocol.NewReturnResponse(chance.MyApproveChance(header, request)) | ||
448 | +} |
@@ -15,10 +15,10 @@ type AuditFlowProcess struct { | @@ -15,10 +15,10 @@ type AuditFlowProcess struct { | ||
15 | Level int `orm:"column(level)" description:"审批步骤"` | 15 | Level int `orm:"column(level)" description:"审批步骤"` |
16 | IsActive int8 `orm:"column(is_active)" description:"是否激活"` | 16 | IsActive int8 `orm:"column(is_active)" description:"是否激活"` |
17 | ApproveTime time.Time `orm:"column(approve_time);type(timestamp)" description:"审批时间"` | 17 | ApproveTime time.Time `orm:"column(approve_time);type(timestamp)" description:"审批时间"` |
18 | - BasicSorce float64 `orm:"column(basic_sorce);null;digits(4);decimals(1)" description:"基础评分"` | ||
19 | - ExtraSorce float64 `orm:"column(extra_sorce);null;digits(4);decimals(1)" description:"附加评分"` | ||
20 | - ValueSorce float64 `orm:"column(value_sorce);null;digits(4);decimals(1)" description:"价值评分"` | ||
21 | - DiscoverySorce float64 `orm:"column(discovery_sorce);null;digits(4);decimals(1)" description:"发现得分(发现得分=基础评分*系数 + 附加评分*系数 + 价值评分*系数)"` | 18 | + BasicScore float64 `orm:"column(basic_score);null;digits(4);decimals(1)" description:"基础评分"` |
19 | + ExtraScore float64 `orm:"column(extra_score);null;digits(4);decimals(1)" description:"附加评分"` | ||
20 | + ValueScore float64 `orm:"column(value_score);null;digits(4);decimals(1)" description:"价值评分"` | ||
21 | + DiscoveryScore float64 `orm:"column(discovery_score);null;digits(4);decimals(1)" description:"发现得分(发现得分=基础评分*系数 + 附加评分*系数 + 价值评分*系数)"` | ||
22 | ReviewStatus int8 `orm:"column(review_status)" description:"审核状态 0:审核中 1:被退回 2:已通过 3.自动通过 "` | 22 | ReviewStatus int8 `orm:"column(review_status)" description:"审核状态 0:审核中 1:被退回 2:已通过 3.自动通过 "` |
23 | AuditFlowType int `orm:"column(audit_flow_type)" description:"审核流类型 1.部门长 2.指定成员 3.指定角色 4.特殊审核人"` | 23 | AuditFlowType int `orm:"column(audit_flow_type)" description:"审核流类型 1.部门长 2.指定成员 3.指定角色 4.特殊审核人"` |
24 | FlowType int `orm:"column(flow_type)" description:"审批类型 1:正常审核 2:特殊审核"` | 24 | FlowType int `orm:"column(flow_type)" description:"审批类型 1:正常审核 2:特殊审核"` |
@@ -25,12 +25,12 @@ type Chance struct { | @@ -25,12 +25,12 @@ type Chance struct { | ||
25 | EnableStatus int8 `orm:"column(enable_status)" description:"有效状态 0:无效 1:有效 "` | 25 | EnableStatus int8 `orm:"column(enable_status)" description:"有效状态 0:无效 1:有效 "` |
26 | UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"` | 26 | UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"` |
27 | CreateAt time.Time `orm:"column(create_at);type(timestamp)" description:"创建时间"` | 27 | CreateAt time.Time `orm:"column(create_at);type(timestamp)" description:"创建时间"` |
28 | - BasicSorce float64 `orm:"column(basic_sorce);null;digits(4);decimals(1)" description:"基础评分"` | ||
29 | - ExtraSorce float64 `orm:"column(extra_sorce);null;digits(4);decimals(1)" description:"附加评分"` | ||
30 | - ValueSorce float64 `orm:"column(value_sorce);null;digits(4);decimals(1)" description:"价值评分"` | ||
31 | - DiscoverySorce float64 `orm:"column(discovery_sorce);null;digits(4);decimals(1)" description:"发现得分(发现得分=基础评分*系数 + 附加评分*系数 + 价值评分*系数)"` | 28 | + BasicScore float64 `orm:"column(basic_score);null;digits(4);decimals(1)" description:"基础评分"` |
29 | + ExtraScore float64 `orm:"column(extra_score);null;digits(4);decimals(1)" description:"附加评分"` | ||
30 | + ValueScore float64 `orm:"column(value_score);null;digits(4);decimals(1)" description:"价值评分"` | ||
31 | + DiscoveryScore float64 `orm:"column(discovery_score);null;digits(4);decimals(1)" description:"发现得分(发现得分=基础评分*系数 + 附加评分*系数 + 价值评分*系数)"` | ||
32 | PublishStatus int `orm:"column(publish_status)" description:"公开状态 0未公开、1部门公开、2公司公开"` | 32 | PublishStatus int `orm:"column(publish_status)" description:"公开状态 0未公开、1部门公开、2公司公开"` |
33 | - PublishData string `orm:"column(publish_data)" description:"公开数据 冗余"` | 33 | + ApproveData string `orm:"column(approve_data)" description:"审核数据 冗余"` |
34 | AuditLevel int `orm:"column(audit_level)" description:"当前审批步骤"` | 34 | AuditLevel int `orm:"column(audit_level)" description:"当前审批步骤"` |
35 | } | 35 | } |
36 | 36 | ||
@@ -61,6 +61,15 @@ func GetChanceById(id int64) (v *Chance, err error) { | @@ -61,6 +61,15 @@ func GetChanceById(id int64) (v *Chance, err error) { | ||
61 | return nil, err | 61 | return nil, err |
62 | } | 62 | } |
63 | 63 | ||
64 | +func GetChanceByIdAndEnable(id int64) (v *Chance, err error) { | ||
65 | + o := orm.NewOrm() | ||
66 | + v = &Chance{Id: id, EnableStatus: 1} | ||
67 | + if err = o.Read(v); err == nil { | ||
68 | + return v, nil | ||
69 | + } | ||
70 | + return nil, err | ||
71 | +} | ||
72 | + | ||
64 | // UpdateChance updates Chance by Id and returns error if | 73 | // UpdateChance updates Chance by Id and returns error if |
65 | // the record to be updated doesn't exist | 74 | // the record to be updated doesn't exist |
66 | func UpdateChanceById(m *Chance) (err error) { | 75 | func UpdateChanceById(m *Chance) (err error) { |
@@ -115,3 +124,26 @@ order by create_at desc | @@ -115,3 +124,26 @@ order by create_at desc | ||
115 | } | 124 | } |
116 | return | 125 | return |
117 | } | 126 | } |
127 | + | ||
128 | +func GetChanceMyApproveChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSize int, v interface{}) (total int, err error) { | ||
129 | + sql := `select a.*,b.images,b.speechs,b.videos from ( | ||
130 | +select a.*,b.user_id,b.source_content,b.enable_status from ( | ||
131 | +select id,approve_time,approve_data,uid,chance_id | ||
132 | +from audit_flow_process where uid=? and enable_status =1 and review_status in (?) and (?=0 or id>?) | ||
133 | +)a left outer join chance b on a.chance_id = b.id | ||
134 | +)a left outer join chance_data b on a.chance_id =b.chance_id | ||
135 | +order by a.approve_time desc | ||
136 | +LIMIT ?` | ||
137 | + | ||
138 | + sqlCount := `select count(0) | ||
139 | +from audit_flow_process where uid=? and enable_status =1 and review_status in (?) ` | ||
140 | + if err = utils.ExecuteQueryOne(&total, sqlCount, uid, utils.JoinInt8s(reviewStatus, ",")); err != nil { | ||
141 | + return | ||
142 | + } | ||
143 | + if v != nil { | ||
144 | + if err = utils.ExecuteQueryAll(v, sql, uid, utils.JoinInt8s(reviewStatus, ","), lastId, lastId, pageSize); err != nil { | ||
145 | + return | ||
146 | + } | ||
147 | + } | ||
148 | + return | ||
149 | +} |
models/chance_department.go
0 → 100644
1 | +package models | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "time" | ||
6 | + | ||
7 | + "github.com/astaxie/beego/orm" | ||
8 | +) | ||
9 | + | ||
10 | +type ChanceDepartment struct { | ||
11 | + Id int64 `orm:"column(id);pk" description:"唯一编号"` | ||
12 | + ChanceId int64 `orm:"column(chance_id)" description:"表chance.id 机会编号"` | ||
13 | + DepartmentId int64 `orm:"column(department_id)" description:"表department.id 部门编号"` | ||
14 | + EnableStatus int8 `orm:"column(enable_status)" description:"有效状态 0:无效 1:有效 "` | ||
15 | + CreateAt time.Time `orm:"column(create_at);type(timestamp);auto_now" description:"创建时间"` | ||
16 | + DeleteAt time.Time `orm:"column(delete_at);type(timestamp)" description:"删除时间"` | ||
17 | +} | ||
18 | + | ||
19 | +var ( | ||
20 | + SqlDeleteChanceDepartment = "delete from chance_department where chance_id =? and enable_status=1" | ||
21 | +) | ||
22 | + | ||
23 | +func (t *ChanceDepartment) TableName() string { | ||
24 | + return "chance_department" | ||
25 | +} | ||
26 | + | ||
27 | +func init() { | ||
28 | + orm.RegisterModel(new(ChanceDepartment)) | ||
29 | +} | ||
30 | + | ||
31 | +// AddChanceDepartment insert a new ChanceDepartment into database and returns | ||
32 | +// last inserted Id on success. | ||
33 | +func AddChanceDepartment(m *ChanceDepartment) (id int64, err error) { | ||
34 | + o := orm.NewOrm() | ||
35 | + id, err = o.Insert(m) | ||
36 | + return | ||
37 | +} | ||
38 | + | ||
39 | +// GetChanceDepartmentById retrieves ChanceDepartment by Id. Returns error if | ||
40 | +// Id doesn't exist | ||
41 | +func GetChanceDepartmentById(id int64) (v *ChanceDepartment, err error) { | ||
42 | + o := orm.NewOrm() | ||
43 | + v = &ChanceDepartment{Id: id} | ||
44 | + if err = o.Read(v); err == nil { | ||
45 | + return v, nil | ||
46 | + } | ||
47 | + return nil, err | ||
48 | +} | ||
49 | + | ||
50 | +// UpdateChanceDepartment updates ChanceDepartment by Id and returns error if | ||
51 | +// the record to be updated doesn't exist | ||
52 | +func UpdateChanceDepartmentById(m *ChanceDepartment) (err error) { | ||
53 | + o := orm.NewOrm() | ||
54 | + v := ChanceDepartment{Id: m.Id} | ||
55 | + // ascertain id exists in the database | ||
56 | + if err = o.Read(&v); err == nil { | ||
57 | + var num int64 | ||
58 | + if num, err = o.Update(m); err == nil { | ||
59 | + fmt.Println("Number of records updated in database:", num) | ||
60 | + } | ||
61 | + } | ||
62 | + return | ||
63 | +} | ||
64 | + | ||
65 | +// DeleteChanceDepartment deletes ChanceDepartment by Id and returns error if | ||
66 | +// the record to be deleted doesn't exist | ||
67 | +func DeleteChanceDepartment(id int64) (err error) { | ||
68 | + o := orm.NewOrm() | ||
69 | + v := ChanceDepartment{Id: id} | ||
70 | + // ascertain id exists in the database | ||
71 | + if err = o.Read(&v); err == nil { | ||
72 | + var num int64 | ||
73 | + if num, err = o.Delete(&ChanceDepartment{Id: id}); err == nil { | ||
74 | + fmt.Println("Number of records deleted in database:", num) | ||
75 | + } | ||
76 | + } | ||
77 | + return | ||
78 | +} |
@@ -43,9 +43,9 @@ const ( | @@ -43,9 +43,9 @@ const ( | ||
43 | 43 | ||
44 | //公开状态 | 44 | //公开状态 |
45 | const ( | 45 | const ( |
46 | - NoPublic = 0 //未公开 | ||
47 | - PublicToDepartment = 1 //部门公开 | ||
48 | - PublicToCompany = 2 //公司公开 | 46 | + NoPublic = -1 //未公开 |
47 | + PublicToDepartment = 1 //部门公开 | ||
48 | + PublicToCompany = 2 //公司公开 | ||
49 | ) | 49 | ) |
50 | 50 | ||
51 | /*Favorite */ | 51 | /*Favorite */ |
@@ -194,6 +194,31 @@ type MySubmitChanceResponse struct { | @@ -194,6 +194,31 @@ type MySubmitChanceResponse struct { | ||
194 | Total int `json:"total"` | 194 | Total int `json:"total"` |
195 | } | 195 | } |
196 | 196 | ||
197 | +/*MyApproveChance 我审核的机会*/ | ||
198 | +type MyApproveChanceRequest struct { | ||
199 | + LastId int64 `json:"lastId"` | ||
200 | + PageSize int `json:"pageSize" valid:"Required"` | ||
201 | + ReviewStatus int8 `json:"reviewStatus"` //审核状态 | ||
202 | +} | ||
203 | +type MyApproveChanceResponse struct { | ||
204 | + List []CommonListItem `json:"list"` | ||
205 | + Total int `json:"total"` | ||
206 | +} | ||
207 | + | ||
208 | +//机会列表 通用项 | ||
209 | +type CommonListItem struct { | ||
210 | + Chance ChanceItem `json:"chance,omitempty"` //机会详情 | ||
211 | + ChanceData ChanceData `json:"chanceData,omitempty"` //机会数据(是否收藏/点赞 浏览数 点赞总数 评论数) | ||
212 | + Approve Approve `json:"approve,omitempty"` //审核人 审核信息(时间) | ||
213 | + ApproveData ApproveData `json:"ApproveData"` //审核数据(公开状态 评分) | ||
214 | + Message interface{} `json:"message,omitempty"` | ||
215 | + Comment interface{} `json:"comment,omitempty"` | ||
216 | + ChanceStatus int `json:"chanceStatus,omitempty"` //1.删除 2.关闭 | ||
217 | +} | ||
218 | + | ||
219 | +type ChanceData struct { | ||
220 | +} | ||
221 | + | ||
197 | //我的机会列表 | 222 | //我的机会列表 |
198 | type ChanceItemOrm struct { | 223 | type ChanceItemOrm struct { |
199 | Id int64 `orm:"column(id)"` | 224 | Id int64 `orm:"column(id)"` |
@@ -214,13 +239,29 @@ type ChanceItem struct { | @@ -214,13 +239,29 @@ type ChanceItem struct { | ||
214 | Videos []Video `json:"videos"` | 239 | Videos []Video `json:"videos"` |
215 | } | 240 | } |
216 | 241 | ||
242 | +//我的审核机会列表 | ||
243 | +type ChanceApproveItemOrm struct { | ||
244 | + ChanceUserId int64 `orm:"column(chance_user_id)"` | ||
245 | + SourceContent string `orm:"column(source_content)"` | ||
246 | + ChanceEnableStatus string `orm:"column(enable_status)"` | ||
247 | + Images string `orm:"column(images)"` | ||
248 | + Voices string `orm:"column(speechs)"` | ||
249 | + Videos string `orm:"column(videos)"` | ||
250 | + | ||
251 | + Id int64 `orm:"column(id)"` //审核id | ||
252 | + ApproveTime time.Time `orm:"column(approve_time)"` | ||
253 | + ApproveData string `orm:"column(approve_data)"` | ||
254 | + ApproveUserId int64 `orm:"column(uid)"` | ||
255 | + ChanceId int64 `orm:"column(chance_id)"` // 机会id | ||
256 | +} | ||
257 | + | ||
217 | /*ChanceDetail 机会详情*/ | 258 | /*ChanceDetail 机会详情*/ |
218 | type ChanceDetailRequest struct { | 259 | type ChanceDetailRequest struct { |
219 | Id int64 `json:"id"` //机会编号 | 260 | Id int64 `json:"id"` //机会编号 |
220 | } | 261 | } |
221 | type ChanceDetailResponse struct { | 262 | type ChanceDetailResponse struct { |
222 | ChanceDetail ChanceItem `json:"chanceDetail"` | 263 | ChanceDetail ChanceItem `json:"chanceDetail"` |
223 | - PublicData *PublicData `json:"publicData"` | 264 | + ApproveData *ApproveData `json:"publicData"` |
224 | ApproveProcess []*ProcessItem `json:"approveProcess"` | 265 | ApproveProcess []*ProcessItem `json:"approveProcess"` |
225 | ApproveAccess *ApproveAccess `json:"approveAccess"` // | 266 | ApproveAccess *ApproveAccess `json:"approveAccess"` // |
226 | } | 267 | } |
@@ -231,3 +272,27 @@ type ChanceDeleteRequest struct { | @@ -231,3 +272,27 @@ type ChanceDeleteRequest struct { | ||
231 | } | 272 | } |
232 | type ChanceDeleteResponse struct { | 273 | type ChanceDeleteResponse struct { |
233 | } | 274 | } |
275 | + | ||
276 | +/*ChanceChangePublish 修改公开状态*/ | ||
277 | +type ChanceChangePublishRequest struct { | ||
278 | + ChanceId int64 `json:"chanceId"` //机会编号 | ||
279 | + PublicData PublicData `json:"publicData"` // 公开数据 | ||
280 | +} | ||
281 | +type ChanceChangePublishResponse struct { | ||
282 | +} | ||
283 | + | ||
284 | +/*ChanceChangeScore 修改评分*/ | ||
285 | +type ChanceChangeScoreRequest struct { | ||
286 | + ChanceId int64 `json:"chanceId"` //机会编号 | ||
287 | + Score Score `json:"score"` | ||
288 | +} | ||
289 | +type ChanceChangeScoreResponse struct { | ||
290 | +} | ||
291 | + | ||
292 | +/*ChanceCalculateScore 计算发现分*/ | ||
293 | +type ChanceCalculateScoreRequest struct { | ||
294 | + Score Score `json:"score"` | ||
295 | +} | ||
296 | +type ChanceCalculateScoreResponse struct { | ||
297 | + DiscoveryScore float64 `json:"discoveryScore"` //发现分 | ||
298 | +} |
@@ -66,6 +66,12 @@ type Role struct { | @@ -66,6 +66,12 @@ type Role struct { | ||
66 | Name string `json:"name"` | 66 | Name string `json:"name"` |
67 | } | 67 | } |
68 | 68 | ||
69 | +type Approve struct { | ||
70 | + Provider BaseUserInfo `json:"provider"` | ||
71 | + ProcessId int64 `json:"processId"` | ||
72 | + ApproveTime int64 `json:"approveTime"` | ||
73 | +} | ||
74 | + | ||
69 | //审核数据 审核通过 | 75 | //审核数据 审核通过 |
70 | type ApproveData struct { | 76 | type ApproveData struct { |
71 | PublicData PublicData `json:"publicData"` // 公开数据 | 77 | PublicData PublicData `json:"publicData"` // 公开数据 |
@@ -80,17 +86,17 @@ type PublicData struct { | @@ -80,17 +86,17 @@ type PublicData struct { | ||
80 | 86 | ||
81 | //可见对象 | 87 | //可见对象 |
82 | type VisibleObject struct { | 88 | type VisibleObject struct { |
83 | - Id string `json:"id"` | 89 | + Id int64 `json:"id"` |
84 | Name string `json:"name,omitempty"` | 90 | Name string `json:"name,omitempty"` |
85 | Type int `json:"type"` //1:部门 2:指定人员 | 91 | Type int `json:"type"` //1:部门 2:指定人员 |
86 | } | 92 | } |
87 | 93 | ||
88 | //评分 | 94 | //评分 |
89 | type Score struct { | 95 | type Score struct { |
90 | - BasicScore float32 `json:"basicScore"` //基础评分 | ||
91 | - ExtraScore float32 `json:"extraScore"` //额外分 | ||
92 | - ValueScore float32 `json:"valueScore"` //价值分 | ||
93 | - DiscoveryScore float32 `json:"discoveryScore"` //发现分 | 96 | + BasicScore float64 `json:"basicScore"` //基础评分 |
97 | + ExtraScore float64 `json:"extraScore"` //额外分 | ||
98 | + ValueScore float64 `json:"valueScore"` //价值分 | ||
99 | + DiscoveryScore float64 `json:"discoveryScore"` //发现分 | ||
94 | } | 100 | } |
95 | 101 | ||
96 | //审核操作权限 | 102 | //审核操作权限 |
@@ -40,6 +40,7 @@ var errmessge ErrorMap = map[int]string{ | @@ -40,6 +40,7 @@ var errmessge ErrorMap = map[int]string{ | ||
40 | 5202: "该机会已被审批", | 40 | 5202: "该机会已被审批", |
41 | 5203: "审批服务器操作失败", | 41 | 5203: "审批服务器操作失败", |
42 | 5204: "评分或者公开状态不能为空", | 42 | 5204: "评分或者公开状态不能为空", |
43 | + 5205: "机会未审核通过,不能修改评分或者公开状态", | ||
43 | 44 | ||
44 | //模板相关 | 45 | //模板相关 |
45 | 5301: "机会模板不存在", | 46 | 5301: "机会模板不存在", |
@@ -65,6 +65,14 @@ func init() { | @@ -65,6 +65,14 @@ func init() { | ||
65 | 65 | ||
66 | beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], | 66 | beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], |
67 | beego.ControllerComments{ | 67 | beego.ControllerComments{ |
68 | + Method: "ChanceCalculateScore", | ||
69 | + Router: `/calculateScore`, | ||
70 | + AllowHTTPMethods: []string{"post"}, | ||
71 | + MethodParams: param.Make(), | ||
72 | + Params: nil}) | ||
73 | + | ||
74 | + beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], | ||
75 | + beego.ControllerComments{ | ||
68 | Method: "ChanceDetail", | 76 | Method: "ChanceDetail", |
69 | Router: `/chanceDetail`, | 77 | Router: `/chanceDetail`, |
70 | AllowHTTPMethods: []string{"post"}, | 78 | AllowHTTPMethods: []string{"post"}, |
@@ -81,6 +89,22 @@ func init() { | @@ -81,6 +89,22 @@ func init() { | ||
81 | 89 | ||
82 | beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], | 90 | beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], |
83 | beego.ControllerComments{ | 91 | beego.ControllerComments{ |
92 | + Method: "ChanceChangePublish", | ||
93 | + Router: `/changePublish`, | ||
94 | + AllowHTTPMethods: []string{"post"}, | ||
95 | + MethodParams: param.Make(), | ||
96 | + Params: nil}) | ||
97 | + | ||
98 | + beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], | ||
99 | + beego.ControllerComments{ | ||
100 | + Method: "ChanceChangeScore", | ||
101 | + Router: `/changeScore`, | ||
102 | + AllowHTTPMethods: []string{"post"}, | ||
103 | + MethodParams: param.Make(), | ||
104 | + Params: nil}) | ||
105 | + | ||
106 | + beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], | ||
107 | + beego.ControllerComments{ | ||
84 | Method: "CommentDetailsMulti", | 108 | Method: "CommentDetailsMulti", |
85 | Router: `/commentDetailsMulti`, | 109 | Router: `/commentDetailsMulti`, |
86 | AllowHTTPMethods: []string{"post"}, | 110 | AllowHTTPMethods: []string{"post"}, |
@@ -137,6 +161,14 @@ func init() { | @@ -137,6 +161,14 @@ func init() { | ||
137 | 161 | ||
138 | beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], | 162 | beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], |
139 | beego.ControllerComments{ | 163 | beego.ControllerComments{ |
164 | + Method: "MyApproveChance", | ||
165 | + Router: `/myApproveChance`, | ||
166 | + AllowHTTPMethods: []string{"post"}, | ||
167 | + MethodParams: param.Make(), | ||
168 | + Params: nil}) | ||
169 | + | ||
170 | + beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], | ||
171 | + beego.ControllerComments{ | ||
140 | Method: "MySubmitChance", | 172 | Method: "MySubmitChance", |
141 | Router: `/mySubmitChance`, | 173 | Router: `/mySubmitChance`, |
142 | AllowHTTPMethods: []string{"post"}, | 174 | AllowHTTPMethods: []string{"post"}, |
1 | package chance | 1 | package chance |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "encoding/json" | ||
4 | "fmt" | 5 | "fmt" |
5 | "github.com/astaxie/beego" | 6 | "github.com/astaxie/beego" |
6 | "github.com/astaxie/beego/httplib" | 7 | "github.com/astaxie/beego/httplib" |
7 | "github.com/astaxie/beego/orm" | 8 | "github.com/astaxie/beego/orm" |
8 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/common" | 9 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/common" |
10 | + "gitlab.fjmaimaimai.com/mmm-go/gocomm/identity/idgen" | ||
9 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | 11 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" |
10 | "io/ioutil" | 12 | "io/ioutil" |
11 | "net/http" | 13 | "net/http" |
@@ -14,8 +16,6 @@ import ( | @@ -14,8 +16,6 @@ import ( | ||
14 | "opp/protocol" | 16 | "opp/protocol" |
15 | "opp/services/agg" | 17 | "opp/services/agg" |
16 | "time" | 18 | "time" |
17 | - | ||
18 | - "encoding/json" | ||
19 | ) | 19 | ) |
20 | 20 | ||
21 | var ( | 21 | var ( |
@@ -272,8 +272,8 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro | @@ -272,8 +272,8 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro | ||
272 | suplusApprove SuplusApprove | 272 | suplusApprove SuplusApprove |
273 | approveType int | 273 | approveType int |
274 | approveItemResponse ApproveItemResponse | 274 | approveItemResponse ApproveItemResponse |
275 | - mapProcess map[string]interface{} | ||
276 | - mapChance map[string]interface{} | 275 | + mapProcess = make(map[string]interface{}) |
276 | + mapChance = make(map[string]interface{}) | ||
277 | ) | 277 | ) |
278 | rsp = &protocol.ChanceApproveResponse{} | 278 | rsp = &protocol.ChanceApproveResponse{} |
279 | //TODO:测试注入 | 279 | //TODO:测试注入 |
@@ -301,35 +301,29 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro | @@ -301,35 +301,29 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro | ||
301 | err = protocol.NewErrWithMessage(5202) | 301 | err = protocol.NewErrWithMessage(5202) |
302 | return | 302 | return |
303 | } | 303 | } |
304 | - log.Info(fmt.Sprintf("用户:%v 提交审核 机会编号:%v 审批流编号:%v 审批状态:%v", header.UserId, chance.Id, process.Id, request.ReviewStatus)) | ||
305 | - if approveItemResponse, err = suplusApprove.ApproveItem(header, approveType, chance.Id, process.Id); err != nil { | ||
306 | - log.Error(err) | ||
307 | - err = protocol.NewErrWithMessage(5203) | ||
308 | - return | ||
309 | - } | ||
310 | { | 304 | { |
311 | mapProcess["ReviewStatus"] = int8(request.ReviewStatus) | 305 | mapProcess["ReviewStatus"] = int8(request.ReviewStatus) |
312 | mapProcess["ApproveTime"] = time.Now() | 306 | mapProcess["ApproveTime"] = time.Now() |
313 | if request.ReviewStatus == protocol.ReviewStatusPass { | 307 | if request.ReviewStatus == protocol.ReviewStatusPass { |
314 | - mapProcess["BasicSorce"] = request.ApproveData.Score.BasicScore | ||
315 | - mapProcess["ExtraSorce"] = request.ApproveData.Score.ExtraScore | ||
316 | - mapProcess["ValueSorce"] = request.ApproveData.Score.ValueScore | ||
317 | - mapProcess["DiscoverySorce"] = request.ApproveData.Score.DiscoveryScore | 308 | + mapProcess["BasicScore"] = request.ApproveData.Score.BasicScore |
309 | + mapProcess["ExtraScore"] = request.ApproveData.Score.ExtraScore | ||
310 | + mapProcess["ValueScore"] = request.ApproveData.Score.ValueScore | ||
311 | + mapProcess["DiscoveryScore"] = request.ApproveData.Score.DiscoveryScore | ||
318 | mapProcess["ApproveData"] = common.AssertJson(request.ApproveData) | 312 | mapProcess["ApproveData"] = common.AssertJson(request.ApproveData) |
313 | + mapProcess["EnableStatus"] = int8(1) | ||
319 | 314 | ||
320 | - mapChance["BasicSorce"] = request.ApproveData.Score.BasicScore | ||
321 | - mapChance["ExtraSorce"] = request.ApproveData.Score.ExtraScore | ||
322 | - mapChance["ValueSorce"] = request.ApproveData.Score.ValueScore | ||
323 | - mapChance["DiscoverySorce"] = request.ApproveData.Score.DiscoveryScore | 315 | + mapChance["BasicScore"] = request.ApproveData.Score.BasicScore |
316 | + mapChance["ExtraScore"] = request.ApproveData.Score.ExtraScore | ||
317 | + mapChance["ValueScore"] = request.ApproveData.Score.ValueScore | ||
318 | + mapChance["DiscoveryScore"] = request.ApproveData.Score.DiscoveryScore | ||
324 | mapChance["ApproveData"] = common.AssertJson(request.ApproveData) | 319 | mapChance["ApproveData"] = common.AssertJson(request.ApproveData) |
325 | mapChance["PublishStatus"] = request.ApproveData.PublicData.PublishStatus | 320 | mapChance["PublishStatus"] = request.ApproveData.PublicData.PublishStatus |
326 | } | 321 | } |
327 | } | 322 | } |
328 | - orm := orm.NewOrm() | ||
329 | - orm.Begin() | ||
330 | - if err = utils.UpdateTableByMapWithOrmer(orm, process, mapProcess); err != nil { | ||
331 | - log.Error("更新机会审核流程 状态失败 process_id:", process.Id, err) | ||
332 | - orm.Rollback() | 323 | + log.Info(fmt.Sprintf("用户:%v 提交审核 机会编号:%v 审批流编号:%v 审批状态:%v", header.UserId, chance.Id, process.Id, request.ReviewStatus)) |
324 | + if approveItemResponse, err = suplusApprove.ApproveItem(header, approveType, chance.Id, process.Id); err != nil { | ||
325 | + log.Error(err) | ||
326 | + err = protocol.NewErrWithMessage(5203) | ||
333 | return | 327 | return |
334 | } | 328 | } |
335 | log.Info(fmt.Sprintf("用户%v 更新机会审核状态 process_id:%v 状态:%v", header.UserId, process.Id, request.ReviewStatus)) | 329 | log.Info(fmt.Sprintf("用户%v 更新机会审核状态 process_id:%v 状态:%v", header.UserId, process.Id, request.ReviewStatus)) |
@@ -382,12 +376,41 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro | @@ -382,12 +376,41 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro | ||
382 | } | 376 | } |
383 | } | 377 | } |
384 | } | 378 | } |
385 | - | 379 | + orm := orm.NewOrm() |
380 | + orm.Begin() | ||
381 | + if err = utils.UpdateTableByMapWithOrmer(orm, process, mapProcess); err != nil { | ||
382 | + log.Error("更新机会审核流程 状态失败 process_id:", process.Id, err) | ||
383 | + orm.Rollback() | ||
384 | + return | ||
385 | + } | ||
386 | if err = utils.UpdateTableByMapWithOrmer(orm, chance, mapChance); err != nil { | 386 | if err = utils.UpdateTableByMapWithOrmer(orm, chance, mapChance); err != nil { |
387 | orm.Rollback() | 387 | orm.Rollback() |
388 | log.Error("更新机会审核状态失败 chance_id:", chance.Id, err) | 388 | log.Error("更新机会审核状态失败 chance_id:", chance.Id, err) |
389 | return | 389 | return |
390 | } | 390 | } |
391 | + if request.ApproveData.PublicData.PublishStatus == protocol.PublicToDepartment { | ||
392 | + if err = utils.ExecuteSQLWithOrmer(orm, models.SqlDeleteChanceDepartment, chance.Id); err != nil { | ||
393 | + log.Error(err) | ||
394 | + orm.Rollback() | ||
395 | + return | ||
396 | + } | ||
397 | + vObjs := request.ApproveData.PublicData.VisibleObjects | ||
398 | + if len(vObjs) > 0 { | ||
399 | + for i := range vObjs { | ||
400 | + if _, err = orm.Insert(&models.ChanceDepartment{ | ||
401 | + Id: idgen.Next(), | ||
402 | + ChanceId: chance.Id, | ||
403 | + DepartmentId: vObjs[i].Id, | ||
404 | + EnableStatus: 1, | ||
405 | + CreateAt: time.Now(), | ||
406 | + }); err != nil { | ||
407 | + log.Error(err) | ||
408 | + orm.Rollback() | ||
409 | + return | ||
410 | + } | ||
411 | + } | ||
412 | + } | ||
413 | + } | ||
391 | orm.Commit() | 414 | orm.Commit() |
392 | return | 415 | return |
393 | } | 416 | } |
@@ -484,10 +507,16 @@ func ChanceApproveProcess(header *protocol.RequestHeader, chance *models.Chance) | @@ -484,10 +507,16 @@ func ChanceApproveProcess(header *protocol.RequestHeader, chance *models.Chance) | ||
484 | checkApprovePermission(p) | 507 | checkApprovePermission(p) |
485 | //机会已经审核通过的直接添加到审核人列表 | 508 | //机会已经审核通过的直接添加到审核人列表 |
486 | if chance.ReviewStatus == protocol.ReviewStatusPass { | 509 | if chance.ReviewStatus == protocol.ReviewStatusPass { |
510 | + if e := json.Unmarshal([]byte(p.ApproveData), &item.ApproveData); e != nil { | ||
511 | + log.Error(e) | ||
512 | + } | ||
487 | rsp.ApproveProcess = append(rsp.ApproveProcess, item) | 513 | rsp.ApproveProcess = append(rsp.ApproveProcess, item) |
488 | continue | 514 | continue |
489 | } | 515 | } |
490 | if p.ReviewStatus == protocol.ReviewStatusPass { | 516 | if p.ReviewStatus == protocol.ReviewStatusPass { |
517 | + if e := json.Unmarshal([]byte(p.ApproveData), &item.ApproveData); e != nil { | ||
518 | + log.Error(e) | ||
519 | + } | ||
491 | rsp.ApproveProcess = append(rsp.ApproveProcess, item) | 520 | rsp.ApproveProcess = append(rsp.ApproveProcess, item) |
492 | continue | 521 | continue |
493 | } | 522 | } |
@@ -264,30 +264,29 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit | @@ -264,30 +264,29 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit | ||
264 | ReviewStatus: protocol.ReviewStatusAuditging, | 264 | ReviewStatus: protocol.ReviewStatusAuditging, |
265 | DepartmentId: request.RelatedDepartment, | 265 | DepartmentId: request.RelatedDepartment, |
266 | } | 266 | } |
267 | - logAndRollBack := func(err error) { | 267 | + if _, err = orm.Insert(chance); err != nil { |
268 | log.Error(err) | 268 | log.Error(err) |
269 | orm.Rollback() | 269 | orm.Rollback() |
270 | return | 270 | return |
271 | } | 271 | } |
272 | - if _, err = orm.Insert(chance); err != nil { | ||
273 | - logAndRollBack(err) | ||
274 | - return | ||
275 | - } | ||
276 | 272 | ||
277 | //生成提交记录 | 273 | //生成提交记录 |
278 | if _, err = orm.Insert(GenAuditFlowProcess_Submit(header, chance.Id, template.Id)); err != nil { | 274 | if _, err = orm.Insert(GenAuditFlowProcess_Submit(header, chance.Id, template.Id)); err != nil { |
279 | - logAndRollBack(err) | 275 | + log.Error(err) |
276 | + orm.Rollback() | ||
280 | return | 277 | return |
281 | } | 278 | } |
282 | //4.查询审核配置 | 279 | //4.查询审核配置 |
283 | //5.生成审核流 | 280 | //5.生成审核流 |
284 | if auditFlows, err = GenAuditFlowProcess(header, chance.Id, template.Id, auditConfig); err != nil { | 281 | if auditFlows, err = GenAuditFlowProcess(header, chance.Id, template.Id, auditConfig); err != nil { |
285 | - logAndRollBack(err) | 282 | + log.Error(err) |
283 | + orm.Rollback() | ||
286 | return | 284 | return |
287 | } | 285 | } |
288 | for i := 0; i < len(auditFlows); i++ { | 286 | for i := 0; i < len(auditFlows); i++ { |
289 | if _, err = orm.Insert(auditFlows[i]); err != nil { | 287 | if _, err = orm.Insert(auditFlows[i]); err != nil { |
290 | - logAndRollBack(err) | 288 | + log.Error(err) |
289 | + orm.Rollback() | ||
291 | return | 290 | return |
292 | } | 291 | } |
293 | } | 292 | } |
@@ -304,7 +303,8 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit | @@ -304,7 +303,8 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit | ||
304 | message := m.MessageData[i] | 303 | message := m.MessageData[i] |
305 | if err = agg.SendApproveMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName, | 304 | if err = agg.SendApproveMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName, |
306 | header.CompanyId, chance.Id, chance.ChanceTypeId, protocol.ReviewStatusAuditging); err != nil { | 305 | header.CompanyId, chance.Id, chance.ChanceTypeId, protocol.ReviewStatusAuditging); err != nil { |
307 | - logAndRollBack(err) | 306 | + log.Error(err) |
307 | + orm.Rollback() | ||
308 | return | 308 | return |
309 | } | 309 | } |
310 | } | 310 | } |
@@ -323,7 +323,8 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit | @@ -323,7 +323,8 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit | ||
323 | UpdateAt: time.Now(), | 323 | UpdateAt: time.Now(), |
324 | } | 324 | } |
325 | if _, err = orm.Insert(data); err != nil { | 325 | if _, err = orm.Insert(data); err != nil { |
326 | - logAndRollBack(err) | 326 | + log.Error(err) |
327 | + orm.Rollback() | ||
327 | return | 328 | return |
328 | } | 329 | } |
329 | } | 330 | } |
@@ -333,6 +334,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit | @@ -333,6 +334,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit | ||
333 | return | 334 | return |
334 | } | 335 | } |
335 | 336 | ||
337 | +//机会编辑 | ||
336 | func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmitRequest) (rsp *protocol.ChanceSubmitResponse, err error) { | 338 | func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmitRequest) (rsp *protocol.ChanceSubmitResponse, err error) { |
337 | var ( | 339 | var ( |
338 | template *models.AuditTemplate | 340 | template *models.AuditTemplate |
@@ -412,6 +414,112 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit | @@ -412,6 +414,112 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit | ||
412 | return | 414 | return |
413 | } | 415 | } |
414 | 416 | ||
417 | +//修改公开状态 | ||
418 | +func ChanceChangePublish(header *protocol.RequestHeader, request *protocol.ChanceChangePublishRequest) (rsp *protocol.ChanceChangePublishResponse, err error) { | ||
419 | + var ( | ||
420 | + chance *models.Chance | ||
421 | + mapChance = make(map[string]interface{}) | ||
422 | + approveData protocol.ApproveData | ||
423 | + ) | ||
424 | + if chance, err = models.GetChanceByIdAndEnable(request.ChanceId); err != nil { | ||
425 | + err = protocol.NewErrWithMessage(5101) //不存在 | ||
426 | + return | ||
427 | + } | ||
428 | + if chance.ReviewStatus != protocol.ReviewStatusPass { | ||
429 | + err = protocol.NewErrWithMessage(5205) | ||
430 | + return | ||
431 | + } | ||
432 | + //TODO:角色检查权限 | ||
433 | + if e := json.Unmarshal([]byte(chance.ApproveData), &approveData); e == nil { | ||
434 | + approveData.PublicData = request.PublicData | ||
435 | + } | ||
436 | + { | ||
437 | + mapChance["ApproveData"] = common.AssertJson(approveData) | ||
438 | + mapChance["PublishStatus"] = request.PublicData.PublishStatus | ||
439 | + } | ||
440 | + orm := orm.NewOrm() | ||
441 | + orm.Begin() | ||
442 | + if err = utils.ExecuteSQLWithOrmer(orm, models.SqlDeleteChanceDepartment, chance.Id); err != nil { | ||
443 | + log.Error(err) | ||
444 | + orm.Rollback() | ||
445 | + return | ||
446 | + } | ||
447 | + if err = utils.UpdateTableByMapWithOrmer(orm, chance, mapChance); err != nil { | ||
448 | + log.Error(err) | ||
449 | + orm.Rollback() | ||
450 | + return | ||
451 | + } | ||
452 | + vObjs := request.PublicData.VisibleObjects | ||
453 | + if request.PublicData.PublishStatus == protocol.PublicToDepartment { | ||
454 | + if len(vObjs) > 0 { | ||
455 | + for i := range vObjs { | ||
456 | + if _, err = orm.Insert(&models.ChanceDepartment{ | ||
457 | + Id: idgen.Next(), | ||
458 | + ChanceId: chance.Id, | ||
459 | + DepartmentId: vObjs[i].Id, | ||
460 | + EnableStatus: 1, | ||
461 | + CreateAt: time.Now(), | ||
462 | + }); err != nil { | ||
463 | + log.Error(err) | ||
464 | + orm.Rollback() | ||
465 | + return | ||
466 | + } | ||
467 | + } | ||
468 | + } | ||
469 | + } | ||
470 | + orm.Commit() | ||
471 | + //TODO:添加log | ||
472 | + rsp = &protocol.ChanceChangePublishResponse{} | ||
473 | + return | ||
474 | +} | ||
475 | + | ||
476 | +//修改评分 | ||
477 | +func ChanceChangeScore(header *protocol.RequestHeader, request *protocol.ChanceChangeScoreRequest) (rsp *protocol.ChanceChangeScoreResponse, err error) { | ||
478 | + var ( | ||
479 | + chance *models.Chance | ||
480 | + mapChance = make(map[string]interface{}) | ||
481 | + approveData protocol.ApproveData | ||
482 | + ) | ||
483 | + if chance, err = models.GetChanceByIdAndEnable(request.ChanceId); err != nil { | ||
484 | + err = protocol.NewErrWithMessage(5101) //不存在 | ||
485 | + return | ||
486 | + } | ||
487 | + if chance.ReviewStatus != protocol.ReviewStatusPass { | ||
488 | + err = protocol.NewErrWithMessage(5205) | ||
489 | + return | ||
490 | + } | ||
491 | + //TODO:角色检查权限 | ||
492 | + if e := json.Unmarshal([]byte(chance.ApproveData), &approveData); e == nil { | ||
493 | + approveData.Score = request.Score | ||
494 | + } | ||
495 | + { | ||
496 | + mapChance["ApproveData"] = common.AssertJson(approveData) | ||
497 | + mapChance["BasicScore"] = request.Score.BasicScore | ||
498 | + mapChance["ExtraScore"] = request.Score.ExtraScore | ||
499 | + mapChance["ValueScore"] = request.Score.ValueScore | ||
500 | + mapChance["DiscoveryScore"] = request.Score.DiscoveryScore | ||
501 | + } | ||
502 | + orm := orm.NewOrm() | ||
503 | + orm.Begin() | ||
504 | + if err = utils.UpdateTableByMapWithOrmer(orm, chance, mapChance); err != nil { | ||
505 | + log.Error(err) | ||
506 | + orm.Rollback() | ||
507 | + return | ||
508 | + } | ||
509 | + orm.Commit() | ||
510 | + rsp = &protocol.ChanceChangeScoreResponse{} | ||
511 | + return | ||
512 | +} | ||
513 | + | ||
514 | +//计算发现分 | ||
515 | +func ChanceCalculateScore(header *protocol.RequestHeader, request *protocol.ChanceCalculateScoreRequest) (rsp *protocol.ChanceCalculateScoreResponse, err error) { | ||
516 | + var () | ||
517 | + //TODO:取配置数据 | ||
518 | + rsp = &protocol.ChanceCalculateScoreResponse{} | ||
519 | + rsp.DiscoveryScore = request.Score.BasicScore*1.0 + request.Score.ExtraScore*1.0 + request.Score.ValueScore*1.0 | ||
520 | + return | ||
521 | +} | ||
522 | + | ||
415 | //生成审批流-提交记录 | 523 | //生成审批流-提交记录 |
416 | func GenAuditFlowProcess_Submit(header *protocol.RequestHeader, chanceId int64, templateId int64) (v *models.AuditFlowProcess) { | 524 | func GenAuditFlowProcess_Submit(header *protocol.RequestHeader, chanceId int64, templateId int64) (v *models.AuditFlowProcess) { |
417 | v = &models.AuditFlowProcess{ | 525 | v = &models.AuditFlowProcess{ |
@@ -683,6 +791,49 @@ func MySubmitChance(header *protocol.RequestHeader, request *protocol.MySubmitCh | @@ -683,6 +791,49 @@ func MySubmitChance(header *protocol.RequestHeader, request *protocol.MySubmitCh | ||
683 | return | 791 | return |
684 | } | 792 | } |
685 | 793 | ||
794 | +//我审核的机会 | ||
795 | +func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApproveChanceRequest) (rsp *protocol.MyApproveChanceResponse, err error) { | ||
796 | + var ( | ||
797 | + myChances []protocol.ChanceApproveItemOrm | ||
798 | + total int | ||
799 | + provider *protocol.BaseUserInfo | ||
800 | + ) | ||
801 | + rsp = &protocol.MyApproveChanceResponse{} | ||
802 | + if total, err = models.GetChanceMyChance(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &myChances); err != nil { | ||
803 | + if err == orm.ErrNoRows { | ||
804 | + err = nil | ||
805 | + return | ||
806 | + } | ||
807 | + log.Error(err) | ||
808 | + return | ||
809 | + } | ||
810 | + if provider, err = agg.GetUserBaseInfo(header.UserId, header.CompanyId); err != nil { | ||
811 | + log.Error(err) | ||
812 | + return | ||
813 | + } | ||
814 | + rsp = &protocol.MyApproveChanceResponse{Total: total} | ||
815 | + for i := 0; i < len(myChances); i++ { | ||
816 | + chance := myChances[i] | ||
817 | + commItem := protocol.CommonListItem{} | ||
818 | + item := protocol.ChanceItem{ | ||
819 | + Id: chance.Id, | ||
820 | + Provider: provider, | ||
821 | + //CreateTime: chance.CreateTime.Unix() * 1000, | ||
822 | + } | ||
823 | + jsonUnmarshal(chance.SourceContent, &item.FormList) | ||
824 | + jsonUnmarshal(chance.Images, &item.Pictures) | ||
825 | + jsonUnmarshal(chance.Voices, &item.Speechs) | ||
826 | + jsonUnmarshal(chance.Videos, &item.Videos) | ||
827 | + | ||
828 | + { | ||
829 | + commItem.Chance = item | ||
830 | + } | ||
831 | + rsp.List = append(rsp.List, commItem) | ||
832 | + } | ||
833 | + | ||
834 | + return | ||
835 | +} | ||
836 | + | ||
686 | func jsonUnmarshal(jsonData string, v interface{}) { | 837 | func jsonUnmarshal(jsonData string, v interface{}) { |
687 | if len(jsonData) == 0 { | 838 | if len(jsonData) == 0 { |
688 | return | 839 | return |
@@ -730,7 +881,7 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail | @@ -730,7 +881,7 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail | ||
730 | jsonUnmarshal(chanceData.Speechs, &item.Speechs) | 881 | jsonUnmarshal(chanceData.Speechs, &item.Speechs) |
731 | jsonUnmarshal(chanceData.Videos, &item.Videos) | 882 | jsonUnmarshal(chanceData.Videos, &item.Videos) |
732 | } | 883 | } |
733 | - jsonUnmarshal(chance.PublishData, &rsp.PublicData) | 884 | + jsonUnmarshal(chance.ApproveData, &rsp.ApproveData) |
734 | rsp.ChanceDetail = item | 885 | rsp.ChanceDetail = item |
735 | if approveProcess, err = ChanceApproveProcess(header, chance); err != nil { | 886 | if approveProcess, err = ChanceApproveProcess(header, chance); err != nil { |
736 | log.Error(err) | 887 | log.Error(err) |
@@ -761,7 +912,7 @@ func ChanceDelete(header *protocol.RequestHeader, request *protocol.ChanceDelete | @@ -761,7 +912,7 @@ func ChanceDelete(header *protocol.RequestHeader, request *protocol.ChanceDelete | ||
761 | return | 912 | return |
762 | } | 913 | } |
763 | //被人审核过 公开状态数据不为空 | 914 | //被人审核过 公开状态数据不为空 |
764 | - if chance.ReviewStatus == protocol.ReviewStatusAuditging && len(chance.PublishData) != 0 { | 915 | + if chance.ReviewStatus == protocol.ReviewStatusAuditging && len(chance.ApproveData) != 0 { |
765 | err = protocol.NewErrWithMessage(5202) | 916 | err = protocol.NewErrWithMessage(5202) |
766 | return | 917 | return |
767 | } | 918 | } |
-
请 注册 或 登录 后发表评论