作者 yangfu

机会提交审核

@@ -4,6 +4,7 @@ import ( @@ -4,6 +4,7 @@ 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/protocol" 6 "opp/protocol"
  7 + "opp/services/chance"
7 "opp/services/message" 8 "opp/services/message"
8 ) 9 )
9 10
@@ -52,3 +53,24 @@ func (this *H5Controller) AnnouncementSubmit() { @@ -52,3 +53,24 @@ func (this *H5Controller) AnnouncementSubmit() {
52 header := GetRequestHeader(this.Ctx) 53 header := GetRequestHeader(this.Ctx)
53 msg = protocol.NewReturnResponse(message.H5AnnouncementSubmit(header, request)) 54 msg = protocol.NewReturnResponse(message.H5AnnouncementSubmit(header, request))
54 } 55 }
  56 +
  57 +//ChanceExample 示例
  58 +//@router /chanceExample [post]
  59 +func (this *H5Controller) ChanceExample() {
  60 + var msg *protocol.ResponseMessage
  61 + defer func() {
  62 + this.Resp(msg)
  63 + }()
  64 + var request *protocol.ChanceExampleRequest
  65 + if err := json.Unmarshal(this.ByteBody, &request); err != nil {
  66 + log.Error(err)
  67 + msg = protocol.BadRequestParam(1)
  68 + return
  69 + }
  70 + if b, m := this.Valid(request); !b {
  71 + msg = m
  72 + return
  73 + }
  74 + header := GetRequestHeader(this.Ctx)
  75 + msg = protocol.NewReturnResponse(chance.ChanceExample(header, request))
  76 +}
@@ -180,6 +180,6 @@ func ExecuteSQLWithOrmer(o orm.Ormer, sqlstr string, param ...interface{}) error @@ -180,6 +180,6 @@ func ExecuteSQLWithOrmer(o orm.Ormer, sqlstr string, param ...interface{}) error
180 return err 180 return err
181 } 181 }
182 num, _ := r.RowsAffected() 182 num, _ := r.RowsAffected()
183 - log.Debug("RowsAffected:%d", num) 183 + log.Debug(fmt.Sprintf("RowsAffected:%d", num))
184 return nil 184 return nil
185 } 185 }
@@ -58,3 +58,10 @@ func JoinInt8s(ids []int8, spilt string) string { @@ -58,3 +58,10 @@ func JoinInt8s(ids []int8, spilt string) string {
58 } 58 }
59 return strings.Join(idStrings, spilt) 59 return strings.Join(idStrings, spilt)
60 } 60 }
  61 +func JoinInt64s(ids []int64, spilt string) string {
  62 + var idStrings []string = make([]string, len(ids))
  63 + for i := 0; i < len(ids); i++ {
  64 + idStrings[i] = fmt.Sprintf("%v", ids[i])
  65 + }
  66 + return strings.Join(idStrings, spilt)
  67 +}
@@ -35,7 +35,7 @@ func init() { @@ -35,7 +35,7 @@ func init() {
35 log.Fatal("connect to redis error address:", beego.AppConfig.String("redis_add_port"), beego.AppConfig.String("redis_auth"), err) 35 log.Fatal("connect to redis error address:", beego.AppConfig.String("redis_add_port"), beego.AppConfig.String("redis_auth"), err)
36 //panic(err) 36 //panic(err)
37 } 37 }
38 - dataSource := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?loc=Asia%%2FShanghai", 38 + dataSource := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?loc=Asia%%2FShanghai&charset=utf8mb4",
39 beego.AppConfig.String("mysql_user"), 39 beego.AppConfig.String("mysql_user"),
40 beego.AppConfig.String("mysql_password"), 40 beego.AppConfig.String("mysql_password"),
41 beego.AppConfig.String("mysql_host"), 41 beego.AppConfig.String("mysql_host"),
@@ -2,6 +2,7 @@ package models @@ -2,6 +2,7 @@ package models
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "opp/internal/utils"
5 "time" 6 "time"
6 7
7 "github.com/astaxie/beego/orm" 8 "github.com/astaxie/beego/orm"
@@ -93,3 +94,23 @@ func GetAuditFlowProcessBy(processId, uid int64) (v *AuditFlowProcess, err error @@ -93,3 +94,23 @@ func GetAuditFlowProcessBy(processId, uid int64) (v *AuditFlowProcess, err error
93 } 94 }
94 return nil, err 95 return nil, err
95 } 96 }
  97 +
  98 +//当前审批批次已经结束 唤醒下一批次审批人
  99 +func UpdatetAuditFlowProcessToNext(chanceId int64, level int, uids []int64) (err error) {
  100 + o := orm.NewOrm()
  101 + sql := "update audit_flow_process set enable_status =1,is_active=1,update_at=now() where chance_id=? and level=? and uid in (?)"
  102 + if err = utils.ExecuteSQLWithOrmer(o, sql, chanceId, level, utils.JoinInt64s(uids, ",")); err != nil {
  103 + return
  104 + }
  105 + return
  106 +}
  107 +
  108 +//或签 有一人已经通过 同批次在审核状态置为无效
  109 +func UpdatetAuditFlowProcessNoApprove(chanceId int64, level int, reviewStatus int) (err error) {
  110 + o := orm.NewOrm()
  111 + sql := "update audit_flow_process set enable_status =0,is_active=0,update_at=now() where chance_id=? and level=? and review_status=?"
  112 + if err = utils.ExecuteSQLWithOrmer(o, sql, chanceId, level, reviewStatus); err != nil {
  113 + return
  114 + }
  115 + return
  116 +}
@@ -90,3 +90,13 @@ func GetAuditTemplates(companyId int64, chanceTypeId int) (v []*AuditTemplate, e @@ -90,3 +90,13 @@ func GetAuditTemplates(companyId int64, chanceTypeId int) (v []*AuditTemplate, e
90 } 90 }
91 return 91 return
92 } 92 }
  93 +
  94 +//获取模板示例
  95 +func GetAuditTemplateExample(id int64) (v string, err error) {
  96 + o := orm.NewOrm()
  97 + sql := "select example from audit_template where id=?"
  98 + if err = o.Raw(sql, id).QueryRow(&v); err == nil {
  99 + return
  100 + }
  101 + return
  102 +}
@@ -92,14 +92,14 @@ type SympathyActionRequest struct { @@ -92,14 +92,14 @@ type SympathyActionRequest struct {
92 type SympathyActionResponse struct { 92 type SympathyActionResponse struct {
93 } 93 }
94 94
95 -/*ChanceType */ 95 +/*ChanceType 机会一级分类请求*/
96 type ChanceTypeRequest struct { 96 type ChanceTypeRequest struct {
97 } 97 }
98 type ChanceTypeResponse struct { 98 type ChanceTypeResponse struct {
99 List []*models.ChanceType `json:"list"` 99 List []*models.ChanceType `json:"list"`
100 } 100 }
101 101
102 -/*Templates */ 102 +/*Templates 模板列表请求*/
103 type TemplatesRequest struct { 103 type TemplatesRequest struct {
104 ChanceTypeId int `json:"chanceTypeId" valid:"Required"` 104 ChanceTypeId int `json:"chanceTypeId" valid:"Required"`
105 } 105 }
@@ -107,14 +107,17 @@ type TemplatesResponse struct { @@ -107,14 +107,17 @@ type TemplatesResponse struct {
107 Templates []*Template `json:"list"` 107 Templates []*Template `json:"list"`
108 } 108 }
109 109
  110 +//模板
110 type Template struct { 111 type Template struct {
111 Id int64 `json:"id"` 112 Id int64 `json:"id"`
112 Name string `json:"name"` 113 Name string `json:"name"`
113 Doc string `json:"doc"` 114 Doc string `json:"doc"`
114 Icon string `json:"icon"` 115 Icon string `json:"icon"`
115 FormList []*Form `json:"formList"` 116 FormList []*Form `json:"formList"`
  117 + Link string `json:"link"` //示例
116 } 118 }
117 119
  120 +//表单
118 type Form struct { 121 type Form struct {
119 Id int `json:"id"` 122 Id int `json:"id"`
120 Label string `json:"label"` 123 Label string `json:"label"`
@@ -124,6 +127,14 @@ type Form struct { @@ -124,6 +127,14 @@ type Form struct {
124 Required int8 `json:"required"` 127 Required int8 `json:"required"`
125 } 128 }
126 129
  130 +/*ChanceExample*/
  131 +type ChanceExampleRequest struct {
  132 + TemplateId int `json:"templateId" valid:"Required"`
  133 +}
  134 +type ChanceExampleResponse struct {
  135 + Content string `json:"content"`
  136 +}
  137 +
127 type ChanceSubmitRequest struct { 138 type ChanceSubmitRequest struct {
128 Id int64 `json:"id"` // = 0添加 >0 编辑 139 Id int64 `json:"id"` // = 0添加 >0 编辑
129 AuditTemplateId int64 `json:"auditTemplateId" valid:"Required"` 140 AuditTemplateId int64 `json:"auditTemplateId" valid:"Required"`
@@ -39,6 +39,9 @@ var errmessge ErrorMap = map[int]string{ @@ -39,6 +39,9 @@ var errmessge ErrorMap = map[int]string{
39 5201: "该机会模板未配置审批人,请选择其他模板", 39 5201: "该机会模板未配置审批人,请选择其他模板",
40 5202: "该机会已被其他人审批", 40 5202: "该机会已被其他人审批",
41 5203: "审批服务器操作失败", 41 5203: "审批服务器操作失败",
  42 +
  43 + //模板相关
  44 + 5301: "机会模板不存在",
42 } 45 }
43 46
44 const ( 47 const (
@@ -23,4 +23,12 @@ func init() { @@ -23,4 +23,12 @@ func init() {
23 MethodParams: param.Make(), 23 MethodParams: param.Make(),
24 Params: nil}) 24 Params: nil})
25 25
  26 + beego.GlobalControllerRouter["opp/controllers:H5Controller"] = append(beego.GlobalControllerRouter["opp/controllers:H5Controller"],
  27 + beego.ControllerComments{
  28 + Method: "ChanceExample",
  29 + Router: `/chanceExample`,
  30 + AllowHTTPMethods: []string{"post"},
  31 + MethodParams: param.Make(),
  32 + Params: nil})
  33 +
26 } 34 }
@@ -10,11 +10,55 @@ import ( @@ -10,11 +10,55 @@ import (
10 ) 10 )
11 11
12 var ( 12 var (
13 - MessageApprove = "提交了一条%v机会消息,需要您审核" 13 + MessageApproving = "提交了一条%v机会消息,需要您审核"
  14 + MessageApproveSuccess = "审核通过你提交的%v机会"
  15 + MessageApproveReject = "退回您了提交的%v机会"
14 ) 16 )
15 17
16 //发送审批消息 18 //发送审批消息
17 -func SendApproveMsg(receiverId int64, name string, companyId int64, chanceId int64, chanceTypeId int) (err error) { 19 +func SendApproveMsg(receiverId int64, name string, companyId int64, chanceId int64, chanceTypeId int, reviewStatus int) (err error) {
  20 + var (
  21 + userMsg *models.UserMsg
  22 + chanceType *models.ChanceType
  23 + format string
  24 + )
  25 + switch reviewStatus {
  26 + case protocol.ReviewStatusAuditging:
  27 + format = MessageApproving
  28 + break
  29 + case protocol.ReviewStatusReturn:
  30 + format = MessageApproveReject
  31 + break
  32 + case protocol.ReviewStatusPass:
  33 + format = MessageApproveSuccess
  34 + break
  35 + default:
  36 + format = MessageApproving
  37 + break
  38 + }
  39 + if chanceType, err = models.GetChanceTypeById(chanceTypeId); err != nil {
  40 + return
  41 + }
  42 + userMsg = &models.UserMsg{
  43 + Id: idgen.Next(),
  44 + CompanyId: companyId,
  45 + ReceiveUserId: receiverId,
  46 + MsgType: protocol.MsgTypeAudit,
  47 + Message: fmt.Sprintf(format, chanceType.Name),
  48 + SourceId: chanceId,
  49 + SourceType: protocol.SourceTypeChance,
  50 + IsPublic: 0,
  51 + CreateAt: time.Now(),
  52 + }
  53 + if _, err = models.AddUserMsg(userMsg); err != nil {
  54 + return
  55 + }
  56 + logMsg(userMsg, name)
  57 + return
  58 +}
  59 +
  60 +//发送审批消息
  61 +func SendApproveMsgByFormat(receiverId int64, name string, companyId int64, chanceId int64, chanceTypeId int, format string) (err error) {
18 var ( 62 var (
19 userMsg *models.UserMsg 63 userMsg *models.UserMsg
20 chanceType *models.ChanceType 64 chanceType *models.ChanceType
@@ -27,7 +71,7 @@ func SendApproveMsg(receiverId int64, name string, companyId int64, chanceId int @@ -27,7 +71,7 @@ func SendApproveMsg(receiverId int64, name string, companyId int64, chanceId int
27 CompanyId: companyId, 71 CompanyId: companyId,
28 ReceiveUserId: receiverId, 72 ReceiveUserId: receiverId,
29 MsgType: protocol.MsgTypeAudit, 73 MsgType: protocol.MsgTypeAudit,
30 - Message: fmt.Sprintf(MessageApprove, chanceType.Name), 74 + Message: fmt.Sprintf(format, chanceType.Name),
31 SourceId: chanceId, 75 SourceId: chanceId,
32 SourceType: protocol.SourceTypeChance, 76 SourceType: protocol.SourceTypeChance,
33 IsPublic: 0, 77 IsPublic: 0,
@@ -8,8 +8,11 @@ import ( @@ -8,8 +8,11 @@ import (
8 "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" 8 "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
9 "io/ioutil" 9 "io/ioutil"
10 "net/http" 10 "net/http"
  11 + "opp/internal/utils"
11 "opp/models" 12 "opp/models"
12 "opp/protocol" 13 "opp/protocol"
  14 + "opp/services/agg"
  15 + "time"
13 16
14 "encoding/json" 17 "encoding/json"
15 ) 18 )
@@ -60,8 +63,8 @@ func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, proces @@ -60,8 +63,8 @@ func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, proces
60 if relativeId == 0 { 63 if relativeId == 0 {
61 relativeId = item.ChanceId 64 relativeId = item.ChanceId
62 } 65 }
63 - if _, ok := mapApproves[i]; ok {  
64 - approve = mapApproves[i] 66 + if _, ok := mapApproves[item.Level]; ok {
  67 + approve = mapApproves[item.Level]
65 } else { 68 } else {
66 approveType = item.AuditFlowType 69 approveType = item.AuditFlowType
67 if approveType == protocol.AuditBySpecailUser { 70 if approveType == protocol.AuditBySpecailUser {
@@ -76,7 +79,7 @@ func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, proces @@ -76,7 +79,7 @@ func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, proces
76 ApproveType: item.AuditFlowType, 79 ApproveType: item.AuditFlowType,
77 ApproveWay: approveWay, 80 ApproveWay: approveWay,
78 } 81 }
79 - mapApproves[i] = approve 82 + mapApproves[item.Level] = approve
80 } 83 }
81 if approver, err = models.GetUserByUcid(item.Uid); err != nil { 84 if approver, err = models.GetUserByUcid(item.Uid); err != nil {
82 log.Error(err) 85 log.Error(err)
@@ -88,7 +91,7 @@ func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, proces @@ -88,7 +91,7 @@ func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, proces
88 }) 91 })
89 } 92 }
90 request.RelativeId = relativeId 93 request.RelativeId = relativeId
91 - for i := 0; i < len(mapApproves); i++ { 94 + for i := 1; i <= len(mapApproves); i++ {
92 if v, ok := mapApproves[i]; ok { 95 if v, ok := mapApproves[i]; ok {
93 request.Approves = append(request.Approves, v) 96 request.Approves = append(request.Approves, v)
94 } 97 }
@@ -177,7 +180,7 @@ func (s SuplusApprove) DoRequest(method string, methodType string, request inter @@ -177,7 +180,7 @@ func (s SuplusApprove) DoRequest(method string, methodType string, request inter
177 log.Error(e) 180 log.Error(e)
178 return 181 return
179 } 182 }
180 - log.Debug(fmt.Sprintf("request-%v request:%v rsp:%v", url, common.AssertJson(request), common.AssertJson(response))) 183 + log.Debug(fmt.Sprintf("request-%v request:%v rsp:%v", url, common.AssertJson(request), string(responseData)))
181 return 184 return
182 } 185 }
183 186
@@ -222,6 +225,7 @@ type contentItem struct { @@ -222,6 +225,7 @@ type contentItem struct {
222 ApproveInstanceId int `json:"approveInstanceId"` //审批实例-id 225 ApproveInstanceId int `json:"approveInstanceId"` //审批实例-id
223 ApproveProcessId int `json:"approveProcessId"` //审批进程节点-id 226 ApproveProcessId int `json:"approveProcessId"` //审批进程节点-id
224 RelativeId int `json:"relativeId"` //机会编号 227 RelativeId int `json:"relativeId"` //机会编号
  228 + MsgApproveStatus int `json:"msgApproveStatus"` //审核状态
225 } 229 }
226 type receiverInfo struct { 230 type receiverInfo struct {
227 ReceiverUid int64 `json:"receiverUid"` //用户id 231 ReceiverUid int64 `json:"receiverUid"` //用户id
@@ -239,9 +243,12 @@ type ApproveItemRequest struct { @@ -239,9 +243,12 @@ type ApproveItemRequest struct {
239 ExtendRelativeId int64 `json:"extendRelativeId"` //业务管理id 243 ExtendRelativeId int64 `json:"extendRelativeId"` //业务管理id
240 } 244 }
241 type ApproveItemResponse struct { 245 type ApproveItemResponse struct {
242 - Status int `json:"status"` //状态1-待确认2-已确认3-已驳回4-已撤回  
243 - ApproveStatus int `json:"approveStatus"` //审批状态0 待审批 1 审批中 2 同意 3 驳回 4 提交订单 5 已被其他人处理 (0这个状态不存在审批后)  
244 - IsApprove int `json:"isApprove"` //是否需要审批 1是 0 否 246 + MessageData ApproveMessageItem `json:"messageData"`
  247 + IsOver int `json:"isOver"` //是否结束1
  248 +}
  249 +type ApproveMessageItem struct {
  250 + ApproveMessage []MessageDataItem `json:"approveMessage"`
  251 + ApplyUserMessage []MessageDataItem `json:"applyUserMessage"`
245 } 252 }
246 253
247 /*ApproveIntegrate 审核列表*/ 254 /*ApproveIntegrate 审核列表*/
@@ -284,8 +291,8 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro @@ -284,8 +291,8 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro
284 err = protocol.NewErrWithMessage(5202) 291 err = protocol.NewErrWithMessage(5202)
285 return 292 return
286 } 293 }
287 - if process.ReviewStatus != protocol.ReviewStatusAuditging {  
288 - log.Error(fmt.Sprintf("已被审核 %v", process.Id)) 294 + if chance.ReviewStatus != protocol.ReviewStatusAuditging {
  295 + log.Error(fmt.Sprintf("机会已经被审核 chance_id:%v review_status:%v", chance.Id, chance.ReviewStatus))
289 err = protocol.NewErrWithMessage(5202) 296 err = protocol.NewErrWithMessage(5202)
290 return 297 return
291 } 298 }
@@ -295,18 +302,74 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro @@ -295,18 +302,74 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro
295 err = protocol.NewErrWithMessage(5203) 302 err = protocol.NewErrWithMessage(5203)
296 return 303 return
297 } 304 }
  305 + if err = utils.UpdateTableByMap(process, map[string]interface{}{
  306 + "ReviewStatus": int8(request.ReviewStatus), "ApproveTime": time.Now()}); err != nil {
  307 + log.Error("更新机会审核状态失败 process_id:", process.Id, err)
  308 + return
  309 + }
  310 + log.Info(fmt.Sprintf("用户%v 更新机会审核状态 process_id:%v 状态:%v", header.UserId, process.Id, request.ReviewStatus))
298 { 311 {
299 - if approveItemResponse.IsApprove == 0 {  
300 - 312 + //更新下一批次的审核人
  313 + var nextApprovers []int64
  314 + if approveItemResponse.IsOver == 1 {
  315 + //结束审批
  316 + if err = utils.UpdateTableByMap(chance, map[string]interface{}{
  317 + "ReviewStatus": int8(request.ReviewStatus), "AuditLevel": chance.AuditLevel + 1}); err != nil {
  318 + log.Error("更新机会审核状态失败 chance_id:", chance.Id, err)
  319 + return
  320 + }
  321 + //发送审核结果消息给提交人
  322 + for i := range approveItemResponse.MessageData.ApplyUserMessage {
  323 + message := approveItemResponse.MessageData.ApplyUserMessage[i]
  324 + nextApprovers = append(nextApprovers, message.ReceiverInfo.ReceiverUid)
  325 + if err = agg.SendApproveMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName,
  326 + header.CompanyId, chance.Id, chance.ChanceTypeId, request.ReviewStatus); err != nil {
  327 + log.Error(err)
  328 + return
  329 + }
  330 + }
  331 + } else {
  332 + //发送下一个消息给下一流程的审核人
  333 + for i := range approveItemResponse.MessageData.ApproveMessage {
  334 + message := approveItemResponse.MessageData.ApproveMessage[i]
  335 + nextApprovers = append(nextApprovers, message.ReceiverInfo.ReceiverUid)
  336 + if err = agg.SendApproveMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName,
  337 + header.CompanyId, chance.Id, chance.ChanceTypeId, protocol.ReviewStatusAuditging); err != nil {
  338 + log.Error(err)
  339 + return
  340 + }
  341 + }
  342 + //更新下一批次的审核人 同批次的为审核的状态置为无效
  343 + if len(nextApprovers) != 0 {
  344 + if err = models.UpdatetAuditFlowProcessToNext(chance.Id, chance.AuditLevel+1, nextApprovers); err != nil {
  345 + log.Error(err)
  346 + log.Info(fmt.Sprintf("更新机会失败 chance_id:%v 下一批次审批人员:%v", chance.Id, nextApprovers))
  347 + return
  348 + }
  349 + log.Info(fmt.Sprintf("更新机会 chance_id:%v 下一批次审批人员:%v", chance.Id, nextApprovers))
  350 + if err = models.UpdatetAuditFlowProcessNoApprove(chance.Id, chance.AuditLevel, protocol.ReviewStatusAuditging); err != nil {
  351 + log.Error(err)
  352 + return
  353 + }
  354 + }
301 } 355 }
302 - //更新审批节点审核信息  
303 - //更新机会  
304 - //发送下一个消息给下一流程的审核人  
305 } 356 }
306 rsp = &protocol.ChanceApproveResponse{} 357 rsp = &protocol.ChanceApproveResponse{}
307 return 358 return
308 } 359 }
309 360
  361 +/*ProcessIntegrate */
  362 +type ProcessIntegrateRequest struct {
  363 +}
  364 +type ProcessIntegrateResponse struct {
  365 +}
  366 +
  367 +func ProcessIntegrate(header *protocol.RequestHeader, request *ProcessIntegrateRequest) (rsp *ProcessIntegrateResponse, err error) {
  368 + var ()
  369 + rsp = &ProcessIntegrateResponse{}
  370 + return
  371 +}
  372 +
310 //系统审核状态转为审核类型 reviewStatus - > approveType 373 //系统审核状态转为审核类型 reviewStatus - > approveType
311 func ConverReviewStatus(reviewStatus int) (approveType int) { 374 func ConverReviewStatus(reviewStatus int) (approveType int) {
312 if reviewStatus == protocol.ReviewStatusPass { 375 if reviewStatus == protocol.ReviewStatusPass {
@@ -190,6 +190,7 @@ func Templates(header *protocol.RequestHeader, request *protocol.TemplatesReques @@ -190,6 +190,7 @@ func Templates(header *protocol.RequestHeader, request *protocol.TemplatesReques
190 Icon: item.Icon, 190 Icon: item.Icon,
191 Doc: item.Doc, 191 Doc: item.Doc,
192 FormList: make([]*protocol.Form, len(forms)), 192 FormList: make([]*protocol.Form, len(forms)),
  193 + Link: fmt.Sprintf("%v?templateId=%v", item.Id),
193 } 194 }
194 for j := range forms { 195 for j := range forms {
195 form := forms[j] 196 form := forms[j]
@@ -212,6 +213,20 @@ func checkTemplateIsVisible(header *protocol.RequestHeader, template *models.Aud @@ -212,6 +213,20 @@ func checkTemplateIsVisible(header *protocol.RequestHeader, template *models.Aud
212 return 213 return
213 } 214 }
214 215
  216 +//模板示例
  217 +func ChanceExample(header *protocol.RequestHeader, request *protocol.ChanceExampleRequest) (rsp *protocol.ChanceExampleResponse, err error) {
  218 + var (
  219 + example string
  220 + )
  221 + if example, err = models.GetAuditTemplateExample(int64(request.TemplateId)); err != nil {
  222 + log.Error(request.TemplateId, err)
  223 + err = protocol.NewErrWithMessage(5301) //模板不存在
  224 + return
  225 + }
  226 + rsp = &protocol.ChanceExampleResponse{example}
  227 + return
  228 +}
  229 +
215 //提交机会 230 //提交机会
216 func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmitRequest) (rsp *protocol.ChanceSubmitResponse, err error) { 231 func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmitRequest) (rsp *protocol.ChanceSubmitResponse, err error) {
217 var ( 232 var (
@@ -280,7 +295,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit @@ -280,7 +295,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit
280 for i := range m.MessageData { 295 for i := range m.MessageData {
281 message := m.MessageData[i] 296 message := m.MessageData[i]
282 if err = agg.SendApproveMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName, 297 if err = agg.SendApproveMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName,
283 - header.CompanyId, chance.Id, chance.ChanceTypeId); err != nil { 298 + header.CompanyId, chance.Id, chance.ChanceTypeId, protocol.ReviewStatusAuditging); err != nil {
284 log.Error(err) 299 log.Error(err)
285 orm.Rollback() 300 orm.Rollback()
286 return 301 return
@@ -501,15 +516,12 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat @@ -501,15 +516,12 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat
501 AuditFlowType: config.AuditFlowType, 516 AuditFlowType: config.AuditFlowType,
502 FlowType: config.FlowType, 517 FlowType: config.FlowType,
503 ActionType: int(config.ActionType), 518 ActionType: int(config.ActionType),
504 - EnableStatus: 1,  
505 - ReviewStatus: protocol.ReviewStatusAuditging, 519 +
  520 + ReviewStatus: protocol.ReviewStatusAuditging,
506 } 521 }
507 - //if uid==0 && auditConfig.NoApprover==1{//审批人为空 自动通过  
508 - // item.  
509 - //}  
510 if config.Level == 1 { 522 if config.Level == 1 {
511 item.IsActive = 1 523 item.IsActive = 1
512 - //通知 user_msg 524 + item.EnableStatus = 1
513 } 525 }
514 log.Info(fmt.Sprintf("生成机会审批流:chance_id:%v audit_id:%v audit_level:%v audit_user:%v action_type:%v", chanceId, item.Id, config.Level, uid, resolveActionType(config.ActionType))) 526 log.Info(fmt.Sprintf("生成机会审批流:chance_id:%v audit_id:%v audit_level:%v audit_user:%v action_type:%v", chanceId, item.Id, config.Level, uid, resolveActionType(config.ActionType)))
515 v = append(v, item) 527 v = append(v, item)