...
|
...
|
@@ -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 |
|
|
÷ndsEstimate.CreatedAt,
|
|
|
÷ndsEstimate.DeletedAt,
|
|
|
÷ndsEstimate.UpdatedAt,
|
|
|
÷ndsEstimate.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 |
|
|
÷ndsEstimate.CreatedAt,
|
|
|
÷ndsEstimate.DeletedAt,
|
|
|
÷ndsEstimate.UpdatedAt,
|
|
|
÷ndsEstimate.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(÷ndsEstimateModels).WherePK().Update(); err != nil {
|
...
|
...
|
@@ -325,6 +332,9 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte |
|
|
if v, ok := queryOptions["cooperationContractNumbers"]; ok && len(v.([]string)) > 0 {
|
|
|
query.Where("cooperation_contract_number in (?)", pg.In(v))
|
|
|
}
|
|
|
if cooperationContractUndertakerId, ok := queryOptions["cooperationContractUndertakerId"]; ok && cooperationContractUndertakerId.(int64) != 0 {
|
|
|
query.Where("cooperation_contract_undertaker_id = ?", cooperationContractUndertakerId)
|
|
|
}
|
|
|
if dividendsParticipateType, ok := queryOptions["dividendsParticipateType"]; ok && dividendsParticipateType.(int32) != 0 {
|
|
|
query.Where("dividends_participate_type = ?", dividendsParticipateType)
|
|
|
}
|
...
|
...
|
@@ -340,6 +350,10 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte |
|
|
if dividendsUserId, ok := queryOptions["dividendsUserId"]; ok && dividendsUserId.(int64) != 0 {
|
|
|
query.Where(`dividends_user @> '{"userId":"?"}'`, dividendsUserId)
|
|
|
}
|
|
|
if dividendsUserIds, ok := queryOptions["dividendsUserIds"]; ok && len(dividendsUserIds.([]int64)) > 0 {
|
|
|
newDividendsUserIds := utils.SliceItoa(dividendsUserIds.([]int64))
|
|
|
query.Where("dividends_user->>'userId' in (?)", pg.In(newDividendsUserIds))
|
|
|
}
|
|
|
if userBaseId, ok := queryOptions["userBaseId"]; ok && userBaseId.(int64) != 0 {
|
|
|
query.Where(`dividends_user @> '{"userBaseId":"?"}'`, userBaseId)
|
|
|
}
|
...
|
...
|
|