功能更新
This commit is contained in:
parent
a339fbf3c7
commit
ae9caecf01
@ -137,3 +137,12 @@ type NotifyClientData struct {
|
||||
Id string `json:"id"`
|
||||
NotifyMsg string `json:"notify_msg"`
|
||||
}
|
||||
|
||||
type OrderData struct {
|
||||
UID int `db:"Date"`
|
||||
OrderId string `db:"OrderNum"`
|
||||
Product string `db:"Product"`
|
||||
ProductName string `db:"ProductName"`
|
||||
EventRecovery string `db:"EventRecovery"`
|
||||
EventAge string `db:"EventAge"`
|
||||
}
|
||||
|
||||
@ -166,3 +166,16 @@ func FeishuNotifyClient(c *gin.Context) {
|
||||
log.Printf("failed to send notify message: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func FeishuNotifyOrder(c *gin.Context) {
|
||||
r := Type.OrderData{}
|
||||
if err := c.ShouldBindJSON(&r); err != nil {
|
||||
c.JSON(400, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
err := feishu.SendNotifyOrderMsg(&r)
|
||||
if err != nil {
|
||||
log.Printf("failed to send notify message: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -532,6 +532,34 @@ func SendNotifyMsg(data *Type.NotifyData) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// AAq9lf37SuuDP
|
||||
func SendNotifyOrderMsg(data *Type.OrderData) error {
|
||||
payload := map[string]interface{}{
|
||||
"type": "template",
|
||||
"data": map[string]interface{}{
|
||||
"template_id": "AAq9lf37SuuDP",
|
||||
"template_version_name": "1.0.1",
|
||||
"template_variable": map[string]interface{}{
|
||||
"UID": data.UID,
|
||||
"OrderId": data.OrderId,
|
||||
"Product": data.Product,
|
||||
"ProductName": data.ProductName,
|
||||
"EventRecovery": data.EventRecovery,
|
||||
"EventAge": data.EventAge,
|
||||
},
|
||||
},
|
||||
}
|
||||
payloadBytes, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
c := client.GetClient()
|
||||
err = c.SendGroupMsg(common.GetUSOperationChatId(), common.FEISHU_CART_TYPE, string(payloadBytes))
|
||||
if err != nil {
|
||||
log.Printf("sendNotifyMsg error %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func SendNotifyClientMsg(data *Type.NotifyClientData) error {
|
||||
payload := map[string]interface{}{
|
||||
"type": "template",
|
||||
|
||||
@ -6,6 +6,7 @@ import (
|
||||
"backend/feishu/data"
|
||||
"backend/feishu/handle"
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
larkcore "github.com/larksuite/oapi-sdk-go/v3/core"
|
||||
@ -18,6 +19,7 @@ import (
|
||||
|
||||
func Server() {
|
||||
if common.GetNMap() {
|
||||
fmt.Printf("Start Feishu server fail\n")
|
||||
return
|
||||
}
|
||||
// 注册事件回调,OnP2MessageReceiveV1 为接收消息 v2.0;OnCustomizedEvent 内的 message 为接收消息 v1.0。
|
||||
@ -42,6 +44,7 @@ func Server() {
|
||||
larkws.WithEventHandler(eventHandler),
|
||||
larkws.WithLogLevel(larkcore.LogLevelDebug),
|
||||
)
|
||||
fmt.Printf("Start Feishu server success\n")
|
||||
// 启动客户端
|
||||
err := cli.Start(context.Background())
|
||||
if err != nil {
|
||||
|
||||
33
log/app.log
33
log/app.log
@ -1,33 +0,0 @@
|
||||
2025/09/24 10:47:22 start statistics
|
||||
2025/09/24 10:47:23 remain 2025-09-23 success
|
||||
2025/09/24 10:47:25 remain 2025-09-22 success
|
||||
2025/09/24 10:47:26 remain 2025-09-21 success
|
||||
2025/09/24 10:47:27 remain 2025-09-20 success
|
||||
2025/09/24 10:47:29 remain 2025-09-19 success
|
||||
2025/09/24 10:47:30 remain 2025-09-18 success
|
||||
2025/09/24 10:47:31 remain 2025-09-17 success
|
||||
2025/09/24 10:47:33 remain 2025-09-16 success
|
||||
2025/09/24 10:47:34 remain 2025-09-15 success
|
||||
2025/09/24 10:47:35 remain 2025-09-14 success
|
||||
2025/09/24 10:47:37 remain 2025-09-13 success
|
||||
2025/09/24 10:47:38 remain 2025-09-12 success
|
||||
2025/09/24 10:47:40 remain 2025-09-11 success
|
||||
2025/09/24 10:47:41 remain 2025-09-10 success
|
||||
2025/09/24 10:47:42 remain 2025-09-09 success
|
||||
2025/09/24 10:47:43 remain 2025-09-08 success
|
||||
2025/09/24 10:47:45 remain 2025-09-07 success
|
||||
2025/09/24 10:47:46 remain 2025-09-06 success
|
||||
2025/09/24 10:47:48 remain 2025-09-05 success
|
||||
2025/09/24 10:47:49 remain 2025-09-04 success
|
||||
2025/09/24 10:47:50 remain 2025-09-03 success
|
||||
2025/09/24 10:47:51 remain 2025-09-02 success
|
||||
2025/09/24 10:47:53 remain 2025-09-01 success
|
||||
2025/09/24 10:47:54 remain 2025-08-31 success
|
||||
2025/09/24 10:47:55 remain 2025-08-30 success
|
||||
2025/09/24 10:47:57 remain 2025-08-29 success
|
||||
2025/09/24 10:47:58 remain 2025-08-28 success
|
||||
2025/09/24 10:47:59 remain 2025-08-27 success
|
||||
2025/09/24 10:48:01 remain 2025-08-26 success
|
||||
2025/09/24 10:48:02 remain 2025-08-25 success
|
||||
2025/09/24 10:48:03 remain 2025-08-24 success
|
||||
2025/09/24 10:48:03 end statistics
|
||||
5
main.go
5
main.go
@ -45,8 +45,9 @@ func main() {
|
||||
feishuApi.POST("/sendWeekInfo", controller.FeishuSendWeekInfo)
|
||||
feishuApi.POST("/updateApp", controller.FeishuUpdateApp)
|
||||
feishuApi.POST("/serverInfo", controller.FeishuServerInfo)
|
||||
feishuApi.POST("/notify", controller.FeishuNotify)
|
||||
feishuApi.POST("/notify/client", controller.FeishuNotifyClient)
|
||||
feishuApi.POST("/notify", controller.FeishuNotify) // 系统报警
|
||||
feishuApi.POST("/notify/client", controller.FeishuNotifyClient) // 客户端报警
|
||||
feishuApi.POST("/notify/order", controller.FeishuNotifyOrder) // 订单通知
|
||||
}
|
||||
api := r.Group("/api", middleware.ValidateToken())
|
||||
{
|
||||
|
||||
BIN
release/backend
BIN
release/backend
Binary file not shown.
11
unit_test.go
11
unit_test.go
@ -10,7 +10,16 @@ import (
|
||||
)
|
||||
|
||||
func TestXxx1(t *testing.T) {
|
||||
util.Statistics(0)
|
||||
//util.Statistics(0)
|
||||
data := Type.OrderData{
|
||||
UID: 123456,
|
||||
OrderId: "202404121234567890",
|
||||
Product: "com.game.product1",
|
||||
ProductName: "100 Gems",
|
||||
EventRecovery: "2024-04-15 12:00:00",
|
||||
EventAge: "2024-04-20 12:00:00",
|
||||
}
|
||||
feishu.SendNotifyOrderMsg(&data)
|
||||
}
|
||||
func TestXxx(t *testing.T) {
|
||||
controller.FeishuSendInfo2(nil)
|
||||
|
||||
@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func ScheduleDailyTask() {
|
||||
Statistics(common.US_APP_ID)
|
||||
//Statistics(common.US_APP_ID)
|
||||
|
||||
// 每天凌晨1点执行统计任务
|
||||
go task(common.UK_APP_ID)
|
||||
@ -30,7 +30,7 @@ func task(AppId int) {
|
||||
}
|
||||
now := time.Now().In(loc)
|
||||
next := now.AddDate(0, 0, 1).Truncate(24 * time.Hour)
|
||||
duration := next.Sub(now) + 300*time.Second // 每天凌晨0:05点执行
|
||||
duration := time.Duration(next.Sub(now).Seconds()+300) * time.Second // 每天凌晨0:05点执行
|
||||
time.Sleep(duration)
|
||||
// 执行统计函数
|
||||
Statistics(AppId)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user