This commit is contained in:
邹宗楠
2022-06-06 15:54:37 +08:00
parent 0de07e5972
commit 50f2a5fcff
3 changed files with 16 additions and 11 deletions

View File

@@ -2,8 +2,6 @@ package tiktok
import (
"encoding/json"
"fmt"
"git.rosy.net.cn/baseapi/utils"
"io/ioutil"
"net/http"
)
@@ -22,16 +20,9 @@ func (a *API) GetCallbackMsg(request *http.Request) (call *DetailCallBackMessage
if err != nil {
return nil, nil, "", err
}
values, err := utils.HTTPBody2Values(data, false)
if err != nil {
return nil, nil, "", err
}
fmt.Println("====================data", string(data))
fmt.Println("====================data", values)
fmt.Println("====================data", utils.URLValues2Map(values))
payInfo := &CallBackResult{}
if err := utils.Map2StructByJson(utils.URLValues2Map(values), &payInfo, false); err != nil {
if err := json.Unmarshal(data, payInfo); err != nil {
return nil, nil, "", err
}

View File

@@ -87,7 +87,7 @@ type ReturnMoneyReq struct {
/***************回调****************/
type CallBackResult struct {
Timestamp int `json:"timestamp"` // Unix 时间戳10 位,整型数
Timestamp string `json:"timestamp"` // Unix 时间戳10 位,整型数
Nonce string `json:"nonce"` // 随机数
Msg string `json:"msg"` // 订单信息的 json 字符串
TypePay string `json:"type"` // 回调类型标记,支付成功回调为"payment"

View File

@@ -1,6 +1,7 @@
package tiktok
import (
"encoding/json"
"fmt"
"git.rosy.net.cn/baseapi"
"go.uber.org/zap"
@@ -56,3 +57,16 @@ func TestFMT(t *testing.T) {
fmt.Println(3&2 != 0)
fmt.Println(3&1 != 0)
}
func TestJieXi(t *testing.T) {
aa := "{\"msg\":\"{\\\"appid\\\":\\\"tta6a1d01c399f264201\\\",\\\"cp_orderno\\\":\\\"88392225672205\\\",\\\"cp_extra\\\":\\\"msg\\\",\\\"way\\\":\\\"1\\\",\\\"channel_no\\\":\\\"4307101087202206060852144781\\\",\\\"channel_gateway_no\\\":\\\"\\\",\\\"payment_order_no\\\":\\\"PCP2022060615343025356252572215\\\",\\\"out_channel_order_no\\\":\\\"4307101087202206060852144781\\\",\\\"total_amount\\\":2,\\\"status\\\":\\\"SUCCESS\\\",\\\"seller_uid\\\":\\\"70915459488196877170\\\",\\\"extra\\\":\\\"\\\",\\\"item_id\\\":\\\"\\\",\\\"paid_at\\\":1654500885,\\\"message\\\":\\\"\\\",\\\"order_id\\\":\\\"7106026546158143752\\\",\\\"trade_item_list\\\":null}\",\"msg_signature\":\"85d4b28842be7294f8440363735476f225fce095\",\"nonce\":\"1670\",\"timestamp\":\"1654500886\",\"type\":\"payment\"}"
payInfo := &CallBackResult{}
err := json.Unmarshal([]byte(aa), payInfo)
fmt.Println("err==========", err)
fmt.Println("payInfo===", payInfo.Msg)
callback := &DetailCallBackMessage{}
err2 := json.Unmarshal([]byte(payInfo.Msg), callback)
fmt.Println("err==========", err2)
fmt.Println("payInfo===", callback.PaymentOrderNo)
}