Browse Source

访谈申请模板消息

xingzai 3 years ago
parent
commit
7fa6c01ab8
3 changed files with 16 additions and 9 deletions
  1. 4 2
      controllers/article.go
  2. 1 2
      controllers/user.go
  3. 11 5
      models/user_record.go

+ 4 - 2
controllers/article.go

@@ -407,7 +407,8 @@ func (this *ArticleController) InterviewApply() {
 			}
 			sellerItem, _ := models.GetSellerByCompanyId(user.CompanyId)
 			if sellerItem != nil && sellerItem.AdminId > 0 && user.Mobile != "" {
-				openIpItem, _ := models.GetUserRecordByUserIdByXzs(sellerItem.UserId, 1)
+				openIpItem, _ := models.GetUserRecordByUserIdByXzs(sellerItem.Mobile, 1)
+				fmt.Println(openIpItem)
 				if openIpItem != nil && openIpItem.OpenId != "" {
 					go services.SendInterviewApplyTemplateMsg(user.RealName, sellerItem.CompanyName, mobile, article.Title, openIpItem.OpenId)
 				}
@@ -429,7 +430,8 @@ func (this *ArticleController) InterviewApply() {
 			}
 			sellerItem, _ := models.GetSellerByCompanyId(user.CompanyId)
 			if sellerItem != nil && sellerItem.AdminId > 0 && user.Mobile != "" {
-				openIpItem, _ := models.GetUserRecordByUserIdByXzs(sellerItem.UserId, 1)
+				openIpItem, _ := models.GetUserRecordByUserIdByXzs(sellerItem.Mobile, 1)
+				fmt.Println(openIpItem)
 				if openIpItem != nil && openIpItem.OpenId != "" {
 					go services.SendInterviewApplyCancelTemplateMsg(user.RealName, sellerItem.CompanyName, mobile, article.Title, openIpItem.OpenId)
 				}

+ 1 - 2
controllers/user.go

@@ -926,7 +926,7 @@ func (this *UserController) ApplyTryOut() {
 
 	cnf, _ := models.GetConfigByCode("tpl_msg")
 	if cnf != nil {
-		if req.ApplyMethod != 1 && sellerItem != nil {
+		if req.ApplyMethod == 1 && sellerItem != nil {
 			cnf.ConfigValue = sellerItem.Mobile
 		}
 		openIpItem, _ := models.GetUserRecordByMobile(1, cnf.ConfigValue)
@@ -936,7 +936,6 @@ func (this *UserController) ApplyTryOut() {
 			go services.SendPermissionApplyTemplateMsg(req.RealName, req.CompanyName, mobile, openIpItem.OpenId, applyMethod)
 		}
 	}
-
 	err = models.AddApplyRecord(&req, user.Mobile, user.CompanyName, uid, user.CompanyId)
 	if err != nil {
 		br.Msg = "申请失败"

+ 11 - 5
models/user_record.go

@@ -47,11 +47,17 @@ func GetUserRecordByUserId(userId, platform int) (item *UserRecord, err error) {
 }
 
 //根据用户id和平台id获取用户关系
-func GetUserRecordByUserIdByXzs(userId, platform int) (item *UserRecord, err error) {
-	sql := `SELECT cr.open_id FROM user_record  as u
-			INNER JOIN cygx_user_record AS cr ON cr.union_id = c.union_id 
-			WHERE user_id=? AND create_platform = ?`
-	err = orm.NewOrm().Raw(sql, userId, platform).QueryRow(&item)
+func GetUserRecordByUserIdByXzs(mobile string, platform int) (item *UserRecord, err error) {
+	sql := `SELECT
+			cr.open_id 
+		FROM
+			wx_user AS u
+			INNER JOIN user_record AS r ON r.user_id = u.user_id
+			INNER JOIN cygx_user_record AS cr ON cr.union_id = r.union_id 
+		WHERE
+			u.mobile = ? 
+			AND create_platform = ?`
+	err = orm.NewOrm().Raw(sql, mobile, platform).QueryRow(&item)
 	return
 }