1
This commit is contained in:
73
platformapi/jdapi/go_query_test.go
Normal file
73
platformapi/jdapi/go_query_test.go
Normal file
@@ -0,0 +1,73 @@
|
||||
package jdapi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"golang.org/x/net/html"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGoQuery(t *testing.T) {
|
||||
urls := []string{"https://www.jxc4.com/?info=eyJjb2RlIjoiLTEiLCJkZXNjIjoi562+5ZCN5pe26Ze05oiz5Y+C5pWw6LaF5pe2IGxldmVsOjAsIGNvZGU6ODUzMDAyIiwiZGF0YSI6IiJ9#/ordermanager"} // 要爬取的网页链接
|
||||
|
||||
var wg sync.WaitGroup
|
||||
for _, url := range urls {
|
||||
wg.Add(1)
|
||||
go func(u string) {
|
||||
defer wg.Done()
|
||||
data, err := fetchPage(u)
|
||||
if err != nil {
|
||||
fmt.Println("Error fetching page:", err)
|
||||
return
|
||||
}
|
||||
// 解析页面数据
|
||||
links := parseLinks(data)
|
||||
fmt.Println("Links on", u, ":", links)
|
||||
}(url)
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func fetchPage(url string) (string, error) {
|
||||
res := &http.Response{Header: http.Header{}}
|
||||
res.Header.Add("token", "TOKEN.V2.2452A93EEB9111EC9B06525400E86DC0.20240527-150008.localpass.C0F204211BF611EF8C78525400E86DC0.[18981810340]")
|
||||
resp, err := http.Get(url)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
// 读取页面内容
|
||||
data, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(data), nil
|
||||
}
|
||||
|
||||
func parseLinks(data string) []string {
|
||||
// 使用golang.org/x/net/html包解析HTML页面,提取链接
|
||||
links := make([]string, 0)
|
||||
tokenizer := html.NewTokenizer(strings.NewReader(data))
|
||||
for {
|
||||
tokenType := tokenizer.Next()
|
||||
globals.SugarLogger.Debugf("=======tokenType := %s", utils.Format4Output(tokenType, false))
|
||||
if tokenType == html.ErrorToken {
|
||||
break
|
||||
}
|
||||
token := tokenizer.Token()
|
||||
if tokenType == html.StartTagToken && token.Data == "a" {
|
||||
for _, attr := range token.Attr {
|
||||
if attr.Key == "href" {
|
||||
links = append(links, attr.Val)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return links
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
// 京西速食(蔬菜)
|
||||
var token1 = `{"access_token":"66e0618f-8e6b-43f8-baae-a9ca4e549cd8","expires_in":1716948768,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市","refresh_token":"eb392238-7f20-4ae4-ab5d-0b22543cbc4a","authority_id":""}`
|
||||
var token1 = `{"access_token":"71480acc-92ff-4044-8848-a6a76d1ae186","expires_in":1717551716,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市","refresh_token":"98eab67a-fa88-442d-ba46-48a6dcf5a101","authority_id":""}`
|
||||
|
||||
// 美好菜市
|
||||
//var token1 = `{"access_token":"9a315a03-c737-4a82-ae52-c9a6ce827007","expires_in":1699490747,"scope":"SCOPE","shop_id":68032645,"shop_name":"美好菜市","refresh_token":"8334c006-5301-4d25-911b-4d8cc7b70ebb","authority_id":""}`
|
||||
@@ -19,7 +19,7 @@ var a = New("7267745202649957900", "51998fcf-d521-4553-8c0c-fa662c8dbd6e", token
|
||||
|
||||
// 查询售后单详情
|
||||
func TestAfsOrder(t *testing.T) {
|
||||
data, err := a.QueryAfsOrderDetail("146223529123133957", false)
|
||||
data, err := a.QueryAfsOrderDetail("146453779045950796", false)
|
||||
globals.SugarLogger.Debugf("data=%s", utils.Format4Output(data, false))
|
||||
globals.SugarLogger.Debugf("data=%s", err)
|
||||
}
|
||||
|
||||
@@ -100,9 +100,6 @@ func TestOrderStatusAndPsInfo(t *testing.T) {
|
||||
a.OrderStatusAndPsInfoNew(utils.Struct2MapByJson(riderInfo), "")
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//TiktokLogisticsORDERRECEIVED = "ORDER_RECEIVED" // 已接单
|
||||
//TiktokLogisticsRIDERARRIVED = "RIDER_ARRIVED" // 已到店
|
||||
//TiktokLogisticsRIDERPICKUP = "RIDER_PICK_UP" // 已取货
|
||||
//TiktokLogisticsDELIVERED = "DELIVERED" // 已送达
|
||||
func TestGetRefundAddressId(t *testing.T) {
|
||||
a.GetRefundAddressId(64250734)
|
||||
}
|
||||
|
||||
@@ -100,6 +100,36 @@ func (a *API) ApplyMarketAfterSale(skuOrderId, count int64, afterSaleReason int3
|
||||
// 501 7 6,27 同意补寄
|
||||
// 502 7 6 拒绝补寄
|
||||
func (a *API) AfterSaleOperate(refundType int32, refundId, remark string, storeId int64) error {
|
||||
//afsOrderDetail, err := a.QueryAfsOrderDetail(refundId, false)
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
//// 平台售后单状态
|
||||
//afterSaleType := afsOrderDetail.Data.ProcessInfo.AfterSaleInfo.AfterSaleType
|
||||
//afterSaleStatus := afsOrderDetail.Data.ProcessInfo.AfterSaleInfo.AfterSaleStatus
|
||||
//
|
||||
//switch afterSaleType {
|
||||
//case AfterSaleTypeAll: // 0
|
||||
// afterSaleStatusMap := map[int64]int{AfterSaleStatusApply: 1, AfterSaleStatusRefuse: 1, AfterSaleStatusLoading: 1, AfterSaleStatusSendBag: 1, AfterSaleStatusRefuseBag: 1}
|
||||
// if isAgree {
|
||||
// if afterSaleStatusMap[afterSaleStatus] == 1 {
|
||||
//
|
||||
// }
|
||||
// } else {
|
||||
//
|
||||
// }
|
||||
//case AfterSaleTypeSendPkgOnlyReturnMoney: // 1
|
||||
//case AfterSaleTypeReturnMoney: // 2
|
||||
//case AfterSaleTypeChangePkg: // 3
|
||||
//case AfterSaleTypeSystemCancel: // 4
|
||||
//case AfterSaleTypeUserCancel: // 5
|
||||
//case AfterSaleTypeInsuredPrice: // 6
|
||||
//case AfterSaleTypeReissue: // 7
|
||||
//case AfterSaleTypeService: // 8
|
||||
//default:
|
||||
// return fmt.Errorf("暂不支持的售后类型,请联系开发")
|
||||
//}
|
||||
|
||||
request := afterSale_operate_request.New()
|
||||
param := request.GetParams()
|
||||
param.Type = refundType
|
||||
@@ -109,10 +139,7 @@ func (a *API) AfterSaleOperate(refundType int32, refundId, remark string, storeI
|
||||
// 101同意退货申请(一次审核) 301 同意换货申请(一次审核) Logistics.ReceiverAddressId 或 Logistics.AfterSaleAddressDetail
|
||||
case AfterSaleEmuAgreeToReturnOneApply, AfterSaleEmuAgreeChangeGoodsOneApply: // 101 // 同意退货申请(一次审核) Logistics.ReceiverAddressId 或 Logistics.AfterSaleAddressDetail
|
||||
var paramList = afterSale_operate_request.ItemsItem{}
|
||||
addressId, err := a.GetRefundAddressId(storeId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
addressId, _ := a.GetRefundAddressId(storeId)
|
||||
paramList.AftersaleId = refundId
|
||||
logistics := &afterSale_operate_request.Logistics{}
|
||||
logistics.ReceiverAddressId = addressId
|
||||
|
||||
@@ -133,6 +133,7 @@ const (
|
||||
AfterSaleTypeUserCancel = 5 // 用户取消
|
||||
AfterSaleTypeInsuredPrice = 6 // 价保
|
||||
AfterSaleTypeReissue = 7 // 补寄
|
||||
AfterSaleTypeService = 8 // 维修
|
||||
)
|
||||
|
||||
// 订单售后退款商户操作枚举
|
||||
|
||||
Reference in New Issue
Block a user