作者 陈志颖

fix:分红退货单预算信息查询

... ... @@ -518,7 +518,8 @@ func (repository *DividendsOrderRepository) FindOne(queryOptions map[string]inte
if err := orderGoodModelQuery.
Where("company_id = ?", dividendsOrderModel.Company.CompanyId).
Where("org_id = ?", dividendsOrderModel.Org.OrgId).
Where("dividends_order_number = ?", dividendsOrderModel.DividendsOrderNumber).Select(); err != nil {
Where("dividends_order_number = ?", dividendsOrderModel.DividendsOrderNumber).
Select(); err != nil {
return nil, fmt.Errorf("分红订单关联的产品不存在")
}
// 聚合分红订单
... ...
... ... @@ -488,8 +488,20 @@ func (repository *DividendsReturnedOrderRepository) FindOne(queryOptions map[str
tx := repository.transactionContext.PgTx
dividendsReturnedOrderModel := new(models.DividendsReturnedOrder)
query := sqlbuilder.BuildQuery(tx.Model(dividendsReturnedOrderModel), queryOptions)
query.SetWhereByQueryOption("dividends_returned_order.dividends_returned_order_id = ?", "dividendsReturnedOrderId")
query.SetWhereByQueryOption("dividends_returned_order.dividends_returned_order_number = ?", "dividendsReturnedOrderNumber")
if dividendsReturnedOrderId, ok := queryOptions["dividendsReturnedOrderId"]; ok && dividendsReturnedOrderId.(int64) != 0 {
query.Where("dividends_returned_order.dividends_returned_order_id = ?", dividendsReturnedOrderId)
}
//query.SetWhereByQueryOption("dividends_returned_order.dividends_returned_order_id = ?", "dividendsReturnedOrderId")
//query.SetWhereByQueryOption("dividends_returned_order.dividends_returned_order_number = ?", "dividendsReturnedOrderNumber")
if dividendsReturnedOrderNumber, ok := queryOptions["dividendsReturnedOrderNumber"]; ok && dividendsReturnedOrderNumber != "" {
query.Where("dividends_returned_order.dividends_returned_order_number = ?", dividendsReturnedOrderNumber)
}
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query.Where("company->>'companyId' = '?'", companyId)
}
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query.Where("org->>'orgId' = '?'", orgId)
}
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
return nil, fmt.Errorf("分红退货单不存在")
... ...