|
@@ -7,15 +7,50 @@ import (
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
-func GetUserRegisterTime(userId string) (t int64) {
|
|
|
- user, ok := db.Mgo.FindById("user", userId, `"l_registedate":1`)
|
|
|
- if ok && user != nil {
|
|
|
- t = common.Int64All((*user)["l_registedate"])
|
|
|
+//用户redis缓存
|
|
|
+type UserBaseMsg struct {
|
|
|
+ Status int `json:"status"` //大会员状态
|
|
|
+ VipStatus int `json:"vip_status"` //超级订阅状态
|
|
|
+ EntnicheStatus int `json:"entniche_status"` //商机管理状态
|
|
|
+ Registedate int64 `json:"registedate"` //用户注册时间
|
|
|
+ EntIsNew bool `json:"entIsNew"` //是否是新版商机管理用户
|
|
|
+}
|
|
|
+
|
|
|
+// GetUserInfo 查看 22年活动 用户是否满足条件
|
|
|
+func GetUserInfo(userId string) *UserBaseMsg {
|
|
|
+ userPower := UserBaseMsg{}
|
|
|
+ if userId == "" {
|
|
|
+ return &userPower
|
|
|
+ }
|
|
|
+ user, ok := db.Mgo.FindById("user", userId, `{"i_member_status":1,"l_registedate":1,"i_vip_status":1,"s_phone":1,"s_m_phone":1}`)
|
|
|
+ if ok && user != nil && len(*user) > 0 {
|
|
|
+ userPower.Status = common.IntAllDef((*user)["i_member_status"], 0)
|
|
|
+ userPower.VipStatus = common.IntAllDef((*user)["i_vip_status"], 0)
|
|
|
+ userPower.Registedate = common.Int64All((*user)["l_registedate"])
|
|
|
+ phone, _ := common.If((*user)["s_phone"] != nil, (*user)["s_phone"], (*user)["s_m_phone"]).(string)
|
|
|
+ if phone != "" {
|
|
|
+ res := db.Mysql.SelectBySql(`SELECT i.isNew,i.name,i.phone,i.status,i.auth_status,u.power FROM entniche_user u LEFT JOIN entniche_info i
|
|
|
+ ON u.ent_id=i.id
|
|
|
+ WHERE u.phone=?
|
|
|
+ ORDER BY i.status DESC,i.auth_status DESC, CASE WHEN i.phone=? THEN 0 ELSE 1 END ASC`, phone, phone)
|
|
|
+ if res != nil && len(*res) > 0 {
|
|
|
+ //已购买企业未过期-商机管理用户
|
|
|
+ for _, v := range *res {
|
|
|
+ if common.IntAll(v["status"]) == 1 && common.IntAll(v["power"]) == 1 {
|
|
|
+ userPower.EntnicheStatus = 1
|
|
|
+ if common.IntAll(v["isNew"]) == 1 {
|
|
|
+ userPower.EntIsNew = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- return
|
|
|
+ return &userPower
|
|
|
}
|
|
|
|
|
|
-//
|
|
|
+// SaveQuestionnaire 保存问卷
|
|
|
func SaveQuestionnaire(userId, phone, answers string) bool {
|
|
|
id := db.Mgo.Save("double_eleven_22_q", map[string]interface{}{
|
|
|
"l_create": time.Now().Unix(),
|
|
@@ -26,7 +61,7 @@ func SaveQuestionnaire(userId, phone, answers string) bool {
|
|
|
return id != ""
|
|
|
}
|
|
|
|
|
|
-//
|
|
|
+// GetWinnerInfo 获取中奖人信息
|
|
|
func GetWinnerInfo() map[string]interface{} {
|
|
|
todayData := db.Mysql.SelectBySql(`SELECT phone,winnerdate,mold FROM winner_info_22_10 WHERE TO_DAYS(winnerdate) = TO_DAYS(NOW())`)
|
|
|
if todayData != nil && len(*todayData) > 0 {
|