|
@@ -6,6 +6,7 @@ import ( |
|
@@ -6,6 +6,7 @@ import ( |
6
|
"fmt"
|
6
|
"fmt"
|
7
|
"github.com/linmadan/egglib-go/core/application"
|
7
|
"github.com/linmadan/egglib-go/core/application"
|
8
|
"github.com/linmadan/egglib-go/utils/tool_funs"
|
8
|
"github.com/linmadan/egglib-go/utils/tool_funs"
|
|
|
9
|
+ "github.com/shopspring/decimal"
|
9
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsOrder/command"
|
10
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsOrder/command"
|
10
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsOrder/query"
|
11
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsOrder/query"
|
11
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
|
12
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
|
|
@@ -121,9 +122,10 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD |
|
@@ -121,9 +122,10 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD |
121
|
var orderGoods []*domain.OrderGood
|
122
|
var orderGoods []*domain.OrderGood
|
122
|
var dividendsOrderAmount float64
|
123
|
var dividendsOrderAmount float64
|
123
|
for _, orderGood := range createDividendsOrderCommand.OrderGoods {
|
124
|
for _, orderGood := range createDividendsOrderCommand.OrderGoods {
|
|
|
125
|
+ orderGoodAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(float64(orderGood.OrderGoodQuantity))).Float64()
|
124
|
orderGoods = append(orderGoods, &domain.OrderGood{
|
126
|
orderGoods = append(orderGoods, &domain.OrderGood{
|
125
|
OrderGoodId: 0,
|
127
|
OrderGoodId: 0,
|
126
|
- OrderGoodAmount: orderGood.OrderGoodAmount,
|
128
|
+ OrderGoodAmount: orderGoodAmount,
|
127
|
OrderGoodName: orderGood.OrderGoodName,
|
129
|
OrderGoodName: orderGood.OrderGoodName,
|
128
|
OrderGoodPrice: orderGood.OrderGoodPrice,
|
130
|
OrderGoodPrice: orderGood.OrderGoodPrice,
|
129
|
OrderGoodQuantity: orderGood.OrderGoodQuantity,
|
131
|
OrderGoodQuantity: orderGood.OrderGoodQuantity,
|
|
@@ -139,7 +141,7 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD |
|
@@ -139,7 +141,7 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD |
139
|
UpdatedAt: time.Time{},
|
141
|
UpdatedAt: time.Time{},
|
140
|
})
|
142
|
})
|
141
|
// 计算分红订单金额
|
143
|
// 计算分红订单金额
|
142
|
- dividendsOrderAmount = dividendsOrderAmount + orderGood.OrderGoodAmount
|
144
|
+ dividendsOrderAmount, _ = decimal.NewFromFloat(dividendsOrderAmount).Add(decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(float64(orderGood.OrderGoodQuantity)).Sub(decimal.NewFromFloat(orderGood.OrderGoodExpense)))).Float64()
|
143
|
}
|
145
|
}
|
144
|
|
146
|
|
145
|
// 订单时间转换
|
147
|
// 订单时间转换
|
|
@@ -621,7 +623,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
@@ -621,7 +623,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
621
|
|
623
|
|
622
|
// 批量创建分红订单
|
624
|
// 批量创建分红订单
|
623
|
for _, dividendsOrder := range createDividendsOrderCommands {
|
625
|
for _, dividendsOrder := range createDividendsOrderCommands {
|
624
|
- // 生成分红订单号
|
626
|
+ // TODO 表为空时生成分红订单号
|
625
|
dividendsOrderNumber, err := dividendsOrderDao.GenerateDividendsOrderNumber()
|
627
|
dividendsOrderNumber, err := dividendsOrderDao.GenerateDividendsOrderNumber()
|
626
|
if err != nil {
|
628
|
if err != nil {
|
627
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
629
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
@@ -667,9 +669,11 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
@@ -667,9 +669,11 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
667
|
}
|
669
|
}
|
668
|
}
|
670
|
}
|
669
|
|
671
|
|
|
|
672
|
+ orderGoodAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(float64(orderGood.OrderGoodQuantity))).Float64()
|
|
|
673
|
+
|
670
|
orderGoods = append(orderGoods, &domain.OrderGood{
|
674
|
orderGoods = append(orderGoods, &domain.OrderGood{
|
671
|
OrderGoodId: 0,
|
675
|
OrderGoodId: 0,
|
672
|
- OrderGoodAmount: orderGood.OrderGoodAmount,
|
676
|
+ OrderGoodAmount: orderGoodAmount,
|
673
|
OrderGoodName: orderGood.OrderGoodName,
|
677
|
OrderGoodName: orderGood.OrderGoodName,
|
674
|
OrderGoodPrice: orderGood.OrderGoodPrice,
|
678
|
OrderGoodPrice: orderGood.OrderGoodPrice,
|
675
|
OrderGoodQuantity: orderGood.OrderGoodQuantity,
|
679
|
OrderGoodQuantity: orderGood.OrderGoodQuantity,
|
|
@@ -685,7 +689,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
@@ -685,7 +689,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
685
|
})
|
689
|
})
|
686
|
|
690
|
|
687
|
// 计算分红订单金额
|
691
|
// 计算分红订单金额
|
688
|
- dividendsOrderAmount = dividendsOrderAmount + orderGood.OrderGoodPrice*float64(orderGood.OrderGoodQuantity)
|
692
|
+ dividendsOrderAmount, _ = decimal.NewFromFloat(dividendsOrderAmount).Add(decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(float64(orderGood.OrderGoodQuantity)).Sub(decimal.NewFromFloat(orderGood.OrderGoodExpense)))).Float64()
|
689
|
}
|
693
|
}
|
690
|
if len(orderGoodErrMap) > 0 {
|
694
|
if len(orderGoodErrMap) > 0 {
|
691
|
row := &domain.ImportInfo{
|
695
|
row := &domain.ImportInfo{
|
|
@@ -758,7 +762,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
@@ -758,7 +762,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
758
|
for _, errorData := range errorDataList {
|
762
|
for _, errorData := range errorDataList {
|
759
|
if len(errorData.GoodLine) == 0 { // 订单错误
|
763
|
if len(errorData.GoodLine) == 0 { // 订单错误
|
760
|
for _, line := range errorData.LineNumbers {
|
764
|
for _, line := range errorData.LineNumbers {
|
761
|
- //s := strconv.Itoa(line + 1)
|
|
|
762
|
tmpRow := &domain.FailInfo{
|
765
|
tmpRow := &domain.FailInfo{
|
763
|
FailReason: "订单数据新增错误:" + errorData.Error.Error(),
|
766
|
FailReason: "订单数据新增错误:" + errorData.Error.Error(),
|
764
|
}
|
767
|
}
|
|
@@ -767,7 +770,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
@@ -767,7 +770,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
767
|
}
|
770
|
}
|
768
|
} else if len(errorData.GoodLine) > 0 { // 订单产品错误
|
771
|
} else if len(errorData.GoodLine) > 0 { // 订单产品错误
|
769
|
for line := range errorData.GoodLine {
|
772
|
for line := range errorData.GoodLine {
|
770
|
- //s := strconv.Itoa(line + 1)
|
|
|
771
|
tmpRow := &domain.FailInfo{
|
773
|
tmpRow := &domain.FailInfo{
|
772
|
FailReason: "订单数据新增错误:" + errorData.Error.Error(),
|
774
|
FailReason: "订单数据新增错误:" + errorData.Error.Error(),
|
773
|
}
|
775
|
}
|