正在显示
2 个修改的文件
包含
32 行增加
和
4 行删除
@@ -2,6 +2,7 @@ package repository | @@ -2,6 +2,7 @@ package repository | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "github.com/go-pg/pg/v10" | ||
5 | 6 | ||
6 | "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder" | 7 | "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder" |
7 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | 8 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" |
@@ -167,7 +168,14 @@ func (repository *DividendsOrderRepository) FindOne(queryOptions map[string]inte | @@ -167,7 +168,14 @@ func (repository *DividendsOrderRepository) FindOne(queryOptions map[string]inte | ||
167 | if dividendsOrderModel.DividendsOrderId == 0 { | 168 | if dividendsOrderModel.DividendsOrderId == 0 { |
168 | return nil, nil | 169 | return nil, nil |
169 | } else { | 170 | } else { |
170 | - return transform.TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel) | 171 | + // 获取订单产品 |
172 | + var orderGoodModels []*models.OrderGood | ||
173 | + orderGoodModelQuery := tx.Model(&orderGoodModels) | ||
174 | + if err := orderGoodModelQuery.Where("dividends_order_number = ?", dividendsOrderModel.DividendsOrderNumber).Select(); err != nil { | ||
175 | + return nil, err | ||
176 | + } | ||
177 | + // 聚合分红订单 | ||
178 | + return transform.TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel, orderGoodModels) | ||
171 | } | 179 | } |
172 | } | 180 | } |
173 | func (repository *DividendsOrderRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.DividendsOrder, error) { | 181 | func (repository *DividendsOrderRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.DividendsOrder, error) { |
@@ -181,7 +189,14 @@ func (repository *DividendsOrderRepository) Find(queryOptions map[string]interfa | @@ -181,7 +189,14 @@ func (repository *DividendsOrderRepository) Find(queryOptions map[string]interfa | ||
181 | return 0, dividendsOrders, err | 189 | return 0, dividendsOrders, err |
182 | } else { | 190 | } else { |
183 | for _, dividendsOrderModel := range dividendsOrderModels { | 191 | for _, dividendsOrderModel := range dividendsOrderModels { |
184 | - if dividendsOrder, err := transform.TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel); err != nil { | 192 | + //获取订单产品 |
193 | + var orderGoodModels []*models.OrderGood | ||
194 | + orderGoodModelQuery := tx.Model(&orderGoodModels) | ||
195 | + if err := orderGoodModelQuery.Where("dividends_order_number = ?", dividendsOrderModel.DividendsOrderNumber).Select(); err != nil { | ||
196 | + return 0, nil, err | ||
197 | + } | ||
198 | + // 聚合分红订单 | ||
199 | + if dividendsOrder, err := transform.TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel, orderGoodModels); err != nil { | ||
185 | return 0, dividendsOrders, err | 200 | return 0, dividendsOrders, err |
186 | } else { | 201 | } else { |
187 | dividendsOrders = append(dividendsOrders, dividendsOrder) | 202 | dividendsOrders = append(dividendsOrders, dividendsOrder) |
@@ -173,7 +173,14 @@ func (repository *DividendsReturnedOrderRepository) FindOne(queryOptions map[str | @@ -173,7 +173,14 @@ func (repository *DividendsReturnedOrderRepository) FindOne(queryOptions map[str | ||
173 | if dividendsReturnedOrderModel.DividendsReturnedOrderId == 0 { | 173 | if dividendsReturnedOrderModel.DividendsReturnedOrderId == 0 { |
174 | return nil, nil | 174 | return nil, nil |
175 | } else { | 175 | } else { |
176 | - return transform.TransformToDividendsReturnedOrderDomainModelFromPgModels(dividendsReturnedOrderModel) | 176 | + // 获取订单产品 |
177 | + var orderGoodModels []*models.OrderGood | ||
178 | + orderGoodModelQuery := tx.Model(&orderGoodModels) | ||
179 | + if err := orderGoodModelQuery.Where("dividends_returned_order_number = ?", dividendsReturnedOrderModel.DividendsOrderNumber).Select(); err != nil { | ||
180 | + return nil, err | ||
181 | + } | ||
182 | + // 聚合分红退货单 | ||
183 | + return transform.TransformToDividendsReturnedOrderDomainModelFromPgModels(dividendsReturnedOrderModel, orderGoodModels) | ||
177 | } | 184 | } |
178 | } | 185 | } |
179 | func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.DividendsReturnedOrder, error) { | 186 | func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.DividendsReturnedOrder, error) { |
@@ -187,7 +194,13 @@ func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string | @@ -187,7 +194,13 @@ func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string | ||
187 | return 0, dividendsReturnedOrders, err | 194 | return 0, dividendsReturnedOrders, err |
188 | } else { | 195 | } else { |
189 | for _, dividendsReturnedOrderModel := range dividendsReturnedOrderModels { | 196 | for _, dividendsReturnedOrderModel := range dividendsReturnedOrderModels { |
190 | - if dividendsReturnedOrder, err := transform.TransformToDividendsReturnedOrderDomainModelFromPgModels(dividendsReturnedOrderModel); err != nil { | 197 | + // 获取订单产品 |
198 | + var orderGoodModels []*models.OrderGood | ||
199 | + orderGoodModelQuery := tx.Model(&orderGoodModels) | ||
200 | + if err := orderGoodModelQuery.Where("dividends_returned_order_number = ?", dividendsReturnedOrderModel.DividendsOrderNumber).Select(); err != nil { | ||
201 | + return 0, nil, err | ||
202 | + } | ||
203 | + if dividendsReturnedOrder, err := transform.TransformToDividendsReturnedOrderDomainModelFromPgModels(dividendsReturnedOrderModel, orderGoodModels); err != nil { | ||
191 | return 0, dividendsReturnedOrders, err | 204 | return 0, dividendsReturnedOrders, err |
192 | } else { | 205 | } else { |
193 | dividendsReturnedOrders = append(dividendsReturnedOrders, dividendsReturnedOrder) | 206 | dividendsReturnedOrders = append(dividendsReturnedOrders, dividendsReturnedOrder) |
-
请 注册 或 登录 后发表评论