作者 陈志颖

feat:添加分红预算信息列表返回

@@ -5,6 +5,7 @@ import ( @@ -5,6 +5,7 @@ import (
5 "github.com/linmadan/egglib-go/core/application" 5 "github.com/linmadan/egglib-go/core/application"
6 "github.com/linmadan/egglib-go/utils/tool_funs" 6 "github.com/linmadan/egglib-go/utils/tool_funs"
7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/command" 7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/command"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/dto"
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/query" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/query"
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
@@ -32,10 +33,76 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsIncentive @@ -32,10 +33,76 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsIncentive
32 defer func() { 33 defer func() {
33 _ = transactionContext.RollbackTransaction() 34 _ = transactionContext.RollbackTransaction()
34 }() 35 }()
35 - if err := transactionContext.CommitTransaction(); err != nil {  
36 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 36 + // 分红订单仓储初始化
  37 + var dividendsOrderRepository domain.DividendsOrderRepository
  38 + if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{
  39 + "transactionContext": transactionContext,
  40 + }); err != nil {
  41 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  42 + } else {
  43 + dividendsOrderRepository = value
  44 + }
  45 + // 分红退货单仓储初始化
  46 + var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository
  47 + if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{
  48 + "transactionContext": transactionContext,
  49 + }); err != nil {
  50 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  51 + } else {
  52 + dividendsReturnedOrderRepository = value
  53 + }
  54 +
  55 + // 订单产品仓储初始化
  56 + var orderGoodRepository domain.OrderGoodRepository
  57 + if value, err := factory.CreateOrderGoodRepository(map[string]interface{}{
  58 + "transactionContext": transactionContext,
  59 + }); err != nil {
  60 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  61 + } else {
  62 + orderGoodRepository = value
  63 + }
  64 +
  65 + // 获取订单产品
  66 + if count, orderGoods, err := orderGoodRepository.Find(tool_funs.SimpleStructToMap(listDividendsIncentivesEstimateQuery)); err != nil {
  67 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  68 + } else {
  69 + var dividendsIncentivesEstimateDtos []*dto.DividendsIncentivesEstimateDto
  70 + for _, orderGood := range orderGoods {
  71 + dividendsIncentivesEstimateDto := &dto.DividendsIncentivesEstimateDto{}
  72 + if orderGood.DividendsOrderNumber != "" { // 查询分红订单
  73 + dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{"dividendsOrderNumber": orderGood.DividendsOrderNumber})
  74 + if err != nil {
  75 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  76 + }
  77 + if dividendsOrder == nil {
  78 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsOrderNumber))
  79 + }
  80 + if err := dividendsIncentivesEstimateDto.LoadDto(orderGood, dividendsOrder.DividendsOrderNumber, dividendsOrder.DividendsOriginalOrderNum, dividendsOrder.CustomerName, dividendsOrder.Region.RegionName, dividendsOrder.OrderTime); err != nil {
  81 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  82 + }
  83 + dividendsIncentivesEstimateDtos = append(dividendsIncentivesEstimateDtos, dividendsIncentivesEstimateDto)
  84 + } else if orderGood.DividendsReturnedOrderNumber != "" { // 查询分红退货单
  85 + dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{"dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber})
  86 + if err != nil {
  87 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  88 + }
  89 + if dividendsReturnedOrder == nil {
  90 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsReturnedOrderNumber))
  91 + }
  92 + if err := dividendsIncentivesEstimateDto.LoadDto(orderGood, dividendsReturnedOrder.DividendsReturnedOrderNumber, dividendsReturnedOrder.OriginalOrderNum, dividendsReturnedOrder.DividendsReturnedCustomerName, dividendsReturnedOrder.Region.RegionName, dividendsReturnedOrder.OrderTime); err != nil {
  93 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  94 + }
  95 + dividendsIncentivesEstimateDtos = append(dividendsIncentivesEstimateDtos, dividendsIncentivesEstimateDto)
  96 + }
  97 + }
  98 + if err := transactionContext.CommitTransaction(); err != nil {
  99 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  100 + }
  101 + return map[string]interface{}{
  102 + "total": count,
  103 + "list": dividendsIncentivesEstimateDtos,
  104 + }, nil
37 } 105 }
38 - return nil, nil  
39 } 106 }
40 107
41 // ListMoneyIncentivesEstimate 返回金额激励分红预算信息列表 108 // ListMoneyIncentivesEstimate 返回金额激励分红预算信息列表
@@ -260,8 +260,7 @@ func (dividendsOrderService *DividendsOrderService) ListDividendsOrders(listDivi @@ -260,8 +260,7 @@ func (dividendsOrderService *DividendsOrderService) ListDividendsOrders(listDivi
260 } 260 }
261 return map[string]interface{}{ 261 return map[string]interface{}{
262 "grid": map[string]interface{}{ 262 "grid": map[string]interface{}{
263 - "total": count,  
264 - "list": dividendsOrders, 263 + "total": count, "list": dividendsOrders,
265 }, 264 },
266 }, nil 265 }, nil
267 } 266 }
@@ -14,7 +14,7 @@ type DividendsOrder struct { @@ -14,7 +14,7 @@ type DividendsOrder struct {
14 DividendsOrderAmount float64 `json:"dividendsOrderAmount"` 14 DividendsOrderAmount float64 `json:"dividendsOrderAmount"`
15 // 订单业务员 15 // 订单业务员
16 OrderSalesman *Salesman `json:"orderSalesman"` 16 OrderSalesman *Salesman `json:"orderSalesman"`
17 - // 订单产生时间 17 + // 订单日期
18 OrderTime time.Time `json:"orderTime"` 18 OrderTime time.Time `json:"orderTime"`
19 // 分红订单分红时间 19 // 分红订单分红时间
20 DividendTime time.Time `json:"dividendTime"` 20 DividendTime time.Time `json:"dividendTime"`
@@ -16,6 +16,8 @@ type DividendsReturnedOrder struct { @@ -16,6 +16,8 @@ type DividendsReturnedOrder struct {
16 DividendsOrderNumber string `json:"dividendsOrderNumber"` 16 DividendsOrderNumber string `json:"dividendsOrderNumber"`
17 // 退货客户姓名 17 // 退货客户姓名
18 DividendsReturnedCustomerName string `json:"dividendsReturnedCustomerName"` 18 DividendsReturnedCustomerName string `json:"dividendsReturnedCustomerName"`
  19 + // 订单日期
  20 + OrderTime time.Time `json:"orderTime"`
19 // 退货日期 21 // 退货日期
20 DividendsReturnedDate time.Time `json:"dividendsReturnedDate"` 22 DividendsReturnedDate time.Time `json:"dividendsReturnedDate"`
21 // 退货区域 23 // 退货区域
@@ -60,9 +62,6 @@ func (dividendsReturnedOrder *DividendsReturnedOrder) Identify() interface{} { @@ -60,9 +62,6 @@ func (dividendsReturnedOrder *DividendsReturnedOrder) Identify() interface{} {
60 } 62 }
61 63
62 func (dividendsReturnedOrder *DividendsReturnedOrder) Update(data map[string]interface{}) error { 64 func (dividendsReturnedOrder *DividendsReturnedOrder) Update(data map[string]interface{}) error {
63 - if dividendsReturnedOrderNumber, ok := data["dividendsReturnedOrderNumber"]; ok {  
64 - dividendsReturnedOrder.DividendsReturnedOrderNumber = dividendsReturnedOrderNumber.(string)  
65 - }  
66 if dividendsReturnedOrderRefund, ok := data["dividendsReturnedOrderRefund"]; ok { 65 if dividendsReturnedOrderRefund, ok := data["dividendsReturnedOrderRefund"]; ok {
67 dividendsReturnedOrder.DividendsReturnedOrderRefund = dividendsReturnedOrderRefund.(float64) 66 dividendsReturnedOrder.DividendsReturnedOrderRefund = dividendsReturnedOrderRefund.(float64)
68 } 67 }
@@ -19,6 +19,8 @@ type DividendsReturnedOrder struct { @@ -19,6 +19,8 @@ type DividendsReturnedOrder struct {
19 DividendsOrderNumber string `comment:"关联分红订单号"` 19 DividendsOrderNumber string `comment:"关联分红订单号"`
20 // 退货客户姓名 20 // 退货客户姓名
21 DividendsReturnedCustomerName string `comment:"退货客户姓名"` 21 DividendsReturnedCustomerName string `comment:"退货客户姓名"`
  22 + // 订单日期
  23 + OrderTime time.Time `comment:"订单日期"`
22 // 退货日期 24 // 退货日期
23 DividendsReturnedDate time.Time `comment:"退货日期"` 25 DividendsReturnedDate time.Time `comment:"退货日期"`
24 // 退货区域 26 // 退货区域
@@ -32,6 +32,7 @@ func TransformToDividendsReturnedOrderDomainModelFromPgModels( @@ -32,6 +32,7 @@ func TransformToDividendsReturnedOrderDomainModelFromPgModels(
32 OriginalOrderNum: dividendsReturnedOrderModel.OriginalOrderNum, 32 OriginalOrderNum: dividendsReturnedOrderModel.OriginalOrderNum,
33 DividendsOrderNumber: dividendsReturnedOrderModel.DividendsOrderNumber, 33 DividendsOrderNumber: dividendsReturnedOrderModel.DividendsOrderNumber,
34 DividendsReturnedCustomerName: dividendsReturnedOrderModel.DividendsReturnedCustomerName, 34 DividendsReturnedCustomerName: dividendsReturnedOrderModel.DividendsReturnedCustomerName,
  35 + OrderTime: dividendsReturnedOrderModel.OrderTime,
35 DividendsReturnedDate: dividendsReturnedOrderModel.DividendsReturnedDate, 36 DividendsReturnedDate: dividendsReturnedOrderModel.DividendsReturnedDate,
36 Region: dividendsReturnedOrderModel.Region, 37 Region: dividendsReturnedOrderModel.Region,
37 Remarks: dividendsReturnedOrderModel.Remarks, 38 Remarks: dividendsReturnedOrderModel.Remarks,
@@ -35,6 +35,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder @@ -35,6 +35,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
35 "original_order_num", 35 "original_order_num",
36 "dividends_order_number", 36 "dividends_order_number",
37 "dividends_returned_customer_name", 37 "dividends_returned_customer_name",
  38 + "order_time",
38 "dividends_returned_date", 39 "dividends_returned_date",
39 "region", 40 "region",
40 "remarks", 41 "remarks",
@@ -69,6 +70,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder @@ -69,6 +70,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
69 &dividendsReturnedOrder.OriginalOrderNum, 70 &dividendsReturnedOrder.OriginalOrderNum,
70 &dividendsReturnedOrder.DividendsOrderNumber, 71 &dividendsReturnedOrder.DividendsOrderNumber,
71 &dividendsReturnedOrder.DividendsReturnedCustomerName, 72 &dividendsReturnedOrder.DividendsReturnedCustomerName,
  73 + &dividendsReturnedOrder.OrderTime,
72 &dividendsReturnedOrder.DividendsReturnedDate, 74 &dividendsReturnedOrder.DividendsReturnedDate,
73 &dividendsReturnedOrder.Region, 75 &dividendsReturnedOrder.Region,
74 &dividendsReturnedOrder.Remarks, 76 &dividendsReturnedOrder.Remarks,
@@ -89,6 +91,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder @@ -89,6 +91,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
89 dividendsReturnedOrder.OriginalOrderNum, 91 dividendsReturnedOrder.OriginalOrderNum,
90 dividendsReturnedOrder.DividendsOrderNumber, 92 dividendsReturnedOrder.DividendsOrderNumber,
91 dividendsReturnedOrder.DividendsReturnedCustomerName, 93 dividendsReturnedOrder.DividendsReturnedCustomerName,
  94 + dividendsReturnedOrder.OrderTime,
92 dividendsReturnedOrder.DividendsReturnedDate, 95 dividendsReturnedOrder.DividendsReturnedDate,
93 dividendsReturnedOrder.Region, 96 dividendsReturnedOrder.Region,
94 dividendsReturnedOrder.Remarks, 97 dividendsReturnedOrder.Remarks,
@@ -135,6 +138,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder @@ -135,6 +138,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
135 &dividendsReturnedOrder.OriginalOrderNum, 138 &dividendsReturnedOrder.OriginalOrderNum,
136 &dividendsReturnedOrder.DividendsOrderNumber, 139 &dividendsReturnedOrder.DividendsOrderNumber,
137 &dividendsReturnedOrder.DividendsReturnedCustomerName, 140 &dividendsReturnedOrder.DividendsReturnedCustomerName,
  141 + &dividendsReturnedOrder.OrderTime,
138 &dividendsReturnedOrder.DividendsReturnedDate, 142 &dividendsReturnedOrder.DividendsReturnedDate,
139 &dividendsReturnedOrder.Region, 143 &dividendsReturnedOrder.Region,
140 &dividendsReturnedOrder.Remarks, 144 &dividendsReturnedOrder.Remarks,
@@ -155,6 +159,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder @@ -155,6 +159,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
155 dividendsReturnedOrder.OriginalOrderNum, 159 dividendsReturnedOrder.OriginalOrderNum,
156 dividendsReturnedOrder.DividendsOrderNumber, 160 dividendsReturnedOrder.DividendsOrderNumber,
157 dividendsReturnedOrder.DividendsReturnedCustomerName, 161 dividendsReturnedOrder.DividendsReturnedCustomerName,
  162 + dividendsReturnedOrder.OrderTime,
158 dividendsReturnedOrder.DividendsReturnedDate, 163 dividendsReturnedOrder.DividendsReturnedDate,
159 dividendsReturnedOrder.Region, 164 dividendsReturnedOrder.Region,
160 dividendsReturnedOrder.Remarks, 165 dividendsReturnedOrder.Remarks,