From c20d32e9754708a58832f764bc0b67bea17a7ddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 21 Sep 2023 17:00:34 +0800 Subject: [PATCH] 1 --- platformapi/tao_vegetable/order_afs.go | 7 ++- platformapi/tao_vegetable/order_test.go | 74 +++++++++++++++++-------- 2 files changed, 57 insertions(+), 24 deletions(-) diff --git a/platformapi/tao_vegetable/order_afs.go b/platformapi/tao_vegetable/order_afs.go index 70e41473..714ed40f 100644 --- a/platformapi/tao_vegetable/order_afs.go +++ b/platformapi/tao_vegetable/order_afs.go @@ -241,8 +241,11 @@ func (a *API) QueryBillList(req *request591.AlibabaWdkBillListRequest) (*domain5 globals.SugarLogger.Debugf("进入 QueryBillList : %s", utils.Format4Output(req, false)) client := ability591.NewAbility591(&a.client) - data, _ := client.AlibabaWdkBillList(req, a.token) - + data, err := client.AlibabaWdkBillList(req, a.token) + if err != nil { + globals.SugarLogger.Debugf("requestId[%s],err[%s]", data.RequestId, utils.Format4Output(err, false)) + return nil, err + } if !*data.ApiResult.Success { globals.SugarLogger.Debugf("requestId[%s],err[%s]", data.RequestId, utils.Format4Output(data, false)) return nil, fmt.Errorf(*data.ApiResult.ErrMsg) diff --git a/platformapi/tao_vegetable/order_test.go b/platformapi/tao_vegetable/order_test.go index 7e5b1cf0..95424bdb 100644 --- a/platformapi/tao_vegetable/order_test.go +++ b/platformapi/tao_vegetable/order_test.go @@ -2,6 +2,7 @@ package tao_vegetable import ( "encoding/json" + "errors" "fmt" domain3156 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability3156/domain" request3156 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability3156/request" @@ -9,9 +10,9 @@ import ( request591 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability591/request" "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/util" "git.rosy.net.cn/baseapi/utils" + "git.rosy.net.cn/jx-callback/business/model" "git.rosy.net.cn/jx-callback/globals" "strconv" - "strings" "testing" "time" ) @@ -227,34 +228,63 @@ func TestDeliveryTrajectory(t *testing.T) { func TestQueryBillList(t *testing.T) { queryData := time.Now() - create := time.Date(queryData.Year(), queryData.Month(), queryData.Day()-20, 0, 0, 0, 0, queryData.Location()) + create := time.Date(queryData.Year(), queryData.Month(), queryData.Day()-90, 0, 0, 0, 0, queryData.Location()) end := time.Date(queryData.Year(), queryData.Month(), queryData.Day(), 23, 59, 59, 59, queryData.Location()) - createTime := util.LocalTime(create) - endTime := util.LocalTime(end) + + data, err := GetOrderTotalShopMoney("", "JX100002", create, end) + + globals.SugarLogger.Debugf("data:= %s", utils.Format4Output(data, false)) + globals.SugarLogger.Debugf("data:= %s", utils.Format4Output(err, false)) +} + +// GetOrderTotalShopMoney 获取门店结算信息 +func GetOrderTotalShopMoney(appOrgCode string, vendorStoreID string, start, end time.Time) (map[string]string, error) { + if start.IsZero() || end.IsZero() { + return nil, errors.New("开始时间和结束时间不能为空") + } + + settlement := make(map[string]string, 0) + + api := apiTao + startBillDate := util.LocalTime(start) + endBillDate := util.LocalTime(end) + pageSize := 200 + pageIndex := 1 + param := &request591.AlibabaWdkBillListRequest{ TxdBillListGetRequest: &domain591.AlibabaWdkBillListTxdBillListGetRequest{ - EndBillDate: &endTime, - StartBillDate: &createTime, - ShopCode: utils.String2Pointer("JX668429"), - PageSize: utils.Int64ToPointer(200), - PageIndex: utils.Int64ToPointer(1), + EndBillDate: &endBillDate, + StartBillDate: &startBillDate, + ShopCode: utils.String2Pointer(vendorStoreID), + PageSize: utils.Int64ToPointer(int64(pageSize)), + PageIndex: utils.Int64ToPointer(int64(pageIndex)), }, } - data, err := apiTao.QueryBillList(param) - if err != nil { - fmt.Println("err === ", err) - return + var totalIndex int64 = 0 + result, _ := api.QueryBillList(param) + for _, v := range *result.TxdBillDetailBOS { + if *v.OrderType == "positive" { + settlement[*v.BizOrderId] = *v.ReceivableAmount + } } - globals.SugarLogger.Debugf("data:= %s", utils.Format4Output(data, false)) -} + if *result.Total > int64(pageSize) { + totalIndex = *result.Total / int64(pageSize) + if *result.Total%int64(pageSize) != model.NO { + totalIndex += 1 + } -func TestName2(t *testing.T) { - emoji := `【右上角关注点亮⭐️】` - a := replaceContentOther(emoji) - fmt.Println(a) -} -func replaceContentOther(content string) string { - return strings.ReplaceAll(strings.ReplaceAll(content, "⃣️", " "), "•", "-") + for i := 2; i <= int(totalIndex); i++ { + param.TxdBillListGetRequest.PageIndex = utils.Int64ToPointer(int64(i)) + result2, _ := api.QueryBillList(param) + for _, v := range *result2.TxdBillDetailBOS { + if *v.OrderType == "positive" { + settlement[*v.BizOrderId] = *v.ReceivableAmount + } + } + } + } + + return settlement, nil }