作者 陈志颖

feat:调整阶段中文生成方法

... ... @@ -3,9 +3,11 @@ package transform
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
)
func TransformToDividendsIncentivesRuleDomainModelFromPgModels(dividendsIncentivesRuleModel *models.DividendsIncentivesRule) (*domain.DividendsIncentivesRule, error) {
stageString := utils.NumberToCNNumber(int(dividendsIncentivesRuleModel.DividendsIncentivesStage))
return &domain.DividendsIncentivesRule{
DividendsIncentivesRuleId: dividendsIncentivesRuleModel.DividendsIncentivesRuleId,
CooperationContractNumber: dividendsIncentivesRuleModel.CooperationContractNumber,
... ... @@ -13,6 +15,7 @@ func TransformToDividendsIncentivesRuleDomainModelFromPgModels(dividendsIncentiv
SalesmanPercentage: dividendsIncentivesRuleModel.SalesmanPercentage,
DividendsIncentivesPercentage: dividendsIncentivesRuleModel.DividendsIncentivesPercentage,
DividendsIncentivesStage: dividendsIncentivesRuleModel.DividendsIncentivesStage,
DividendsIncentivesStageCN: stageString,
DividendsIncentivesStageEnd: dividendsIncentivesRuleModel.DividendsIncentivesStageEnd,
DividendsIncentivesStageStart: dividendsIncentivesRuleModel.DividendsIncentivesStageStart,
Remarks: dividendsIncentivesRuleModel.Remarks,
... ...
... ... @@ -3,14 +3,17 @@ package transform
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
)
func TransformToMoneyIncentivesRuleDomainModelFromPgModels(moneyIncentivesRuleModel *models.MoneyIncentivesRule) (*domain.MoneyIncentivesRule, error) {
stageString := utils.NumberToCNNumber(int(moneyIncentivesRuleModel.MoneyIncentivesStage))
return &domain.MoneyIncentivesRule{
MoneyIncentivesRuleId: moneyIncentivesRuleModel.MoneyIncentivesRuleId,
CooperationContractNumber: moneyIncentivesRuleModel.CooperationContractNumber,
MoneyIncentivesAmount: moneyIncentivesRuleModel.MoneyIncentivesAmount,
MoneyIncentivesStage: moneyIncentivesRuleModel.MoneyIncentivesStage,
MoneyIncentivesStageCN: stageString,
MoneyIncentivesStageEnd: moneyIncentivesRuleModel.MoneyIncentivesStageEnd,
MoneyIncentivesStageStart: moneyIncentivesRuleModel.MoneyIncentivesStageStart,
MoneyIncentivesTime: moneyIncentivesRuleModel.MoneyIncentivesTime,
... ...
... ... @@ -27,23 +27,6 @@ func Intersect(nums1 []int64, nums2 []int64) []int64 {
return intersection
}
////求交集
//func intersect(slice1, slice2 []int64) []int64 {
// m := make(map[int64]int)
// nn := make([]int64, 0)
// for _, v := range slice1 {
// m[v]++
// }
//
// for _, v := range slice2 {
// times, _ := m[v]
// if times == 1 {
// nn = append(nn, v)
// }
// }
// return nn
//}
// Difference 求差集 slice1-并集
func Difference(slice1, slice2 []int64) []int64 {
m := make(map[int64]int)
... ... @@ -83,7 +66,7 @@ func Round(value float64, places int32) float64 {
// NumberToCNNumber 数字转中文数字
func NumberToCNNumber(num int) string {
chineseMap := []string{"阶段", "十", "百", "千", "万", "十", "百", "千", "亿", "十", "百", "千"}
chineseMap := []string{"", "十", "百", "千", "万", "十", "百", "千", "亿", "十", "百", "千"}
chineseNum := []string{"零", "一", "二", "三", "四", "五", "六", "七", "八", "九"}
var listNum []int
for ; num > 0; num = num / 10 {
... ... @@ -103,8 +86,9 @@ func NumberToCNNumber(num int) string {
copyChinese = strings.Replace(copyChinese, "零十", "零", 1)
copyChinese = strings.Replace(copyChinese, "零百", "零", 1)
copyChinese = strings.Replace(copyChinese, "零千", "零", 1)
copyChinese = strings.Replace(copyChinese, "零零", "零", 1)
copyChinese = strings.Replace(copyChinese, "零圆", "圆", 1)
copyChinese = strings.Replace(copyChinese, "零零", "", 1)
//copyChinese = strings.Replace(copyChinese, "零圆", "", 1)
//copyChinese = strings.Replace(copyChinese, "零", "", 1)
if copyChinese == chinese {
break
... ... @@ -113,6 +97,6 @@ func NumberToCNNumber(num int) string {
}
}
return "第" + chinese
return "第" + chinese + "阶段"
}
... ...