作者 陈志颖

fix:修复根据分红订单号查询分红订单详情

... ... @@ -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())
}
... ...
... ... @@ -77,6 +77,24 @@ func (dao *CooperationContractDao) CheckContractNumberAvailable(queryOptions map
return !ok, err
}
// CheckContractNumberExist 检验合约编号是否存在
func (dao *CooperationContractDao) CheckContractNumberExist(queryOptions map[string]interface{}) (bool, error) {
tx := dao.transactionContext.PgTx
var cooperationContractModels []*models.CooperationContract
query := tx.Model(&cooperationContractModels)
if cooperationContractNumber, ok := queryOptions["cooperationContractNumber"]; ok && cooperationContractNumber != "" {
query = query.Where("cooperation_contract_number = ?", cooperationContractNumber)
}
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query = query.Where(`cooperation_contract.company @> '{"companyId":"?"}'`, companyId)
}
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query = query.Where(`cooperation_contract.org @> '{"orgId":"?"}'`, orgId)
}
ok, err := query.Exists()
return ok, err
}
// SearchCooperationContractByUndertaker 查询共创合约并根据承接人返回
func (dao *CooperationContractDao) SearchCooperationContractByUndertaker(queryOptions map[string]interface{}) (int, []*models.CooperationContractByUndertaker, error) {
tx := dao.transactionContext.PgTx
... ...