|
@@ -16,7 +16,7 @@ import (
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
-func AddAcceptance(in *biservice.AcceptanceReq, DkPersonMap []map[string]interface{}, entId int64, productMap map[string]string) string {
|
|
|
+func AddAcceptance(in *biservice.AcceptanceReq, DkPersonMap, ScDkPersonMap []map[string]interface{}, entId int64, productMap map[string]string, scProductMap map[string]string) string {
|
|
|
in.ParamData = strings.ReplaceAll(in.ParamData, "\n", "")
|
|
|
nowTime := time.Now().Format(date.Date_Full_Layout)
|
|
|
//编号处理
|
|
@@ -78,73 +78,35 @@ func AddAcceptance(in *biservice.AcceptanceReq, DkPersonMap []map[string]interfa
|
|
|
}
|
|
|
}
|
|
|
//判断是否创建工单
|
|
|
- dkPerson := ""
|
|
|
- dkdeptName := ""
|
|
|
- dkdeptId := ""
|
|
|
dkProduct := []string{}
|
|
|
- dkPositionId := int64(0)
|
|
|
- personMap := map[string]interface{}{}
|
|
|
+ scdkProduct := []string{}
|
|
|
+ dkOk, scDkOk := false, false
|
|
|
if _, isOk := childMap["咨询产品"]; isOk {
|
|
|
for _, v := range strings.Split(gconv.String(childMap["咨询产品"]), ",") {
|
|
|
- switch productMap[v] {
|
|
|
- case "dk":
|
|
|
+ if productMap[v] != "" {
|
|
|
dkProduct = append(dkProduct, v)
|
|
|
- if dkPositionId == 0 {
|
|
|
- personMap = Findcandidate(DkPersonMap, entId)
|
|
|
- dkPositionId = gconv.Int64(personMap["positionId"])
|
|
|
- dkPerson = gconv.String(personMap["name"])
|
|
|
- dkdeptId = gconv.String(personMap["deptId"])
|
|
|
- dkdeptName = gconv.String(personMap["deptName"])
|
|
|
- }
|
|
|
+ dkOk = true
|
|
|
continue
|
|
|
- default:
|
|
|
- is_clue = 2
|
|
|
}
|
|
|
-
|
|
|
+ if scProductMap[v] != "" {
|
|
|
+ scdkProduct = append(scdkProduct, v)
|
|
|
+ scDkOk = true
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ is_clue = 2
|
|
|
}
|
|
|
}
|
|
|
- if dkPositionId != 0 {
|
|
|
- work_order_no := fmt.Sprintf("GD%s%s", time.Now().Format(date.Date_yyyyMMdd), FindNumber("gd"))
|
|
|
- orderWorkMap := map[string]interface{}{
|
|
|
- "work_order_no": work_order_no,
|
|
|
- "acceptance_no": acceptance_no,
|
|
|
- "type": strings.Join(dkProduct, ","),
|
|
|
- "status": 1,
|
|
|
- "initiator_name": in.EntUserName,
|
|
|
- "initiator_position_id": in.PositionId,
|
|
|
- "current_name": dkPerson,
|
|
|
- "current_position_id": dkPositionId,
|
|
|
- "is_delete": 1,
|
|
|
- "creator_name": in.EntUserName,
|
|
|
- "creator_position_id": in.PositionId,
|
|
|
- "creator_time": nowTime,
|
|
|
- "two_type": "dk",
|
|
|
- "department_no": dkdeptId,
|
|
|
- "department_name": dkdeptName,
|
|
|
- "update_time": nil,
|
|
|
- }
|
|
|
- ok3 := WorkOrder.InsertByTx(tx, "order_work", orderWorkMap)
|
|
|
- if ok3 <= 0 {
|
|
|
+ if dkOk {
|
|
|
+ //大客工单保存
|
|
|
+ if !AddOrderWork("dk", acceptance_no, nowTime, phone, company, tx, in, DkPersonMap, entId, dkProduct) {
|
|
|
return false
|
|
|
}
|
|
|
- //发送邮件
|
|
|
- //日志添加
|
|
|
- approvalRecordMap := map[string]interface{}{
|
|
|
- "work_order_no": work_order_no,
|
|
|
- "status": 1,
|
|
|
- "new_status": nil,
|
|
|
- "handle_name": dkPerson,
|
|
|
- "handle_position_id": dkPositionId,
|
|
|
- "handle_dept_id": dkdeptId,
|
|
|
- "handle_dept_name": dkdeptName,
|
|
|
- "creator_name": in.EntUserName,
|
|
|
- "creator_position_id": in.PositionId,
|
|
|
- "is_delete": 1,
|
|
|
- "creator_time": nowTime,
|
|
|
+ }
|
|
|
+ if scDkOk {
|
|
|
+ //大客工单保存
|
|
|
+ if !AddOrderWork("scdk", acceptance_no, nowTime, phone, company, tx, in, ScDkPersonMap, entId, scdkProduct) {
|
|
|
+ return false
|
|
|
}
|
|
|
- WorkOrder.InsertByTx(tx, "approval_record", approvalRecordMap)
|
|
|
- log.Println(personMap)
|
|
|
- WorkMail(GmailAuth, personMap, strings.Join(dkProduct, ","), dkPerson, in.EntUserName, nowTime, work_order_no, phone, company)
|
|
|
}
|
|
|
}
|
|
|
//先新增受理单主单
|
|
@@ -162,10 +124,74 @@ func AddAcceptance(in *biservice.AcceptanceReq, DkPersonMap []map[string]interfa
|
|
|
}
|
|
|
return ""
|
|
|
|
|
|
+}
|
|
|
+func AddOrderWork(orderType, acceptance_no, nowTime, phone, company string, tx *sql.Tx, in *biservice.AcceptanceReq, PersonMapArr []map[string]interface{}, entId int64, product []string) bool {
|
|
|
+ dkPerson := ""
|
|
|
+ dkdeptName := ""
|
|
|
+ dkdeptId := ""
|
|
|
+ dkPositionId := int64(0)
|
|
|
+ personMap := map[string]interface{}{}
|
|
|
+ personMap = Findcandidate(PersonMapArr, entId, orderType)
|
|
|
+ dkPositionId = gconv.Int64(personMap["positionId"])
|
|
|
+ dkPerson = gconv.String(personMap["name"])
|
|
|
+ dkdeptId = gconv.String(personMap["deptId"])
|
|
|
+ dkdeptName = gconv.String(personMap["deptName"])
|
|
|
+ if dkPositionId != 0 {
|
|
|
+ work_order_no := fmt.Sprintf("GD%s%s", time.Now().Format(date.Date_yyyyMMdd), FindNumber("gd"))
|
|
|
+ orderWorkMap := map[string]interface{}{
|
|
|
+ "work_order_no": work_order_no,
|
|
|
+ "acceptance_no": acceptance_no,
|
|
|
+ "type": strings.Join(product, ","),
|
|
|
+ "status": 1,
|
|
|
+ "initiator_name": in.EntUserName,
|
|
|
+ "initiator_position_id": in.PositionId,
|
|
|
+ "current_name": dkPerson,
|
|
|
+ "current_position_id": dkPositionId,
|
|
|
+ "is_delete": 1,
|
|
|
+ "creator_name": in.EntUserName,
|
|
|
+ "creator_position_id": in.PositionId,
|
|
|
+ "creator_time": nowTime,
|
|
|
+ "two_type": orderType,
|
|
|
+ "department_no": dkdeptId,
|
|
|
+ "department_name": dkdeptName,
|
|
|
+ "update_time": nil,
|
|
|
+ }
|
|
|
+ ok3 := WorkOrder.InsertByTx(tx, "order_work", orderWorkMap)
|
|
|
+ if ok3 <= 0 {
|
|
|
+ log.Println("工单保存失败")
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ //发送邮件
|
|
|
+ //日志添加
|
|
|
+ approvalRecordMap := map[string]interface{}{
|
|
|
+ "work_order_no": work_order_no,
|
|
|
+ "status": 1,
|
|
|
+ "new_status": nil,
|
|
|
+ "handle_name": dkPerson,
|
|
|
+ "handle_position_id": dkPositionId,
|
|
|
+ "handle_dept_id": dkdeptId,
|
|
|
+ "handle_dept_name": dkdeptName,
|
|
|
+ "creator_name": in.EntUserName,
|
|
|
+ "creator_position_id": in.PositionId,
|
|
|
+ "is_delete": 1,
|
|
|
+ "creator_time": nowTime,
|
|
|
+ }
|
|
|
+ ok4 := WorkOrder.InsertByTx(tx, "approval_record", approvalRecordMap)
|
|
|
+ if ok4 <= 0 {
|
|
|
+ log.Println("工单记录保存失败")
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ log.Println(personMap)
|
|
|
+ log.Println(GmailAuth, personMap, strings.Join(product, ","), dkPerson, in.EntUserName, nowTime, work_order_no, phone, company)
|
|
|
+
|
|
|
+ //WorkMail(GmailAuth, personMap, strings.Join(product, ","), dkPerson, in.EntUserName, nowTime, work_order_no, phone, company)
|
|
|
+ }
|
|
|
+ return true
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// 大客人员选择
|
|
|
-func Findcandidate(DkPersonMap []map[string]interface{}, entId int64) map[string]interface{} {
|
|
|
+func Findcandidate(DkPersonMap []map[string]interface{}, entId int64, orderType string) map[string]interface{} {
|
|
|
person := map[string]interface{}{}
|
|
|
positionArr := []string{}
|
|
|
personMap := map[string]map[string]interface{}{}
|
|
@@ -220,10 +246,10 @@ FROM
|
|
|
FROM
|
|
|
order_work
|
|
|
WHERE
|
|
|
- FIND_IN_SET(current_position_id , ?)
|
|
|
+ FIND_IN_SET(current_position_id , ?) and two_type=?
|
|
|
GROUP BY current_position_id
|
|
|
ORDER BY
|
|
|
- count`, strings.Join(positionArr, ","))
|
|
|
+ count`, strings.Join(positionArr, ","), orderType)
|
|
|
if positionNumberMap != nil && len(*positionNumberMap) == len(DkPersonMap) {
|
|
|
positionId = gconv.Int64((*positionNumberMap)[0]["current_position_id"])
|
|
|
} else if positionNumberMap != nil && len(*positionNumberMap) != len(DkPersonMap) {
|