正在显示
6 个修改的文件
包含
54 行增加
和
14 行删除
| @@ -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= |
| 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 { |
| @@ -77,8 +79,3 @@ func (dividendsIncentivesRule *DividendsIncentivesRule) Update(data map[string]i | @@ -77,8 +79,3 @@ func (dividendsIncentivesRule *DividendsIncentivesRule) Update(data map[string]i | ||
| 77 | } | 79 | } |
| 78 | return nil | 80 | return nil |
| 79 | } | 81 | } |
| 80 | - | ||
| 81 | -// NumberToCNNumber 数字转中文数字 | ||
| 82 | -func (dividendsIncentivesRule *DividendsIncentivesRule) NumberToCNNumber() (string, error) { | ||
| 83 | - return "", nil | ||
| 84 | -} |
| 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 { |
| @@ -82,8 +84,3 @@ func (moneyIncentivesRule *MoneyIncentivesRule) Update(data map[string]interface | @@ -82,8 +84,3 @@ func (moneyIncentivesRule *MoneyIncentivesRule) Update(data map[string]interface | ||
| 82 | } | 84 | } |
| 83 | return nil | 85 | return nil |
| 84 | } | 86 | } |
| 85 | - | ||
| 86 | -// NumberToCNNumber 数字转中文数字 | ||
| 87 | -func (moneyIncentivesRule *MoneyIncentivesRule) NumberToCNNumber() (string, error) { | ||
| 88 | - return "", nil | ||
| 89 | -} |
| @@ -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, |
| 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 返回两个数组的交集 |
| @@ -77,4 +79,40 @@ func Round(value float64, places int32) float64 { | @@ -77,4 +79,40 @@ func Round(value float64, places int32) float64 { | ||
| 77 | d := quantity.Round(places) | 79 | d := quantity.Round(places) |
| 78 | rsp, _ := d.Float64() | 80 | rsp, _ := d.Float64() |
| 79 | return rsp | 81 | return rsp |
| 80 | -} | ||
| 82 | +} | ||
| 83 | + | ||
| 84 | +// NumberToCNNumber 数字转中文数字 | ||
| 85 | +func NumberToCNNumber(num int) string { | ||
| 86 | + chineseMap := []string{"阶段", "十", "百", "千", "万", "十", "百", "千", "亿", "十", "百", "千"} | ||
| 87 | + chineseNum := []string{"零", "一", "二", "三", "四", "五", "六", "七", "八", "九"} | ||
| 88 | + var listNum []int | ||
| 89 | + for ; num > 0; num = num / 10 { | ||
| 90 | + listNum = append(listNum, num%10) | ||
| 91 | + } | ||
| 92 | + n := len(listNum) | ||
| 93 | + chinese := "" | ||
| 94 | + //注意这里是倒序的 | ||
| 95 | + for i := n - 1; i >= 0; i-- { | ||
| 96 | + chinese = fmt.Sprintf("%s%s%s", chinese, chineseNum[listNum[i]], chineseMap[i]) | ||
| 97 | + } | ||
| 98 | + //注意替换顺序 | ||
| 99 | + for { | ||
| 100 | + copyChinese := chinese | ||
| 101 | + copyChinese = strings.Replace(copyChinese, "零万", "万", 1) | ||
| 102 | + copyChinese = strings.Replace(copyChinese, "零亿", "亿", 1) | ||
| 103 | + copyChinese = strings.Replace(copyChinese, "零十", "零", 1) | ||
| 104 | + copyChinese = strings.Replace(copyChinese, "零百", "零", 1) | ||
| 105 | + copyChinese = strings.Replace(copyChinese, "零千", "零", 1) | ||
| 106 | + copyChinese = strings.Replace(copyChinese, "零零", "零", 1) | ||
| 107 | + copyChinese = strings.Replace(copyChinese, "零圆", "圆", 1) | ||
| 108 | + | ||
| 109 | + if copyChinese == chinese { | ||
| 110 | + break | ||
| 111 | + } else { | ||
| 112 | + chinese = copyChinese | ||
| 113 | + } | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + return "第" + chinese | ||
| 117 | + | ||
| 118 | +} |
-
请 注册 或 登录 后发表评论