Browse Source

新增短信重复校验

longyu 2 years ago
parent
commit
48eb855822
2 changed files with 9 additions and 2 deletions
  1. 2 2
      models/sms_record.go
  2. 7 0
      services/sms_send.go

+ 2 - 2
models/sms_record.go

@@ -70,7 +70,7 @@ func ModifySmsRecordUnicode(unionCode string,id int) (err error) {
 
 
 func GetSmsRecordList()(list []*SmsRecord,err error)  {
 func GetSmsRecordList()(list []*SmsRecord,err error)  {
 	o := orm.NewOrm()
 	o := orm.NewOrm()
-	sql := `SELECT * FROM sms_record WHERE union_code<>'' `
-	_, err = o.Raw(sql).Exec()
+	sql := `SELECT * FROM sms_record WHERE union_code='' `
+	_, err = o.Raw(sql).QueryRows(&list)
 	return
 	return
 }
 }

+ 7 - 0
services/sms_send.go

@@ -59,6 +59,7 @@ func AddUnionCode() {
 		return
 		return
 	}
 	}
 	for _, v := range list {
 	for _, v := range list {
+		fmt.Println(v.Id,v.Mobile)
 		unionCode := utils.MD5(v.Mobile + v.Body + v.SmsDate)
 		unionCode := utils.MD5(v.Mobile + v.Body + v.SmsDate)
 		err = models.ModifySmsRecordUnicode(unionCode, v.Id)
 		err = models.ModifySmsRecordUnicode(unionCode, v.Id)
 		if err != nil {
 		if err != nil {
@@ -67,3 +68,9 @@ func AddUnionCode() {
 		}
 		}
 	}
 	}
 }
 }
+
+//func init() {
+//	fmt.Println("start 111")
+//	AddUnionCode()
+//	fmt.Println("end 111")
+//}