正在显示
9 个修改的文件
包含
165 行增加
和
51 行删除
1 | appname = opportunity | 1 | appname = opportunity |
2 | httpport = 8080 | 2 | httpport = 8080 |
3 | -runmode = "${RUN_MODE||local}" | 3 | +runmode = "${RUN_MODE||dev}" |
4 | 4 | ||
5 | #没设置的话 this.Ctx.Input.RequestBody 没有值 | 5 | #没设置的话 this.Ctx.Input.RequestBody 没有值 |
6 | copyrequestbody = true | 6 | copyrequestbody = true |
@@ -10,7 +10,7 @@ copyrequestbody = true | @@ -10,7 +10,7 @@ copyrequestbody = true | ||
10 | #开启应用内文档开关 | 10 | #开启应用内文档开关 |
11 | EnableDocs = true | 11 | EnableDocs = true |
12 | 12 | ||
13 | -include "local.conf" | 13 | +include "dev.conf" |
14 | include "dev-online.conf" | 14 | include "dev-online.conf" |
15 | include "test.conf" | 15 | include "test.conf" |
16 | include "prod.conf" | 16 | include "prod.conf" |
@@ -316,36 +316,22 @@ func (this *ChanceController) ChanceDelete() { | @@ -316,36 +316,22 @@ func (this *ChanceController) ChanceDelete() { | ||
316 | } | 316 | } |
317 | 317 | ||
318 | //ChanceApprove 机会审核 | 318 | //ChanceApprove 机会审核 |
319 | -//func(this *ChanceController)ChanceApprove(){ | ||
320 | -// var msg *protocol.ResponseMessage | ||
321 | -// defer func() { | ||
322 | -// this.Resp(msg) | ||
323 | -// }() | ||
324 | -// var request *protocol.ChanceApproveRequest | ||
325 | -// if err:=json.Unmarshal(this.ByteBody,&request);err!=nil{ | ||
326 | -// log.Error(err) | ||
327 | -// msg = protocol.BadRequestParam(1) | ||
328 | -// return | ||
329 | -// } | ||
330 | -// if b,m :=this.Valid(request);!b{ | ||
331 | -// msg = m | ||
332 | -// return | ||
333 | -// } | ||
334 | -// header := controllers.GetRequestHeader(this.Ctx) | ||
335 | -// msg = protocol.NewReturnResponse(chance.ChanceApprove(header,request)) | ||
336 | -//} | ||
337 | -// | ||
338 | -///*ChanceApprove */ | ||
339 | -//type ChanceApproveRequest struct { | ||
340 | -// Xxx string`json:"xxx" valid:"Required"` | ||
341 | -//} | ||
342 | -//type ChanceApproveResponse struct { | ||
343 | -//} | ||
344 | -// | ||
345 | -//func ChanceApprove(header *protocol.RequestHeader,request *protocol.ChanceApproveRequest)(rsp *protocol.ChanceApproveResponse,err error){ | ||
346 | -// var ( | ||
347 | -// | ||
348 | -// ) | ||
349 | -// rsp =&protocol.ChanceApproveResponse{} | ||
350 | -// return | ||
351 | -//} | 319 | +//@router /approve [post] |
320 | +func (this *ChanceController) ChanceApprove() { | ||
321 | + var msg *protocol.ResponseMessage | ||
322 | + defer func() { | ||
323 | + this.Resp(msg) | ||
324 | + }() | ||
325 | + var request *protocol.ChanceApproveRequest | ||
326 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
327 | + log.Error(err) | ||
328 | + msg = protocol.BadRequestParam(1) | ||
329 | + return | ||
330 | + } | ||
331 | + if b, m := this.Valid(request); !b { | ||
332 | + msg = m | ||
333 | + return | ||
334 | + } | ||
335 | + header := controllers.GetRequestHeader(this.Ctx) | ||
336 | + msg = protocol.NewReturnResponse(chance.ChanceApprove(header, request)) | ||
337 | +} |
@@ -82,3 +82,14 @@ func DeleteAuditFlowProcess(id int64) (err error) { | @@ -82,3 +82,14 @@ func DeleteAuditFlowProcess(id int64) (err error) { | ||
82 | } | 82 | } |
83 | return | 83 | return |
84 | } | 84 | } |
85 | + | ||
86 | +//审核流程编号 按用户编号 | ||
87 | +//获取审核流节点 | ||
88 | +func GetAuditFlowProcessBy(processId, uid int64) (v *AuditFlowProcess, err error) { | ||
89 | + o := orm.NewOrm() | ||
90 | + sql := "select * from audit_flow_process where id=? and uid=? and enable_status=1" | ||
91 | + if err = o.Raw(sql, processId, uid).QueryRow(&v); err == nil { | ||
92 | + return v, nil | ||
93 | + } | ||
94 | + return nil, err | ||
95 | +} |
1 | package protocol | 1 | package protocol |
2 | 2 | ||
3 | +const ( | ||
4 | + ApproveTypePass = 2 //审核通过 | ||
5 | + ApproveTypeReject = 3 //审核驳回 | ||
6 | + //ApproveReturn =4 //审核撤回 | ||
7 | +) | ||
8 | + | ||
3 | type ApproveProcess struct { | 9 | type ApproveProcess struct { |
4 | //RelativeId int64 `json:"relativeId"` | 10 | //RelativeId int64 `json:"relativeId"` |
5 | Uid int64 `json:"uid"` | 11 | Uid int64 `json:"uid"` |
@@ -9,3 +15,14 @@ type ApproveProcess struct { | @@ -9,3 +15,14 @@ type ApproveProcess struct { | ||
9 | Active int `json:"active"` | 15 | Active int `json:"active"` |
10 | ApproveTime int64 `json:"approveTime"` //审核时间 | 16 | ApproveTime int64 `json:"approveTime"` //审核时间 |
11 | } | 17 | } |
18 | + | ||
19 | +/*ChanceApprove 机会审核*/ | ||
20 | +type ChanceApproveRequest struct { | ||
21 | + Uid int64 `json:"uid"` //TODO:测试使用 注入审核人 | ||
22 | + ChanceId int64 `json:"chanceId"` //机会编号 | ||
23 | + ProcessId int64 `json:"processId"` //审批流程编号 | ||
24 | + ReviewStatus int `json:"reviewStatus"` //protocol.ReviewStatus | ||
25 | + //Suggestion string `json:"suggestion"` //原因/建议 | ||
26 | +} | ||
27 | +type ChanceApproveResponse struct { | ||
28 | +} |
@@ -57,6 +57,30 @@ func init() { | @@ -57,6 +57,30 @@ func init() { | ||
57 | 57 | ||
58 | beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], | 58 | beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], |
59 | beego.ControllerComments{ | 59 | beego.ControllerComments{ |
60 | + Method: "ChanceApprove", | ||
61 | + Router: `/approve`, | ||
62 | + AllowHTTPMethods: []string{"post"}, | ||
63 | + MethodParams: param.Make(), | ||
64 | + Params: nil}) | ||
65 | + | ||
66 | + beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], | ||
67 | + beego.ControllerComments{ | ||
68 | + Method: "ChanceDelete", | ||
69 | + Router: `/chanceDelete`, | ||
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{ | ||
76 | + Method: "ChanceDetail", | ||
77 | + Router: `/chanceDetail`, | ||
78 | + AllowHTTPMethods: []string{"post"}, | ||
79 | + MethodParams: param.Make(), | ||
80 | + Params: nil}) | ||
81 | + | ||
82 | + beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], | ||
83 | + beego.ControllerComments{ | ||
60 | Method: "ChanceType", | 84 | Method: "ChanceType", |
61 | Router: `/chanceType`, | 85 | Router: `/chanceType`, |
62 | AllowHTTPMethods: []string{"post"}, | 86 | AllowHTTPMethods: []string{"post"}, |
@@ -100,19 +100,20 @@ func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, proces | @@ -100,19 +100,20 @@ func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, proces | ||
100 | } | 100 | } |
101 | 101 | ||
102 | //审批操作 | 102 | //审批操作 |
103 | -func (s SuplusApprove) ApproveItem(header *protocol.RequestHeader, approveType int, chanceId int64) (response ApproveItemResponse, err error) { | 103 | +func (s SuplusApprove) ApproveItem(header *protocol.RequestHeader, approveType int, chanceId int64, processId int64) (response ApproveItemResponse, err error) { |
104 | var ( | 104 | var ( |
105 | request ApproveItemRequest = ApproveItemRequest{ | 105 | request ApproveItemRequest = ApproveItemRequest{ |
106 | - RelativeId: chanceId, | ||
107 | - Type: approveType, | ||
108 | - Suggestion: "", | ||
109 | - Sign: ApproveSign, | ||
110 | - ApproveType: 2, | ||
111 | - Uid: header.UserId, | 106 | + RelativeId: chanceId, |
107 | + Type: approveType, | ||
108 | + Suggestion: "", | ||
109 | + Sign: ApproveSign, | ||
110 | + ApproveType: 2, //编辑 | ||
111 | + Uid: header.UserId, | ||
112 | + ExtendRelativeId: processId, | ||
112 | } | 113 | } |
113 | ) | 114 | ) |
114 | - if s.DoRequest(ApproveItem, http.MethodPost, request, &response); err != nil { | ||
115 | - log.Error(err) | 115 | + if err = s.DoRequest(ApproveItem, http.MethodPost, request, &response); err != nil { |
116 | + return | ||
116 | } | 117 | } |
117 | log.Info(fmt.Sprintf("success request suplus-approve:%v request:%v response:%v", ApproveItem, common.AssertJson(request), common.AssertJson(response))) | 118 | log.Info(fmt.Sprintf("success request suplus-approve:%v request:%v response:%v", ApproveItem, common.AssertJson(request), common.AssertJson(response))) |
118 | return | 119 | return |
@@ -229,12 +230,13 @@ type receiverInfo struct { | @@ -229,12 +230,13 @@ type receiverInfo struct { | ||
229 | 230 | ||
230 | /*ApproveItem 审批操作*/ | 231 | /*ApproveItem 审批操作*/ |
231 | type ApproveItemRequest struct { | 232 | type ApproveItemRequest struct { |
232 | - RelativeId int64 `json:"relativeId"` //关联id | ||
233 | - Type int `json:"type"` //审批类型 2 同意 3 驳回 4 撤回 5 直接提交 | ||
234 | - Suggestion string `json:"suggestion"` //原因/建议 | ||
235 | - Sign string `json:"sign"` //CHANCE | ||
236 | - ApproveType int `json:"approveType"` //1-新增(订单用新增) 2-编辑 | ||
237 | - Uid int64 `json:"uid"` //用户id | 233 | + RelativeId int64 `json:"relativeId"` //关联id |
234 | + Type int `json:"type"` //审批类型 2 同意 3 驳回 4 撤回 5 直接提交 | ||
235 | + Suggestion string `json:"suggestion"` //原因/建议 | ||
236 | + Sign string `json:"sign"` //CHANCE | ||
237 | + ApproveType int `json:"approveType"` //1-新增(订单用新增) 2-编辑 | ||
238 | + Uid int64 `json:"uid"` //用户id | ||
239 | + ExtendRelativeId int64 `json:"extendRelativeId"` //业务管理id | ||
238 | } | 240 | } |
239 | type ApproveItemResponse struct { | 241 | type ApproveItemResponse struct { |
240 | Status int `json:"status"` //状态1-待确认2-已确认3-已驳回4-已撤回 | 242 | Status int `json:"status"` //状态1-待确认2-已确认3-已驳回4-已撤回 |
@@ -252,3 +254,74 @@ type AppproveProcess struct { | @@ -252,3 +254,74 @@ type AppproveProcess struct { | ||
252 | ExtendRelativeId int64 `json:"extendRelativeId"` | 254 | ExtendRelativeId int64 `json:"extendRelativeId"` |
253 | Status int `json:"status"` | 255 | Status int `json:"status"` |
254 | } | 256 | } |
257 | + | ||
258 | +//机会审核 | ||
259 | +func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceApproveRequest) (rsp *protocol.ChanceApproveResponse, err error) { | ||
260 | + var ( | ||
261 | + process *models.AuditFlowProcess | ||
262 | + chance *models.Chance | ||
263 | + suplusApprove SuplusApprove | ||
264 | + approveType int | ||
265 | + approveItemResponse ApproveItemResponse | ||
266 | + ) | ||
267 | + //TODO:测试注入 | ||
268 | + if request.Uid != 0 { | ||
269 | + header.UserId = request.Uid | ||
270 | + } | ||
271 | + approveType = ConverReviewStatus(request.ReviewStatus) | ||
272 | + if approveType == 0 { | ||
273 | + log.Error("request.reviewStatus error :", request.ReviewStatus) | ||
274 | + err = protocol.NewErrWithMessage(2) | ||
275 | + return | ||
276 | + } | ||
277 | + if chance, err = models.GetChanceById(request.ChanceId); err != nil { | ||
278 | + log.Error(err) | ||
279 | + err = protocol.NewErrWithMessage(5101) | ||
280 | + return | ||
281 | + } | ||
282 | + if process, err = models.GetAuditFlowProcessBy(request.ProcessId, header.UserId); err != nil { | ||
283 | + log.Error(request.ProcessId, header.UserId, err) | ||
284 | + err = protocol.NewErrWithMessage(5202) | ||
285 | + return | ||
286 | + } | ||
287 | + if process.ReviewStatus != protocol.ReviewStatusAuditging { | ||
288 | + log.Error(fmt.Sprintf("已被审核 %v", process.Id)) | ||
289 | + err = protocol.NewErrWithMessage(5202) | ||
290 | + return | ||
291 | + } | ||
292 | + log.Info(fmt.Sprintf("用户:%v 提交审核 机会编号:%v 审批流编号:%v 审批状态:%v", header.UserId, chance.Id, process.Id, request.ReviewStatus)) | ||
293 | + if approveItemResponse, err = suplusApprove.ApproveItem(header, approveType, chance.Id, process.Id); err != nil { | ||
294 | + log.Error(err) | ||
295 | + err = protocol.NewErrWithMessage(5203) | ||
296 | + return | ||
297 | + } | ||
298 | + { | ||
299 | + if approveItemResponse.IsApprove == 0 { | ||
300 | + | ||
301 | + } | ||
302 | + //更新审批节点审核信息 | ||
303 | + //更新机会 | ||
304 | + //发送下一个消息给下一流程的审核人 | ||
305 | + } | ||
306 | + rsp = &protocol.ChanceApproveResponse{} | ||
307 | + return | ||
308 | +} | ||
309 | + | ||
310 | +//系统审核状态转为审核类型 reviewStatus - > approveType | ||
311 | +func ConverReviewStatus(reviewStatus int) (approveType int) { | ||
312 | + if reviewStatus == protocol.ReviewStatusPass { | ||
313 | + approveType = protocol.ApproveTypePass | ||
314 | + } else if reviewStatus == protocol.ReviewStatusReturn { | ||
315 | + approveType = protocol.ApproveTypeReject | ||
316 | + } | ||
317 | + return | ||
318 | +} | ||
319 | + | ||
320 | +func ConverTypeToReviewStaus(approveType int) (reviewStatus int) { | ||
321 | + if approveType == protocol.ApproveTypePass { | ||
322 | + reviewStatus = protocol.ReviewStatusPass | ||
323 | + } else if approveType == protocol.ApproveTypeReject { | ||
324 | + reviewStatus = protocol.ReviewStatusReturn | ||
325 | + } | ||
326 | + return | ||
327 | +} |
@@ -502,6 +502,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat | @@ -502,6 +502,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat | ||
502 | FlowType: config.FlowType, | 502 | FlowType: config.FlowType, |
503 | ActionType: int(config.ActionType), | 503 | ActionType: int(config.ActionType), |
504 | EnableStatus: 1, | 504 | EnableStatus: 1, |
505 | + ReviewStatus: protocol.ReviewStatusAuditging, | ||
505 | } | 506 | } |
506 | //if uid==0 && auditConfig.NoApprover==1{//审批人为空 自动通过 | 507 | //if uid==0 && auditConfig.NoApprover==1{//审批人为空 自动通过 |
507 | // item. | 508 | // item. |
-
请 注册 或 登录 后发表评论