feat: 下游售后(批充、直充)zltx api 接入

This commit is contained in:
fuzhongyun 2025-11-26 20:00:14 +08:00
parent 43522037db
commit a844d12979
3 changed files with 118 additions and 165 deletions

View File

@ -4,6 +4,7 @@ import (
"ai_scheduler/internal/config" "ai_scheduler/internal/config"
"ai_scheduler/internal/entitys" "ai_scheduler/internal/entitys"
"ai_scheduler/internal/pkg/l_request" "ai_scheduler/internal/pkg/l_request"
"ai_scheduler/internal/pkg/util"
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
@ -39,10 +40,10 @@ type OrderAfterSaleResellerRequest struct {
OrderNumber []string `json:"orderNumber"` // 订单号 OrderNumber []string `json:"orderNumber"` // 订单号
Account []string `json:"account"` // 充值账号 Account []string `json:"account"` // 充值账号
SerialCreateTime string `json:"serialCreateTime"` // 流水创建时间 SerialCreateTime string `json:"serialCreateTime"` // 流水创建时间
AfterType int `json:"afterType"` // 处理方式 1.退款 2.扣款 AfterType string `json:"afterType"` // 处理方式 1.退款 2.扣款
AfterSalesPrice float64 `json:"afterSalesPrice"` // 售后金额 AfterSalesPrice string `json:"afterSalesPrice"` // 售后金额
AfterSalesReason string `json:"afterSalesReason"` // 售后原因 AfterSalesReason string `json:"afterSalesReason"` // 售后原因
ResponsibleType int `json:"responsibleType"` // 费用承担者 1.供应商 2.商务 3.公司 4.无 ResponsibleType string `json:"responsibleType"` // 费用承担者 1.供应商 2.商务 3.公司 4.无
ResponsiblePerson string `json:"responsiblePerson"` // 费用承担供应商 ResponsiblePerson string `json:"responsiblePerson"` // 费用承担供应商
} }
@ -67,7 +68,7 @@ type OrderAfterSaleResellerData struct {
Platforms map[int]string `json:"platforms"` Platforms map[int]string `json:"platforms"`
AfterType int `json:"afterType"` // 处理方式 1.退款 2.扣款 AfterType int `json:"afterType"` // 处理方式 1.退款 2.扣款
Remark string `json:"remark"` // 售后原因 Remark string `json:"remark"` // 售后原因
AfterAmount float64 `json:"afterAmount"` // 售后金额 AfterAmount string `json:"afterAmount"` // 售后金额
ResponsibleType int `json:"responsibleType"` // 费用承担者 1.供应商 2.商务 3.公司 4.无 ResponsibleType int `json:"responsibleType"` // 费用承担者 1.供应商 2.商务 3.公司 4.无
ResponsiblePerson string `json:"responsiblePerson"` // 费用承担供应商 ResponsiblePerson string `json:"responsiblePerson"` // 费用承担供应商
IsExistsAfterSale bool `json:"isExistsAfterSale"` // 是否已存在售后 IsExistsAfterSale bool `json:"isExistsAfterSale"` // 是否已存在售后
@ -76,13 +77,13 @@ type OrderAfterSaleResellerData struct {
// 接口返回 // 接口返回
type OrderAfterSaleResellerApiResponse struct { type OrderAfterSaleResellerApiResponse struct {
Code int `json:"code"` Code int `json:"code"`
Msg string `json:"msg"` Error string `json:"error"`
Data OrderAfterSaleResellerApiData `json:"data"` Data OrderAfterSaleResellerApiData `json:"data"`
} }
type OrderAfterSaleResellerApiData struct { type OrderAfterSaleResellerApiData struct {
Data []OrderAfterSaleResellerApiBase `json:"data"` Data []OrderAfterSaleResellerApiBase `json:"data"`
ExtData map[string]OrderAfterSaleResellerApiExtItem `json:"ext"` ExtData map[string]OrderAfterSaleResellerApiExtItem `json:"extraData"`
} }
type OrderAfterSaleResellerApiBase struct { type OrderAfterSaleResellerApiBase struct {
OrderType int `json:"orderType"` OrderType int `json:"orderType"`
@ -99,13 +100,14 @@ type OrderAfterSaleResellerApiBase struct {
Platforms map[int]string `json:"platforms"` Platforms map[int]string `json:"platforms"`
} }
type OrderAfterSaleResellerApiExtItem struct { type OrderAfterSaleResellerApiExtItem struct {
IsExistsAfterSale bool `json:"isExistsAfterSale"` // 是否已存在售后 IsExistsAfterSale bool `json:"isExistsAfterSale"` // 是否已存在售后 - 未使用
SerialCreateTime int `json:"serialCreateTime"` // 流水创建时间 SerialCreateTime int `json:"createTime"` // 流水创建时间
} }
func (t *OrderAfterSaleResellerTool) Execute(ctx context.Context, requireData *entitys.RequireData) error { func (t *OrderAfterSaleResellerTool) Execute(ctx context.Context, requireData *entitys.RequireData) error {
var req OrderAfterSaleResellerRequest var req OrderAfterSaleResellerRequest
if err := json.Unmarshal([]byte(requireData.Match.Parameters), &req); err != nil { if err := json.Unmarshal([]byte(requireData.Match.Parameters), &req); err != nil {
entitys.ResError(requireData.Ch, t.Name(), "解析参数失败,请重试或联系管理员")
return err return err
} }
if len(req.OrderNumber) == 0 && len(req.Account) == 0 { if len(req.OrderNumber) == 0 && len(req.Account) == 0 {
@ -114,15 +116,20 @@ func (t *OrderAfterSaleResellerTool) Execute(ctx context.Context, requireData *e
entitys.ResLog(requireData.Ch, t.Name(), "正在拉取售后订单信息") entitys.ResLog(requireData.Ch, t.Name(), "正在拉取售后订单信息")
return t.checkOrderAfterSaleResellerMock(req, requireData) return t.checkOrderAfterSaleReseller(req, requireData)
} }
func (t *OrderAfterSaleResellerTool) checkOrderAfterSaleReseller(toolReq OrderAfterSaleResellerRequest, requireData *entitys.RequireData) error { func (t *OrderAfterSaleResellerTool) checkOrderAfterSaleReseller(toolReq OrderAfterSaleResellerRequest, requireData *entitys.RequireData) error {
// 流水创建时间上下浮动10min // 流水创建时间上下浮动10min
serialCreateTime, err := time.ParseInLocation(time.DateTime, toolReq.SerialCreateTime, time.Local) serialCreateTime := time.Now()
if err != nil { var err error
return err if toolReq.SerialCreateTime != "" {
serialCreateTime, err = time.ParseInLocation(time.DateTime, toolReq.SerialCreateTime, time.Local)
if err != nil {
return err
}
} }
serialStartTime := serialCreateTime.Unix() - 10*60 serialStartTime := serialCreateTime.Unix() - 10*60
serialEndTime := serialCreateTime.Unix() + 10*60 serialEndTime := serialCreateTime.Unix() + 10*60
@ -142,7 +149,7 @@ func (t *OrderAfterSaleResellerTool) checkOrderAfterSaleReseller(toolReq OrderAf
// 多订单号 // 多订单号
if len(toolReq.OrderNumber) > 0 { if len(toolReq.OrderNumber) > 0 {
body := map[string]any{ body := map[string]any{
"orderNumber": toolReq.OrderNumber, // 订单号 "order_numbers": toolReq.OrderNumber, // 订单号
} }
orderList, err = t.getAfterSaleResellerList(headers, body, toolReq) orderList, err = t.getAfterSaleResellerList(headers, body, toolReq)
if err != nil { if err != nil {
@ -160,9 +167,9 @@ func (t *OrderAfterSaleResellerTool) checkOrderAfterSaleReseller(toolReq OrderAf
defer waitGroup.Done() defer waitGroup.Done()
body := map[string]any{ body := map[string]any{
"account": account, // 充值账号 "account": account, // 充值账号
"serialStartTime": serialStartTime, // 流水创建时 "create_time": []int64{serialStartTime, serialEndTime}, // 流水创建时间区
"serialEndTime": serialEndTime, // 流水结束时间 "order_type": 1, // 1.直充
} }
orderListIn, errIn := t.getAfterSaleResellerList(headers, body, toolReq) orderListIn, errIn := t.getAfterSaleResellerList(headers, body, toolReq)
if errIn != nil { if errIn != nil {
@ -216,8 +223,8 @@ func (t *OrderAfterSaleResellerTool) getAfterSaleResellerList(headers map[string
if err = json.Unmarshal(res.Content, &resp); err != nil { if err = json.Unmarshal(res.Content, &resp); err != nil {
return nil, err return nil, err
} }
if resp.Code != 0 { if resp.Code != 200 {
return nil, fmt.Errorf("after sale reseller failed: %s", resp.Msg) return nil, fmt.Errorf("after sale reseller failed: %s", resp.Error)
} }
orderList := make([]*OrderAfterSaleResellerData, 0, len(resp.Data.Data)) orderList := make([]*OrderAfterSaleResellerData, 0, len(resp.Data.Data))
@ -237,10 +244,10 @@ func (t *OrderAfterSaleResellerTool) getAfterSaleResellerList(headers map[string
OurProductTitle: item.OurProductTitle, OurProductTitle: item.OurProductTitle,
Account: item.Account, Account: item.Account,
Platforms: item.Platforms, Platforms: item.Platforms,
AfterType: originInput.AfterType, AfterType: util.StringToInt(originInput.AfterType),
Remark: originInput.AfterSalesReason, Remark: originInput.AfterSalesReason,
AfterAmount: originInput.AfterSalesPrice, AfterAmount: originInput.AfterSalesPrice,
ResponsibleType: originInput.ResponsibleType, ResponsibleType: util.StringToInt(originInput.ResponsibleType),
ResponsiblePerson: originInput.ResponsiblePerson, ResponsiblePerson: originInput.ResponsiblePerson,
}) })
} }
@ -248,7 +255,7 @@ func (t *OrderAfterSaleResellerTool) getAfterSaleResellerList(headers map[string
// 追加扩展数据 // 追加扩展数据
for _, item := range orderList { for _, item := range orderList {
if extItem, ok := resp.Data.ExtData[item.OrderNumber]; ok { if extItem, ok := resp.Data.ExtData[item.OrderNumber]; ok {
item.IsExistsAfterSale = extItem.IsExistsAfterSale item.IsExistsAfterSale = item.OrderType > 100 // 101 直充&已售后
item.CreateTime = extItem.SerialCreateTime item.CreateTime = extItem.SerialCreateTime
} }
} }
@ -256,64 +263,64 @@ func (t *OrderAfterSaleResellerTool) getAfterSaleResellerList(headers map[string
return orderList, nil return orderList, nil
} }
func (t *OrderAfterSaleResellerTool) checkOrderAfterSaleResellerMock(req OrderAfterSaleResellerRequest, requireData *entitys.RequireData) error { // func (t *OrderAfterSaleResellerTool) checkOrderAfterSaleResellerMock(req OrderAfterSaleResellerRequest, requireData *entitys.RequireData) error {
resp := OrderAfterSaleResellerResponse{ // resp := OrderAfterSaleResellerResponse{
Code: 0, // Code: 0,
Msg: "success", // Msg: "success",
Data: []*OrderAfterSaleResellerData{ // Data: []*OrderAfterSaleResellerData{
{ // {
OrderType: 1, // OrderType: 1,
OrderNumber: "846784115378364417", // OrderNumber: "846784115378364417",
OrderAmount: 0.1, // OrderAmount: 0.1,
OrderPrice: 0.1, // OrderPrice: 0.1,
SignCompany: 1, // SignCompany: 1,
OrderQuantity: 1, // OrderQuantity: 1,
ResellerID: 23329, // ResellerID: 23329,
ResellerName: "分销商23329", // ResellerName: "分销商23329",
OurProductID: 106, // OurProductID: 106,
OurProductTitle: "爱奇艺黄金会员周卡", // OurProductTitle: "爱奇艺黄金会员周卡",
Account: []string{"15516353308"}, // Account: []string{"15516353308"},
Platforms: map[int]string{4: "爱奇艺"}, // Platforms: map[int]string{4: "爱奇艺"},
CreateTime: 1723304000, // CreateTime: 1723304000,
AfterType: 1, // AfterType: 1,
Remark: "测试售后", // Remark: "测试售后",
AfterAmount: 50, // AfterAmount: 50,
ResponsibleType: 1, // ResponsibleType: 1,
IsExistsAfterSale: false, // IsExistsAfterSale: false,
}, // },
{ // {
OrderType: 101, // OrderType: 101,
OrderNumber: "846052057729867777", // OrderNumber: "846052057729867777",
OrderAmount: 23, // OrderAmount: 23,
OrderPrice: 23, // OrderPrice: 23,
SignCompany: 1, // SignCompany: 1,
OrderQuantity: 1, // OrderQuantity: 1,
ResellerID: 25629, // ResellerID: 25629,
ResellerName: "二期财务分销商简称", // ResellerName: "二期财务分销商简称",
OurProductID: 104, // OurProductID: 104,
OurProductTitle: "优酷年卡", // OurProductTitle: "优酷年卡",
Account: []string{"18380416326"}, // Account: []string{"18380416326"},
Platforms: map[int]string{1: "爱瓦力"}, // Platforms: map[int]string{1: "爱瓦力"},
CreateTime: 1723305000, // CreateTime: 1723305000,
AfterType: 2, // AfterType: 2,
Remark: "测试售后2", // Remark: "测试售后2",
AfterAmount: 30, // AfterAmount: 30,
ResponsibleType: 2, // ResponsibleType: 2,
IsExistsAfterSale: false, // IsExistsAfterSale: false,
}, // },
}, // },
} // }
if len(req.OrderNumber) == 1 { // if len(req.OrderNumber) == 1 {
resp.Data = resp.Data[:1] // resp.Data = resp.Data[:1]
} // }
jsonByte, err := json.Marshal(resp) // jsonByte, err := json.Marshal(resp)
if err != nil { // if err != nil {
return err // return err
} // }
entitys.ResLog(requireData.Ch, t.Name(), "售后订单信息拉取完成") // entitys.ResLog(requireData.Ch, t.Name(), "售后订单信息拉取完成")
entitys.ResJson(requireData.Ch, t.Name(), string(jsonByte)) // entitys.ResJson(requireData.Ch, t.Name(), string(jsonByte))
return nil // return nil
} // }

View File

@ -4,6 +4,7 @@ import (
"ai_scheduler/internal/config" "ai_scheduler/internal/config"
"ai_scheduler/internal/entitys" "ai_scheduler/internal/entitys"
"ai_scheduler/internal/pkg/l_request" "ai_scheduler/internal/pkg/l_request"
"ai_scheduler/internal/pkg/util"
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
@ -35,10 +36,10 @@ func (t *OrderAfterSaleResellerBatchTool) Definition() entitys.ToolDefinition {
type OrderAfterSaleResellerBatchRequest struct { type OrderAfterSaleResellerBatchRequest struct {
OrderNumber []string `json:"orderNumber"` // 订单号 OrderNumber []string `json:"orderNumber"` // 订单号
AfterType int `json:"afterType"` // 处理方式 1.退款 2.扣款 AfterType string `json:"afterType"` // 处理方式 1.退款 2.扣款
AfterSalesPrice float64 `json:"afterSalesPrice"` // 售后金额 AfterSalesPrice string `json:"afterSalesPrice"` // 售后金额
AfterSalesReason string `json:"afterSalesReason"` // 售后原因 AfterSalesReason string `json:"afterSalesReason"` // 售后原因
ResponsibleType int `json:"responsibleType"` // 费用承担者 1.供应商 2.商务 3.公司 4.无 ResponsibleType string `json:"responsibleType"` // 费用承担者 1.供应商 2.商务 3.公司 4.无
ResponsiblePerson string `json:"responsiblePerson"` // 费用承担供应商 ResponsiblePerson string `json:"responsiblePerson"` // 费用承担供应商
} }
@ -63,7 +64,7 @@ type OrderAfterSaleResellerBatchData struct {
Platforms map[int]string `json:"platforms"` Platforms map[int]string `json:"platforms"`
AfterType int `json:"afterType"` // 处理方式 1.退款 2.扣款 AfterType int `json:"afterType"` // 处理方式 1.退款 2.扣款
Remark string `json:"remark"` // 售后原因 Remark string `json:"remark"` // 售后原因
AfterAmount float64 `json:"afterAmount"` // 售后金额 AfterAmount string `json:"afterAmount"` // 售后金额
ResponsibleType int `json:"responsibleType"` // 费用承担者 1.供应商 2.商务 3.公司 4.无 ResponsibleType int `json:"responsibleType"` // 费用承担者 1.供应商 2.商务 3.公司 4.无
ResponsiblePerson string `json:"responsiblePerson"` // 费用承担供应商 ResponsiblePerson string `json:"responsiblePerson"` // 费用承担供应商
IsExistsAfterSale bool `json:"isExistsAfterSale"` // 是否已存在售后 IsExistsAfterSale bool `json:"isExistsAfterSale"` // 是否已存在售后
@ -72,13 +73,13 @@ type OrderAfterSaleResellerBatchData struct {
// 接口返回 // 接口返回
type OrderAfterSaleResellerBatchApiResponse struct { type OrderAfterSaleResellerBatchApiResponse struct {
Code int `json:"code"` Code int `json:"code"`
Msg string `json:"msg"` Error string `json:"error"`
Data OrderAfterSaleResellerBatchApiData `json:"data"` Data OrderAfterSaleResellerBatchApiData `json:"data"`
} }
type OrderAfterSaleResellerBatchApiData struct { type OrderAfterSaleResellerBatchApiData struct {
Data []OrderAfterSaleResellerBatchApiBase `json:"data"` Data []OrderAfterSaleResellerBatchApiBase `json:"data"`
ExtData map[string]OrderAfterSaleResellerBatchApiExtItem `json:"ext"` ExtData map[string]OrderAfterSaleResellerBatchApiExtItem `json:"extraData"`
} }
type OrderAfterSaleResellerBatchApiBase struct { type OrderAfterSaleResellerBatchApiBase struct {
OrderType int `json:"orderType"` OrderType int `json:"orderType"`
@ -95,13 +96,14 @@ type OrderAfterSaleResellerBatchApiBase struct {
Platforms map[int]string `json:"platforms"` Platforms map[int]string `json:"platforms"`
} }
type OrderAfterSaleResellerBatchApiExtItem struct { type OrderAfterSaleResellerBatchApiExtItem struct {
IsExistsAfterSale bool `json:"isExistsAfterSale"` // 是否已存在售后 IsExistsAfterSale bool `json:"isExistsAfterSale"` // 是否已存在售后 - 未使用
SerialCreateTime int `json:"serialCreateTime"` // 流水创建时间 SerialCreateTime int `json:"createTime"` // 流水创建时间
} }
func (t *OrderAfterSaleResellerBatchTool) Execute(ctx context.Context, requireData *entitys.RequireData) error { func (t *OrderAfterSaleResellerBatchTool) Execute(ctx context.Context, requireData *entitys.RequireData) error {
var req OrderAfterSaleResellerBatchRequest var req OrderAfterSaleResellerBatchRequest
if err := json.Unmarshal([]byte(requireData.Match.Parameters), &req); err != nil { if err := json.Unmarshal([]byte(requireData.Match.Parameters), &req); err != nil {
entitys.ResError(requireData.Ch, t.Name(), "解析参数失败,请重试或联系管理员")
return err return err
} }
if len(req.OrderNumber) == 0 { if len(req.OrderNumber) == 0 {
@ -110,7 +112,7 @@ func (t *OrderAfterSaleResellerBatchTool) Execute(ctx context.Context, requireDa
entitys.ResLog(requireData.Ch, t.Name(), "正在拉取售后订单信息") entitys.ResLog(requireData.Ch, t.Name(), "正在拉取售后订单信息")
return t.checkOrderAfterSaleResellerBatchMock(req, requireData) return t.checkOrderAfterSaleResellerBatch(req, requireData)
} }
func (t *OrderAfterSaleResellerBatchTool) checkOrderAfterSaleResellerBatch(toolReq OrderAfterSaleResellerBatchRequest, requireData *entitys.RequireData) error { func (t *OrderAfterSaleResellerBatchTool) checkOrderAfterSaleResellerBatch(toolReq OrderAfterSaleResellerBatchRequest, requireData *entitys.RequireData) error {
@ -121,7 +123,8 @@ func (t *OrderAfterSaleResellerBatchTool) checkOrderAfterSaleResellerBatch(toolR
}, },
Method: "POST", Method: "POST",
Json: map[string]any{ Json: map[string]any{
"orderNumber": toolReq.OrderNumber, // 流水号 "order_numbers": toolReq.OrderNumber, // 流水号
"order_type": 2, // 2.批充
}, },
} }
res, err := req.Send() res, err := req.Send()
@ -133,13 +136,13 @@ func (t *OrderAfterSaleResellerBatchTool) checkOrderAfterSaleResellerBatch(toolR
if err = json.Unmarshal(res.Content, &resp); err != nil { if err = json.Unmarshal(res.Content, &resp); err != nil {
return err return err
} }
if resp.Code != 0 { if resp.Code != 200 {
return fmt.Errorf("after sale supplier failed: %s", resp.Msg) return fmt.Errorf("after sale supplier failed: %s", resp.Error)
} }
toolResp := OrderAfterSaleResellerBatchResponse{ toolResp := OrderAfterSaleResellerBatchResponse{
Code: resp.Code, Code: resp.Code,
Msg: resp.Msg, Msg: resp.Error,
Data: make([]*OrderAfterSaleResellerBatchData, 0, len(resp.Data.Data)), Data: make([]*OrderAfterSaleResellerBatchData, 0, len(resp.Data.Data)),
} }
@ -158,10 +161,10 @@ func (t *OrderAfterSaleResellerBatchTool) checkOrderAfterSaleResellerBatch(toolR
OurProductTitle: item.OurProductTitle, OurProductTitle: item.OurProductTitle,
Account: item.Account, Account: item.Account,
Platforms: item.Platforms, Platforms: item.Platforms,
AfterType: toolReq.AfterType, AfterType: util.StringToInt(toolReq.AfterType),
Remark: toolReq.AfterSalesReason, Remark: toolReq.AfterSalesReason,
AfterAmount: toolReq.AfterSalesPrice, AfterAmount: toolReq.AfterSalesPrice,
ResponsibleType: toolReq.ResponsibleType, ResponsibleType: util.StringToInt(toolReq.ResponsibleType),
ResponsiblePerson: toolReq.ResponsiblePerson, ResponsiblePerson: toolReq.ResponsiblePerson,
}) })
} }
@ -169,7 +172,7 @@ func (t *OrderAfterSaleResellerBatchTool) checkOrderAfterSaleResellerBatch(toolR
// 追加扩展数据 // 追加扩展数据
for _, item := range toolResp.Data { for _, item := range toolResp.Data {
if extItem, ok := resp.Data.ExtData[item.OrderNumber]; ok { if extItem, ok := resp.Data.ExtData[item.OrderNumber]; ok {
item.IsExistsAfterSale = extItem.IsExistsAfterSale item.IsExistsAfterSale = item.OrderType > 100 // 102 批充&已售后
item.CreateTime = extItem.SerialCreateTime item.CreateTime = extItem.SerialCreateTime
} }
} }
@ -183,65 +186,3 @@ func (t *OrderAfterSaleResellerBatchTool) checkOrderAfterSaleResellerBatch(toolR
entitys.ResJson(requireData.Ch, t.Name(), string(jsonByte)) entitys.ResJson(requireData.Ch, t.Name(), string(jsonByte))
return nil return nil
} }
func (t *OrderAfterSaleResellerBatchTool) checkOrderAfterSaleResellerBatchMock(req OrderAfterSaleResellerBatchRequest, requireData *entitys.RequireData) error {
resp := OrderAfterSaleResellerBatchResponse{
Code: 0,
Msg: "success",
Data: []*OrderAfterSaleResellerBatchData{
{
OrderType: 1,
OrderNumber: "846784115378364417",
OrderAmount: 0.1,
OrderPrice: 0.1,
SignCompany: 1,
OrderQuantity: 1,
ResellerID: 23329,
ResellerName: "分销商23329",
OurProductID: 106,
OurProductTitle: "爱奇艺黄金会员周卡",
Account: []string{"15516353308"},
Platforms: map[int]string{4: "爱奇艺"},
CreateTime: 1723304000,
AfterType: 1,
Remark: "测试售后",
AfterAmount: 50,
ResponsibleType: 1,
IsExistsAfterSale: false,
},
{
OrderType: 101,
OrderNumber: "846052057729867777",
OrderAmount: 23,
OrderPrice: 23,
SignCompany: 1,
OrderQuantity: 1,
ResellerID: 25629,
ResellerName: "二期财务分销商简称",
OurProductID: 104,
OurProductTitle: "优酷年卡",
Account: []string{"18380416326"},
Platforms: map[int]string{1: "爱瓦力"},
CreateTime: 1723305000,
AfterType: 2,
Remark: "测试售后2",
AfterAmount: 30,
ResponsibleType: 2,
IsExistsAfterSale: false,
},
},
}
if len(req.OrderNumber) == 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
}

View File

@ -94,13 +94,14 @@ type OrderAfterSaleSupplierApiBase struct {
ExecuteTime int `json:"executeTime"` // 充值执行时间 ExecuteTime int `json:"executeTime"` // 充值执行时间
} }
type OrderAfterSaleSupplierApiExtItem struct { type OrderAfterSaleSupplierApiExtItem struct {
IsExistsAfterSale bool `json:"existAfterSales"` // 是否已存在售后 IsExistsAfterSale bool `json:"existAfterSales"` // 是否已存在售后 - 未使用
SerialCreateTime int `json:"createTime"` // 流水创建时间 SerialCreateTime int `json:"createTime"` // 流水创建时间
} }
func (t *OrderAfterSaleSupplierTool) Execute(ctx context.Context, requireData *entitys.RequireData) error { func (t *OrderAfterSaleSupplierTool) Execute(ctx context.Context, requireData *entitys.RequireData) error {
var req OrderAfterSaleSupplierRequest var req OrderAfterSaleSupplierRequest
if err := json.Unmarshal([]byte(requireData.Match.Parameters), &req); err != nil { if err := json.Unmarshal([]byte(requireData.Match.Parameters), &req); err != nil {
entitys.ResError(requireData.Ch, t.Name(), "解析参数失败,请重试或联系管理员")
return err return err
} }
if len(req.SerialNumber) == 0 && len(req.Account) == 0 { if len(req.SerialNumber) == 0 && len(req.Account) == 0 {
@ -114,9 +115,13 @@ func (t *OrderAfterSaleSupplierTool) Execute(ctx context.Context, requireData *e
func (t *OrderAfterSaleSupplierTool) checkOrderAfterSaleSupplier(toolReq OrderAfterSaleSupplierRequest, requireData *entitys.RequireData) error { func (t *OrderAfterSaleSupplierTool) checkOrderAfterSaleSupplier(toolReq OrderAfterSaleSupplierRequest, requireData *entitys.RequireData) error {
// 流水创建时间上下浮动10min // 流水创建时间上下浮动10min
serialCreateTime, err := time.ParseInLocation(time.DateTime, toolReq.SerialCreateTime, time.Local) serialCreateTime := time.Now()
if err != nil { var err error
return err if toolReq.SerialCreateTime != "" {
serialCreateTime, err = time.ParseInLocation(time.DateTime, toolReq.SerialCreateTime, time.Local)
if err != nil {
return err
}
} }
serialStartTime := serialCreateTime.Unix() - 10*60 serialStartTime := serialCreateTime.Unix() - 10*60
serialEndTime := serialCreateTime.Unix() + 10*60 serialEndTime := serialCreateTime.Unix() + 10*60