|
@@ -1,7 +1,9 @@
|
|
|
package service
|
|
|
|
|
|
import (
|
|
|
+ "app.yhyue.com/moapp/jybase/common"
|
|
|
"app.yhyue.com/moapp/jybase/date"
|
|
|
+ "app.yhyue.com/moapp/jybase/mail"
|
|
|
"app.yhyue.com/moapp/jybase/redis"
|
|
|
. "bp.jydev.jianyu360.cn/BaseService/biService/entity"
|
|
|
"bp.jydev.jianyu360.cn/BaseService/biService/rpc/biservice"
|
|
@@ -50,6 +52,8 @@ func AddAcceptance(in *biservice.AcceptanceReq, DkPersonMap []map[string]interfa
|
|
|
//新增受理单子单
|
|
|
childMap := gconv.Map(in.ParamData)
|
|
|
if childMap != nil && len(childMap) > 0 {
|
|
|
+ phone := ""
|
|
|
+ company := ""
|
|
|
innerArr := []interface{}{}
|
|
|
innerStr := []string{"acceptance_no", "field_name", "field_value", "creator_name", "creator_position_id", "creator_time"}
|
|
|
for k, v := range childMap {
|
|
@@ -59,6 +63,12 @@ func AddAcceptance(in *biservice.AcceptanceReq, DkPersonMap []map[string]interfa
|
|
|
innerArr = append(innerArr, in.EntUserName)
|
|
|
innerArr = append(innerArr, in.PositionId)
|
|
|
innerArr = append(innerArr, nowTime)
|
|
|
+ switch k {
|
|
|
+ case "公司名称":
|
|
|
+ company = gconv.String(v)
|
|
|
+ case "联系方式num":
|
|
|
+ phone = gconv.String(v)
|
|
|
+ }
|
|
|
}
|
|
|
if len(innerArr) > 0 {
|
|
|
ok2, ok3 := WorkOrder.InsertBatchByTx(tx, "order_acceptance_children", innerStr, innerArr)
|
|
@@ -113,7 +123,7 @@ func AddAcceptance(in *biservice.AcceptanceReq, DkPersonMap []map[string]interfa
|
|
|
}
|
|
|
//发送邮件
|
|
|
log.Println(personMap)
|
|
|
-
|
|
|
+ WorkMail(GmailAuth, personMap, strings.Join(dkProduct, ","), dkPerson, in.EntUserName, nowTime, work_order_no, phone, company)
|
|
|
}
|
|
|
}
|
|
|
//先新增受理单主单
|
|
@@ -186,11 +196,26 @@ FROM
|
|
|
FROM
|
|
|
order_work
|
|
|
WHERE
|
|
|
- current_position_id IN (?)
|
|
|
+ FIND_IN_SET(current_position_id , ?)
|
|
|
+ GROUP BY current_position_id
|
|
|
ORDER BY
|
|
|
count`, strings.Join(positionArr, ","))
|
|
|
- if positionNumberMap != nil && len(*positionNumberMap) > 0 {
|
|
|
+ if positionNumberMap != nil && len(*positionNumberMap) == len(DkPersonMap) {
|
|
|
positionId = gconv.Int64((*positionNumberMap)[0]["current_position_id"])
|
|
|
+ } else if positionNumberMap != nil && len(*positionNumberMap) != len(DkPersonMap) {
|
|
|
+ for _, v := range positionArr {
|
|
|
+ count := int64(0)
|
|
|
+ for _, v1 := range *positionNumberMap {
|
|
|
+ id := gconv.String(v1["current_position_id"])
|
|
|
+ if id == v {
|
|
|
+ count = gconv.Int64(v1["count"])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if count == 0 {
|
|
|
+ positionId = gconv.Int64(v)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
positionId = gconv.Int64(positionArr[0])
|
|
|
}
|
|
@@ -249,3 +274,32 @@ func FindNumber(moudle string) string {
|
|
|
count := redis.Incr("newother", key)
|
|
|
return fmt.Sprintf("%04d", count)
|
|
|
}
|
|
|
+func WorkMail(gmailAuth []*mail.GmailAuth, personMap map[string]interface{}, productStr string, personName1, personName2, createTimeStr, acceptance_no, phone, company string) {
|
|
|
+ orderType := fmt.Sprintf(`客户咨询线索(%s)`, productStr)
|
|
|
+ title := fmt.Sprintf("%s通知", orderType)
|
|
|
+ if personName1 == gconv.String(personMap["deptPersonName"]) {
|
|
|
+ personMap["deptPersonMail"] = ""
|
|
|
+ }
|
|
|
+ if personName1 == gconv.String(personMap["superiorDepthPersonName"]) {
|
|
|
+ personMap["superiorDepthPersonMail"] = ""
|
|
|
+ }
|
|
|
+ content := fmt.Sprintf(`%s,您好,“%s”于%s新增了1条"%s”(工单编号:%s)%s%s,请及时前往【剑鱼PC工作台-任务单-工单管理-我负责的】进行工单处理。`, personName1, personName2, createTimeStr, orderType, acceptance_no, gconv.String(common.If(phone == "", "", fmt.Sprintf(`,客户联系方式为:%s`, phone))), gconv.String(common.If(company == "", "", fmt.Sprintf(`,公司名称:%s`, company))))
|
|
|
+ toMail := gconv.String(personMap["mail"])
|
|
|
+ toCc := fmt.Sprintf("%s%s", gconv.String(common.If(gconv.String(personMap["deptPersonMail"]) == "", "", gconv.String(personMap["deptPersonMail"]))), gconv.String(common.If(gconv.String(personMap["superiorDepthPersonMail"]) == "", "", gconv.String(personMap["superiorDepthPersonMail"]))))
|
|
|
+ log.Println(toMail, toCc, title, content)
|
|
|
+ toMail = "wanghao@topnet.net.cn"
|
|
|
+ toCc = "wanghao@topnet.net.cn"
|
|
|
+ for k, v := range gmailAuth {
|
|
|
+ fool := mail.GSendMail_q("剑鱼标讯", toMail, toCc, "", title, content, "", "", v)
|
|
|
+ if fool {
|
|
|
+ logx.Info(in.Mails, fmt.Sprintf("使用%s发送邮件成功", v.User))
|
|
|
+ break
|
|
|
+ }
|
|
|
+ if k < len(gmailAuth)-1 {
|
|
|
+ logx.Info(toMail, fmt.Sprintf("使用%s发送邮件失败!3s后使用其他邮箱尝试", v.User))
|
|
|
+ } else {
|
|
|
+ logx.Info(toMail, fmt.Sprintf("使用%s发送邮件失败!", v.User))
|
|
|
+ }
|
|
|
+ time.Sleep(time.Second * 3)
|
|
|
+ }
|
|
|
+}
|