作者 陈志颖

fix:取消分红预算单调整

... ... @@ -145,6 +145,10 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
}
}
log.Logger.Info("查询到的合约", map[string]interface{}{
"cooperationContractsMap": cooperationContractsMap,
})
// 订单时间转换
orderTimeInt, err := strconv.ParseInt(createDividendsOrderCommand.OrderTime, 10, 64)
if err != nil {
... ... @@ -163,9 +167,14 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
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 {
if cooperationContractsMap[orderGood.CooperationContractNumber].IncentivesType != 1 {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单产品不能关联金额激励规则")
}
} else {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创合约不存在")
}
// 校验产品关联合约的激励规则是否匹配订单时间
if cooperationContractsMap[orderGood.CooperationContractNumber] != nil {
for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules {
... ...
... ... @@ -44,7 +44,7 @@ type DividendsEstimate struct {
// 操作时间
OperateTime time.Time `comment:"操作时间"`
// 取消状态
IsCanceled bool `comment:"取消状态" pg:",use_zero,default:false"`
IsCanceled bool `comment:"取消状态" pg:",use_zero"`
// 产品ID
OrderGoodId int64 `comment:"产品ID"`
// 创建时间
... ...
... ... @@ -48,6 +48,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
"created_at",
"deleted_at",
"updated_at",
"cooperation_contract_undertaker_id",
}
insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields)
insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlBuildFields)
... ... @@ -86,6 +87,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
&dividendsEstimate.CreatedAt,
&dividendsEstimate.DeletedAt,
&dividendsEstimate.UpdatedAt,
&dividendsEstimate.CooperationContractUndertakerId,
),
fmt.Sprintf("INSERT INTO dividends_estimates (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
dividendsEstimate.DividendsEstimateId,
... ... @@ -110,6 +112,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
dividendsEstimate.CreatedAt,
nil,
dividendsEstimate.UpdatedAt,
dividendsEstimate.CooperationContractUndertakerId,
); err != nil {
return dividendsEstimate, err
}
... ... @@ -138,6 +141,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
&dividendsEstimate.CreatedAt,
&dividendsEstimate.DeletedAt,
&dividendsEstimate.UpdatedAt,
&dividendsEstimate.CooperationContractUndertakerId,
),
fmt.Sprintf("UPDATE dividends_estimates SET %s WHERE dividends_estimate_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
dividendsEstimate.DividendsEstimateId,
... ... @@ -162,6 +166,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
dividendsEstimate.CreatedAt,
nil,
dividendsEstimate.UpdatedAt,
dividendsEstimate.CooperationContractUndertakerId,
dividendsEstimate.Identify(),
); err != nil {
return dividendsEstimate, err
... ... @@ -183,28 +188,29 @@ func (repository *DividendsEstimateRepository) SaveMany(dividendsEstimates []*do
}
}
dividendsEstimateModels = append(dividendsEstimateModels, &models.DividendsEstimate{
DividendsEstimateId: dividendsEstimate.DividendsEstimateId,
DividendsAccountStatus: dividendsEstimate.DividendsAccountStatus,
PaymentStatus: dividendsEstimate.PaymentStatus,
DividendsAmount: dividendsEstimate.DividendsAmount,
DividendsEstimateOrderNumber: dividendsEstimate.DividendsEstimateOrderNumber,
DividendsEstimateTime: dividendsEstimate.DividendsEstimateTime,
DividendsParticipateType: dividendsEstimate.DividendsParticipateType,
DividendsType: dividendsEstimate.DividendsType,
DividendsTypeName: dividendsEstimate.DividendsTypeName,
OrderOrReturnedOrderNum: dividendsEstimate.OrderOrReturnedOrderNum,
CooperationContractNumber: dividendsEstimate.CooperationContractNumber,
DividendsUser: dividendsEstimate.DividendsUser,
DividendsStage: dividendsEstimate.DividendsStage,
Org: dividendsEstimate.Org,
Company: dividendsEstimate.Company,
Operator: dividendsEstimate.Operator,
OperateTime: dividendsEstimate.OperateTime,
IsCanceled: dividendsEstimate.IsCanceled,
OrderGoodId: dividendsEstimate.OrderGoodId,
CreatedAt: dividendsEstimate.CreatedAt,
DeletedAt: dividendsEstimate.DeletedAt,
UpdatedAt: dividendsEstimate.UpdatedAt,
DividendsEstimateId: dividendsEstimate.DividendsEstimateId,
DividendsAccountStatus: dividendsEstimate.DividendsAccountStatus,
PaymentStatus: dividendsEstimate.PaymentStatus,
DividendsAmount: dividendsEstimate.DividendsAmount,
DividendsEstimateOrderNumber: dividendsEstimate.DividendsEstimateOrderNumber,
DividendsEstimateTime: dividendsEstimate.DividendsEstimateTime,
DividendsParticipateType: dividendsEstimate.DividendsParticipateType,
DividendsType: dividendsEstimate.DividendsType,
DividendsTypeName: dividendsEstimate.DividendsTypeName,
OrderOrReturnedOrderNum: dividendsEstimate.OrderOrReturnedOrderNum,
CooperationContractNumber: dividendsEstimate.CooperationContractNumber,
DividendsUser: dividendsEstimate.DividendsUser,
DividendsStage: dividendsEstimate.DividendsStage,
Org: dividendsEstimate.Org,
Company: dividendsEstimate.Company,
Operator: dividendsEstimate.Operator,
OperateTime: dividendsEstimate.OperateTime,
IsCanceled: dividendsEstimate.IsCanceled,
OrderGoodId: dividendsEstimate.OrderGoodId,
CreatedAt: dividendsEstimate.CreatedAt,
DeletedAt: dividendsEstimate.DeletedAt,
UpdatedAt: dividendsEstimate.UpdatedAt,
CooperationContractUndertakerId: dividendsEstimate.CooperationContractUndertakerId,
})
}
if len(dividendsEstimateModels) > 0 {
... ... @@ -229,28 +235,29 @@ func (repository *DividendsEstimateRepository) UpdateMany(dividendsEstimates []*
var dividendsEstimateModels []*models.DividendsEstimate
for _, dividendsEstimate := range dividendsEstimates {
dividendsEstimateModels = append(dividendsEstimateModels, &models.DividendsEstimate{
DividendsEstimateId: dividendsEstimate.DividendsEstimateId,
DividendsAccountStatus: dividendsEstimate.DividendsAccountStatus,
PaymentStatus: dividendsEstimate.PaymentStatus,
DividendsAmount: dividendsEstimate.DividendsAmount,
DividendsEstimateOrderNumber: dividendsEstimate.DividendsEstimateOrderNumber,
DividendsEstimateTime: dividendsEstimate.DividendsEstimateTime,
DividendsParticipateType: dividendsEstimate.DividendsParticipateType,
DividendsType: dividendsEstimate.DividendsType,
DividendsTypeName: dividendsEstimate.DividendsTypeName,
OrderOrReturnedOrderNum: dividendsEstimate.OrderOrReturnedOrderNum,
CooperationContractNumber: dividendsEstimate.CooperationContractNumber,
DividendsUser: dividendsEstimate.DividendsUser,
DividendsStage: dividendsEstimate.DividendsStage,
Org: dividendsEstimate.Org,
Company: dividendsEstimate.Company,
Operator: dividendsEstimate.Operator,
OperateTime: dividendsEstimate.OperateTime,
IsCanceled: dividendsEstimate.IsCanceled,
OrderGoodId: dividendsEstimate.OrderGoodId,
CreatedAt: dividendsEstimate.CreatedAt,
DeletedAt: dividendsEstimate.DeletedAt,
UpdatedAt: time.Now(),
DividendsEstimateId: dividendsEstimate.DividendsEstimateId,
DividendsAccountStatus: dividendsEstimate.DividendsAccountStatus,
PaymentStatus: dividendsEstimate.PaymentStatus,
DividendsAmount: dividendsEstimate.DividendsAmount,
DividendsEstimateOrderNumber: dividendsEstimate.DividendsEstimateOrderNumber,
DividendsEstimateTime: dividendsEstimate.DividendsEstimateTime,
DividendsParticipateType: dividendsEstimate.DividendsParticipateType,
DividendsType: dividendsEstimate.DividendsType,
DividendsTypeName: dividendsEstimate.DividendsTypeName,
OrderOrReturnedOrderNum: dividendsEstimate.OrderOrReturnedOrderNum,
CooperationContractNumber: dividendsEstimate.CooperationContractNumber,
DividendsUser: dividendsEstimate.DividendsUser,
DividendsStage: dividendsEstimate.DividendsStage,
Org: dividendsEstimate.Org,
Company: dividendsEstimate.Company,
Operator: dividendsEstimate.Operator,
OperateTime: dividendsEstimate.OperateTime,
IsCanceled: dividendsEstimate.IsCanceled,
OrderGoodId: dividendsEstimate.OrderGoodId,
CreatedAt: dividendsEstimate.CreatedAt,
DeletedAt: dividendsEstimate.DeletedAt,
UpdatedAt: time.Now(),
CooperationContractUndertakerId: dividendsEstimate.CooperationContractUndertakerId,
})
}
if _, err := tx.Model(&dividendsEstimateModels).WherePK().Update(); err != nil {
... ...
... ... @@ -45,7 +45,7 @@ func (serviceGateway *httplibBaseServiceGateway) createRequest(url string, metho
case "head":
request = httplib.Head(url)
break
default:
:
request = httplib.Get(url)
}
return request.SetTimeout(serviceGateway.connectTimeout, serviceGateway.readWriteTimeout)
... ...