正在显示
5 个修改的文件
包含
96 行增加
和
31 行删除
@@ -23,7 +23,7 @@ yunpian_app_key ="0bf6fb10a11a68a95dee80901eb545b5" | @@ -23,7 +23,7 @@ yunpian_app_key ="0bf6fb10a11a68a95dee80901eb545b5" | ||
23 | #存储 http://ability.fjmaimaimai.com:8080/ | 23 | #存储 http://ability.fjmaimaimai.com:8080/ |
24 | source_host ="http://mmm-opp-dev.fjmaimaimai.com/" | 24 | source_host ="http://mmm-opp-dev.fjmaimaimai.com/" |
25 | source_virtual_path=file/opp | 25 | source_virtual_path=file/opp |
26 | -source_path ="${aliyun_file_access||/var/www/opp/file} | 26 | +source_path =/var/www/opp/file |
27 | 27 | ||
28 | #网易云信 IM | 28 | #网易云信 IM |
29 | net_im_base_url ="https://api.netease.im/nimserver" | 29 | net_im_base_url ="https://api.netease.im/nimserver" |
@@ -39,6 +39,13 @@ var errmessge ErrorMap = map[int]string{ | @@ -39,6 +39,13 @@ var errmessge ErrorMap = map[int]string{ | ||
39 | 5201: "该机会模板未配置审批人,请选择其他模板", | 39 | 5201: "该机会模板未配置审批人,请选择其他模板", |
40 | } | 40 | } |
41 | 41 | ||
42 | +const ( | ||
43 | + MsgTypeBulletin = 1 //公告 | ||
44 | + MsgTypeCommend = 2 //表彰 | ||
45 | + MsgTypeInteraction = 4 //互动消息 | ||
46 | + MsgTypeAudit = 8 //机会审核 | ||
47 | +) | ||
48 | + | ||
42 | /*MessageCenter */ | 49 | /*MessageCenter */ |
43 | type MessageCenterRequest struct { | 50 | type MessageCenterRequest struct { |
44 | MsgType int `json:"msgType" valid:"Required"` | 51 | MsgType int `json:"msgType" valid:"Required"` |
services/agg/message.go
0 → 100644
1 | +package agg | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/mmm-go/gocomm/identity/idgen" | ||
6 | + "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | ||
7 | + "opp/models" | ||
8 | + "opp/protocol" | ||
9 | + "time" | ||
10 | +) | ||
11 | + | ||
12 | +var ( | ||
13 | + MessageApprove = "提交了一条%v机会消息,需要您审核" | ||
14 | +) | ||
15 | + | ||
16 | +//发送审批消息 | ||
17 | +func SendApproveMsg(receiverId int64, name string, companyId int64, chanceId int64, chanceTypeId int) (err error) { | ||
18 | + var ( | ||
19 | + userMsg *models.UserMsg | ||
20 | + chanceType *models.ChanceType | ||
21 | + ) | ||
22 | + if chanceType, err = models.GetChanceTypeById(chanceTypeId); err != nil { | ||
23 | + return | ||
24 | + } | ||
25 | + userMsg = &models.UserMsg{ | ||
26 | + Id: idgen.Next(), | ||
27 | + CompanyId: companyId, | ||
28 | + ReceiveUserId: receiverId, | ||
29 | + MsgType: protocol.MsgTypeAudit, | ||
30 | + Message: fmt.Sprintf(MessageApprove, chanceType.Name), | ||
31 | + SourceId: chanceId, | ||
32 | + SourceType: protocol.SourceTypeChance, | ||
33 | + IsPublic: 0, | ||
34 | + CreateAt: time.Now(), | ||
35 | + } | ||
36 | + if _, err = models.AddUserMsg(userMsg); err != nil { | ||
37 | + return | ||
38 | + } | ||
39 | + logMsg(userMsg, name) | ||
40 | + return | ||
41 | +} | ||
42 | + | ||
43 | +//打印消息日志 | ||
44 | +func logMsg(msg *models.UserMsg, name string) { | ||
45 | + log.Info(fmt.Sprintf("发送消息 消息类型:%v Receiver:%v(%v) Message:%v SourceId:%v SourceType:%v", | ||
46 | + msg.MsgType, msg.ReceiveUserId, name, msg.Message, msg.SourceId, msg.SourceType)) | ||
47 | +} |
@@ -30,10 +30,10 @@ type SuplusApprove struct { | @@ -30,10 +30,10 @@ type SuplusApprove struct { | ||
30 | } | 30 | } |
31 | 31 | ||
32 | //新增审批实例 | 32 | //新增审批实例 |
33 | -func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, process []*models.AuditFlowProcess) (err error) { | 33 | +func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, process []*models.AuditFlowProcess) (response NewApproveInstanceResponse, err error) { |
34 | var ( | 34 | var ( |
35 | - request NewApproveInstanceRequest | ||
36 | - response NewApproveInstanceResponse | 35 | + request NewApproveInstanceRequest |
36 | + //response NewApproveInstanceResponse | ||
37 | mapApproves map[int]*Approve = make(map[int]*Approve) | 37 | mapApproves map[int]*Approve = make(map[int]*Approve) |
38 | relativeId int64 | 38 | relativeId int64 |
39 | userCompany *models.UserCompany | 39 | userCompany *models.UserCompany |
@@ -85,8 +85,6 @@ func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, proces | @@ -85,8 +85,6 @@ func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, proces | ||
85 | approve.ApproveUsers = append(approve.ApproveUsers, ApproveUsers{ | 85 | approve.ApproveUsers = append(approve.ApproveUsers, ApproveUsers{ |
86 | Uid: item.Uid, | 86 | Uid: item.Uid, |
87 | Name: approver.NickName, | 87 | Name: approver.NickName, |
88 | - //RoleId:5, | ||
89 | - RoleId: 0, | ||
90 | }) | 88 | }) |
91 | } | 89 | } |
92 | request.RelativeId = relativeId | 90 | request.RelativeId = relativeId |
@@ -193,25 +191,42 @@ type NewApproveInstanceRequest struct { | @@ -193,25 +191,42 @@ type NewApproveInstanceRequest struct { | ||
193 | RelativeId int64 `json:"relativeId"` //关联id | 191 | RelativeId int64 `json:"relativeId"` //关联id |
194 | 192 | ||
195 | } | 193 | } |
196 | -type NewApproveInstanceResponse interface{} | 194 | +type NewApproveInstanceResponse struct { |
195 | + MessageData []MessageDataItem `json:"messageData"` | ||
196 | +} | ||
197 | 197 | ||
198 | //审批节点 | 198 | //审批节点 |
199 | type Approve struct { | 199 | type Approve struct { |
200 | ApproveWay int `json:"approveWay"` //审批方式 1 会签 2 或签 3 发起人从角色成员中自选 | 200 | ApproveWay int `json:"approveWay"` //审批方式 1 会签 2 或签 3 发起人从角色成员中自选 |
201 | ApproveType int `json:"approveType"` //审批类型 1 业务区域负责人 2 指定成员 3 角色 | 201 | ApproveType int `json:"approveType"` //审批类型 1 业务区域负责人 2 指定成员 3 角色 |
202 | + IsDefault int `json:"isDefault"` //1 是默认 0 不是 | ||
203 | + RoleName string `json:"roleName"` //角色名/负责人 | ||
204 | + RoleId int `json:"roleId"` //角色id | ||
202 | ApproveUsers []ApproveUsers `json:"approveUsers"` //审批人 | 205 | ApproveUsers []ApproveUsers `json:"approveUsers"` //审批人 |
203 | } | 206 | } |
204 | 207 | ||
205 | //审批人 | 208 | //审批人 |
206 | type ApproveUsers struct { | 209 | type ApproveUsers struct { |
207 | - Uid int64 `json:"uid"` //用户id | ||
208 | - Name string `json:"name"` //用户名 | ||
209 | - IsDefault int `json:"isDefault"` //1 是默认 0 不是 | ||
210 | - RoleName string `json:"roleName"` //角色名/负责人 | ||
211 | - RoleId int `json:"roleId"` //角色id | 210 | + Uid int64 `json:"uid"` //用户id |
211 | + Name string `json:"name"` //用户名 | ||
212 | ParentIds []int `json:"parentIds"` | 212 | ParentIds []int `json:"parentIds"` |
213 | } | 213 | } |
214 | 214 | ||
215 | +//审批 消息列表 | ||
216 | +type MessageDataItem struct { | ||
217 | + MessageContent contentItem `json:"messageContent"` | ||
218 | + ReceiverInfo receiverInfo `json:"receiverInfo"` | ||
219 | +} | ||
220 | +type contentItem struct { | ||
221 | + ApproveInstanceId int `json:"approveInstanceId"` //审批实例-id | ||
222 | + ApproveProcessId int `json:"approveProcessId"` //审批进程节点-id | ||
223 | + RelativeId int `json:"relativeId"` //机会编号 | ||
224 | +} | ||
225 | +type receiverInfo struct { | ||
226 | + ReceiverUid int64 `json:"receiverUid"` //用户id | ||
227 | + ReceiverName string `json:"receiverName"` //接收人 | ||
228 | +} | ||
229 | + | ||
215 | /*ApproveItem 审批操作*/ | 230 | /*ApproveItem 审批操作*/ |
216 | type ApproveItemRequest struct { | 231 | type ApproveItemRequest struct { |
217 | RelativeId int64 `json:"relativeId"` //关联id | 232 | RelativeId int64 `json:"relativeId"` //关联id |
@@ -269,10 +269,23 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit | @@ -269,10 +269,23 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit | ||
269 | } | 269 | } |
270 | } | 270 | } |
271 | if len(auditFlows) > 0 { | 271 | if len(auditFlows) > 0 { |
272 | - if err = suplusApprove.NewApproveInstance(header, auditFlows); err != nil { | ||
273 | - log.Error(fmt.Sprintf("uid:%v", header.UserId), "request suplus-approve.NewApproveInstance err", err) | 272 | + //7.发送审批实例给审批服务器 |
273 | + if m, e := suplusApprove.NewApproveInstance(header, auditFlows); e != nil { | ||
274 | + log.Error(fmt.Sprintf("uid:%v", header.UserId), "request suplus-approve.NewApproveInstance err", e) | ||
274 | orm.Rollback() | 275 | orm.Rollback() |
276 | + err = e | ||
275 | return | 277 | return |
278 | + } else { | ||
279 | + //7.发送消息通知给审核人(审核消息) | ||
280 | + for i := range m.MessageData { | ||
281 | + message := m.MessageData[i] | ||
282 | + if err = agg.SendApproveMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName, | ||
283 | + header.CompanyId, chance.Id, chance.ChanceTypeId); err != nil { | ||
284 | + log.Error(err) | ||
285 | + orm.Rollback() | ||
286 | + return | ||
287 | + } | ||
288 | + } | ||
276 | } | 289 | } |
277 | } | 290 | } |
278 | 291 | ||
@@ -295,8 +308,6 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit | @@ -295,8 +308,6 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit | ||
295 | } | 308 | } |
296 | orm.Commit() | 309 | orm.Commit() |
297 | 310 | ||
298 | - //6.激活审核流 | ||
299 | - //TODO:7.发送消息通知给审核人(审核消息) | ||
300 | rsp = &protocol.ChanceSubmitResponse{} | 311 | rsp = &protocol.ChanceSubmitResponse{} |
301 | return | 312 | return |
302 | } | 313 | } |
@@ -342,21 +353,6 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit | @@ -342,21 +353,6 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit | ||
342 | } | 353 | } |
343 | } | 354 | } |
344 | 355 | ||
345 | - //4.查询审核配置 | ||
346 | - //5.生成审核流 删除旧的 生成新的 | ||
347 | - //if auditFlows, err = GenAuditFlowProcess(header, chance.Id, template.Id, auditConfig); err != nil { | ||
348 | - // log.Error(err) | ||
349 | - // orm.Rollback() | ||
350 | - // return | ||
351 | - //} | ||
352 | - //for i := 0; i < len(auditFlows); i++ { | ||
353 | - // if _, err = orm.Insert(auditFlows[i]); err != nil { | ||
354 | - // log.Error(err) | ||
355 | - // orm.Rollback() | ||
356 | - // return | ||
357 | - // } | ||
358 | - //} | ||
359 | - | ||
360 | //6.更新文件 | 356 | //6.更新文件 |
361 | { | 357 | { |
362 | if chanceData, err = models.GetChanceDataByChanceId(chance.Id); err == nil { | 358 | if chanceData, err = models.GetChanceDataByChanceId(chance.Id); err == nil { |
-
请 注册 或 登录 后发表评论