作者 陈志颖

feat:仓储层报错优化

... ... @@ -1303,7 +1303,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
UserPhone: "",
}
}
undertakersOriginal = undertakersOriginal + strconv.FormatInt(int64(i), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")"
undertakersOriginal = undertakersOriginal + strconv.FormatInt(int64(i+1), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")"
}
undertakerChangeTmp1 := "【" + undertakersOriginal + "】"
... ... @@ -1340,7 +1340,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
UserPhone: "",
}
}
undertakersChanged = undertakersChanged + strconv.FormatInt(int64(i), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")"
undertakersChanged = undertakersChanged + strconv.FormatInt(int64(i+1), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")"
}
undertakerChangeTemp2 := "【" + undertakersChanged + "】"
// 拼接承接人变更记录
... ...
... ... @@ -134,7 +134,7 @@ func (repository *ContractUndertakerFeedbackRepository) FindOne(queryOptions map
query.SetWhereByQueryOption("contract_undertaker_feedback.feedback_id = ?", "contractUndertakerFeedbackId")
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
return nil, fmt.Errorf("没有此资源")
return nil, fmt.Errorf("承接人反馈信息不存在")
} else {
return nil, err
}
... ...
... ... @@ -4,6 +4,7 @@ import (
"fmt"
"github.com/go-pg/pg/v10"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
"time"
"github.com/linmadan/egglib-go/persistent/pg/sqlbuilder"
... ... @@ -189,7 +190,7 @@ func (repository *CooperationApplicationRepository) FindOne(queryOptions map[str
query.SetWhereByQueryOption("cooperation_application.cooperation_application_id = ?", "cooperationApplicationId")
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
return nil, fmt.Errorf("没有此资源")
return nil, fmt.Errorf("共创申请不存在")
} else {
return nil, err
}
... ... @@ -200,14 +201,26 @@ func (repository *CooperationApplicationRepository) FindOne(queryOptions map[str
// 获取共创项目
cooperationProjectModel := new(models.CooperationProject)
cooperationProjectQuery := tx.Model(cooperationProjectModel)
if err := cooperationProjectQuery.Where("cooperation_project_number = ?", cooperationApplicationModel.CooperationProjectNumber).First(); err != nil {
return nil, err
if err := cooperationProjectQuery.
Where("company->>'companyId' = '?'", cooperationApplicationModel.Company.CompanyId).
Where("org->>'orgId' = '?'", cooperationApplicationModel.Org.OrgId).
Where("cooperation_project_number = ?", cooperationApplicationModel.CooperationProjectNumber).First(); err != nil {
log.Logger.Error("申请关联的共创项目不存在", map[string]interface{}{
"cooperationApplicationModel": cooperationApplicationModel,
})
return nil, fmt.Errorf("申请关联的共创项目不存在")
}
// 获取共创模式
cooperationModeModel := new(models.CooperationMode)
cooperationModeQuery := tx.Model(cooperationModeModel)
if err := cooperationModeQuery.Where("cooperation_mode_number = ?", cooperationProjectModel.CooperationModeNumber).First(); err != nil {
return nil, err
if err := cooperationModeQuery.
Where("company->>'companyId' = '?'", cooperationApplicationModel.Company.CompanyId).
Where("org->>'orgId' = '?'", cooperationApplicationModel.Org.OrgId).
Where("cooperation_mode_number = ?", cooperationProjectModel.CooperationModeNumber).First(); err != nil {
log.Logger.Error("申请关联的共创模式不存在", map[string]interface{}{
"cooperationApplicationModel": cooperationApplicationModel,
})
return nil, fmt.Errorf("申请关联的共创模式不存在")
}
return transform.TransformToCooperationApplicationDomainModelFromPgModels(cooperationApplicationModel, cooperationProjectModel, cooperationModeModel)
}
... ... @@ -270,7 +283,10 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string
Where("org->>'orgId' = '?'", cooperationApplicationModel.Org.OrgId).
Where("cooperation_project_number = ?", cooperationApplicationModel.CooperationProjectNumber).
First(); err != nil {
return 0, nil, err
log.Logger.Error("申请关联的共创项目不存在", map[string]interface{}{
"cooperationApplicationModel": cooperationApplicationModel,
})
return 0, nil, fmt.Errorf("申请关联的共创项目不存在")
}
// 获取共创模式
cooperationModeModel := new(models.CooperationMode)
... ... @@ -280,7 +296,10 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string
Where("org->>'orgId' = '?'", cooperationApplicationModel.Org.OrgId).
Where("cooperation_mode_number = ?", cooperationProjectModel.CooperationModeNumber).
First(); err != nil {
return 0, nil, err
log.Logger.Error("申请关联的共创模式不存在", map[string]interface{}{
"cooperationApplicationModel": cooperationApplicationModel,
})
return 0, nil, fmt.Errorf("申请关联的共创模式不存在")
}
if cooperationApplication, err := transform.TransformToCooperationApplicationDomainModelFromPgModels(cooperationApplicationModel, cooperationProjectModel, cooperationModeModel); err != nil {
return 0, cooperationApplications, err
... ...
... ... @@ -139,7 +139,7 @@ func (repository *CooperationContractChangeLogRepository) FindOne(queryOptions m
query.SetWhereByQueryOption("cooperation_contract_change_log.cooperation_contract_change_log_id = ?", "cooperationContractChangeLogId")
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
return nil, fmt.Errorf("没有此资源")
return nil, fmt.Errorf("共创合约变更记录不存在")
} else {
return nil, err
}
... ...
... ... @@ -154,7 +154,7 @@ func (repository *CooperationContractRelevantRepository) FindOne(queryOptions ma
query.SetWhereByQueryOption("cooperation_contract_relevant.cooperation_contract_relevant_id = ?", "cooperationContractRelevantId")
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
return nil, fmt.Errorf("没有此资源")
return nil, fmt.Errorf("合约相关人不存在")
} else {
return nil, err
}
... ...
... ... @@ -1032,7 +1032,7 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in
Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId).
Where("cooperation_mode_number = ?", cooperationContractModel.CooperationModeNumber).
First(); err != nil {
return 0, nil, err
return 0, nil, fmt.Errorf("合约关联的共创模式不存在")
}
// 获取分红激励规则列表
var dividendsIncentivesRuleModels []*models.DividendsIncentivesRule
... ... @@ -1042,7 +1042,7 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in
Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId).
Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).
Select(); err != nil {
return 0, nil, err
return 0, nil, fmt.Errorf("合约关联的分红激励规则列表不存在")
}
// 获取金额激励规则列表
var moneyIncentivesRuleModels []*models.MoneyIncentivesRule
... ... @@ -1052,7 +1052,7 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in
Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId).
Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).
Select(); err != nil {
return 0, nil, err
return 0, nil, fmt.Errorf("合约关联的金额激励规则列表不存在")
}
// 获取承接人列表
var cooperationContractUndertakerModels []*models.CooperationContractUndertaker
... ... @@ -1062,7 +1062,7 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in
Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId).
Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).
Select(); err != nil {
return 0, nil, err
return 0, nil, fmt.Errorf("合约相关的承接人列表不存在")
}
// 获取相关人列表
var cooperationContractRelevantModels []*models.CooperationContractRelevant
... ... @@ -1072,7 +1072,7 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in
Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId).
Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).
Select(); err != nil {
return 0, nil, err
return 0, nil, fmt.Errorf("合约相关的相关人列表不存在")
}
if cooperationContract, err := transform.TransformToCooperationContractDomainModelFromPgModels(
cooperationContractModel,
... ...
... ... @@ -169,7 +169,7 @@ func (repository *CooperationContractUndertakerRepository) FindOne(queryOptions
query.SetWhereByQueryOption("cooperation_contract_undertaker.cooperation_contract_undertaker_id = ?", "cooperationContractUndertakerId")
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
return nil, fmt.Errorf("没有此资源")
return nil, fmt.Errorf("合约承接人不存在")
} else {
return nil, err
}
... ...
... ... @@ -156,7 +156,7 @@ func (repository *CooperationModeRepository) FindOne(queryOptions map[string]int
}
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
return nil, fmt.Errorf("没有此资源")
return nil, fmt.Errorf("共创模式不存在")
} else {
return nil, err
}
... ...
... ... @@ -4,6 +4,7 @@ import (
"fmt"
"github.com/go-pg/pg/v10"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
"time"
"github.com/linmadan/egglib-go/persistent/pg/sqlbuilder"
... ... @@ -218,7 +219,7 @@ func (repository *CooperationProjectRepository) FindOne(queryOptions map[string]
}
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
return nil, fmt.Errorf("没有此资源")
return nil, fmt.Errorf("共创项目不存在")
} else {
return nil, err
}
... ... @@ -230,7 +231,10 @@ func (repository *CooperationProjectRepository) FindOne(queryOptions map[string]
cooperationModeModel := new(models.CooperationMode)
cooperationModeQuery := tx.Model(cooperationModeModel)
if err := cooperationModeQuery.Where("cooperation_mode_number = ?", cooperationProjectModel.CooperationModeNumber).First(); err != nil {
return nil, err
log.Logger.Error("共创项目关联的共创模式不存在", map[string]interface{}{
"cooperationProjectModel": cooperationProjectModel,
})
return nil, fmt.Errorf("共创项目关联的共创模式不存在")
}
return transform.TransformToCooperationProjectDomainModelFromPgModels(cooperationProjectModel, cooperationModeModel)
}
... ... @@ -287,7 +291,10 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int
Where("org->>'orgId' = '?'", cooperationProjectModel.Org.OrgId).
Where("cooperation_mode_number = ?", cooperationProjectModel.CooperationModeNumber).
First(); err != nil {
return 0, nil, err
log.Logger.Error("共创项目关联的共创模式不存在", map[string]interface{}{
"cooperationProjectModel": cooperationProjectModel,
})
return 0, nil, fmt.Errorf("共创项目关联的共创模式不存在")
}
if cooperationProject, err := transform.TransformToCooperationProjectDomainModelFromPgModels(cooperationProjectModel, cooperationModeModel); err != nil {
return 0, cooperationProjects, err
... ...
... ... @@ -184,7 +184,7 @@ func (repository *CreditAccountRepository) FindOne(queryOptions map[string]inter
query.SetWhereByQueryOption("credit_account.credit_account_id = ?", "creditAccountId")
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
return nil, fmt.Errorf("没有此资源")
return nil, fmt.Errorf("账期结算单不存在")
} else {
return nil, err
}
... ...
... ... @@ -264,7 +264,7 @@ func (repository *DividendsEstimateRepository) FindOne(queryOptions map[string]i
}
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
return nil, fmt.Errorf("没有此资源")
return nil, fmt.Errorf("分红预算单不存在")
} else {
return nil, err
}
... ...
... ... @@ -149,7 +149,7 @@ func (repository *DividendsIncentivesRuleRepository) FindOne(queryOptions map[st
query.SetWhereByQueryOption("dividends_incentives_rule.dividends_incentives_rule_id = ?", "dividendsIncentivesRuleId")
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
return nil, fmt.Errorf("没有此资源")
return nil, fmt.Errorf("分红激励规则不存在")
} else {
return nil, err
}
... ...
... ... @@ -379,7 +379,7 @@ func (repository *DividendsOrderRepository) FindOne(queryOptions map[string]inte
}
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
return nil, fmt.Errorf("没有此资源")
return nil, fmt.Errorf("分红订单不存在")
} else {
return nil, err
}
... ... @@ -394,7 +394,7 @@ func (repository *DividendsOrderRepository) FindOne(queryOptions map[string]inte
Where("company_id = ?", dividendsOrderModel.Company.CompanyId).
Where("org_id = ?", dividendsOrderModel.Org.OrgId).
Where("dividends_order_number = ?", dividendsOrderModel.DividendsOrderNumber).Select(); err != nil {
return nil, err
return nil, fmt.Errorf("分红订单关联的产品不存在")
}
// 聚合分红订单
return transform.TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel, orderGoodModels)
... ... @@ -446,7 +446,10 @@ func (repository *DividendsOrderRepository) Find(queryOptions map[string]interfa
Where("org_id = ?", dividendsOrderModel.Org.OrgId).
Where("dividends_order_number = ?", dividendsOrderModel.DividendsOrderNumber).
Select(); err != nil {
return 0, nil, err
log.Logger.Error("分红订单关联的产品不存在", map[string]interface{}{
"dividendsOrderModel": dividendsOrderModel,
})
return 0, nil, fmt.Errorf("分红订单关联的产品不存在")
}
// 聚合分红订单
if dividendsOrder, err := transform.TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel, orderGoodModels); err != nil {
... ...
... ... @@ -382,7 +382,7 @@ func (repository *DividendsReturnedOrderRepository) FindOne(queryOptions map[str
query.SetWhereByQueryOption("dividends_returned_order.dividends_returned_order_number = ?", "dividendsReturnedOrderNumber")
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
return nil, fmt.Errorf("没有此资源")
return nil, fmt.Errorf("分红退货单不存在")
} else {
return nil, err
}
... ... @@ -397,7 +397,7 @@ func (repository *DividendsReturnedOrderRepository) FindOne(queryOptions map[str
Where("company_id = ?", dividendsReturnedOrderModel.Company.CompanyId).
Where("org_id = ?", dividendsReturnedOrderModel.Org.OrgId).
Where("dividends_returned_order_number = ?", dividendsReturnedOrderModel.DividendsReturnedOrderNumber).Select(); err != nil {
return nil, err
return nil, fmt.Errorf("分红退货单关联的产品不存在")
}
// 聚合分红退货单
return transform.TransformToDividendsReturnedOrderDomainModelFromPgModels(dividendsReturnedOrderModel, orderGoodModels)
... ... @@ -449,7 +449,10 @@ func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string
Where("org_id = ?", dividendsReturnedOrderModel.Org.OrgId).
Where("dividends_returned_order_number = ?", dividendsReturnedOrderModel.DividendsReturnedOrderNumber).
Select(); err != nil {
return 0, nil, err
log.Logger.Error("分红退货单关联的产品不存在", map[string]interface{}{
"dividendsReturnedOrderModel": dividendsReturnedOrderModel,
})
return 0, nil, fmt.Errorf("分红退货单关联的产品不存在")
}
if dividendsReturnedOrder, err := transform.TransformToDividendsReturnedOrderDomainModelFromPgModels(dividendsReturnedOrderModel, orderGoodModels); err != nil {
return 0, dividendsReturnedOrders, err
... ...
... ... @@ -149,7 +149,7 @@ func (repository *MoneyIncentivesRuleRepository) FindOne(queryOptions map[string
query.SetWhereByQueryOption("money_incentives_rule.money_incentives_rule_id = ?", "moneyIncentivesRuleId")
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
return nil, fmt.Errorf("没有此资源")
return nil, fmt.Errorf("金额激励规则不存在")
} else {
return nil, err
}
... ...
... ... @@ -150,7 +150,7 @@ func (repository *OrderGoodRepository) FindOne(queryOptions map[string]interface
query.SetWhereByQueryOption("order_good.order_good_id = ?", "orderGoodId")
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
return nil, fmt.Errorf("没有此资源")
return nil, fmt.Errorf("订单产品不存在")
} else {
return nil, err
}
... ...