Merge branch 'master' of https://e.coding.net/rosydev/baseapi
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package ebaiapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -20,29 +18,29 @@ func TestAPI_GetImOnlineStatus(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestParseMultilayerJson(t *testing.T) {
|
||||
//var data1 = `{"subBizType": "SEND_MESSAGE","bizType": "IM","payload": {"senderId":"20235760123","receiverIds":["105872382789","30506545123","20235760456"],"createTime":1642647893901,"groupId":"$2$10514249123$PNM","msgId": "1654907240123.PNM","contentType": "1","content":"{"text":"测试消息"}"},"platformShopId": "32267818868"}`
|
||||
var data8 = `{
|
||||
"subBizType": "SEND_MESSAGE",
|
||||
"bizType": "IM",
|
||||
"payload": {
|
||||
"senderId": "102000022769889",
|
||||
"receiverIds": ["102000022769889", "30507511668"],
|
||||
"createTime": 1680579669946,
|
||||
"groupId": "$2$10996707119$PNM",
|
||||
"msgId": "1734454964456.PNM",
|
||||
"contentType": 8,
|
||||
"content": "{\"elements\":[{\"elementContent\":\"{\\\"atAll\\\":false,\\\"defaultNick\\\":\\\"\\\",\\\"uid\\\":{\\\"appUid\\\":\\\"30507511668\\\",\\\"domain\\\":\\\"eleme\\\"}}\",\"elementType\":3},{\"elementContent\":\"{\\\"extensions\\\":{},\\\"text\\\":\\\"@商家 我选的就是退一个杯子呀\\\"}\",\"elementType\":1}]}"
|
||||
},
|
||||
"platformShopId": "507511668"
|
||||
}`
|
||||
//retVal1 := ParseMultilayerJson(data1)
|
||||
//fmt.Println(utils.Format4Output(retVal1, false))
|
||||
//retVal8 := ParseMultilayerJson(data8)
|
||||
//fmt.Println(utils.Format4Output(retVal8, false))
|
||||
temp := ImMessageSent{}
|
||||
err := json.Unmarshal([]byte(data8), &temp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println(temp)
|
||||
// //var data1 = `{"subBizType": "SEND_MESSAGE","bizType": "IM","payload": {"senderId":"20235760123","receiverIds":["105872382789","30506545123","20235760456"],"createTime":1642647893901,"groupId":"$2$10514249123$PNM","msgId": "1654907240123.PNM","contentType": "1","content":"{"text":"测试消息"}"},"platformShopId": "32267818868"}`
|
||||
// var data8 = `{
|
||||
// "subBizType": "SEND_MESSAGE",
|
||||
// "bizType": "IM",
|
||||
// "payload": {
|
||||
// "senderId": "102000022769889",
|
||||
// "receiverIds": ["102000022769889", "30507511668"],
|
||||
// "createTime": 1680579669946,
|
||||
// "groupId": "$2$10996707119$PNM",
|
||||
// "msgId": "1734454964456.PNM",
|
||||
// "contentType": 8,
|
||||
// "content": "{\"elements\":[{\"elementContent\":\"{\\\"atAll\\\":false,\\\"defaultNick\\\":\\\"\\\",\\\"uid\\\":{\\\"appUid\\\":\\\"30507511668\\\",\\\"domain\\\":\\\"eleme\\\"}}\",\"elementType\":3},{\"elementContent\":\"{\\\"extensions\\\":{},\\\"text\\\":\\\"@商家 我选的就是退一个杯子呀\\\"}\",\"elementType\":1}]}"
|
||||
// },
|
||||
// "platformShopId": "507511668"
|
||||
//}`
|
||||
// //retVal1 := ParseMultilayerJson(data1)
|
||||
// //fmt.Println(utils.Format4Output(retVal1, false))
|
||||
// //retVal8 := ParseMultilayerJson(data8)
|
||||
// //fmt.Println(utils.Format4Output(retVal8, false))
|
||||
// temp := ImMessageSent{}
|
||||
// err := json.Unmarshal([]byte(data8), &temp)
|
||||
// if err != nil {
|
||||
// fmt.Println(err)
|
||||
// }
|
||||
// fmt.Println(temp)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ebaiapi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
@@ -618,11 +619,13 @@ func (a *API) OrderAgreeReturnGoods(orderID, refundOrderID string) (err error) {
|
||||
|
||||
//售后 拒绝退货退款
|
||||
func (a *API) OrderDisagreeReturnGoods(orderID, refundOrderID, reason string) (err error) {
|
||||
_, err = a.AccessAPI("order.disagreereturngoods", map[string]interface{}{
|
||||
data, err := a.AccessAPI("order.disagreereturngoods", map[string]interface{}{
|
||||
"order_id": orderID,
|
||||
"refund_order_id": refundOrderID,
|
||||
"reason": reason,
|
||||
"refuse_code": "5",
|
||||
"refuse_reason": reason,
|
||||
})
|
||||
fmt.Println(data)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,11 @@ import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
func TestCancelOrder(t *testing.T) {
|
||||
err := api.OrderDisagreeReturnGoods("4007560108986061407", "1939575364735607", "1")
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
func TestOrderGet(t *testing.T) {
|
||||
result, err := api.OrderGet("4055150105296238277")
|
||||
if err != nil {
|
||||
|
||||
@@ -4,6 +4,12 @@ import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
BillChargeTypeOrder = 1 // 外卖订单
|
||||
BillChargeTypeWayBillFee = 3 // 配送费
|
||||
BillChargeTypeTimingFee = 10 // 定时宝,保险费
|
||||
)
|
||||
|
||||
type Bill struct {
|
||||
AppPoiCode string `json:"app_poi_code"` // APP方门店id,传商家中台系统里门店的编码。如商家在操作绑定门店至开放平台应用中时,未绑定三方门店id信息,则默认APP方门店id与美团门店id相同。
|
||||
StartDate int64 `json:"start_date"` // 秒级时间戳
|
||||
@@ -25,17 +31,46 @@ type Bill struct {
|
||||
3)想要实现的效果;
|
||||
4)预计开发周期和上线时间;
|
||||
5)商家公司授权开通日账单接口的证明。(点击下载授权证明模板,授权证明以附件形式提供。)*/
|
||||
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
|
||||
func (a *API) GetStoreBillList(param *Bill) (map[string]*SettleOrderList, error) {
|
||||
orderSettle := make(map[string]*SettleOrderList, 0)
|
||||
|
||||
for {
|
||||
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
|
||||
}
|
||||
|
||||
for _, v := range data.Data {
|
||||
settle, ok := orderSettle[v.WmOrderViewId]
|
||||
if !ok {
|
||||
settle = &SettleOrderList{OrderId: v.WmOrderViewId}
|
||||
}
|
||||
switch v.BillChargeType {
|
||||
case BillChargeTypeOrder: // 平台结算
|
||||
settle.PlatformSettlement = v.SettleAmount
|
||||
case BillChargeTypeWayBillFee: // 运费
|
||||
settle.DeliveryFee = v.SettleAmount
|
||||
case BillChargeTypeTimingFee: // 定时宝
|
||||
settle.TimingFee = v.SettleAmount
|
||||
default:
|
||||
continue
|
||||
}
|
||||
orderSettle[v.WmOrderViewId] = settle
|
||||
}
|
||||
|
||||
if int64(data.ExtraInfo.TotalCount) >= (param.Offset * param.Limit) {
|
||||
param.Offset += param.Limit
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
var data *StoreBillListRes
|
||||
if err := utils.Map2StructByJson(result, &data, false); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return data, nil
|
||||
return orderSettle, nil
|
||||
}
|
||||
|
||||
// StoreBillListReq 门店结算查询条件
|
||||
@@ -49,8 +84,8 @@ type StoreBillListReq struct {
|
||||
|
||||
// StoreBillListRes 门店结算返回值
|
||||
type StoreBillListRes struct {
|
||||
ExtraInfo ExtraInfoData `json:"extra_info"`
|
||||
Data []*BillListData `json:"data"`
|
||||
ExtraInfo ExtraInfoData `json:"extra_info"`
|
||||
Data []BillListData `json:"data"`
|
||||
}
|
||||
|
||||
type ExtraInfoData struct {
|
||||
@@ -123,7 +158,7 @@ type WmAppOrderSkuBenefitDetailList struct {
|
||||
}
|
||||
|
||||
type wmAppOrderActDetails struct {
|
||||
actId int64 `json:"act_id"` // 商品参与活动的活动id
|
||||
ActId int64 `json:"act_id"` // 商品参与活动的活动id
|
||||
MTType int `json:"type"` // 参与活动的活动类型,参考值:1-首单立减;2-满减优惠;4-套餐惠赠优惠;9-美团红包;11-提前下单减优惠;17-折扣商品;18-美团专送再减;20-第二份半价优惠;22-门店新客立减;27-指定商品满减;40-加价购;43-X元M件;46-超值换购;66-会员折扣商品;101-商家代金券优惠;117-商品优惠券;118-商品折扣券;900-首单红包优惠。
|
||||
PoiCharge float64 `json:"poiCharge"` // 本活动id及活动类型下商家承担的金额,单位分。
|
||||
}
|
||||
@@ -132,12 +167,20 @@ type MedicalInsuranceFee struct {
|
||||
Name string `json:"name"` // 商品名称。
|
||||
SkuId string `json:"sku_id"` // 商品sku的规格编码,SKU码/货号。
|
||||
Count int `json:"count"` // 商品数量 注:当字段count=0时,此账单记录为商家发起的按重量退差价,但结算类型仍为“26-闪购品类订单部分退款”(billChargeType=26)。
|
||||
totalOriginPrice float64 `json:"totalOriginPrice"` // 商品原价总价(含商品包装盒费),单位分。
|
||||
totalPoiCharge float64 `json:"totalPoiCharge"` // 配送费优惠商家承担总金额,单位分。
|
||||
wmAppOrderShippingActDetailList []wmAppOrderShippingActDetailList `json:"wmAppOrderShippingActDetailList"` // sku商品参与的配送费活动详情。
|
||||
TotalOriginPrice float64 `json:"totalOriginPrice"` // 商品原价总价(含商品包装盒费),单位分。
|
||||
TotalPoiCharge float64 `json:"totalPoiCharge"` // 配送费优惠商家承担总金额,单位分。
|
||||
WmAppOrderShippingActDetailList []wmAppOrderShippingActDetailList `json:"wmAppOrderShippingActDetailList"` // sku商品参与的配送费活动详情。
|
||||
}
|
||||
|
||||
type wmAppOrderShippingActDetailList struct {
|
||||
MTType int `json:"type"` // 参与配送费活动的活动类型,参考值:9-美团红包,21-会员免配送费,25-立减配送费,30-满减配送费,36-新人减配送费,54-新客专享减配送费,59-新客专享减配送费,300-商家会员减配送费,302-预订单减配送费,304-减免运费券,101-商家代金券优惠,305-津贴优惠。
|
||||
PoiCharge float64 `json:"poiCharge"` // 商家承担金额,单位分。
|
||||
}
|
||||
|
||||
// SettleOrderList 返回值
|
||||
type SettleOrderList struct {
|
||||
OrderId string `json:"order_id"` // 订单id
|
||||
TimingFee int64 `json:"timing_fee"` // 准时保险费
|
||||
DeliveryFee int64 `json:"delivery_fee"` // 配送费
|
||||
PlatformSettlement int64 `json:"platform_settlement"` // 平台结算金额
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package mtwmapi
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
|
||||
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)
|
||||
from := time.Date(now.Year(), now.Month(), now.Day()-8, 0, 0, 0, 0, time.Local)
|
||||
to := time.Date(now.Year(), now.Month(), now.Day()-2, 23, 59, 59, 59, time.Local)
|
||||
param := &Bill{
|
||||
AppPoiCode: "16967920",
|
||||
StartDate: from.Unix(),
|
||||
@@ -19,8 +19,19 @@ func TestBillList(t *testing.T) {
|
||||
Limit: 200,
|
||||
}
|
||||
|
||||
data, _ := api.GetStoreBillList(param)
|
||||
globals.SugarLogger.Debugf("data := %s", utils.Format4Output(data.Data[0], false))
|
||||
// performanceServiceFee 订单配送费
|
||||
// userPayShippingAmount 用户支付配送费
|
||||
data, err := api.GetStoreBillList(param)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("err := %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
for _, v := range data {
|
||||
globals.SugarLogger.Debugf("OrderId : %s , TimingFee : %d , DeliveryFee : %d , PlatformSettlement : %d ", v.OrderId, v.TimingFee, v.DeliveryFee, v.PlatformSettlement)
|
||||
}
|
||||
}
|
||||
|
||||
func TestA1(t *testing.T) {
|
||||
a := -20
|
||||
fmt.Println(a * -1)
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ func init() {
|
||||
api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "")
|
||||
|
||||
// 果园
|
||||
// api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "")
|
||||
//api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "")
|
||||
|
||||
//商超
|
||||
//api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_n4TwqCntWWuvQwAawzxC0w") //token_n4TwqCntWWuvQwAawzxC0w
|
||||
|
||||
Reference in New Issue
Block a user