Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creat…
…ion-cooperation into dev
正在显示
13 个修改的文件
包含
104 行增加
和
65 行删除
| @@ -4,6 +4,7 @@ go 1.16 | @@ -4,6 +4,7 @@ go 1.16 | ||
| 4 | 4 | ||
| 5 | require ( | 5 | require ( |
| 6 | github.com/Shopify/sarama v1.25.0 | 6 | github.com/Shopify/sarama v1.25.0 |
| 7 | + github.com/Tnze/go.num/v2 v2.0.0-20191006170829-cb483d4c9152 // indirect | ||
| 7 | github.com/ajg/form v1.5.1 // indirect | 8 | github.com/ajg/form v1.5.1 // indirect |
| 8 | github.com/beego/beego/v2 v2.0.1 | 9 | github.com/beego/beego/v2 v2.0.1 |
| 9 | github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect | 10 | github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect |
| @@ -5,6 +5,8 @@ github.com/Shopify/sarama v1.25.0 h1:ch1ywjRLjfJtU+EaiJ+l0rWffQ6TRpyYmW4DX7Cb2SU | @@ -5,6 +5,8 @@ github.com/Shopify/sarama v1.25.0 h1:ch1ywjRLjfJtU+EaiJ+l0rWffQ6TRpyYmW4DX7Cb2SU | ||
| 5 | github.com/Shopify/sarama v1.25.0/go.mod h1:y/CFFTO9eaMTNriwu/Q+W4eioLqiDMGkA1W+gmdfj8w= | 5 | github.com/Shopify/sarama v1.25.0/go.mod h1:y/CFFTO9eaMTNriwu/Q+W4eioLqiDMGkA1W+gmdfj8w= |
| 6 | github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc= | 6 | github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc= |
| 7 | github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= | 7 | github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= |
| 8 | +github.com/Tnze/go.num/v2 v2.0.0-20191006170829-cb483d4c9152 h1:6Ny2zcG2k/0aOE8rLbDdLdPMr0o7lqMfdnYJe6pZj9w= | ||
| 9 | +github.com/Tnze/go.num/v2 v2.0.0-20191006170829-cb483d4c9152/go.mod h1:fNGLFjpxgDvBqQPv1HYSuGi6pRuI8wdKvvspYvUQufc= | ||
| 8 | github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU= | 10 | github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU= |
| 9 | github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= | 11 | github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= |
| 10 | github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= | 12 | github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= |
| @@ -507,7 +507,7 @@ func (cooperationContractService *CooperationContractService) OperateCooperation | @@ -507,7 +507,7 @@ func (cooperationContractService *CooperationContractService) OperateCooperation | ||
| 507 | }); err != nil { | 507 | }); err != nil { |
| 508 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | 508 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) |
| 509 | } | 509 | } |
| 510 | - if cooperationContract, err := cooperationContractRepository.Save(cooperationContract); err != nil { | 510 | + if cooperationContract, err := cooperationContractRepository.UpdateOne(cooperationContract); err != nil { |
| 511 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 511 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 512 | } else { | 512 | } else { |
| 513 | if err := transactionContext.CommitTransaction(); err != nil { | 513 | if err := transactionContext.CommitTransaction(); err != nil { |
| @@ -8,6 +8,6 @@ type Attachment struct { | @@ -8,6 +8,6 @@ type Attachment struct { | ||
| 8 | Name string `json:"name"` | 8 | Name string `json:"name"` |
| 9 | // 附件地址 | 9 | // 附件地址 |
| 10 | Url string `json:"url"` | 10 | Url string `json:"url"` |
| 11 | - // 附件文件大小 | ||
| 12 | - FileSize int64 `json:"fileSize,string"` | 11 | + // 附件文件大小,保存KB单位 |
| 12 | + FileSize int64 `json:"fileSize"` | ||
| 13 | } | 13 | } |
| @@ -50,7 +50,8 @@ type CooperationContract struct { | @@ -50,7 +50,8 @@ type CooperationContract struct { | ||
| 50 | 50 | ||
| 51 | type CooperationContractRepository interface { | 51 | type CooperationContractRepository interface { |
| 52 | Save(cooperationContract *CooperationContract) (*CooperationContract, error) | 52 | Save(cooperationContract *CooperationContract) (*CooperationContract, error) |
| 53 | - UpdateMany(cooperationContract []*CooperationContract) ([]*CooperationContract, error) | 53 | + UpdateOne(cooperationContract *CooperationContract) (*CooperationContract, error) |
| 54 | + UpdateMany(cooperationContracts []*CooperationContract) ([]*CooperationContract, error) | ||
| 54 | Remove(cooperationContract *CooperationContract) (*CooperationContract, error) | 55 | Remove(cooperationContract *CooperationContract) (*CooperationContract, error) |
| 55 | BatchRemove(cooperationContracts []*CooperationContract) ([]*CooperationContract, error) | 56 | BatchRemove(cooperationContracts []*CooperationContract) ([]*CooperationContract, error) |
| 56 | FindOne(queryOptions map[string]interface{}) (*CooperationContract, error) | 57 | FindOne(queryOptions map[string]interface{}) (*CooperationContract, error) |
| 1 | package domain | 1 | package domain |
| 2 | 2 | ||
| 3 | -import "time" | 3 | +import ( |
| 4 | + "time" | ||
| 5 | +) | ||
| 4 | 6 | ||
| 5 | // DividendsIncentivesRule 金额激励规则实体 | 7 | // DividendsIncentivesRule 金额激励规则实体 |
| 6 | type DividendsIncentivesRule struct { | 8 | type DividendsIncentivesRule struct { |
| @@ -15,7 +17,9 @@ type DividendsIncentivesRule struct { | @@ -15,7 +17,9 @@ type DividendsIncentivesRule struct { | ||
| 15 | // 分红规则激励百分点 | 17 | // 分红规则激励百分点 |
| 16 | DividendsIncentivesPercentage float64 `json:"dividendsIncentivesPercentage"` | 18 | DividendsIncentivesPercentage float64 `json:"dividendsIncentivesPercentage"` |
| 17 | // 分红规则激励阶段,阶段返回时需要转换为中文数字 | 19 | // 分红规则激励阶段,阶段返回时需要转换为中文数字 |
| 18 | - DividendsIncentivesStage int64 `json:"dividendsIncentivesStage,string"` | 20 | + DividendsIncentivesStage int64 `json:"dividendsIncentivesStage"` |
| 21 | + // 分红激励规则阶段中文表示 | ||
| 22 | + DividendsIncentivesStageCN string `json:"dividendsIncentivesStageCN"` | ||
| 19 | // 分红规则激励阶段结束 | 23 | // 分红规则激励阶段结束 |
| 20 | DividendsIncentivesStageEnd time.Time `json:"dividendsIncentivesStageEnd"` | 24 | DividendsIncentivesStageEnd time.Time `json:"dividendsIncentivesStageEnd"` |
| 21 | // 分红规则激励阶段开始 | 25 | // 分红规则激励阶段开始 |
| @@ -73,20 +77,5 @@ func (dividendsIncentivesRule *DividendsIncentivesRule) Update(data map[string]i | @@ -73,20 +77,5 @@ func (dividendsIncentivesRule *DividendsIncentivesRule) Update(data map[string]i | ||
| 73 | if dividendsIncentivesStageStart, ok := data["dividendsIncentivesStageStart"]; ok { | 77 | if dividendsIncentivesStageStart, ok := data["dividendsIncentivesStageStart"]; ok { |
| 74 | dividendsIncentivesRule.DividendsIncentivesStageStart = dividendsIncentivesStageStart.(time.Time) | 78 | dividendsIncentivesRule.DividendsIncentivesStageStart = dividendsIncentivesStageStart.(time.Time) |
| 75 | } | 79 | } |
| 76 | - if orgId, ok := data["orgId"]; ok { | ||
| 77 | - dividendsIncentivesRule.Org.OrgId = orgId.(int64) | ||
| 78 | - } | ||
| 79 | - if orgName, ok := data["orgName"]; ok { | ||
| 80 | - dividendsIncentivesRule.Org.OrgName = orgName.(string) | ||
| 81 | - } | ||
| 82 | - if companyId, ok := data["companyId"]; ok { | ||
| 83 | - dividendsIncentivesRule.Org.Company.CompanyId = companyId.(int64) | ||
| 84 | - } | ||
| 85 | - if companyLogo, ok := data["companyLogo"]; ok { | ||
| 86 | - dividendsIncentivesRule.Org.Company.CompanyLogo = companyLogo.(string) | ||
| 87 | - } | ||
| 88 | - if companyName, ok := data["companyName"]; ok { | ||
| 89 | - dividendsIncentivesRule.Org.Company.CompanyName = companyName.(string) | ||
| 90 | - } | ||
| 91 | return nil | 80 | return nil |
| 92 | } | 81 | } |
| 1 | package domain | 1 | package domain |
| 2 | 2 | ||
| 3 | -import "time" | 3 | +import ( |
| 4 | + "time" | ||
| 5 | +) | ||
| 4 | 6 | ||
| 5 | // MoneyIncentivesRule 金额激励规则实体 | 7 | // MoneyIncentivesRule 金额激励规则实体 |
| 6 | type MoneyIncentivesRule struct { | 8 | type MoneyIncentivesRule struct { |
| @@ -11,7 +13,9 @@ type MoneyIncentivesRule struct { | @@ -11,7 +13,9 @@ type MoneyIncentivesRule struct { | ||
| 11 | // 激励金额 | 13 | // 激励金额 |
| 12 | MoneyIncentivesAmount float64 `json:"moneyIncentivesAmount"` | 14 | MoneyIncentivesAmount float64 `json:"moneyIncentivesAmount"` |
| 13 | // 金额激励阶段,阶段返回时需要转换为中文数字 | 15 | // 金额激励阶段,阶段返回时需要转换为中文数字 |
| 14 | - MoneyIncentivesStage int64 `json:"moneyIncentivesStage,string"` | 16 | + MoneyIncentivesStage int64 `json:"moneyIncentivesStage"` |
| 17 | + // 金额激励规则阶段中文表示 | ||
| 18 | + MoneyIncentivesStageCN string `json:"moneyIncentivesStageCN"` | ||
| 15 | // 金额激励阶段有效期结束 | 19 | // 金额激励阶段有效期结束 |
| 16 | MoneyIncentivesStageEnd time.Time `json:"moneyIncentivesStageEnd"` | 20 | MoneyIncentivesStageEnd time.Time `json:"moneyIncentivesStageEnd"` |
| 17 | // 金额激励阶段有效期开始 | 21 | // 金额激励阶段有效期开始 |
| @@ -78,20 +82,5 @@ func (moneyIncentivesRule *MoneyIncentivesRule) Update(data map[string]interface | @@ -78,20 +82,5 @@ func (moneyIncentivesRule *MoneyIncentivesRule) Update(data map[string]interface | ||
| 78 | if salesmanPercentage, ok := data["salesmanPercentage"]; ok { | 82 | if salesmanPercentage, ok := data["salesmanPercentage"]; ok { |
| 79 | moneyIncentivesRule.SalesmanPercentage = salesmanPercentage.(float64) | 83 | moneyIncentivesRule.SalesmanPercentage = salesmanPercentage.(float64) |
| 80 | } | 84 | } |
| 81 | - if orgId, ok := data["orgId"]; ok { | ||
| 82 | - moneyIncentivesRule.Org.OrgId = orgId.(int64) | ||
| 83 | - } | ||
| 84 | - if orgName, ok := data["orgName"]; ok { | ||
| 85 | - moneyIncentivesRule.Org.OrgName = orgName.(string) | ||
| 86 | - } | ||
| 87 | - if companyId, ok := data["companyId"]; ok { | ||
| 88 | - moneyIncentivesRule.Org.Company.CompanyId = companyId.(int64) | ||
| 89 | - } | ||
| 90 | - if companyLogo, ok := data["companyLogo"]; ok { | ||
| 91 | - moneyIncentivesRule.Org.Company.CompanyLogo = companyLogo.(string) | ||
| 92 | - } | ||
| 93 | - if companyName, ok := data["companyName"]; ok { | ||
| 94 | - moneyIncentivesRule.Org.Company.CompanyName = companyName.(string) | ||
| 95 | - } | ||
| 96 | return nil | 85 | return nil |
| 97 | } | 86 | } |
| @@ -3,6 +3,7 @@ package transform | @@ -3,6 +3,7 @@ package transform | ||
| 3 | import ( | 3 | import ( |
| 4 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | 4 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" |
| 5 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" | 5 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" |
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" | ||
| 6 | ) | 7 | ) |
| 7 | 8 | ||
| 8 | func TransformToCooperationContractDomainModelFromPgModels( | 9 | func TransformToCooperationContractDomainModelFromPgModels( |
| @@ -15,6 +16,7 @@ func TransformToCooperationContractDomainModelFromPgModels( | @@ -15,6 +16,7 @@ func TransformToCooperationContractDomainModelFromPgModels( | ||
| 15 | // 分红激励规则 | 16 | // 分红激励规则 |
| 16 | var dividendsIncentivesRulesDomain []*domain.DividendsIncentivesRule | 17 | var dividendsIncentivesRulesDomain []*domain.DividendsIncentivesRule |
| 17 | for _, rule := range dividendsIncentivesRules { | 18 | for _, rule := range dividendsIncentivesRules { |
| 19 | + stageString := utils.NumberToCNNumber(int(rule.DividendsIncentivesStage)) | ||
| 18 | dividendsIncentivesRulesDomain = append(dividendsIncentivesRulesDomain, &domain.DividendsIncentivesRule{ | 20 | dividendsIncentivesRulesDomain = append(dividendsIncentivesRulesDomain, &domain.DividendsIncentivesRule{ |
| 19 | DividendsIncentivesRuleId: rule.DividendsIncentivesRuleId, | 21 | DividendsIncentivesRuleId: rule.DividendsIncentivesRuleId, |
| 20 | CooperationContractNumber: rule.CooperationContractNumber, | 22 | CooperationContractNumber: rule.CooperationContractNumber, |
| @@ -22,6 +24,7 @@ func TransformToCooperationContractDomainModelFromPgModels( | @@ -22,6 +24,7 @@ func TransformToCooperationContractDomainModelFromPgModels( | ||
| 22 | SalesmanPercentage: rule.SalesmanPercentage, | 24 | SalesmanPercentage: rule.SalesmanPercentage, |
| 23 | DividendsIncentivesPercentage: rule.DividendsIncentivesPercentage, | 25 | DividendsIncentivesPercentage: rule.DividendsIncentivesPercentage, |
| 24 | DividendsIncentivesStage: rule.DividendsIncentivesStage, | 26 | DividendsIncentivesStage: rule.DividendsIncentivesStage, |
| 27 | + DividendsIncentivesStageCN: stageString, | ||
| 25 | DividendsIncentivesStageEnd: rule.DividendsIncentivesStageEnd, | 28 | DividendsIncentivesStageEnd: rule.DividendsIncentivesStageEnd, |
| 26 | DividendsIncentivesStageStart: rule.DividendsIncentivesStageStart, | 29 | DividendsIncentivesStageStart: rule.DividendsIncentivesStageStart, |
| 27 | Org: rule.Org, | 30 | Org: rule.Org, |
| @@ -34,11 +37,13 @@ func TransformToCooperationContractDomainModelFromPgModels( | @@ -34,11 +37,13 @@ func TransformToCooperationContractDomainModelFromPgModels( | ||
| 34 | // 金额激励规则 | 37 | // 金额激励规则 |
| 35 | var moneyIncentivesRulesDomain []*domain.MoneyIncentivesRule | 38 | var moneyIncentivesRulesDomain []*domain.MoneyIncentivesRule |
| 36 | for _, rule := range moneyIncentivesRules { | 39 | for _, rule := range moneyIncentivesRules { |
| 40 | + stageString := utils.NumberToCNNumber(int(rule.MoneyIncentivesStage)) | ||
| 37 | moneyIncentivesRulesDomain = append(moneyIncentivesRulesDomain, &domain.MoneyIncentivesRule{ | 41 | moneyIncentivesRulesDomain = append(moneyIncentivesRulesDomain, &domain.MoneyIncentivesRule{ |
| 38 | MoneyIncentivesRuleId: rule.MoneyIncentivesRuleId, | 42 | MoneyIncentivesRuleId: rule.MoneyIncentivesRuleId, |
| 39 | CooperationContractNumber: rule.CooperationContractNumber, | 43 | CooperationContractNumber: rule.CooperationContractNumber, |
| 40 | MoneyIncentivesAmount: rule.MoneyIncentivesAmount, | 44 | MoneyIncentivesAmount: rule.MoneyIncentivesAmount, |
| 41 | MoneyIncentivesStage: rule.MoneyIncentivesStage, | 45 | MoneyIncentivesStage: rule.MoneyIncentivesStage, |
| 46 | + MoneyIncentivesStageCN: stageString, | ||
| 42 | MoneyIncentivesStageEnd: rule.MoneyIncentivesStageEnd, | 47 | MoneyIncentivesStageEnd: rule.MoneyIncentivesStageEnd, |
| 43 | MoneyIncentivesStageStart: rule.MoneyIncentivesStageStart, | 48 | MoneyIncentivesStageStart: rule.MoneyIncentivesStageStart, |
| 44 | MoneyIncentivesTime: rule.MoneyIncentivesTime, | 49 | MoneyIncentivesTime: rule.MoneyIncentivesTime, |
| @@ -77,6 +82,8 @@ func TransformToCooperationContractDomainModelFromPgModels( | @@ -77,6 +82,8 @@ func TransformToCooperationContractDomainModelFromPgModels( | ||
| 77 | Orgs: undertaker.Orgs, | 82 | Orgs: undertaker.Orgs, |
| 78 | Department: undertaker.Department, | 83 | Department: undertaker.Department, |
| 79 | Roles: undertaker.Roles, | 84 | Roles: undertaker.Roles, |
| 85 | + Referrer: undertaker.Referrer, | ||
| 86 | + Salesman: undertaker.Salesman, | ||
| 80 | UserInfo: undertaker.UserInfo, | 87 | UserInfo: undertaker.UserInfo, |
| 81 | UserType: undertaker.UserType, | 88 | UserType: undertaker.UserType, |
| 82 | Status: undertaker.Status, | 89 | Status: undertaker.Status, |
| @@ -3,9 +3,11 @@ package transform | @@ -3,9 +3,11 @@ package transform | ||
| 3 | import ( | 3 | import ( |
| 4 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | 4 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" |
| 5 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" | 5 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" |
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" | ||
| 6 | ) | 7 | ) |
| 7 | 8 | ||
| 8 | func TransformToDividendsIncentivesRuleDomainModelFromPgModels(dividendsIncentivesRuleModel *models.DividendsIncentivesRule) (*domain.DividendsIncentivesRule, error) { | 9 | func TransformToDividendsIncentivesRuleDomainModelFromPgModels(dividendsIncentivesRuleModel *models.DividendsIncentivesRule) (*domain.DividendsIncentivesRule, error) { |
| 10 | + stageString := utils.NumberToCNNumber(int(dividendsIncentivesRuleModel.DividendsIncentivesStage)) | ||
| 9 | return &domain.DividendsIncentivesRule{ | 11 | return &domain.DividendsIncentivesRule{ |
| 10 | DividendsIncentivesRuleId: dividendsIncentivesRuleModel.DividendsIncentivesRuleId, | 12 | DividendsIncentivesRuleId: dividendsIncentivesRuleModel.DividendsIncentivesRuleId, |
| 11 | CooperationContractNumber: dividendsIncentivesRuleModel.CooperationContractNumber, | 13 | CooperationContractNumber: dividendsIncentivesRuleModel.CooperationContractNumber, |
| @@ -13,6 +15,7 @@ func TransformToDividendsIncentivesRuleDomainModelFromPgModels(dividendsIncentiv | @@ -13,6 +15,7 @@ func TransformToDividendsIncentivesRuleDomainModelFromPgModels(dividendsIncentiv | ||
| 13 | SalesmanPercentage: dividendsIncentivesRuleModel.SalesmanPercentage, | 15 | SalesmanPercentage: dividendsIncentivesRuleModel.SalesmanPercentage, |
| 14 | DividendsIncentivesPercentage: dividendsIncentivesRuleModel.DividendsIncentivesPercentage, | 16 | DividendsIncentivesPercentage: dividendsIncentivesRuleModel.DividendsIncentivesPercentage, |
| 15 | DividendsIncentivesStage: dividendsIncentivesRuleModel.DividendsIncentivesStage, | 17 | DividendsIncentivesStage: dividendsIncentivesRuleModel.DividendsIncentivesStage, |
| 18 | + DividendsIncentivesStageCN: stageString, | ||
| 16 | DividendsIncentivesStageEnd: dividendsIncentivesRuleModel.DividendsIncentivesStageEnd, | 19 | DividendsIncentivesStageEnd: dividendsIncentivesRuleModel.DividendsIncentivesStageEnd, |
| 17 | DividendsIncentivesStageStart: dividendsIncentivesRuleModel.DividendsIncentivesStageStart, | 20 | DividendsIncentivesStageStart: dividendsIncentivesRuleModel.DividendsIncentivesStageStart, |
| 18 | Remarks: dividendsIncentivesRuleModel.Remarks, | 21 | Remarks: dividendsIncentivesRuleModel.Remarks, |
| @@ -3,14 +3,17 @@ package transform | @@ -3,14 +3,17 @@ package transform | ||
| 3 | import ( | 3 | import ( |
| 4 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | 4 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" |
| 5 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" | 5 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" |
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" | ||
| 6 | ) | 7 | ) |
| 7 | 8 | ||
| 8 | func TransformToMoneyIncentivesRuleDomainModelFromPgModels(moneyIncentivesRuleModel *models.MoneyIncentivesRule) (*domain.MoneyIncentivesRule, error) { | 9 | func TransformToMoneyIncentivesRuleDomainModelFromPgModels(moneyIncentivesRuleModel *models.MoneyIncentivesRule) (*domain.MoneyIncentivesRule, error) { |
| 10 | + stageString := utils.NumberToCNNumber(int(moneyIncentivesRuleModel.MoneyIncentivesStage)) | ||
| 9 | return &domain.MoneyIncentivesRule{ | 11 | return &domain.MoneyIncentivesRule{ |
| 10 | MoneyIncentivesRuleId: moneyIncentivesRuleModel.MoneyIncentivesRuleId, | 12 | MoneyIncentivesRuleId: moneyIncentivesRuleModel.MoneyIncentivesRuleId, |
| 11 | CooperationContractNumber: moneyIncentivesRuleModel.CooperationContractNumber, | 13 | CooperationContractNumber: moneyIncentivesRuleModel.CooperationContractNumber, |
| 12 | MoneyIncentivesAmount: moneyIncentivesRuleModel.MoneyIncentivesAmount, | 14 | MoneyIncentivesAmount: moneyIncentivesRuleModel.MoneyIncentivesAmount, |
| 13 | MoneyIncentivesStage: moneyIncentivesRuleModel.MoneyIncentivesStage, | 15 | MoneyIncentivesStage: moneyIncentivesRuleModel.MoneyIncentivesStage, |
| 16 | + MoneyIncentivesStageCN: stageString, | ||
| 14 | MoneyIncentivesStageEnd: moneyIncentivesRuleModel.MoneyIncentivesStageEnd, | 17 | MoneyIncentivesStageEnd: moneyIncentivesRuleModel.MoneyIncentivesStageEnd, |
| 15 | MoneyIncentivesStageStart: moneyIncentivesRuleModel.MoneyIncentivesStageStart, | 18 | MoneyIncentivesStageStart: moneyIncentivesRuleModel.MoneyIncentivesStageStart, |
| 16 | MoneyIncentivesTime: moneyIncentivesRuleModel.MoneyIncentivesTime, | 19 | MoneyIncentivesTime: moneyIncentivesRuleModel.MoneyIncentivesTime, |
| @@ -591,6 +591,33 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -591,6 +591,33 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
| 591 | return cooperationContract, nil | 591 | return cooperationContract, nil |
| 592 | } | 592 | } |
| 593 | 593 | ||
| 594 | +func (repository *CooperationContractRepository) UpdateOne(cooperationContract *domain.CooperationContract) (*domain.CooperationContract, error) { | ||
| 595 | + tx := repository.transactionContext.PgTx | ||
| 596 | + cooperationContractModel := new(models.CooperationContract) | ||
| 597 | + cooperationContractModel = &models.CooperationContract{ | ||
| 598 | + CooperationContractId: cooperationContract.CooperationContractId, | ||
| 599 | + CooperationContractDescription: cooperationContract.CooperationContractDescription, | ||
| 600 | + CooperationContractName: cooperationContract.CooperationContractName, | ||
| 601 | + CooperationContractNumber: cooperationContract.CooperationContractNumber, | ||
| 602 | + CooperationProjectNumber: cooperationContract.CooperationProjectNumber, | ||
| 603 | + CooperationContractUndertakerTypes: cooperationContract.CooperationContractUndertakerTypes, | ||
| 604 | + CooperationContractSponsor: cooperationContract.CooperationContractSponsor, | ||
| 605 | + CooperationModeNumber: cooperationContract.CooperationMode.CooperationModeNumber, | ||
| 606 | + Status: cooperationContract.Status, | ||
| 607 | + Org: cooperationContract.Org, | ||
| 608 | + Company: cooperationContract.Company, | ||
| 609 | + Operator: cooperationContract.Operator, | ||
| 610 | + OperateTime: cooperationContract.OperateTime, | ||
| 611 | + CreatedAt: cooperationContract.CreatedAt, | ||
| 612 | + DeletedAt: cooperationContract.DeletedAt, | ||
| 613 | + UpdatedAt: time.Now(), | ||
| 614 | + } | ||
| 615 | + if _, err := tx.Model(cooperationContractModel).WherePK().Update(); err != nil { | ||
| 616 | + return nil, err | ||
| 617 | + } | ||
| 618 | + return cooperationContract, nil | ||
| 619 | +} | ||
| 620 | + | ||
| 594 | func (repository *CooperationContractRepository) UpdateMany(cooperationContracts []*domain.CooperationContract) ([]*domain.CooperationContract, error) { | 621 | func (repository *CooperationContractRepository) UpdateMany(cooperationContracts []*domain.CooperationContract) ([]*domain.CooperationContract, error) { |
| 595 | tx := repository.transactionContext.PgTx | 622 | tx := repository.transactionContext.PgTx |
| 596 | var cooperationContractModels []*models.CooperationContract | 623 | var cooperationContractModels []*models.CooperationContract |
| @@ -653,7 +680,7 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom | @@ -653,7 +680,7 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom | ||
| 653 | if err := cooperationContractUndertakerQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil { | 680 | if err := cooperationContractUndertakerQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil { |
| 654 | return nil, err | 681 | return nil, err |
| 655 | } else { | 682 | } else { |
| 656 | - if _, err := tx.Model(&cooperationContractUndertakerModels).WherePK().Delete(); err != nil { | 683 | + if _, err := tx.Model(&cooperationContractUndertakerModels).Delete(); err != nil { |
| 657 | return nil, err | 684 | return nil, err |
| 658 | } | 685 | } |
| 659 | } | 686 | } |
| @@ -663,7 +690,7 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom | @@ -663,7 +690,7 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom | ||
| 663 | if err := cooperationContractRelevantQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil { | 690 | if err := cooperationContractRelevantQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil { |
| 664 | return nil, err | 691 | return nil, err |
| 665 | } else { | 692 | } else { |
| 666 | - if _, err := tx.Model(&cooperationContractRelevantModels).WherePK().Delete(); err != nil { | 693 | + if _, err := tx.Model(&cooperationContractRelevantModels).Delete(); err != nil { |
| 667 | return nil, err | 694 | return nil, err |
| 668 | } | 695 | } |
| 669 | } | 696 | } |
| @@ -710,7 +737,7 @@ func (repository *CooperationContractRepository) BatchRemove(cooperationContract | @@ -710,7 +737,7 @@ func (repository *CooperationContractRepository) BatchRemove(cooperationContract | ||
| 710 | if err := cooperationContractUndertakerQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil { | 737 | if err := cooperationContractUndertakerQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil { |
| 711 | return nil, err | 738 | return nil, err |
| 712 | } else { | 739 | } else { |
| 713 | - if _, err := tx.Model(&cooperationContractUndertakerModels).WherePK().Delete(); err != nil { | 740 | + if _, err := tx.Model(&cooperationContractUndertakerModels).Delete(); err != nil { |
| 714 | return nil, err | 741 | return nil, err |
| 715 | } | 742 | } |
| 716 | } | 743 | } |
| @@ -720,7 +747,7 @@ func (repository *CooperationContractRepository) BatchRemove(cooperationContract | @@ -720,7 +747,7 @@ func (repository *CooperationContractRepository) BatchRemove(cooperationContract | ||
| 720 | if err := cooperationContractRelevantQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil { | 747 | if err := cooperationContractRelevantQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil { |
| 721 | return nil, err | 748 | return nil, err |
| 722 | } else { | 749 | } else { |
| 723 | - if _, err := tx.Model(&cooperationContractRelevantModels).WherePK().Delete(); err != nil { | 750 | + if _, err := tx.Model(&cooperationContractRelevantModels).Delete(); err != nil { |
| 724 | return nil, err | 751 | return nil, err |
| 725 | } | 752 | } |
| 726 | } | 753 | } |
| 1 | package utils | 1 | package utils |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | - "strconv" | 4 | + "fmt" |
| 5 | "github.com/shopspring/decimal" | 5 | "github.com/shopspring/decimal" |
| 6 | + "strconv" | ||
| 7 | + "strings" | ||
| 6 | ) | 8 | ) |
| 7 | 9 | ||
| 8 | // Intersect 返回两个数组的交集 | 10 | // Intersect 返回两个数组的交集 |
| @@ -25,23 +27,6 @@ func Intersect(nums1 []int64, nums2 []int64) []int64 { | @@ -25,23 +27,6 @@ func Intersect(nums1 []int64, nums2 []int64) []int64 { | ||
| 25 | return intersection | 27 | return intersection |
| 26 | } | 28 | } |
| 27 | 29 | ||
| 28 | -////求交集 | ||
| 29 | -//func intersect(slice1, slice2 []int64) []int64 { | ||
| 30 | -// m := make(map[int64]int) | ||
| 31 | -// nn := make([]int64, 0) | ||
| 32 | -// for _, v := range slice1 { | ||
| 33 | -// m[v]++ | ||
| 34 | -// } | ||
| 35 | -// | ||
| 36 | -// for _, v := range slice2 { | ||
| 37 | -// times, _ := m[v] | ||
| 38 | -// if times == 1 { | ||
| 39 | -// nn = append(nn, v) | ||
| 40 | -// } | ||
| 41 | -// } | ||
| 42 | -// return nn | ||
| 43 | -//} | ||
| 44 | - | ||
| 45 | // Difference 求差集 slice1-并集 | 30 | // Difference 求差集 slice1-并集 |
| 46 | func Difference(slice1, slice2 []int64) []int64 { | 31 | func Difference(slice1, slice2 []int64) []int64 { |
| 47 | m := make(map[int64]int) | 32 | m := make(map[int64]int) |
| @@ -78,3 +63,40 @@ func Round(value float64, places int32) float64 { | @@ -78,3 +63,40 @@ func Round(value float64, places int32) float64 { | ||
| 78 | rsp, _ := d.Float64() | 63 | rsp, _ := d.Float64() |
| 79 | return rsp | 64 | return rsp |
| 80 | } | 65 | } |
| 66 | + | ||
| 67 | +// NumberToCNNumber 数字转中文数字 | ||
| 68 | +func NumberToCNNumber(num int) string { | ||
| 69 | + chineseMap := []string{"", "十", "百", "千", "万", "十", "百", "千", "亿", "十", "百", "千"} | ||
| 70 | + chineseNum := []string{"零", "一", "二", "三", "四", "五", "六", "七", "八", "九"} | ||
| 71 | + var listNum []int | ||
| 72 | + for ; num > 0; num = num / 10 { | ||
| 73 | + listNum = append(listNum, num%10) | ||
| 74 | + } | ||
| 75 | + n := len(listNum) | ||
| 76 | + chinese := "" | ||
| 77 | + //注意这里是倒序的 | ||
| 78 | + for i := n - 1; i >= 0; i-- { | ||
| 79 | + chinese = fmt.Sprintf("%s%s%s", chinese, chineseNum[listNum[i]], chineseMap[i]) | ||
| 80 | + } | ||
| 81 | + //注意替换顺序 | ||
| 82 | + for { | ||
| 83 | + copyChinese := chinese | ||
| 84 | + copyChinese = strings.Replace(copyChinese, "零万", "万", 1) | ||
| 85 | + copyChinese = strings.Replace(copyChinese, "零亿", "亿", 1) | ||
| 86 | + copyChinese = strings.Replace(copyChinese, "零十", "零", 1) | ||
| 87 | + copyChinese = strings.Replace(copyChinese, "零百", "零", 1) | ||
| 88 | + copyChinese = strings.Replace(copyChinese, "零千", "零", 1) | ||
| 89 | + copyChinese = strings.Replace(copyChinese, "零零", "", 1) | ||
| 90 | + //copyChinese = strings.Replace(copyChinese, "零圆", "", 1) | ||
| 91 | + //copyChinese = strings.Replace(copyChinese, "零", "", 1) | ||
| 92 | + | ||
| 93 | + if copyChinese == chinese { | ||
| 94 | + break | ||
| 95 | + } else { | ||
| 96 | + chinese = copyChinese | ||
| 97 | + } | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + return "第" + chinese + "阶段" | ||
| 101 | + | ||
| 102 | +} |
| @@ -12,9 +12,4 @@ func init() { | @@ -12,9 +12,4 @@ func init() { | ||
| 12 | Logger = logrus.NewLogrusLogger() | 12 | Logger = logrus.NewLogrusLogger() |
| 13 | Logger.SetServiceName(constant.SERVICE_NAME) | 13 | Logger.SetServiceName(constant.SERVICE_NAME) |
| 14 | Logger.SetLevel(constant.LOG_LEVEL) | 14 | Logger.SetLevel(constant.LOG_LEVEL) |
| 15 | - | ||
| 16 | - //if constant.ENABLE_KAFKA_LOG { | ||
| 17 | - // w, _ := logrus.NewKafkaWriter(constant.KAFKA_HOSTS, constant.TOPIC_LOG_STASH, false) | ||
| 18 | - // Logger.AddHook(w) | ||
| 19 | - //} | ||
| 20 | } | 15 | } |
-
请 注册 或 登录 后发表评论