zwxi 10 ماه پیش
والد
کامیت
be0b8a22f2
6فایلهای تغییر یافته به همراه86 افزوده شده و 16 حذف شده
  1. 1 1
      controllers/activity.go
  2. 2 2
      controllers/user.go
  3. 70 0
      models/user_record.go
  4. 2 2
      services/activity.go
  5. 2 2
      services/user.go
  6. 9 9
      services/wechat_send_category_template_msg.go

+ 1 - 1
controllers/activity.go

@@ -1929,7 +1929,7 @@ func (this *ActivityController) AskAdd() {
 			}
 			// 给所属销售发送消息
 			if sellerItem != nil {
-				openIdList, e := models.GetUserRecordListByMobile(4, sellerItem.Mobile+","+utils.WxMsgTemplateIdAskMsgMobilePublic)
+				openIdList, e := models.GetMfyxUserRecordListByMobile(12, sellerItem.Mobile+","+utils.WxMsgTemplateIdAskMsgMobilePublic)
 				if e != nil {
 					err = errors.New("GetUserRecordListByMobile, Err: " + e.Error())
 					return

+ 2 - 2
controllers/user.go

@@ -697,9 +697,9 @@ func (this *UserController) ApplyTryOut() {
 	if sellerItem == nil {
 		go services.SendPermissionApplyTemplateMsgAdmin(req, mobile, applyMethod, categoryApplyMethod, redirectUrl, isResearch)
 	} else {
-		openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
+		openIpItem, _ := models.GetMfyxUserRecordByMobile(12, sellerItem.Mobile)
 		if openIpItem != nil && openIpItem.OpenId != "" {
-			go services.SendPermissionApplyTemplateMsg(req.RealName, req.CompanyName, mobile, applyMethod, openIpItem)
+			//go services.SendPermissionApplyTemplateMsg(req.RealName, req.CompanyName, mobile, applyMethod, openIpItem)
 			go services.SendPermissionApplyCategoryTemplateMsg(req.RealName, req.CompanyName, mobile, categoryApplyMethod, openIpItem, redirectUrl)
 		}
 	}

+ 70 - 0
models/user_record.go

@@ -162,3 +162,73 @@ func GetUserRecordListByMobile(platform int, bindAccount string) (items []*OpenI
 	_, err = orm.NewOrm().Raw(sql).QueryRows(&items)
 	return
 }
+
+
+// 根据手机号获取用户的openid
+func GetMfyxUserRecordListByMobile(platform int, bindAccount string) (items []*OpenIdList, err error) {
+	var sql string
+	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
+}
+
+// 根据用户id和平台id获取用户关系
+func GetMfyxUserRecordByMobile(platform int, bindAccount string) (item *OpenIdList, err error) {
+	var sql string
+	sql = `SELECT open_id,cygx_user_id AS user_id  FROM	cygx_mfyx_gzh_user_record  WHERE	1 = 1  AND cygx_bind_account = ?`
+	err = orm.NewOrm().Raw(sql, bindAccount).QueryRow(&item)
+	return
+}
+
+func GetMfyxWxOpenIdByMobileSliceList(mobiles []string) (items []*OpenIdList, err error) {
+	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/activity.go

@@ -1784,7 +1784,7 @@ func ActivityUserRemind(user *models.WxUserItem, activityDetail *models.Activity
 		sourceMsg = "活动报名"
 	}
 
-	openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+	openIdList, e := models.GetMfyxWxOpenIdByMobileList(sellerItemQy.Mobile)
 	if e != nil {
 		err = errors.New("GetUserRecordListByMobile, Err: " + e.Error())
 		return err
@@ -1793,7 +1793,7 @@ func ActivityUserRemind(user *models.WxUserItem, activityDetail *models.Activity
 	var keyword2 string
 	keyword1 = activityDetail.ActivityName
 	keyword2 = fmt.Sprint("互动:", sourceMsg, ",", user.RealName, "--", user.CompanyName)
-	SendWxMsgWithActivityUserRemind(keyword1, keyword2, openIdList, activityDetail.ActivityId)
+	//SendWxMsgWithActivityUserRemind(keyword1, keyword2, openIdList, activityDetail.ActivityId)
 
 	// 类目模版
 	keyword1 = utils.TruncateActivityNameString(user.RealName + "-" + user.CompanyName)

+ 2 - 2
services/user.go

@@ -704,13 +704,13 @@ func SendPermissionApplyTemplateMsgAdmin(req models.ApplyTryReq, usermobile, app
 		err = errors.New("GetConfigByCode, Err: " + e.Error() + configCode)
 		return
 	}
-	openIdList, e := models.GetWxOpenIdByMobileList(cnf.ConfigValue)
+	openIdList, e := models.GetMfyxWxOpenIdByMobileList(cnf.ConfigValue)
 	if e != nil && e.Error() != utils.ErrNoRow() {
 		err = errors.New("GetUserRecordListByMobile, Err: " + e.Error() + cnf.ConfigValue)
 		return err
 	}
 	for _, v := range openIdList {
-		go SendPermissionApplyTemplateMsg(req.RealName, req.CompanyName, usermobile, applyMethod, v)
+		//go SendPermissionApplyTemplateMsg(req.RealName, req.CompanyName, usermobile, applyMethod, v)
 		go SendPermissionApplyCategoryTemplateMsg(req.RealName, req.CompanyName, usermobile, categoryApplyMethod, v, redirectUrl)
 	}
 	return

+ 9 - 9
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
 	}
@@ -168,7 +168,7 @@ func SendWxCategoryMsgSpecialFollow(specialId int) (err error) {
 
 	mobile = strings.TrimRight(mobile, ",")
 
-	openIdList, e := models.GetWxOpenIdByMobileList(mobile)
+	openIdList, e := models.GetMfyxWxOpenIdByMobileList(mobile)
 	if e != nil {
 		err = errors.New("GetSellerByAdminId, Err: " + e.Error())
 		return
@@ -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
@@ -381,7 +381,7 @@ func SendNeiRongZuActivitieSignCategoryTemplateMsg(user *models.WxUserItem, acti
 		err = errors.New("GetConfigByCode, Err: " + e.Error() + configCode)
 		return
 	}
-	openIdList, e := models.GetUserRecordListByMobile(4, cnf.ConfigValue+","+sellerItemQy.Mobile+","+utils.MobileShenTao)
+	openIdList, e := models.GetMfyxUserRecordListByMobile(12, cnf.ConfigValue+","+sellerItemQy.Mobile+","+utils.MobileShenTao)
 	if e != nil && e.Error() != utils.ErrNoRow() {
 		err = errors.New("GetUserRecordListByMobile, Err: " + e.Error() + cnf.ConfigValue)
 		return
@@ -435,7 +435,7 @@ func SendActivitieCancelSignCategoryTemplateMsg(user *models.WxUserItem, activit
 		err = errors.New("GetConfigByCode, Err: " + e.Error() + configCode)
 		return
 	}
-	openIdList, e := models.GetUserRecordListByMobile(4, cnf.ConfigValue+","+sellerItemQy.Mobile+","+utils.MobileShenTao)
+	openIdList, e := models.GetMfyxUserRecordListByMobile(12, cnf.ConfigValue+","+sellerItemQy.Mobile+","+utils.MobileShenTao)
 	if e != nil && e.Error() != utils.ErrNoRow() {
 		err = errors.New("GetUserRecordListByMobile, Err: " + e.Error() + cnf.ConfigValue)
 		return
@@ -505,7 +505,7 @@ func SendCommentWxCategoryTemplateMsg(req models.AddCygxArticleCommentReq, user
 	} else {
 		mobile = companyItem.Mobile + "," + utils.WxMsgTemplateIdAskMsgMobilePublic
 	}
-	openIdList, e := models.GetWxOpenIdByMobileList(mobile)
+	openIdList, e := models.GetMfyxWxOpenIdByMobileList(mobile)
 	if e != nil {
 		err = errors.New("GetWxOpenIdByMobileList, Err: " + e.Error())
 		return
@@ -605,7 +605,7 @@ func SendActivitieSignCategoryTemplateMsg(user *models.WxUserItem, activityDetai
 	keyword4 = utils.TruncateActivityNameString(activityDetail.ActivityName)
 	keyword5 = time.Now().Format(utils.FormatDateTimeMinute2)
 
-	openIdList, e := models.GetWxOpenIdByMobileSliceList(mobiles)
+	openIdList, e := models.GetMfyxWxOpenIdByMobileSliceList(mobiles)
 	if e != nil {
 		err = errors.New("GetWxOpenIdByMobileList, Err: " + e.Error())
 		return
@@ -664,7 +664,7 @@ func SendWxCategoryMsgInteractive(user *models.WxUserItem, interactive string, a
 		return err
 	}
 	if sellerItemQy != nil {
-		openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+		openIdList, e := models.GetMfyxWxOpenIdByMobileList(sellerItemQy.Mobile)
 		if e != nil {
 			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
 			return
@@ -729,7 +729,7 @@ func SearchKeywordUserRmindCategoryMsg(user *models.WxUserItem, keyWord string)
 		return
 	}
 	if sellerItemQy != nil {
-		openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+		openIdList, e := models.GetMfyxWxOpenIdByMobileList(sellerItemQy.Mobile)
 		if e != nil {
 			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
 			return