正在显示
9 个修改的文件
包含
66 行增加
和
16 行删除
| @@ -8,7 +8,7 @@ import ( | @@ -8,7 +8,7 @@ import ( | ||
| 8 | type CooperationContractUndertaker struct { | 8 | type CooperationContractUndertaker struct { |
| 9 | tableName string `comment:"共创合约承接人" pg:"cooperation_contract_undertakers,alias:cooperation_contract_undertaker"` | 9 | tableName string `comment:"共创合约承接人" pg:"cooperation_contract_undertakers,alias:cooperation_contract_undertaker"` |
| 10 | // 共创合约承接人id | 10 | // 共创合约承接人id |
| 11 | - CooperationContractUndertakerId int64 `comment:"共创合约承接人id" pg:",pk"` | 11 | + CooperationContractUndertakerId int64 `comment:"共创合约承接人id" pg:",pk,unique"` |
| 12 | // 共创合约编号 | 12 | // 共创合约编号 |
| 13 | CooperationContractNumber string `comment:"共创合约编号"` | 13 | CooperationContractNumber string `comment:"共创合约编号"` |
| 14 | // 共创合约承接人uid | 14 | // 共创合约承接人uid |
| @@ -8,7 +8,7 @@ import ( | @@ -8,7 +8,7 @@ import ( | ||
| 8 | type DividendsIncentivesRule struct { | 8 | type DividendsIncentivesRule struct { |
| 9 | tableName string `comment:"金额激励规则实体" pg:"dividends_incentives_rules,alias:dividends_incentives_rule"` | 9 | tableName string `comment:"金额激励规则实体" pg:"dividends_incentives_rules,alias:dividends_incentives_rule"` |
| 10 | // 分红规则ID | 10 | // 分红规则ID |
| 11 | - DividendsIncentivesRuleId int64 `comment:"分红规则ID" pg:",pk"` | 11 | + DividendsIncentivesRuleId int64 `comment:"分红规则ID" pg:",pk,unique"` |
| 12 | // 关联的项目合约编号 | 12 | // 关联的项目合约编号 |
| 13 | CooperationContractNumber string `comment:"关联的项目合约编号"` | 13 | CooperationContractNumber string `comment:"关联的项目合约编号"` |
| 14 | // 推荐人抽成比例 | 14 | // 推荐人抽成比例 |
| @@ -8,7 +8,7 @@ import ( | @@ -8,7 +8,7 @@ import ( | ||
| 8 | type MoneyIncentivesRule struct { | 8 | type MoneyIncentivesRule struct { |
| 9 | tableName string `comment:"金额激励规则实体" pg:"money_incentives_rules,alias:money_incentives_rule"` | 9 | tableName string `comment:"金额激励规则实体" pg:"money_incentives_rules,alias:money_incentives_rule"` |
| 10 | // 金额激励规则ID | 10 | // 金额激励规则ID |
| 11 | - MoneyIncentivesRuleId int64 `comment:"金额激励规则ID" pg:",pk"` | 11 | + MoneyIncentivesRuleId int64 `comment:"金额激励规则ID" pg:",pk,unique"` |
| 12 | // 关联的共创合约编号 | 12 | // 关联的共创合约编号 |
| 13 | CooperationContractNumber string `comment:"关联的共创合约编号"` | 13 | CooperationContractNumber string `comment:"关联的共创合约编号"` |
| 14 | // 激励金额 | 14 | // 激励金额 |
| @@ -265,13 +265,21 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string | @@ -265,13 +265,21 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string | ||
| 265 | // 获取共创项目 | 265 | // 获取共创项目 |
| 266 | cooperationProjectModel := new(models.CooperationProject) | 266 | cooperationProjectModel := new(models.CooperationProject) |
| 267 | cooperationProjectQuery := tx.Model(cooperationProjectModel) | 267 | cooperationProjectQuery := tx.Model(cooperationProjectModel) |
| 268 | - if err := cooperationProjectQuery.Where("cooperation_project_number = ?", cooperationApplicationModel.CooperationProjectNumber).First(); err != nil { | 268 | + if err := cooperationProjectQuery. |
| 269 | + Where("company->>'companyId' = '?'", cooperationApplicationModel.Company.CompanyId). | ||
| 270 | + Where("org->>'orgId' = '?'", cooperationApplicationModel.Org.OrgId). | ||
| 271 | + Where("cooperation_project_number = ?", cooperationApplicationModel.CooperationProjectNumber). | ||
| 272 | + First(); err != nil { | ||
| 269 | return 0, nil, err | 273 | return 0, nil, err |
| 270 | } | 274 | } |
| 271 | // 获取共创模式 | 275 | // 获取共创模式 |
| 272 | cooperationModeModel := new(models.CooperationMode) | 276 | cooperationModeModel := new(models.CooperationMode) |
| 273 | cooperationModeQuery := tx.Model(cooperationModeModel) | 277 | cooperationModeQuery := tx.Model(cooperationModeModel) |
| 274 | - if err := cooperationModeQuery.Where("cooperation_mode_number = ?", cooperationProjectModel.CooperationModeNumber).First(); err != nil { | 278 | + if err := cooperationModeQuery. |
| 279 | + Where("company->>'companyId' = '?'", cooperationApplicationModel.Company.CompanyId). | ||
| 280 | + Where("org->>'orgId' = '?'", cooperationApplicationModel.Org.OrgId). | ||
| 281 | + Where("cooperation_mode_number = ?", cooperationProjectModel.CooperationModeNumber). | ||
| 282 | + First(); err != nil { | ||
| 275 | return 0, nil, err | 283 | return 0, nil, err |
| 276 | } | 284 | } |
| 277 | if cooperationApplication, err := transform.TransformToCooperationApplicationDomainModelFromPgModels(cooperationApplicationModel, cooperationProjectModel, cooperationModeModel); err != nil { | 285 | if cooperationApplication, err := transform.TransformToCooperationApplicationDomainModelFromPgModels(cooperationApplicationModel, cooperationProjectModel, cooperationModeModel); err != nil { |
| @@ -125,10 +125,10 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -125,10 +125,10 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
| 125 | CreatedAt: time.Now(), | 125 | CreatedAt: time.Now(), |
| 126 | }) | 126 | }) |
| 127 | } | 127 | } |
| 128 | - log.Logger.Info("新增的相关人", map[string]interface{}{ | ||
| 129 | - "relevantPeopleModel": relevantPeopleModel, | ||
| 130 | - }) | ||
| 131 | if len(relevantPeopleModel) > 0 { | 128 | if len(relevantPeopleModel) > 0 { |
| 129 | + log.Logger.Info("新增的相关人", map[string]interface{}{ | ||
| 130 | + "relevantPeopleModel": relevantPeopleModel, | ||
| 131 | + }) | ||
| 132 | if _, err := tx.Model(&relevantPeopleModel).Insert(); err != nil { | 132 | if _, err := tx.Model(&relevantPeopleModel).Insert(); err != nil { |
| 133 | return nil, err | 133 | return nil, err |
| 134 | } | 134 | } |
| @@ -158,6 +158,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -158,6 +158,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
| 158 | }) | 158 | }) |
| 159 | } | 159 | } |
| 160 | if len(undertakersModel) > 0 { | 160 | if len(undertakersModel) > 0 { |
| 161 | + log.Logger.Info("新增的承接人", map[string]interface{}{ | ||
| 162 | + "undertakersModel": undertakersModel, | ||
| 163 | + }) | ||
| 161 | if _, err := tx.Model(&undertakersModel).Insert(); err != nil { | 164 | if _, err := tx.Model(&undertakersModel).Insert(); err != nil { |
| 162 | return nil, err | 165 | return nil, err |
| 163 | } | 166 | } |
| @@ -183,6 +186,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -183,6 +186,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
| 183 | }) | 186 | }) |
| 184 | } | 187 | } |
| 185 | if len(dividendsIncentivesRulesModel) > 0 { | 188 | if len(dividendsIncentivesRulesModel) > 0 { |
| 189 | + log.Logger.Info("新增分红激励规则", map[string]interface{}{ | ||
| 190 | + "dividendsIncentivesRulesModel": dividendsIncentivesRulesModel, | ||
| 191 | + }) | ||
| 186 | if _, err := tx.Model(÷ndsIncentivesRulesModel).Insert(); err != nil { | 192 | if _, err := tx.Model(÷ndsIncentivesRulesModel).Insert(); err != nil { |
| 187 | return nil, err | 193 | return nil, err |
| 188 | } | 194 | } |
| @@ -209,6 +215,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -209,6 +215,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
| 209 | }) | 215 | }) |
| 210 | } | 216 | } |
| 211 | if len(moneyIncentivesRulesModel) > 0 { | 217 | if len(moneyIncentivesRulesModel) > 0 { |
| 218 | + log.Logger.Info("新增金额激励规则", map[string]interface{}{ | ||
| 219 | + "moneyIncentivesRulesModel": moneyIncentivesRulesModel, | ||
| 220 | + }) | ||
| 212 | if _, err := tx.Model(&moneyIncentivesRulesModel).Insert(); err != nil { | 221 | if _, err := tx.Model(&moneyIncentivesRulesModel).Insert(); err != nil { |
| 213 | return nil, err | 222 | return nil, err |
| 214 | } | 223 | } |
| @@ -1018,31 +1027,51 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in | @@ -1018,31 +1027,51 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in | ||
| 1018 | // 获取共创模式 | 1027 | // 获取共创模式 |
| 1019 | cooperationModeModel := new(models.CooperationMode) | 1028 | cooperationModeModel := new(models.CooperationMode) |
| 1020 | cooperationModeQuery := tx.Model(cooperationModeModel) | 1029 | cooperationModeQuery := tx.Model(cooperationModeModel) |
| 1021 | - if err := cooperationModeQuery.Where("cooperation_mode_number = ?", cooperationContractModel.CooperationModeNumber).First(); err != nil { | 1030 | + if err := cooperationModeQuery. |
| 1031 | + Where("company->>'companyId' = '?'", cooperationContractModel.Company.CompanyId). | ||
| 1032 | + Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId). | ||
| 1033 | + Where("cooperation_mode_number = ?", cooperationContractModel.CooperationModeNumber). | ||
| 1034 | + First(); err != nil { | ||
| 1022 | return 0, nil, err | 1035 | return 0, nil, err |
| 1023 | } | 1036 | } |
| 1024 | // 获取分红激励规则列表 | 1037 | // 获取分红激励规则列表 |
| 1025 | var dividendsIncentivesRuleModels []*models.DividendsIncentivesRule | 1038 | var dividendsIncentivesRuleModels []*models.DividendsIncentivesRule |
| 1026 | dividendsIncentivesRuleQuery := tx.Model(÷ndsIncentivesRuleModels) | 1039 | dividendsIncentivesRuleQuery := tx.Model(÷ndsIncentivesRuleModels) |
| 1027 | - if err := dividendsIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).Select(); err != nil { | 1040 | + if err := dividendsIncentivesRuleQuery. |
| 1041 | + Where("company->>'companyId' = '?'", cooperationContractModel.Company.CompanyId). | ||
| 1042 | + Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId). | ||
| 1043 | + Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber). | ||
| 1044 | + Select(); err != nil { | ||
| 1028 | return 0, nil, err | 1045 | return 0, nil, err |
| 1029 | } | 1046 | } |
| 1030 | // 获取金额激励规则列表 | 1047 | // 获取金额激励规则列表 |
| 1031 | var moneyIncentivesRuleModels []*models.MoneyIncentivesRule | 1048 | var moneyIncentivesRuleModels []*models.MoneyIncentivesRule |
| 1032 | moneyIncentivesRuleQuery := tx.Model(&moneyIncentivesRuleModels) | 1049 | moneyIncentivesRuleQuery := tx.Model(&moneyIncentivesRuleModels) |
| 1033 | - if err := moneyIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).Select(); err != nil { | 1050 | + if err := moneyIncentivesRuleQuery. |
| 1051 | + Where("company->>'companyId' = '?'", cooperationContractModel.Company.CompanyId). | ||
| 1052 | + Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId). | ||
| 1053 | + Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber). | ||
| 1054 | + Select(); err != nil { | ||
| 1034 | return 0, nil, err | 1055 | return 0, nil, err |
| 1035 | } | 1056 | } |
| 1036 | // 获取承接人列表 | 1057 | // 获取承接人列表 |
| 1037 | var cooperationContractUndertakerModels []*models.CooperationContractUndertaker | 1058 | var cooperationContractUndertakerModels []*models.CooperationContractUndertaker |
| 1038 | cooperationContractUndertakerQuery := tx.Model(&cooperationContractUndertakerModels) | 1059 | cooperationContractUndertakerQuery := tx.Model(&cooperationContractUndertakerModels) |
| 1039 | - if err := cooperationContractUndertakerQuery.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).Select(); err != nil { | 1060 | + if err := cooperationContractUndertakerQuery. |
| 1061 | + Where("company->>'companyId' = '?'", cooperationContractModel.Company.CompanyId). | ||
| 1062 | + Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId). | ||
| 1063 | + Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber). | ||
| 1064 | + Select(); err != nil { | ||
| 1040 | return 0, nil, err | 1065 | return 0, nil, err |
| 1041 | } | 1066 | } |
| 1042 | // 获取相关人列表 | 1067 | // 获取相关人列表 |
| 1043 | var cooperationContractRelevantModels []*models.CooperationContractRelevant | 1068 | var cooperationContractRelevantModels []*models.CooperationContractRelevant |
| 1044 | cooperationContractRelevantQuery := tx.Model(&cooperationContractRelevantModels) | 1069 | cooperationContractRelevantQuery := tx.Model(&cooperationContractRelevantModels) |
| 1045 | - if err := cooperationContractRelevantQuery.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).Select(); err != nil { | 1070 | + if err := cooperationContractRelevantQuery. |
| 1071 | + Where("company->>'companyId' = '?'", cooperationContractModel.Company.CompanyId). | ||
| 1072 | + Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId). | ||
| 1073 | + Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber). | ||
| 1074 | + Select(); err != nil { | ||
| 1046 | return 0, nil, err | 1075 | return 0, nil, err |
| 1047 | } | 1076 | } |
| 1048 | if cooperationContract, err := transform.TransformToCooperationContractDomainModelFromPgModels( | 1077 | if cooperationContract, err := transform.TransformToCooperationContractDomainModelFromPgModels( |
| @@ -279,7 +279,11 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int | @@ -279,7 +279,11 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int | ||
| 279 | // 获取共创模式 | 279 | // 获取共创模式 |
| 280 | cooperationModeModel := new(models.CooperationMode) | 280 | cooperationModeModel := new(models.CooperationMode) |
| 281 | cooperationModeQuery := tx.Model(cooperationModeModel) | 281 | cooperationModeQuery := tx.Model(cooperationModeModel) |
| 282 | - if err := cooperationModeQuery.Where("cooperation_mode_number = ?", cooperationProjectModel.CooperationModeNumber).First(); err != nil { | 282 | + if err := cooperationModeQuery. |
| 283 | + Where("company->>'companyId' = '?'", cooperationProjectModel.Company.CompanyId). | ||
| 284 | + Where("org->>'orgId' = '?'", cooperationProjectModel.Org.OrgId). | ||
| 285 | + Where("cooperation_mode_number = ?", cooperationProjectModel.CooperationModeNumber). | ||
| 286 | + First(); err != nil { | ||
| 283 | return 0, nil, err | 287 | return 0, nil, err |
| 284 | } | 288 | } |
| 285 | if cooperationProject, err := transform.TransformToCooperationProjectDomainModelFromPgModels(cooperationProjectModel, cooperationModeModel); err != nil { | 289 | if cooperationProject, err := transform.TransformToCooperationProjectDomainModelFromPgModels(cooperationProjectModel, cooperationModeModel); err != nil { |
| @@ -433,7 +433,11 @@ func (repository *DividendsOrderRepository) Find(queryOptions map[string]interfa | @@ -433,7 +433,11 @@ func (repository *DividendsOrderRepository) Find(queryOptions map[string]interfa | ||
| 433 | //获取订单产品 | 433 | //获取订单产品 |
| 434 | var orderGoodModels []*models.OrderGood | 434 | var orderGoodModels []*models.OrderGood |
| 435 | orderGoodModelQuery := tx.Model(&orderGoodModels) | 435 | orderGoodModelQuery := tx.Model(&orderGoodModels) |
| 436 | - if err := orderGoodModelQuery.Where("dividends_order_number = ?", dividendsOrderModel.DividendsOrderNumber).Select(); err != nil { | 436 | + if err := orderGoodModelQuery. |
| 437 | + Where("company->>'companyId' = '?'", dividendsOrderModel.Company.CompanyId). | ||
| 438 | + Where("org->>'orgId' = '?'", dividendsOrderModel.Org.OrgId). | ||
| 439 | + Where("dividends_order_number = ?", dividendsOrderModel.DividendsOrderNumber). | ||
| 440 | + Select(); err != nil { | ||
| 437 | return 0, nil, err | 441 | return 0, nil, err |
| 438 | } | 442 | } |
| 439 | // 聚合分红订单 | 443 | // 聚合分红订单 |
| @@ -435,7 +435,11 @@ func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string | @@ -435,7 +435,11 @@ func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string | ||
| 435 | // 获取订单产品 | 435 | // 获取订单产品 |
| 436 | var orderGoodModels []*models.OrderGood | 436 | var orderGoodModels []*models.OrderGood |
| 437 | orderGoodModelQuery := tx.Model(&orderGoodModels) | 437 | orderGoodModelQuery := tx.Model(&orderGoodModels) |
| 438 | - if err := orderGoodModelQuery.Where("dividends_returned_order_number = ?", dividendsReturnedOrderModel.DividendsReturnedOrderNumber).Select(); err != nil { | 438 | + if err := orderGoodModelQuery. |
| 439 | + Where("company->>'companyId' = '?'", dividendsReturnedOrderModel.Company.CompanyId). | ||
| 440 | + Where("org->>'orgId' = '?'", dividendsReturnedOrderModel.Org.OrgId). | ||
| 441 | + Where("dividends_returned_order_number = ?", dividendsReturnedOrderModel.DividendsReturnedOrderNumber). | ||
| 442 | + Select(); err != nil { | ||
| 439 | return 0, nil, err | 443 | return 0, nil, err |
| 440 | } | 444 | } |
| 441 | if dividendsReturnedOrder, err := transform.TransformToDividendsReturnedOrderDomainModelFromPgModels(dividendsReturnedOrderModel, orderGoodModels); err != nil { | 445 | if dividendsReturnedOrder, err := transform.TransformToDividendsReturnedOrderDomainModelFromPgModels(dividendsReturnedOrderModel, orderGoodModels); err != nil { |
| @@ -26,6 +26,7 @@ func (repository *OrderGoodRepository) nextIdentify() (int64, error) { | @@ -26,6 +26,7 @@ func (repository *OrderGoodRepository) nextIdentify() (int64, error) { | ||
| 26 | id, err := IdWorker.NextId() | 26 | id, err := IdWorker.NextId() |
| 27 | return id, err | 27 | return id, err |
| 28 | } | 28 | } |
| 29 | + | ||
| 29 | func (repository *OrderGoodRepository) Save(orderGood *domain.OrderGood) (*domain.OrderGood, error) { | 30 | func (repository *OrderGoodRepository) Save(orderGood *domain.OrderGood) (*domain.OrderGood, error) { |
| 30 | sqlBuildFields := []string{ | 31 | sqlBuildFields := []string{ |
| 31 | "order_good_id", | 32 | "order_good_id", |
-
请 注册 或 登录 后发表评论