diff --git a/config/config_test.yaml b/config/config_test.yaml index 8134c01..9b9066c 100644 --- a/config/config_test.yaml +++ b/config/config_test.yaml @@ -57,13 +57,13 @@ tools: api_secret: "ObqxwyR20r9rVNhju0sCPQyQA98_FZSc32W4vgxnGFH_b02HZr1BPCJsOAF816nu" zltxOrderAfterSaleSupplier: enabled: true - base_url: "https://revcl.1688sup.com/api/admin/afterSales/reseller_supplier" + base_url: "https://gateway.dev.cdlsxd.cn/zltx_api/admin/afterSales/directs" zltxOrderAfterSaleReseller: enabled: true - base_url: "https://revcl.1688sup.com/api/admin/afterSales/reseller_supplier" + base_url: "https://gateway.dev.cdlsxd.cn/zltx_api/admin/afterSales/reseller_pre_ai" zltxOrderAfterSaleResellerBatch: enabled: true - base_url: "https://revcl.1688sup.com/api/admin/afterSales/reseller_supplier_batch" + base_url: "https://gateway.dev.cdlsxd.cn/zltx_api/admin/afterSales/reseller_pre_ai" diff --git a/internal/pkg/util/string.go b/internal/pkg/util/string.go index 81b7e29..e179c4a 100644 --- a/internal/pkg/util/string.go +++ b/internal/pkg/util/string.go @@ -2,6 +2,7 @@ package util import ( "encoding/json" + "strconv" "strings" ) @@ -19,3 +20,9 @@ func EscapeJSONString(s string) string { b, _ := json.Marshal(s) return string(b[1 : len(b)-1]) } + +// string 转 int +func StringToInt(s string) int { + i, _ := strconv.Atoi(s) + return i +} diff --git a/internal/tools/zltx/order_after_supplier.go b/internal/tools/zltx/order_after_supplier.go index 805c38a..321f2aa 100644 --- a/internal/tools/zltx/order_after_supplier.go +++ b/internal/tools/zltx/order_after_supplier.go @@ -4,6 +4,7 @@ import ( "ai_scheduler/internal/config" "ai_scheduler/internal/entitys" "ai_scheduler/internal/pkg/l_request" + "ai_scheduler/internal/pkg/util" "context" "encoding/json" "fmt" @@ -41,7 +42,7 @@ type OrderAfterSaleSupplierRequest struct { SerialCreateTime string `json:"serialCreateTime"` // 流水创建时间 AfterSalesReason string `json:"afterSalesReason"` // 售后原因 AfterSalesPrice string `json:"afterSalesPrice"` // 售后金额 - AfterType int `json:"afterType"` // 售后类型 1.加款 2.扣款 + AfterType string `json:"afterType"` // 售后类型 1.加款 2.扣款 } // 工具最终返回 @@ -63,7 +64,7 @@ type OrderAfterSaleSupplierData struct { PlatformID int `json:"platformId"` // 上游平台id SignCompanyName string `json:"signCompanyName"` // 签约主体名称 Reason string `json:"reason"` // 售后原因 - SalePrice float64 `json:"salePrice"` // 售后金额 + SalePrice string `json:"salePrice"` // 售后金额 SaleType int `json:"saleType"` // 处理方式 1.加款 2.扣款 ExecuteTime int `json:"executeTime"` // 流水创建时间 IsExistsAfterSale bool `json:"isExistsAfterSale"` // 是否已存在售后 @@ -71,13 +72,13 @@ type OrderAfterSaleSupplierData struct { // 接口返回 type OrderAfterSaleSupplierApiResponse struct { - Code int `json:"code"` - Msg string `json:"msg"` - Data OrderAfterSaleSupplierApiData `json:"data"` + Code int `json:"code"` + Error string `json:"error"` + Data OrderAfterSaleSupplierApiData `json:"data"` } type OrderAfterSaleSupplierApiData struct { Data []OrderAfterSaleSupplierApiBase `json:"data"` - ExtData map[string]OrderAfterSaleSupplierApiExtItem `json:"ext"` + ExtData map[string]OrderAfterSaleSupplierApiExtItem `json:"extraData"` } type OrderAfterSaleSupplierApiBase struct { SerialNumber string `json:"serialNumber"` // 流水号 @@ -90,13 +91,11 @@ type OrderAfterSaleSupplierApiBase struct { PlatformProductID int `json:"platformProductId"` // 上有商品id PlatformID int `json:"platformId"` // 上游平台id SignCompanyName string `json:"signCompanyName"` // 签约主体名称 - Reason string `json:"reason"` // 售后原因 - SalePrice float64 `json:"salePrice"` // 售后金额 - SaleType int `json:"saleType"` // 处理方式 1.加款 2.扣款 + ExecuteTime int `json:"executeTime"` // 充值执行时间 } type OrderAfterSaleSupplierApiExtItem struct { - IsExistsAfterSale bool `json:"isExistsAfterSale"` // 是否已存在售后 - SerialCreateTime int `json:"serialCreateTime"` // 流水创建时间 + IsExistsAfterSale bool `json:"existAfterSales"` // 是否已存在售后 + SerialCreateTime int `json:"createTime"` // 流水创建时间 } func (t *OrderAfterSaleSupplierTool) Execute(ctx context.Context, requireData *entitys.RequireData) error { @@ -110,7 +109,7 @@ func (t *OrderAfterSaleSupplierTool) Execute(ctx context.Context, requireData *e entitys.ResLog(requireData.Ch, t.Name(), "正在拉取售后订单信息") - return t.checkOrderAfterSaleSupplierMock(req, requireData) + return t.checkOrderAfterSaleSupplier(req, requireData) } func (t *OrderAfterSaleSupplierTool) checkOrderAfterSaleSupplier(toolReq OrderAfterSaleSupplierRequest, requireData *entitys.RequireData) error { @@ -138,9 +137,9 @@ func (t *OrderAfterSaleSupplierTool) checkOrderAfterSaleSupplier(toolReq OrderAf // 多流水号 if len(toolReq.SerialNumber) > 0 { body := map[string]any{ - "serialNumber": toolReq.SerialNumber, // 流水号 + "serial_numbers": toolReq.SerialNumber, // 流水号 } - orderList, err = t.getAfterSaleSupplierList(headers, body) + orderList, err = t.getAfterSaleSupplierList(headers, body, toolReq) if err != nil { return err } @@ -156,11 +155,10 @@ func (t *OrderAfterSaleSupplierTool) checkOrderAfterSaleSupplier(toolReq OrderAf defer waitGroup.Done() body := map[string]any{ - "account": account, // 充值账号 - "serialStartTime": serialStartTime, // 流水创建时间 - "serialEndTime": serialEndTime, // 流水结束时间 + "account": account, // 充值账号 + "create_time": []int64{serialStartTime, serialEndTime}, // 流水创建时间区间 } - orderListIn, errIn := t.getAfterSaleSupplierList(headers, body) + orderListIn, errIn := t.getAfterSaleSupplierList(headers, body, toolReq) if errIn != nil { return } @@ -196,7 +194,7 @@ func (t *OrderAfterSaleSupplierTool) checkOrderAfterSaleSupplier(toolReq OrderAf return nil } -func (t *OrderAfterSaleSupplierTool) getAfterSaleSupplierList(headers map[string]string, body map[string]any) ([]*OrderAfterSaleSupplierData, error) { +func (t *OrderAfterSaleSupplierTool) getAfterSaleSupplierList(headers map[string]string, body map[string]any, originInput OrderAfterSaleSupplierRequest) ([]*OrderAfterSaleSupplierData, error) { req := l_request.Request{ Url: t.config.BaseURL, Headers: headers, @@ -212,8 +210,8 @@ func (t *OrderAfterSaleSupplierTool) getAfterSaleSupplierList(headers map[string if err = json.Unmarshal(res.Content, &resp); err != nil { return nil, err } - if resp.Code != 0 { - return nil, fmt.Errorf("after sale supplier failed: %s", resp.Msg) + if resp.Code != 200 { + return nil, fmt.Errorf("after sale supplier failed: %s", resp.Error) } orderList := make([]*OrderAfterSaleSupplierData, 0, len(resp.Data.Data)) @@ -231,9 +229,9 @@ func (t *OrderAfterSaleSupplierTool) getAfterSaleSupplierList(headers map[string PlatformProductID: item.PlatformProductID, PlatformID: item.PlatformID, SignCompanyName: item.SignCompanyName, - Reason: item.Reason, - SalePrice: item.SalePrice, - SaleType: item.SaleType, + Reason: originInput.AfterSalesReason, + SalePrice: originInput.AfterSalesPrice, + SaleType: util.StringToInt(originInput.AfterType), }) } @@ -247,60 +245,3 @@ func (t *OrderAfterSaleSupplierTool) getAfterSaleSupplierList(headers map[string return orderList, nil } - -// mock待删除 -func (t *OrderAfterSaleSupplierTool) checkOrderAfterSaleSupplierMock(req OrderAfterSaleSupplierRequest, requireData *entitys.RequireData) error { - resp := OrderAfterSaleSupplierResponse{ - Code: 0, - Msg: "success", - Data: []*OrderAfterSaleSupplierData{ - { - SerialNumber: "847465394004430849", - PlatformName: "爱奇艺", - SignCompany: 1, - PlatformProductName: "爱奇艺官方周卡", - PlatformPrice: 6, - TerminalAccount: "15516353308", - Status: 1, - PlatformProductID: 2, - PlatformID: 4, - SignCompanyName: "成都蓝色兄弟网络科技有限公司", - ExecuteTime: 1763961931, - Reason: "测试售后", - SalePrice: 50, - SaleType: 1, - IsExistsAfterSale: false, - }, - { - SerialNumber: "843493448012140545", - PlatformName: "卓望别名1", - SignCompany: 1, - PlatformProductName: "卓望--别名商品1", - PlatformPrice: 897.7765, - TerminalAccount: "18380416326", - Status: -1, - PlatformProductID: 7497, - PlatformID: 15, - SignCompanyName: "成都蓝色兄弟网络科技有限公司", - ExecuteTime: 1763014914, - Reason: "测试售后2", - SalePrice: 30, - SaleType: 2, - IsExistsAfterSale: true, - }, - }, - } - - if len(req.SerialNumber) == 1 { - resp.Data = resp.Data[:1] - } - - jsonByte, err := json.Marshal(resp) - if err != nil { - return err - } - - entitys.ResLog(requireData.Ch, t.Name(), "售后订单信息拉取完成") - entitys.ResJson(requireData.Ch, t.Name(), string(jsonByte)) - return nil -}