正在显示
15 个修改的文件
包含
473 行增加
和
112 行删除
@@ -8,7 +8,7 @@ import ( | @@ -8,7 +8,7 @@ import ( | ||
8 | ) | 8 | ) |
9 | 9 | ||
10 | // 创建现金兑换活动 | 10 | // 创建现金兑换活动 |
11 | -type CreateExchangeActivityCommand struct { | 11 | +type CreateExchangeCashActivityCommand struct { |
12 | CompanyId int64 `json:"companyId" valid:"Required"` // 公司id | 12 | CompanyId int64 `json:"companyId" valid:"Required"` // 公司id |
13 | ExchangeActivityName string `json:"exchangeActivityName"` // 活动名称 | 13 | ExchangeActivityName string `json:"exchangeActivityName"` // 活动名称 |
14 | CashPool *domain.CashPool `json:"cashPool"` // 兑换现金活动关联的现金池,最新的现金池 | 14 | CashPool *domain.CashPool `json:"cashPool"` // 兑换现金活动关联的现金池,最新的现金池 |
@@ -20,7 +20,7 @@ type CreateExchangeActivityCommand struct { | @@ -20,7 +20,7 @@ type CreateExchangeActivityCommand struct { | ||
20 | ExchangeCashPeople []*domain.ExchangeCashPersonList `json:"exchangeList"` // 兑换活动清单 | 20 | ExchangeCashPeople []*domain.ExchangeCashPersonList `json:"exchangeList"` // 兑换活动清单 |
21 | } | 21 | } |
22 | 22 | ||
23 | -func (createExchangeActivityCommand *CreateExchangeActivityCommand) ValidateCommand() error { | 23 | +func (createExchangeActivityCommand *CreateExchangeCashActivityCommand) ValidateCommand() error { |
24 | valid := validation.Validation{} | 24 | valid := validation.Validation{} |
25 | b, err := valid.Valid(createExchangeActivityCommand) | 25 | b, err := valid.Valid(createExchangeActivityCommand) |
26 | if err != nil { | 26 | if err != nil { |
@@ -7,7 +7,6 @@ import ( | @@ -7,7 +7,6 @@ import ( | ||
7 | 7 | ||
8 | // 移除兑换现金人员 | 8 | // 移除兑换现金人员 |
9 | type RemoveExchangeCashPersonCommand struct { | 9 | type RemoveExchangeCashPersonCommand struct { |
10 | - ExchangeCashActivityId int64 `json:"exchangeCashActivityId" valid:"Required"` // 兑换现金人员参与的活动ID | ||
11 | ExchangeCashPersonId int64 `json:"exchangeCashId" valid:"Required"` // 兑换现金人员编号 | 10 | ExchangeCashPersonId int64 `json:"exchangeCashId" valid:"Required"` // 兑换现金人员编号 |
12 | } | 11 | } |
13 | 12 |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | +) | ||
7 | + | ||
8 | +type SearchExchangeCashActivityCommand struct { | ||
9 | + ExchangeCashActivityName string `json:"exchangeCashActivityName"` // 兑换现金活动名称 | ||
10 | +} | ||
11 | + | ||
12 | +func (searchExchangeCashActivityCommand *SearchExchangeCashActivityCommand) ValidateCommand() error { | ||
13 | + valid := validation.Validation{} | ||
14 | + b, err := valid.Valid(searchExchangeCashActivityCommand) | ||
15 | + if err != nil { | ||
16 | + return err | ||
17 | + } | ||
18 | + if !b { | ||
19 | + for _, validErr := range valid.Errors { | ||
20 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
21 | + } | ||
22 | + } | ||
23 | + return nil | ||
24 | +} | ||
25 | + |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | +) | ||
7 | + | ||
8 | +type SearchExchangeCashPersonCommand struct { | ||
9 | + ExchangeCashPersonName string `json:"exchangeCashPersonName"` // 兑换素币人员名称 | ||
10 | +} | ||
11 | + | ||
12 | +func (searchExchangeCashPersonCommand *SearchExchangeCashPersonCommand) ValidateCommand() error { | ||
13 | + valid := validation.Validation{} | ||
14 | + b, err := valid.Valid(searchExchangeCashPersonCommand) | ||
15 | + if err != nil { | ||
16 | + return err | ||
17 | + } | ||
18 | + if !b { | ||
19 | + for _, validErr := range valid.Errors { | ||
20 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
21 | + } | ||
22 | + } | ||
23 | + return nil | ||
24 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | +) | ||
7 | + | ||
8 | +type SearchSuMoneyTransactionCommand struct { | ||
9 | + EmployeeName string `json:"employeeName"` // 员工姓名 | ||
10 | +} | ||
11 | + | ||
12 | +func (searchSuMoneyTransactionCommand *SearchSuMoneyTransactionCommand) ValidateCommand() error { | ||
13 | + valid := validation.Validation{} | ||
14 | + b, err := valid.Valid(searchSuMoneyTransactionCommand) | ||
15 | + if err != nil { | ||
16 | + return err | ||
17 | + } | ||
18 | + if !b { | ||
19 | + for _, validErr := range valid.Errors { | ||
20 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
21 | + } | ||
22 | + } | ||
23 | + return nil | ||
24 | +} |
@@ -7,7 +7,7 @@ import ( | @@ -7,7 +7,7 @@ import ( | ||
7 | "time" | 7 | "time" |
8 | ) | 8 | ) |
9 | 9 | ||
10 | -type UpdateExchangeCashActivity struct { | 10 | +type UpdateExchangeCashActivityCommand struct { |
11 | ExchangeCashActivityId int64 `json:"exchangeCashActivityId"` // 兑换现金活动id | 11 | ExchangeCashActivityId int64 `json:"exchangeCashActivityId"` // 兑换现金活动id |
12 | CompanyId int64 `json:"companyId" valid:"Required"` // 公司id | 12 | CompanyId int64 `json:"companyId" valid:"Required"` // 公司id |
13 | ExchangeActivityName string `json:"exchangeActivityName"` // 活动名称 | 13 | ExchangeActivityName string `json:"exchangeActivityName"` // 活动名称 |
@@ -19,7 +19,7 @@ type UpdateExchangeCashActivity struct { | @@ -19,7 +19,7 @@ type UpdateExchangeCashActivity struct { | ||
19 | ExchangeCashPeople []*domain.ExchangeCashPersonList `json:"exchangeCashPeople"` // 兑换活动清单 | 19 | ExchangeCashPeople []*domain.ExchangeCashPersonList `json:"exchangeCashPeople"` // 兑换活动清单 |
20 | } | 20 | } |
21 | 21 | ||
22 | -func (updateExchangeCashActivity *UpdateExchangeCashActivity) ValidateCommand() error { | 22 | +func (updateExchangeCashActivity *UpdateExchangeCashActivityCommand) ValidateCommand() error { |
23 | valid := validation.Validation{} | 23 | valid := validation.Validation{} |
24 | b, err := valid.Valid(updateExchangeCashActivity) | 24 | b, err := valid.Valid(updateExchangeCashActivity) |
25 | if err != nil { | 25 | if err != nil { |
@@ -7,7 +7,6 @@ import ( | @@ -7,7 +7,6 @@ import ( | ||
7 | 7 | ||
8 | type UpdateExchangeCashPersonCommand struct { | 8 | type UpdateExchangeCashPersonCommand struct { |
9 | ExchangeCashPersonId int64 `json:"exchangeCashPersonId" valid:"Required"` // 兑换现金人员编号 | 9 | ExchangeCashPersonId int64 `json:"exchangeCashPersonId" valid:"Required"` // 兑换现金人员编号 |
10 | - ExchangeCashActivityId int64 `json:"exchangeCashActivityId" valid:"Required"` // 参与的兑换现金活动id | ||
11 | ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换的素币(需要和当前的已兑换素币进行比较,少于当前已兑换素币则生成一条扣除素币记录,大于当前已兑换素币则生成一条增加素币记录) | 10 | ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换的素币(需要和当前的已兑换素币进行比较,少于当前已兑换素币则生成一条扣除素币记录,大于当前已兑换素币则生成一条增加素币记录) |
12 | ExchangedCash float64 `json:"exchangedCash"` // 已兑换的现金 | 11 | ExchangedCash float64 `json:"exchangedCash"` // 已兑换的现金 |
13 | } | 12 | } |
@@ -8,6 +8,9 @@ import ( | @@ -8,6 +8,9 @@ import ( | ||
8 | // 获取兑换现金活动列表 | 8 | // 获取兑换现金活动列表 |
9 | type ListExchangeCashActivityQuery struct { | 9 | type ListExchangeCashActivityQuery struct { |
10 | CompanyId int64 `json:"companyId"` // 公司id | 10 | CompanyId int64 `json:"companyId"` // 公司id |
11 | + ExchangeCashActivityNameMatch string `json:"exchangeCashActivityNameMatch,omitempty"` | ||
12 | + Offset int `json:"offset,omitempty"` | ||
13 | + Limit int `json:"limit,omitempty"` | ||
11 | } | 14 | } |
12 | 15 | ||
13 | func (listExchangeCashActivityQuery *ListExchangeCashActivityQuery) ValidateQuery() error { | 16 | func (listExchangeCashActivityQuery *ListExchangeCashActivityQuery) ValidateQuery() error { |
@@ -8,6 +8,9 @@ import ( | @@ -8,6 +8,9 @@ import ( | ||
8 | // 获取兑换活动兑换清单 | 8 | // 获取兑换活动兑换清单 |
9 | type ListExchangeCashPersonQuery struct { | 9 | type ListExchangeCashPersonQuery struct { |
10 | ExchangeCashActivityId int64 `json:"exchangeCashActivityId"` // 兑换现金活动id | 10 | ExchangeCashActivityId int64 `json:"exchangeCashActivityId"` // 兑换现金活动id |
11 | + ExchangeCashPersonNameMatch string `json:"exchangeCashPersonNameMatch,omitempty"` // 兑换活动名称匹配 | ||
12 | + Offset int `json:"offset,omitempty"` // 查询偏离量 | ||
13 | + Limit int `json:"limit,omitempty"` // 查询限制 | ||
11 | } | 14 | } |
12 | 15 | ||
13 | func (listExchangeCashPersonQuery *ListExchangeCashPersonQuery) ValidateQuery() error { | 16 | func (listExchangeCashPersonQuery *ListExchangeCashPersonQuery) ValidateQuery() error { |
@@ -4,15 +4,17 @@ import ( | @@ -4,15 +4,17 @@ import ( | ||
4 | "github.com/linmadan/egglib-go/core/application" | 4 | "github.com/linmadan/egglib-go/core/application" |
5 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory" | 5 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory" |
6 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/command" | 6 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/command" |
7 | + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/query" | ||
7 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/service" | 8 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/service" |
9 | + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao" | ||
8 | ) | 10 | ) |
9 | 11 | ||
10 | // 现金池服务 | 12 | // 现金池服务 |
11 | type CashPoolService struct { | 13 | type CashPoolService struct { |
12 | } | 14 | } |
13 | 15 | ||
14 | -// 操作现金池 | ||
15 | -func (cashService *CashPoolService) OperationCashPool(createCashPoolCommand *command.CreateCashPoolCommand) (interface{}, error) { | 16 | +// 投入现金 |
17 | +func (cashPoolService *CashPoolService) OperationCashPool(createCashPoolCommand *command.CreateCashPoolCommand) (interface{}, error) { | ||
16 | if err := createCashPoolCommand.ValidateCommand(); err != nil { | 18 | if err := createCashPoolCommand.ValidateCommand(); err != nil { |
17 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 19 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
18 | } | 20 | } |
@@ -31,17 +33,44 @@ func (cashService *CashPoolService) OperationCashPool(createCashPoolCommand *com | @@ -31,17 +33,44 @@ func (cashService *CashPoolService) OperationCashPool(createCashPoolCommand *com | ||
31 | transactionContext.RollbackTransaction() | 33 | transactionContext.RollbackTransaction() |
32 | }() | 34 | }() |
33 | 35 | ||
34 | - var cashPoolService service.InputCashPoolService | 36 | + var employeeDao *dao.EmployeeDao |
37 | + if value, err := factory.CreateEmployeeDao(map[string]interface{}{ | ||
38 | + "transactionContext": transactionContext, | ||
39 | + }); err != nil { | ||
40 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
41 | + } else { | ||
42 | + employeeDao = value | ||
43 | + } | ||
44 | + | ||
45 | + var systemExchangedCash float64 | ||
46 | + if value, err := employeeDao.CalculateSystemCash(createCashPoolCommand.CompanyId); err != nil { | ||
47 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
48 | + } else { | ||
49 | + systemExchangedCash = value | ||
50 | + } | ||
51 | + | ||
52 | + var ( | ||
53 | + systemChangedSuMoney float64 | ||
54 | + systemUnChangeSuMoney float64 | ||
55 | + ) | ||
56 | + if value1, value2, err := employeeDao.CalculateSystemSuMoney(createCashPoolCommand.CompanyId); err != nil { | ||
57 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
58 | + } else { | ||
59 | + systemChangedSuMoney = value1 | ||
60 | + systemUnChangeSuMoney = value2 | ||
61 | + } | ||
62 | + | ||
63 | + var inputCashPoolService service.InputCashPoolService | ||
35 | 64 | ||
36 | if value, err := factory.CreateInputCashPoolService(map[string]interface{}{ | 65 | if value, err := factory.CreateInputCashPoolService(map[string]interface{}{ |
37 | "transactionContext": transactionContext, | 66 | "transactionContext": transactionContext, |
38 | }); err != nil { | 67 | }); err != nil { |
39 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 68 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
40 | } else { | 69 | } else { |
41 | - cashPoolService = value | 70 | + inputCashPoolService = value |
42 | } | 71 | } |
43 | 72 | ||
44 | - if task, err := cashPoolService.Input(createCashPoolCommand.CompanyId, createCashPoolCommand.Operator, createCashPoolCommand.Cash); err != nil { | 73 | + if task, err := inputCashPoolService.Input(createCashPoolCommand.CompanyId, createCashPoolCommand.Operator, createCashPoolCommand.Cash, systemChangedSuMoney, systemUnChangeSuMoney, systemExchangedCash); err != nil { |
45 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 74 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
46 | } else { | 75 | } else { |
47 | if err := transactionContext.CommitTransaction(); err != nil { | 76 | if err := transactionContext.CommitTransaction(); err != nil { |
@@ -51,6 +80,68 @@ func (cashService *CashPoolService) OperationCashPool(createCashPoolCommand *com | @@ -51,6 +80,68 @@ func (cashService *CashPoolService) OperationCashPool(createCashPoolCommand *com | ||
51 | } | 80 | } |
52 | } | 81 | } |
53 | 82 | ||
83 | +// TODO 返回现金池 | ||
84 | +func (cashPoolService *CashPoolService) CashPool(getCashPoolQuery *query.GetCashPoolQuery) (interface{}, error) { | ||
85 | + return nil, nil | ||
86 | +} | ||
87 | + | ||
88 | +// TODO 返回兑换现金活动 | ||
89 | +func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCashActivityCommand *query.ListExchangeCashActivityQuery) (interface{}, error) { | ||
90 | + return nil, nil | ||
91 | +} | ||
92 | + | ||
93 | +// TODO 新增兑换现金活动 | ||
94 | +func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchangeCashActivityCommand *command.CreateExchangeCashActivityCommand) (interface{}, error) { | ||
95 | + return nil, nil | ||
96 | +} | ||
97 | + | ||
98 | +// TODO 返回兑换现金活动列表 | ||
99 | +func (cashPoolService *CashPoolService) ExchangeCashActivityList(listExchangeCashActivityQuery *query.ListExchangeCashActivityQuery) (interface{}, error) { | ||
100 | + return nil, nil | ||
101 | +} | ||
102 | + | ||
103 | +// TODO 移除兑换现金活动 | ||
104 | +func (cashPoolService *CashPoolService) RemoveExchangeCashActivity(removeExchangeCashActivityCommand *command.RemoveExchangeCashActivityCommand) (interface{}, error) { | ||
105 | + return nil, nil | ||
106 | +} | ||
107 | + | ||
108 | +// TODO 返回兑换现金活动 | ||
109 | +func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashActivityQuery *query.GetExchangeCashActivityQuery) (interface{}, error) { | ||
110 | + return nil, nil | ||
111 | +} | ||
112 | + | ||
113 | +// TODO 更新兑换现金活动 | ||
114 | +func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchangeCashActivityCommand *command.UpdateExchangeCashActivityCommand) (interface{}, error) { | ||
115 | + return nil, nil | ||
116 | +} | ||
117 | + | ||
118 | +// TODO 新建兑换现金人员 | ||
119 | +func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeCashPersonCommand *command.CreateExchangeCashPersonCommand) (interface{}, error) { | ||
120 | + return nil, nil | ||
121 | +} | ||
122 | + | ||
123 | +// TODO 返回兑换现金人员 | ||
124 | +func (cashPoolService *CashPoolService) GetExchangeCashPerson(getExchangeCashPersonQuery *query.GetExchangeCashPersonQuery) (interface{}, error) { | ||
125 | + return nil, nil | ||
126 | +} | ||
127 | + | ||
128 | +// TODO 返回兑换现金人员列表 | ||
129 | +func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashPersonQuery *query.ListExchangeCashPersonQuery) (interface{}, error) { | ||
130 | + return nil, nil | ||
131 | +} | ||
132 | + | ||
133 | +// TODO 移除兑换现金人员 | ||
134 | +func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeCashPersonCommand *command.RemoveExchangeCashPersonCommand) (interface{}, error) { | ||
135 | + return nil, nil | ||
136 | +} | ||
137 | + | ||
138 | +// TODO 更新兑换现金人员 | ||
139 | +func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeCashCommand *command.UpdateExchangeCashPersonCommand) (interface{}, error) { | ||
140 | + return nil, nil | ||
141 | +} | ||
142 | + | ||
143 | +// TODO 导入兑换现金人员 | ||
144 | + | ||
54 | func NewCashPoolService(options map[string]interface{}) *CashPoolService { | 145 | func NewCashPoolService(options map[string]interface{}) *CashPoolService { |
55 | newCashPoolService := &CashPoolService{} | 146 | newCashPoolService := &CashPoolService{} |
56 | return newCashPoolService | 147 | return newCashPoolService |
@@ -183,6 +183,11 @@ func (suMoneyService *SuMoneyService) SuMoneyTransactionRecordStatistics(suMoney | @@ -183,6 +183,11 @@ func (suMoneyService *SuMoneyService) SuMoneyTransactionRecordStatistics(suMoney | ||
183 | } | 183 | } |
184 | } | 184 | } |
185 | 185 | ||
186 | +// TODO 搜索素币流水 | ||
187 | +func (suMoneyService *SuMoneyService) SearchPersonSuMoneyTransaction(searchSuMoneyTransactionCommand *command.SearchSuMoneyTransactionCommand) (interface{}, error) { | ||
188 | + return nil, nil | ||
189 | +} | ||
190 | + | ||
186 | func NewSuMoneyService(options map[string]interface{}) *SuMoneyService { | 191 | func NewSuMoneyService(options map[string]interface{}) *SuMoneyService { |
187 | newSuMoneyService := &SuMoneyService{} | 192 | newSuMoneyService := &SuMoneyService{} |
188 | return newSuMoneyService | 193 | return newSuMoneyService |
@@ -7,5 +7,5 @@ import ( | @@ -7,5 +7,5 @@ import ( | ||
7 | 7 | ||
8 | type InputCashPoolService interface { | 8 | type InputCashPoolService interface { |
9 | coreDomain.DomainEventPublisher | 9 | coreDomain.DomainEventPublisher |
10 | - Input(companyId int64, operatorUid int64, cash float64) (*domain.CashPool, error) | 10 | + Input(companyId int64, operatorUid int64, cash float64, exchangedSuMoney float64, unExchangeSuMoney float64, exchangedCash float64) (*domain.CashPool, error) |
11 | } | 11 | } |
@@ -4,7 +4,6 @@ import ( | @@ -4,7 +4,6 @@ import ( | ||
4 | "fmt" | 4 | "fmt" |
5 | coreDomain "github.com/linmadan/egglib-go/core/domain" | 5 | coreDomain "github.com/linmadan/egglib-go/core/domain" |
6 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | 6 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" |
7 | - //"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory" | ||
8 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" | 7 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" |
9 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/repository" | 8 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/repository" |
10 | "time" | 9 | "time" |
@@ -15,7 +14,7 @@ type CashPoolService struct { | @@ -15,7 +14,7 @@ type CashPoolService struct { | ||
15 | transactionContext *pgTransaction.TransactionContext | 14 | transactionContext *pgTransaction.TransactionContext |
16 | } | 15 | } |
17 | 16 | ||
18 | -func (service *CashPoolService) Input(companyId int64, operatorUid int64, cash float64) (*domain.CashPool, error) { | 17 | +func (service *CashPoolService) Input(companyId int64, operatorUid int64, cash float64, systemUnExchangeSuMoney float64, systemExchangedSuMoney float64, systemExchangedCash float64) (*domain.CashPool, error) { |
19 | var cashPoolRepository domain.CashPoolRepository | 18 | var cashPoolRepository domain.CashPoolRepository |
20 | var employeeRepository domain.EmployeeRepository | 19 | var employeeRepository domain.EmployeeRepository |
21 | 20 | ||
@@ -25,35 +24,6 @@ func (service *CashPoolService) Input(companyId int64, operatorUid int64, cash f | @@ -25,35 +24,6 @@ func (service *CashPoolService) Input(companyId int64, operatorUid int64, cash f | ||
25 | employeeRepository = repository | 24 | employeeRepository = repository |
26 | } | 25 | } |
27 | 26 | ||
28 | - //transactionContext, err := factory.CreateTransactionContext(nil) | ||
29 | - // | ||
30 | - //var employeeDao *dao.EmployeeDao | ||
31 | - //if value, err := factory.CreateEmployeeDao(map[string]interface{}{ | ||
32 | - // "transactionContext": transactionContext, | ||
33 | - //}); err != nil { | ||
34 | - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
35 | - //} else { | ||
36 | - // employeeDao = value | ||
37 | - //} | ||
38 | - | ||
39 | - //var systemExchangedCash float64 | ||
40 | - //if value, err := employeeDao.CalculateSystemCash(companyId); err != nil { | ||
41 | - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
42 | - //} else { | ||
43 | - // systemExchangedCash = value | ||
44 | - //} | ||
45 | - | ||
46 | - //var ( | ||
47 | - // systemChangedSuMoney float64 | ||
48 | - // systemUnChangeSuMoney float64 | ||
49 | - //) | ||
50 | - //if value1, value2, err := employeeDao.CalculateSystemSuMoney(companyId); err != nil { | ||
51 | - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
52 | - //} else { | ||
53 | - // systemChangedSuMoney = value1 | ||
54 | - // systemUnChangeSuMoney = value2 | ||
55 | - //} | ||
56 | - | ||
57 | operator, err := employeeRepository.FindOne(map[string]interface{}{ | 27 | operator, err := employeeRepository.FindOne(map[string]interface{}{ |
58 | "uid": operatorUid, | 28 | "uid": operatorUid, |
59 | }) | 29 | }) |
@@ -77,11 +47,11 @@ func (service *CashPoolService) Input(companyId int64, operatorUid int64, cash f | @@ -77,11 +47,11 @@ func (service *CashPoolService) Input(companyId int64, operatorUid int64, cash f | ||
77 | cashPoolInfo := &domain.CashPool{ | 47 | cashPoolInfo := &domain.CashPool{ |
78 | CompanyId: companyId, | 48 | CompanyId: companyId, |
79 | Cash: cash, | 49 | Cash: cash, |
80 | - //ExchangedCash: systemExchangedCash, | 50 | + ExchangedCash: systemExchangedCash, |
81 | UnExchangeCash: currentCashPool.UnExchangeCash + cash, | 51 | UnExchangeCash: currentCashPool.UnExchangeCash + cash, |
82 | - //ExchangedSuMoney: systemChangedSuMoney, | ||
83 | - //UnExchangeSuMoney: systemUnChangeSuMoney, | ||
84 | - //Rate: systemExchangedCash / systemChangedSuMoney, | 52 | + ExchangedSuMoney: systemExchangedSuMoney, |
53 | + UnExchangeSuMoney: systemUnExchangeSuMoney, | ||
54 | + Rate: systemExchangedCash / systemExchangedSuMoney, | ||
85 | Operator: operator.EmployeeInfo, | 55 | Operator: operator.EmployeeInfo, |
86 | CreateTime: time.Now(), | 56 | CreateTime: time.Now(), |
87 | } | 57 | } |
@@ -17,14 +17,19 @@ type SuMoneyController struct { | @@ -17,14 +17,19 @@ type SuMoneyController struct { | ||
17 | func (controller *SuMoneyController) OperationSuMoney() { | 17 | func (controller *SuMoneyController) OperationSuMoney() { |
18 | suMoneyService := service.NewSuMoneyService(nil) | 18 | suMoneyService := service.NewSuMoneyService(nil) |
19 | operationSuMoneyCommand := &command.OperationSuMoneyCommand{} | 19 | operationSuMoneyCommand := &command.OperationSuMoneyCommand{} |
20 | + | ||
20 | json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), operationSuMoneyCommand) | 21 | json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), operationSuMoneyCommand) |
22 | + | ||
21 | data, err := suMoneyService.OperationSuMoney(operationSuMoneyCommand) | 23 | data, err := suMoneyService.OperationSuMoney(operationSuMoneyCommand) |
24 | + | ||
22 | var response utils.JsonResponse | 25 | var response utils.JsonResponse |
26 | + | ||
23 | if err != nil { | 27 | if err != nil { |
24 | response = utils.ResponseError(controller.Ctx, err) | 28 | response = utils.ResponseError(controller.Ctx, err) |
25 | } else { | 29 | } else { |
26 | response = utils.ResponseData(controller.Ctx, data) | 30 | response = utils.ResponseData(controller.Ctx, data) |
27 | } | 31 | } |
32 | + | ||
28 | controller.Data["json"] = response | 33 | controller.Data["json"] = response |
29 | controller.ServeJSON() | 34 | controller.ServeJSON() |
30 | } | 35 | } |
@@ -32,15 +37,20 @@ func (controller *SuMoneyController) OperationSuMoney() { | @@ -32,15 +37,20 @@ func (controller *SuMoneyController) OperationSuMoney() { | ||
32 | func (controller *SuMoneyController) GetSuMoneyTransactionRecord() { | 37 | func (controller *SuMoneyController) GetSuMoneyTransactionRecord() { |
33 | suMoneyService := service.NewSuMoneyService(nil) | 38 | suMoneyService := service.NewSuMoneyService(nil) |
34 | getSuMoneyTransactionRecordQuery := &query.GetSuMoneyTransactionRecordQuery{} | 39 | getSuMoneyTransactionRecordQuery := &query.GetSuMoneyTransactionRecordQuery{} |
40 | + | ||
35 | suMoneyTransactionRecordId, _ := controller.GetInt64(":suMoneyTransactionRecordId") | 41 | suMoneyTransactionRecordId, _ := controller.GetInt64(":suMoneyTransactionRecordId") |
36 | getSuMoneyTransactionRecordQuery.SuMoneyTransactionRecordId = suMoneyTransactionRecordId | 42 | getSuMoneyTransactionRecordQuery.SuMoneyTransactionRecordId = suMoneyTransactionRecordId |
43 | + | ||
37 | data, err := suMoneyService.GetSuMoneyTransactionRecord(getSuMoneyTransactionRecordQuery) | 44 | data, err := suMoneyService.GetSuMoneyTransactionRecord(getSuMoneyTransactionRecordQuery) |
45 | + | ||
38 | var response utils.JsonResponse | 46 | var response utils.JsonResponse |
47 | + | ||
39 | if err != nil { | 48 | if err != nil { |
40 | response = utils.ResponseError(controller.Ctx, err) | 49 | response = utils.ResponseError(controller.Ctx, err) |
41 | } else { | 50 | } else { |
42 | response = utils.ResponseData(controller.Ctx, data) | 51 | response = utils.ResponseData(controller.Ctx, data) |
43 | } | 52 | } |
53 | + | ||
44 | controller.Data["json"] = response | 54 | controller.Data["json"] = response |
45 | controller.ServeJSON() | 55 | controller.ServeJSON() |
46 | } | 56 | } |
@@ -48,14 +58,19 @@ func (controller *SuMoneyController) GetSuMoneyTransactionRecord() { | @@ -48,14 +58,19 @@ func (controller *SuMoneyController) GetSuMoneyTransactionRecord() { | ||
48 | func (controller *SuMoneyController) ExchangeSuMoney() { | 58 | func (controller *SuMoneyController) ExchangeSuMoney() { |
49 | suMoneyService := service.NewSuMoneyService(nil) | 59 | suMoneyService := service.NewSuMoneyService(nil) |
50 | exchangeSuMoneyCommand := &command.ExchangeSuMoneyCommand{} | 60 | exchangeSuMoneyCommand := &command.ExchangeSuMoneyCommand{} |
61 | + | ||
51 | json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), exchangeSuMoneyCommand) | 62 | json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), exchangeSuMoneyCommand) |
63 | + | ||
52 | data, err := suMoneyService.ExchangeSuMoney(exchangeSuMoneyCommand) | 64 | data, err := suMoneyService.ExchangeSuMoney(exchangeSuMoneyCommand) |
65 | + | ||
53 | var response utils.JsonResponse | 66 | var response utils.JsonResponse |
67 | + | ||
54 | if err != nil { | 68 | if err != nil { |
55 | response = utils.ResponseError(controller.Ctx, err) | 69 | response = utils.ResponseError(controller.Ctx, err) |
56 | } else { | 70 | } else { |
57 | response = utils.ResponseData(controller.Ctx, data) | 71 | response = utils.ResponseData(controller.Ctx, data) |
58 | } | 72 | } |
73 | + | ||
59 | controller.Data["json"] = response | 74 | controller.Data["json"] = response |
60 | controller.ServeJSON() | 75 | controller.ServeJSON() |
61 | } | 76 | } |
@@ -63,14 +78,19 @@ func (controller *SuMoneyController) ExchangeSuMoney() { | @@ -63,14 +78,19 @@ func (controller *SuMoneyController) ExchangeSuMoney() { | ||
63 | func (controller *SuMoneyController) SearchSuMoneyTransactionRecord() { | 78 | func (controller *SuMoneyController) SearchSuMoneyTransactionRecord() { |
64 | suMoneyService := service.NewSuMoneyService(nil) | 79 | suMoneyService := service.NewSuMoneyService(nil) |
65 | searchSuMoneyTransactionRecordCommand := &command.SearchSuMoneyTransactionRecordCommand{} | 80 | searchSuMoneyTransactionRecordCommand := &command.SearchSuMoneyTransactionRecordCommand{} |
81 | + | ||
66 | json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), searchSuMoneyTransactionRecordCommand) | 82 | json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), searchSuMoneyTransactionRecordCommand) |
83 | + | ||
67 | data, err := suMoneyService.SearchSuMoneyTransactionRecord(searchSuMoneyTransactionRecordCommand) | 84 | data, err := suMoneyService.SearchSuMoneyTransactionRecord(searchSuMoneyTransactionRecordCommand) |
85 | + | ||
68 | var response utils.JsonResponse | 86 | var response utils.JsonResponse |
87 | + | ||
69 | if err != nil { | 88 | if err != nil { |
70 | response = utils.ResponseError(controller.Ctx, err) | 89 | response = utils.ResponseError(controller.Ctx, err) |
71 | } else { | 90 | } else { |
72 | response = utils.ResponseData(controller.Ctx, data) | 91 | response = utils.ResponseData(controller.Ctx, data) |
73 | } | 92 | } |
93 | + | ||
74 | controller.Data["json"] = response | 94 | controller.Data["json"] = response |
75 | controller.ServeJSON() | 95 | controller.ServeJSON() |
76 | } | 96 | } |
@@ -78,112 +98,306 @@ func (controller *SuMoneyController) SearchSuMoneyTransactionRecord() { | @@ -78,112 +98,306 @@ func (controller *SuMoneyController) SearchSuMoneyTransactionRecord() { | ||
78 | func (controller *SuMoneyController) SuMoneyTransactionRecordStatistics() { | 98 | func (controller *SuMoneyController) SuMoneyTransactionRecordStatistics() { |
79 | suMoneyService := service.NewSuMoneyService(nil) | 99 | suMoneyService := service.NewSuMoneyService(nil) |
80 | suMoneyTransactionRecordStatisticsCommand := &command.SuMoneyTransactionRecordStatisticsCommand{} | 100 | suMoneyTransactionRecordStatisticsCommand := &command.SuMoneyTransactionRecordStatisticsCommand{} |
101 | + | ||
81 | json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), suMoneyTransactionRecordStatisticsCommand) | 102 | json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), suMoneyTransactionRecordStatisticsCommand) |
103 | + | ||
82 | data, err := suMoneyService.SuMoneyTransactionRecordStatistics(suMoneyTransactionRecordStatisticsCommand) | 104 | data, err := suMoneyService.SuMoneyTransactionRecordStatistics(suMoneyTransactionRecordStatisticsCommand) |
105 | + | ||
83 | var response utils.JsonResponse | 106 | var response utils.JsonResponse |
107 | + | ||
84 | if err != nil { | 108 | if err != nil { |
85 | response = utils.ResponseError(controller.Ctx, err) | 109 | response = utils.ResponseError(controller.Ctx, err) |
86 | } else { | 110 | } else { |
87 | response = utils.ResponseData(controller.Ctx, data) | 111 | response = utils.ResponseData(controller.Ctx, data) |
88 | } | 112 | } |
113 | + | ||
89 | controller.Data["json"] = response | 114 | controller.Data["json"] = response |
90 | controller.ServeJSON() | 115 | controller.ServeJSON() |
91 | } | 116 | } |
92 | 117 | ||
93 | -/** | ||
94 | - * 现金池投入 | ||
95 | - */ | 118 | +// 投入现金池 |
96 | func (controller *SuMoneyController) CashInput() { | 119 | func (controller *SuMoneyController) CashInput() { |
120 | + cashPoolService := service.NewCashPoolService(nil) | ||
121 | + createCashPoolCommand := &command.CreateCashPoolCommand{} | ||
122 | + | ||
123 | + json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), createCashPoolCommand) | ||
124 | + | ||
125 | + data, err := cashPoolService.OperationCashPool(createCashPoolCommand) | ||
126 | + | ||
127 | + var response utils.JsonResponse | ||
128 | + | ||
129 | + if err != nil { | ||
130 | + response = utils.ResponseError(controller.Ctx, err) | ||
131 | + } else { | ||
132 | + response = utils.ResponseData(controller.Ctx, data) | ||
133 | + } | ||
134 | + | ||
135 | + controller.Data["json"] = response | ||
136 | + controller.ServeJSON() | ||
137 | +} | ||
138 | + | ||
139 | +// 返回现金池 | ||
140 | +func (controller *SuMoneyController) CashPool() { | ||
141 | + cashPoolService := service.NewCashPoolService(nil) | ||
142 | + getCashPoolQuery := &query.GetCashPoolQuery{} | ||
143 | + | ||
144 | + json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), getCashPoolQuery) | ||
145 | + | ||
146 | + data, err := cashPoolService.CashPool(getCashPoolQuery) | ||
147 | + | ||
148 | + var response utils.JsonResponse | ||
149 | + | ||
150 | + if err != nil { | ||
151 | + response = utils.ResponseError(controller.Ctx, err) | ||
152 | + } else { | ||
153 | + response = utils.ResponseData(controller.Ctx, data) | ||
154 | + } | ||
97 | 155 | ||
156 | + controller.Data["json"] = response | ||
157 | + controller.ServeJSON() | ||
98 | } | 158 | } |
99 | 159 | ||
100 | -/** | ||
101 | - * 返回兑换活动列表 | ||
102 | - */ | 160 | +// 返回兑换活动列表 |
103 | func (controller *SuMoneyController) ListExchangeActivities () { | 161 | func (controller *SuMoneyController) ListExchangeActivities () { |
162 | + cashPoolService := service.NewCashPoolService(nil) | ||
163 | + listExchangeCashActivityQuery := &query.ListExchangeCashActivityQuery{} | ||
164 | + | ||
165 | + companyId, _ := controller.GetInt64("companyId") | ||
166 | + listExchangeCashActivityQuery.CompanyId = companyId | ||
167 | + | ||
168 | + exchangeCashActivityNameMatch := controller.GetString("activityNameMatch") | ||
169 | + listExchangeCashActivityQuery.ExchangeCashActivityNameMatch = exchangeCashActivityNameMatch | ||
170 | + | ||
171 | + offset, _ := controller.GetInt("offset") | ||
172 | + listExchangeCashActivityQuery.Offset = offset | ||
173 | + | ||
174 | + limit, _ := controller.GetInt("limit") | ||
175 | + listExchangeCashActivityQuery.Limit = limit | ||
176 | + | ||
177 | + data, err := cashPoolService.ListExchangeCashActivity(listExchangeCashActivityQuery) | ||
104 | 178 | ||
179 | + var response utils.JsonResponse | ||
180 | + | ||
181 | + if err != nil { | ||
182 | + response = utils.ResponseError(controller.Ctx, err) | ||
183 | + } else { | ||
184 | + response = utils.ResponseData(controller.Ctx, data) | ||
185 | + } | ||
186 | + | ||
187 | + controller.Data["json"] = response | ||
188 | + controller.ServeJSON() | ||
105 | } | 189 | } |
106 | 190 | ||
107 | -/** | ||
108 | - * 更新兑换活动信息 | ||
109 | - */ | 191 | +// 更新兑换活动信息 |
110 | func (controller *SuMoneyController) UpdateExchangeActivities () { | 192 | func (controller *SuMoneyController) UpdateExchangeActivities () { |
193 | + cashPoolService := service.NewCashPoolService(nil) | ||
194 | + updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{} | ||
195 | + | ||
196 | + json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), updateExchangeCashActivityCommand) | ||
111 | 197 | ||
198 | + activityId, _ := controller.GetInt64(":activityId") | ||
199 | + updateExchangeCashActivityCommand.ExchangeCashActivityId = activityId | ||
200 | + | ||
201 | + data, err := cashPoolService.UpdateExchangeCashActivity(updateExchangeCashActivityCommand) | ||
202 | + | ||
203 | + var response utils.JsonResponse | ||
204 | + | ||
205 | + if err != nil { | ||
206 | + response = utils.ResponseError(controller.Ctx, err) | ||
207 | + } else { | ||
208 | + response = utils.ResponseData(controller.Ctx, data) | ||
209 | + } | ||
210 | + | ||
211 | + controller.Data["json"] = response | ||
212 | + controller.ServeJSON() | ||
112 | } | 213 | } |
113 | 214 | ||
114 | -/** | ||
115 | - * 新增兑换活动 | ||
116 | - */ | 215 | +// 新增兑换活动 |
117 | func (controller *SuMoneyController) CreateExchangeActivities () { | 216 | func (controller *SuMoneyController) CreateExchangeActivities () { |
217 | + cashPoolService := service.NewCashPoolService(nil) | ||
218 | + createExchangeCashActivityCommand := &command.CreateExchangeCashActivityCommand{} | ||
219 | + | ||
220 | + json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), createExchangeCashActivityCommand) | ||
221 | + | ||
222 | + data, err := cashPoolService.CreateExchangeCashActivity(createExchangeCashActivityCommand) | ||
223 | + | ||
224 | + var response utils.JsonResponse | ||
225 | + | ||
226 | + if err != nil { | ||
227 | + response = utils.ResponseError(controller.Ctx, err) | ||
228 | + } else { | ||
229 | + response = utils.ResponseData(controller.Ctx, data) | ||
230 | + } | ||
118 | 231 | ||
232 | + controller.Data["json"] = response | ||
233 | + controller.ServeJSON() | ||
119 | } | 234 | } |
120 | 235 | ||
121 | -/** | ||
122 | - * 删除兑换活动 | ||
123 | - */ | 236 | +// 移除兑换活动 |
124 | func (controller *SuMoneyController) RemoveExchangeActivities () { | 237 | func (controller *SuMoneyController) RemoveExchangeActivities () { |
238 | + cashPoolService := service.NewCashPoolService(nil) | ||
239 | + removeExchangeCashActivityCommand := &command.RemoveExchangeCashActivityCommand{} | ||
125 | 240 | ||
126 | -} | 241 | + activityId, _ := controller.GetInt64(":activityId") |
242 | + removeExchangeCashActivityCommand. ExchangeCashActivityId = activityId | ||
243 | + | ||
244 | + data, err := cashPoolService.RemoveExchangeCashActivity(removeExchangeCashActivityCommand) | ||
245 | + | ||
246 | + var response utils.JsonResponse | ||
127 | 247 | ||
128 | -/** | ||
129 | - * 搜索兑换素币活动 | ||
130 | - */ | ||
131 | -func (controller *SuMoneyController) searchExchangeActivities () { | 248 | + if err != nil { |
249 | + response = utils.ResponseError(controller.Ctx, err) | ||
250 | + } else { | ||
251 | + response = utils.ResponseData(controller.Ctx, data) | ||
252 | + } | ||
132 | 253 | ||
254 | + controller.Data["json"] = response | ||
255 | + controller.ServeJSON() | ||
133 | } | 256 | } |
134 | 257 | ||
135 | -/** | ||
136 | - * 兑换活动数据统计 | ||
137 | - */ | ||
138 | -func (controller *SuMoneyController) exchangeActivitiesStatistics () { | 258 | +// 返回兑换现金活动 |
259 | +func (controller *SuMoneyController) GerExchangeCashActivity () { | ||
260 | + cashPoolService := service.NewCashPoolService(nil) | ||
261 | + getExchangeCashActivityQuery := &query.GetExchangeCashActivityQuery{} | ||
262 | + | ||
263 | + activityId, _ := controller.GetInt64(":activityId") | ||
264 | + getExchangeCashActivityQuery.ExchangeCashActivityId = activityId | ||
265 | + | ||
266 | + data, err := cashPoolService.GetExchangeCashActivity(getExchangeCashActivityQuery) | ||
267 | + | ||
268 | + var response utils.JsonResponse | ||
269 | + | ||
270 | + if err != nil { | ||
271 | + response = utils.ResponseError(controller.Ctx, err) | ||
272 | + } else { | ||
273 | + response = utils.ResponseData(controller.Ctx, data) | ||
274 | + } | ||
139 | 275 | ||
276 | + controller.Data["json"] = response | ||
277 | + controller.ServeJSON() | ||
140 | } | 278 | } |
141 | 279 | ||
142 | -/** | ||
143 | - * 获取素币兑换清单 | ||
144 | - */ | 280 | +// 返回兑换现金人员列表 |
145 | func (controller *SuMoneyController) ListExchangeList () { | 281 | func (controller *SuMoneyController) ListExchangeList () { |
282 | + cashPoolService := service.NewCashPoolService(nil) | ||
283 | + listExchangeCashListQuery := &query.ListExchangeCashPersonQuery{} | ||
284 | + | ||
285 | + activityId, _ := controller.GetInt64("activityId") | ||
286 | + listExchangeCashListQuery.ExchangeCashActivityId = activityId | ||
287 | + | ||
288 | + exchangeCashPersonNameMatch := controller.GetString("personNameMatch") | ||
289 | + listExchangeCashListQuery.ExchangeCashPersonNameMatch = exchangeCashPersonNameMatch | ||
290 | + | ||
291 | + offset, _ := controller.GetInt("offset") | ||
292 | + listExchangeCashListQuery.Offset = offset | ||
293 | + | ||
294 | + limit, _ := controller.GetInt("limit") | ||
295 | + listExchangeCashListQuery.Limit = limit | ||
296 | + | ||
297 | + data, err := cashPoolService.ListExchangeCashPerson(listExchangeCashListQuery) | ||
298 | + | ||
299 | + var response utils.JsonResponse | ||
300 | + | ||
301 | + if err != nil { | ||
302 | + response = utils.ResponseError(controller.Ctx, err) | ||
303 | + } else { | ||
304 | + response = utils.ResponseData(controller.Ctx, data) | ||
305 | + } | ||
146 | 306 | ||
307 | + controller.Data["json"] = response | ||
308 | + controller.ServeJSON() | ||
147 | } | 309 | } |
148 | 310 | ||
149 | -/** | ||
150 | - * 新增素币兑换清单 | ||
151 | - */ | 311 | +// 新增兑换现金人员 |
152 | func (controller *SuMoneyController) CreateExchangeList () { | 312 | func (controller *SuMoneyController) CreateExchangeList () { |
313 | + cashPoolService := service.NewCashPoolService(nil) | ||
314 | + createExchangeCashPersonCommand := &command.CreateExchangeCashPersonCommand{} | ||
153 | 315 | ||
316 | + json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), createExchangeCashPersonCommand) | ||
317 | + | ||
318 | + data, err := cashPoolService.CreateExchangeCashPerson(createExchangeCashPersonCommand) | ||
319 | + | ||
320 | + var response utils.JsonResponse | ||
321 | + | ||
322 | + if err != nil { | ||
323 | + response = utils.ResponseError(controller.Ctx, err) | ||
324 | + } else { | ||
325 | + response = utils.ResponseData(controller.Ctx, data) | ||
326 | + } | ||
327 | + | ||
328 | + controller.Data["json"] = response | ||
329 | + controller.ServeJSON() | ||
154 | } | 330 | } |
155 | 331 | ||
156 | -/** | ||
157 | - * 更新素币兑换清单 | ||
158 | - */ | 332 | +// 更新兑换现金人员 |
159 | func (controller *SuMoneyController) UpdateExchangeList () { | 333 | func (controller *SuMoneyController) UpdateExchangeList () { |
334 | + cashPoolService := service.NewCashPoolService(nil) | ||
335 | + updateExchangeCashPersonCommand := &command.UpdateExchangeCashPersonCommand{} | ||
336 | + | ||
337 | + json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), updateExchangeCashPersonCommand) | ||
338 | + | ||
339 | + personId, _ := controller.GetInt64(":personId") | ||
340 | + updateExchangeCashPersonCommand. ExchangeCashPersonId = personId | ||
341 | + | ||
342 | + data, err := cashPoolService.UpdateExchangeCashPerson(updateExchangeCashPersonCommand) | ||
343 | + | ||
344 | + var response utils.JsonResponse | ||
160 | 345 | ||
346 | + if err != nil { | ||
347 | + response = utils.ResponseError(controller.Ctx, err) | ||
348 | + } else { | ||
349 | + response = utils.ResponseData(controller.Ctx, data) | ||
350 | + } | ||
351 | + | ||
352 | + controller.Data["json"] = response | ||
353 | + controller.ServeJSON() | ||
161 | } | 354 | } |
162 | 355 | ||
163 | -/** | ||
164 | - * 删除素币兑换清单 | ||
165 | - */ | 356 | +// 移除兑换现金人员 |
166 | func (controller *SuMoneyController) RemoveExchangeList () { | 357 | func (controller *SuMoneyController) RemoveExchangeList () { |
358 | + cashPoolService := service.NewCashPoolService(nil) | ||
359 | + removeExchangeCashPersonCommand := &command.RemoveExchangeCashPersonCommand{} | ||
167 | 360 | ||
168 | -} | 361 | + personId, _ := controller.GetInt64(":personId") |
362 | + removeExchangeCashPersonCommand.ExchangeCashPersonId = personId | ||
363 | + | ||
364 | + data, err := cashPoolService.RemoveExchangeCashPerson(removeExchangeCashPersonCommand) | ||
169 | 365 | ||
170 | -/** | ||
171 | - * 搜索素币兑换清单 | ||
172 | - */ | ||
173 | -func (controller *SuMoneyController) searchExchangeList () { | 366 | + var response utils.JsonResponse |
174 | 367 | ||
368 | + if err != nil { | ||
369 | + response = utils.ResponseError(controller.Ctx, err) | ||
370 | + } else { | ||
371 | + response = utils.ResponseData(controller.Ctx, data) | ||
372 | + } | ||
373 | + | ||
374 | + controller.Data["json"] = response | ||
375 | + controller.ServeJSON() | ||
175 | } | 376 | } |
176 | 377 | ||
177 | -/** | ||
178 | - * 导出素币兑换清单 | ||
179 | - */ | ||
180 | -func (controller *SuMoneyController) ExportExchangeList () { | 378 | +// 返回素币兑换人员 |
379 | +func (controller *SuMoneyController) GetExchangeCashPerson () { | ||
380 | + cashPoolService := service.NewCashPoolService(nil) | ||
381 | + getExchangeCashPersonQuery := &query.GetExchangeCashPersonQuery{} | ||
382 | + | ||
383 | + personId, _ := controller.GetInt64(":personId") | ||
384 | + getExchangeCashPersonQuery.ExchangeCashPersonId = personId | ||
385 | + | ||
386 | + data, err := cashPoolService.GetExchangeCashPerson(getExchangeCashPersonQuery) | ||
181 | 387 | ||
388 | + var response utils.JsonResponse | ||
389 | + | ||
390 | + if err != nil { | ||
391 | + response = utils.ResponseError(controller.Ctx, err) | ||
392 | + } else { | ||
393 | + response = utils.ResponseData(controller.Ctx, data) | ||
394 | + } | ||
395 | + | ||
396 | + controller.Data["json"] = response | ||
397 | + controller.ServeJSON() | ||
182 | } | 398 | } |
183 | 399 | ||
184 | -/** | ||
185 | - * 导入素币兑换清单 | ||
186 | - */ | 400 | +// TODO 导入素币兑换清单 |
187 | func (controller *SuMoneyController) ImportExchangeList () { | 401 | func (controller *SuMoneyController) ImportExchangeList () { |
188 | - | 402 | + |
189 | } | 403 | } |
@@ -7,24 +7,28 @@ import ( | @@ -7,24 +7,28 @@ import ( | ||
7 | 7 | ||
8 | func init() { | 8 | func init() { |
9 | /**********************************************素币流水******************************************/ | 9 | /**********************************************素币流水******************************************/ |
10 | - beego.Router("/su-money/operation", &controllers.SuMoneyController{}, "Post:OperationSuMoney") | ||
11 | - beego.Router("/su-money/su-money-transaction-records/:suMoneyTransactionRecordId", &controllers.SuMoneyController{}, "Get:GetSuMoneyTransactionRecord") | ||
12 | - beego.Router("/su-money/exchange", &controllers.SuMoneyController{}, "Post:ExchangeSuMoney") | ||
13 | - beego.Router("/su-money/search-su-money-transaction-record", &controllers.SuMoneyController{}, "Post:SearchSuMoneyTransactionRecord") | ||
14 | - beego.Router("/su-money/su-money-transaction-record-statistics", &controllers.SuMoneyController{}, "Post:SuMoneyTransactionRecordStatistics") | 10 | + beego.Router("/su-money/operation", &controllers.SuMoneyController{}, "Post:OperationSuMoney") // 操作素币(增加,扣除,兑换) |
11 | + beego.Router("/su-money/su-money-transaction-records/:suMoneyTransactionRecordId", &controllers.SuMoneyController{}, "Get:GetSuMoneyTransactionRecord") // 返回素币事务记录 | ||
12 | + beego.Router("/su-money/exchange", &controllers.SuMoneyController{}, "Post:ExchangeSuMoney") // 兑换素币 | ||
13 | + beego.Router("/su-money/search-su-money-transaction-record", &controllers.SuMoneyController{}, "Post:SearchSuMoneyTransactionRecord") // 搜索素币事务记录 | ||
14 | + beego.Router("/su-money/su-money-transaction-record-statistics", &controllers.SuMoneyController{}, "Post:SuMoneyTransactionRecordStatistics") // 返回素币事务记录统计 | ||
15 | 15 | ||
16 | /**********************************************现金池*******************************************/ | 16 | /**********************************************现金池*******************************************/ |
17 | - beego.Router("/cash-pool/input", &controllers.SuMoneyController{}, "POST:CashInput") // 现金池投入 | 17 | + beego.Router("/cash-pool/input", &controllers.SuMoneyController{}, "POST:CashInput") // 现金池投入 |
18 | + beego.Router("/cash-pool/cash-pool-statistics", &controllers.SuMoneyController{}, "GET:CashPool") // 返回现金池统计 | ||
18 | 19 | ||
19 | - beego.Router("/cash-pool/", &controllers.SuMoneyController{}, "GET:ListExchangeActivities") // 返回兑换活动列表 | ||
20 | - beego.Router("/cash-pool/:activityId", &controllers.SuMoneyController{}, "PUT:UpdateExchangeActivities") // 编辑兑换活动 | ||
21 | - beego.Router("/cash-pool/", &controllers.SuMoneyController{}, "POST:CreateExchangeActivities") // 新增兑换活动 | ||
22 | - beego.Router("/cash-pool/:activityId", &controllers.SuMoneyController{}, "DELETE:RemoveExchangeActivities") // 删除兑换活动 | 20 | + beego.Router("/cash-pool/activity/", &controllers.SuMoneyController{}, "GET:ListExchangeActivities") // 返回兑换活动列表 |
21 | + beego.Router("/cash-pool/activity/:activityId", &controllers.SuMoneyController{}, "GET:ListExchangeActivities") // 返回兑换活动 | ||
22 | + beego.Router("/cash-pool/activity/:activityId", &controllers.SuMoneyController{}, "PUT:UpdateExchangeActivities") // 编辑兑换活动 | ||
23 | + beego.Router("/cash-pool/activity", &controllers.SuMoneyController{}, "POST:CreateExchangeActivities") // 新增兑换活动 | ||
24 | + beego.Router("/cash-pool/activity/:activityId", &controllers.SuMoneyController{}, "DELETE:RemoveExchangeActivities") // 删除兑换活动 | ||
25 | + //beego.Router("/cash-pool/activity/search-exchange-cash-activity", &controllers.SuMoneyController{}, "POST:SearchExchangeCashActivity") // 搜索兑换现金活动 | ||
23 | 26 | ||
24 | - beego.Router("/cash-pool/exchange-list", &controllers.SuMoneyController{}, "GET:ListExchangeList") // 返回素币兑换清单 | ||
25 | - beego.Router("/cash-pool/exchange-list", &controllers.SuMoneyController{}, "POST:CreateExchangeList") // 新增素币兑换清单 | ||
26 | - beego.Router("/cash-pool/exchange-list/:personId", &controllers.SuMoneyController{}, "PUT:UpdateExchangeList") // 编辑素币兑换清单 | ||
27 | - beego.Router("/cash-pool/exchange-list/:personId", &controllers.SuMoneyController{}, "DELETE:RemoveExchangeList") // 删除素币兑换清单 | ||
28 | - beego.Router("/cash-pool/exchange-list/export", &controllers.SuMoneyController{}, "POST:ExportExchangeList") // 导出素币兑换清单 | ||
29 | - beego.Router("/cash-pool/exchange-list/import", &controllers.SuMoneyController{}, "POST:ImportExchangeList") // 导入素币兑换清单 | 27 | + beego.Router("/cash-pool/activity/exchange-list/", &controllers.SuMoneyController{}, "GET:ListExchangeList") // 返回素币兑换清单 |
28 | + beego.Router("/cash-pool/activity/exchange-list/:personId", &controllers.SuMoneyController{}, "GET:GetExchangeCashPerson") // 返回素币兑换人员 | ||
29 | + beego.Router("/cash-pool/activity/exchange-list", &controllers.SuMoneyController{}, "POST:CreateExchangeList") // 新增素币兑换清单 | ||
30 | + beego.Router("/cash-pool/activity/exchange-list/:personId", &controllers.SuMoneyController{}, "PUT:UpdateExchangeList") // 编辑素币兑换清单 | ||
31 | + beego.Router("/cash-pool/activity/exchange-list/:personId", &controllers.SuMoneyController{}, "DELETE:RemoveExchangeList") // 删除素币兑换清单 | ||
32 | + beego.Router("/cash-pool/activity/exchange-list/import", &controllers.SuMoneyController{}, "POST:ImportExchangeList") // 导入素币兑换清单 | ||
33 | + //beego.Router("/cash-pool/activity/exchange-list/search-exchange-cash-person", &controllers.SuMoneyController{}, "POST:SearchExchangeCashPerson") // 搜索兑换现金人员 | ||
30 | } | 34 | } |
-
请 注册 或 登录 后发表评论