...
|
...
|
@@ -144,6 +144,13 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD |
|
|
}
|
|
|
}
|
|
|
|
|
|
// 订单时间转换
|
|
|
orderTimeInt, err := strconv.ParseInt(createDividendsOrderCommand.OrderTime, 10, 64)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "订单时间错误")
|
|
|
}
|
|
|
orderTime := utils.TransformTimestampToTime(orderTimeInt)
|
|
|
|
|
|
// 新增订单产品
|
|
|
var orderGoods []*domain.OrderGood
|
|
|
var dividendsOrderAmount float64
|
...
|
...
|
@@ -151,12 +158,26 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD |
|
|
// 计算订单产品金额
|
|
|
orderGoodAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Float64()
|
|
|
|
|
|
// 校验共创合约
|
|
|
ruleMatchedFlag := false
|
|
|
if orderGood.CooperationContractNumber != "" {
|
|
|
// 校验共创合约激励类型是否正确
|
|
|
if cooperationContractsMap[orderGood.CooperationContractNumber] != nil && cooperationContractsMap[orderGood.CooperationContractNumber].IncentivesType != 1 {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单产品不能关联金额激励规则")
|
|
|
}
|
|
|
// 校验产品关联合约的激励规则是否匹配订单时间
|
|
|
if cooperationContractsMap[orderGood.CooperationContractNumber] != nil {
|
|
|
for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules {
|
|
|
if orderTime.Before(incentivesRule.DividendsIncentivesStageStart) && orderTime.After(incentivesRule.DividendsIncentivesStageEnd) {
|
|
|
ruleMatchedFlag = true
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if !ruleMatchedFlag {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "订单时间无法匹配分红激励规则,请重新选择")
|
|
|
}
|
|
|
}
|
|
|
|
|
|
orderGoods = append(orderGoods, &domain.OrderGood{
|
|
|
OrderGoodId: 0,
|
|
|
OrderGoodAmount: orderGoodAmount,
|
...
|
...
|
@@ -178,13 +199,6 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD |
|
|
dividendsOrderAmount, _ = decimal.NewFromFloat(dividendsOrderAmount).Add(decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Sub(decimal.NewFromFloat(orderGood.OrderGoodExpense))).Float64()
|
|
|
}
|
|
|
|
|
|
// 订单时间转换
|
|
|
orderTimeInt, err := strconv.ParseInt(createDividendsOrderCommand.OrderTime, 10, 64)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "订单时间错误")
|
|
|
}
|
|
|
orderTime := utils.TransformTimestampToTime(orderTimeInt)
|
|
|
|
|
|
// 新增分红订单
|
|
|
newDividendsOrder := &domain.DividendsOrder{
|
|
|
DividendsOrderNumber: dividendsOrderNumber,
|
...
|
...
|
@@ -696,6 +710,19 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
// 订单时间转换
|
|
|
orderTimeInt, err := strconv.ParseInt(dividendsOrder.OrderTime, 10, 64)
|
|
|
if err != nil {
|
|
|
row := &domain.ImportInfo{
|
|
|
Error: application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("订单日期转换错误:%s", err)),
|
|
|
LineNumbers: dividendsOrder.LineNumbers, // 错误影响的行
|
|
|
GoodLine: map[int]interface{}{},
|
|
|
}
|
|
|
errorDataList = append(errorDataList, row)
|
|
|
continue
|
|
|
}
|
|
|
orderTime := utils.TransformTimestampToTime(orderTimeInt)
|
|
|
|
|
|
// 新增订单产品
|
|
|
var orderGoods []*domain.OrderGood
|
|
|
var dividendsOrderAmount float64
|
...
|
...
|
@@ -717,10 +744,23 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
orderGoodAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Float64()
|
|
|
|
|
|
// 校验共创合约激励类型是否正确
|
|
|
ruleMatchedFlag := false
|
|
|
if orderGood.CooperationContractNumber != "" {
|
|
|
if cooperationContractsMap[orderGood.CooperationContractNumber] != nil && cooperationContractsMap[orderGood.CooperationContractNumber].IncentivesType != 1 {
|
|
|
orderGoodErrMap[dividendsOrder.OrderGoods[i].LineNumber] = application.ThrowError(application.INTERNAL_SERVER_ERROR, "退货单产品不能关联金额激励规则")
|
|
|
}
|
|
|
// 校验产品关联合约的激励规则是否匹配订单时间
|
|
|
if cooperationContractsMap[orderGood.CooperationContractNumber] != nil {
|
|
|
for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules {
|
|
|
if orderTime.Before(incentivesRule.DividendsIncentivesStageStart) && orderTime.After(incentivesRule.DividendsIncentivesStageEnd) {
|
|
|
ruleMatchedFlag = true
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if !ruleMatchedFlag {
|
|
|
orderGoodErrMap[dividendsOrder.OrderGoods[i].LineNumber] = application.ThrowError(application.INTERNAL_SERVER_ERROR, "订单时间无法匹配分红激励规则,请重新选择")
|
|
|
}
|
|
|
}
|
|
|
|
|
|
orderGoods = append(orderGoods, &domain.OrderGood{
|
...
|
...
|
@@ -753,19 +793,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
continue
|
|
|
}
|
|
|
|
|
|
// 订单时间转换
|
|
|
orderTimeInt, err := strconv.ParseInt(dividendsOrder.OrderTime, 10, 64)
|
|
|
if err != nil {
|
|
|
row := &domain.ImportInfo{
|
|
|
Error: application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("订单日期转换错误:%s", err)),
|
|
|
LineNumbers: dividendsOrder.LineNumbers, // 错误影响的行
|
|
|
GoodLine: map[int]interface{}{},
|
|
|
}
|
|
|
errorDataList = append(errorDataList, row)
|
|
|
continue
|
|
|
}
|
|
|
orderTime := utils.TransformTimestampToTime(orderTimeInt)
|
|
|
|
|
|
// 新增分红订单
|
|
|
newDividendsOrder := &domain.DividendsOrder{
|
|
|
DividendsOrderId: 0,
|
...
|
...
|
@@ -1132,6 +1159,8 @@ func (dividendsOrderService *DividendsOrderService) UpdateDividendsOrder(updateD |
|
|
var orderGoods []*domain.OrderGood
|
|
|
var dividendsOrderAmount float64
|
|
|
for _, orderGood := range updateDividendsOrderCommand.OrderGoods {
|
|
|
// TODO 合约合法性校验,订单时间匹配规则校验,
|
|
|
|
|
|
// 产品ID类型转换
|
|
|
orderGoodId, err3 := strconv.ParseInt(orderGood.OrderGoodId, 10, 64)
|
|
|
if err3 != nil {
|
...
|
...
|
|