|
@@ -18,6 +18,7 @@ import (
|
|
|
"app.yhyue.com/moapp/message/handler/activity"
|
|
|
"app.yhyue.com/moapp/message/model"
|
|
|
. "app.yhyue.com/moapp/message/rpc"
|
|
|
+ mrpc "app.yhyue.com/moapp/message/rpc"
|
|
|
. "bp.jydev.jianyu360.cn/BaseService/pushpkg/p"
|
|
|
|
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
@@ -253,6 +254,7 @@ func EntSubscribe(entUserId, entId int64) int {
|
|
|
func (this *Task) ConfirmChallenge() {
|
|
|
sessVal := this.Session().GetMultiple()
|
|
|
baseUserId := gconv.Int64(sessVal["base_user_id"])
|
|
|
+ userId := gconv.String(sessVal["mgoUserId"])
|
|
|
rData, errMsg := func() (interface{}, error) {
|
|
|
infoMap := map[string]interface{}{}
|
|
|
if string(this.Body()) == "" {
|
|
@@ -274,7 +276,6 @@ func (this *Task) ConfirmChallenge() {
|
|
|
}) {
|
|
|
go func() {
|
|
|
//用户点击“确认挑战”给用户发消息
|
|
|
- userId := gconv.String(sessVal["mgoUserId"])
|
|
|
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)
|
|
|
req := &message.MultipleSaveMsgReq{
|
|
@@ -290,8 +291,48 @@ func (this *Task) ConfirmChallenge() {
|
|
|
}
|
|
|
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 stauts=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
|
|
|
}()
|