|
@@ -79,7 +79,10 @@ func (e *EquityActive) GiftVip() {
|
|
|
return
|
|
|
}
|
|
|
// 判断id是职位id还是mongoid 处理
|
|
|
- mgoId, positionId := getUserID(e.UserId)
|
|
|
+ mgoId, positionId, phone := getUserID(e.UserId)
|
|
|
+ if phone != "" {
|
|
|
+ e.Phone = phone
|
|
|
+ }
|
|
|
//6. 发送短信、站内信
|
|
|
eName := common.ObjToString((*eInfo)[0]["name"])
|
|
|
code := common.ObjToString((*eInfo)[0]["code"])
|
|
@@ -139,15 +142,19 @@ func (e *EquityActive) findVipStock(activeId, mold int) (data *[]map[string]inte
|
|
|
}
|
|
|
|
|
|
// 根据用户mongoid或者职位id 返回mgoId 和 职位id
|
|
|
-func getUserID(userId string) (mgoId string, positionId string) {
|
|
|
+func getUserID(userId string) (mgoId string, positionId string, phone string) {
|
|
|
// 判断是mgoId 还是职位id
|
|
|
if bson.IsObjectIdHex(userId) {
|
|
|
mgoId = userId
|
|
|
// 如果是mgoId 去mgo库查base_user_id
|
|
|
- rs, b := util.MQFW.FindById("user", userId, `{"base_user_id":1}`)
|
|
|
+ rs, b := util.MQFW.FindById("user", userId, `{"base_user_id":1,"s_phone":1,"s_m_phone":1}`)
|
|
|
if !b || rs == nil || len(*rs) == 0 {
|
|
|
return
|
|
|
}
|
|
|
+ phone = common.ObjToString((*rs)["s_phone"])
|
|
|
+ if phone == "" {
|
|
|
+ phone = common.ObjToString((*rs)["s_m_phone"])
|
|
|
+ }
|
|
|
// 根据base_user_id 去查 base_position 获取职位id 条件是user_id
|
|
|
baseUserId := (*rs)["base_user_id"]
|
|
|
q := fmt.Sprintf("select id from %s where user_id=? ", TablebasePosition)
|
|
@@ -168,11 +175,15 @@ func getUserID(userId string) (mgoId string, positionId string) {
|
|
|
//去mgo 库查base_user_id
|
|
|
rs, b := util.MQFW.FindOneByField("user", map[string]interface{}{
|
|
|
"base_user_id": base_user_id,
|
|
|
- }, `{"_id":1}`)
|
|
|
+ }, `{"_id":1,"s_phone":1,"s_m_phone":1}`)
|
|
|
if !b || rs == nil || len(*rs) == 0 {
|
|
|
return
|
|
|
}
|
|
|
mgoId = mongodb.BsonIdToSId((*rs)["_id"])
|
|
|
+ phone = common.ObjToString((*rs)["s_phone"])
|
|
|
+ if phone == "" {
|
|
|
+ phone = common.ObjToString((*rs)["s_m_phone"])
|
|
|
+ }
|
|
|
}
|
|
|
return
|
|
|
}
|
|
@@ -194,19 +205,21 @@ func (e *EquityActive) sendVipMsg(mgoId string, positionId, eName, code, ex_end_
|
|
|
if PhoneReg.MatchString(e.Phone) {
|
|
|
phone = string(phone[0:3]) + "****" + string(phone[(len(phone)-4):])
|
|
|
}
|
|
|
- }
|
|
|
- smsconfig := config.Config.EquityActive.Sms
|
|
|
- args3, args4 := "", ""
|
|
|
- if len(smsconfig.Args) == 2 {
|
|
|
- args3 = fmt.Sprintf(smsconfig.Args[0], eName, code)
|
|
|
+ smsconfig := config.Config.EquityActive.Sms
|
|
|
+ args3, args4 := "", ""
|
|
|
+ if len(smsconfig.Args) == 2 {
|
|
|
+ args3 = fmt.Sprintf(smsconfig.Args[0], eName, code)
|
|
|
+ } else {
|
|
|
+ log.Println("视频会员活动短信模板内容参数配置异常,请检查配置文件。")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ params := []string{phone, e.ProductType, args3, args4}
|
|
|
+ sms.SendSms(config.Config.SmsServiceRpc, smsconfig.Tid, e.Phone, params...)
|
|
|
} else {
|
|
|
- log.Println("视频会员活动短信模板内容参数配置异常,请检查配置文件。")
|
|
|
- return
|
|
|
+ log.Println("未获取到用户手机号,不再发送短信:", e.OrderCode, e.UserId, e.Phone)
|
|
|
}
|
|
|
- params := []string{phone, e.ProductType, args3, args4}
|
|
|
- sms.SendSms(config.Config.SmsServiceRpc, smsconfig.Tid, e.Phone, params...)
|
|
|
if mgoId == "" {
|
|
|
- log.Println("获取用户mgoId失败:", e.OrderCode, e.Phone, e.UserId)
|
|
|
+ log.Println("equityActive 获取用户mgoId失败,不再发送消息:", e.OrderCode, e.Phone, e.UserId)
|
|
|
return
|
|
|
}
|
|
|
siteMsg := config.Config.EquityActive.SiteMsg
|