zwxi 9 ماه پیش
والد
کامیت
c0134f82bb
2فایلهای تغییر یافته به همراه39 افزوده شده و 2 حذف شده
  1. 23 0
      models/wechat_send_msg.go
  2. 16 2
      services/company_approval_message.go

+ 23 - 0
models/wechat_send_msg.go

@@ -54,4 +54,27 @@ func GetUserRecordListByMobileArr(bindAccount []string) (items []*OpenIdList, er
 			1 = 1  ` + condition
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
+}
+
+
+// 根据手机号获取用户的openid
+func GetMfyxUserRecordListByMobileArr(bindAccount []string) (items []*OpenIdList, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	lenarr := len(bindAccount)
+	if lenarr == 0 {
+		return
+	}
+	var condition string
+	var pars []interface{}
+	condition = ` AND u.cygx_bind_account IN (` + utils.GetOrmInReplace(lenarr) + `)`
+	pars = append(pars, bindAccount)
+	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
 }

+ 16 - 2
services/company_approval_message.go

@@ -188,6 +188,10 @@ func AddCompanyApprovalMessageRai(companyId, companyContractId int, applyRealNam
 
 	for _, v := range list {
 		if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN || v.ChartPermissionId == utils.YAN_XUAN_KOU_DIAN_BAO_ID {
+			openIdList, err = models.GetMfyxUserRecordListByMobileArr(mobiles)
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				return err
+			}
 			go SendWxCategoryMsgWithRaiSell(companyName, "销售:"+applyRealName, "已签约研选", time.Now().Format(utils.FormatDateTimeMinute2), openIdList)
 		}
 	}
@@ -218,6 +222,16 @@ func AddCompanyApprovalMessageWangYang(companyId, companyContractId int, applyRe
 		return
 	}
 
+	mfyxopenIdList, e := models.GetMfyxUserRecordListByMobileArr(mobiles)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetMfyxUserRecordListByMobileArr, Err: " + e.Error())
+		return
+	}
+	if len(mfyxopenIdList) == 0 {
+		return
+	}
+
+
 	list, e := company_contract.GetCompanyContractPermissionByCompanyContractId(companyContractId)
 	if e != nil && e.Error() != utils.ErrNoRow() {
 		err = errors.New("GetCompanyContractPermissionByCompanyContractId, Err: " + e.Error())
@@ -244,7 +258,7 @@ func AddCompanyApprovalMessageWangYang(companyId, companyContractId int, applyRe
 		keyword2 = time.Now().Format(utils.FormatDateTime)
 		keyword3 = "签约【研选订阅】"
 		go SendWxMsgWithRaiWangYang(keyword1, keyword2, keyword3, keyword4, openIdList)
-		go SendWxCategoryMsgWithRaiWangYang(companyName, "销售:"+applyRealName, keyword3, time.Now().Format(utils.FormatDateTimeMinute2), openIdList)
+		go SendWxCategoryMsgWithRaiWangYang(companyName, "销售:"+applyRealName, keyword3, time.Now().Format(utils.FormatDateTimeMinute2), mfyxopenIdList)
 	}
 
 	if points > 0 {
@@ -252,7 +266,7 @@ func AddCompanyApprovalMessageWangYang(companyId, companyContractId int, applyRe
 		keyword2 = time.Now().Format(utils.FormatDateTime)
 		keyword3 = "签约【研选扣点包(" + fmt.Sprint(points) + "个点)】"
 		go SendWxMsgWithRaiWangYang(keyword1, keyword2, keyword3, keyword4, openIdList)
-		go SendWxCategoryMsgWithRaiWangYang(companyName, "销售:"+applyRealName, keyword3, time.Now().Format(utils.FormatDateTimeMinute2), openIdList)
+		go SendWxCategoryMsgWithRaiWangYang(companyName, "销售:"+applyRealName, keyword3, time.Now().Format(utils.FormatDateTimeMinute2), mfyxopenIdList)
 	}
 
 	return