...
|
...
|
@@ -723,12 +723,30 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增分红订单异常")
|
|
|
}
|
|
|
|
|
|
// 校验共创合约是否合法
|
|
|
// 共创合约DAO初始化
|
|
|
var cooperationContractDao *dao.CooperationContractDao
|
|
|
if value, err := factory.CreateCooperationContractDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
} else {
|
|
|
cooperationContractDao = value
|
|
|
}
|
|
|
|
|
|
// 新增订单产品
|
|
|
var orderGoods []*domain.OrderGood
|
|
|
var dividendsOrderAmount float64
|
|
|
for _, orderGood := range dividendsOrder.OrderGoods {
|
|
|
// 校验共创合约是否合法
|
|
|
contractNumberExist, _ := cooperationContractDao.CheckContractNumberExist(map[string]interface{}{
|
|
|
"companyId": importDividendsOrderCommand.CompanyId,
|
|
|
"orgId": importDividendsOrderCommand.OrgId,
|
|
|
"cooperationContractNumber": orderGood.CooperationContractNumber,
|
|
|
})
|
|
|
if !contractNumberExist {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "共创合约编号不存在")
|
|
|
}
|
|
|
|
|
|
orderGoods = append(orderGoods, &domain.OrderGood{
|
|
|
OrderGoodId: 0,
|
|
|
OrderGoodAmount: orderGood.OrderGoodAmount,
|
...
|
...
|
@@ -741,10 +759,11 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
OrderGoodExpense: orderGood.OrderGoodExpense,
|
|
|
OrgId: importDividendsOrderCommand.OrgId,
|
|
|
CompanyId: importDividendsOrderCommand.CompanyId,
|
|
|
CreatedAt: time.Time{},
|
|
|
CreatedAt: time.Now(),
|
|
|
DeletedAt: time.Time{},
|
|
|
UpdatedAt: time.Time{},
|
|
|
})
|
|
|
|
|
|
// 计算分红订单金额
|
|
|
dividendsOrderAmount = dividendsOrderAmount + orderGood.OrderGoodAmount
|
|
|
}
|
...
|
...
|
@@ -752,7 +771,13 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
// 订单时间转换
|
|
|
orderTimeInt, err := strconv.ParseInt(dividendsOrder.OrderTime, 10, 64)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "订单日期转换错误")
|
|
|
row := &domain.ImportInfo{
|
|
|
Error: application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("订单日期转换错误:%s", err)),
|
|
|
LineNumbers: dividendsOrder.LineNumbers, // 错误影响的行
|
|
|
GoodLine: map[int]interface{}{},
|
|
|
}
|
|
|
errorDataList = append(errorDataList, row)
|
|
|
continue
|
|
|
}
|
|
|
orderTime := utils.TransformTimestampToTime(orderTimeInt)
|
|
|
|
...
|
...
|
@@ -790,6 +815,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
continue
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 错误报告处理
|
|
|
if len(errorDataList) <= 0 {
|
|
|
if err3 := transactionContext.CommitTransaction(); err3 != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err3.Error())
|
...
|
...
|
@@ -875,7 +902,7 @@ func (dividendsOrderService *DividendsOrderService) GetDividendsOrder(getDividen |
|
|
} else {
|
|
|
dividendsOrderRepository = value
|
|
|
}
|
|
|
dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{"dividendsOrderId": getDividendsOrderQuery.DividendsOrderId})
|
|
|
dividendsOrder, err := dividendsOrderRepository.FindOne(tool_funs.SimpleStructToMap(getDividendsOrderQuery))
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
|