Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creat…
…ion-cooperation into dev
正在显示
18 个修改的文件
包含
147 行增加
和
43 行删除
| @@ -1303,7 +1303,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -1303,7 +1303,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
| 1303 | UserPhone: "", | 1303 | UserPhone: "", |
| 1304 | } | 1304 | } |
| 1305 | } | 1305 | } |
| 1306 | - undertakersOriginal = undertakersOriginal + strconv.FormatInt(int64(i), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")" | 1306 | + undertakersOriginal = undertakersOriginal + strconv.FormatInt(int64(i+1), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")" |
| 1307 | } | 1307 | } |
| 1308 | undertakerChangeTmp1 := "【" + undertakersOriginal + "】" | 1308 | undertakerChangeTmp1 := "【" + undertakersOriginal + "】" |
| 1309 | 1309 | ||
| @@ -1340,7 +1340,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -1340,7 +1340,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
| 1340 | UserPhone: "", | 1340 | UserPhone: "", |
| 1341 | } | 1341 | } |
| 1342 | } | 1342 | } |
| 1343 | - undertakersChanged = undertakersChanged + strconv.FormatInt(int64(i), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")" | 1343 | + undertakersChanged = undertakersChanged + strconv.FormatInt(int64(i+1), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")" |
| 1344 | } | 1344 | } |
| 1345 | undertakerChangeTemp2 := "【" + undertakersChanged + "】" | 1345 | undertakerChangeTemp2 := "【" + undertakersChanged + "】" |
| 1346 | // 拼接承接人变更记录 | 1346 | // 拼接承接人变更记录 |
| @@ -617,7 +617,9 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD | @@ -617,7 +617,9 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD | ||
| 617 | }, nil | 617 | }, nil |
| 618 | } | 618 | } |
| 619 | 619 | ||
| 620 | - // 批量导入创建分红订单 | 620 | + var creatDividendsOrder []*domain.DividendsOrder |
| 621 | + | ||
| 622 | + // 批量创建分红订单 | ||
| 621 | for _, dividendsOrder := range createDividendsOrderCommands { | 623 | for _, dividendsOrder := range createDividendsOrderCommands { |
| 622 | // 生成分红订单号 | 624 | // 生成分红订单号 |
| 623 | dividendsOrderNumber, err := dividendsOrderDao.GenerateDividendsOrderNumber() | 625 | dividendsOrderNumber, err := dividendsOrderDao.GenerateDividendsOrderNumber() |
| @@ -732,19 +734,14 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD | @@ -732,19 +734,14 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD | ||
| 732 | Operator: operator, | 734 | Operator: operator, |
| 733 | } | 735 | } |
| 734 | 736 | ||
| 735 | - if _, err2 := dividendsOrderRepository.Save(newDividendsOrder); err2 != nil { | ||
| 736 | - row := &domain.ImportInfo{ | ||
| 737 | - Error: application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("保存订单数据失败:%s", err)), | ||
| 738 | - LineNumbers: dividendsOrder.LineNumbers, // 错误影响的行 | ||
| 739 | - GoodLine: map[int]interface{}{}, | ||
| 740 | - } | ||
| 741 | - errorDataList = append(errorDataList, row) | ||
| 742 | - continue | ||
| 743 | - } | 737 | + creatDividendsOrder = append(creatDividendsOrder, newDividendsOrder) |
| 744 | } | 738 | } |
| 745 | 739 | ||
| 746 | // 错误报告处理 | 740 | // 错误报告处理 |
| 747 | if len(errorDataList) <= 0 { // 成功返回 | 741 | if len(errorDataList) <= 0 { // 成功返回 |
| 742 | + if _, err2 := dividendsOrderRepository.SaveMany(creatDividendsOrder); err2 != nil { | ||
| 743 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error()) | ||
| 744 | + } | ||
| 748 | if err3 := transactionContext.CommitTransaction(); err3 != nil { | 745 | if err3 := transactionContext.CommitTransaction(); err3 != nil { |
| 749 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err3.Error()) | 746 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err3.Error()) |
| 750 | } | 747 | } |
| @@ -66,6 +66,7 @@ type FailInfo struct { | @@ -66,6 +66,7 @@ type FailInfo struct { | ||
| 66 | 66 | ||
| 67 | type DividendsOrderRepository interface { | 67 | type DividendsOrderRepository interface { |
| 68 | Save(dividendsOrder *DividendsOrder) (*DividendsOrder, error) | 68 | Save(dividendsOrder *DividendsOrder) (*DividendsOrder, error) |
| 69 | + SaveMany(dividendsOrders []*DividendsOrder) ([]*DividendsOrder, error) | ||
| 69 | UpdateMany(dividendsOrders []*DividendsOrder) ([]*DividendsOrder, error) | 70 | UpdateMany(dividendsOrders []*DividendsOrder) ([]*DividendsOrder, error) |
| 70 | Remove(dividendsOrder *DividendsOrder) (*DividendsOrder, error) | 71 | Remove(dividendsOrder *DividendsOrder) (*DividendsOrder, error) |
| 71 | BatchRemove(dividendsOrders []*DividendsOrder) ([]*DividendsOrder, error) | 72 | BatchRemove(dividendsOrders []*DividendsOrder) ([]*DividendsOrder, error) |
| @@ -134,7 +134,7 @@ func (repository *ContractUndertakerFeedbackRepository) FindOne(queryOptions map | @@ -134,7 +134,7 @@ func (repository *ContractUndertakerFeedbackRepository) FindOne(queryOptions map | ||
| 134 | query.SetWhereByQueryOption("contract_undertaker_feedback.feedback_id = ?", "contractUndertakerFeedbackId") | 134 | query.SetWhereByQueryOption("contract_undertaker_feedback.feedback_id = ?", "contractUndertakerFeedbackId") |
| 135 | if err := query.First(); err != nil { | 135 | if err := query.First(); err != nil { |
| 136 | if err.Error() == "pg: no rows in result set" { | 136 | if err.Error() == "pg: no rows in result set" { |
| 137 | - return nil, fmt.Errorf("没有此资源") | 137 | + return nil, fmt.Errorf("承接人反馈信息不存在") |
| 138 | } else { | 138 | } else { |
| 139 | return nil, err | 139 | return nil, err |
| 140 | } | 140 | } |
| @@ -4,6 +4,7 @@ import ( | @@ -4,6 +4,7 @@ import ( | ||
| 4 | "fmt" | 4 | "fmt" |
| 5 | "github.com/go-pg/pg/v10" | 5 | "github.com/go-pg/pg/v10" |
| 6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" | 6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" |
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log" | ||
| 7 | "time" | 8 | "time" |
| 8 | 9 | ||
| 9 | "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder" | 10 | "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder" |
| @@ -189,7 +190,7 @@ func (repository *CooperationApplicationRepository) FindOne(queryOptions map[str | @@ -189,7 +190,7 @@ func (repository *CooperationApplicationRepository) FindOne(queryOptions map[str | ||
| 189 | query.SetWhereByQueryOption("cooperation_application.cooperation_application_id = ?", "cooperationApplicationId") | 190 | query.SetWhereByQueryOption("cooperation_application.cooperation_application_id = ?", "cooperationApplicationId") |
| 190 | if err := query.First(); err != nil { | 191 | if err := query.First(); err != nil { |
| 191 | if err.Error() == "pg: no rows in result set" { | 192 | if err.Error() == "pg: no rows in result set" { |
| 192 | - return nil, fmt.Errorf("没有此资源") | 193 | + return nil, fmt.Errorf("共创申请不存在") |
| 193 | } else { | 194 | } else { |
| 194 | return nil, err | 195 | return nil, err |
| 195 | } | 196 | } |
| @@ -200,14 +201,26 @@ func (repository *CooperationApplicationRepository) FindOne(queryOptions map[str | @@ -200,14 +201,26 @@ func (repository *CooperationApplicationRepository) FindOne(queryOptions map[str | ||
| 200 | // 获取共创项目 | 201 | // 获取共创项目 |
| 201 | cooperationProjectModel := new(models.CooperationProject) | 202 | cooperationProjectModel := new(models.CooperationProject) |
| 202 | cooperationProjectQuery := tx.Model(cooperationProjectModel) | 203 | cooperationProjectQuery := tx.Model(cooperationProjectModel) |
| 203 | - if err := cooperationProjectQuery.Where("cooperation_project_number = ?", cooperationApplicationModel.CooperationProjectNumber).First(); err != nil { | ||
| 204 | - return nil, err | 204 | + if err := cooperationProjectQuery. |
| 205 | + Where("company->>'companyId' = '?'", cooperationApplicationModel.Company.CompanyId). | ||
| 206 | + Where("org->>'orgId' = '?'", cooperationApplicationModel.Org.OrgId). | ||
| 207 | + Where("cooperation_project_number = ?", cooperationApplicationModel.CooperationProjectNumber).First(); err != nil { | ||
| 208 | + log.Logger.Error("申请关联的共创项目不存在", map[string]interface{}{ | ||
| 209 | + "cooperationApplicationModel": cooperationApplicationModel, | ||
| 210 | + }) | ||
| 211 | + return nil, fmt.Errorf("申请关联的共创项目不存在") | ||
| 205 | } | 212 | } |
| 206 | // 获取共创模式 | 213 | // 获取共创模式 |
| 207 | cooperationModeModel := new(models.CooperationMode) | 214 | cooperationModeModel := new(models.CooperationMode) |
| 208 | cooperationModeQuery := tx.Model(cooperationModeModel) | 215 | cooperationModeQuery := tx.Model(cooperationModeModel) |
| 209 | - if err := cooperationModeQuery.Where("cooperation_mode_number = ?", cooperationProjectModel.CooperationModeNumber).First(); err != nil { | ||
| 210 | - return nil, err | 216 | + if err := cooperationModeQuery. |
| 217 | + Where("company->>'companyId' = '?'", cooperationApplicationModel.Company.CompanyId). | ||
| 218 | + Where("org->>'orgId' = '?'", cooperationApplicationModel.Org.OrgId). | ||
| 219 | + Where("cooperation_mode_number = ?", cooperationProjectModel.CooperationModeNumber).First(); err != nil { | ||
| 220 | + log.Logger.Error("申请关联的共创模式不存在", map[string]interface{}{ | ||
| 221 | + "cooperationApplicationModel": cooperationApplicationModel, | ||
| 222 | + }) | ||
| 223 | + return nil, fmt.Errorf("申请关联的共创模式不存在") | ||
| 211 | } | 224 | } |
| 212 | return transform.TransformToCooperationApplicationDomainModelFromPgModels(cooperationApplicationModel, cooperationProjectModel, cooperationModeModel) | 225 | return transform.TransformToCooperationApplicationDomainModelFromPgModels(cooperationApplicationModel, cooperationProjectModel, cooperationModeModel) |
| 213 | } | 226 | } |
| @@ -271,7 +284,10 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string | @@ -271,7 +284,10 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string | ||
| 271 | Where("org->>'orgId' = '?'", cooperationApplicationModel.Org.OrgId). | 284 | Where("org->>'orgId' = '?'", cooperationApplicationModel.Org.OrgId). |
| 272 | Where("cooperation_project_number = ?", cooperationApplicationModel.CooperationProjectNumber). | 285 | Where("cooperation_project_number = ?", cooperationApplicationModel.CooperationProjectNumber). |
| 273 | First(); err != nil { | 286 | First(); err != nil { |
| 274 | - return 0, nil, err | 287 | + log.Logger.Error("申请关联的共创项目不存在", map[string]interface{}{ |
| 288 | + "cooperationApplicationModel": cooperationApplicationModel, | ||
| 289 | + }) | ||
| 290 | + return 0, nil, fmt.Errorf("申请关联的共创项目不存在") | ||
| 275 | } | 291 | } |
| 276 | // 获取共创模式 | 292 | // 获取共创模式 |
| 277 | cooperationModeModel := new(models.CooperationMode) | 293 | cooperationModeModel := new(models.CooperationMode) |
| @@ -282,7 +298,10 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string | @@ -282,7 +298,10 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string | ||
| 282 | Where("org->>'orgId' = '?'", cooperationApplicationModel.Org.OrgId). | 298 | Where("org->>'orgId' = '?'", cooperationApplicationModel.Org.OrgId). |
| 283 | Where("cooperation_mode_number = ?", cooperationProjectModel.CooperationModeNumber). | 299 | Where("cooperation_mode_number = ?", cooperationProjectModel.CooperationModeNumber). |
| 284 | First(); err != nil { | 300 | First(); err != nil { |
| 285 | - return 0, nil, err | 301 | + log.Logger.Error("申请关联的共创模式不存在", map[string]interface{}{ |
| 302 | + "cooperationApplicationModel": cooperationApplicationModel, | ||
| 303 | + }) | ||
| 304 | + return 0, nil, fmt.Errorf("申请关联的共创模式不存在") | ||
| 286 | } | 305 | } |
| 287 | if cooperationApplication, err := transform.TransformToCooperationApplicationDomainModelFromPgModels(cooperationApplicationModel, cooperationProjectModel, cooperationModeModel); err != nil { | 306 | if cooperationApplication, err := transform.TransformToCooperationApplicationDomainModelFromPgModels(cooperationApplicationModel, cooperationProjectModel, cooperationModeModel); err != nil { |
| 288 | return 0, cooperationApplications, err | 307 | return 0, cooperationApplications, err |
| @@ -139,7 +139,7 @@ func (repository *CooperationContractChangeLogRepository) FindOne(queryOptions m | @@ -139,7 +139,7 @@ func (repository *CooperationContractChangeLogRepository) FindOne(queryOptions m | ||
| 139 | query.SetWhereByQueryOption("cooperation_contract_change_log.cooperation_contract_change_log_id = ?", "cooperationContractChangeLogId") | 139 | query.SetWhereByQueryOption("cooperation_contract_change_log.cooperation_contract_change_log_id = ?", "cooperationContractChangeLogId") |
| 140 | if err := query.First(); err != nil { | 140 | if err := query.First(); err != nil { |
| 141 | if err.Error() == "pg: no rows in result set" { | 141 | if err.Error() == "pg: no rows in result set" { |
| 142 | - return nil, fmt.Errorf("没有此资源") | 142 | + return nil, fmt.Errorf("共创合约变更记录不存在") |
| 143 | } else { | 143 | } else { |
| 144 | return nil, err | 144 | return nil, err |
| 145 | } | 145 | } |
| @@ -154,7 +154,7 @@ func (repository *CooperationContractRelevantRepository) FindOne(queryOptions ma | @@ -154,7 +154,7 @@ func (repository *CooperationContractRelevantRepository) FindOne(queryOptions ma | ||
| 154 | query.SetWhereByQueryOption("cooperation_contract_relevant.cooperation_contract_relevant_id = ?", "cooperationContractRelevantId") | 154 | query.SetWhereByQueryOption("cooperation_contract_relevant.cooperation_contract_relevant_id = ?", "cooperationContractRelevantId") |
| 155 | if err := query.First(); err != nil { | 155 | if err := query.First(); err != nil { |
| 156 | if err.Error() == "pg: no rows in result set" { | 156 | if err.Error() == "pg: no rows in result set" { |
| 157 | - return nil, fmt.Errorf("没有此资源") | 157 | + return nil, fmt.Errorf("合约相关人不存在") |
| 158 | } else { | 158 | } else { |
| 159 | return nil, err | 159 | return nil, err |
| 160 | } | 160 | } |
| @@ -1032,7 +1032,7 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in | @@ -1032,7 +1032,7 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in | ||
| 1032 | Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId). | 1032 | Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId). |
| 1033 | Where("cooperation_mode_number = ?", cooperationContractModel.CooperationModeNumber). | 1033 | Where("cooperation_mode_number = ?", cooperationContractModel.CooperationModeNumber). |
| 1034 | First(); err != nil { | 1034 | First(); err != nil { |
| 1035 | - return 0, nil, err | 1035 | + return 0, nil, fmt.Errorf("合约关联的共创模式不存在") |
| 1036 | } | 1036 | } |
| 1037 | // 获取分红激励规则列表 | 1037 | // 获取分红激励规则列表 |
| 1038 | var dividendsIncentivesRuleModels []*models.DividendsIncentivesRule | 1038 | var dividendsIncentivesRuleModels []*models.DividendsIncentivesRule |
| @@ -1042,7 +1042,7 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in | @@ -1042,7 +1042,7 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in | ||
| 1042 | Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId). | 1042 | Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId). |
| 1043 | Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber). | 1043 | Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber). |
| 1044 | Select(); err != nil { | 1044 | Select(); err != nil { |
| 1045 | - return 0, nil, err | 1045 | + return 0, nil, fmt.Errorf("合约关联的分红激励规则列表不存在") |
| 1046 | } | 1046 | } |
| 1047 | // 获取金额激励规则列表 | 1047 | // 获取金额激励规则列表 |
| 1048 | var moneyIncentivesRuleModels []*models.MoneyIncentivesRule | 1048 | var moneyIncentivesRuleModels []*models.MoneyIncentivesRule |
| @@ -1052,7 +1052,7 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in | @@ -1052,7 +1052,7 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in | ||
| 1052 | Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId). | 1052 | Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId). |
| 1053 | Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber). | 1053 | Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber). |
| 1054 | Select(); err != nil { | 1054 | Select(); err != nil { |
| 1055 | - return 0, nil, err | 1055 | + return 0, nil, fmt.Errorf("合约关联的金额激励规则列表不存在") |
| 1056 | } | 1056 | } |
| 1057 | // 获取承接人列表 | 1057 | // 获取承接人列表 |
| 1058 | var cooperationContractUndertakerModels []*models.CooperationContractUndertaker | 1058 | var cooperationContractUndertakerModels []*models.CooperationContractUndertaker |
| @@ -1062,7 +1062,7 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in | @@ -1062,7 +1062,7 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in | ||
| 1062 | Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId). | 1062 | Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId). |
| 1063 | Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber). | 1063 | Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber). |
| 1064 | Select(); err != nil { | 1064 | Select(); err != nil { |
| 1065 | - return 0, nil, err | 1065 | + return 0, nil, fmt.Errorf("合约相关的承接人列表不存在") |
| 1066 | } | 1066 | } |
| 1067 | // 获取相关人列表 | 1067 | // 获取相关人列表 |
| 1068 | var cooperationContractRelevantModels []*models.CooperationContractRelevant | 1068 | var cooperationContractRelevantModels []*models.CooperationContractRelevant |
| @@ -1072,7 +1072,7 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in | @@ -1072,7 +1072,7 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in | ||
| 1072 | Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId). | 1072 | Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId). |
| 1073 | Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber). | 1073 | Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber). |
| 1074 | Select(); err != nil { | 1074 | Select(); err != nil { |
| 1075 | - return 0, nil, err | 1075 | + return 0, nil, fmt.Errorf("合约相关的相关人列表不存在") |
| 1076 | } | 1076 | } |
| 1077 | if cooperationContract, err := transform.TransformToCooperationContractDomainModelFromPgModels( | 1077 | if cooperationContract, err := transform.TransformToCooperationContractDomainModelFromPgModels( |
| 1078 | cooperationContractModel, | 1078 | cooperationContractModel, |
| @@ -169,7 +169,7 @@ func (repository *CooperationContractUndertakerRepository) FindOne(queryOptions | @@ -169,7 +169,7 @@ func (repository *CooperationContractUndertakerRepository) FindOne(queryOptions | ||
| 169 | query.SetWhereByQueryOption("cooperation_contract_undertaker.cooperation_contract_undertaker_id = ?", "cooperationContractUndertakerId") | 169 | query.SetWhereByQueryOption("cooperation_contract_undertaker.cooperation_contract_undertaker_id = ?", "cooperationContractUndertakerId") |
| 170 | if err := query.First(); err != nil { | 170 | if err := query.First(); err != nil { |
| 171 | if err.Error() == "pg: no rows in result set" { | 171 | if err.Error() == "pg: no rows in result set" { |
| 172 | - return nil, fmt.Errorf("没有此资源") | 172 | + return nil, fmt.Errorf("合约承接人不存在") |
| 173 | } else { | 173 | } else { |
| 174 | return nil, err | 174 | return nil, err |
| 175 | } | 175 | } |
| @@ -156,7 +156,7 @@ func (repository *CooperationModeRepository) FindOne(queryOptions map[string]int | @@ -156,7 +156,7 @@ func (repository *CooperationModeRepository) FindOne(queryOptions map[string]int | ||
| 156 | } | 156 | } |
| 157 | if err := query.First(); err != nil { | 157 | if err := query.First(); err != nil { |
| 158 | if err.Error() == "pg: no rows in result set" { | 158 | if err.Error() == "pg: no rows in result set" { |
| 159 | - return nil, fmt.Errorf("没有此资源") | 159 | + return nil, fmt.Errorf("共创模式不存在") |
| 160 | } else { | 160 | } else { |
| 161 | return nil, err | 161 | return nil, err |
| 162 | } | 162 | } |
| @@ -4,6 +4,7 @@ import ( | @@ -4,6 +4,7 @@ import ( | ||
| 4 | "fmt" | 4 | "fmt" |
| 5 | "github.com/go-pg/pg/v10" | 5 | "github.com/go-pg/pg/v10" |
| 6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" | 6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" |
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log" | ||
| 7 | "time" | 8 | "time" |
| 8 | 9 | ||
| 9 | "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder" | 10 | "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder" |
| @@ -218,7 +219,7 @@ func (repository *CooperationProjectRepository) FindOne(queryOptions map[string] | @@ -218,7 +219,7 @@ func (repository *CooperationProjectRepository) FindOne(queryOptions map[string] | ||
| 218 | } | 219 | } |
| 219 | if err := query.First(); err != nil { | 220 | if err := query.First(); err != nil { |
| 220 | if err.Error() == "pg: no rows in result set" { | 221 | if err.Error() == "pg: no rows in result set" { |
| 221 | - return nil, fmt.Errorf("没有此资源") | 222 | + return nil, fmt.Errorf("共创项目不存在") |
| 222 | } else { | 223 | } else { |
| 223 | return nil, err | 224 | return nil, err |
| 224 | } | 225 | } |
| @@ -230,7 +231,10 @@ func (repository *CooperationProjectRepository) FindOne(queryOptions map[string] | @@ -230,7 +231,10 @@ func (repository *CooperationProjectRepository) FindOne(queryOptions map[string] | ||
| 230 | cooperationModeModel := new(models.CooperationMode) | 231 | cooperationModeModel := new(models.CooperationMode) |
| 231 | cooperationModeQuery := tx.Model(cooperationModeModel) | 232 | cooperationModeQuery := tx.Model(cooperationModeModel) |
| 232 | if err := cooperationModeQuery.Where("cooperation_mode_number = ?", cooperationProjectModel.CooperationModeNumber).First(); err != nil { | 233 | if err := cooperationModeQuery.Where("cooperation_mode_number = ?", cooperationProjectModel.CooperationModeNumber).First(); err != nil { |
| 233 | - return nil, err | 234 | + log.Logger.Error("共创项目关联的共创模式不存在", map[string]interface{}{ |
| 235 | + "cooperationProjectModel": cooperationProjectModel, | ||
| 236 | + }) | ||
| 237 | + return nil, fmt.Errorf("共创项目关联的共创模式不存在") | ||
| 234 | } | 238 | } |
| 235 | return transform.TransformToCooperationProjectDomainModelFromPgModels(cooperationProjectModel, cooperationModeModel) | 239 | return transform.TransformToCooperationProjectDomainModelFromPgModels(cooperationProjectModel, cooperationModeModel) |
| 236 | } | 240 | } |
| @@ -287,7 +291,10 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int | @@ -287,7 +291,10 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int | ||
| 287 | Where("org->>'orgId' = '?'", cooperationProjectModel.Org.OrgId). | 291 | Where("org->>'orgId' = '?'", cooperationProjectModel.Org.OrgId). |
| 288 | Where("cooperation_mode_number = ?", cooperationProjectModel.CooperationModeNumber). | 292 | Where("cooperation_mode_number = ?", cooperationProjectModel.CooperationModeNumber). |
| 289 | First(); err != nil { | 293 | First(); err != nil { |
| 290 | - return 0, nil, err | 294 | + log.Logger.Error("共创项目关联的共创模式不存在", map[string]interface{}{ |
| 295 | + "cooperationProjectModel": cooperationProjectModel, | ||
| 296 | + }) | ||
| 297 | + return 0, nil, fmt.Errorf("共创项目关联的共创模式不存在") | ||
| 291 | } | 298 | } |
| 292 | if cooperationProject, err := transform.TransformToCooperationProjectDomainModelFromPgModels(cooperationProjectModel, cooperationModeModel); err != nil { | 299 | if cooperationProject, err := transform.TransformToCooperationProjectDomainModelFromPgModels(cooperationProjectModel, cooperationModeModel); err != nil { |
| 293 | return 0, cooperationProjects, err | 300 | return 0, cooperationProjects, err |
| @@ -184,7 +184,7 @@ func (repository *CreditAccountRepository) FindOne(queryOptions map[string]inter | @@ -184,7 +184,7 @@ func (repository *CreditAccountRepository) FindOne(queryOptions map[string]inter | ||
| 184 | query.SetWhereByQueryOption("credit_account.credit_account_id = ?", "creditAccountId") | 184 | query.SetWhereByQueryOption("credit_account.credit_account_id = ?", "creditAccountId") |
| 185 | if err := query.First(); err != nil { | 185 | if err := query.First(); err != nil { |
| 186 | if err.Error() == "pg: no rows in result set" { | 186 | if err.Error() == "pg: no rows in result set" { |
| 187 | - return nil, fmt.Errorf("没有此资源") | 187 | + return nil, fmt.Errorf("账期结算单不存在") |
| 188 | } else { | 188 | } else { |
| 189 | return nil, err | 189 | return nil, err |
| 190 | } | 190 | } |
| @@ -264,7 +264,7 @@ func (repository *DividendsEstimateRepository) FindOne(queryOptions map[string]i | @@ -264,7 +264,7 @@ func (repository *DividendsEstimateRepository) FindOne(queryOptions map[string]i | ||
| 264 | } | 264 | } |
| 265 | if err := query.First(); err != nil { | 265 | if err := query.First(); err != nil { |
| 266 | if err.Error() == "pg: no rows in result set" { | 266 | if err.Error() == "pg: no rows in result set" { |
| 267 | - return nil, fmt.Errorf("没有此资源") | 267 | + return nil, fmt.Errorf("分红预算单不存在") |
| 268 | } else { | 268 | } else { |
| 269 | return nil, err | 269 | return nil, err |
| 270 | } | 270 | } |
| @@ -149,7 +149,7 @@ func (repository *DividendsIncentivesRuleRepository) FindOne(queryOptions map[st | @@ -149,7 +149,7 @@ func (repository *DividendsIncentivesRuleRepository) FindOne(queryOptions map[st | ||
| 149 | query.SetWhereByQueryOption("dividends_incentives_rule.dividends_incentives_rule_id = ?", "dividendsIncentivesRuleId") | 149 | query.SetWhereByQueryOption("dividends_incentives_rule.dividends_incentives_rule_id = ?", "dividendsIncentivesRuleId") |
| 150 | if err := query.First(); err != nil { | 150 | if err := query.First(); err != nil { |
| 151 | if err.Error() == "pg: no rows in result set" { | 151 | if err.Error() == "pg: no rows in result set" { |
| 152 | - return nil, fmt.Errorf("没有此资源") | 152 | + return nil, fmt.Errorf("分红激励规则不存在") |
| 153 | } else { | 153 | } else { |
| 154 | return nil, err | 154 | return nil, err |
| 155 | } | 155 | } |
| @@ -295,6 +295,80 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend | @@ -295,6 +295,80 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend | ||
| 295 | return dividendsOrder, nil | 295 | return dividendsOrder, nil |
| 296 | } | 296 | } |
| 297 | 297 | ||
| 298 | +func (repository *DividendsOrderRepository) SaveMany(dividendsOrders []*domain.DividendsOrder) ([]*domain.DividendsOrder, error) { | ||
| 299 | + tx := repository.transactionContext.PgTx | ||
| 300 | + var dividendsOrderModels []*models.DividendsOrder | ||
| 301 | + var orderGoodsModel []*models.OrderGood | ||
| 302 | + for _, dividendsOrder := range dividendsOrders { | ||
| 303 | + dividendsOrderModels = append(dividendsOrderModels, &models.DividendsOrder{ | ||
| 304 | + DividendsOrderNumber: dividendsOrder.DividendsOrderNumber, | ||
| 305 | + DividendsOriginalOrderNum: dividendsOrder.DividendsOriginalOrderNum, | ||
| 306 | + DividendsOrderAmount: dividendsOrder.DividendsOrderAmount, | ||
| 307 | + OrderTime: dividendsOrder.OrderTime, | ||
| 308 | + DividendTime: dividendsOrder.DividendTime, | ||
| 309 | + DividendStatus: dividendsOrder.DividendStatus, | ||
| 310 | + Region: dividendsOrder.Region, | ||
| 311 | + CustomerName: dividendsOrder.CustomerName, | ||
| 312 | + Org: dividendsOrder.Org, | ||
| 313 | + Company: dividendsOrder.Company, | ||
| 314 | + CreatedAt: time.Now(), | ||
| 315 | + DeletedAt: dividendsOrder.DeletedAt, | ||
| 316 | + UpdatedAt: dividendsOrder.UpdatedAt, | ||
| 317 | + OperateTime: time.Now(), | ||
| 318 | + Operator: dividendsOrder.Operator, | ||
| 319 | + Remarks: dividendsOrder.Remarks, | ||
| 320 | + }) | ||
| 321 | + for _, good := range dividendsOrder.Goods { | ||
| 322 | + orderGoodsModel = append(orderGoodsModel, &models.OrderGood{ | ||
| 323 | + OrderGoodAmount: good.OrderGoodAmount, | ||
| 324 | + OrderGoodName: good.OrderGoodName, | ||
| 325 | + OrderGoodPrice: good.OrderGoodPrice, | ||
| 326 | + OrderGoodQuantity: good.OrderGoodQuantity, | ||
| 327 | + DividendsOrderNumber: dividendsOrder.DividendsOrderNumber, | ||
| 328 | + DividendsReturnedOrderNumber: "", | ||
| 329 | + CooperationContractNumber: good.CooperationContractNumber, | ||
| 330 | + CompanyId: good.CompanyId, | ||
| 331 | + OrgId: good.OrgId, | ||
| 332 | + OrderGoodExpense: good.OrderGoodExpense, | ||
| 333 | + OrderGoodDividendsStatus: good.OrderGoodDividendsStatus, | ||
| 334 | + CreatedAt: time.Now(), | ||
| 335 | + DeletedAt: time.Time{}, | ||
| 336 | + UpdatedAt: time.Time{}, | ||
| 337 | + }) | ||
| 338 | + } | ||
| 339 | + } | ||
| 340 | + if _, err := tx.Model(÷ndsOrderModels).Insert(); err != nil { // 新增分红订单 | ||
| 341 | + return nil, err | ||
| 342 | + } else { // 新增分红订单产品 | ||
| 343 | + if _, err := tx.Model(&orderGoodsModel).Insert(); err != nil { | ||
| 344 | + return nil, err | ||
| 345 | + } | ||
| 346 | + } | ||
| 347 | + var dividendsOrdersSaved []*domain.DividendsOrder | ||
| 348 | + for _, dividendsOrderModel := range dividendsOrderModels { | ||
| 349 | + //获取订单产品 | ||
| 350 | + var orderGoodModels []*models.OrderGood | ||
| 351 | + orderGoodModelQuery := tx.Model(&orderGoodModels) | ||
| 352 | + if err := orderGoodModelQuery. | ||
| 353 | + Where("company_id = ?", dividendsOrderModel.Company.CompanyId). | ||
| 354 | + Where("org_id = ?", dividendsOrderModel.Org.OrgId). | ||
| 355 | + Where("dividends_order_number = ?", dividendsOrderModel.DividendsOrderNumber). | ||
| 356 | + Select(); err != nil { | ||
| 357 | + log.Logger.Error("分红订单关联的产品不存在", map[string]interface{}{ | ||
| 358 | + "dividendsOrderModel": dividendsOrderModel, | ||
| 359 | + }) | ||
| 360 | + return nil, fmt.Errorf("分红订单关联的产品不存在") | ||
| 361 | + } | ||
| 362 | + // 聚合分红订单 | ||
| 363 | + if dividendsOrder, err := transform.TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel, orderGoodModels); err != nil { | ||
| 364 | + return dividendsOrders, err | ||
| 365 | + } else { | ||
| 366 | + dividendsOrders = append(dividendsOrders, dividendsOrder) | ||
| 367 | + } | ||
| 368 | + } | ||
| 369 | + return dividendsOrdersSaved, nil | ||
| 370 | +} | ||
| 371 | + | ||
| 298 | func (repository *DividendsOrderRepository) UpdateMany(dividendsOrders []*domain.DividendsOrder) ([]*domain.DividendsOrder, error) { | 372 | func (repository *DividendsOrderRepository) UpdateMany(dividendsOrders []*domain.DividendsOrder) ([]*domain.DividendsOrder, error) { |
| 299 | tx := repository.transactionContext.PgTx | 373 | tx := repository.transactionContext.PgTx |
| 300 | var dividendsOrderModels []*models.DividendsOrder | 374 | var dividendsOrderModels []*models.DividendsOrder |
| @@ -379,7 +453,7 @@ func (repository *DividendsOrderRepository) FindOne(queryOptions map[string]inte | @@ -379,7 +453,7 @@ func (repository *DividendsOrderRepository) FindOne(queryOptions map[string]inte | ||
| 379 | } | 453 | } |
| 380 | if err := query.First(); err != nil { | 454 | if err := query.First(); err != nil { |
| 381 | if err.Error() == "pg: no rows in result set" { | 455 | if err.Error() == "pg: no rows in result set" { |
| 382 | - return nil, fmt.Errorf("没有此资源") | 456 | + return nil, fmt.Errorf("分红订单不存在") |
| 383 | } else { | 457 | } else { |
| 384 | return nil, err | 458 | return nil, err |
| 385 | } | 459 | } |
| @@ -394,7 +468,7 @@ func (repository *DividendsOrderRepository) FindOne(queryOptions map[string]inte | @@ -394,7 +468,7 @@ func (repository *DividendsOrderRepository) FindOne(queryOptions map[string]inte | ||
| 394 | Where("company_id = ?", dividendsOrderModel.Company.CompanyId). | 468 | Where("company_id = ?", dividendsOrderModel.Company.CompanyId). |
| 395 | Where("org_id = ?", dividendsOrderModel.Org.OrgId). | 469 | Where("org_id = ?", dividendsOrderModel.Org.OrgId). |
| 396 | Where("dividends_order_number = ?", dividendsOrderModel.DividendsOrderNumber).Select(); err != nil { | 470 | Where("dividends_order_number = ?", dividendsOrderModel.DividendsOrderNumber).Select(); err != nil { |
| 397 | - return nil, err | 471 | + return nil, fmt.Errorf("分红订单关联的产品不存在") |
| 398 | } | 472 | } |
| 399 | // 聚合分红订单 | 473 | // 聚合分红订单 |
| 400 | return transform.TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel, orderGoodModels) | 474 | return transform.TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel, orderGoodModels) |
| @@ -446,7 +520,10 @@ func (repository *DividendsOrderRepository) Find(queryOptions map[string]interfa | @@ -446,7 +520,10 @@ func (repository *DividendsOrderRepository) Find(queryOptions map[string]interfa | ||
| 446 | Where("org_id = ?", dividendsOrderModel.Org.OrgId). | 520 | Where("org_id = ?", dividendsOrderModel.Org.OrgId). |
| 447 | Where("dividends_order_number = ?", dividendsOrderModel.DividendsOrderNumber). | 521 | Where("dividends_order_number = ?", dividendsOrderModel.DividendsOrderNumber). |
| 448 | Select(); err != nil { | 522 | Select(); err != nil { |
| 449 | - return 0, nil, err | 523 | + log.Logger.Error("分红订单关联的产品不存在", map[string]interface{}{ |
| 524 | + "dividendsOrderModel": dividendsOrderModel, | ||
| 525 | + }) | ||
| 526 | + return 0, nil, fmt.Errorf("分红订单关联的产品不存在") | ||
| 450 | } | 527 | } |
| 451 | // 聚合分红订单 | 528 | // 聚合分红订单 |
| 452 | if dividendsOrder, err := transform.TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel, orderGoodModels); err != nil { | 529 | if dividendsOrder, err := transform.TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel, orderGoodModels); err != nil { |
| @@ -382,7 +382,7 @@ func (repository *DividendsReturnedOrderRepository) FindOne(queryOptions map[str | @@ -382,7 +382,7 @@ func (repository *DividendsReturnedOrderRepository) FindOne(queryOptions map[str | ||
| 382 | query.SetWhereByQueryOption("dividends_returned_order.dividends_returned_order_number = ?", "dividendsReturnedOrderNumber") | 382 | query.SetWhereByQueryOption("dividends_returned_order.dividends_returned_order_number = ?", "dividendsReturnedOrderNumber") |
| 383 | if err := query.First(); err != nil { | 383 | if err := query.First(); err != nil { |
| 384 | if err.Error() == "pg: no rows in result set" { | 384 | if err.Error() == "pg: no rows in result set" { |
| 385 | - return nil, fmt.Errorf("没有此资源") | 385 | + return nil, fmt.Errorf("分红退货单不存在") |
| 386 | } else { | 386 | } else { |
| 387 | return nil, err | 387 | return nil, err |
| 388 | } | 388 | } |
| @@ -397,7 +397,7 @@ func (repository *DividendsReturnedOrderRepository) FindOne(queryOptions map[str | @@ -397,7 +397,7 @@ func (repository *DividendsReturnedOrderRepository) FindOne(queryOptions map[str | ||
| 397 | Where("company_id = ?", dividendsReturnedOrderModel.Company.CompanyId). | 397 | Where("company_id = ?", dividendsReturnedOrderModel.Company.CompanyId). |
| 398 | Where("org_id = ?", dividendsReturnedOrderModel.Org.OrgId). | 398 | Where("org_id = ?", dividendsReturnedOrderModel.Org.OrgId). |
| 399 | Where("dividends_returned_order_number = ?", dividendsReturnedOrderModel.DividendsReturnedOrderNumber).Select(); err != nil { | 399 | Where("dividends_returned_order_number = ?", dividendsReturnedOrderModel.DividendsReturnedOrderNumber).Select(); err != nil { |
| 400 | - return nil, err | 400 | + return nil, fmt.Errorf("分红退货单关联的产品不存在") |
| 401 | } | 401 | } |
| 402 | // 聚合分红退货单 | 402 | // 聚合分红退货单 |
| 403 | return transform.TransformToDividendsReturnedOrderDomainModelFromPgModels(dividendsReturnedOrderModel, orderGoodModels) | 403 | return transform.TransformToDividendsReturnedOrderDomainModelFromPgModels(dividendsReturnedOrderModel, orderGoodModels) |
| @@ -449,7 +449,10 @@ func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string | @@ -449,7 +449,10 @@ func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string | ||
| 449 | Where("org_id = ?", dividendsReturnedOrderModel.Org.OrgId). | 449 | Where("org_id = ?", dividendsReturnedOrderModel.Org.OrgId). |
| 450 | Where("dividends_returned_order_number = ?", dividendsReturnedOrderModel.DividendsReturnedOrderNumber). | 450 | Where("dividends_returned_order_number = ?", dividendsReturnedOrderModel.DividendsReturnedOrderNumber). |
| 451 | Select(); err != nil { | 451 | Select(); err != nil { |
| 452 | - return 0, nil, err | 452 | + log.Logger.Error("分红退货单关联的产品不存在", map[string]interface{}{ |
| 453 | + "dividendsReturnedOrderModel": dividendsReturnedOrderModel, | ||
| 454 | + }) | ||
| 455 | + return 0, nil, fmt.Errorf("分红退货单关联的产品不存在") | ||
| 453 | } | 456 | } |
| 454 | if dividendsReturnedOrder, err := transform.TransformToDividendsReturnedOrderDomainModelFromPgModels(dividendsReturnedOrderModel, orderGoodModels); err != nil { | 457 | if dividendsReturnedOrder, err := transform.TransformToDividendsReturnedOrderDomainModelFromPgModels(dividendsReturnedOrderModel, orderGoodModels); err != nil { |
| 455 | return 0, dividendsReturnedOrders, err | 458 | return 0, dividendsReturnedOrders, err |
| @@ -149,7 +149,7 @@ func (repository *MoneyIncentivesRuleRepository) FindOne(queryOptions map[string | @@ -149,7 +149,7 @@ func (repository *MoneyIncentivesRuleRepository) FindOne(queryOptions map[string | ||
| 149 | query.SetWhereByQueryOption("money_incentives_rule.money_incentives_rule_id = ?", "moneyIncentivesRuleId") | 149 | query.SetWhereByQueryOption("money_incentives_rule.money_incentives_rule_id = ?", "moneyIncentivesRuleId") |
| 150 | if err := query.First(); err != nil { | 150 | if err := query.First(); err != nil { |
| 151 | if err.Error() == "pg: no rows in result set" { | 151 | if err.Error() == "pg: no rows in result set" { |
| 152 | - return nil, fmt.Errorf("没有此资源") | 152 | + return nil, fmt.Errorf("金额激励规则不存在") |
| 153 | } else { | 153 | } else { |
| 154 | return nil, err | 154 | return nil, err |
| 155 | } | 155 | } |
| @@ -150,7 +150,7 @@ func (repository *OrderGoodRepository) FindOne(queryOptions map[string]interface | @@ -150,7 +150,7 @@ func (repository *OrderGoodRepository) FindOne(queryOptions map[string]interface | ||
| 150 | query.SetWhereByQueryOption("order_good.order_good_id = ?", "orderGoodId") | 150 | query.SetWhereByQueryOption("order_good.order_good_id = ?", "orderGoodId") |
| 151 | if err := query.First(); err != nil { | 151 | if err := query.First(); err != nil { |
| 152 | if err.Error() == "pg: no rows in result set" { | 152 | if err.Error() == "pg: no rows in result set" { |
| 153 | - return nil, fmt.Errorf("没有此资源") | 153 | + return nil, fmt.Errorf("订单产品不存在") |
| 154 | } else { | 154 | } else { |
| 155 | return nil, err | 155 | return nil, err |
| 156 | } | 156 | } |
-
请 注册 或 登录 后发表评论