正在显示
1 个修改的文件
包含
46 行增加
和
38 行删除
@@ -3,7 +3,6 @@ package service | @@ -3,7 +3,6 @@ package service | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | "github.com/linmadan/egglib-go/utils/tool_funs" | 5 | "github.com/linmadan/egglib-go/utils/tool_funs" |
6 | - "strconv" | ||
7 | "time" | 6 | "time" |
8 | 7 | ||
9 | "github.com/linmadan/egglib-go/core/application" | 8 | "github.com/linmadan/egglib-go/core/application" |
@@ -11,7 +10,6 @@ import ( | @@ -11,7 +10,6 @@ import ( | ||
11 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/command" | 10 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/command" |
12 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/query" | 11 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/query" |
13 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" | 12 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" |
14 | - "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao" | ||
15 | ) | 13 | ) |
16 | 14 | ||
17 | // 现金池服务 | 15 | // 现金池服务 |
@@ -33,33 +31,28 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co | @@ -33,33 +31,28 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co | ||
33 | defer func() { | 31 | defer func() { |
34 | transactionContext.RollbackTransaction() | 32 | transactionContext.RollbackTransaction() |
35 | }() | 33 | }() |
36 | - var cashPoolDao *dao.CashPoolDao | ||
37 | - if value, err := factory.CreateCashPoolDao(map[string]interface{}{ | ||
38 | - "transactionContext": transactionContext, | ||
39 | - }); err != nil { | ||
40 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
41 | - } else { | ||
42 | - cashPoolDao = value | ||
43 | - } | ||
44 | - var ( | ||
45 | - systemExchangedCash float64 | ||
46 | - systemUnExchangeCash float64 | ||
47 | - ) | ||
48 | - if value, err := cashPoolDao.CalculateSystemCash(createCashPoolCommand.CompanyId); err != nil { | ||
49 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
50 | - } else { | ||
51 | - systemExchangedCash = value | ||
52 | - } | ||
53 | - var ( | ||
54 | - systemChangedSuMoney float64 | ||
55 | - systemUnChangeSuMoney float64 | ||
56 | - ) | ||
57 | - if value1, value2, err := cashPoolDao.CalculateSystemSuMoney(createCashPoolCommand.CompanyId); err != nil { | ||
58 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
59 | - } else { | ||
60 | - systemChangedSuMoney = value1 | ||
61 | - systemUnChangeSuMoney = value2 | ||
62 | - } | 34 | + |
35 | + // TODO 判断公司是否存在 | ||
36 | + //var cashPoolDao *dao.CashPoolDao | ||
37 | + //if value, err := factory.CreateCashPoolDao(map[string]interface{}{ | ||
38 | + // "transactionContext": transactionContext, | ||
39 | + //}); err != nil { | ||
40 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
41 | + //} else { | ||
42 | + // cashPoolDao = value | ||
43 | + //} | ||
44 | + | ||
45 | + var systemUnExchangeCash float64 | ||
46 | + | ||
47 | + //systemExchangedCash, err := cashPoolDao.CalculateSystemCash(createCashPoolCommand.CompanyId) | ||
48 | + //if err != nil { | ||
49 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
50 | + //} | ||
51 | + | ||
52 | + //systemChangedSuMoney, systemUnChangeSuMoney, err := cashPoolDao.CalculateSystemSuMoney(createCashPoolCommand.CompanyId) | ||
53 | + //if err != nil { | ||
54 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
55 | + //} | ||
63 | 56 | ||
64 | var cashPoolRepository domain.CashPoolRepository | 57 | var cashPoolRepository domain.CashPoolRepository |
65 | if value, err := factory.CreateCashPoolRepository(map[string]interface{}{ | 58 | if value, err := factory.CreateCashPoolRepository(map[string]interface{}{ |
@@ -83,15 +76,19 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co | @@ -83,15 +76,19 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co | ||
83 | // systemUnExchangeCash = cashPools[0].UnExchangeCash | 76 | // systemUnExchangeCash = cashPools[0].UnExchangeCash |
84 | //} | 77 | //} |
85 | 78 | ||
86 | - rate, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", systemExchangedCash / systemChangedSuMoney), 64) // 平均兑换汇率 | 79 | + //rate, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", systemExchangedCash / systemChangedSuMoney), 64) // 平均兑换汇率 |
87 | newCashPool := &domain.CashPool{ | 80 | newCashPool := &domain.CashPool{ |
88 | CompanyId: createCashPoolCommand.CompanyId, | 81 | CompanyId: createCashPoolCommand.CompanyId, |
89 | Cash: createCashPoolCommand.Cash, | 82 | Cash: createCashPoolCommand.Cash, |
90 | - ExchangedCash: systemExchangedCash, | 83 | + //ExchangedCash: systemExchangedCash, |
84 | + ExchangedCash: 0, | ||
91 | UnExchangeCash: createCashPoolCommand.Cash + systemUnExchangeCash, | 85 | UnExchangeCash: createCashPoolCommand.Cash + systemUnExchangeCash, |
92 | - ExchangedSuMoney: systemChangedSuMoney, | ||
93 | - UnExchangeSuMoney: systemUnChangeSuMoney, | ||
94 | - Rate: rate, | 86 | + //ExchangedSuMoney: systemChangedSuMoney, |
87 | + ExchangedSuMoney: 0, | ||
88 | + //UnExchangeSuMoney: systemUnChangeSuMoney, | ||
89 | + UnExchangeSuMoney: 0, | ||
90 | + //Rate: rate, | ||
91 | + Rate: 0, | ||
95 | CreateTime: time.Now(), | 92 | CreateTime: time.Now(), |
96 | } | 93 | } |
97 | 94 | ||
@@ -142,10 +139,21 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC | @@ -142,10 +139,21 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC | ||
142 | if err := transactionContext.CommitTransaction(); err != nil { | 139 | if err := transactionContext.CommitTransaction(); err != nil { |
143 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 140 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
144 | } | 141 | } |
145 | - return map[string]interface{}{ | ||
146 | - "count": count, | ||
147 | - "cashPools": cashPools, | ||
148 | - }, nil | 142 | + // TODO 初始状态下,现金池返回默认值 |
143 | + if count == 0 { | ||
144 | + return map[string]interface{}{ | ||
145 | + "cashPoolId": 4, | ||
146 | + "cash": 0, | ||
147 | + "companyId": 101, | ||
148 | + "exchangedCash": 100, | ||
149 | + "unExchangeCash": 1001, | ||
150 | + "exchangedSuMoney": 50, | ||
151 | + "unExchangeSuMoney": 11, | ||
152 | + "rate": 2, | ||
153 | + "createTime": "2020-11-03T17:23:00.848676+08:00", | ||
154 | + }, nil | ||
155 | + } | ||
156 | + return cashPools[0], nil | ||
149 | } | 157 | } |
150 | } | 158 | } |
151 | 159 |
-
请 注册 或 登录 后发表评论