|
@@ -723,12 +723,30 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
@@ -723,12 +723,30 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
723
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增分红订单异常")
|
723
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增分红订单异常")
|
724
|
}
|
724
|
}
|
725
|
|
725
|
|
726
|
- // 校验共创合约是否合法
|
726
|
+ // 共创合约DAO初始化
|
|
|
727
|
+ var cooperationContractDao *dao.CooperationContractDao
|
|
|
728
|
+ if value, err := factory.CreateCooperationContractDao(map[string]interface{}{
|
|
|
729
|
+ "transactionContext": transactionContext,
|
|
|
730
|
+ }); err != nil {
|
|
|
731
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
732
|
+ } else {
|
|
|
733
|
+ cooperationContractDao = value
|
|
|
734
|
+ }
|
727
|
|
735
|
|
728
|
// 新增订单产品
|
736
|
// 新增订单产品
|
729
|
var orderGoods []*domain.OrderGood
|
737
|
var orderGoods []*domain.OrderGood
|
730
|
var dividendsOrderAmount float64
|
738
|
var dividendsOrderAmount float64
|
731
|
for _, orderGood := range dividendsOrder.OrderGoods {
|
739
|
for _, orderGood := range dividendsOrder.OrderGoods {
|
|
|
740
|
+ // 校验共创合约是否合法
|
|
|
741
|
+ contractNumberExist, _ := cooperationContractDao.CheckContractNumberExist(map[string]interface{}{
|
|
|
742
|
+ "companyId": importDividendsOrderCommand.CompanyId,
|
|
|
743
|
+ "orgId": importDividendsOrderCommand.OrgId,
|
|
|
744
|
+ "cooperationContractNumber": orderGood.CooperationContractNumber,
|
|
|
745
|
+ })
|
|
|
746
|
+ if !contractNumberExist {
|
|
|
747
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, "共创合约编号不存在")
|
|
|
748
|
+ }
|
|
|
749
|
+
|
732
|
orderGoods = append(orderGoods, &domain.OrderGood{
|
750
|
orderGoods = append(orderGoods, &domain.OrderGood{
|
733
|
OrderGoodId: 0,
|
751
|
OrderGoodId: 0,
|
734
|
OrderGoodAmount: orderGood.OrderGoodAmount,
|
752
|
OrderGoodAmount: orderGood.OrderGoodAmount,
|
|
@@ -741,10 +759,11 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
@@ -741,10 +759,11 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
741
|
OrderGoodExpense: orderGood.OrderGoodExpense,
|
759
|
OrderGoodExpense: orderGood.OrderGoodExpense,
|
742
|
OrgId: importDividendsOrderCommand.OrgId,
|
760
|
OrgId: importDividendsOrderCommand.OrgId,
|
743
|
CompanyId: importDividendsOrderCommand.CompanyId,
|
761
|
CompanyId: importDividendsOrderCommand.CompanyId,
|
744
|
- CreatedAt: time.Time{},
|
762
|
+ CreatedAt: time.Now(),
|
745
|
DeletedAt: time.Time{},
|
763
|
DeletedAt: time.Time{},
|
746
|
UpdatedAt: time.Time{},
|
764
|
UpdatedAt: time.Time{},
|
747
|
})
|
765
|
})
|
|
|
766
|
+
|
748
|
// 计算分红订单金额
|
767
|
// 计算分红订单金额
|
749
|
dividendsOrderAmount = dividendsOrderAmount + orderGood.OrderGoodAmount
|
768
|
dividendsOrderAmount = dividendsOrderAmount + orderGood.OrderGoodAmount
|
750
|
}
|
769
|
}
|
|
@@ -752,7 +771,13 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
@@ -752,7 +771,13 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
752
|
// 订单时间转换
|
771
|
// 订单时间转换
|
753
|
orderTimeInt, err := strconv.ParseInt(dividendsOrder.OrderTime, 10, 64)
|
772
|
orderTimeInt, err := strconv.ParseInt(dividendsOrder.OrderTime, 10, 64)
|
754
|
if err != nil {
|
773
|
if err != nil {
|
755
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "订单日期转换错误")
|
774
|
+ row := &domain.ImportInfo{
|
|
|
775
|
+ Error: application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("订单日期转换错误:%s", err)),
|
|
|
776
|
+ LineNumbers: dividendsOrder.LineNumbers, // 错误影响的行
|
|
|
777
|
+ GoodLine: map[int]interface{}{},
|
|
|
778
|
+ }
|
|
|
779
|
+ errorDataList = append(errorDataList, row)
|
|
|
780
|
+ continue
|
756
|
}
|
781
|
}
|
757
|
orderTime := utils.TransformTimestampToTime(orderTimeInt)
|
782
|
orderTime := utils.TransformTimestampToTime(orderTimeInt)
|
758
|
|
783
|
|
|
@@ -790,6 +815,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
@@ -790,6 +815,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
790
|
continue
|
815
|
continue
|
791
|
}
|
816
|
}
|
792
|
}
|
817
|
}
|
|
|
818
|
+
|
|
|
819
|
+ // 错误报告处理
|
793
|
if len(errorDataList) <= 0 {
|
820
|
if len(errorDataList) <= 0 {
|
794
|
if err3 := transactionContext.CommitTransaction(); err3 != nil {
|
821
|
if err3 := transactionContext.CommitTransaction(); err3 != nil {
|
795
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err3.Error())
|
822
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err3.Error())
|
|
@@ -875,7 +902,7 @@ func (dividendsOrderService *DividendsOrderService) GetDividendsOrder(getDividen |
|
@@ -875,7 +902,7 @@ func (dividendsOrderService *DividendsOrderService) GetDividendsOrder(getDividen |
875
|
} else {
|
902
|
} else {
|
876
|
dividendsOrderRepository = value
|
903
|
dividendsOrderRepository = value
|
877
|
}
|
904
|
}
|
878
|
- dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{"dividendsOrderId": getDividendsOrderQuery.DividendsOrderId})
|
905
|
+ dividendsOrder, err := dividendsOrderRepository.FindOne(tool_funs.SimpleStructToMap(getDividendsOrderQuery))
|
879
|
if err != nil {
|
906
|
if err != nil {
|
880
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
907
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
881
|
}
|
908
|
}
|