This commit is contained in:
邹宗楠
2023-04-23 15:44:48 +08:00
parent 76fb7fc028
commit 61d9da631c
8 changed files with 75 additions and 17 deletions

View File

@@ -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 {

View 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 用户支付配送费
}

View File

@@ -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
})

View File

@@ -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)
}

View File

@@ -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)
}