作者 陈志颖

feat:调整分红订单和分红退货单仓储功能

... ... @@ -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)
... ...
... ... @@ -173,7 +173,14 @@ func (repository *DividendsReturnedOrderRepository) FindOne(queryOptions map[str
if dividendsReturnedOrderModel.DividendsReturnedOrderId == 0 {
return nil, nil
} else {
return transform.TransformToDividendsReturnedOrderDomainModelFromPgModels(dividendsReturnedOrderModel)
// 获取订单产品
var orderGoodModels []*models.OrderGood
orderGoodModelQuery := tx.Model(&orderGoodModels)
if err := orderGoodModelQuery.Where("dividends_returned_order_number = ?", dividendsReturnedOrderModel.DividendsOrderNumber).Select(); err != nil {
return nil, err
}
// 聚合分红退货单
return transform.TransformToDividendsReturnedOrderDomainModelFromPgModels(dividendsReturnedOrderModel, orderGoodModels)
}
}
func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.DividendsReturnedOrder, error) {
... ... @@ -187,7 +194,13 @@ func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string
return 0, dividendsReturnedOrders, err
} else {
for _, dividendsReturnedOrderModel := range dividendsReturnedOrderModels {
if dividendsReturnedOrder, err := transform.TransformToDividendsReturnedOrderDomainModelFromPgModels(dividendsReturnedOrderModel); err != nil {
// 获取订单产品
var orderGoodModels []*models.OrderGood
orderGoodModelQuery := tx.Model(&orderGoodModels)
if err := orderGoodModelQuery.Where("dividends_returned_order_number = ?", dividendsReturnedOrderModel.DividendsOrderNumber).Select(); err != nil {
return 0, nil, err
}
if dividendsReturnedOrder, err := transform.TransformToDividendsReturnedOrderDomainModelFromPgModels(dividendsReturnedOrderModel, orderGoodModels); err != nil {
return 0, dividendsReturnedOrders, err
} else {
dividendsReturnedOrders = append(dividendsReturnedOrders, dividendsReturnedOrder)
... ...