Pārlūkot izejas kodu

feat:更换短信平台

wangchuanjin 3 gadi atpakaļ
vecāks
revīzija
0f4b8c4d54

+ 2 - 1
src/config.json

@@ -316,5 +316,6 @@
     "criticality":2,
     "indexcontentTimeOut":86400,
     "seoBeforeTimeHour":12160,
-    "canReadNotice": 3
+    "canReadNotice": 3,
+    "smsServiceRpc":"127.0.0.1:932"
 }

+ 1 - 3
src/jfw/front/applysub.go

@@ -119,10 +119,8 @@ func (a *Applysub) SendMsg() error {
 				session.Set("MsgCode", MsgCode)
 				session.Set("phoneNum", phoneNum)
 				session.Set("lastSendMsgTime", time.Now().Unix())
-				param := make(map[string]string)
-				param["code"] = MsgCode
 				go func() {
-					jy.SendSMS("2828060", phoneNum, param)
+					jy.SendSMS(util.ObjToString(config.Sysconfig["smsServiceRpc"]), phoneNum, MsgCode)
 				}()
 				log.Println("手机号码", phoneNum, "验证码", MsgCode)
 			} else {

+ 2 - 2
src/jfw/front/login.go

@@ -87,7 +87,7 @@ func (l *Login) Login() error {
 				return -1
 			} else if tmp := l.GetSession("CheckCodeId"); tmp == nil || !captcha.VerifyString(tmp.(string), l.GetString("code")) {
 				return -2
-			} else if jy.SendPhoneIdentCode(phone, l.Session()) {
+			} else if jy.SendPhoneIdentCode(qutil.ObjToString(config.Sysconfig["smsServiceRpc"]), phone, l.Session()) {
 				return 1
 			}
 			return 0
@@ -210,7 +210,7 @@ func (l *Login) ForgetPwd() error {
 			//手机号是否已被注册
 			if !phoneIsExists(phone) {
 				return "phoneNotExists"
-			} else if jy.SendPhoneIdentCode(phone, l.Session()) {
+			} else if jy.SendPhoneIdentCode(qutil.ObjToString(config.Sysconfig["smsServiceRpc"]), phone, l.Session()) {
 				return "y"
 			}
 		} else if reqType == "nextStep" {

+ 2 - 4
src/jfw/front/otherAct.go

@@ -2,6 +2,7 @@ package front
 
 import (
 	"fmt"
+	"jfw/config"
 	"qfw/util"
 	"qfw/util/jy"
 	"regexp"
@@ -63,11 +64,8 @@ func (f *Front) SendMessage() {
 				session.Set("MsgCode", MsgCode)
 				session.Set("phoneNum", phoneNum)
 				session.Set("lastSendMsgTime", time.Now().Unix())
-				param := make(map[string]string)
-				param["code"] = MsgCode
-
 				go func() {
-					jy.SendSMS("2828060", phoneNum, param)
+					jy.SendSMS(util.ObjToString(config.Sysconfig["smsServiceRpc"]), phoneNum, MsgCode)
 				}()
 				fmt.Println("手机号码", phoneNum, "验证码", MsgCode)
 			} else {

+ 1 - 1
src/jfw/front/pchelper.go

@@ -173,7 +173,7 @@ func (l *PcHelper) Login() error {
 				return -2
 			} else if !phoneReg.MatchString(phone) {
 				return -1
-			} else if jy.SendPhoneIdentCode(phone, l.Session()) {
+			} else if jy.SendPhoneIdentCode(util.ObjToString(config.Sysconfig["smsServiceRpc"]), phone, l.Session()) {
 				return 1
 			}
 			return 0

+ 3 - 3
src/jfw/modules/app/src/app/front/login.go

@@ -145,7 +145,7 @@ func (l *Login) Login() error {
 				return -2
 			} else if !phoneReg.MatchString(phone) {
 				return -1
-			} else if jy.SendPhoneIdentCode(phone, l.Session()) {
+			} else if jy.SendPhoneIdentCode(qutil.ObjToString(config.Sysconfig["smsServiceRpc"]), phone, l.Session()) {
 				return 1
 			}
 			return 0
@@ -380,7 +380,7 @@ func (l *Login) Register() error {
 			//手机号是否已被注册
 			if userIsExists(phone) {
 				return "phoneExists"
-			} else if jy.SendPhoneIdentCode(phone, l.Session()) {
+			} else if jy.SendPhoneIdentCode(qutil.ObjToString(config.Sysconfig["smsServiceRpc"]), phone, l.Session()) {
 				return "y"
 			}
 		} else if reqType == "nextStep" {
@@ -667,7 +667,7 @@ func (l *Login) ForgetPwd() error {
 					{"s_m_phone": phone}},
 			}) == 0 {
 				return "phoneNotExists"
-			} else if jy.SendPhoneIdentCode(phone, l.Session()) {
+			} else if jy.SendPhoneIdentCode(qutil.ObjToString(config.Sysconfig["smsServiceRpc"]), phone, l.Session()) {
 				return "y"
 			}
 		} else if reqType == "nextStep" {

+ 2 - 1
src/jfw/modules/app/src/config.json

@@ -161,5 +161,6 @@
     "optimalTime":"2021-08-03 12:00:00",
     "criticality":2,
     "canReadNotice": 3,
-    "namePrefix":"JY_%s"
+    "namePrefix":"JY_%s",
+    "smsServiceRpc":"127.0.0.1:932"
 }

+ 5 - 13
src/jfw/modules/common/src/qfw/util/jy/jy.go

@@ -186,20 +186,14 @@ func SendMailIdentCode(to, code string, auth []*mail.GmailAuth) bool {
 	return false
 }
 
-//根据模板发送短信,模板是运营商设定的。
-//第三个参数是可变参数,可以传入多个,但要和模板相匹配
-func SendSMS(tplcode /*模板代码*/, mobile /*手机号码*/ string, param map[string]string) {
-	tmp := []string{}
-	for k, v := range param {
-		tmp = append(tmp, "#"+k+"#="+v)
-	}
-	text := strings.Join(tmp, "&")
-	sms.SendSms(mobile, tplcode, text)
+//
+func SendSMS(address, mobile string, params ...string) {
+	sms.SendSms(address, "01", mobile, params...)
 }
 
 //发送验证码
 //增加sessionKey字段 更换手机号防止绕过身份校验
-func SendPhoneIdentCode(phone string, session *httpsession.Session, sessionKey ...string) bool {
+func SendPhoneIdentCode(address, phone string, session *httpsession.Session, sessionKey ...string) bool {
 	sessionKeyFlag := defaultPhoneFlag
 	if len(sessionKey) > 0 && sessionKey[0] != "" {
 		sessionKeyFlag = sessionKey[0]
@@ -216,10 +210,8 @@ func SendPhoneIdentCode(phone string, session *httpsession.Session, sessionKey .
 	session.Set(fmt.Sprintf("%sKey", sessionKeyFlag), phone)
 	session.Set(fmt.Sprintf("%sTime", sessionKeyFlag), time.Now().Unix())
 	//发送短信
-	param := make(map[string]string)
-	param["code"] = s_ranNum
 	log.Println("短信验证码", phone, s_ranNum)
-	SendSMS("2828060", phone, param)
+	SendSMS(address, phone, s_ranNum)
 	return true
 }
 

+ 2 - 1
src/jfw/modules/distribution/src/config.json

@@ -98,5 +98,6 @@
 	"accountMergeOnline":"2055-03-30 00:00:00",
 	"regurl":[
 		"^distribution/share/shareLink$"
-	]
+	],
+    "smsServiceRpc":"127.0.0.1:932"
 }

+ 12 - 15
src/jfw/modules/distribution/src/service/action/partner.go

@@ -1,16 +1,14 @@
 package action
 
 import (
-	"log"
-	"timetask"
-
-	"qfw/util/jy"
-
 	. "api"
 	"database/sql"
+	"log"
 	qu "qfw/util"
+	"qfw/util/jy"
 	. "service/config"
 	"time"
+	"timetask"
 
 	"github.com/go-xweb/xweb"
 )
@@ -39,8 +37,7 @@ func (p *Partner) SendMessage() {
 	status, msg := func() (int, string) {
 		token := p.GetString("token")
 		phone := jy.CheckSendMsg(token)
-		log.Println("====", phone)
-		if jy.IsPhone(phone) && jy.SendPhoneIdentCode(phone, p.Session()) {
+		if jy.IsPhone(phone) && jy.SendPhoneIdentCode(Sysconfig.SmsServiceRpc, phone, p.Session()) {
 			return 1, ""
 		}
 		return -1, "发送失败"
@@ -76,13 +73,13 @@ func (p *Partner) AddPartner() {
 		} else if Mysql.Count("dis_partner", map[string]interface{}{"email": mail}) > 0 {
 			return -1, "该邮箱已加入合作伙伴"
 		}
-		log.Println("code:",p.GetString("code"))
+		log.Println("code:", p.GetString("code"))
 		send_phone := jy.CheckPhoneIdent(p.Session(), p.GetString("code")) //验证码不正确
-		log.Println("send_phone:",send_phone)
+		log.Println("send_phone:", send_phone)
 		if send_phone == "" {
 			user_phone := ""
 			u, ok := MQFW.FindById("user", userid, `{"s_phone":1,"s_m_phone":1,"s_myemail":1}`)
-			log.Println("user:",u,ok)
+			log.Println("user:", u, ok)
 			if ok && u != nil && *u != nil {
 				if s_phone, _ := (*u)["s_phone"].(string); s_phone != "" {
 					user_phone = s_phone
@@ -90,15 +87,15 @@ func (p *Partner) AddPartner() {
 					user_phone = s_m_phone
 				}
 			}
-			log.Println("phone:",phone)
-			log.Println("user_phone:",user_phone)
+			log.Println("phone:", phone)
+			log.Println("user_phone:", user_phone)
 			if phone != user_phone {
 				return -1, "验证码错误"
 
 			}
 		}
 		//typ, _ := p.GetInt("type") // 1个人伙伴 2企业伙伴
-		typ:=int64(2)
+		typ := int64(2)
 		if typ != 1 && typ != 2 {
 			return -1, "type参数格式错误"
 		}
@@ -418,7 +415,7 @@ func (p *Partner) ReapplyPartner() {
 				if (*phoneData)["uid"] != userid {
 					return -1, "该手机号已加入合作伙伴"
 				}
-			}else{
+			} else {
 				send_phone := jy.CheckPhoneIdent(p.Session(), p.GetString("code")) //验证码不正确
 				if send_phone == "" {
 					user_phone := ""
@@ -435,7 +432,7 @@ func (p *Partner) ReapplyPartner() {
 					}
 				}
 			}
-		}else{
+		} else {
 			send_phone := jy.CheckPhoneIdent(p.Session(), p.GetString("code")) //验证码不正确
 			if send_phone == "" {
 				user_phone := ""

+ 1 - 0
src/jfw/modules/distribution/src/service/config/config.go

@@ -41,6 +41,7 @@ type config struct {
 	PhoneFilterFlag    bool
 	AccountMergeOnline string
 	Regurl             []string
+	SmsServiceRpc      string
 }
 
 type BalanceRes struct {

+ 2 - 1
src/jfw/modules/subscribepay/src/config.json

@@ -95,5 +95,6 @@
 		"数据流量包":true,
 		"省份订阅包":true,
 		"附件下载包":true
-   }
+   },
+   "smsServiceRpc":"127.0.0.1:932"
 }

+ 1 - 0
src/jfw/modules/subscribepay/src/config/config.go

@@ -61,6 +61,7 @@ type config struct {
 	ActivityName       string
 	ShareRedisName     string
 	Product            map[string]bool
+	SmsServiceRpc      string
 }
 type mgoConf struct {
 	Address           string

+ 0 - 18
src/jfw/modules/subscribepay/src/entity/dataexport.go

@@ -11,7 +11,6 @@ import (
 	"os"
 	qutil "qfw/util"
 	"qfw/util/dataexport"
-	"qfw/util/jy"
 	"qfw/util/mail"
 	"regexp"
 	"strconv"
@@ -100,7 +99,6 @@ func (d *dataExportStruct) PayCallBack(param *CallBackParam) bool {
 			}, updateMap)
 			if update {
 				//先发个通知
-				go SendNotice(orderdata, download_url)
 				go SendMailToBJFinance(orderdata, pay_time, param.TransactionId, 1, config.GmailAuth)
 
 				//发送邮件移至定时任务
@@ -137,22 +135,6 @@ func (d *dataExportStruct) PayCallBack(param *CallBackParam) bool {
 	return update
 }
 
-//发送通知
-func SendNotice(order *map[string]interface{}, download_url string) {
-	order_code := qutil.ObjToString((*order)["order_code"])
-	user_mail := qutil.ObjToString((*order)["user_mail"])
-	url := fmt.Sprintf("%s%s", config.Config.WebDomain, download_url)
-	for _, audit := range config.ExConf.AuditPersons {
-		if regexp.MustCompile("^\\d+$").MatchString(audit) {
-			jy.SendSMS("2828100", audit, map[string]string{
-				"name":     order_code,
-				"username": user_mail,
-				"tel":      url,
-			})
-		}
-	}
-}
-
 var finaceLock *sync.Mutex = &sync.Mutex{}
 
 //给北京财务人员发邮件

+ 1 - 1
src/jfw/modules/subscribepay/src/service/phoneCollent.go

@@ -110,7 +110,7 @@ func phoneStep_coll(sess *httpsession.Session, step int, phone, code string) (st
 		if !jy.PhoneReg.MatchString(phone) {
 			return "", fmt.Errorf("手机号格式不正确")
 		}
-		if !jy.SendPhoneIdentCode(phone, sess) {
+		if !jy.SendPhoneIdentCode(config.Config.SmsServiceRpc, phone, sess) {
 			return "", fmt.Errorf("验证码发送频繁")
 		}
 		return phone, nil

+ 1 - 1
src/jfw/modules/subscribepay/src/service/userAccountInfo.go

@@ -776,7 +776,7 @@ func phoneStep(sess *httpsession.Session, step int, phone, code, sign string) (s
 				return "", fmt.Errorf("手机号已被使用")
 			}
 		}
-		if !jy.SendPhoneIdentCode(phone, sess, fmt.Sprintf("%s_%s", customSendPhoneMsgSessionKey, sign)) {
+		if !jy.SendPhoneIdentCode(config.Config.SmsServiceRpc, phone, sess, fmt.Sprintf("%s_%s", customSendPhoneMsgSessionKey, sign)) {
 			return "", fmt.Errorf("验证码发送频繁")
 		}
 		incurKey := fmt.Sprintf(redisPhoneCaptchaFilter, qutil.ObjToString(sess.Get("userId")), time.Now().Day())

+ 2 - 1
src/jfw/modules/subscribepay/src/service/vipSubscribeTrial.go

@@ -1,6 +1,7 @@
 package service
 
 import (
+	"config"
 	"encoding/json"
 	"entity"
 	"errors"
@@ -130,7 +131,7 @@ func (t *TrialOrder) SendPhoneCaptcha() {
 		t.SetSession("subvip_trial_lastSend", time.Now().Unix())
 		log.Printf("%s 发送短信验证码 %s\n", t.GetSession("userId"), MsgCode)
 		go func() {
-			jy.SendSMS("2828060", phoneNum, map[string]string{"code": MsgCode})
+			jy.SendSMS(config.Config.SmsServiceRpc, phoneNum, MsgCode)
 		}()
 		return true, ""
 	}()