浏览代码

Merge branch 'dev4.6.3' of http://192.168.3.207:8080/qmx/jy into dev4.6.3

tsz 3 年之前
父节点
当前提交
fe7088923f
共有 1 个文件被更改,包括 24 次插入0 次删除
  1. 24 0
      src/jfw/modules/publicapply/src/active/21yearEndReport.go

+ 24 - 0
src/jfw/modules/publicapply/src/active/21yearEndReport.go

@@ -68,6 +68,11 @@ func (this *YearEndReport) YearEndReportApi() {
 		if userId == "" {
 			return nil, fmt.Errorf("未登录")
 		}
+		openid := qutil.ObjToString(this.Session().Get("s_m_openid"))
+		if checkUserIsSubscribe(openid) {
+			return nil, fmt.Errorf("未关注")
+		}
+
 		if time.Now().Unix() > yearEndReportEndTimeStamp {
 			return nil, fmt.Errorf("不在活动期限内")
 		}
@@ -138,3 +143,22 @@ func getRandom(userId string, t int64) int32 {
 	}
 	return int32(i)%9 + 1
 }
+
+//checkUserIsSubscribe 检查用户是否关注
+func checkUserIsSubscribe(openid string) bool {
+	if openid == "" {
+		user, ok := db.Mgo.FindOneByField("user", map[string]interface{}{
+			"i_appid":    2,
+			"s_m_openid": openid,
+			"s_unionid":  map[string]interface{}{"$ne": openid},
+		}, `{"i_ispush":1}`)
+		if ok && user != nil {
+			if (*user)["_id"] == nil || qutil.IntAllDef((*user)["i_ispush"], 1) == 0 {
+				return false
+			} else {
+				return true
+			}
+		}
+	}
+	return false
+}