|
@@ -4,38 +4,67 @@ import (
|
|
|
. "app.yhyue.com/moapp/jybase/api"
|
|
|
qu "app.yhyue.com/moapp/jybase/common"
|
|
|
"app.yhyue.com/moapp/jybase/redis"
|
|
|
- "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
|
|
|
"fmt"
|
|
|
+ "github.com/levigross/grequests"
|
|
|
"jy/src/jfw/modules/bigmember/src/config"
|
|
|
"jy/src/jfw/modules/bigmember/src/db"
|
|
|
+ "log"
|
|
|
+)
|
|
|
+
|
|
|
+const (
|
|
|
+ KFPhone = "400-108-6670"
|
|
|
)
|
|
|
|
|
|
func (u *Use) GetCustom() {
|
|
|
- r := func() Result {
|
|
|
- cName := func() (customName string) {
|
|
|
- userid := qu.ObjToString(u.GetSession("userId"))
|
|
|
- positionId := qu.Int64All(u.GetSession("positionId"))
|
|
|
- t := u.GetString("type") // kf 直接返回客服 不查询客成
|
|
|
- if userid == "" || t == "kf" {
|
|
|
- return
|
|
|
- }
|
|
|
- bigPower := jy.GetBigVipUserBaseMsg(u.Session(), *config.Middleground)
|
|
|
- if bigPower.Status <= 0 && bigPower.EntnicheStatus <= 0 {
|
|
|
- return ""
|
|
|
- }
|
|
|
- res := db.MysqlSubject.SelectBySql("SELECT i.name as customer_name FROM dwd_f_data_equity_info e INNER JOIN dwd_f_crm_clue_info c on (e.uid=c.uid) INNER JOIN dwd_f_csm_customer_info i on( c.id = i.clue_id) WHERE e.position_id=? AND e.product_type in ('大会员','商机管理') AND c.is_transfer=1", positionId)
|
|
|
- if res != nil || len(*res) != 0 {
|
|
|
- for _, m := range *res {
|
|
|
- if customName = qu.ObjToString(m["customer_name"]); customName != "" {
|
|
|
- return
|
|
|
- }
|
|
|
+ data := func() (customInfo map[string]interface{}) {
|
|
|
+ defaultCustomerServiceInfo := getWxm("") // 默认的客服
|
|
|
+ if customInfo, b := defaultCustomerServiceInfo.(map[string]interface{}); b {
|
|
|
+ customInfo["phone"] = KFPhone
|
|
|
+ }
|
|
|
+ userid := qu.ObjToString(u.GetSession("userId"))
|
|
|
+ positionId := qu.Int64All(u.GetSession("positionId"))
|
|
|
+ t := u.GetString("type") // kf 直接返回客服 不查询客成
|
|
|
+ if userid == "" || t == "kf" {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 调用王浩的接口获取客服信息
|
|
|
+ //调用王浩的接口 获取客服信息 替换结果
|
|
|
+ data := map[string]interface{}{
|
|
|
+ "position_id": positionId,
|
|
|
+ }
|
|
|
+ geq := &grequests.RequestOptions{
|
|
|
+ JSON: data,
|
|
|
+ }
|
|
|
+ resp, err := grequests.Post(config.Config.CustomerServiceUrl, geq)
|
|
|
+ if err != nil {
|
|
|
+ log.Println("调用接口失败:", data, err)
|
|
|
+ }
|
|
|
+ if resp != nil {
|
|
|
+ csiData := map[string]interface{}{}
|
|
|
+ err = resp.JSON(&csiData)
|
|
|
+ if err != nil {
|
|
|
+ log.Println("序列化失败:", resp, err)
|
|
|
+ } else {
|
|
|
+ if qu.InterfaceToStr(csiData["phone"]) != "" && qu.InterfaceToStr(csiData["wxer"]) != "" {
|
|
|
+ customInfo = csiData
|
|
|
}
|
|
|
}
|
|
|
- return
|
|
|
- }()
|
|
|
- return Result{Data: getWxm(cName)}
|
|
|
+ }
|
|
|
+ //bigPower := jy.GetBigVipUserBaseMsg(u.Session(), *config.Middleground)
|
|
|
+ //if bigPower.Status <= 0 && bigPower.EntnicheStatus <= 0 {
|
|
|
+ // return ""
|
|
|
+ //}
|
|
|
+ //res := db.MysqlSubject.SelectBySql("SELECT i.name as customer_name FROM dwd_f_data_equity_info e INNER JOIN dwd_f_crm_clue_info c on (e.uid=c.uid) INNER JOIN dwd_f_csm_customer_info i on( c.id = i.clue_id) WHERE e.position_id=? AND e.product_type in ('大会员','商机管理') AND c.is_transfer=1", positionId)
|
|
|
+ //if res != nil || len(*res) != 0 {
|
|
|
+ // for _, m := range *res {
|
|
|
+ // if customName = qu.ObjToString(m["customer_name"]); customName != "" {
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ return
|
|
|
}()
|
|
|
- u.ServeJson(r)
|
|
|
+ u.ServeJson(Result{Data: data})
|
|
|
}
|
|
|
|
|
|
func getWxm(name string) (customEwm interface{}) {
|