作者 陈志颖

fix:导入订单的订单时间校验

... ... @@ -561,24 +561,24 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
hashValue := md5.Sum([]byte(dividendsOrder.OriginalOrderNum))
hashString := hex.EncodeToString(hashValue[:])
// 订单日期时间格式转换
timeValue, err := time.ParseInLocation("2006/01/02", dividendsOrder.OrderTime, time.Local)
if err != nil {
tmpRow := &domain.FailInfo{
FailReason: "无效的订单日期",
}
tmpRow.ImportDividendsOrderData = &dividendsOrder
aggregateErrorList = append(aggregateErrorList, tmpRow)
continue
}
if _, ok := dividendsOrderCommands[hashString]; !ok {
// 订单日期时间格式转换
timeValue, err := time.ParseInLocation("2006/01/02", dividendsOrder.OrderTime, time.Local)
if err != nil {
tmpRow := &domain.FailInfo{
FailReason: "无效的订单日期",
ImportDividendsOrderData: &importDividendsOrderCommand.DividendsOrderData[i],
}
aggregateErrorList = append(aggregateErrorList, tmpRow)
continue
}
// 产品相关:产品名称,产品数量、产品价格、费用
quantity, err := strconv.ParseFloat(dividendsOrder.OrderGoodQuantity, 64)
if err != nil {
tmpRow := &domain.FailInfo{
FailReason: "产品数量类型错误",
FailReason: "产品数量类型错误",
ImportDividendsOrderData: &importDividendsOrderCommand.DividendsOrderData[i],
}
tmpRow.ImportDividendsOrderData = &dividendsOrder
aggregateErrorList = append(aggregateErrorList, tmpRow)
... ... @@ -588,9 +588,9 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
price, err := strconv.ParseFloat(dividendsOrder.OrderGoodPrice, 64)
if err != nil {
tmpRow := &domain.FailInfo{
FailReason: "产品价格类型错误",
FailReason: "产品价格类型错误",
ImportDividendsOrderData: &importDividendsOrderCommand.DividendsOrderData[i],
}
tmpRow.ImportDividendsOrderData = &dividendsOrder
aggregateErrorList = append(aggregateErrorList, tmpRow)
continue
}
... ... @@ -599,9 +599,9 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
if dividendsOrder.Expense != "" {
if expenseParse, err := strconv.ParseFloat(dividendsOrder.Expense, 64); err != nil {
tmpRow := &domain.FailInfo{
FailReason: "费用类型错误",
FailReason: "费用类型错误",
ImportDividendsOrderData: &importDividendsOrderCommand.DividendsOrderData[i],
}
tmpRow.ImportDividendsOrderData = &dividendsOrder
aggregateErrorList = append(aggregateErrorList, tmpRow)
continue
} else {
... ... @@ -636,14 +636,26 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
UserBaseId: importDividendsOrderCommand.UserBaseId,
LineNumbers: []int{i}, // 记录行号
}
} else { // 聚合同一笔订单产品
} else if _, exist := dividendsOrderCommands[hashString]; exist { // 聚合同一笔订单产品
// 订单日期时间格式转换
timeValue, err := time.ParseInLocation("2006/01/02", dividendsOrder.OrderTime, time.Local)
if err != nil {
tmpRow := &domain.FailInfo{
FailReason: "无效的订单日期",
ImportDividendsOrderData: &importDividendsOrderCommand.DividendsOrderData[i],
}
aggregateErrorList = append(aggregateErrorList, tmpRow)
continue
}
// 产品相关:产品名称,产品数量、产品价格、费用
quantity, err := strconv.ParseFloat(dividendsOrder.OrderGoodQuantity, 64)
if err != nil {
tmpRow := &domain.FailInfo{
FailReason: "产品数量类型错误",
FailReason: "产品数量类型错误",
ImportDividendsOrderData: &importDividendsOrderCommand.DividendsOrderData[i],
}
tmpRow.ImportDividendsOrderData = &dividendsOrder
aggregateErrorList = append(aggregateErrorList, tmpRow)
continue
}
... ... @@ -651,9 +663,9 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
price, err := strconv.ParseFloat(dividendsOrder.OrderGoodPrice, 64)
if err != nil {
tmpRow := &domain.FailInfo{
FailReason: "产品价格类型错误",
FailReason: "产品价格类型错误",
ImportDividendsOrderData: &importDividendsOrderCommand.DividendsOrderData[i],
}
tmpRow.ImportDividendsOrderData = &dividendsOrder
aggregateErrorList = append(aggregateErrorList, tmpRow)
continue
}
... ... @@ -662,9 +674,9 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
if dividendsOrder.Expense != "" {
if expenseParse, err := strconv.ParseFloat(dividendsOrder.Expense, 64); err != nil {
tmpRow := &domain.FailInfo{
FailReason: "费用类型错误",
FailReason: "费用类型错误",
ImportDividendsOrderData: &importDividendsOrderCommand.DividendsOrderData[i],
}
tmpRow.ImportDividendsOrderData = &dividendsOrder
aggregateErrorList = append(aggregateErrorList, tmpRow)
continue
} else {
... ... @@ -686,7 +698,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
})
tmpRow := &domain.FailInfo{
FailReason: "同一笔订单的订单时间必须相同",
ImportDividendsOrderData: &dividendsOrder,
ImportDividendsOrderData: &importDividendsOrderCommand.DividendsOrderData[i],
}
aggregateErrorList = append(aggregateErrorList, tmpRow)
log.Logger.Info("聚合订单错误:", map[string]interface{}{
... ...
... ... @@ -589,7 +589,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
if err != nil {
tmpRow := &domain.FailReturnedInfo{
FailReason: "无效的订单日期",
ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
}
aggregateErrorList = append(aggregateErrorList, tmpRow)
continue
... ... @@ -600,7 +600,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
if err != nil {
tmpRow := &domain.FailReturnedInfo{
FailReason: "无效的退货日期",
ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
}
aggregateErrorList = append(aggregateErrorList, tmpRow)
continue
... ... @@ -611,7 +611,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
if err != nil {
tmpRow := &domain.FailReturnedInfo{
FailReason: "产品数量类型错误",
ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
}
aggregateErrorList = append(aggregateErrorList, tmpRow)
continue
... ... @@ -621,7 +621,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
if err != nil {
tmpRow := &domain.FailReturnedInfo{
FailReason: "产品价格类型错误",
ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
}
aggregateErrorList = append(aggregateErrorList, tmpRow)
continue
... ... @@ -661,7 +661,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
if err != nil {
tmpRow := &domain.FailReturnedInfo{
FailReason: "无效的订单日期",
ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
}
aggregateErrorList = append(aggregateErrorList, tmpRow)
continue
... ... @@ -672,7 +672,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
if err != nil {
tmpRow := &domain.FailReturnedInfo{
FailReason: "产品数量类型错误",
ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
}
aggregateErrorList = append(aggregateErrorList, tmpRow)
continue
... ... @@ -682,7 +682,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
if err != nil {
tmpRow := &domain.FailReturnedInfo{
FailReason: "产品价格类型错误",
ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
}
aggregateErrorList = append(aggregateErrorList, tmpRow)
continue
... ... @@ -691,7 +691,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
if strconv.FormatInt(timeValue.Local().UnixNano()/1e6, 10) != dividendsReturnedOrderCommands[hashString].OrderTime {
tmpRow := &domain.FailReturnedInfo{
FailReason: "同一笔退货单的订单时间必须相同",
ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
}
aggregateErrorList = append(aggregateErrorList, tmpRow)
continue
... ...