package test import ( "encoding/base64" "encoding/json" "testing" "time" "voucher/internal/biz/bo" "voucher/internal/pkg/helper" ) func Test_MarketingSend(t *testing.T) { tests := []struct { name string }{ { name: "给指定用户报名多笔立减活动", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { MarketingSend() }) } } func Test_MarketingQuery(t *testing.T) { tests := []struct { name string appId, openId, couponId string }{ { name: "查询绑定多笔立减活动的代金券详情", // 查询的商户非创建方商户 查询商户要为创建方商户 appId: "wx619991cc795028f5", openId: "oSNb4ftgnWC22Z0cWTjsQebdr2Yk", couponId: "139923450432", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { resp, err := MarketingQuery(tt.appId, tt.openId, tt.couponId) if err != nil { t.Errorf("MarketingQuery() error = %v", err) return } t.Logf("MarketingQuery() = %v", resp) }) } // 合单订单就是没有核销回调通知的 // {"code":"APPID_MCHID_NOT_MATCH","message":"商户号与AppID不匹配"} // APPID_MCHID_NOT_MATCH 商户号与AppID不匹配 调用接口的商户号需与接口传入的AppID有绑定关系 //openid不是自己的appid下的喔,这也能查询到吗” //不行的,需要是在自己appid下的才能查到 } func Test_QixingNotifyData(t *testing.T) { wxBody := `{"id":"4ab2699d-e91d-5460-9810-25fd6d4c69a5","create_time":"2025-12-08T17:54: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":"21386484","coupon_id":"142388354994","coupon_name":"银行卡多笔立减","description":"","status":"SENDED","create_time":"2025-12-08T17:50:48+08:00","coupon_type":"NORMAL","no_cash":false,"singleitem":false,"business_type":"","consume_information":{"consume_time":"2025-12-08T17:54:24+08:00","consume_mchid":"1274938601","transaction_id":"4200002996202512083063051834","consume_amount":16}}}` content := base64.StdEncoding.EncodeToString([]byte(wxBody)) ciphertext := helper.Md5(content + "DrY1zLkOH01q0sN66vrmkdpbWsyb41ho") req := bo.QiXingRequestBo{ Content: content, Timestamp: time.Now().UnixMilli(), Ciphertext: ciphertext, } b, _ := json.Marshal(req) t.Log(string(b)) // {"content":"base64(微信通知json对象数据)","timestamp":1765447477945,"ciphertext":"md5(base64(微信通知json对象数据)+key)"} //t.Logf(`{"content":"%s","timestamp":122345677890,"ciphertext":"%s"}`, content, ciphertext) }