饿先达扒网页接口,微信支付新增接口

This commit is contained in:
苏尹岚
2020-02-12 15:15:34 +08:00
parent 46ede7c9c5
commit 661c9aba89
7 changed files with 269 additions and 39 deletions

View File

@@ -101,7 +101,7 @@ func (a *API) BegetActivityList(showStatus, activityType int, baiduShopID, suppl
}
for {
params["curpage"] = pageNo
retVal, err2 := a.AccessStorePage("commodity/activity/begetactivitylist", params, false)
retVal, err2 := a.AccessStorePage("commodity/activity/begetactivitylist", "", params, false)
if err = err2; err == nil {
var listInfo *PageActListInfo
if err = utils.Map2StructByJson(retVal, &listInfo, true); err != nil {
@@ -136,7 +136,7 @@ func (a *API) BegetActSkuList(activityID, baiduShopID, supplierID int64) (actSku
}
for {
params["curpage"] = pageNo
retVal, err2 := a.AccessStorePage("commodity/activity/begetactskulist", params, false)
retVal, err2 := a.AccessStorePage("commodity/activity/begetactskulist", "", params, false)
if err = err2; err == nil {
var pageActivityInfo *PageActivityInfo
if err = utils.Map2StructByJson(retVal, &pageActivityInfo, true); err != nil {

View File

@@ -22,6 +22,7 @@ const (
const (
ResponseCodeSuccess = 0
ResponseCodeSuccess2 = 200
GetStoreSuccessButUnderfind = 4001 // 拉取网页饿百门店信息,但是显示门店不存在
ResponseCodeCallElmFailed = 2101 // 这个可以尝试重试
)

View File

@@ -26,16 +26,19 @@ func init() {
sugarLogger = logger.Sugar()
baseapi.Init(sugarLogger)
// sandbox果园测试门店
api = New("62289", "d3ec2358d6a819ea")
// api = New("62289", "d3ec2358d6a819ea")
// 京西菜市
// api = New("34665", "c3db75b754ea2d89")
api = New("34665", "c3db75b754ea2d89")
// 京西果园
// api = New("35957", "10013fbb7c2ddad7")
api.SetCookie("PASSPORT_DELIMONT_TOKEN", "PBE_2.0_5cd1c6141c127d4188f026ac01fc93656266683e8dfb3127c2fdf894259e9034125ff3bdd2a997a385802ee3ef1802ba93a04acea34fde2d2b6e802c5dcd4ec6e3f4ad909a1d806e3ceeb349ed726b03d60ed1fe7010d4140aa338d9c5f05e3fec172c78d3d7f0ca579d61b7015af1bf99aa46b04d2b8a64aa50646dc09afe94b6b60e0ba9a933635db5e8b2a035e9b6d693b289acf1b256d5b9a3f8478c87b0b009115bfd1394f20bb5a0dc2c07b8d013a25f286ec6bf7f2d86010d65507e31358834b7a6b58fbd88cb3f1a12cf71c997b91c1527f6f3c10693f7c2bd6073da8633a98cd2dc1114dfa5be5ee0e60b02cf7e4a94d0fb563a8c01717e7c050f02249117219c07a2eb211577c208ba77f4d536fa25139bc249be93b38d6fc495ef67a32aa206835d177db402bc534de1d29caf4f6b4fbcd912c13f167d00d1732222744c336a5189728f72fb5e153c4b1164171cfb0c811f34f4c2fedd43f721b8706b43f8d631251c")
api.SetCookie("WMUSS", "4AAPQCAAB5PF0aUGcBVzoRTCEkOFhFIhx-Yk9vN2EfPHYoLlROKBEsQmAUQjhNUgRt0ADAP5x-RFklwAAdjxGO11iOj8xKXYSSDIJb2BcPghsaklNfQwGS10JOVRFfhAiYElhEXFXIzoJKyloCGdwdFE6Qk9FRxojUFN3FVEHNjJPZJu4Bt9nxQ13cwoMbjA")
api.SetCookie("WMSTOKEN", "AcAANQZAABbC04rUBZFc2UYanlocDAaP0dcfzZCeS1SHQ1qJ15ExgAA13A2dGLjdbcitBZJu4Bn6B_g6cZAAA0tyyFm8cdBaNAQAAwug8HTG0xRjwt1UZzbcAAN7ofRO")
// api.SetCookieWithStr(`
// PASSPORT_DELIMONT_TOKEN=PBE_2.0_5cd1c6141c127d4188f026ac01fc93656266683e8dfb3127c2fdf894259e9034125ff3bdd2a997a385802ee3ef1802ba93a04acea34fde2d2b6e802c5dcd4ec6e3f4ad909a1d806e3ceeb349ed726b03d60ed1fe7010d4140aa338d9c5f05e3fec172c78d3d7f0ca579d61b7015af1bf99aa46b04d2b8a64aa50646dc09afe94b6b60e0ba9a933635db5e8b2a035e9b6d693b289acf1b256d5b9a3f8478c87b0b009115bfd1394f20bb5a0dc2c07b8d013a25f286ec6bf7f2d86010d65507e31358834b7a6b58fbd88cb3f1a12cf71c997b91c1527f6f3c10693f7c2bd6073da8633a98cd2dc1114dfa5be5ee0e60b02cf7e4a94d0fb563a8c01717e7c050f02249117219c07a2eb211577c208ba77f4d536fa25139bc249be93b38d6fc495ef67a32aa206835d177db402bc534de1d29caf4f6b4fbcd912c13f167d00d1732222744c336a5189728f72fb5e153c4b1164171cfb0c811f34f4c2fedd43f721b8706b43f8d631251c
// `)
}
func TestTest(t *testing.T) {

View File

@@ -1,6 +1,7 @@
package ebaiapi
import (
"encoding/json"
"fmt"
"net/http"
"strings"
@@ -375,19 +376,114 @@ type StoreShowWindowSkuList struct {
SkuStatus int `json:"sku_status"`
}
func (a *API) AccessStorePage2(subURL string, params map[string]interface{}, isPost bool, cookies map[string]string) (retVal map[string]interface{}, err error) {
type ExianDaSkus struct {
Category string `json:"category"`
CustomGoodsCode interface{} `json:"customGoodsCode"`
CustomGoodsID int `json:"customGoodsId"`
ElemeGoodsCode string `json:"elemeGoodsCode"`
ElemeGoodsID string `json:"elemeGoodsId"`
ElemeOwnerCode string `json:"elemeOwnerCode"`
ElemeOwnerID int `json:"elemeOwnerId"`
ExtValues struct {
} `json:"extValues"`
GoodsID int `json:"goodsId"`
GoodsName string `json:"goodsName"`
ID int `json:"id"`
ImageURL string `json:"imageUrl"`
IsShelflife int `json:"isShelflife"`
IsWeight int `json:"isWeight"`
MeasurementUnitID int `json:"measurementUnitId"`
MeasurementUnitText string `json:"measurementUnitText"`
OperationType int `json:"operationType"`
OperationTypeName string `json:"operationTypeName"`
OwnerID string `json:"ownerId"`
OwnerName string `json:"ownerName"`
PurchaseUnitConversionRate string `json:"purchaseUnitConversionRate"`
PurchaseUnitID int `json:"purchaseUnitId"`
PurchaseUnitText string `json:"purchaseUnitText"`
Status int `json:"status"`
TaxRate string `json:"taxRate"`
UpcID string `json:"upcId"`
}
type ExianDaSku struct {
AdventLifeCycle interface{} `json:"adventLifeCycle"`
CategoryIDFirst int `json:"categoryIdFirst"`
CategoryIDSecond int `json:"categoryIdSecond"`
CategoryIDThird int `json:"categoryIdThird"`
CategoryText string `json:"categoryText"`
CreatedBy string `json:"createdBy"`
CustomGoodsCode interface{} `json:"customGoodsCode"`
CustomGoodsID int `json:"customGoodsId"`
ElemeGoodsCode string `json:"elemeGoodsCode"`
ElemeGoodsID string `json:"elemeGoodsId"`
ElemeOwnerCode string `json:"elemeOwnerCode"`
ElemeOwnerID int `json:"elemeOwnerId"`
ExtValues struct {
} `json:"extValues"`
GoodsID int `json:"goodsId"`
GoodsName string `json:"goodsName"`
GoodsType int `json:"goodsType"`
Height string `json:"height"`
ImageCOs []struct {
ExtValues struct {
} `json:"extValues"`
Seq int `json:"seq"`
URL string `json:"url"`
} `json:"imageCOs"`
IsDelete int `json:"isDelete"`
IsEstimateLifeCycle int `json:"isEstimateLifeCycle"`
IsShelflife int `json:"isShelflife"`
IsWeight int `json:"isWeight"`
Length string `json:"length"`
LifeCycle int `json:"lifeCycle"`
LockupLifeCycle interface{} `json:"lockupLifeCycle"`
MeasurementUnitID int `json:"measurementUnitId"`
MeasurementUnitText string `json:"measurementUnitText"`
NetWeight string `json:"netWeight"`
OperationType int `json:"operationType"`
OwnerID string `json:"ownerId"`
OwnerName string `json:"ownerName"`
PurchaseUnitConversionRate string `json:"purchaseUnitConversionRate"`
PurchaseUnitID int `json:"purchaseUnitId"`
PurchaseUnitText string `json:"purchaseUnitText"`
RejectLifeCycle interface{} `json:"rejectLifeCycle"`
Status int `json:"status"`
TaxRate string `json:"taxRate"`
TemperatureType int `json:"temperatureType"`
TenantID int `json:"tenantId"`
UpcIds []string `json:"upcIds"`
UpdatedBy interface{} `json:"updatedBy"`
Volume string `json:"volume"`
Weight string `json:"weight"`
Width string `json:"width"`
}
func (a *API) AccessStorePage2(subURL, storeURL2 string, params map[string]interface{}, isPost bool, cookies map[string]string) (retVal map[string]interface{}, err error) {
if a.GetCookieCount() == 0 {
return nil, fmt.Errorf("需要设置Store Cookie才能使用此方法")
}
err = platformapi.AccessPlatformAPIWithRetry(a.client,
func() *http.Request {
var request *http.Request
if !isPost {
request, _ = http.NewRequest(http.MethodGet, utils.GenerateGetURL(storeURL, subURL, params), nil)
var url string
if storeURL2 != "" {
url = storeURL2
} else {
request, _ = http.NewRequest(http.MethodPost, utils.GenerateGetURL(storeURL, subURL, nil), strings.NewReader(utils.Map2URLValues(params).Encode()))
request.Header.Set("charset", "UTF-8")
request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
url = storeURL
}
if !isPost {
request, _ = http.NewRequest(http.MethodGet, utils.GenerateGetURL(url, subURL, params), nil)
} else {
if storeURL2 != "" {
result, _ := json.MarshalIndent(params, "", " ")
request, _ = http.NewRequest(http.MethodPost, utils.GenerateGetURL(url, subURL, nil), strings.NewReader(string(result)))
request.Header.Set("Content-Type", "application/ncp4+json")
} else {
request, _ = http.NewRequest(http.MethodPost, utils.GenerateGetURL(url, subURL, nil), strings.NewReader(utils.Map2URLValues(params).Encode()))
request.Header.Set("charset", "UTF-8")
request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
}
}
a.FillRequestCookies(request)
for k, v := range cookies {
@@ -404,15 +500,20 @@ func (a *API) AccessStorePage2(subURL string, params map[string]interface{}, isP
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
}
retVal = jsonResult1
if storeURL2 != "" {
return platformapi.ErrLevelSuccess, nil
}
if jsonResult1["errno"] == nil {
if jsonResult1[platformapi.KeyData] == nil {
baseapi.SugarLogger.Warnf("ebai AccessStorePage2, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
} else {
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("%s return not json", subURL)
if storeURL2 == "" {
if jsonResult1[platformapi.KeyData] == nil {
baseapi.SugarLogger.Warnf("ebai AccessStorePage2, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
} else {
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("%s return not json", subURL)
}
}
}
code := int(utils.MustInterface2Int64(jsonResult1["errno"]))
if code == ResponseCodeSuccess {
if code == ResponseCodeSuccess || code == ResponseCodeSuccess2 {
if subURL == swithShopURL {
for _, v := range response.Cookies() {
if v.Name == "SWITCH_SHOP" {
@@ -435,8 +536,8 @@ func (a *API) AccessStorePage2(subURL string, params map[string]interface{}, isP
return retVal, err
}
func (a *API) AccessStorePage(subURL string, params map[string]interface{}, isPost bool) (retVal map[string]interface{}, err error) {
return a.AccessStorePage2(subURL, params, isPost, nil)
func (a *API) AccessStorePage(subURL, storeURL2 string, params map[string]interface{}, isPost bool) (retVal map[string]interface{}, err error) {
return a.AccessStorePage2(subURL, storeURL2, params, isPost, nil)
}
func (a *API) GetRealMobile4Order(orderId string) (mobile string, err error) {
@@ -450,7 +551,7 @@ func (a *API) GetRealMobile4Order(orderId string) (mobile string, err error) {
}
func (a *API) GetStoreOrderInfo(orderId string) (storeOrderInfo map[string]interface{}, err error) {
retVal, err := a.AccessStorePage("crm/orderlist", map[string]interface{}{
retVal, err := a.AccessStorePage("crm/orderlist", "", map[string]interface{}{
"keyword": orderId,
}, false)
if err == nil {
@@ -477,7 +578,7 @@ func (a *API) GetStoreOrderInfoList(fromTime, toTime string, shopID string, orde
}
for {
params["page"] = pageNo
retVal, err2 := a.AccessStorePage("crm/orderlist", params, false)
retVal, err2 := a.AccessStorePage("crm/orderlist", "", params, false)
if err = err2; err == nil {
resultList := retVal["order_list"].([]interface{})
storeOrderList = append(storeOrderList, utils.Slice2MapSlice(resultList)...)
@@ -521,7 +622,7 @@ func (a *API) getCommentList(isElm bool, fromTime, toTime time.Time, shopID, sup
}[1-utils.Bool2Int(isElm)])
for {
params["page_num"] = pageNo
retVal, err2 := a.AccessStorePage(fixedURL, params, false)
retVal, err2 := a.AccessStorePage(fixedURL, "", params, false)
if err = err2; err == nil {
for _, comment := range retVal["comment_list"].([]interface{}) {
commentMap := comment.(map[string]interface{})
@@ -562,7 +663,7 @@ func (a *API) PageGetSkuList(baiduShopID int64) (skuList []map[string]interface{
}
for {
params["curpage"] = pageNo
retVal, err2 := a.AccessStorePage("commodity/getskulist", params, false)
retVal, err2 := a.AccessStorePage("commodity/getskulist", "", params, false)
if err = err2; err == nil {
for _, sku := range retVal["sku_list"].([]interface{}) {
skuList = append(skuList, sku.(map[string]interface{}))
@@ -583,7 +684,7 @@ func (a *API) PageGetCustomSkuList(baiduShopID int64, customCatID int64) (skuLis
"wid": baiduShopID,
"custom_cat_id": customCatID,
}
retVal, err := a.AccessStorePage("commodity/getCustomSkuList", params, false)
retVal, err := a.AccessStorePage("commodity/getCustomSkuList", "", params, false)
if err == nil {
return utils.Slice2MapSlice(retVal["sku_list"].([]interface{})), nil
}
@@ -594,7 +695,7 @@ func (a *API) PageGetCustomCatList(baiduShopID int64) (catList []map[string]inte
params := map[string]interface{}{
"wid": baiduShopID,
}
retVal, err := a.AccessStorePage("commodity/GetCustomCatList", params, false)
retVal, err := a.AccessStorePage("commodity/GetCustomCatList", "", params, false)
if err == nil {
return utils.Slice2MapSlice(retVal["cat_list"].([]interface{})), nil
}
@@ -701,7 +802,7 @@ func (a *API) AccessStorePageNoCookie(subURL string, params map[string]interface
}
func (a *API) SwitchShop(baiduShopID int64) (switchShopCookie string, err error) {
result, err := a.AccessStorePage("crm/manager/switchshop", map[string]interface{}{
result, err := a.AccessStorePage("crm/manager/switchshop", "", map[string]interface{}{
"switch_shop_id": baiduShopID,
}, true)
if err == nil {
@@ -711,7 +812,7 @@ func (a *API) SwitchShop(baiduShopID int64) (switchShopCookie string, err error)
}
func (a *API) GetShopUserInfo2(switchShopCookie string) (shopUserInfo *PageShopUserInfo, err error) {
shopInfo, err := a.AccessStorePage2("crm/account/getshopuserinfo", nil, true, map[string]string{
shopInfo, err := a.AccessStorePage2("crm/account/getshopuserinfo", "", nil, true, map[string]string{
"SWITCH_SHOP": switchShopCookie,
})
if err == nil {
@@ -733,7 +834,7 @@ func (a *API) GetShopHealthByDetail2(switchShopCookie string) (shopHealthDetail
if err != nil {
return nil, err
}
result, err := a.AccessStorePage2("crm/getshophealthydetail", map[string]interface{}{
result, err := a.AccessStorePage2("crm/getshophealthydetail", "", map[string]interface{}{
"shop_id": shopInfo.EleID,
}, true, map[string]string{
"SWITCH_SHOP": switchShopCookie,
@@ -764,7 +865,7 @@ func (a *API) GetShopListByPage(status, proxyBusinessState, pageCount, pageNum i
"pageCount": pageCount,
"pageNum": pageNum,
}
retVal, err := a.AccessStorePage("crm/suppliershopstatus", params, false)
retVal, err := a.AccessStorePage("crm/suppliershopstatus", "", params, false)
if err == nil {
utils.Map2StructByJson(retVal["shop_list"], &shopList, true)
totalCount = int(utils.MustInterface2Int64(retVal["total"]))
@@ -782,7 +883,7 @@ func (a *API) ModifyTip4OrderWaybill(orderID, elemeOrderID string, tip, zhongBao
"tip": tip,
"zhongbao_ask_price": zhongBaoAskPrice,
}
_, err = a.AccessStorePage("crm/modifytip", params, false)
_, err = a.AccessStorePage("crm/modifytip", "", params, false)
return err
}
@@ -791,7 +892,7 @@ func (a *API) GetStoresShowWindowSkus(baiduShopID int64) (storeShowWindowList []
params := map[string]interface{}{
"wid": baiduShopID,
}
result, err := a.AccessStorePage("crm/shop/getcurrshopwindow", params, true)
result, err := a.AccessStorePage("crm/shop/getcurrshopwindow", "", params, true)
if err == nil {
err2 := utils.Map2StructByJson(result["sku_list"], &storeShowWindowList, false)
if err2 != nil {
@@ -800,3 +901,54 @@ func (a *API) GetStoresShowWindowSkus(baiduShopID int64) (storeShowWindowList []
}
return storeShowWindowList, err
}
//获取饿鲜达商品库
func (a *API) GetExianDaSkuDepot() (results []*ExianDaSkus, err error) {
var (
pageNum = 1
pageSize = 200
)
params := map[string]interface{}{
"metas": map[string]interface{}{},
"params": map[string]interface{}{
"goodsListQry": map[string]interface{}{
"pageNum": pageNum,
"pageSize": pageSize,
},
},
}
for {
result, err := a.AccessStorePage("bwm_newretail.scm_ic/GoodsServiceI/findGoodsList", "https://ncp.ele.me", params, true)
if err != nil {
continue
}
if len(result) < pageSize {
break
}
if len(result) > 0 {
var exianDaSkus []*ExianDaSkus
utils.Map2StructByJson(result["data"], &exianDaSkus, false)
results = append(results, exianDaSkus...)
}
pageNum++
}
return results, err
}
//获取饿鲜达单个商品主要取分类id
func (a *API) GetExianDaSku(exdSkuID int64) (results *ExianDaSku, err error) {
params := map[string]interface{}{
"metas": map[string]interface{}{},
"params": map[string]interface{}{
"goodsGetQry": map[string]interface{}{
"elemeGoodsId": exdSkuID,
},
},
}
result, err := a.AccessStorePage("bwm_newretail.scm_ic/GoodsServiceI/findGoodsById", "https://ncp.ele.me", params, true)
if err != nil {
return results, err
}
utils.Map2StructByJson(result["data"], &results, false)
return results, err
}

View File

@@ -151,3 +151,13 @@ func TestGetStoresShowWindowSkus(t *testing.T) {
result, _ := api.GetStoresShowWindowSkus(32267089415)
t.Log(utils.Format4Output(result, false))
}
func TestGetExianDaSkuDepot(t *testing.T) {
result, _ := api.GetExianDaSkuDepot()
t.Log(utils.Format4Output(result, false))
}
func TestGetExianDaSku(t *testing.T) {
result, _ := api.GetExianDaSku(100000000000184645)
t.Log(utils.Format4Output(result, false))
}

View File

@@ -52,6 +52,7 @@ const (
Relation = "PARTNER"
AccountTypeWx = "PERSONAL_WECHATID"
AccountTypeOpen = "PERSONAL_OPENID"
CheckName = "NO_CHECK"
)
var (
@@ -59,6 +60,8 @@ var (
"secapi/pay/multiprofitsharing": "secapi/pay/multiprofitsharing",
"pay/profitsharingaddreceiver": "pay/profitsharingaddreceiver",
"pay/profitsharingremovereceiver": "pay/profitsharingremovereceiver",
"secapi/pay/profitsharingreturn": "secapi/pay/profitsharingreturn",
"secapi/pay/profitsharingfinish": "secapi/pay/profitsharingfinish",
}
)
@@ -324,7 +327,7 @@ type ProfitSharingReceiverResult struct {
type ReturnProfitSharingParam struct {
RequestBase
OrderID string `json:"order_id" xml:"order_id"`
// OrderID string `json:"order_id" xml:"order_id"`
OutOrderNo string `json:"out_order_no" xml:"out_order_no"`
OutReturnNo string `json:"out_return_no" xml:"out_return_no"`
ReturnAccountType string `json:"return_account_type" xml:"return_account_type"`
@@ -355,6 +358,30 @@ type ReturnProfitSharingResult struct {
FinishTime string `json:"finish_time" xml:"finish_time"`
}
type FinishProfitSharingParam struct {
RequestBase
TransactionID string `json:"transaction_id" xml:"transaction_id"`
OutOrderNo string `json:"out_order_no" xml:"out_order_no"`
Description string `json:"description" xml:"description"`
}
type FinishProfitSharingResult struct {
ReturnCode string `json:"return_code" xml:"return_code"`
ReturnMsg string `json:"return_msg" xml:"return_msg"`
ResultCode string `json:"result_code" xml:"result_code"`
ErrCode string `json:"err_code,omitempty" xml:"err_code,omitempty"`
ErrCodeDes string `json:"err_code_des,omitempty" xml:"err_code_des,omitempty"`
AppID string `json:"appid" xml:"appid"`
MchID string `json:"mch_id" xml:"mch_id"`
NonceStr string `json:"nonce_str" xml:"nonce_str"`
Sign string `json:"sign" xml:"sign"`
TransactionID string `json:"transaction_id" xml:"transaction_id"`
OutOrderNo string `json:"out_order_no" xml:"out_order_no"`
OrderID string `json:"order_id" xml:"order_id"`
}
func New(appID, appKey, mchID string, config ...*platformapi.APIConfig) *API {
curConfig := platformapi.DefAPIConfig
if len(config) > 0 {
@@ -616,7 +643,17 @@ func (a *API) DeleteProfitSharingReceiver(param *ProfitSharingReceiverParam) (re
//分账回退
//https://pay.weixin.qq.com/wiki/doc/api/allocation.php?chapter=27_7&index=7
func (a *API) ReturnProfitSharing(param *ReturnProfitSharingParam) (result *ReturnProfitSharingResult, err error) {
retVal, err := a.AccessAPI("pay/profitsharingreturn", param)
retVal, err := a.AccessAPI("secapi/pay/profitsharingreturn", param)
if err == nil {
err = a.translateResult(retVal, &result)
}
return result, err
}
//完结分账
//https://pay.weixin.qq.com/wiki/doc/api/allocation.php?chapter=27_5&index=6
func (a *API) FinishProfitSharing(param *FinishProfitSharingParam) (result *FinishProfitSharingResult, err error) {
retVal, err := a.AccessAPI("secapi/pay/profitsharingfinish", param)
if err == nil {
err = a.translateResult(retVal, &result)
}

View File

@@ -44,7 +44,7 @@ func TestCreateUnifiedOrder(t *testing.T) {
OutTradeNo: orderNo,
SpbillCreateIP: "114.114.114.114",
TradeType: TradeTypeNative,
TotalFee: 10,
TotalFee: 20,
ProfitSharing: OptYes,
})
if err != nil {
@@ -105,8 +105,8 @@ func TestXml2Json(t *testing.T) {
func TestMultiProfitSharing(t *testing.T) {
result, err := api.MultiProfitSharing(&MultiProfitSharingParam{
TransactionID: "4200000519202002065628033681",
OutOrderNo: "1895BA2948A411EA88B97824AF852DFE",
TransactionID: "4200000506202002122465150534",
OutOrderNo: "A18546A84D6111EA8D8A7824AF852DFE",
Receivers: `[{"type":"PERSONAL_OPENID","account":"ojWb10ND2JBY_hOic5phWQNChWC0","amount":1,"description":"分到个人"}]`,
})
if err != nil {
@@ -115,14 +115,25 @@ func TestMultiProfitSharing(t *testing.T) {
t.Log(utils.Format4Output(result, false))
}
func TestFinishProfitSharing(t *testing.T) {
result, err := api.FinishProfitSharing(&FinishProfitSharingParam{
TransactionID: "4200000506202002122465150534",
OutOrderNo: "A18546A84D6111EA8D8A7824AF852DFE",
Description: "测试",
})
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}
func TestTransfers(t *testing.T) {
orderNo := utils.GetUUID()
result, err := api.Transfers(&TransfersParam{
PartnerTradeNo: orderNo,
OpenID: "ojWb10ND2JBY_hOic5phWQNChWC0",
CheckName: "FORCE_CHECK",
ReUserName: "苏尹岚",
Amount: 10,
OpenID: "ojWb10M_8kV8NT0aZJa6A5umG1c8",
CheckName: "NO_CHECK",
Amount: 100,
Desc: "测试",
SpbillCreateIP: "114.114.114.114",
})
@@ -158,3 +169,19 @@ func TestDeleteProfitSharingReceiver(t *testing.T) {
}
t.Log(utils.Format4Output(result, false))
}
func TestReturnProfitSharing(t *testing.T) {
orderNo := utils.GetUUID()
result, err := api.ReturnProfitSharing(&ReturnProfitSharingParam{
OutOrderNo: "A18546A84D6111EA8D8A7824AF852DFE",
OutReturnNo: orderNo,
ReturnAccountType: "MERCHANT_ID",
ReturnAccount: "1390686702",
ReturnAmount: 1000,
Description: "测试",
})
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}