feat: 上游售后接入实际zltx接口
This commit is contained in:
parent
2a312dc205
commit
43522037db
|
|
@ -57,13 +57,13 @@ tools:
|
||||||
api_secret: "ObqxwyR20r9rVNhju0sCPQyQA98_FZSc32W4vgxnGFH_b02HZr1BPCJsOAF816nu"
|
api_secret: "ObqxwyR20r9rVNhju0sCPQyQA98_FZSc32W4vgxnGFH_b02HZr1BPCJsOAF816nu"
|
||||||
zltxOrderAfterSaleSupplier:
|
zltxOrderAfterSaleSupplier:
|
||||||
enabled: true
|
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:
|
zltxOrderAfterSaleReseller:
|
||||||
enabled: true
|
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:
|
zltxOrderAfterSaleResellerBatch:
|
||||||
enabled: true
|
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"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -19,3 +20,9 @@ func EscapeJSONString(s string) string {
|
||||||
b, _ := json.Marshal(s)
|
b, _ := json.Marshal(s)
|
||||||
return string(b[1 : len(b)-1])
|
return string(b[1 : len(b)-1])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// string 转 int
|
||||||
|
func StringToInt(s string) int {
|
||||||
|
i, _ := strconv.Atoi(s)
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
@ -41,7 +42,7 @@ type OrderAfterSaleSupplierRequest struct {
|
||||||
SerialCreateTime string `json:"serialCreateTime"` // 流水创建时间
|
SerialCreateTime string `json:"serialCreateTime"` // 流水创建时间
|
||||||
AfterSalesReason string `json:"afterSalesReason"` // 售后原因
|
AfterSalesReason string `json:"afterSalesReason"` // 售后原因
|
||||||
AfterSalesPrice string `json:"afterSalesPrice"` // 售后金额
|
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
|
PlatformID int `json:"platformId"` // 上游平台id
|
||||||
SignCompanyName string `json:"signCompanyName"` // 签约主体名称
|
SignCompanyName string `json:"signCompanyName"` // 签约主体名称
|
||||||
Reason string `json:"reason"` // 售后原因
|
Reason string `json:"reason"` // 售后原因
|
||||||
SalePrice float64 `json:"salePrice"` // 售后金额
|
SalePrice string `json:"salePrice"` // 售后金额
|
||||||
SaleType int `json:"saleType"` // 处理方式 1.加款 2.扣款
|
SaleType int `json:"saleType"` // 处理方式 1.加款 2.扣款
|
||||||
ExecuteTime int `json:"executeTime"` // 流水创建时间
|
ExecuteTime int `json:"executeTime"` // 流水创建时间
|
||||||
IsExistsAfterSale bool `json:"isExistsAfterSale"` // 是否已存在售后
|
IsExistsAfterSale bool `json:"isExistsAfterSale"` // 是否已存在售后
|
||||||
|
|
@ -72,12 +73,12 @@ type OrderAfterSaleSupplierData struct {
|
||||||
// 接口返回
|
// 接口返回
|
||||||
type OrderAfterSaleSupplierApiResponse struct {
|
type OrderAfterSaleSupplierApiResponse struct {
|
||||||
Code int `json:"code"`
|
Code int `json:"code"`
|
||||||
Msg string `json:"msg"`
|
Error string `json:"error"`
|
||||||
Data OrderAfterSaleSupplierApiData `json:"data"`
|
Data OrderAfterSaleSupplierApiData `json:"data"`
|
||||||
}
|
}
|
||||||
type OrderAfterSaleSupplierApiData struct {
|
type OrderAfterSaleSupplierApiData struct {
|
||||||
Data []OrderAfterSaleSupplierApiBase `json:"data"`
|
Data []OrderAfterSaleSupplierApiBase `json:"data"`
|
||||||
ExtData map[string]OrderAfterSaleSupplierApiExtItem `json:"ext"`
|
ExtData map[string]OrderAfterSaleSupplierApiExtItem `json:"extraData"`
|
||||||
}
|
}
|
||||||
type OrderAfterSaleSupplierApiBase struct {
|
type OrderAfterSaleSupplierApiBase struct {
|
||||||
SerialNumber string `json:"serialNumber"` // 流水号
|
SerialNumber string `json:"serialNumber"` // 流水号
|
||||||
|
|
@ -90,13 +91,11 @@ type OrderAfterSaleSupplierApiBase struct {
|
||||||
PlatformProductID int `json:"platformProductId"` // 上有商品id
|
PlatformProductID int `json:"platformProductId"` // 上有商品id
|
||||||
PlatformID int `json:"platformId"` // 上游平台id
|
PlatformID int `json:"platformId"` // 上游平台id
|
||||||
SignCompanyName string `json:"signCompanyName"` // 签约主体名称
|
SignCompanyName string `json:"signCompanyName"` // 签约主体名称
|
||||||
Reason string `json:"reason"` // 售后原因
|
ExecuteTime int `json:"executeTime"` // 充值执行时间
|
||||||
SalePrice float64 `json:"salePrice"` // 售后金额
|
|
||||||
SaleType int `json:"saleType"` // 处理方式 1.加款 2.扣款
|
|
||||||
}
|
}
|
||||||
type OrderAfterSaleSupplierApiExtItem struct {
|
type OrderAfterSaleSupplierApiExtItem struct {
|
||||||
IsExistsAfterSale bool `json:"isExistsAfterSale"` // 是否已存在售后
|
IsExistsAfterSale bool `json:"existAfterSales"` // 是否已存在售后
|
||||||
SerialCreateTime int `json:"serialCreateTime"` // 流水创建时间
|
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 {
|
||||||
|
|
@ -110,7 +109,7 @@ func (t *OrderAfterSaleSupplierTool) Execute(ctx context.Context, requireData *e
|
||||||
|
|
||||||
entitys.ResLog(requireData.Ch, t.Name(), "正在拉取售后订单信息")
|
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 {
|
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 {
|
if len(toolReq.SerialNumber) > 0 {
|
||||||
body := map[string]any{
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -157,10 +156,9 @@ func (t *OrderAfterSaleSupplierTool) checkOrderAfterSaleSupplier(toolReq OrderAf
|
||||||
|
|
||||||
body := map[string]any{
|
body := map[string]any{
|
||||||
"account": account, // 充值账号
|
"account": account, // 充值账号
|
||||||
"serialStartTime": serialStartTime, // 流水创建时间
|
"create_time": []int64{serialStartTime, serialEndTime}, // 流水创建时间区间
|
||||||
"serialEndTime": serialEndTime, // 流水结束时间
|
|
||||||
}
|
}
|
||||||
orderListIn, errIn := t.getAfterSaleSupplierList(headers, body)
|
orderListIn, errIn := t.getAfterSaleSupplierList(headers, body, toolReq)
|
||||||
if errIn != nil {
|
if errIn != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -196,7 +194,7 @@ func (t *OrderAfterSaleSupplierTool) checkOrderAfterSaleSupplier(toolReq OrderAf
|
||||||
return nil
|
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{
|
req := l_request.Request{
|
||||||
Url: t.config.BaseURL,
|
Url: t.config.BaseURL,
|
||||||
Headers: headers,
|
Headers: headers,
|
||||||
|
|
@ -212,8 +210,8 @@ func (t *OrderAfterSaleSupplierTool) getAfterSaleSupplierList(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 supplier failed: %s", resp.Msg)
|
return nil, fmt.Errorf("after sale supplier failed: %s", resp.Error)
|
||||||
}
|
}
|
||||||
|
|
||||||
orderList := make([]*OrderAfterSaleSupplierData, 0, len(resp.Data.Data))
|
orderList := make([]*OrderAfterSaleSupplierData, 0, len(resp.Data.Data))
|
||||||
|
|
@ -231,9 +229,9 @@ func (t *OrderAfterSaleSupplierTool) getAfterSaleSupplierList(headers map[string
|
||||||
PlatformProductID: item.PlatformProductID,
|
PlatformProductID: item.PlatformProductID,
|
||||||
PlatformID: item.PlatformID,
|
PlatformID: item.PlatformID,
|
||||||
SignCompanyName: item.SignCompanyName,
|
SignCompanyName: item.SignCompanyName,
|
||||||
Reason: item.Reason,
|
Reason: originInput.AfterSalesReason,
|
||||||
SalePrice: item.SalePrice,
|
SalePrice: originInput.AfterSalesPrice,
|
||||||
SaleType: item.SaleType,
|
SaleType: util.StringToInt(originInput.AfterType),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -247,60 +245,3 @@ func (t *OrderAfterSaleSupplierTool) getAfterSaleSupplierList(headers map[string
|
||||||
|
|
||||||
return orderList, nil
|
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
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue