|
@@ -18,6 +18,7 @@ import (
|
|
"app.yhyue.com/moapp/message/handler/activity"
|
|
"app.yhyue.com/moapp/message/handler/activity"
|
|
"app.yhyue.com/moapp/message/model"
|
|
"app.yhyue.com/moapp/message/model"
|
|
. "app.yhyue.com/moapp/message/rpc"
|
|
. "app.yhyue.com/moapp/message/rpc"
|
|
|
|
+ mrpc "app.yhyue.com/moapp/message/rpc"
|
|
. "bp.jydev.jianyu360.cn/BaseService/pushpkg/p"
|
|
. "bp.jydev.jianyu360.cn/BaseService/pushpkg/p"
|
|
|
|
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
@@ -27,6 +28,7 @@ type Task struct {
|
|
*xweb.Action
|
|
*xweb.Action
|
|
task xweb.Mapper `xweb:"/task"` //获取任务
|
|
task xweb.Mapper `xweb:"/task"` //获取任务
|
|
confirmChallenge xweb.Mapper `xweb:"/confirmChallenge"` //确认挑战
|
|
confirmChallenge xweb.Mapper `xweb:"/confirmChallenge"` //确认挑战
|
|
|
|
+ tes xweb.Mapper `xweb:"/tes"`
|
|
}
|
|
}
|
|
|
|
|
|
type TaskInfo struct {
|
|
type TaskInfo struct {
|
|
@@ -95,7 +97,8 @@ func (this *Task) Task() {
|
|
dataM[types] = tf
|
|
dataM[types] = tf
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- userMsg, ok := db.Mgo.FindById("user", mgoUserId, `{"l_registedate":1,"s_m_phone":1,"s_phone":1,"s_myemail":1,"s_nickname":1,"s_headimageurl":1,"s_password":1,"s_company":1,"s_unionid":1,"o_jy":1,"o_vipjy":1,"o_member_jy":1,"i_app_login_task":1}`)
|
|
|
|
|
|
+ userMsg, ok := db.Mgo.FindById("user", mgoUserId, `{"s_m_openid":1,"l_registedate":1,"s_m_phone":1,"s_phone":1,"s_myemail":1,"s_nickname":1,"s_headimageurl":1,"s_password":1,"s_company":1,"s_unionid":1,"o_jy":1,"o_vipjy":1,"o_member_jy":1,"i_app_login_task":1}`)
|
|
|
|
+ log.Println("===>", userMsg)
|
|
if userMsg == nil || len(*userMsg) == 0 || !ok {
|
|
if userMsg == nil || len(*userMsg) == 0 || !ok {
|
|
return nil, fmt.Errorf("未查询到用户")
|
|
return nil, fmt.Errorf("未查询到用户")
|
|
}
|
|
}
|
|
@@ -120,6 +123,7 @@ func (this *Task) Task() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
mail := gconv.String((*userMsg)["s_myemail"])
|
|
mail := gconv.String((*userMsg)["s_myemail"])
|
|
|
|
+ openid := gconv.String((*userMsg)["s_m_openid"])
|
|
if !isNew {
|
|
if !isNew {
|
|
//邮箱是否绑定
|
|
//邮箱是否绑定
|
|
if mail != "" {
|
|
if mail != "" {
|
|
@@ -127,17 +131,35 @@ func (this *Task) Task() {
|
|
dataM[model.BindMail].FinishTime = now
|
|
dataM[model.BindMail].FinishTime = now
|
|
activity.Task(&model.Message{
|
|
activity.Task(&model.Message{
|
|
E_code: "task",
|
|
E_code: "task",
|
|
- E_userId: userId,
|
|
|
|
|
|
+ E_userId: mgoUserId,
|
|
E_time: time.Now().Unix(),
|
|
E_time: time.Now().Unix(),
|
|
E_app: "jyweb_node2",
|
|
E_app: "jyweb_node2",
|
|
E_body: map[string]interface{}{
|
|
E_body: map[string]interface{}{
|
|
- "code": 1009, //首次订阅
|
|
|
|
|
|
+ "code": 1016,
|
|
"types": "bindMail",
|
|
"types": "bindMail",
|
|
"baseUserId": baseUserId,
|
|
"baseUserId": baseUserId,
|
|
"positionId": positionId,
|
|
"positionId": positionId,
|
|
},
|
|
},
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ //openid是否绑定
|
|
|
|
+ if openid != "" {
|
|
|
|
+ dataM[model.FollowWx].Status = 1
|
|
|
|
+ dataM[model.FollowWx].FinishTime = now
|
|
|
|
+ activity.Task(&model.Message{
|
|
|
|
+ E_code: "task",
|
|
|
|
+ E_userId: mgoUserId,
|
|
|
|
+ E_time: time.Now().Unix(),
|
|
|
|
+ E_app: "jyweb_node2",
|
|
|
|
+ E_body: map[string]interface{}{
|
|
|
|
+ "code": 1008, //首次订阅
|
|
|
|
+ "types": "followWx",
|
|
|
|
+ "baseUserId": baseUserId,
|
|
|
|
+ "positionId": positionId,
|
|
|
|
+ },
|
|
|
|
+ })
|
|
|
|
+ }
|
|
}
|
|
}
|
|
//判断是否已经创建任务
|
|
//判断是否已经创建任务
|
|
integralTaskData := db.Tidb.SelectBySql(`select * from integral_task where user_id =? limit 1`, baseUserId)
|
|
integralTaskData := db.Tidb.SelectBySql(`select * from integral_task where user_id =? limit 1`, baseUserId)
|
|
@@ -252,8 +274,8 @@ func EntSubscribe(entUserId, entId int64) int {
|
|
|
|
|
|
func (this *Task) ConfirmChallenge() {
|
|
func (this *Task) ConfirmChallenge() {
|
|
sessVal := this.Session().GetMultiple()
|
|
sessVal := this.Session().GetMultiple()
|
|
- positionId := gconv.Int64(sessVal["positionId"])
|
|
|
|
baseUserId := gconv.Int64(sessVal["base_user_id"])
|
|
baseUserId := gconv.Int64(sessVal["base_user_id"])
|
|
|
|
+ userId := gconv.String(sessVal["mgoUserId"])
|
|
rData, errMsg := func() (interface{}, error) {
|
|
rData, errMsg := func() (interface{}, error) {
|
|
infoMap := map[string]interface{}{}
|
|
infoMap := map[string]interface{}{}
|
|
if string(this.Body()) == "" {
|
|
if string(this.Body()) == "" {
|
|
@@ -269,14 +291,12 @@ func (this *Task) ConfirmChallenge() {
|
|
dayLater := time.Now().Add(time.Duration(config.TaskConf.TaskDayTime-1) * time.Hour * 24)
|
|
dayLater := time.Now().Add(time.Duration(config.TaskConf.TaskDayTime-1) * time.Hour * 24)
|
|
endTime := time.Date(dayLater.Year(), dayLater.Month(), dayLater.Day(), 23, 59, 59, 0, time.Local)
|
|
endTime := time.Date(dayLater.Year(), dayLater.Month(), dayLater.Day(), 23, 59, 59, 0, time.Local)
|
|
if db.Tidb.Update("integral_task", map[string]interface{}{
|
|
if db.Tidb.Update("integral_task", map[string]interface{}{
|
|
- "position_id": positionId,
|
|
|
|
- "user_id": baseUserId,
|
|
|
|
|
|
+ "user_id": baseUserId,
|
|
}, map[string]interface{}{
|
|
}, map[string]interface{}{
|
|
"end_time": endTime.Format(date.Date_Full_Layout),
|
|
"end_time": endTime.Format(date.Date_Full_Layout),
|
|
}) {
|
|
}) {
|
|
go func() {
|
|
go func() {
|
|
//用户点击“确认挑战”给用户发消息
|
|
//用户点击“确认挑战”给用户发消息
|
|
- userId := gconv.String(sessVal["mgoUserId"])
|
|
|
|
wxUrl := "/front/sess/" + Se.EncodeString(userId+",_id,identityKeep,") + "__" + Se.EncodeString(config.PushConfig.Messages.ConfirmChallenge.MobileUrl)
|
|
wxUrl := "/front/sess/" + Se.EncodeString(userId+",_id,identityKeep,") + "__" + Se.EncodeString(config.PushConfig.Messages.ConfirmChallenge.MobileUrl)
|
|
appUrl := "/jyapp/free/sess/" + Se.EncodeString(userId+",id,"+strconv.Itoa(int(time.Now().Unix()))+",") + "__" + Se.EncodeString(config.PushConfig.Messages.ConfirmChallenge.MobileUrl)
|
|
appUrl := "/jyapp/free/sess/" + Se.EncodeString(userId+",id,"+strconv.Itoa(int(time.Now().Unix()))+",") + "__" + Se.EncodeString(config.PushConfig.Messages.ConfirmChallenge.MobileUrl)
|
|
req := &message.MultipleSaveMsgReq{
|
|
req := &message.MultipleSaveMsgReq{
|
|
@@ -292,8 +312,48 @@ func (this *Task) ConfirmChallenge() {
|
|
}
|
|
}
|
|
SendMsg("确认挑战", req)
|
|
SendMsg("确认挑战", req)
|
|
}()
|
|
}()
|
|
- return map[string]interface{}{"status": 1}, nil
|
|
|
|
}
|
|
}
|
|
|
|
+ //判断用户是否已经完成所有任务
|
|
|
|
+ userMsg, ok := db.Mgo.FindById("user", userId, `{"l_registedate":1}`)
|
|
|
|
+ if userMsg == nil || len(*userMsg) == 0 || !ok {
|
|
|
|
+ return map[string]interface{}{"status": -1}, fmt.Errorf("未查询到用户")
|
|
|
|
+ }
|
|
|
|
+ //注册时间 判断是新手任务还是老用户限时任务
|
|
|
|
+ l_registedate := gconv.Int64((*userMsg)["l_registedate"])
|
|
|
|
+ isNew := l_registedate > config.TaskConf.TaskStartTime //是否注册时间处于新手任务开始时间
|
|
|
|
+ ts := this.InitTask(isNew)
|
|
|
|
+ taskDetailCount := db.Tidb.CountBySql(`select count(1) from integral_task_detail where user_id =? and status=1`, baseUserId)
|
|
|
|
+ taskMsg := db.Tidb.SelectBySql(`select id from integral_task where user_id =? LIMIT 1`, baseUserId)
|
|
|
|
+ if taskMsg == nil || len(*taskMsg) == 0 {
|
|
|
|
+ return map[string]interface{}{"status": -1}, fmt.Errorf("任务创建失败")
|
|
|
|
+ }
|
|
|
|
+ taskId := gconv.Int64((*taskMsg)[0]["id"])
|
|
|
|
+ if gconv.Int(taskDetailCount) == len(ts) {
|
|
|
|
+ //任务完成 赠送超级订阅
|
|
|
|
+ //判断是否完成所有任务且开启确认挑战
|
|
|
|
+ if mrpc.SubVipHarvest(userId, 7, "") == nil {
|
|
|
|
+ if db.Tidb.Update("integral_task", map[string]interface{}{"id": taskId}, map[string]interface{}{
|
|
|
|
+ "success_status": 1,
|
|
|
|
+ }) {
|
|
|
|
+ go func() {
|
|
|
|
+ wxUrl := "/front/sess/" + Se.EncodeString(userId+",_id,"+strconv.Itoa(int(time.Now().Unix()))+",") + "__" + Se.EncodeString(config.PushConfig.Messages.GetVip.MobileUrl)
|
|
|
|
+ appUrl := "/jyapp/free/sess/" + Se.EncodeString(userId+",_id,"+strconv.Itoa(int(time.Now().Unix()))+",") + "__" + Se.EncodeString(config.PushConfig.Messages.GetVip.MobileUrl)
|
|
|
|
+ SendMsg("获赠七天超级订阅服务", &message.MultipleSaveMsgReq{
|
|
|
|
+ UserIds: userId,
|
|
|
|
+ Title: config.PushConfig.Messages.GetVip.Title,
|
|
|
|
+ Content: config.PushConfig.Messages.GetVip.Content,
|
|
|
|
+ MsgType: config.PushConfig.Messages.GetVip.MsgType,
|
|
|
|
+ Link: config.PushConfig.Messages.GetVip.PcUrl + "," + config.PushConfig.Messages.GetVip.MobileUrl + "," + config.PushConfig.Messages.GetVip.MobileUrl,
|
|
|
|
+ Appid: config.PushConfig.Messages.GetVip.Appid,
|
|
|
|
+ AppPushUrl: appUrl,
|
|
|
|
+ WxPushUrl: config.PushConfig.Webdomain + wxUrl,
|
|
|
|
+ IosPushUrl: appUrl,
|
|
|
|
+ })
|
|
|
|
+ }()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return map[string]interface{}{"status": 1}, nil
|
|
}
|
|
}
|
|
return map[string]interface{}{"status": 1}, nil
|
|
return map[string]interface{}{"status": 1}, nil
|
|
}()
|
|
}()
|
|
@@ -302,3 +362,22 @@ func (this *Task) ConfirmChallenge() {
|
|
}
|
|
}
|
|
this.ServeJson(NewResult(rData, errMsg))
|
|
this.ServeJson(NewResult(rData, errMsg))
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+func (this *Task) Tes() {
|
|
|
|
+
|
|
|
|
+ d := mrpc.SubVipHarvest("65433cecbd1d69bdca017505", 7, "")
|
|
|
|
+ fmt.Println(d)
|
|
|
|
+ return
|
|
|
|
+ activity.Task(&model.Message{
|
|
|
|
+ E_code: "task",
|
|
|
|
+ E_userId: "65433cecbd1d69bdca017505", //5ed6cii...
|
|
|
|
+ E_time: 1698800604, //1605223065
|
|
|
|
+ E_app: "jyapp_node1", //jywx_node1/jyweb_node2/jyapp_node1/jysubscribe
|
|
|
|
+ E_body: map[string]interface{}{
|
|
|
|
+ "baseUserId": 3755163,
|
|
|
|
+ "code": 1008,
|
|
|
|
+ "num": 50,
|
|
|
|
+ "positionId": 1205322910,
|
|
|
|
+ "types": "followWx",
|
|
|
|
+ }})
|
|
|
|
+}
|