...
|
...
|
@@ -8,8 +8,11 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
|
|
|
"io/ioutil"
|
|
|
"net/http"
|
|
|
"opp/internal/utils"
|
|
|
"opp/models"
|
|
|
"opp/protocol"
|
|
|
"opp/services/agg"
|
|
|
"time"
|
|
|
|
|
|
"encoding/json"
|
|
|
)
|
...
|
...
|
@@ -60,8 +63,8 @@ func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, proces |
|
|
if relativeId == 0 {
|
|
|
relativeId = item.ChanceId
|
|
|
}
|
|
|
if _, ok := mapApproves[i]; ok {
|
|
|
approve = mapApproves[i]
|
|
|
if _, ok := mapApproves[item.Level]; ok {
|
|
|
approve = mapApproves[item.Level]
|
|
|
} else {
|
|
|
approveType = item.AuditFlowType
|
|
|
if approveType == protocol.AuditBySpecailUser {
|
...
|
...
|
@@ -76,7 +79,7 @@ func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, proces |
|
|
ApproveType: item.AuditFlowType,
|
|
|
ApproveWay: approveWay,
|
|
|
}
|
|
|
mapApproves[i] = approve
|
|
|
mapApproves[item.Level] = approve
|
|
|
}
|
|
|
if approver, err = models.GetUserByUcid(item.Uid); err != nil {
|
|
|
log.Error(err)
|
...
|
...
|
@@ -88,7 +91,7 @@ func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, proces |
|
|
})
|
|
|
}
|
|
|
request.RelativeId = relativeId
|
|
|
for i := 0; i < len(mapApproves); i++ {
|
|
|
for i := 1; i <= len(mapApproves); i++ {
|
|
|
if v, ok := mapApproves[i]; ok {
|
|
|
request.Approves = append(request.Approves, v)
|
|
|
}
|
...
|
...
|
@@ -177,7 +180,7 @@ func (s SuplusApprove) DoRequest(method string, methodType string, request inter |
|
|
log.Error(e)
|
|
|
return
|
|
|
}
|
|
|
log.Debug(fmt.Sprintf("request-%v request:%v rsp:%v", url, common.AssertJson(request), common.AssertJson(response)))
|
|
|
log.Debug(fmt.Sprintf("request-%v request:%v rsp:%v", url, common.AssertJson(request), string(responseData)))
|
|
|
return
|
|
|
}
|
|
|
|
...
|
...
|
@@ -222,6 +225,7 @@ type contentItem struct { |
|
|
ApproveInstanceId int `json:"approveInstanceId"` //审批实例-id
|
|
|
ApproveProcessId int `json:"approveProcessId"` //审批进程节点-id
|
|
|
RelativeId int `json:"relativeId"` //机会编号
|
|
|
MsgApproveStatus int `json:"msgApproveStatus"` //审核状态
|
|
|
}
|
|
|
type receiverInfo struct {
|
|
|
ReceiverUid int64 `json:"receiverUid"` //用户id
|
...
|
...
|
@@ -239,9 +243,12 @@ type ApproveItemRequest struct { |
|
|
ExtendRelativeId int64 `json:"extendRelativeId"` //业务管理id
|
|
|
}
|
|
|
type ApproveItemResponse struct {
|
|
|
Status int `json:"status"` //状态1-待确认2-已确认3-已驳回4-已撤回
|
|
|
ApproveStatus int `json:"approveStatus"` //审批状态0 待审批 1 审批中 2 同意 3 驳回 4 提交订单 5 已被其他人处理 (0这个状态不存在审批后)
|
|
|
IsApprove int `json:"isApprove"` //是否需要审批 1是 0 否
|
|
|
MessageData ApproveMessageItem `json:"messageData"`
|
|
|
IsOver int `json:"isOver"` //是否结束1
|
|
|
}
|
|
|
type ApproveMessageItem struct {
|
|
|
ApproveMessage []MessageDataItem `json:"approveMessage"`
|
|
|
ApplyUserMessage []MessageDataItem `json:"applyUserMessage"`
|
|
|
}
|
|
|
|
|
|
/*ApproveIntegrate 审核列表*/
|
...
|
...
|
@@ -284,8 +291,8 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro |
|
|
err = protocol.NewErrWithMessage(5202)
|
|
|
return
|
|
|
}
|
|
|
if process.ReviewStatus != protocol.ReviewStatusAuditging {
|
|
|
log.Error(fmt.Sprintf("已被审核 %v", process.Id))
|
|
|
if chance.ReviewStatus != protocol.ReviewStatusAuditging {
|
|
|
log.Error(fmt.Sprintf("机会已经被审核 chance_id:%v review_status:%v", chance.Id, chance.ReviewStatus))
|
|
|
err = protocol.NewErrWithMessage(5202)
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -295,18 +302,74 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro |
|
|
err = protocol.NewErrWithMessage(5203)
|
|
|
return
|
|
|
}
|
|
|
if err = utils.UpdateTableByMap(process, map[string]interface{}{
|
|
|
"ReviewStatus": int8(request.ReviewStatus), "ApproveTime": time.Now()}); err != nil {
|
|
|
log.Error("更新机会审核状态失败 process_id:", process.Id, err)
|
|
|
return
|
|
|
}
|
|
|
log.Info(fmt.Sprintf("用户%v 更新机会审核状态 process_id:%v 状态:%v", header.UserId, process.Id, request.ReviewStatus))
|
|
|
{
|
|
|
if approveItemResponse.IsApprove == 0 {
|
|
|
|
|
|
//更新下一批次的审核人
|
|
|
var nextApprovers []int64
|
|
|
if approveItemResponse.IsOver == 1 {
|
|
|
//结束审批
|
|
|
if err = utils.UpdateTableByMap(chance, map[string]interface{}{
|
|
|
"ReviewStatus": int8(request.ReviewStatus), "AuditLevel": chance.AuditLevel + 1}); err != nil {
|
|
|
log.Error("更新机会审核状态失败 chance_id:", chance.Id, err)
|
|
|
return
|
|
|
}
|
|
|
//发送审核结果消息给提交人
|
|
|
for i := range approveItemResponse.MessageData.ApplyUserMessage {
|
|
|
message := approveItemResponse.MessageData.ApplyUserMessage[i]
|
|
|
nextApprovers = append(nextApprovers, message.ReceiverInfo.ReceiverUid)
|
|
|
if err = agg.SendApproveMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName,
|
|
|
header.CompanyId, chance.Id, chance.ChanceTypeId, request.ReviewStatus); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
//发送下一个消息给下一流程的审核人
|
|
|
for i := range approveItemResponse.MessageData.ApproveMessage {
|
|
|
message := approveItemResponse.MessageData.ApproveMessage[i]
|
|
|
nextApprovers = append(nextApprovers, message.ReceiverInfo.ReceiverUid)
|
|
|
if err = agg.SendApproveMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName,
|
|
|
header.CompanyId, chance.Id, chance.ChanceTypeId, protocol.ReviewStatusAuditging); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
//更新下一批次的审核人 同批次的为审核的状态置为无效
|
|
|
if len(nextApprovers) != 0 {
|
|
|
if err = models.UpdatetAuditFlowProcessToNext(chance.Id, chance.AuditLevel+1, nextApprovers); err != nil {
|
|
|
log.Error(err)
|
|
|
log.Info(fmt.Sprintf("更新机会失败 chance_id:%v 下一批次审批人员:%v", chance.Id, nextApprovers))
|
|
|
return
|
|
|
}
|
|
|
log.Info(fmt.Sprintf("更新机会 chance_id:%v 下一批次审批人员:%v", chance.Id, nextApprovers))
|
|
|
if err = models.UpdatetAuditFlowProcessNoApprove(chance.Id, chance.AuditLevel, protocol.ReviewStatusAuditging); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//更新审批节点审核信息
|
|
|
//更新机会
|
|
|
//发送下一个消息给下一流程的审核人
|
|
|
}
|
|
|
rsp = &protocol.ChanceApproveResponse{}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
/*ProcessIntegrate */
|
|
|
type ProcessIntegrateRequest struct {
|
|
|
}
|
|
|
type ProcessIntegrateResponse struct {
|
|
|
}
|
|
|
|
|
|
func ProcessIntegrate(header *protocol.RequestHeader, request *ProcessIntegrateRequest) (rsp *ProcessIntegrateResponse, err error) {
|
|
|
var ()
|
|
|
rsp = &ProcessIntegrateResponse{}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//系统审核状态转为审核类型 reviewStatus - > approveType
|
|
|
func ConverReviewStatus(reviewStatus int) (approveType int) {
|
|
|
if reviewStatus == protocol.ReviewStatusPass {
|
...
|
...
|
|