|
@@ -3,6 +3,9 @@ package controllers
|
|
|
import (
|
|
|
"hongze/hongze_robot/models"
|
|
|
"hongze/hongze_robot/utils"
|
|
|
+ "time"
|
|
|
+
|
|
|
+ "github.com/blinkbean/dingtalk"
|
|
|
)
|
|
|
|
|
|
//短信管理
|
|
@@ -10,7 +13,6 @@ type SmsController struct {
|
|
|
BaseCommonController
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// @Title 短信转发接口
|
|
|
// @Description 短信转发接口
|
|
|
// @Param request body company.CompanyApplyApproveReq true "type json string"
|
|
@@ -22,14 +24,45 @@ func (this *SmsController) SmsSend() {
|
|
|
this.Data["json"] = br
|
|
|
this.ServeJSON()
|
|
|
}()
|
|
|
- sign:=this.GetString("Sign")
|
|
|
- address:=this.GetString("Address")
|
|
|
- body:=this.GetString("Body")
|
|
|
- name:=this.GetString("Name")
|
|
|
- date:=this.GetString("Date")
|
|
|
+ sign := this.GetString("Sign")
|
|
|
+ address := this.GetString("Address")
|
|
|
+ body := this.GetString("Body")
|
|
|
+ name := this.GetString("Name")
|
|
|
+ date := this.GetString("Date")
|
|
|
+ utils.FileLog.Info(" %s; %s; %s; %s; %s", sign, address, body, name, date)
|
|
|
|
|
|
- utils.FileLog.Info(" %s; %s; %s; %s; %s",sign,address,body,name,date)
|
|
|
+ count, err := models.GetSmsRecordCount(address, date)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "失败,请联系技术"
|
|
|
+ br.ErrMsg = "失败;Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //判断记录是否存在
|
|
|
+ if count <= 0 {
|
|
|
+ var dingToken = []string{"5f9ae772343b20af806e1f8a6c27a3d8c1b57d8c36f468ab0a12d7eca1cf423c"}
|
|
|
+ msg := []string{
|
|
|
+ "### " + address,
|
|
|
+ "---",
|
|
|
+ "- <font color=#00ff00 size=6>" + body + "</font>",
|
|
|
+ "- " + date,
|
|
|
+ }
|
|
|
+ cli := dingtalk.InitDingTalk(dingToken, "hongze")
|
|
|
+ cli.SendTextMessage("content", dingtalk.WithAtAll())
|
|
|
+ cli.SendMarkDownMessageBySlice("测试测试", msg)
|
|
|
+
|
|
|
+ record := new(models.SmsRecord)
|
|
|
+ record.CreateTime = time.Now()
|
|
|
+ record.Mobile = address
|
|
|
+ record.SmsDate = date
|
|
|
+ record.Body = body
|
|
|
+ _, err = models.AddSmsRecord(record)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "失败,请联系技术"
|
|
|
+ br.ErrMsg = "新增记录失败;Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
br.Msg = "发送成功"
|
|
|
-}
|
|
|
+}
|