From cde314878143c0b4ca8d8c4497fecb32333d78ef Mon Sep 17 00:00:00 2001 From: lijianbin <513837235@.qq.com> Date: Tue, 9 Nov 2021 10:22:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0sendNotice=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client.go | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/client.go b/client.go index 5ddca90..6af3b0d 100644 --- a/client.go +++ b/client.go @@ -2,6 +2,7 @@ package msgrpc import ( "encoding/json" + "errors" "log" "strconv" "time" @@ -69,3 +70,66 @@ func SendMsg(site_id, dbname, business_id, domainname, msg_type, order_sn, memo return &res_arr, nil } + + +func SendNotcie(site_id, dbname, manager_id string, template_Data map[string]string, url ...string) (bool, error) { + if dbname == "" || dbname == "" || manager_id == ""{ + return false, errors.New("参数错误") + } + + conn, err := rpc_server_conn(url...) + + if err != nil { + return false, err + } + defer conn.Close() + + arg := NoticeSend{} + arg.SiteId = site_id + arg.Dbname = dbname + arg.ManagerId = manager_id + arg.TemplateData = template_Data + + data_json, err := json.Marshal(arg) + + if err != nil { + return false, err + } + now_int64 := time.Now().Unix() + + encryData := crypter.DesEn(string(data_json), DES_KEY) + + now := strconv.FormatInt(now_int64, 10) + + sign := Sign(encryData, now) + + req := &Request{proto.String(encryData), proto.String(now), proto.String(sign), nil} + + res := &Response{} + + err = conn.SendNotcie(req, res) + + if err != nil { + log.Println("msgrpc SendNotcie error:", err) + return false, err + } + + res_data, err := GetOrgData(res) + + if err != nil { + return false, err + } + if res_data == "" { + return false, nil + } + + var notice_res bool + + err = json.Unmarshal([]byte(res_data), ¬ice_res) + + if err != nil { + return false, err + } + return notice_res, nil + +}