send ding msg
This commit is contained in:
parent
e0d8575b78
commit
bacf62d5a9
|
@ -0,0 +1,27 @@
|
|||
package dingtalkapi
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"service/library/logger"
|
||||
)
|
||||
|
||||
func SendBizDingtalk(content string) {
|
||||
url := "https://oapi.dingtalk.com/robot/send?access_token=df06fe143b47b0068b3e7fea924f896e2a1123679ab82639faedcab7bef1d6e2"
|
||||
msg := fmt.Sprintf("{\"msgtype\":\"text\",\"text\":{\"content\":\"%s\"}}", content)
|
||||
req, err := http.NewRequest("POST", url, bytes.NewBuffer([]byte(msg)))
|
||||
if err != nil {
|
||||
logger.Error("http new request failed:%s - %s", msg, err.Error())
|
||||
return
|
||||
}
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
logger.Error("accept letter send failed:%#v - %s", req, err.Error())
|
||||
return
|
||||
}
|
||||
logger.Info("send dingtalk biz msg: %v", msg)
|
||||
_ = resp.Body.Close()
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package dingtalkapi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestSendBizDingtalk(t *testing.T) {
|
||||
c := fmt.Sprintf("【主播TX】-%s\n用户id: %d\n用户mid: %d\n用户昵称: %s\nTX Amount: %.2f\n商户: %s\n结果: 成功",
|
||||
time.Now().Format("2006-01-02 15:04:05"), 11111, 222, "测试", float64(5059859)/100.0, "ssss")
|
||||
SendBizDingtalk(c)
|
||||
}
|
|
@ -13,6 +13,7 @@ import (
|
|||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"service/api/adapter/dingtalkapi"
|
||||
"service/api/base"
|
||||
"service/api/errs"
|
||||
"service/api/message/response"
|
||||
|
@ -1894,6 +1895,9 @@ func (v *Vas) WithdrawApply(ctx *gin.Context, req *vasproto.WithdrawApplyReq) (t
|
|||
}
|
||||
}
|
||||
|
||||
acntMap, _ := v.account.GetAccountMapByMids(ctx, []int64{mid})
|
||||
acnt := acntMap[mid]
|
||||
|
||||
// 检查余额
|
||||
wallet, _ := v.CheckWalletExist(ctx, nil, mid)
|
||||
if wallet == nil {
|
||||
|
@ -1968,6 +1972,15 @@ func (v *Vas) WithdrawApply(ctx *gin.Context, req *vasproto.WithdrawApplyReq) (t
|
|||
logger.Error("AddWithdrawHis fail, wHis: %v, errHis: %v", util.ToJson(wHis), errHis)
|
||||
}
|
||||
|
||||
// 发送钉钉消息
|
||||
dingtalkMsgContent := fmt.Sprintf("主播TX -- %s\n\n用户id: %d\n用户mid: %d\n用户昵称: %s\nTX Amount: %.2f\n商户: %s\n结果: 成功",
|
||||
time.Now().Format("2006-01-02 15:04:05"), acnt.GetUserId(), mid, acnt.GetName(), float64(money)/100.0, appid)
|
||||
if len(errMsgSt) > 0 {
|
||||
dingtalkMsgContent = fmt.Sprintf("主播TX -- %s\n\n用户id: %d\n用户mid: %d\n用户昵称: %s\nTX Amount: %.2f\n商户: %s\n结果: 失败\n详情:%s",
|
||||
time.Now().Format("2006-01-02 15:04:05"), acnt.GetUserId(), mid, acnt.GetName(), float64(money)/100.0, appid, util.ToJson(errMsgSt))
|
||||
}
|
||||
dingtalkapi.SendBizDingtalk(dingtalkMsgContent)
|
||||
|
||||
errTx := v.store.DealTxCR(tx, err)
|
||||
if errTx != nil {
|
||||
logger.Error("DealTxCR fail, err: %v", errTx)
|
||||
|
|
Loading…
Reference in New Issue