From 8895f29963b5451cfdc789d9ff5742955ea638b4 Mon Sep 17 00:00:00 2001 From: fuzhongyun <15339891972@163.com> Date: Thu, 27 Nov 2025 10:09:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=201.=E8=B0=83=E6=95=B4=E5=94=AE=E5=90=8E?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E3=80=81=E8=B4=B9=E7=94=A8=E6=89=BF=E6=8B=85?= =?UTF-8?q?=E7=9D=80=E9=BB=98=E8=AE=A4=202.=E5=94=AE=E5=90=8E=E9=87=91?= =?UTF-8?q?=E9=A2=9Dstring->float64=203.=E4=BC=98=E5=8C=96=E6=97=A0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=93=8D=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/pkg/util/string.go | 6 +++++ internal/tools/zltx/order_after_reseller.go | 27 ++++++++++++++----- .../tools/zltx/order_after_reseller_batch.go | 27 ++++++++++++++----- internal/tools/zltx/order_after_supplier.go | 20 ++++++++++---- 4 files changed, 62 insertions(+), 18 deletions(-) diff --git a/internal/pkg/util/string.go b/internal/pkg/util/string.go index e179c4a..1fc898a 100644 --- a/internal/pkg/util/string.go +++ b/internal/pkg/util/string.go @@ -26,3 +26,9 @@ func StringToInt(s string) int { i, _ := strconv.Atoi(s) return i } + +// string 转 float64 +func StringToFloat64(s string) float64 { + i, _ := strconv.ParseFloat(s, 64) + return i +} diff --git a/internal/tools/zltx/order_after_reseller.go b/internal/tools/zltx/order_after_reseller.go index 51dff22..aefc18b 100644 --- a/internal/tools/zltx/order_after_reseller.go +++ b/internal/tools/zltx/order_after_reseller.go @@ -68,7 +68,7 @@ type OrderAfterSaleResellerData struct { Platforms map[int]string `json:"platforms"` AfterType int `json:"afterType"` // 处理方式 1.退款 2.扣款 Remark string `json:"remark"` // 售后原因 - AfterAmount string `json:"afterAmount"` // 售后金额 + AfterAmount float64 `json:"afterAmount"` // 售后金额 ResponsibleType int `json:"responsibleType"` // 费用承担者 1.供应商 2.商务 3.公司 4.无 ResponsiblePerson string `json:"responsiblePerson"` // 费用承担供应商 IsExistsAfterSale bool `json:"isExistsAfterSale"` // 是否已存在售后 @@ -107,8 +107,7 @@ type OrderAfterSaleResellerApiExtItem struct { func (t *OrderAfterSaleResellerTool) Execute(ctx context.Context, requireData *entitys.RequireData) error { var req OrderAfterSaleResellerRequest if err := json.Unmarshal([]byte(requireData.Match.Parameters), &req); err != nil { - entitys.ResError(requireData.Ch, t.Name(), "解析参数失败,请重试或联系管理员") - return err + return fmt.Errorf("解析参数失败,请重试或联系管理员") } if len(req.OrderNumber) == 0 && len(req.Account) == 0 { return fmt.Errorf("订单号 和 充值账号 不能同时为空") @@ -190,6 +189,11 @@ func (t *OrderAfterSaleResellerTool) checkOrderAfterSaleReseller(toolReq OrderAf return fmt.Errorf("订单号 和 充值账号 不能同时为空") } + // 未查询到相应售后订单,请核实提供信息是否正确 + if len(orderList) == 0 { + return fmt.Errorf("未查询到相应售后订单,请核实提供信息是否正确") + } + toolResp := OrderAfterSaleResellerResponse{ Code: 0, Msg: "Success", @@ -231,6 +235,17 @@ func (t *OrderAfterSaleResellerTool) getAfterSaleResellerList(headers map[string // 转换数据 for _, item := range resp.Data.Data { + // 处理方式 + afterType := util.StringToInt(originInput.AfterType) + if afterType == 0 { + afterType = 1 // 默认退款 + } + // 费用承担者 + responsibleType := util.StringToInt(originInput.ResponsibleType) + if responsibleType == 0 { + responsibleType = 4 // 默认无 + } + orderList = append(orderList, &OrderAfterSaleResellerData{ OrderType: item.OrderType, OrderNumber: item.OrderNumber, @@ -244,10 +259,10 @@ func (t *OrderAfterSaleResellerTool) getAfterSaleResellerList(headers map[string OurProductTitle: item.OurProductTitle, Account: item.Account, Platforms: item.Platforms, - AfterType: util.StringToInt(originInput.AfterType), + AfterType: afterType, Remark: originInput.AfterSalesReason, - AfterAmount: originInput.AfterSalesPrice, - ResponsibleType: util.StringToInt(originInput.ResponsibleType), + AfterAmount: util.StringToFloat64(originInput.AfterSalesPrice), + ResponsibleType: responsibleType, ResponsiblePerson: originInput.ResponsiblePerson, }) } diff --git a/internal/tools/zltx/order_after_reseller_batch.go b/internal/tools/zltx/order_after_reseller_batch.go index c039ecc..7a87115 100644 --- a/internal/tools/zltx/order_after_reseller_batch.go +++ b/internal/tools/zltx/order_after_reseller_batch.go @@ -64,7 +64,7 @@ type OrderAfterSaleResellerBatchData struct { Platforms map[int]string `json:"platforms"` AfterType int `json:"afterType"` // 处理方式 1.退款 2.扣款 Remark string `json:"remark"` // 售后原因 - AfterAmount string `json:"afterAmount"` // 售后金额 + AfterAmount float64 `json:"afterAmount"` // 售后金额 ResponsibleType int `json:"responsibleType"` // 费用承担者 1.供应商 2.商务 3.公司 4.无 ResponsiblePerson string `json:"responsiblePerson"` // 费用承担供应商 IsExistsAfterSale bool `json:"isExistsAfterSale"` // 是否已存在售后 @@ -103,8 +103,7 @@ type OrderAfterSaleResellerBatchApiExtItem struct { func (t *OrderAfterSaleResellerBatchTool) Execute(ctx context.Context, requireData *entitys.RequireData) error { var req OrderAfterSaleResellerBatchRequest if err := json.Unmarshal([]byte(requireData.Match.Parameters), &req); err != nil { - entitys.ResError(requireData.Ch, t.Name(), "解析参数失败,请重试或联系管理员") - return err + return fmt.Errorf("解析参数失败,请重试或联系管理员") } if len(req.OrderNumber) == 0 { return fmt.Errorf("批充订单号不能为空") @@ -137,7 +136,10 @@ func (t *OrderAfterSaleResellerBatchTool) checkOrderAfterSaleResellerBatch(toolR return err } if resp.Code != 200 { - return fmt.Errorf("after sale supplier failed: %s", resp.Error) + return fmt.Errorf("售后订单查询异常: %s", resp.Error) + } + if len(resp.Data.Data) == 0 { + return fmt.Errorf("未查询到相应售后订单,请核实订单号是否正确") } toolResp := OrderAfterSaleResellerBatchResponse{ @@ -148,6 +150,17 @@ func (t *OrderAfterSaleResellerBatchTool) checkOrderAfterSaleResellerBatch(toolR // 转换数据 for _, item := range resp.Data.Data { + // 处理方式 + afterType := util.StringToInt(toolReq.AfterType) + if afterType == 0 { + afterType = 1 // 默认退款 + } + // 费用承担者 + responsibleType := util.StringToInt(toolReq.ResponsibleType) + if responsibleType == 0 { + responsibleType = 4 // 默认无 + } + toolResp.Data = append(toolResp.Data, &OrderAfterSaleResellerBatchData{ OrderType: item.OrderType, OrderNumber: item.OrderNumber, @@ -161,10 +174,10 @@ func (t *OrderAfterSaleResellerBatchTool) checkOrderAfterSaleResellerBatch(toolR OurProductTitle: item.OurProductTitle, Account: item.Account, Platforms: item.Platforms, - AfterType: util.StringToInt(toolReq.AfterType), + AfterType: afterType, Remark: toolReq.AfterSalesReason, - AfterAmount: toolReq.AfterSalesPrice, - ResponsibleType: util.StringToInt(toolReq.ResponsibleType), + AfterAmount: util.StringToFloat64(toolReq.AfterSalesPrice), + ResponsibleType: responsibleType, ResponsiblePerson: toolReq.ResponsiblePerson, }) } diff --git a/internal/tools/zltx/order_after_supplier.go b/internal/tools/zltx/order_after_supplier.go index 3ed294e..d5631ff 100644 --- a/internal/tools/zltx/order_after_supplier.go +++ b/internal/tools/zltx/order_after_supplier.go @@ -64,7 +64,7 @@ type OrderAfterSaleSupplierData struct { PlatformID int `json:"platformId"` // 上游平台id SignCompanyName string `json:"signCompanyName"` // 签约主体名称 Reason string `json:"reason"` // 售后原因 - SalePrice string `json:"salePrice"` // 售后金额 + SalePrice float64 `json:"salePrice"` // 售后金额 SaleType int `json:"saleType"` // 处理方式 1.加款 2.扣款 ExecuteTime int `json:"executeTime"` // 流水创建时间 IsExistsAfterSale bool `json:"isExistsAfterSale"` // 是否已存在售后 @@ -101,8 +101,7 @@ type OrderAfterSaleSupplierApiExtItem struct { func (t *OrderAfterSaleSupplierTool) Execute(ctx context.Context, requireData *entitys.RequireData) error { var req OrderAfterSaleSupplierRequest if err := json.Unmarshal([]byte(requireData.Match.Parameters), &req); err != nil { - entitys.ResError(requireData.Ch, t.Name(), "解析参数失败,请重试或联系管理员") - return err + return fmt.Errorf("解析参数失败,请重试或联系管理员") } if len(req.SerialNumber) == 0 && len(req.Account) == 0 { return fmt.Errorf("充值流水号 和 充值账号 不能同时为空") @@ -182,6 +181,11 @@ func (t *OrderAfterSaleSupplierTool) checkOrderAfterSaleSupplier(toolReq OrderAf return fmt.Errorf("充值流水号 和 充值账号 不能同时为空") } + // 未查询到相应售后订单,请核实提供信息是否正确 + if len(orderList) == 0 { + return fmt.Errorf("未查询到相应售后订单,请核实提供信息是否正确") + } + toolResp := OrderAfterSaleSupplierResponse{ Code: 0, Msg: "Success", @@ -223,6 +227,12 @@ func (t *OrderAfterSaleSupplierTool) getAfterSaleSupplierList(headers map[string // 转换数据 for _, item := range resp.Data.Data { + // 处理方式 + afterType := util.StringToInt(originInput.AfterType) + if afterType == 0 { + afterType = 1 // 默认退款 + } + orderList = append(orderList, &OrderAfterSaleSupplierData{ SerialNumber: item.SerialNumber, PlatformName: item.PlatformName, @@ -235,8 +245,8 @@ func (t *OrderAfterSaleSupplierTool) getAfterSaleSupplierList(headers map[string PlatformID: item.PlatformID, SignCompanyName: item.SignCompanyName, Reason: originInput.AfterSalesReason, - SalePrice: originInput.AfterSalesPrice, - SaleType: util.StringToInt(originInput.AfterType), + SalePrice: util.StringToFloat64(originInput.AfterSalesPrice), + SaleType: afterType, }) }