Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
liexin_scm_wms_sync
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
474a76e6
authored
Apr 30, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
切换钉钉消息方式
parent
4746e394
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
75 additions
and
54 deletions
cmd/main.go
cmd/queue/sync_audit_status/main.go
cmd/queue/sync_customer/main.go
cmd/queue/sync_goods/main.go
cmd/queue/sync_goods/product.go
cmd/queue/sync_in_store/main.go
cmd/queue/sync_out_store/main.go
cmd/queue/sync_status/main.go
cmd/queue/sync_supplier/main.go
cmd/source/data/goods.xlsx
cmd/source/goods/goods.go
internal/service/dingding.go
cmd/main.go
View file @
474a76e6
package
main
package
main
import
(
import
(
"fmt"
"scm_server/internal/service"
"strings"
)
)
func
main
()
{
func
main
()
{
temp
:=
`{\"type\":\"save\",\"date\":{\"FID\":\"UxasZFrOQGC+oCfTmVSNuUQJ5/A=\",\"FBrand\":\"3M\",\"FModel\":\"aabbddcc\",\"FGoods\":\"\u4E8C\u6781\u7BA1\"}}`
service
.
SendDingTalkRobotToApi
(
"xxx"
)
temp
=
strings
.
ReplaceAll
(
temp
,
`\`
,
""
)
fmt
.
Println
(
temp
)
return
}
}
cmd/queue/sync_audit_status/main.go
View file @
474a76e6
...
@@ -10,7 +10,6 @@ import (
...
@@ -10,7 +10,6 @@ import (
"github.com/pkg/errors"
"github.com/pkg/errors"
"scm_server/cmd/queue/sync_audit_status/product"
"scm_server/cmd/queue/sync_audit_status/product"
"scm_server/configs"
"scm_server/configs"
"scm_server/internal/common"
"scm_server/internal/logic"
"scm_server/internal/logic"
"scm_server/internal/model"
"scm_server/internal/model"
"scm_server/internal/service"
"scm_server/internal/service"
...
@@ -55,9 +54,9 @@ ERR:
...
@@ -55,9 +54,9 @@ ERR:
//如果失败了,记录到表,并且发送钉钉消息
//如果失败了,记录到表,并且发送钉钉消息
if
err
=
logic
.
InsertAuditStatusLog
(
auditStatusLog
);
err
!=
nil
{
if
err
=
logic
.
InsertAuditStatusLog
(
auditStatusLog
);
err
!=
nil
{
log
.
Error
(
err
.
Error
())
log
.
Error
(
err
.
Error
())
service
.
Send
Message
(
common
.
ErrorSendPhone
,
err
.
Error
())
service
.
Send
DingTalkRobotToApi
(
err
.
Error
())
}
}
service
.
Send
Message
(
common
.
ErrorSendPhone
,
auditStatusLog
.
SyncError
)
service
.
Send
DingTalkRobotToApi
(
auditStatusLog
.
SyncError
)
return
nil
return
nil
}
}
...
...
cmd/queue/sync_customer/main.go
View file @
474a76e6
...
@@ -76,7 +76,7 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
...
@@ -76,7 +76,7 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
goto
ERR
goto
ERR
}
}
default
:
default
:
err
=
errors
.
New
(
"同步客户出现不存在的操作类型"
)
err
=
errors
.
New
(
"同步客户出现不存在的操作类型"
+
operateType
)
goto
ERR
goto
ERR
}
}
//操作成功后还要去请求后端接口同步数据
//操作成功后还要去请求后端接口同步数据
...
@@ -99,12 +99,12 @@ ERR:
...
@@ -99,12 +99,12 @@ ERR:
SyncName
:
"customer"
,
SyncName
:
"customer"
,
}
}
if
err
=
logic
.
InsertSyncLog
(
syncLog
);
err
!=
nil
{
if
err
=
logic
.
InsertSyncLog
(
syncLog
);
err
!=
nil
{
service
.
Send
Message
(
common
.
ErrorSendPhone
,
err
.
Error
())
service
.
Send
DingTalkRobotToApi
(
err
.
Error
())
}
}
//发送钉钉错误消息
//发送钉钉错误消息
msg
,
_
:=
json
.
Marshal
(
syncLog
)
msg
,
_
:=
json
.
Marshal
(
syncLog
)
service
.
Send
Message
(
common
.
ErrorSendPhone
,
string
(
msg
))
service
.
Send
DingTalkRobotToApi
(
string
(
msg
))
//保存日志
//保存日志
log
.
Error
(
"%s"
,
string
(
msg
))
log
.
Error
(
"%s"
,
string
(
msg
))
...
...
cmd/queue/sync_goods/main.go
View file @
474a76e6
...
@@ -79,7 +79,7 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
...
@@ -79,7 +79,7 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
goto
ERR
goto
ERR
}
}
default
:
default
:
err
=
errors
.
New
(
"同步供应商出现不存在的操作类型"
)
err
=
errors
.
New
(
"同步供应商出现不存在的操作类型"
+
operateType
)
goto
ERR
goto
ERR
}
}
//操作成功后还要去请求后端接口同步数据
//操作成功后还要去请求后端接口同步数据
...
@@ -103,12 +103,12 @@ ERR:
...
@@ -103,12 +103,12 @@ ERR:
}
}
//错误日志插入错误,需要告警
//错误日志插入错误,需要告警
if
err
=
logic
.
InsertSyncLog
(
syncLog
);
err
!=
nil
{
if
err
=
logic
.
InsertSyncLog
(
syncLog
);
err
!=
nil
{
service
.
Send
Message
(
common
.
ErrorSendPhone
,
err
.
Error
())
service
.
Send
DingTalkRobotToApi
(
err
.
Error
())
}
}
//发送钉钉错误消息
//发送钉钉错误消息
msg
,
_
:=
json
.
Marshal
(
syncLog
)
msg
,
_
:=
json
.
Marshal
(
syncLog
)
service
.
Send
Message
(
common
.
ErrorSendPhone
,
string
(
msg
))
service
.
Send
DingTalkRobotToApi
(
string
(
msg
))
//保存日志
//保存日志
log
.
Error
(
"%s"
,
string
(
msg
))
log
.
Error
(
"%s"
,
string
(
msg
))
return
nil
return
nil
...
...
cmd/queue/sync_goods/product.go
View file @
474a76e6
cmd/queue/sync_in_store/main.go
View file @
474a76e6
...
@@ -97,7 +97,7 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
...
@@ -97,7 +97,7 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
goto
ERR
goto
ERR
}
}
default
:
default
:
err
=
errors
.
New
(
"同步入货单出现不存在的操作类型"
)
err
=
errors
.
New
(
"同步入货单出现不存在的操作类型"
+
operateType
)
goto
ERR
goto
ERR
}
}
//操作成功后还要去请求后端接口同步数据
//操作成功后还要去请求后端接口同步数据
...
@@ -105,7 +105,7 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
...
@@ -105,7 +105,7 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
goto
ERR
goto
ERR
}
}
fmt
.
Println
(
"同步成功,开始发送金蝶状态同步"
)
fmt
.
Println
(
"同步成功,开始发送金蝶状态同步"
)
if
err
=
product
.
SyncErpStatus
(
"in
_s
tore"
,
inStore
.
BillId
);
err
!=
nil
{
if
err
=
product
.
SyncErpStatus
(
"in
S
tore"
,
inStore
.
BillId
);
err
!=
nil
{
goto
ERR
goto
ERR
}
}
return
nil
return
nil
...
@@ -121,11 +121,11 @@ ERR:
...
@@ -121,11 +121,11 @@ ERR:
}
}
//错误日志插入错误,需要告警
//错误日志插入错误,需要告警
if
err
=
logic
.
InsertSyncLog
(
syncLog
);
err
!=
nil
{
if
err
=
logic
.
InsertSyncLog
(
syncLog
);
err
!=
nil
{
service
.
Send
Message
(
common
.
ErrorSendPhone
,
err
.
Error
())
service
.
Send
DingTalkRobotToApi
(
err
.
Error
())
}
}
//发送钉钉错误消息
//发送钉钉错误消息
msg
,
_
=
json
.
Marshal
(
syncLog
)
msg
,
_
=
json
.
Marshal
(
syncLog
)
service
.
Send
Message
(
common
.
ErrorSendPhone
,
string
(
msg
))
service
.
Send
DingTalkRobotToApi
(
string
(
msg
))
//保存日志
//保存日志
log
.
Error
(
"%s"
,
string
(
msg
))
log
.
Error
(
"%s"
,
string
(
msg
))
return
nil
return
nil
...
@@ -194,8 +194,8 @@ func TransformParams(message InStoreMessage) (result req.Param) {
...
@@ -194,8 +194,8 @@ func TransformParams(message InStoreMessage) (result req.Param) {
detailPrefix
=
fmt
.
Sprintf
(
"detail[%d]["
,
key
)
detailPrefix
=
fmt
.
Sprintf
(
"detail[%d]["
,
key
)
detailMap
=
map
[
string
]
interface
{}{
detailMap
=
map
[
string
]
interface
{}{
detailPrefix
+
"erp_entry_sn]"
:
entry
.
FSourceBillEntryID
,
detailPrefix
+
"erp_entry_sn]"
:
entry
.
FSourceBillEntryID
,
detailPrefix
+
"
goods_erp
_id]"
:
entry
.
FMaterialID
,
detailPrefix
+
"
erp_goods
_id]"
:
entry
.
FMaterialID
,
detailPrefix
+
"goods_name]"
:
entry
.
F
Goods
,
detailPrefix
+
"goods_name]"
:
entry
.
F
Model
,
detailPrefix
+
"brand_name]"
:
entry
.
FBrand
,
detailPrefix
+
"brand_name]"
:
entry
.
FBrand
,
detailPrefix
+
"number]"
:
entry
.
FQty
,
detailPrefix
+
"number]"
:
entry
.
FQty
,
detailPrefix
+
"country]"
:
entry
.
FOriginCountry
,
detailPrefix
+
"country]"
:
entry
.
FOriginCountry
,
...
...
cmd/queue/sync_out_store/main.go
View file @
474a76e6
...
@@ -98,7 +98,7 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
...
@@ -98,7 +98,7 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
goto
ERR
goto
ERR
}
}
default
:
default
:
err
=
errors
.
New
(
"同步出货单出现不存在的操作类型"
)
err
=
errors
.
New
(
"同步出货单出现不存在的操作类型"
+
operateType
)
goto
ERR
goto
ERR
}
}
//操作成功后还要去请求后端接口同步数据
//操作成功后还要去请求后端接口同步数据
...
@@ -106,7 +106,7 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
...
@@ -106,7 +106,7 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
goto
ERR
goto
ERR
}
}
fmt
.
Println
(
"同步成功,开始发送金蝶状态同步"
)
fmt
.
Println
(
"同步成功,开始发送金蝶状态同步"
)
if
err
=
product
.
SyncErpStatus
(
"out
_s
tore"
,
outStore
.
BillId
);
err
!=
nil
{
if
err
=
product
.
SyncErpStatus
(
"out
S
tore"
,
outStore
.
BillId
);
err
!=
nil
{
goto
ERR
goto
ERR
}
}
return
nil
return
nil
...
@@ -122,11 +122,11 @@ ERR:
...
@@ -122,11 +122,11 @@ ERR:
}
}
//错误日志插入错误,需要告警
//错误日志插入错误,需要告警
if
err
=
logic
.
InsertSyncLog
(
syncLog
);
err
!=
nil
{
if
err
=
logic
.
InsertSyncLog
(
syncLog
);
err
!=
nil
{
service
.
Send
Message
(
common
.
ErrorSendPhone
,
err
.
Error
())
service
.
Send
DingTalkRobotToApi
(
err
.
Error
())
}
}
//发送钉钉错误消息
//发送钉钉错误消息
msg
,
_
=
json
.
Marshal
(
syncLog
)
msg
,
_
=
json
.
Marshal
(
syncLog
)
service
.
Send
Message
(
common
.
ErrorSendPhone
,
string
(
msg
))
service
.
Send
DingTalkRobotToApi
(
string
(
msg
))
//保存日志
//保存日志
log
.
Error
(
"%s"
,
string
(
msg
))
log
.
Error
(
"%s"
,
string
(
msg
))
...
@@ -188,7 +188,7 @@ func TransformParams(message OutStoreMessage) (params map[string]interface{}) {
...
@@ -188,7 +188,7 @@ func TransformParams(message OutStoreMessage) (params map[string]interface{}) {
for
_
,
entry
=
range
message
.
Data
.
FEntrys
{
for
_
,
entry
=
range
message
.
Data
.
FEntrys
{
outStoreDetail
=
append
(
outStoreDetail
,
map
[
string
]
interface
{}{
outStoreDetail
=
append
(
outStoreDetail
,
map
[
string
]
interface
{}{
"erp_goods_id"
:
entry
.
FMaterialID
,
"erp_goods_id"
:
entry
.
FMaterialID
,
"goods_name"
:
entry
.
F
Goods
,
"goods_name"
:
entry
.
F
Model
,
"brand_name"
:
entry
.
FBrand
,
"brand_name"
:
entry
.
FBrand
,
"number"
:
entry
.
FQty
,
"number"
:
entry
.
FQty
,
"goods_unit"
:
entry
.
FUnit
,
"goods_unit"
:
entry
.
FUnit
,
...
@@ -205,7 +205,7 @@ func TransformParams(message OutStoreMessage) (params map[string]interface{}) {
...
@@ -205,7 +205,7 @@ func TransformParams(message OutStoreMessage) (params map[string]interface{}) {
"receive_address"
:
message
.
Data
.
FRecPersonAddress
,
"receive_address"
:
message
.
Data
.
FRecPersonAddress
,
"receive_user_name"
:
message
.
Data
.
FRecPerson
,
"receive_user_name"
:
message
.
Data
.
FRecPerson
,
"receive_tel"
:
message
.
Data
.
FRecPersonContact
,
"receive_tel"
:
message
.
Data
.
FRecPersonContact
,
"erp_
in
_store_id"
:
message
.
Data
.
FSourceBillID
,
"erp_
out
_store_id"
:
message
.
Data
.
FSourceBillID
,
"erp_client_sn"
:
message
.
Data
.
FPrincipalNo
,
"erp_client_sn"
:
message
.
Data
.
FPrincipalNo
,
"remark"
:
message
.
Data
.
Remark
,
"remark"
:
message
.
Data
.
Remark
,
"erp_store_sn"
:
message
.
Data
.
FWarehouseNo
,
"erp_store_sn"
:
message
.
Data
.
FWarehouseNo
,
...
...
cmd/queue/sync_status/main.go
View file @
474a76e6
...
@@ -9,7 +9,6 @@ import (
...
@@ -9,7 +9,6 @@ import (
"github.com/mushishixian/gosoap"
"github.com/mushishixian/gosoap"
"github.com/pkg/errors"
"github.com/pkg/errors"
"scm_server/configs"
"scm_server/configs"
"scm_server/internal/common"
"scm_server/internal/logic"
"scm_server/internal/logic"
"scm_server/internal/model"
"scm_server/internal/model"
"scm_server/internal/service"
"scm_server/internal/service"
...
@@ -52,9 +51,9 @@ ERR:
...
@@ -52,9 +51,9 @@ ERR:
syncStatusLog
.
AddTime
=
time
.
Now
()
.
Unix
()
syncStatusLog
.
AddTime
=
time
.
Now
()
.
Unix
()
//如果失败了,记录到表,并且发送钉钉消息
//如果失败了,记录到表,并且发送钉钉消息
if
err
=
logic
.
InsertSyncStatusLog
(
syncStatusLog
);
err
!=
nil
{
if
err
=
logic
.
InsertSyncStatusLog
(
syncStatusLog
);
err
!=
nil
{
service
.
Send
Message
(
common
.
ErrorSendPhone
,
err
.
Error
())
service
.
Send
DingTalkRobotToApi
(
err
.
Error
())
}
}
service
.
Send
Message
(
common
.
ErrorSendPhone
,
syncStatusLog
.
SyncError
)
service
.
Send
DingTalkRobotToApi
(
syncStatusLog
.
SyncError
)
return
nil
return
nil
}
}
...
@@ -114,11 +113,11 @@ func SyncErpDataStatus(syncName, uniqueId string) (err error) {
...
@@ -114,11 +113,11 @@ func SyncErpDataStatus(syncName, uniqueId string) (err error) {
apiUrl
=
configs
.
ErpSyncBaseDataStatusApi
apiUrl
=
configs
.
ErpSyncBaseDataStatusApi
apiMethod
=
"synRewriteErpBaseDataStatus"
apiMethod
=
"synRewriteErpBaseDataStatus"
break
break
case
"in
_s
tore"
:
case
"in
S
tore"
:
apiUrl
=
configs
.
ErpSyncBillStatusApi
apiUrl
=
configs
.
ErpSyncBillStatusApi
apiMethod
=
"synErpInventoryStatus"
apiMethod
=
"synErpInventoryStatus"
break
break
case
"out
_s
tore"
:
case
"out
S
tore"
:
apiUrl
=
configs
.
ErpSyncBillStatusApi
apiUrl
=
configs
.
ErpSyncBillStatusApi
apiMethod
=
"synErpInventoryStatus"
apiMethod
=
"synErpInventoryStatus"
break
break
...
@@ -163,6 +162,8 @@ func CheckBaseDataRequest(res *gosoap.Response) (err error) {
...
@@ -163,6 +162,8 @@ func CheckBaseDataRequest(res *gosoap.Response) (err error) {
for
key
,
value
:=
range
responseData
{
for
key
,
value
:=
range
responseData
{
//金蝶判断成功的标志
//金蝶判断成功的标志
if
key
==
"0000"
{
if
key
==
"0000"
{
//成功还要去修改记录表
fmt
.
Println
(
"OK"
)
return
return
}
}
//金额判断失败的标志
//金额判断失败的标志
...
@@ -183,7 +184,6 @@ func CheckBillDataRequest(res *gosoap.Response) (err error) {
...
@@ -183,7 +184,6 @@ func CheckBillDataRequest(res *gosoap.Response) (err error) {
}
}
//没有这个xml节点代表金蝶报错了
//没有这个xml节点代表金蝶报错了
root
:=
doc
.
SelectElement
(
"ns1:synErpInventoryStatusResponse"
)
root
:=
doc
.
SelectElement
(
"ns1:synErpInventoryStatusResponse"
)
fmt
.
Println
(
root
)
if
root
==
nil
{
if
root
==
nil
{
return
errors
.
New
(
string
(
res
.
Body
))
return
errors
.
New
(
string
(
res
.
Body
))
}
}
...
@@ -194,6 +194,7 @@ func CheckBillDataRequest(res *gosoap.Response) (err error) {
...
@@ -194,6 +194,7 @@ func CheckBillDataRequest(res *gosoap.Response) (err error) {
for
key
,
value
:=
range
responseData
{
for
key
,
value
:=
range
responseData
{
//金蝶判断成功的标志
//金蝶判断成功的标志
if
key
==
"0000"
{
if
key
==
"0000"
{
fmt
.
Println
(
"OK"
)
return
return
}
}
//金额判断失败的标志
//金额判断失败的标志
...
...
cmd/queue/sync_supplier/main.go
View file @
474a76e6
...
@@ -77,7 +77,7 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
...
@@ -77,7 +77,7 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
goto
ERR
goto
ERR
}
}
default
:
default
:
err
=
errors
.
New
(
"同步供应商出现不存在的操作类型"
)
err
=
errors
.
New
(
"同步供应商出现不存在的操作类型"
+
operateType
+
operateType
)
goto
ERR
goto
ERR
}
}
//操作成功后还要去请求后端接口同步数据
//操作成功后还要去请求后端接口同步数据
...
@@ -100,11 +100,11 @@ ERR:
...
@@ -100,11 +100,11 @@ ERR:
SyncName
:
"supplier"
,
SyncName
:
"supplier"
,
}
}
if
err
=
logic
.
InsertSyncLog
(
syncLog
);
err
!=
nil
{
if
err
=
logic
.
InsertSyncLog
(
syncLog
);
err
!=
nil
{
service
.
Send
Message
(
common
.
ErrorSendPhone
,
err
.
Error
())
service
.
Send
DingTalkRobotToApi
(
err
.
Error
())
}
}
//发送钉钉错误消息
//发送钉钉错误消息
msg
,
_
:=
json
.
Marshal
(
syncLog
)
msg
,
_
:=
json
.
Marshal
(
syncLog
)
service
.
Send
Message
(
common
.
ErrorSendPhone
,
string
(
msg
))
service
.
Send
DingTalkRobotToApi
(
string
(
msg
))
//保存日志
//保存日志
log
.
Error
(
"%s"
,
string
(
msg
))
log
.
Error
(
"%s"
,
string
(
msg
))
...
...
cmd/source/data/goods.xlsx
View file @
474a76e6
No preview for this file type
cmd/source/goods/goods.go
View file @
474a76e6
...
@@ -41,9 +41,6 @@ func Import() {
...
@@ -41,9 +41,6 @@ func Import() {
if
key
==
0
{
if
key
==
0
{
continue
continue
}
}
if
key
==
100
{
break
}
goods
.
ErpId
=
row
.
Cells
[
0
]
.
String
()
goods
.
ErpId
=
row
.
Cells
[
0
]
.
String
()
goods
.
GoodsName
=
row
.
Cells
[
1
]
.
String
()
goods
.
GoodsName
=
row
.
Cells
[
1
]
.
String
()
goods
.
BrandName
=
row
.
Cells
[
2
]
.
String
()
goods
.
BrandName
=
row
.
Cells
[
2
]
.
String
()
...
...
internal/service/dingding.go
View file @
474a76e6
package
service
package
service
import
(
import
(
"scm_server/internal/common"
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"github.com/imroc/req"
"net/http"
"net/http"
"net/url"
"net/url"
"scm_server/internal/common"
"strconv"
"strconv"
"time"
"time"
)
)
...
@@ -14,29 +15,27 @@ const APIMD5STR string = "fh6y5t4rr351d2c3bryi"
...
@@ -14,29 +15,27 @@ const APIMD5STR string = "fh6y5t4rr351d2c3bryi"
const
APIDOMAIN
string
=
"http://api.ichunt.com/msg/sendMessageByAuto"
const
APIDOMAIN
string
=
"http://api.ichunt.com/msg/sendMessageByAuto"
const
ADMINTEL
int64
=
18825159814
const
ADMINTEL
int64
=
18825159814
func
AdminErr
(
err
error
)
{
func
AdminErr
(
err
error
)
{
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
err
)
fmt
.
Println
(
err
)
SendMessage
(
ADMINTEL
,
err
.
Error
())
SendMessage
(
ADMINTEL
,
err
.
Error
())
}
}
}
}
func
SendMessage
(
mobile
int64
,
content
string
)
{
func
SendMessage
(
mobile
int64
,
content
string
){
if
mobile
!=
0
{
if
mobile
!=
0
{
timeNow
:=
time
.
Now
()
.
Unix
()
timeNow
:=
time
.
Now
()
.
Unix
()
requestContent
,
_
:=
json
.
Marshal
(
map
[
string
]
string
{
"content"
:
content
})
requestContent
,
_
:=
json
.
Marshal
(
map
[
string
]
string
{
"content"
:
content
})
requestTel
,
_
:=
json
.
Marshal
([]
int64
{
mobile
})
requestTel
,
_
:=
json
.
Marshal
([]
int64
{
mobile
})
resp
,
err
:=
http
.
PostForm
(
APIDOMAIN
,
url
.
Values
{
resp
,
err
:=
http
.
PostForm
(
APIDOMAIN
,
url
.
Values
{
"data"
:
{
string
(
requestContent
)},
"data"
:
{
string
(
requestContent
)},
"touser"
:
{
string
(
requestTel
)},
"touser"
:
{
string
(
requestTel
)},
"keyword"
:
{
"register_nopay_notify"
},
"keyword"
:
{
"register_nopay_notify"
},
"k1"
:
{
strconv
.
FormatInt
(
int64
(
timeNow
),
10
)},
"k1"
:
{
strconv
.
FormatInt
(
int64
(
timeNow
),
10
)},
"k2"
:
{
common
.
Md5
(
common
.
Md5
(
strconv
.
FormatInt
(
int64
(
timeNow
),
10
))
+
APIMD5STR
)},
"k2"
:
{
common
.
Md5
(
common
.
Md5
(
strconv
.
FormatInt
(
int64
(
timeNow
),
10
))
+
APIMD5STR
)},
"is_ignore"
:
{},
"is_ignore"
:
{},
})
})
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -46,3 +45,32 @@ func SendMessage(mobile int64 , content string){
...
@@ -46,3 +45,32 @@ func SendMessage(mobile int64 , content string){
}
}
}
}
type
DingDingRequest
struct
{
MsgType
string
`json:"msgtype"`
Text
map
[
string
]
string
`json:"text"`
IsAtAll
bool
`json:"isAtAll"`
}
func
SendDingTalkRobotToApi
(
content
string
)
{
var
(
requestData
DingDingRequest
apiUrl
,
token
string
resp
*
req
.
Resp
err
error
)
content
=
"仓储同步告警 : "
+
content
requestData
.
MsgType
=
"text"
requestData
.
Text
=
map
[
string
]
string
{
"content"
:
content
,
}
req
.
Debug
=
false
requestData
.
IsAtAll
=
false
token
=
"3c048caba514a5252aa8bdbb3e10994def6409a2f0d5212e5626c1a071152ec3"
apiUrl
=
"https://api.ichunt.com/public/dingtalkrobot?access_token="
+
token
params
:=
req
.
BodyJSON
(
requestData
)
resp
,
err
=
req
.
Post
(
apiUrl
,
params
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
}
fmt
.
Println
(
resp
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment