zwxi 11 месяцев назад
Родитель
Сommit
c38c138924
2 измененных файлов с 51 добавлено и 3 удалено
  1. 49 1
      models/user_record.go
  2. 2 2
      services/wechat_send_category_template_msg.go

+ 49 - 1
models/user_record.go

@@ -161,4 +161,52 @@ func GetUserRecordListByMobile(platform int, bindAccount string) (items []*OpenI
 		WHERE 1= 1	AND cygx_bind_account IN (` + bindAccount + `)`
 	_, err = orm.NewOrm().Raw(sql).QueryRows(&items)
 	return
-}
+}
+
+
+// 根据手机号获取用户的openid
+func GetMfyxUserRecordListByMobile(platform int, bindAccount string) (items []*OpenIdList, err error) {
+	var sql string
+	//if utils.RunMode == "release" {
+	//	sql = `SELECT cr.open_id,user_id FROM user_record  as u
+	//		INNER JOIN cygx_user_record AS cr ON cr.union_id = u.union_id
+	//		WHERE create_platform=? AND bind_account IN (` + bindAccount + `)`
+	//} else {
+	//	platform = 1
+	//	sql = `SELECT open_id,user_id FROM	user_record  WHERE create_platform =? AND bind_account IN (` + bindAccount + `)`
+	//}
+	sql = `SELECT
+			cr.open_id,
+			cr.cygx_user_id as  user_id 
+		FROM
+		  cygx_mfyx_gzh_user_record  as cr 
+		WHERE 1= 1	AND cygx_bind_account IN (` + bindAccount + `)`
+	_, err = orm.NewOrm().Raw(sql).QueryRows(&items)
+	return
+}
+
+func GetMfyxWxOpenIdByMobileList(mobile string) (items []*OpenIdList, err error) {
+	sliceMobile := strings.Split(mobile, ",")
+	var mobiles []string
+	for _, v := range sliceMobile {
+		mobiles = append(mobiles, v)
+	}
+	o := orm.NewOrm()
+	lenarr := len(mobiles)
+	if lenarr == 0 {
+		return
+	}
+	var condition string
+	var pars []interface{}
+	condition = ` AND u.cygx_bind_account IN (` + utils.GetOrmInReplace(lenarr) + `)`
+	pars = append(pars, mobiles)
+	sql := `SELECT
+			u.open_id,
+			u.cygx_user_id AS user_id 
+		FROM
+			cygx_mfyx_gzh_user_record AS u 
+		WHERE
+			1 = 1  ` + condition
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 2 - 2
services/wechat_send_category_template_msg.go

@@ -87,7 +87,7 @@ func SendWxCategoryMsgSpecialAuthor(specialId, status int) (err error) {
 		return err
 	}
 
-	openIdList, err := models.GetUserRecordListByMobile(4, user.Mobile)
+	openIdList, err := models.GetMfyxUserRecordListByMobile(12, user.Mobile)
 	if err != nil && err.Error() != utils.ErrNoRow() {
 		return err
 	}
@@ -212,7 +212,7 @@ func SendReviewCategoryTemplateMsgAdmin(specialId int) (err error) {
 		}
 	}()
 	//王芳、葛琳和沈涛
-	openIdList, e := models.GetUserRecordListByMobile(4, utils.WxMsgTemplateIdYXSpecialReview)
+	openIdList, e := models.GetMfyxUserRecordListByMobile(12, utils.WxMsgTemplateIdYXSpecialReview)
 	if e != nil && e.Error() != utils.ErrNoRow() {
 		err = errors.New("GetUserRecordListByMobile, Err: " + e.Error())
 		return err