作者 陈志颖

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

... ... @@ -5,6 +5,7 @@ import (
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/dto"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
... ... @@ -32,10 +33,76 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsIncentive
defer func() {
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
// 分红订单仓储初始化
var dividendsOrderRepository domain.DividendsOrderRepository
if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
dividendsOrderRepository = value
}
// 分红退货单仓储初始化
var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository
if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
dividendsReturnedOrderRepository = value
}
// 订单产品仓储初始化
var orderGoodRepository domain.OrderGoodRepository
if value, err := factory.CreateOrderGoodRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
orderGoodRepository = value
}
// 获取订单产品
if count, orderGoods, err := orderGoodRepository.Find(tool_funs.SimpleStructToMap(listDividendsIncentivesEstimateQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
var dividendsIncentivesEstimateDtos []*dto.DividendsIncentivesEstimateDto
for _, orderGood := range orderGoods {
dividendsIncentivesEstimateDto := &dto.DividendsIncentivesEstimateDto{}
if orderGood.DividendsOrderNumber != "" { // 查询分红订单
dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{"dividendsOrderNumber": orderGood.DividendsOrderNumber})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if dividendsOrder == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsOrderNumber))
}
if err := dividendsIncentivesEstimateDto.LoadDto(orderGood, dividendsOrder.DividendsOrderNumber, dividendsOrder.DividendsOriginalOrderNum, dividendsOrder.CustomerName, dividendsOrder.Region.RegionName, dividendsOrder.OrderTime); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
dividendsIncentivesEstimateDtos = append(dividendsIncentivesEstimateDtos, dividendsIncentivesEstimateDto)
} else if orderGood.DividendsReturnedOrderNumber != "" { // 查询分红退货单
dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{"dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if dividendsReturnedOrder == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsReturnedOrderNumber))
}
if err := dividendsIncentivesEstimateDto.LoadDto(orderGood, dividendsReturnedOrder.DividendsReturnedOrderNumber, dividendsReturnedOrder.OriginalOrderNum, dividendsReturnedOrder.DividendsReturnedCustomerName, dividendsReturnedOrder.Region.RegionName, dividendsReturnedOrder.OrderTime); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
dividendsIncentivesEstimateDtos = append(dividendsIncentivesEstimateDtos, dividendsIncentivesEstimateDto)
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return map[string]interface{}{
"total": count,
"list": dividendsIncentivesEstimateDtos,
}, nil
}
return nil, nil
}
// ListMoneyIncentivesEstimate 返回金额激励分红预算信息列表
... ...
... ... @@ -260,8 +260,7 @@ func (dividendsOrderService *DividendsOrderService) ListDividendsOrders(listDivi
}
return map[string]interface{}{
"grid": map[string]interface{}{
"total": count,
"list": dividendsOrders,
"total": count, "list": dividendsOrders,
},
}, nil
}
... ...
... ... @@ -14,7 +14,7 @@ type DividendsOrder struct {
DividendsOrderAmount float64 `json:"dividendsOrderAmount"`
// 订单业务员
OrderSalesman *Salesman `json:"orderSalesman"`
// 订单产生时间
// 订单日期
OrderTime time.Time `json:"orderTime"`
// 分红订单分红时间
DividendTime time.Time `json:"dividendTime"`
... ...
... ... @@ -16,6 +16,8 @@ type DividendsReturnedOrder struct {
DividendsOrderNumber string `json:"dividendsOrderNumber"`
// 退货客户姓名
DividendsReturnedCustomerName string `json:"dividendsReturnedCustomerName"`
// 订单日期
OrderTime time.Time `json:"orderTime"`
// 退货日期
DividendsReturnedDate time.Time `json:"dividendsReturnedDate"`
// 退货区域
... ... @@ -60,9 +62,6 @@ func (dividendsReturnedOrder *DividendsReturnedOrder) Identify() interface{} {
}
func (dividendsReturnedOrder *DividendsReturnedOrder) Update(data map[string]interface{}) error {
if dividendsReturnedOrderNumber, ok := data["dividendsReturnedOrderNumber"]; ok {
dividendsReturnedOrder.DividendsReturnedOrderNumber = dividendsReturnedOrderNumber.(string)
}
if dividendsReturnedOrderRefund, ok := data["dividendsReturnedOrderRefund"]; ok {
dividendsReturnedOrder.DividendsReturnedOrderRefund = dividendsReturnedOrderRefund.(float64)
}
... ...
... ... @@ -19,6 +19,8 @@ type DividendsReturnedOrder struct {
DividendsOrderNumber string `comment:"关联分红订单号"`
// 退货客户姓名
DividendsReturnedCustomerName string `comment:"退货客户姓名"`
// 订单日期
OrderTime time.Time `comment:"订单日期"`
// 退货日期
DividendsReturnedDate time.Time `comment:"退货日期"`
// 退货区域
... ...
... ... @@ -32,6 +32,7 @@ func TransformToDividendsReturnedOrderDomainModelFromPgModels(
OriginalOrderNum: dividendsReturnedOrderModel.OriginalOrderNum,
DividendsOrderNumber: dividendsReturnedOrderModel.DividendsOrderNumber,
DividendsReturnedCustomerName: dividendsReturnedOrderModel.DividendsReturnedCustomerName,
OrderTime: dividendsReturnedOrderModel.OrderTime,
DividendsReturnedDate: dividendsReturnedOrderModel.DividendsReturnedDate,
Region: dividendsReturnedOrderModel.Region,
Remarks: dividendsReturnedOrderModel.Remarks,
... ...
... ... @@ -35,6 +35,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
"original_order_num",
"dividends_order_number",
"dividends_returned_customer_name",
"order_time",
"dividends_returned_date",
"region",
"remarks",
... ... @@ -69,6 +70,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
&dividendsReturnedOrder.OriginalOrderNum,
&dividendsReturnedOrder.DividendsOrderNumber,
&dividendsReturnedOrder.DividendsReturnedCustomerName,
&dividendsReturnedOrder.OrderTime,
&dividendsReturnedOrder.DividendsReturnedDate,
&dividendsReturnedOrder.Region,
&dividendsReturnedOrder.Remarks,
... ... @@ -89,6 +91,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
dividendsReturnedOrder.OriginalOrderNum,
dividendsReturnedOrder.DividendsOrderNumber,
dividendsReturnedOrder.DividendsReturnedCustomerName,
dividendsReturnedOrder.OrderTime,
dividendsReturnedOrder.DividendsReturnedDate,
dividendsReturnedOrder.Region,
dividendsReturnedOrder.Remarks,
... ... @@ -135,6 +138,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
&dividendsReturnedOrder.OriginalOrderNum,
&dividendsReturnedOrder.DividendsOrderNumber,
&dividendsReturnedOrder.DividendsReturnedCustomerName,
&dividendsReturnedOrder.OrderTime,
&dividendsReturnedOrder.DividendsReturnedDate,
&dividendsReturnedOrder.Region,
&dividendsReturnedOrder.Remarks,
... ... @@ -155,6 +159,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
dividendsReturnedOrder.OriginalOrderNum,
dividendsReturnedOrder.DividendsOrderNumber,
dividendsReturnedOrder.DividendsReturnedCustomerName,
dividendsReturnedOrder.OrderTime,
dividendsReturnedOrder.DividendsReturnedDate,
dividendsReturnedOrder.Region,
dividendsReturnedOrder.Remarks,
... ...