...
|
...
|
@@ -2,6 +2,7 @@ package repository |
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
"github.com/go-pg/pg/v10"
|
|
|
|
|
|
"github.com/linmadan/egglib-go/persistent/pg/sqlbuilder"
|
|
|
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
|
...
|
...
|
@@ -167,7 +168,14 @@ func (repository *DividendsOrderRepository) FindOne(queryOptions map[string]inte |
|
|
if dividendsOrderModel.DividendsOrderId == 0 {
|
|
|
return nil, nil
|
|
|
} else {
|
|
|
return transform.TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel)
|
|
|
// 获取订单产品
|
|
|
var orderGoodModels []*models.OrderGood
|
|
|
orderGoodModelQuery := tx.Model(&orderGoodModels)
|
|
|
if err := orderGoodModelQuery.Where("dividends_order_number = ?", dividendsOrderModel.DividendsOrderNumber).Select(); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
// 聚合分红订单
|
|
|
return transform.TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel, orderGoodModels)
|
|
|
}
|
|
|
}
|
|
|
func (repository *DividendsOrderRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.DividendsOrder, error) {
|
...
|
...
|
@@ -181,7 +189,14 @@ func (repository *DividendsOrderRepository) Find(queryOptions map[string]interfa |
|
|
return 0, dividendsOrders, err
|
|
|
} else {
|
|
|
for _, dividendsOrderModel := range dividendsOrderModels {
|
|
|
if dividendsOrder, err := transform.TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel); err != nil {
|
|
|
//获取订单产品
|
|
|
var orderGoodModels []*models.OrderGood
|
|
|
orderGoodModelQuery := tx.Model(&orderGoodModels)
|
|
|
if err := orderGoodModelQuery.Where("dividends_order_number = ?", dividendsOrderModel.DividendsOrderNumber).Select(); err != nil {
|
|
|
return 0, nil, err
|
|
|
}
|
|
|
// 聚合分红订单
|
|
|
if dividendsOrder, err := transform.TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel, orderGoodModels); err != nil {
|
|
|
return 0, dividendsOrders, err
|
|
|
} else {
|
|
|
dividendsOrders = append(dividendsOrders, dividendsOrder)
|
...
|
...
|
|