Jelajahi Sumber

fix:商机管理未设置订阅信息用户报错

zhangxinlei1996 3 tahun lalu
induk
melakukan
cc93a536e3
1 mengubah file dengan 13 tambahan dan 5 penghapusan
  1. 13 5
      entity/subscribe.go

+ 13 - 5
entity/subscribe.go

@@ -6,7 +6,6 @@ import (
 	"app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/mongodb"
 	"app.yhyue.com/moapp/jybase/mysql"
-	"github.com/zeromicro/go-zero/core/logx"
 )
 
 //获取用户状态
@@ -36,7 +35,6 @@ func (this *UserInfoReq) GetUserInfo() (ret map[string]interface{}, msg string)
 	}
 	varentinfo := &EntInfo{Mysql: this.Mysql} //商机管理
 	this.EntId, this.EntUserId = GetEntByPhone(this.Mysql, phone)
-	logx.Info(this.EntId, this.EntUserId, phone)
 	entinfo := varentinfo.GetById(int(this.EntId))
 	entniche_status := entinfo.Status
 	//用户相关订阅设置
@@ -64,6 +62,7 @@ func (this *UserInfoReq) GetUserInfo() (ret map[string]interface{}, msg string)
 	case "e":
 		//商机管理
 		entnicheJy := this.EntnicheSub()
+		log.Println("~~~", entnicheJy)
 		if entnicheJy != nil {
 			object = this.format(entnicheJy)
 		}
@@ -279,10 +278,19 @@ func (this *UserInfoReq) EntnicheSub() *map[string]interface{} {
 		})
 
 	}
+	log.Println(entInfo.Ent.Name, entInfo.Ent.Id, entInfo.Ent)
 	entnicheJy := common.ObjToMap((*res)["o_entniche"])
-	(*entnicheJy)["starttime"] = entInfo.Ent.Startdate
-	(*entnicheJy)["endtime"] = entInfo.Ent.Enddate
-	(*entnicheJy)["power"] = entInfo.User_power //用户权益
+	if entnicheJy != nil && len(*entnicheJy) > 0 {
+		(*entnicheJy)["starttime"] = entInfo.Ent.Startdate
+		(*entnicheJy)["endtime"] = entInfo.Ent.Enddate
+		(*entnicheJy)["power"] = entInfo.User_power //用户权益
+	} else {
+		entnicheJy = &map[string]interface{}{
+			"starttime": entInfo.Ent.Startdate,
+			"endtime":   entInfo.Ent.Enddate,
+			"power":     entInfo.User_power,
+		}
+	}
 	//获取商机管理的订阅设置
 	return entnicheJy
 }