|
@@ -16,7 +16,7 @@ import (
|
|
"time"
|
|
"time"
|
|
)
|
|
)
|
|
|
|
|
|
-func AddAcceptance(in *biservice.AcceptanceReq, DkPersonMap, ScDkPersonMap []map[string]interface{}, entId int64, productMap map[string]string, scProductMap map[string]string) string {
|
|
|
|
|
|
+func AddAcceptance(in *biservice.AcceptanceReq, productMap []ProductMap, entId int64) string {
|
|
in.ParamData = strings.ReplaceAll(in.ParamData, "\n", "")
|
|
in.ParamData = strings.ReplaceAll(in.ParamData, "\n", "")
|
|
nowTime := time.Now().Format(date.Date_Full_Layout)
|
|
nowTime := time.Now().Format(date.Date_Full_Layout)
|
|
//编号处理
|
|
//编号处理
|
|
@@ -78,33 +78,28 @@ func AddAcceptance(in *biservice.AcceptanceReq, DkPersonMap, ScDkPersonMap []map
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//判断是否创建工单
|
|
//判断是否创建工单
|
|
- dkProduct := []string{}
|
|
|
|
- scdkProduct := []string{}
|
|
|
|
- dkOk, scDkOk := false, false
|
|
|
|
|
|
+ selectedProductMap := map[string]SelectProductMap{}
|
|
|
|
+ productArr := []string{}
|
|
if _, isOk := childMap["咨询产品"]; isOk {
|
|
if _, isOk := childMap["咨询产品"]; isOk {
|
|
for _, v := range strings.Split(gconv.String(childMap["咨询产品"]), ",") {
|
|
for _, v := range strings.Split(gconv.String(childMap["咨询产品"]), ",") {
|
|
- if productMap[v] != "" {
|
|
|
|
- dkProduct = append(dkProduct, v)
|
|
|
|
- dkOk = true
|
|
|
|
- continue
|
|
|
|
|
|
+ for _, product := range productMap {
|
|
|
|
+ if strings.Contains(product.Product, v) {
|
|
|
|
+ selectedProduct := selectedProductMap[product.ProductCode]
|
|
|
|
+ selectedProduct.PersonArr = product.PersonArr
|
|
|
|
+ selectedProduct.Product = append(selectedProduct.Product, v)
|
|
|
|
+ productArr = append(productArr, v)
|
|
|
|
+ selectedProductMap[product.ProductCode] = selectedProduct
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- if scProductMap[v] != "" {
|
|
|
|
- scdkProduct = append(scdkProduct, v)
|
|
|
|
- scDkOk = true
|
|
|
|
- continue
|
|
|
|
- }
|
|
|
|
- is_clue = 2
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
- }
|
|
|
|
- if dkOk {
|
|
|
|
- //大客工单保存
|
|
|
|
- if !AddOrderWork("dk", acceptance_no, nowTime, phone, company, tx, in, DkPersonMap, entId, dkProduct) {
|
|
|
|
- return false
|
|
|
|
|
|
+ if len(strings.Split(gconv.String(childMap["咨询产品"]), ",")) != len(productArr) {
|
|
|
|
+ is_clue = 2
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if scDkOk {
|
|
|
|
- //大客工单保存
|
|
|
|
- if !AddOrderWork("scdk", acceptance_no, nowTime, phone, company, tx, in, ScDkPersonMap, entId, scdkProduct) {
|
|
|
|
|
|
+ for k, v := range selectedProductMap {
|
|
|
|
+ if !AddOrderWork(k, acceptance_no, nowTime, phone, company, tx, in, v, entId) {
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -125,13 +120,13 @@ func AddAcceptance(in *biservice.AcceptanceReq, DkPersonMap, ScDkPersonMap []map
|
|
return ""
|
|
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 {
|
|
|
|
|
|
+func AddOrderWork(orderType, acceptance_no, nowTime, phone, company string, tx *sql.Tx, in *biservice.AcceptanceReq, selectPersonMap SelectProductMap, entId int64) bool {
|
|
dkPerson := ""
|
|
dkPerson := ""
|
|
dkdeptName := ""
|
|
dkdeptName := ""
|
|
dkdeptId := ""
|
|
dkdeptId := ""
|
|
dkPositionId := int64(0)
|
|
dkPositionId := int64(0)
|
|
personMap := map[string]interface{}{}
|
|
personMap := map[string]interface{}{}
|
|
- personMap = Findcandidate(PersonMapArr, entId, orderType)
|
|
|
|
|
|
+ personMap = Findcandidate(selectPersonMap.PersonArr, entId, orderType)
|
|
dkPositionId = gconv.Int64(personMap["positionId"])
|
|
dkPositionId = gconv.Int64(personMap["positionId"])
|
|
dkPerson = gconv.String(personMap["name"])
|
|
dkPerson = gconv.String(personMap["name"])
|
|
dkdeptId = gconv.String(personMap["deptId"])
|
|
dkdeptId = gconv.String(personMap["deptId"])
|
|
@@ -141,7 +136,7 @@ func AddOrderWork(orderType, acceptance_no, nowTime, phone, company string, tx *
|
|
orderWorkMap := map[string]interface{}{
|
|
orderWorkMap := map[string]interface{}{
|
|
"work_order_no": work_order_no,
|
|
"work_order_no": work_order_no,
|
|
"acceptance_no": acceptance_no,
|
|
"acceptance_no": acceptance_no,
|
|
- "type": strings.Join(product, ","),
|
|
|
|
|
|
+ "type": strings.Join(selectPersonMap.Product, ","),
|
|
"status": 1,
|
|
"status": 1,
|
|
"initiator_name": in.EntUserName,
|
|
"initiator_name": in.EntUserName,
|
|
"initiator_position_id": in.PositionId,
|
|
"initiator_position_id": in.PositionId,
|
|
@@ -156,6 +151,7 @@ func AddOrderWork(orderType, acceptance_no, nowTime, phone, company string, tx *
|
|
"department_name": dkdeptName,
|
|
"department_name": dkdeptName,
|
|
"update_time": nil,
|
|
"update_time": nil,
|
|
}
|
|
}
|
|
|
|
+ logx.Info(orderWorkMap, "11111", selectPersonMap)
|
|
ok3 := WorkOrder.InsertByTx(tx, "order_work", orderWorkMap)
|
|
ok3 := WorkOrder.InsertByTx(tx, "order_work", orderWorkMap)
|
|
if ok3 <= 0 {
|
|
if ok3 <= 0 {
|
|
log.Println("工单保存失败")
|
|
log.Println("工单保存失败")
|
|
@@ -182,26 +178,26 @@ func AddOrderWork(orderType, acceptance_no, nowTime, phone, company string, tx *
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
log.Println(personMap)
|
|
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)
|
|
|
|
|
|
+ log.Println(GmailAuth, personMap, strings.Join(selectPersonMap.Product, ","), dkPerson, in.EntUserName, nowTime, work_order_no, phone, company)
|
|
|
|
+ WorkMail(GmailAuth, personMap, strings.Join(selectPersonMap.Product, ","), dkPerson, in.EntUserName, nowTime, work_order_no, phone, company)
|
|
}
|
|
}
|
|
return true
|
|
return true
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
// 大客人员选择
|
|
// 大客人员选择
|
|
-func Findcandidate(DkPersonMap []map[string]interface{}, entId int64, orderType string) map[string]interface{} {
|
|
|
|
|
|
+func Findcandidate(personArr []Person, entId int64, orderType string) map[string]interface{} {
|
|
person := map[string]interface{}{}
|
|
person := map[string]interface{}{}
|
|
positionArr := []string{}
|
|
positionArr := []string{}
|
|
personMap := map[string]map[string]interface{}{}
|
|
personMap := map[string]map[string]interface{}{}
|
|
positionId := int64(0)
|
|
positionId := int64(0)
|
|
phoneArr := []string{}
|
|
phoneArr := []string{}
|
|
personNameArr := []string{}
|
|
personNameArr := []string{}
|
|
- for _, v := range DkPersonMap {
|
|
|
|
- phoneArr = append(phoneArr, fmt.Sprintf(`"%s"`, gconv.String(v["phone"])))
|
|
|
|
- personNameArr = append(personNameArr, fmt.Sprintf(`"%s"`, gconv.String(v["personName"])))
|
|
|
|
- personMap[gconv.String(v["phone"])] = map[string]interface{}{
|
|
|
|
- "name": gconv.String(v["personName"]),
|
|
|
|
|
|
+ for _, v := range personArr {
|
|
|
|
+ phoneArr = append(phoneArr, fmt.Sprintf(`"%s"`, v.Phone))
|
|
|
|
+ personNameArr = append(personNameArr, fmt.Sprintf(`"%s"`, v.Name))
|
|
|
|
+ personMap[gconv.String(v.Phone)] = map[string]interface{}{
|
|
|
|
+ "name": gconv.String(v.Name),
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//个人邮箱,部门信息获取
|
|
//个人邮箱,部门信息获取
|
|
@@ -251,9 +247,9 @@ FROM
|
|
GROUP BY current_position_id
|
|
GROUP BY current_position_id
|
|
ORDER BY
|
|
ORDER BY
|
|
count ,FIELD(current_name,?) asc `, strings.Join(positionArr, ","), orderType, strings.Join(personNameArr, ","))
|
|
count ,FIELD(current_name,?) asc `, strings.Join(positionArr, ","), orderType, strings.Join(personNameArr, ","))
|
|
- if positionNumberMap != nil && len(*positionNumberMap) == len(DkPersonMap) {
|
|
|
|
|
|
+ if positionNumberMap != nil && len(*positionNumberMap) == len(personArr) {
|
|
positionId = gconv.Int64((*positionNumberMap)[0]["current_position_id"])
|
|
positionId = gconv.Int64((*positionNumberMap)[0]["current_position_id"])
|
|
- } else if positionNumberMap != nil && len(*positionNumberMap) != len(DkPersonMap) {
|
|
|
|
|
|
+ } else if positionNumberMap != nil && len(*positionNumberMap) != len(personArr) {
|
|
for _, v := range positionArr {
|
|
for _, v := range positionArr {
|
|
count := int64(0)
|
|
count := int64(0)
|
|
for _, v1 := range *positionNumberMap {
|
|
for _, v1 := range *positionNumberMap {
|
|
@@ -344,14 +340,11 @@ func WorkMail(gmailAuth []*mail.GmailAuth, personMap map[string]interface{}, pro
|
|
if gconv.String(common.If(gconv.String(personMap["superiorDepthPersonMail"]) == "", "", gconv.String(personMap["superiorDepthPersonMail"]))) != "" {
|
|
if gconv.String(common.If(gconv.String(personMap["superiorDepthPersonMail"]) == "", "", gconv.String(personMap["superiorDepthPersonMail"]))) != "" {
|
|
mailArr = append(mailArr, gconv.String(common.If(gconv.String(personMap["superiorDepthPersonMail"]) == "", "", gconv.String(personMap["superiorDepthPersonMail"]))))
|
|
mailArr = append(mailArr, gconv.String(common.If(gconv.String(personMap["superiorDepthPersonMail"]) == "", "", gconv.String(personMap["superiorDepthPersonMail"]))))
|
|
}
|
|
}
|
|
-
|
|
|
|
toCc := strings.Join(mailArr, ",")
|
|
toCc := strings.Join(mailArr, ",")
|
|
if len(mailArr) > 0 {
|
|
if len(mailArr) > 0 {
|
|
toMail = fmt.Sprintf("%s|%s", toMail, toCc)
|
|
toMail = fmt.Sprintf("%s|%s", toMail, toCc)
|
|
}
|
|
}
|
|
log.Println(toMail, "", title, content)
|
|
log.Println(toMail, "", title, content)
|
|
- /*toMail = "wanghao@topnet.net.cn"
|
|
|
|
- toCc = "wanghao@topnet.net.cn"*/
|
|
|
|
for k, v := range gmailAuth {
|
|
for k, v := range gmailAuth {
|
|
fool := mail.GSendMail_q("剑鱼标讯", toMail, "", "", title, content, "", "", v)
|
|
fool := mail.GSendMail_q("剑鱼标讯", toMail, "", "", title, content, "", "", v)
|
|
if fool {
|
|
if fool {
|