test
This commit is contained in:
parent
9131c0b7a6
commit
41071798b9
|
@ -3,7 +3,7 @@ package main
|
||||||
// main 这只是一个演示
|
// main 这只是一个演示
|
||||||
func main() {
|
func main() {
|
||||||
//alipayOrderRedPack()
|
//alipayOrderRedPack()
|
||||||
wechatRedPackOrder()
|
wechatOrderCpn()
|
||||||
//wechatRedPackQuery()
|
//wechatRedPackQuery()
|
||||||
//alipayNotifyRedPack()
|
//alipayNotifyRedPack()
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,32 @@ func getWechatCpnConf() []byte {
|
||||||
return marshal
|
return marshal
|
||||||
}
|
}
|
||||||
|
|
||||||
func wechatCpn() {
|
func wechatOrderCpn() {
|
||||||
|
err := manage.Add(wechatCpnConf)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
defer manage.Close()
|
||||||
|
request := &proto.OrderRequest{
|
||||||
|
Config: getWechatCpnConf(),
|
||||||
|
Order: &proto.OrderRequest_Order{
|
||||||
|
OrderNo: "240403164049635931",
|
||||||
|
Account: "oO3vO5AxRWgTjmMD38FTvnB5Rq6o",
|
||||||
|
Extra: []byte(`{"app_id":"13100720242","stock_creator_mchid":"1605446142"}`),
|
||||||
|
},
|
||||||
|
Product: &proto.OrderRequest_Product{
|
||||||
|
ProductNo: "3102024032977191_11",
|
||||||
|
Extra: []byte(`{}`),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
res, err := instance.Order(context.Background(), alpayRedConf.Tag, request)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
log.Printf("Order res:%+v", res)
|
||||||
|
}
|
||||||
|
|
||||||
|
func wechatQueryCpn() {
|
||||||
err := manage.Add(wechatCpnConf)
|
err := manage.Add(wechatCpnConf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
|
|
|
@ -47,11 +47,13 @@ func (s *AlipayCpnService) Order(ctx context.Context, request *proto.OrderReques
|
||||||
|
|
||||||
var sp string
|
var sp string
|
||||||
err = requests.URL(baseUri).Post().BodyForm(uv).ToString(&sp).Fetch(ctx)
|
err = requests.URL(baseUri).Post().BodyForm(uv).ToString(&sp).Fetch(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("请求异常,msg:" + err.Error())
|
||||||
|
}
|
||||||
var response *po.OrderResp
|
var response *po.OrderResp
|
||||||
sp = helper.ToChinese(sp)
|
sp = helper.ToChinese(sp)
|
||||||
if err = json.Unmarshal([]byte(sp), &response); err != nil {
|
if err = json.Unmarshal([]byte(sp), &response); err != nil {
|
||||||
return nil, fmt.Errorf("请求异常,msg:" + err.Error())
|
return nil, fmt.Errorf("请求解析异常,msg:" + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return orderResp(request, response), nil
|
return orderResp(request, response), nil
|
||||||
|
@ -84,7 +86,7 @@ func (s *AlipayCpnService) Query(ctx context.Context, request *proto.QueryReques
|
||||||
var response po.QueryResp
|
var response po.QueryResp
|
||||||
sp = helper.ToChinese(sp)
|
sp = helper.ToChinese(sp)
|
||||||
if err = json.Unmarshal([]byte(sp), &response); err != nil {
|
if err = json.Unmarshal([]byte(sp), &response); err != nil {
|
||||||
return nil, fmt.Errorf("请求异常,msg:" + err.Error())
|
return nil, fmt.Errorf("请求解析异常,msg:" + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return queryResp(request, response), nil
|
return queryResp(request, response), nil
|
||||||
|
|
|
@ -38,7 +38,7 @@ func TestOrder(t *testing.T) {
|
||||||
Extra: []byte(`{"logon_id":"13100720242"}`),
|
Extra: []byte(`{"logon_id":"13100720242"}`),
|
||||||
},
|
},
|
||||||
Product: &proto.OrderRequest_Product{
|
Product: &proto.OrderRequest_Product{
|
||||||
ProductNo: "3102024032977191",
|
ProductNo: "3102024032977191_11",
|
||||||
Extra: []byte(`{}`),
|
Extra: []byte(`{}`),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package po
|
package po
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"gitea.cdlsxd.cn/sdk/plugin/proto"
|
"gitea.cdlsxd.cn/sdk/plugin/proto"
|
||||||
"plugins/alipay_cpn/internal/vo"
|
"plugins/alipay_cpn/internal/vo"
|
||||||
)
|
)
|
||||||
|
@ -38,10 +37,7 @@ func (o *OrderResp) GetMsg() string {
|
||||||
if o.Response.Code.IsSuccess() {
|
if o.Response.Code.IsSuccess() {
|
||||||
return o.Response.Msg
|
return o.Response.Msg
|
||||||
}
|
}
|
||||||
return fmt.Sprintf(
|
return o.Response.SubMsg
|
||||||
"code:[%s],msg:[%s],subCode:[%s],subMsg[%s]",
|
|
||||||
o.Response.Code, o.Response.Msg, o.Response.SubCode, o.Response.SubMsg,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OrderResp) GetOrderStatus() proto.Status {
|
func (o *OrderResp) GetOrderStatus() proto.Status {
|
||||||
|
|
|
@ -53,7 +53,7 @@ func (s *AlipayRedPackService) Order(ctx context.Context, request *proto.OrderRe
|
||||||
var response *po.OrderResp
|
var response *po.OrderResp
|
||||||
sp = helper.ToChinese(sp)
|
sp = helper.ToChinese(sp)
|
||||||
if err = json.Unmarshal([]byte(sp), &response); err != nil {
|
if err = json.Unmarshal([]byte(sp), &response); err != nil {
|
||||||
return nil, fmt.Errorf("请求异常,msg:" + err.Error())
|
return nil, fmt.Errorf("请求解析异常,msg:" + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return orderResp(request, response), nil
|
return orderResp(request, response), nil
|
||||||
|
@ -86,7 +86,7 @@ func (s *AlipayRedPackService) Query(ctx context.Context, request *proto.QueryRe
|
||||||
var response po.QueryResp
|
var response po.QueryResp
|
||||||
sp = helper.ToChinese(sp)
|
sp = helper.ToChinese(sp)
|
||||||
if err = json.Unmarshal([]byte(sp), &response); err != nil {
|
if err = json.Unmarshal([]byte(sp), &response); err != nil {
|
||||||
return nil, fmt.Errorf("请求异常,msg:" + err.Error())
|
return nil, fmt.Errorf("请求解析异常,msg:" + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return queryResp(request, response), nil
|
return queryResp(request, response), nil
|
||||||
|
|
|
@ -27,8 +27,7 @@ func orderReq(order *proto.OrderRequest_Order, product *proto.OrderRequest_Produ
|
||||||
}
|
}
|
||||||
var extra Extra
|
var extra Extra
|
||||||
if order.Extra != nil {
|
if order.Extra != nil {
|
||||||
err := json.Unmarshal(order.Extra, &extra)
|
if err := json.Unmarshal(order.Extra, &extra); err != nil {
|
||||||
if err != nil {
|
|
||||||
return cashcoupons.SendCouponRequest{}, fmt.Errorf("order拓展参数 json unmarshal error: %v", err)
|
return cashcoupons.SendCouponRequest{}, fmt.Errorf("order拓展参数 json unmarshal error: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,10 +35,10 @@ func TestOrder(t *testing.T) {
|
||||||
Order: &proto.OrderRequest_Order{
|
Order: &proto.OrderRequest_Order{
|
||||||
OrderNo: "240403164049635931",
|
OrderNo: "240403164049635931",
|
||||||
Account: "oO3vO5AxRWgTjmMD38FTvnB5Rq6o",
|
Account: "oO3vO5AxRWgTjmMD38FTvnB5Rq6o",
|
||||||
Extra: []byte(`{"app_id":"13100720242","stock_creator_mchid":"1605446142"`),
|
Extra: []byte(`{"app_id":"13100720242","stock_creator_mchid":"1605446142"}`),
|
||||||
},
|
},
|
||||||
Product: &proto.OrderRequest_Product{
|
Product: &proto.OrderRequest_Product{
|
||||||
ProductNo: "3102024032977191",
|
ProductNo: "3102024032977191_11",
|
||||||
Extra: []byte(`{}`),
|
Extra: []byte(`{}`),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue