Files
baseapi/platformapi/mtwmapi/order_test.go
邹宗楠 88c315d874 1
2024-06-28 15:42:23 +08:00

252 lines
6.0 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package mtwmapi
import (
"fmt"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/globals"
"math"
"strings"
"testing"
"time"
)
func TestOrderViewStatus(t *testing.T) {
result, err := api.OrderViewStatus(123)
if err != nil {
t.Fatal(err)
}
t.Log(result)
}
func TestTimne(t *testing.T) {
fmt.Println(utils.Interface2Int64WithDefault(1695292241, 0))
fmt.Println(getTimeFromTimestamp(utils.Interface2Int64WithDefault(1695292241, 0)))
}
func getTimeFromTimestamp(timeStamp int64) time.Time {
if timeStamp < 1538103149 { // 立即达订单给的是1而不是空01538103149不是特殊值只是一个任意之前的时间这样写可以处理
return utils.DefaultTimeValue
}
return utils.Timestamp2Time(timeStamp)
}
func TestOrderGetOrderDetail(t *testing.T) {
result, err := api.OrderGetOrderDetail(301135342863962437, false)
if err != nil {
t.Fatal(err)
}
globals.SugarLogger.Debugf("====%s", utils.Format4Output(result["poi_receive_detail_yuan"], false))
if len(result) == 0 {
t.Fatal("result should have value")
}
for k, v := range result {
fmt.Println(fmt.Sprintf("%s=%v", k, v))
}
//globals.SugarLogger.Debugf("%s", utils.Format4Output(result, false))
}
func TestJsuan(t *testing.T) {
fmt.Println(StandardPrice2Int2(-12.39))
}
func StandardPrice2Int2(value float64) int64 {
return int64(math.Round(value * 100))
}
func TestOrderGetPartRefundFoods(t *testing.T) {
result, err := api.OrderGetPartRefundFoods(93475541926981203)
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}
func TestOrderReceived(t *testing.T) {
err := api.OrderReceived(25236872740350976)
if err != nil {
t.Fatal(err)
}
}
func TestOrderConfirm(t *testing.T) {
err := api.OrderConfirm(2000844470023437537)
if utils.IsErrMatch(err, utils.Int2Str(ErrCodeOpFailed), []string{
"订单已经确认过了",
}) {
err = nil
} else {
globals.SugarLogger.Warnf("mtwm AcceptOrRefuseOrder orderID:%s failed with err:%v", "1", err)
}
if err != nil {
t.Fatal(err)
}
}
func TestOrderApplyPartRefund(t *testing.T) {
err := api.OrderApplyPartRefund(93495654059392270, "缺货", []*RefundSku{
&RefundSku{
AppFoodCode: "30831",
Count: 1,
},
})
if err != nil {
t.Fatal(err)
}
}
func TestOrderLogisticsStatus(t *testing.T) {
result, err := api.OrderLogisticsStatus(1100710754248464487)
if err != nil {
t.Fatal(err)
}
if result == nil {
t.Fatal("result should have value")
}
t.Log(utils.Format4Output(result, false))
}
func TestGetDeliveryPath(t *testing.T) {
data1, data2, err := api.GetDeliveryPath(1100718012566212160, "7290541")
fmt.Println(data1)
fmt.Println(data2)
fmt.Println(utils.Float64ToStr(float64(data1) / 1000000))
fmt.Println(utils.Float64ToStr(float64(data2) / 1000000))
fmt.Println(err)
}
func TestOrderLogisticsFee(t *testing.T) {
result, err := api.OrderLogisticsFee(1100709560902354698)
if err != nil {
t.Fatal(err)
}
if result == 0 {
t.Fatal("result should have value")
}
t.Log(utils.Format4Output(result, false))
}
func TestOrderBatchPullPhoneNumber(t *testing.T) {
result, err := api.OrderBatchPullPhoneNumber("5873_2705892", 0, MaxBatchPullPhoneNumberLimit)
t.Log(utils.Format4Output(result, false))
if err != nil {
t.Fatal(err)
}
}
func TestOrderGetRiderInfoPhoneNumber(t *testing.T) {
result, err := api.OrderGetRiderInfoPhoneNumber("8872485", 0, MaxBatchPullPhoneNumberLimit)
t.Log(utils.Format4Output(result, false))
if err != nil {
t.Fatal(err)
}
}
func TestGetOrderRefundDetail(t *testing.T) {
result, err := api.GetOrderRefundDetail(301135342863962437, 0)
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}
func TestGetOrderRefundDetail2(t *testing.T) {
result, err := api.GetOrderRefundDetail(601112850243823799, 0)
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}
func TestGetOrderActDetaill(t *testing.T) {
result, err := api.GetOrderActDetail([]*GetOrderActDetailParam{
&GetOrderActDetailParam{
OrderID: 69760842061320598,
// ActParam: []*GetOrderActDetailParamAct{
// &GetOrderActDetailParamAct{
// Type: 1,
// },
// },
},
})
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}
func TestGetOrderIdByDaySeq(t *testing.T) {
result, err := api.GetOrderIdByDaySeq("8050205", utils.Str2Time("2021-02-21"), 1, MaxGap4GetOrderIdByDaySeq)
t.Log(utils.Format4Output(result, false))
if err != nil {
t.Fatal(err)
}
}
func TestGetOrderIdByDaySeqSingle(t *testing.T) {
result, err := api.GetOrderIdByDaySeqSingle("17284266", utils.Time2Date(time.Now()), 1)
t.Log(utils.Format4Output(result, false))
if err != nil {
t.Fatal(err)
}
}
func TestOrderRefundReject(t *testing.T) {
err := api.OrderRefundReject(27058923254735296, "测试")
// t.Log(utils.Format4Output(result, false))
if err != nil {
t.Fatal(err)
}
}
func TestOrderRefundAgree(t *testing.T) {
err := api.OrderRefundAgree(27058922456066076, "测试")
// t.Log(utils.Format4Output(result, false))
if err != nil {
t.Fatal(err)
}
}
func TestOrderCancel(t *testing.T) {
err := api.OrderCancel(27058922397679200, "取消", 1)
// t.Log(utils.Format4Output(result, false))
if err != nil {
t.Fatal(err)
}
}
func TestAa2(t *testing.T) {
time := time.Now().Unix()
fmt.Println(api.signParams(apiURL+"/oauth/authorize?", map[string]interface{}{
"timestamp": time,
"app_id": "5873",
"app_poi_code": "12422751",
"response_type": "token",
}), time)
}
func TestDeleving(t *testing.T) {
err := api.OrderLogisticsChange2Self(148815413321281654)
fmt.Println(strings.Contains(err.Error(), "1047"))
t.Fatal(err)
}
func TestOrderDelivering(t *testing.T) {
err := api.OrderDelivering(148815413321281654)
t.Fatal(err)
}
func TestApplyCompensation(t *testing.T) {
param := &ApplyCompensationRes{
OrderId: 3500902110034359123,
Reason: "申请退款",
ApplyStatus: 110,
Amount: 35.31,
//FoodData: nil,
}
err := api.ApplyCompensation(param)
if err != nil {
fmt.Println(err.Error())
}
}