作者 陈志颖

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

@@ -561,24 +561,24 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -561,24 +561,24 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
561 hashValue := md5.Sum([]byte(dividendsOrder.OriginalOrderNum)) 561 hashValue := md5.Sum([]byte(dividendsOrder.OriginalOrderNum))
562 hashString := hex.EncodeToString(hashValue[:]) 562 hashString := hex.EncodeToString(hashValue[:])
563 563
564 - // 订单日期时间格式转换  
565 - timeValue, err := time.ParseInLocation("2006/01/02", dividendsOrder.OrderTime, time.Local)  
566 - if err != nil {  
567 - tmpRow := &domain.FailInfo{  
568 - FailReason: "无效的订单日期",  
569 - }  
570 - tmpRow.ImportDividendsOrderData = &dividendsOrder  
571 - aggregateErrorList = append(aggregateErrorList, tmpRow)  
572 - continue  
573 - }  
574 -  
575 if _, ok := dividendsOrderCommands[hashString]; !ok { 564 if _, ok := dividendsOrderCommands[hashString]; !ok {
  565 + // 订单日期时间格式转换
  566 + timeValue, err := time.ParseInLocation("2006/01/02", dividendsOrder.OrderTime, time.Local)
  567 + if err != nil {
  568 + tmpRow := &domain.FailInfo{
  569 + FailReason: "无效的订单日期",
  570 + ImportDividendsOrderData: &importDividendsOrderCommand.DividendsOrderData[i],
  571 + }
  572 + aggregateErrorList = append(aggregateErrorList, tmpRow)
  573 + continue
  574 + }
576 575
577 // 产品相关:产品名称,产品数量、产品价格、费用 576 // 产品相关:产品名称,产品数量、产品价格、费用
578 quantity, err := strconv.ParseFloat(dividendsOrder.OrderGoodQuantity, 64) 577 quantity, err := strconv.ParseFloat(dividendsOrder.OrderGoodQuantity, 64)
579 if err != nil { 578 if err != nil {
580 tmpRow := &domain.FailInfo{ 579 tmpRow := &domain.FailInfo{
581 - FailReason: "产品数量类型错误", 580 + FailReason: "产品数量类型错误",
  581 + ImportDividendsOrderData: &importDividendsOrderCommand.DividendsOrderData[i],
582 } 582 }
583 tmpRow.ImportDividendsOrderData = &dividendsOrder 583 tmpRow.ImportDividendsOrderData = &dividendsOrder
584 aggregateErrorList = append(aggregateErrorList, tmpRow) 584 aggregateErrorList = append(aggregateErrorList, tmpRow)
@@ -588,9 +588,9 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -588,9 +588,9 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
588 price, err := strconv.ParseFloat(dividendsOrder.OrderGoodPrice, 64) 588 price, err := strconv.ParseFloat(dividendsOrder.OrderGoodPrice, 64)
589 if err != nil { 589 if err != nil {
590 tmpRow := &domain.FailInfo{ 590 tmpRow := &domain.FailInfo{
591 - FailReason: "产品价格类型错误", 591 + FailReason: "产品价格类型错误",
  592 + ImportDividendsOrderData: &importDividendsOrderCommand.DividendsOrderData[i],
592 } 593 }
593 - tmpRow.ImportDividendsOrderData = &dividendsOrder  
594 aggregateErrorList = append(aggregateErrorList, tmpRow) 594 aggregateErrorList = append(aggregateErrorList, tmpRow)
595 continue 595 continue
596 } 596 }
@@ -599,9 +599,9 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -599,9 +599,9 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
599 if dividendsOrder.Expense != "" { 599 if dividendsOrder.Expense != "" {
600 if expenseParse, err := strconv.ParseFloat(dividendsOrder.Expense, 64); err != nil { 600 if expenseParse, err := strconv.ParseFloat(dividendsOrder.Expense, 64); err != nil {
601 tmpRow := &domain.FailInfo{ 601 tmpRow := &domain.FailInfo{
602 - FailReason: "费用类型错误", 602 + FailReason: "费用类型错误",
  603 + ImportDividendsOrderData: &importDividendsOrderCommand.DividendsOrderData[i],
603 } 604 }
604 - tmpRow.ImportDividendsOrderData = &dividendsOrder  
605 aggregateErrorList = append(aggregateErrorList, tmpRow) 605 aggregateErrorList = append(aggregateErrorList, tmpRow)
606 continue 606 continue
607 } else { 607 } else {
@@ -636,14 +636,26 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -636,14 +636,26 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
636 UserBaseId: importDividendsOrderCommand.UserBaseId, 636 UserBaseId: importDividendsOrderCommand.UserBaseId,
637 LineNumbers: []int{i}, // 记录行号 637 LineNumbers: []int{i}, // 记录行号
638 } 638 }
639 - } else { // 聚合同一笔订单产品 639 +
  640 + } else if _, exist := dividendsOrderCommands[hashString]; exist { // 聚合同一笔订单产品
  641 + // 订单日期时间格式转换
  642 + timeValue, err := time.ParseInLocation("2006/01/02", dividendsOrder.OrderTime, time.Local)
  643 + if err != nil {
  644 + tmpRow := &domain.FailInfo{
  645 + FailReason: "无效的订单日期",
  646 + ImportDividendsOrderData: &importDividendsOrderCommand.DividendsOrderData[i],
  647 + }
  648 + aggregateErrorList = append(aggregateErrorList, tmpRow)
  649 + continue
  650 + }
  651 +
640 // 产品相关:产品名称,产品数量、产品价格、费用 652 // 产品相关:产品名称,产品数量、产品价格、费用
641 quantity, err := strconv.ParseFloat(dividendsOrder.OrderGoodQuantity, 64) 653 quantity, err := strconv.ParseFloat(dividendsOrder.OrderGoodQuantity, 64)
642 if err != nil { 654 if err != nil {
643 tmpRow := &domain.FailInfo{ 655 tmpRow := &domain.FailInfo{
644 - FailReason: "产品数量类型错误", 656 + FailReason: "产品数量类型错误",
  657 + ImportDividendsOrderData: &importDividendsOrderCommand.DividendsOrderData[i],
645 } 658 }
646 - tmpRow.ImportDividendsOrderData = &dividendsOrder  
647 aggregateErrorList = append(aggregateErrorList, tmpRow) 659 aggregateErrorList = append(aggregateErrorList, tmpRow)
648 continue 660 continue
649 } 661 }
@@ -651,9 +663,9 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -651,9 +663,9 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
651 price, err := strconv.ParseFloat(dividendsOrder.OrderGoodPrice, 64) 663 price, err := strconv.ParseFloat(dividendsOrder.OrderGoodPrice, 64)
652 if err != nil { 664 if err != nil {
653 tmpRow := &domain.FailInfo{ 665 tmpRow := &domain.FailInfo{
654 - FailReason: "产品价格类型错误", 666 + FailReason: "产品价格类型错误",
  667 + ImportDividendsOrderData: &importDividendsOrderCommand.DividendsOrderData[i],
655 } 668 }
656 - tmpRow.ImportDividendsOrderData = &dividendsOrder  
657 aggregateErrorList = append(aggregateErrorList, tmpRow) 669 aggregateErrorList = append(aggregateErrorList, tmpRow)
658 continue 670 continue
659 } 671 }
@@ -662,9 +674,9 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -662,9 +674,9 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
662 if dividendsOrder.Expense != "" { 674 if dividendsOrder.Expense != "" {
663 if expenseParse, err := strconv.ParseFloat(dividendsOrder.Expense, 64); err != nil { 675 if expenseParse, err := strconv.ParseFloat(dividendsOrder.Expense, 64); err != nil {
664 tmpRow := &domain.FailInfo{ 676 tmpRow := &domain.FailInfo{
665 - FailReason: "费用类型错误", 677 + FailReason: "费用类型错误",
  678 + ImportDividendsOrderData: &importDividendsOrderCommand.DividendsOrderData[i],
666 } 679 }
667 - tmpRow.ImportDividendsOrderData = &dividendsOrder  
668 aggregateErrorList = append(aggregateErrorList, tmpRow) 680 aggregateErrorList = append(aggregateErrorList, tmpRow)
669 continue 681 continue
670 } else { 682 } else {
@@ -686,7 +698,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -686,7 +698,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
686 }) 698 })
687 tmpRow := &domain.FailInfo{ 699 tmpRow := &domain.FailInfo{
688 FailReason: "同一笔订单的订单时间必须相同", 700 FailReason: "同一笔订单的订单时间必须相同",
689 - ImportDividendsOrderData: &dividendsOrder, 701 + ImportDividendsOrderData: &importDividendsOrderCommand.DividendsOrderData[i],
690 } 702 }
691 aggregateErrorList = append(aggregateErrorList, tmpRow) 703 aggregateErrorList = append(aggregateErrorList, tmpRow)
692 log.Logger.Info("聚合订单错误:", map[string]interface{}{ 704 log.Logger.Info("聚合订单错误:", map[string]interface{}{
@@ -589,7 +589,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -589,7 +589,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
589 if err != nil { 589 if err != nil {
590 tmpRow := &domain.FailReturnedInfo{ 590 tmpRow := &domain.FailReturnedInfo{
591 FailReason: "无效的订单日期", 591 FailReason: "无效的订单日期",
592 - ImportDividendsReturnedOrderData: &dividendsReturnedOrder, 592 + ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
593 } 593 }
594 aggregateErrorList = append(aggregateErrorList, tmpRow) 594 aggregateErrorList = append(aggregateErrorList, tmpRow)
595 continue 595 continue
@@ -600,7 +600,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -600,7 +600,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
600 if err != nil { 600 if err != nil {
601 tmpRow := &domain.FailReturnedInfo{ 601 tmpRow := &domain.FailReturnedInfo{
602 FailReason: "无效的退货日期", 602 FailReason: "无效的退货日期",
603 - ImportDividendsReturnedOrderData: &dividendsReturnedOrder, 603 + ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
604 } 604 }
605 aggregateErrorList = append(aggregateErrorList, tmpRow) 605 aggregateErrorList = append(aggregateErrorList, tmpRow)
606 continue 606 continue
@@ -611,7 +611,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -611,7 +611,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
611 if err != nil { 611 if err != nil {
612 tmpRow := &domain.FailReturnedInfo{ 612 tmpRow := &domain.FailReturnedInfo{
613 FailReason: "产品数量类型错误", 613 FailReason: "产品数量类型错误",
614 - ImportDividendsReturnedOrderData: &dividendsReturnedOrder, 614 + ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
615 } 615 }
616 aggregateErrorList = append(aggregateErrorList, tmpRow) 616 aggregateErrorList = append(aggregateErrorList, tmpRow)
617 continue 617 continue
@@ -621,7 +621,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -621,7 +621,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
621 if err != nil { 621 if err != nil {
622 tmpRow := &domain.FailReturnedInfo{ 622 tmpRow := &domain.FailReturnedInfo{
623 FailReason: "产品价格类型错误", 623 FailReason: "产品价格类型错误",
624 - ImportDividendsReturnedOrderData: &dividendsReturnedOrder, 624 + ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
625 } 625 }
626 aggregateErrorList = append(aggregateErrorList, tmpRow) 626 aggregateErrorList = append(aggregateErrorList, tmpRow)
627 continue 627 continue
@@ -661,7 +661,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -661,7 +661,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
661 if err != nil { 661 if err != nil {
662 tmpRow := &domain.FailReturnedInfo{ 662 tmpRow := &domain.FailReturnedInfo{
663 FailReason: "无效的订单日期", 663 FailReason: "无效的订单日期",
664 - ImportDividendsReturnedOrderData: &dividendsReturnedOrder, 664 + ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
665 } 665 }
666 aggregateErrorList = append(aggregateErrorList, tmpRow) 666 aggregateErrorList = append(aggregateErrorList, tmpRow)
667 continue 667 continue
@@ -672,7 +672,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -672,7 +672,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
672 if err != nil { 672 if err != nil {
673 tmpRow := &domain.FailReturnedInfo{ 673 tmpRow := &domain.FailReturnedInfo{
674 FailReason: "产品数量类型错误", 674 FailReason: "产品数量类型错误",
675 - ImportDividendsReturnedOrderData: &dividendsReturnedOrder, 675 + ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
676 } 676 }
677 aggregateErrorList = append(aggregateErrorList, tmpRow) 677 aggregateErrorList = append(aggregateErrorList, tmpRow)
678 continue 678 continue
@@ -682,7 +682,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -682,7 +682,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
682 if err != nil { 682 if err != nil {
683 tmpRow := &domain.FailReturnedInfo{ 683 tmpRow := &domain.FailReturnedInfo{
684 FailReason: "产品价格类型错误", 684 FailReason: "产品价格类型错误",
685 - ImportDividendsReturnedOrderData: &dividendsReturnedOrder, 685 + ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
686 } 686 }
687 aggregateErrorList = append(aggregateErrorList, tmpRow) 687 aggregateErrorList = append(aggregateErrorList, tmpRow)
688 continue 688 continue
@@ -691,7 +691,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -691,7 +691,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
691 if strconv.FormatInt(timeValue.Local().UnixNano()/1e6, 10) != dividendsReturnedOrderCommands[hashString].OrderTime { 691 if strconv.FormatInt(timeValue.Local().UnixNano()/1e6, 10) != dividendsReturnedOrderCommands[hashString].OrderTime {
692 tmpRow := &domain.FailReturnedInfo{ 692 tmpRow := &domain.FailReturnedInfo{
693 FailReason: "同一笔退货单的订单时间必须相同", 693 FailReason: "同一笔退货单的订单时间必须相同",
694 - ImportDividendsReturnedOrderData: &dividendsReturnedOrder, 694 + ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
695 } 695 }
696 aggregateErrorList = append(aggregateErrorList, tmpRow) 696 aggregateErrorList = append(aggregateErrorList, tmpRow)
697 continue 697 continue