100 lines
3.7 KiB
Go
100 lines
3.7 KiB
Go
package mq_http
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
"time"
|
|
"voucher/internal/biz/bo"
|
|
)
|
|
|
|
func Test_WechatNotifyProducer(t *testing.T) {
|
|
|
|
tag := "voucher_notify_dev"
|
|
|
|
bodyStr := `{"id":"5465699d-de6a-5414-a8df-283167b577ca",
|
|
"create_time":"2025-03-07T15:57:24+08:00",
|
|
"resource_type":"encrypt-resource",
|
|
"event_type":"COUPON.USE",
|
|
"summary":"代金券核销通知",
|
|
"original_type":"coupon",
|
|
"associated_data":"coupon",
|
|
"plain_text":{
|
|
"stock_creator_mchid":"1652465541",
|
|
"stock_id":"10000000",
|
|
"coupon_id":"192720602126930329826",
|
|
"coupon_name":"萧山农商新客激活礼",
|
|
"description":"","status":"USED",
|
|
"create_time":"2025-03-07T15:49:31+08:00",
|
|
"coupon_type":"NORMAL",
|
|
"no_cash":false,
|
|
"singleitem":false,
|
|
"consume_information":{"consume_time":"2025-03-07T15:57:24+08:00","consume_mchid":"1800002761","transaction_id":"4200002544202503077103159055"}}}`
|
|
|
|
if err := wechatNotifyProducer(tag, bodyStr); err != nil {
|
|
t.Errorf("入队失败 error = %v", err)
|
|
return
|
|
}
|
|
}
|
|
|
|
func Test_WechatNotifyProducer2(t *testing.T) {
|
|
|
|
tag := "voucher_notify_pro"
|
|
|
|
bodyStr := `{"id":"5465699d-de6a-5414-a8df-283167b577ca",
|
|
"create_time":"2025-03-07T15:57:24+08:00",
|
|
"resource_type":"encrypt-resource",
|
|
"event_type":"COUPON.USE",
|
|
"summary":"代金券核销通知",
|
|
"original_type":"coupon",
|
|
"associated_data":"coupon",
|
|
"plain_text":{
|
|
"stock_creator_mchid":"1652465541",
|
|
"stock_id":"20392273",
|
|
"coupon_id":"101286678322",
|
|
"coupon_name":"test",
|
|
"description":"",
|
|
"status":"USED",
|
|
"create_time":"2025-03-07T15:49:31+08:00",
|
|
"coupon_type":"NORMAL",
|
|
"no_cash":false,
|
|
"singleitem":false,
|
|
"consume_information":{"consume_time":"2025-03-07T15:57:24+08:00","consume_mchid":"1800002761","transaction_id":"4200002544202503077103159055"}}}`
|
|
|
|
if err := wechatNotifyProducer(tag, bodyStr); err != nil {
|
|
t.Errorf("入队失败 error = %v", err)
|
|
return
|
|
}
|
|
}
|
|
|
|
func Test_WechatNotifyProducer3(t *testing.T) {
|
|
|
|
useTime := time.Now().Format(time.RFC3339)
|
|
t.Log(useTime)
|
|
|
|
x, _ := time.Parse(time.RFC3339, useTime)
|
|
t.Log(x.Format(time.DateTime))
|
|
|
|
//tag := "voucher_notify_dev"
|
|
//
|
|
//bodyStr := `{"id":"8804b1d0-74e8-5975-815d-e567a761a213","create_time":"2025-03-18T09:20:50+08:00","resource_type":"encrypt-resource","event_type":"COUPON.USE","summary":"代金券核销通知","original_type":"coupon","associated_data":"coupon","plain_text":{"stock_creator_mchid":"1652465541","stock_id":"20255099","coupon_id":"97046583699","coupon_name":"招行测试滚动有效期","description":"","status":"USED","create_time":"2025-03-17T19:38:52+08:00","coupon_type":"NORMAL","no_cash":false,"singleitem":false,"consume_information":{"consume_time":"2025-03-18T09:20:50+08:00","consume_mchid":"1532524971","transaction_id":"4200002702202503180978933760"}}}`
|
|
//
|
|
//if err := wechatNotifyProducer(tag, bodyStr); err != nil {
|
|
// t.Errorf("入队失败 error = %v", err)
|
|
// return
|
|
//}
|
|
}
|
|
|
|
func Test_WechatVoucherNotifyData(t *testing.T) {
|
|
|
|
bodyStr := `{"id":"8804b1d0-74e8-5975-815d-e567a761a213","create_time":"2025-03-18T09:20:50+08:00","resource_type":"encrypt-resource","event_type":"COUPON.USE","summary":"代金券核销通知","original_type":"coupon","associated_data":"coupon","plain_text":{"stock_creator_mchid":"1652465541","stock_id":"20255099","coupon_id":"97046583699","coupon_name":"招行测试滚动有效期","description":"","status":"USED","create_time":"2025-03-17T19:38:52+08:00","coupon_type":"NORMAL","no_cash":false,"singleitem":false,"consume_information":{"consume_time":"2025-03-18T09:20:50+08:00","consume_mchid":"1532524971","transaction_id":"4200002702202503180978933760"}}}`
|
|
|
|
var x *bo.WechatVoucherNotifyBo
|
|
|
|
if err := json.Unmarshal([]byte(bodyStr), &x); err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
|
|
t.Log(x)
|
|
}
|