1
This commit is contained in:
@@ -1,5 +1,17 @@
|
||||
package mtwmapi
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
type Bill struct {
|
||||
AppPoiCode string `json:"app_poi_code"` // APP方门店id,传商家中台系统里门店的编码。如商家在操作绑定门店至开放平台应用中时,未绑定三方门店id信息,则默认APP方门店id与美团门店id相同。
|
||||
StartDate int64 `json:"start_date"` // 秒级时间戳
|
||||
EndDate int64 `json:"end_date"` // 秒级时间戳
|
||||
Offset int64 `json:"offset"`
|
||||
Limit int64 `json:"limit"`
|
||||
}
|
||||
|
||||
// GetStoreBillList 获取门店的订单账单
|
||||
/*
|
||||
1.金额类字段单位使用“分”
|
||||
@@ -13,8 +25,17 @@ package mtwmapi
|
||||
3)想要实现的效果;
|
||||
4)预计开发周期和上线时间;
|
||||
5)商家公司授权开通日账单接口的证明。(点击下载授权证明模板,授权证明以附件形式提供。)*/
|
||||
func (a *API) GetStoreBillList() {
|
||||
func (a *API) GetStoreBillList(param *Bill) (*StoreBillListRes, error) {
|
||||
result, err := a.AccessAPI3("bill/list", true, utils.Struct2Map(param, "", false))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var data *StoreBillListRes
|
||||
if err := utils.Map2StructByJson(result, &data, false); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
// StoreBillListReq 门店结算查询条件
|
||||
@@ -28,7 +49,8 @@ type StoreBillListReq struct {
|
||||
|
||||
// StoreBillListRes 门店结算返回值
|
||||
type StoreBillListRes struct {
|
||||
ExtraInfo ExtraInfoData `json:"extra_info"`
|
||||
ExtraInfo ExtraInfoData `json:"extra_info"`
|
||||
Data []*BillListData `json:"data"`
|
||||
}
|
||||
|
||||
type ExtraInfoData struct {
|
||||
|
||||
26
platformapi/mtwmapi/bill_list_test.go
Normal file
26
platformapi/mtwmapi/bill_list_test.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package mtwmapi
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestBillList(t *testing.T) {
|
||||
now := time.Now()
|
||||
from := time.Date(now.Year(), now.Month(), now.Day()-5, 0, 0, 0, 0, time.Local)
|
||||
to := time.Date(now.Year(), now.Month(), now.Day()-5, 23, 59, 59, 59, time.Local)
|
||||
param := &Bill{
|
||||
AppPoiCode: "16967920",
|
||||
StartDate: from.Unix(),
|
||||
EndDate: to.Unix(),
|
||||
Offset: 0,
|
||||
Limit: 200,
|
||||
}
|
||||
|
||||
data, _ := api.GetStoreBillList(param)
|
||||
globals.SugarLogger.Debugf("data := %s", utils.Format4Output(data.Data[0], false))
|
||||
// performanceServiceFee 订单配送费
|
||||
// userPayShippingAmount 用户支付配送费
|
||||
}
|
||||
@@ -245,11 +245,21 @@ func (a *API) AccessAPI3(cmd string, isGet bool, bizParams map[string]interface{
|
||||
// 不管有无错误,都尝试取得数据(因为有出错,但有有效数据返回的情况),比如ecommerce/order/getOrderIdByDaySeq
|
||||
retVal = jsonResult1
|
||||
if errObj, ok := jsonResult1["data"]; ok {
|
||||
errorInfo := errObj.(string)
|
||||
if errorInfo != "ok" {
|
||||
newErr := utils.NewErrorIntCode(jsonResult1["error_list"].([]interface{})[0].(map[string]interface{})["msg"].(string), int(utils.MustInterface2Int64(jsonResult1["error_list"].([]interface{})[0].(map[string]interface{})["code"])))
|
||||
return errLevel, newErr
|
||||
switch errObj.(type) {
|
||||
case string:
|
||||
errorInfo := errObj.(string)
|
||||
if errorInfo != "ok" {
|
||||
var newErr *utils.ErrorWithCode
|
||||
if cmd == "bill/list" {
|
||||
newErr = utils.NewErrorIntCode(jsonResult1["error"].(interface{}).(map[string]interface{})["msg"].(string), int(utils.MustInterface2Int64(jsonResult1["error"].(interface{}).(map[string]interface{})["code"])))
|
||||
} else {
|
||||
newErr = utils.NewErrorIntCode(jsonResult1["error_list"].([]interface{})[0].(map[string]interface{})["msg"].(string), int(utils.MustInterface2Int64(jsonResult1["error_list"].([]interface{})[0].(map[string]interface{})["code"])))
|
||||
}
|
||||
return errLevel, newErr
|
||||
}
|
||||
case interface{}:
|
||||
}
|
||||
|
||||
}
|
||||
return platformapi.ErrLevelSuccess, nil
|
||||
})
|
||||
|
||||
@@ -20,13 +20,13 @@ func init() {
|
||||
baseapi.Init(sugarLogger)
|
||||
|
||||
// 菜市
|
||||
//api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "")
|
||||
api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "")
|
||||
|
||||
// 果园
|
||||
// api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "")
|
||||
|
||||
//商超
|
||||
api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_n4TwqCntWWuvQwAawzxC0w") //token_n4TwqCntWWuvQwAawzxC0w
|
||||
//api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_n4TwqCntWWuvQwAawzxC0w") //token_n4TwqCntWWuvQwAawzxC0w
|
||||
cookieStr := `
|
||||
acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1;
|
||||
`
|
||||
@@ -42,7 +42,7 @@ func TestAccessAPI(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetOAuthCode(t *testing.T) {
|
||||
result, err := api.GetOAuthCode("12422751")
|
||||
result, err := api.GetOAuthCode("17395411")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -60,7 +60,7 @@ func TestGetAccessToken(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetAccessToken2(t *testing.T) {
|
||||
result, err := api.GetAccessToken2("17371124") //refresh_token_pLG7Jw7g9mu7oOzNSuJIUg
|
||||
result, err := api.GetAccessToken2("17395411") //refresh_token_pLG7Jw7g9mu7oOzNSuJIUg
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -46,8 +46,8 @@ func TestPoiSave(t *testing.T) {
|
||||
//utils.FilterMapNilMembers(utils.Struct2FlatMap(result[0]))
|
||||
//poiParams["address"] = "成都市温江区柳城学海路585号"
|
||||
//poiParams["pic_url"] = "http://image.jxc4.com/image/5c9fc4fffb4d5ff1aecf85a2d2543e00.jpg"
|
||||
poiParams["name"] = "京西到家(犀浦店)"
|
||||
err := api.PoiSave("17371124", poiParams)
|
||||
poiParams["name"] = "京西菜市(礼嘉桥村市场店)"
|
||||
err := api.PoiSave("17395411", poiParams)
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
// "authority_id": ""
|
||||
//}`
|
||||
|
||||
var token = `{"access_token":"b558d5bd-d55d-4322-8602-85ba449cbc79","expires_in":1681667840,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"3a3c0ad2-bcbd-4f55-b7af-6b406dabc47a","authority_id":""}`
|
||||
var token = `{"access_token":"c2c6e258-847d-4e8f-a695-b20488a5a667","expires_in":1682270239,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"ebf0e9f1-b200-47c2-a2bb-bafefbdaed47","authority_id":""}`
|
||||
|
||||
//var token = `{"access_token":"e3173e9f-266f-4d87-88e7-e7cd837bc9d9","expires_in":1672882632,"scope":"SCOPE","shop_id":68023619,"shop_name":"京西到家","refresh_token":"5070aae2-493f-46bd-b5d6-6ea0cd64729f","authority_id":""}`
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ func (a *API) UpdateSkuStock(param *sku_syncStock_request.SkuSyncStockParam) err
|
||||
return err
|
||||
}
|
||||
if resp.Code != RequestSuccessCode {
|
||||
return errors.New(resp.Msg)
|
||||
return errors.New(resp.SubMsg)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -62,9 +62,9 @@ func TestGetSkuDetailLocalId(t *testing.T) {
|
||||
|
||||
func TestUpdateSkuStore(t *testing.T) {
|
||||
err := a.UpdateSkuStock(&sku_syncStock_request.SkuSyncStockParam{
|
||||
ProductId: 3605142143867471418,
|
||||
OutSkuId: 6045168,
|
||||
StockNum: 2,
|
||||
ProductId: 3612015462742906941,
|
||||
OutSkuId: 6094281,
|
||||
StockNum: 9999,
|
||||
Incremental: false,
|
||||
})
|
||||
fmt.Println(err)
|
||||
|
||||
Reference in New Issue
Block a user