fix: 1.时间不传时,默认30d内 2.解析后的时间格式异常,时间置为空 3.售后金额为空时,默认订单金额

This commit is contained in:
fuzhongyun 2025-11-27 16:29:58 +08:00
parent aba8a18900
commit 3510be1db7
3 changed files with 54 additions and 16 deletions

View File

@ -112,6 +112,14 @@ func (t *OrderAfterSaleResellerTool) Execute(ctx context.Context, requireData *e
if len(req.OrderNumber) == 0 && len(req.Account) == 0 {
return fmt.Errorf("订单号 和 充值账号 不能同时为空")
}
// 时间格式不匹配,直接置为空
if req.SerialCreateTime != "" {
_, err := time.ParseInLocation(time.DateTime, req.SerialCreateTime, time.Local)
if err != nil {
entitys.ResLog(requireData.Ch, t.Name(), "时间格式不匹配,已置为空")
req.SerialCreateTime = ""
}
}
entitys.ResLog(requireData.Ch, t.Name(), "正在拉取售后订单信息")
@ -119,19 +127,21 @@ func (t *OrderAfterSaleResellerTool) Execute(ctx context.Context, requireData *e
}
func (t *OrderAfterSaleResellerTool) checkOrderAfterSaleReseller(toolReq OrderAfterSaleResellerRequest, requireData *entitys.RequireData) error {
// 流水创建时间上下浮动10min
serialCreateTime := time.Now()
var err error
var serialStartTime, serialEndTime int64
if toolReq.SerialCreateTime != "" {
serialCreateTime, err = time.ParseInLocation(time.DateTime, toolReq.SerialCreateTime, time.Local)
// 流水创建时间上下浮动10min
serialCreateTime, err := time.ParseInLocation(time.DateTime, toolReq.SerialCreateTime, time.Local)
if err != nil {
return err
}
serialStartTime = serialCreateTime.Unix() - 10*60
serialEndTime = serialCreateTime.Unix() + 10*60
} else {
// 未指定流水创建时间默认30天内
serialEndTime = time.Now().Unix()
serialStartTime = serialEndTime - 60*60*24*30 // 30天内
}
serialStartTime := serialCreateTime.Unix() - 10*60
serialEndTime := serialCreateTime.Unix() + 10*60
// 账号数量超过10直接截断
if len(toolReq.Account) > 10 {
entitys.ResLog(requireData.Ch, t.Name(), "账号数量超过10已被截断")
@ -144,6 +154,7 @@ func (t *OrderAfterSaleResellerTool) checkOrderAfterSaleReseller(toolReq OrderAf
// 最终输出
var orderList []*OrderAfterSaleResellerData
var err error
// 多订单号
if len(toolReq.OrderNumber) > 0 {
@ -245,6 +256,11 @@ func (t *OrderAfterSaleResellerTool) getAfterSaleResellerList(headers map[string
if responsibleType == 0 {
responsibleType = 4 // 默认无
}
// 售后金额
afterSalesPrice := util.StringToFloat64(originInput.AfterSalesPrice)
if afterSalesPrice == 0 {
afterSalesPrice = item.OrderPrice
}
orderList = append(orderList, &OrderAfterSaleResellerData{
OrderType: item.OrderType,
@ -261,7 +277,7 @@ func (t *OrderAfterSaleResellerTool) getAfterSaleResellerList(headers map[string
Platforms: item.Platforms,
AfterType: afterType,
Remark: originInput.AfterSalesReason,
AfterAmount: util.StringToFloat64(originInput.AfterSalesPrice),
AfterAmount: afterSalesPrice,
ResponsibleType: responsibleType,
ResponsiblePerson: originInput.ResponsiblePerson,
})

View File

@ -160,6 +160,11 @@ func (t *OrderAfterSaleResellerBatchTool) checkOrderAfterSaleResellerBatch(toolR
if responsibleType == 0 {
responsibleType = 4 // 默认无
}
// 售后金额
afterSalesPrice := util.StringToFloat64(toolReq.AfterSalesPrice)
if afterSalesPrice == 0 {
afterSalesPrice = item.OrderPrice
}
toolResp.Data = append(toolResp.Data, &OrderAfterSaleResellerBatchData{
OrderType: item.OrderType,
@ -176,7 +181,7 @@ func (t *OrderAfterSaleResellerBatchTool) checkOrderAfterSaleResellerBatch(toolR
Platforms: item.Platforms,
AfterType: afterType,
Remark: toolReq.AfterSalesReason,
AfterAmount: util.StringToFloat64(toolReq.AfterSalesPrice),
AfterAmount: afterSalesPrice,
ResponsibleType: responsibleType,
ResponsiblePerson: toolReq.ResponsiblePerson,
})

View File

@ -106,6 +106,14 @@ func (t *OrderAfterSaleSupplierTool) Execute(ctx context.Context, requireData *e
if len(req.SerialNumber) == 0 && len(req.Account) == 0 {
return fmt.Errorf("充值流水号 和 充值账号 不能同时为空")
}
// 时间格式不匹配,直接置为空
if req.SerialCreateTime != "" {
_, err := time.ParseInLocation(time.DateTime, req.SerialCreateTime, time.Local)
if err != nil {
entitys.ResLog(requireData.Ch, t.Name(), "时间格式不匹配,已置为空")
req.SerialCreateTime = ""
}
}
entitys.ResLog(requireData.Ch, t.Name(), "正在拉取售后订单信息")
@ -113,17 +121,20 @@ func (t *OrderAfterSaleSupplierTool) Execute(ctx context.Context, requireData *e
}
func (t *OrderAfterSaleSupplierTool) checkOrderAfterSaleSupplier(toolReq OrderAfterSaleSupplierRequest, requireData *entitys.RequireData) error {
// 流水创建时间上下浮动10min
serialCreateTime := time.Now()
var err error
var serialStartTime, serialEndTime int64
if toolReq.SerialCreateTime != "" {
serialCreateTime, err = time.ParseInLocation(time.DateTime, toolReq.SerialCreateTime, time.Local)
// 流水创建时间上下浮动10min
serialCreateTime, err := time.ParseInLocation(time.DateTime, toolReq.SerialCreateTime, time.Local)
if err != nil {
return err
}
serialStartTime = serialCreateTime.Unix() - 10*60
serialEndTime = serialCreateTime.Unix() + 10*60
} else {
// 未指定流水创建时间默认30天内
serialEndTime = time.Now().Unix()
serialStartTime = serialEndTime - 60*60*24*30 // 30天内
}
serialStartTime := serialCreateTime.Unix() - 10*60
serialEndTime := serialCreateTime.Unix() + 10*60
// 账号数量超过10直接截断
if len(toolReq.Account) > 10 {
@ -137,6 +148,7 @@ func (t *OrderAfterSaleSupplierTool) checkOrderAfterSaleSupplier(toolReq OrderAf
// 最终输出
var orderList []*OrderAfterSaleSupplierData
var err error
// 多流水号
if len(toolReq.SerialNumber) > 0 {
@ -232,6 +244,11 @@ func (t *OrderAfterSaleSupplierTool) getAfterSaleSupplierList(headers map[string
if afterType == 0 {
afterType = 1 // 默认退款
}
// 售后金额
afterSalesPrice := util.StringToFloat64(originInput.AfterSalesPrice)
if afterSalesPrice == 0 {
afterSalesPrice = item.PlatformPrice
}
orderList = append(orderList, &OrderAfterSaleSupplierData{
SerialNumber: item.SerialNumber,
@ -245,7 +262,7 @@ func (t *OrderAfterSaleSupplierTool) getAfterSaleSupplierList(headers map[string
PlatformID: item.PlatformID,
SignCompanyName: item.SignCompanyName,
Reason: originInput.AfterSalesReason,
SalePrice: util.StringToFloat64(originInput.AfterSalesPrice),
SalePrice: afterSalesPrice,
SaleType: afterType,
})
}