fix: 1.调整售后类型、费用承担着默认 2.售后金额string->float64 3.优化无数据响应
This commit is contained in:
parent
4656468e8a
commit
8895f29963
|
|
@ -26,3 +26,9 @@ func StringToInt(s string) int {
|
||||||
i, _ := strconv.Atoi(s)
|
i, _ := strconv.Atoi(s)
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// string 转 float64
|
||||||
|
func StringToFloat64(s string) float64 {
|
||||||
|
i, _ := strconv.ParseFloat(s, 64)
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,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 string `json:"afterAmount"` // 售后金额
|
AfterAmount float64 `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"` // 是否已存在售后
|
||||||
|
|
@ -107,8 +107,7 @@ type OrderAfterSaleResellerApiExtItem struct {
|
||||||
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 fmt.Errorf("解析参数失败,请重试或联系管理员")
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
if len(req.OrderNumber) == 0 && len(req.Account) == 0 {
|
if len(req.OrderNumber) == 0 && len(req.Account) == 0 {
|
||||||
return fmt.Errorf("订单号 和 充值账号 不能同时为空")
|
return fmt.Errorf("订单号 和 充值账号 不能同时为空")
|
||||||
|
|
@ -190,6 +189,11 @@ func (t *OrderAfterSaleResellerTool) checkOrderAfterSaleReseller(toolReq OrderAf
|
||||||
return fmt.Errorf("订单号 和 充值账号 不能同时为空")
|
return fmt.Errorf("订单号 和 充值账号 不能同时为空")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 未查询到相应售后订单,请核实提供信息是否正确
|
||||||
|
if len(orderList) == 0 {
|
||||||
|
return fmt.Errorf("未查询到相应售后订单,请核实提供信息是否正确")
|
||||||
|
}
|
||||||
|
|
||||||
toolResp := OrderAfterSaleResellerResponse{
|
toolResp := OrderAfterSaleResellerResponse{
|
||||||
Code: 0,
|
Code: 0,
|
||||||
Msg: "Success",
|
Msg: "Success",
|
||||||
|
|
@ -231,6 +235,17 @@ func (t *OrderAfterSaleResellerTool) getAfterSaleResellerList(headers map[string
|
||||||
|
|
||||||
// 转换数据
|
// 转换数据
|
||||||
for _, item := range resp.Data.Data {
|
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{
|
orderList = append(orderList, &OrderAfterSaleResellerData{
|
||||||
OrderType: item.OrderType,
|
OrderType: item.OrderType,
|
||||||
OrderNumber: item.OrderNumber,
|
OrderNumber: item.OrderNumber,
|
||||||
|
|
@ -244,10 +259,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: util.StringToInt(originInput.AfterType),
|
AfterType: afterType,
|
||||||
Remark: originInput.AfterSalesReason,
|
Remark: originInput.AfterSalesReason,
|
||||||
AfterAmount: originInput.AfterSalesPrice,
|
AfterAmount: util.StringToFloat64(originInput.AfterSalesPrice),
|
||||||
ResponsibleType: util.StringToInt(originInput.ResponsibleType),
|
ResponsibleType: responsibleType,
|
||||||
ResponsiblePerson: originInput.ResponsiblePerson,
|
ResponsiblePerson: originInput.ResponsiblePerson,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,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 string `json:"afterAmount"` // 售后金额
|
AfterAmount float64 `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"` // 是否已存在售后
|
||||||
|
|
@ -103,8 +103,7 @@ type OrderAfterSaleResellerBatchApiExtItem struct {
|
||||||
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 fmt.Errorf("解析参数失败,请重试或联系管理员")
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
if len(req.OrderNumber) == 0 {
|
if len(req.OrderNumber) == 0 {
|
||||||
return fmt.Errorf("批充订单号不能为空")
|
return fmt.Errorf("批充订单号不能为空")
|
||||||
|
|
@ -137,7 +136,10 @@ func (t *OrderAfterSaleResellerBatchTool) checkOrderAfterSaleResellerBatch(toolR
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if resp.Code != 200 {
|
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{
|
toolResp := OrderAfterSaleResellerBatchResponse{
|
||||||
|
|
@ -148,6 +150,17 @@ func (t *OrderAfterSaleResellerBatchTool) checkOrderAfterSaleResellerBatch(toolR
|
||||||
|
|
||||||
// 转换数据
|
// 转换数据
|
||||||
for _, item := range resp.Data.Data {
|
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{
|
toolResp.Data = append(toolResp.Data, &OrderAfterSaleResellerBatchData{
|
||||||
OrderType: item.OrderType,
|
OrderType: item.OrderType,
|
||||||
OrderNumber: item.OrderNumber,
|
OrderNumber: item.OrderNumber,
|
||||||
|
|
@ -161,10 +174,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: util.StringToInt(toolReq.AfterType),
|
AfterType: afterType,
|
||||||
Remark: toolReq.AfterSalesReason,
|
Remark: toolReq.AfterSalesReason,
|
||||||
AfterAmount: toolReq.AfterSalesPrice,
|
AfterAmount: util.StringToFloat64(toolReq.AfterSalesPrice),
|
||||||
ResponsibleType: util.StringToInt(toolReq.ResponsibleType),
|
ResponsibleType: responsibleType,
|
||||||
ResponsiblePerson: toolReq.ResponsiblePerson,
|
ResponsiblePerson: toolReq.ResponsiblePerson,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,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 string `json:"salePrice"` // 售后金额
|
SalePrice float64 `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"` // 是否已存在售后
|
||||||
|
|
@ -101,8 +101,7 @@ type OrderAfterSaleSupplierApiExtItem struct {
|
||||||
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 fmt.Errorf("解析参数失败,请重试或联系管理员")
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
if len(req.SerialNumber) == 0 && len(req.Account) == 0 {
|
if len(req.SerialNumber) == 0 && len(req.Account) == 0 {
|
||||||
return fmt.Errorf("充值流水号 和 充值账号 不能同时为空")
|
return fmt.Errorf("充值流水号 和 充值账号 不能同时为空")
|
||||||
|
|
@ -182,6 +181,11 @@ func (t *OrderAfterSaleSupplierTool) checkOrderAfterSaleSupplier(toolReq OrderAf
|
||||||
return fmt.Errorf("充值流水号 和 充值账号 不能同时为空")
|
return fmt.Errorf("充值流水号 和 充值账号 不能同时为空")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 未查询到相应售后订单,请核实提供信息是否正确
|
||||||
|
if len(orderList) == 0 {
|
||||||
|
return fmt.Errorf("未查询到相应售后订单,请核实提供信息是否正确")
|
||||||
|
}
|
||||||
|
|
||||||
toolResp := OrderAfterSaleSupplierResponse{
|
toolResp := OrderAfterSaleSupplierResponse{
|
||||||
Code: 0,
|
Code: 0,
|
||||||
Msg: "Success",
|
Msg: "Success",
|
||||||
|
|
@ -223,6 +227,12 @@ func (t *OrderAfterSaleSupplierTool) getAfterSaleSupplierList(headers map[string
|
||||||
|
|
||||||
// 转换数据
|
// 转换数据
|
||||||
for _, item := range resp.Data.Data {
|
for _, item := range resp.Data.Data {
|
||||||
|
// 处理方式
|
||||||
|
afterType := util.StringToInt(originInput.AfterType)
|
||||||
|
if afterType == 0 {
|
||||||
|
afterType = 1 // 默认退款
|
||||||
|
}
|
||||||
|
|
||||||
orderList = append(orderList, &OrderAfterSaleSupplierData{
|
orderList = append(orderList, &OrderAfterSaleSupplierData{
|
||||||
SerialNumber: item.SerialNumber,
|
SerialNumber: item.SerialNumber,
|
||||||
PlatformName: item.PlatformName,
|
PlatformName: item.PlatformName,
|
||||||
|
|
@ -235,8 +245,8 @@ func (t *OrderAfterSaleSupplierTool) getAfterSaleSupplierList(headers map[string
|
||||||
PlatformID: item.PlatformID,
|
PlatformID: item.PlatformID,
|
||||||
SignCompanyName: item.SignCompanyName,
|
SignCompanyName: item.SignCompanyName,
|
||||||
Reason: originInput.AfterSalesReason,
|
Reason: originInput.AfterSalesReason,
|
||||||
SalePrice: originInput.AfterSalesPrice,
|
SalePrice: util.StringToFloat64(originInput.AfterSalesPrice),
|
||||||
SaleType: util.StringToInt(originInput.AfterType),
|
SaleType: afterType,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue