...
|
...
|
@@ -100,19 +100,20 @@ func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, proces |
|
|
}
|
|
|
|
|
|
//审批操作
|
|
|
func (s SuplusApprove) ApproveItem(header *protocol.RequestHeader, approveType int, chanceId int64) (response ApproveItemResponse, err error) {
|
|
|
func (s SuplusApprove) ApproveItem(header *protocol.RequestHeader, approveType int, chanceId int64, processId int64) (response ApproveItemResponse, err error) {
|
|
|
var (
|
|
|
request ApproveItemRequest = ApproveItemRequest{
|
|
|
RelativeId: chanceId,
|
|
|
Type: approveType,
|
|
|
Suggestion: "",
|
|
|
Sign: ApproveSign,
|
|
|
ApproveType: 2,
|
|
|
Uid: header.UserId,
|
|
|
RelativeId: chanceId,
|
|
|
Type: approveType,
|
|
|
Suggestion: "",
|
|
|
Sign: ApproveSign,
|
|
|
ApproveType: 2, //编辑
|
|
|
Uid: header.UserId,
|
|
|
ExtendRelativeId: processId,
|
|
|
}
|
|
|
)
|
|
|
if s.DoRequest(ApproveItem, http.MethodPost, request, &response); err != nil {
|
|
|
log.Error(err)
|
|
|
if err = s.DoRequest(ApproveItem, http.MethodPost, request, &response); err != nil {
|
|
|
return
|
|
|
}
|
|
|
log.Info(fmt.Sprintf("success request suplus-approve:%v request:%v response:%v", ApproveItem, common.AssertJson(request), common.AssertJson(response)))
|
|
|
return
|
...
|
...
|
@@ -229,12 +230,13 @@ type receiverInfo struct { |
|
|
|
|
|
/*ApproveItem 审批操作*/
|
|
|
type ApproveItemRequest struct {
|
|
|
RelativeId int64 `json:"relativeId"` //关联id
|
|
|
Type int `json:"type"` //审批类型 2 同意 3 驳回 4 撤回 5 直接提交
|
|
|
Suggestion string `json:"suggestion"` //原因/建议
|
|
|
Sign string `json:"sign"` //CHANCE
|
|
|
ApproveType int `json:"approveType"` //1-新增(订单用新增) 2-编辑
|
|
|
Uid int64 `json:"uid"` //用户id
|
|
|
RelativeId int64 `json:"relativeId"` //关联id
|
|
|
Type int `json:"type"` //审批类型 2 同意 3 驳回 4 撤回 5 直接提交
|
|
|
Suggestion string `json:"suggestion"` //原因/建议
|
|
|
Sign string `json:"sign"` //CHANCE
|
|
|
ApproveType int `json:"approveType"` //1-新增(订单用新增) 2-编辑
|
|
|
Uid int64 `json:"uid"` //用户id
|
|
|
ExtendRelativeId int64 `json:"extendRelativeId"` //业务管理id
|
|
|
}
|
|
|
type ApproveItemResponse struct {
|
|
|
Status int `json:"status"` //状态1-待确认2-已确认3-已驳回4-已撤回
|
...
|
...
|
@@ -252,3 +254,74 @@ type AppproveProcess struct { |
|
|
ExtendRelativeId int64 `json:"extendRelativeId"`
|
|
|
Status int `json:"status"`
|
|
|
}
|
|
|
|
|
|
//机会审核
|
|
|
func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceApproveRequest) (rsp *protocol.ChanceApproveResponse, err error) {
|
|
|
var (
|
|
|
process *models.AuditFlowProcess
|
|
|
chance *models.Chance
|
|
|
suplusApprove SuplusApprove
|
|
|
approveType int
|
|
|
approveItemResponse ApproveItemResponse
|
|
|
)
|
|
|
//TODO:测试注入
|
|
|
if request.Uid != 0 {
|
|
|
header.UserId = request.Uid
|
|
|
}
|
|
|
approveType = ConverReviewStatus(request.ReviewStatus)
|
|
|
if approveType == 0 {
|
|
|
log.Error("request.reviewStatus error :", request.ReviewStatus)
|
|
|
err = protocol.NewErrWithMessage(2)
|
|
|
return
|
|
|
}
|
|
|
if chance, err = models.GetChanceById(request.ChanceId); err != nil {
|
|
|
log.Error(err)
|
|
|
err = protocol.NewErrWithMessage(5101)
|
|
|
return
|
|
|
}
|
|
|
if process, err = models.GetAuditFlowProcessBy(request.ProcessId, header.UserId); err != nil {
|
|
|
log.Error(request.ProcessId, header.UserId, err)
|
|
|
err = protocol.NewErrWithMessage(5202)
|
|
|
return
|
|
|
}
|
|
|
if process.ReviewStatus != protocol.ReviewStatusAuditging {
|
|
|
log.Error(fmt.Sprintf("已被审核 %v", process.Id))
|
|
|
err = protocol.NewErrWithMessage(5202)
|
|
|
return
|
|
|
}
|
|
|
log.Info(fmt.Sprintf("用户:%v 提交审核 机会编号:%v 审批流编号:%v 审批状态:%v", header.UserId, chance.Id, process.Id, request.ReviewStatus))
|
|
|
if approveItemResponse, err = suplusApprove.ApproveItem(header, approveType, chance.Id, process.Id); err != nil {
|
|
|
log.Error(err)
|
|
|
err = protocol.NewErrWithMessage(5203)
|
|
|
return
|
|
|
}
|
|
|
{
|
|
|
if approveItemResponse.IsApprove == 0 {
|
|
|
|
|
|
}
|
|
|
//更新审批节点审核信息
|
|
|
//更新机会
|
|
|
//发送下一个消息给下一流程的审核人
|
|
|
}
|
|
|
rsp = &protocol.ChanceApproveResponse{}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//系统审核状态转为审核类型 reviewStatus - > approveType
|
|
|
func ConverReviewStatus(reviewStatus int) (approveType int) {
|
|
|
if reviewStatus == protocol.ReviewStatusPass {
|
|
|
approveType = protocol.ApproveTypePass
|
|
|
} else if reviewStatus == protocol.ReviewStatusReturn {
|
|
|
approveType = protocol.ApproveTypeReject
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func ConverTypeToReviewStaus(approveType int) (reviewStatus int) {
|
|
|
if approveType == protocol.ApproveTypePass {
|
|
|
reviewStatus = protocol.ReviewStatusPass
|
|
|
} else if approveType == protocol.ApproveTypeReject {
|
|
|
reviewStatus = protocol.ReviewStatusReturn
|
|
|
}
|
|
|
return
|
|
|
} |
...
|
...
|
|