|
@@ -144,6 +144,13 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD |
|
@@ -144,6 +144,13 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD |
144
|
}
|
144
|
}
|
145
|
}
|
145
|
}
|
146
|
|
146
|
|
|
|
147
|
+ // 订单时间转换
|
|
|
148
|
+ orderTimeInt, err := strconv.ParseInt(createDividendsOrderCommand.OrderTime, 10, 64)
|
|
|
149
|
+ if err != nil {
|
|
|
150
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "订单时间错误")
|
|
|
151
|
+ }
|
|
|
152
|
+ orderTime := utils.TransformTimestampToTime(orderTimeInt)
|
|
|
153
|
+
|
147
|
// 新增订单产品
|
154
|
// 新增订单产品
|
148
|
var orderGoods []*domain.OrderGood
|
155
|
var orderGoods []*domain.OrderGood
|
149
|
var dividendsOrderAmount float64
|
156
|
var dividendsOrderAmount float64
|
|
@@ -151,12 +158,26 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD |
|
@@ -151,12 +158,26 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD |
151
|
// 计算订单产品金额
|
158
|
// 计算订单产品金额
|
152
|
orderGoodAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Float64()
|
159
|
orderGoodAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Float64()
|
153
|
|
160
|
|
154
|
- // 校验共创合约
|
161
|
+ ruleMatchedFlag := false
|
155
|
if orderGood.CooperationContractNumber != "" {
|
162
|
if orderGood.CooperationContractNumber != "" {
|
|
|
163
|
+ // 校验共创合约激励类型是否正确
|
156
|
if cooperationContractsMap[orderGood.CooperationContractNumber] != nil && cooperationContractsMap[orderGood.CooperationContractNumber].IncentivesType != 1 {
|
164
|
if cooperationContractsMap[orderGood.CooperationContractNumber] != nil && cooperationContractsMap[orderGood.CooperationContractNumber].IncentivesType != 1 {
|
157
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单产品不能关联金额激励规则")
|
165
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单产品不能关联金额激励规则")
|
158
|
}
|
166
|
}
|
|
|
167
|
+ // 校验产品关联合约的激励规则是否匹配订单时间
|
|
|
168
|
+ if cooperationContractsMap[orderGood.CooperationContractNumber] != nil {
|
|
|
169
|
+ for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules {
|
|
|
170
|
+ if orderTime.Before(incentivesRule.DividendsIncentivesStageStart) && orderTime.After(incentivesRule.DividendsIncentivesStageEnd) {
|
|
|
171
|
+ ruleMatchedFlag = true
|
|
|
172
|
+ break
|
|
|
173
|
+ }
|
|
|
174
|
+ }
|
159
|
}
|
175
|
}
|
|
|
176
|
+ if !ruleMatchedFlag {
|
|
|
177
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "订单时间无法匹配分红激励规则,请重新选择")
|
|
|
178
|
+ }
|
|
|
179
|
+ }
|
|
|
180
|
+
|
160
|
orderGoods = append(orderGoods, &domain.OrderGood{
|
181
|
orderGoods = append(orderGoods, &domain.OrderGood{
|
161
|
OrderGoodId: 0,
|
182
|
OrderGoodId: 0,
|
162
|
OrderGoodAmount: orderGoodAmount,
|
183
|
OrderGoodAmount: orderGoodAmount,
|
|
@@ -178,13 +199,6 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD |
|
@@ -178,13 +199,6 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD |
178
|
dividendsOrderAmount, _ = decimal.NewFromFloat(dividendsOrderAmount).Add(decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Sub(decimal.NewFromFloat(orderGood.OrderGoodExpense))).Float64()
|
199
|
dividendsOrderAmount, _ = decimal.NewFromFloat(dividendsOrderAmount).Add(decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Sub(decimal.NewFromFloat(orderGood.OrderGoodExpense))).Float64()
|
179
|
}
|
200
|
}
|
180
|
|
201
|
|
181
|
- // 订单时间转换
|
|
|
182
|
- orderTimeInt, err := strconv.ParseInt(createDividendsOrderCommand.OrderTime, 10, 64)
|
|
|
183
|
- if err != nil {
|
|
|
184
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "订单时间错误")
|
|
|
185
|
- }
|
|
|
186
|
- orderTime := utils.TransformTimestampToTime(orderTimeInt)
|
|
|
187
|
-
|
|
|
188
|
// 新增分红订单
|
202
|
// 新增分红订单
|
189
|
newDividendsOrder := &domain.DividendsOrder{
|
203
|
newDividendsOrder := &domain.DividendsOrder{
|
190
|
DividendsOrderNumber: dividendsOrderNumber,
|
204
|
DividendsOrderNumber: dividendsOrderNumber,
|
|
@@ -696,6 +710,19 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
@@ -696,6 +710,19 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
696
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
710
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
697
|
}
|
711
|
}
|
698
|
|
712
|
|
|
|
713
|
+ // 订单时间转换
|
|
|
714
|
+ orderTimeInt, err := strconv.ParseInt(dividendsOrder.OrderTime, 10, 64)
|
|
|
715
|
+ if err != nil {
|
|
|
716
|
+ row := &domain.ImportInfo{
|
|
|
717
|
+ Error: application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("订单日期转换错误:%s", err)),
|
|
|
718
|
+ LineNumbers: dividendsOrder.LineNumbers, // 错误影响的行
|
|
|
719
|
+ GoodLine: map[int]interface{}{},
|
|
|
720
|
+ }
|
|
|
721
|
+ errorDataList = append(errorDataList, row)
|
|
|
722
|
+ continue
|
|
|
723
|
+ }
|
|
|
724
|
+ orderTime := utils.TransformTimestampToTime(orderTimeInt)
|
|
|
725
|
+
|
699
|
// 新增订单产品
|
726
|
// 新增订单产品
|
700
|
var orderGoods []*domain.OrderGood
|
727
|
var orderGoods []*domain.OrderGood
|
701
|
var dividendsOrderAmount float64
|
728
|
var dividendsOrderAmount float64
|
|
@@ -717,10 +744,23 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
@@ -717,10 +744,23 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
717
|
orderGoodAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Float64()
|
744
|
orderGoodAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Float64()
|
718
|
|
745
|
|
719
|
// 校验共创合约激励类型是否正确
|
746
|
// 校验共创合约激励类型是否正确
|
|
|
747
|
+ ruleMatchedFlag := false
|
720
|
if orderGood.CooperationContractNumber != "" {
|
748
|
if orderGood.CooperationContractNumber != "" {
|
721
|
if cooperationContractsMap[orderGood.CooperationContractNumber] != nil && cooperationContractsMap[orderGood.CooperationContractNumber].IncentivesType != 1 {
|
749
|
if cooperationContractsMap[orderGood.CooperationContractNumber] != nil && cooperationContractsMap[orderGood.CooperationContractNumber].IncentivesType != 1 {
|
722
|
orderGoodErrMap[dividendsOrder.OrderGoods[i].LineNumber] = application.ThrowError(application.INTERNAL_SERVER_ERROR, "退货单产品不能关联金额激励规则")
|
750
|
orderGoodErrMap[dividendsOrder.OrderGoods[i].LineNumber] = application.ThrowError(application.INTERNAL_SERVER_ERROR, "退货单产品不能关联金额激励规则")
|
723
|
}
|
751
|
}
|
|
|
752
|
+ // 校验产品关联合约的激励规则是否匹配订单时间
|
|
|
753
|
+ if cooperationContractsMap[orderGood.CooperationContractNumber] != nil {
|
|
|
754
|
+ for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules {
|
|
|
755
|
+ if orderTime.Before(incentivesRule.DividendsIncentivesStageStart) && orderTime.After(incentivesRule.DividendsIncentivesStageEnd) {
|
|
|
756
|
+ ruleMatchedFlag = true
|
|
|
757
|
+ break
|
|
|
758
|
+ }
|
|
|
759
|
+ }
|
|
|
760
|
+ }
|
|
|
761
|
+ if !ruleMatchedFlag {
|
|
|
762
|
+ orderGoodErrMap[dividendsOrder.OrderGoods[i].LineNumber] = application.ThrowError(application.INTERNAL_SERVER_ERROR, "订单时间无法匹配分红激励规则,请重新选择")
|
|
|
763
|
+ }
|
724
|
}
|
764
|
}
|
725
|
|
765
|
|
726
|
orderGoods = append(orderGoods, &domain.OrderGood{
|
766
|
orderGoods = append(orderGoods, &domain.OrderGood{
|
|
@@ -753,19 +793,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
@@ -753,19 +793,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
753
|
continue
|
793
|
continue
|
754
|
}
|
794
|
}
|
755
|
|
795
|
|
756
|
- // 订单时间转换
|
|
|
757
|
- orderTimeInt, err := strconv.ParseInt(dividendsOrder.OrderTime, 10, 64)
|
|
|
758
|
- if err != nil {
|
|
|
759
|
- row := &domain.ImportInfo{
|
|
|
760
|
- Error: application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("订单日期转换错误:%s", err)),
|
|
|
761
|
- LineNumbers: dividendsOrder.LineNumbers, // 错误影响的行
|
|
|
762
|
- GoodLine: map[int]interface{}{},
|
|
|
763
|
- }
|
|
|
764
|
- errorDataList = append(errorDataList, row)
|
|
|
765
|
- continue
|
|
|
766
|
- }
|
|
|
767
|
- orderTime := utils.TransformTimestampToTime(orderTimeInt)
|
|
|
768
|
-
|
|
|
769
|
// 新增分红订单
|
796
|
// 新增分红订单
|
770
|
newDividendsOrder := &domain.DividendsOrder{
|
797
|
newDividendsOrder := &domain.DividendsOrder{
|
771
|
DividendsOrderId: 0,
|
798
|
DividendsOrderId: 0,
|
|
@@ -1132,6 +1159,8 @@ func (dividendsOrderService *DividendsOrderService) UpdateDividendsOrder(updateD |
|
@@ -1132,6 +1159,8 @@ func (dividendsOrderService *DividendsOrderService) UpdateDividendsOrder(updateD |
1132
|
var orderGoods []*domain.OrderGood
|
1159
|
var orderGoods []*domain.OrderGood
|
1133
|
var dividendsOrderAmount float64
|
1160
|
var dividendsOrderAmount float64
|
1134
|
for _, orderGood := range updateDividendsOrderCommand.OrderGoods {
|
1161
|
for _, orderGood := range updateDividendsOrderCommand.OrderGoods {
|
|
|
1162
|
+ // TODO 合约合法性校验,订单时间匹配规则校验,
|
|
|
1163
|
+
|
1135
|
// 产品ID类型转换
|
1164
|
// 产品ID类型转换
|
1136
|
orderGoodId, err3 := strconv.ParseInt(orderGood.OrderGoodId, 10, 64)
|
1165
|
orderGoodId, err3 := strconv.ParseInt(orderGood.OrderGoodId, 10, 64)
|
1137
|
if err3 != nil {
|
1166
|
if err3 != nil {
|