作者 陈志颖

feat:完成素币管理->现金池控制器

... ... @@ -8,7 +8,7 @@ import (
)
// 创建现金兑换活动
type CreateExchangeActivityCommand struct {
type CreateExchangeCashActivityCommand struct {
CompanyId int64 `json:"companyId" valid:"Required"` // 公司id
ExchangeActivityName string `json:"exchangeActivityName"` // 活动名称
CashPool *domain.CashPool `json:"cashPool"` // 兑换现金活动关联的现金池,最新的现金池
... ... @@ -20,7 +20,7 @@ type CreateExchangeActivityCommand struct {
ExchangeCashPeople []*domain.ExchangeCashPersonList `json:"exchangeList"` // 兑换活动清单
}
func (createExchangeActivityCommand *CreateExchangeActivityCommand) ValidateCommand() error {
func (createExchangeActivityCommand *CreateExchangeCashActivityCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(createExchangeActivityCommand)
if err != nil {
... ...
... ... @@ -7,7 +7,6 @@ import (
// 移除兑换现金人员
type RemoveExchangeCashPersonCommand struct {
ExchangeCashActivityId int64 `json:"exchangeCashActivityId" valid:"Required"` // 兑换现金人员参与的活动ID
ExchangeCashPersonId int64 `json:"exchangeCashId" valid:"Required"` // 兑换现金人员编号
}
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type SearchExchangeCashActivityCommand struct {
ExchangeCashActivityName string `json:"exchangeCashActivityName"` // 兑换现金活动名称
}
func (searchExchangeCashActivityCommand *SearchExchangeCashActivityCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(searchExchangeCashActivityCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type SearchExchangeCashPersonCommand struct {
ExchangeCashPersonName string `json:"exchangeCashPersonName"` // 兑换素币人员名称
}
func (searchExchangeCashPersonCommand *SearchExchangeCashPersonCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(searchExchangeCashPersonCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
\ No newline at end of file
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type SearchSuMoneyTransactionCommand struct {
EmployeeName string `json:"employeeName"` // 员工姓名
}
func (searchSuMoneyTransactionCommand *SearchSuMoneyTransactionCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(searchSuMoneyTransactionCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
... ... @@ -7,7 +7,7 @@ import (
"time"
)
type UpdateExchangeCashActivity struct {
type UpdateExchangeCashActivityCommand struct {
ExchangeCashActivityId int64 `json:"exchangeCashActivityId"` // 兑换现金活动id
CompanyId int64 `json:"companyId" valid:"Required"` // 公司id
ExchangeActivityName string `json:"exchangeActivityName"` // 活动名称
... ... @@ -19,7 +19,7 @@ type UpdateExchangeCashActivity struct {
ExchangeCashPeople []*domain.ExchangeCashPersonList `json:"exchangeCashPeople"` // 兑换活动清单
}
func (updateExchangeCashActivity *UpdateExchangeCashActivity) ValidateCommand() error {
func (updateExchangeCashActivity *UpdateExchangeCashActivityCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(updateExchangeCashActivity)
if err != nil {
... ...
... ... @@ -7,7 +7,6 @@ import (
type UpdateExchangeCashPersonCommand struct {
ExchangeCashPersonId int64 `json:"exchangeCashPersonId" valid:"Required"` // 兑换现金人员编号
ExchangeCashActivityId int64 `json:"exchangeCashActivityId" valid:"Required"` // 参与的兑换现金活动id
ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换的素币(需要和当前的已兑换素币进行比较,少于当前已兑换素币则生成一条扣除素币记录,大于当前已兑换素币则生成一条增加素币记录)
ExchangedCash float64 `json:"exchangedCash"` // 已兑换的现金
}
... ...
... ... @@ -8,6 +8,9 @@ import (
// 获取兑换现金活动列表
type ListExchangeCashActivityQuery struct {
CompanyId int64 `json:"companyId"` // 公司id
ExchangeCashActivityNameMatch string `json:"exchangeCashActivityNameMatch,omitempty"`
Offset int `json:"offset,omitempty"`
Limit int `json:"limit,omitempty"`
}
func (listExchangeCashActivityQuery *ListExchangeCashActivityQuery) ValidateQuery() error {
... ...
... ... @@ -8,6 +8,9 @@ import (
// 获取兑换活动兑换清单
type ListExchangeCashPersonQuery struct {
ExchangeCashActivityId int64 `json:"exchangeCashActivityId"` // 兑换现金活动id
ExchangeCashPersonNameMatch string `json:"exchangeCashPersonNameMatch,omitempty"` // 兑换活动名称匹配
Offset int `json:"offset,omitempty"` // 查询偏离量
Limit int `json:"limit,omitempty"` // 查询限制
}
func (listExchangeCashPersonQuery *ListExchangeCashPersonQuery) ValidateQuery() error {
... ...
... ... @@ -4,15 +4,17 @@ import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/command"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/query"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/service"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"
)
// 现金池服务
type CashPoolService struct {
}
// 操作现金池
func (cashService *CashPoolService) OperationCashPool(createCashPoolCommand *command.CreateCashPoolCommand) (interface{}, error) {
// 投入现金
func (cashPoolService *CashPoolService) OperationCashPool(createCashPoolCommand *command.CreateCashPoolCommand) (interface{}, error) {
if err := createCashPoolCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
... ... @@ -31,17 +33,44 @@ func (cashService *CashPoolService) OperationCashPool(createCashPoolCommand *com
transactionContext.RollbackTransaction()
}()
var cashPoolService service.InputCashPoolService
var employeeDao *dao.EmployeeDao
if value, err := factory.CreateEmployeeDao(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
employeeDao = value
}
var systemExchangedCash float64
if value, err := employeeDao.CalculateSystemCash(createCashPoolCommand.CompanyId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
systemExchangedCash = value
}
var (
systemChangedSuMoney float64
systemUnChangeSuMoney float64
)
if value1, value2, err := employeeDao.CalculateSystemSuMoney(createCashPoolCommand.CompanyId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
systemChangedSuMoney = value1
systemUnChangeSuMoney = value2
}
var inputCashPoolService service.InputCashPoolService
if value, err := factory.CreateInputCashPoolService(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cashPoolService = value
inputCashPoolService = value
}
if task, err := cashPoolService.Input(createCashPoolCommand.CompanyId, createCashPoolCommand.Operator, createCashPoolCommand.Cash); err != nil {
if task, err := inputCashPoolService.Input(createCashPoolCommand.CompanyId, createCashPoolCommand.Operator, createCashPoolCommand.Cash, systemChangedSuMoney, systemUnChangeSuMoney, systemExchangedCash); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
... ... @@ -51,6 +80,68 @@ func (cashService *CashPoolService) OperationCashPool(createCashPoolCommand *com
}
}
// TODO 返回现金池
func (cashPoolService *CashPoolService) CashPool(getCashPoolQuery *query.GetCashPoolQuery) (interface{}, error) {
return nil, nil
}
// TODO 返回兑换现金活动
func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCashActivityCommand *query.ListExchangeCashActivityQuery) (interface{}, error) {
return nil, nil
}
// TODO 新增兑换现金活动
func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchangeCashActivityCommand *command.CreateExchangeCashActivityCommand) (interface{}, error) {
return nil, nil
}
// TODO 返回兑换现金活动列表
func (cashPoolService *CashPoolService) ExchangeCashActivityList(listExchangeCashActivityQuery *query.ListExchangeCashActivityQuery) (interface{}, error) {
return nil, nil
}
// TODO 移除兑换现金活动
func (cashPoolService *CashPoolService) RemoveExchangeCashActivity(removeExchangeCashActivityCommand *command.RemoveExchangeCashActivityCommand) (interface{}, error) {
return nil, nil
}
// TODO 返回兑换现金活动
func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashActivityQuery *query.GetExchangeCashActivityQuery) (interface{}, error) {
return nil, nil
}
// TODO 更新兑换现金活动
func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchangeCashActivityCommand *command.UpdateExchangeCashActivityCommand) (interface{}, error) {
return nil, nil
}
// TODO 新建兑换现金人员
func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeCashPersonCommand *command.CreateExchangeCashPersonCommand) (interface{}, error) {
return nil, nil
}
// TODO 返回兑换现金人员
func (cashPoolService *CashPoolService) GetExchangeCashPerson(getExchangeCashPersonQuery *query.GetExchangeCashPersonQuery) (interface{}, error) {
return nil, nil
}
// TODO 返回兑换现金人员列表
func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashPersonQuery *query.ListExchangeCashPersonQuery) (interface{}, error) {
return nil, nil
}
// TODO 移除兑换现金人员
func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeCashPersonCommand *command.RemoveExchangeCashPersonCommand) (interface{}, error) {
return nil, nil
}
// TODO 更新兑换现金人员
func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeCashCommand *command.UpdateExchangeCashPersonCommand) (interface{}, error) {
return nil, nil
}
// TODO 导入兑换现金人员
func NewCashPoolService(options map[string]interface{}) *CashPoolService {
newCashPoolService := &CashPoolService{}
return newCashPoolService
... ...
... ... @@ -183,6 +183,11 @@ func (suMoneyService *SuMoneyService) SuMoneyTransactionRecordStatistics(suMoney
}
}
// TODO 搜索素币流水
func (suMoneyService *SuMoneyService) SearchPersonSuMoneyTransaction(searchSuMoneyTransactionCommand *command.SearchSuMoneyTransactionCommand) (interface{}, error) {
return nil, nil
}
func NewSuMoneyService(options map[string]interface{}) *SuMoneyService {
newSuMoneyService := &SuMoneyService{}
return newSuMoneyService
... ...
... ... @@ -7,5 +7,5 @@ import (
type InputCashPoolService interface {
coreDomain.DomainEventPublisher
Input(companyId int64, operatorUid int64, cash float64) (*domain.CashPool, error)
Input(companyId int64, operatorUid int64, cash float64, exchangedSuMoney float64, unExchangeSuMoney float64, exchangedCash float64) (*domain.CashPool, error)
}
... ...
... ... @@ -4,7 +4,6 @@ import (
"fmt"
coreDomain "github.com/linmadan/egglib-go/core/domain"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
//"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/repository"
"time"
... ... @@ -15,7 +14,7 @@ type CashPoolService struct {
transactionContext *pgTransaction.TransactionContext
}
func (service *CashPoolService) Input(companyId int64, operatorUid int64, cash float64) (*domain.CashPool, error) {
func (service *CashPoolService) Input(companyId int64, operatorUid int64, cash float64, systemUnExchangeSuMoney float64, systemExchangedSuMoney float64, systemExchangedCash float64) (*domain.CashPool, error) {
var cashPoolRepository domain.CashPoolRepository
var employeeRepository domain.EmployeeRepository
... ... @@ -25,35 +24,6 @@ func (service *CashPoolService) Input(companyId int64, operatorUid int64, cash f
employeeRepository = repository
}
//transactionContext, err := factory.CreateTransactionContext(nil)
//
//var employeeDao *dao.EmployeeDao
//if value, err := factory.CreateEmployeeDao(map[string]interface{}{
// "transactionContext": transactionContext,
//}); err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
//} else {
// employeeDao = value
//}
//var systemExchangedCash float64
//if value, err := employeeDao.CalculateSystemCash(companyId); err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
//} else {
// systemExchangedCash = value
//}
//var (
// systemChangedSuMoney float64
// systemUnChangeSuMoney float64
//)
//if value1, value2, err := employeeDao.CalculateSystemSuMoney(companyId); err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
//} else {
// systemChangedSuMoney = value1
// systemUnChangeSuMoney = value2
//}
operator, err := employeeRepository.FindOne(map[string]interface{}{
"uid": operatorUid,
})
... ... @@ -77,11 +47,11 @@ func (service *CashPoolService) Input(companyId int64, operatorUid int64, cash f
cashPoolInfo := &domain.CashPool{
CompanyId: companyId,
Cash: cash,
//ExchangedCash: systemExchangedCash,
ExchangedCash: systemExchangedCash,
UnExchangeCash: currentCashPool.UnExchangeCash + cash,
//ExchangedSuMoney: systemChangedSuMoney,
//UnExchangeSuMoney: systemUnChangeSuMoney,
//Rate: systemExchangedCash / systemChangedSuMoney,
ExchangedSuMoney: systemExchangedSuMoney,
UnExchangeSuMoney: systemUnExchangeSuMoney,
Rate: systemExchangedCash / systemExchangedSuMoney,
Operator: operator.EmployeeInfo,
CreateTime: time.Now(),
}
... ...
... ... @@ -17,14 +17,19 @@ type SuMoneyController struct {
func (controller *SuMoneyController) OperationSuMoney() {
suMoneyService := service.NewSuMoneyService(nil)
operationSuMoneyCommand := &command.OperationSuMoneyCommand{}
json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), operationSuMoneyCommand)
data, err := suMoneyService.OperationSuMoney(operationSuMoneyCommand)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
... ... @@ -32,15 +37,20 @@ func (controller *SuMoneyController) OperationSuMoney() {
func (controller *SuMoneyController) GetSuMoneyTransactionRecord() {
suMoneyService := service.NewSuMoneyService(nil)
getSuMoneyTransactionRecordQuery := &query.GetSuMoneyTransactionRecordQuery{}
suMoneyTransactionRecordId, _ := controller.GetInt64(":suMoneyTransactionRecordId")
getSuMoneyTransactionRecordQuery.SuMoneyTransactionRecordId = suMoneyTransactionRecordId
data, err := suMoneyService.GetSuMoneyTransactionRecord(getSuMoneyTransactionRecordQuery)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
... ... @@ -48,14 +58,19 @@ func (controller *SuMoneyController) GetSuMoneyTransactionRecord() {
func (controller *SuMoneyController) ExchangeSuMoney() {
suMoneyService := service.NewSuMoneyService(nil)
exchangeSuMoneyCommand := &command.ExchangeSuMoneyCommand{}
json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), exchangeSuMoneyCommand)
data, err := suMoneyService.ExchangeSuMoney(exchangeSuMoneyCommand)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
... ... @@ -63,14 +78,19 @@ func (controller *SuMoneyController) ExchangeSuMoney() {
func (controller *SuMoneyController) SearchSuMoneyTransactionRecord() {
suMoneyService := service.NewSuMoneyService(nil)
searchSuMoneyTransactionRecordCommand := &command.SearchSuMoneyTransactionRecordCommand{}
json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), searchSuMoneyTransactionRecordCommand)
data, err := suMoneyService.SearchSuMoneyTransactionRecord(searchSuMoneyTransactionRecordCommand)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
... ... @@ -78,112 +98,306 @@ func (controller *SuMoneyController) SearchSuMoneyTransactionRecord() {
func (controller *SuMoneyController) SuMoneyTransactionRecordStatistics() {
suMoneyService := service.NewSuMoneyService(nil)
suMoneyTransactionRecordStatisticsCommand := &command.SuMoneyTransactionRecordStatisticsCommand{}
json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), suMoneyTransactionRecordStatisticsCommand)
data, err := suMoneyService.SuMoneyTransactionRecordStatistics(suMoneyTransactionRecordStatisticsCommand)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
/**
* 现金池投入
*/
// 投入现金池
func (controller *SuMoneyController) CashInput() {
cashPoolService := service.NewCashPoolService(nil)
createCashPoolCommand := &command.CreateCashPoolCommand{}
json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), createCashPoolCommand)
data, err := cashPoolService.OperationCashPool(createCashPoolCommand)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
/**
* 返回兑换活动列表
*/
// 返回现金池
func (controller *SuMoneyController) CashPool() {
cashPoolService := service.NewCashPoolService(nil)
getCashPoolQuery := &query.GetCashPoolQuery{}
json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), getCashPoolQuery)
data, err := cashPoolService.CashPool(getCashPoolQuery)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
// 返回兑换活动列表
func (controller *SuMoneyController) ListExchangeActivities () {
cashPoolService := service.NewCashPoolService(nil)
listExchangeCashActivityQuery := &query.ListExchangeCashActivityQuery{}
companyId, _ := controller.GetInt64("companyId")
listExchangeCashActivityQuery.CompanyId = companyId
exchangeCashActivityNameMatch := controller.GetString("activityNameMatch")
listExchangeCashActivityQuery.ExchangeCashActivityNameMatch = exchangeCashActivityNameMatch
offset, _ := controller.GetInt("offset")
listExchangeCashActivityQuery.Offset = offset
limit, _ := controller.GetInt("limit")
listExchangeCashActivityQuery.Limit = limit
data, err := cashPoolService.ListExchangeCashActivity(listExchangeCashActivityQuery)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
/**
* 更新兑换活动信息
*/
// 更新兑换活动信息
func (controller *SuMoneyController) UpdateExchangeActivities () {
cashPoolService := service.NewCashPoolService(nil)
updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{}
json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), updateExchangeCashActivityCommand)
activityId, _ := controller.GetInt64(":activityId")
updateExchangeCashActivityCommand.ExchangeCashActivityId = activityId
data, err := cashPoolService.UpdateExchangeCashActivity(updateExchangeCashActivityCommand)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
/**
* 新增兑换活动
*/
// 新增兑换活动
func (controller *SuMoneyController) CreateExchangeActivities () {
cashPoolService := service.NewCashPoolService(nil)
createExchangeCashActivityCommand := &command.CreateExchangeCashActivityCommand{}
json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), createExchangeCashActivityCommand)
data, err := cashPoolService.CreateExchangeCashActivity(createExchangeCashActivityCommand)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
/**
* 删除兑换活动
*/
// 移除兑换活动
func (controller *SuMoneyController) RemoveExchangeActivities () {
cashPoolService := service.NewCashPoolService(nil)
removeExchangeCashActivityCommand := &command.RemoveExchangeCashActivityCommand{}
}
activityId, _ := controller.GetInt64(":activityId")
removeExchangeCashActivityCommand. ExchangeCashActivityId = activityId
data, err := cashPoolService.RemoveExchangeCashActivity(removeExchangeCashActivityCommand)
var response utils.JsonResponse
/**
* 搜索兑换素币活动
*/
func (controller *SuMoneyController) searchExchangeActivities () {
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
/**
* 兑换活动数据统计
*/
func (controller *SuMoneyController) exchangeActivitiesStatistics () {
// 返回兑换现金活动
func (controller *SuMoneyController) GerExchangeCashActivity () {
cashPoolService := service.NewCashPoolService(nil)
getExchangeCashActivityQuery := &query.GetExchangeCashActivityQuery{}
activityId, _ := controller.GetInt64(":activityId")
getExchangeCashActivityQuery.ExchangeCashActivityId = activityId
data, err := cashPoolService.GetExchangeCashActivity(getExchangeCashActivityQuery)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
/**
* 获取素币兑换清单
*/
// 返回兑换现金人员列表
func (controller *SuMoneyController) ListExchangeList () {
cashPoolService := service.NewCashPoolService(nil)
listExchangeCashListQuery := &query.ListExchangeCashPersonQuery{}
activityId, _ := controller.GetInt64("activityId")
listExchangeCashListQuery.ExchangeCashActivityId = activityId
exchangeCashPersonNameMatch := controller.GetString("personNameMatch")
listExchangeCashListQuery.ExchangeCashPersonNameMatch = exchangeCashPersonNameMatch
offset, _ := controller.GetInt("offset")
listExchangeCashListQuery.Offset = offset
limit, _ := controller.GetInt("limit")
listExchangeCashListQuery.Limit = limit
data, err := cashPoolService.ListExchangeCashPerson(listExchangeCashListQuery)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
/**
* 新增素币兑换清单
*/
// 新增兑换现金人员
func (controller *SuMoneyController) CreateExchangeList () {
cashPoolService := service.NewCashPoolService(nil)
createExchangeCashPersonCommand := &command.CreateExchangeCashPersonCommand{}
json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), createExchangeCashPersonCommand)
data, err := cashPoolService.CreateExchangeCashPerson(createExchangeCashPersonCommand)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
/**
* 更新素币兑换清单
*/
// 更新兑换现金人员
func (controller *SuMoneyController) UpdateExchangeList () {
cashPoolService := service.NewCashPoolService(nil)
updateExchangeCashPersonCommand := &command.UpdateExchangeCashPersonCommand{}
json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), updateExchangeCashPersonCommand)
personId, _ := controller.GetInt64(":personId")
updateExchangeCashPersonCommand. ExchangeCashPersonId = personId
data, err := cashPoolService.UpdateExchangeCashPerson(updateExchangeCashPersonCommand)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
/**
* 删除素币兑换清单
*/
// 移除兑换现金人员
func (controller *SuMoneyController) RemoveExchangeList () {
cashPoolService := service.NewCashPoolService(nil)
removeExchangeCashPersonCommand := &command.RemoveExchangeCashPersonCommand{}
}
personId, _ := controller.GetInt64(":personId")
removeExchangeCashPersonCommand.ExchangeCashPersonId = personId
/**
* 搜索素币兑换清单
*/
func (controller *SuMoneyController) searchExchangeList () {
data, err := cashPoolService.RemoveExchangeCashPerson(removeExchangeCashPersonCommand)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
/**
* 导出素币兑换清单
*/
func (controller *SuMoneyController) ExportExchangeList () {
// 返回素币兑换人员
func (controller *SuMoneyController) GetExchangeCashPerson () {
cashPoolService := service.NewCashPoolService(nil)
getExchangeCashPersonQuery := &query.GetExchangeCashPersonQuery{}
personId, _ := controller.GetInt64(":personId")
getExchangeCashPersonQuery.ExchangeCashPersonId = personId
data, err := cashPoolService.GetExchangeCashPerson(getExchangeCashPersonQuery)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
/**
* 导入素币兑换清单
*/
// TODO 导入素币兑换清单
func (controller *SuMoneyController) ImportExchangeList () {
}
\ No newline at end of file
... ...
... ... @@ -7,24 +7,28 @@ import (
func init() {
/**********************************************素币流水******************************************/
beego.Router("/su-money/operation", &controllers.SuMoneyController{}, "Post:OperationSuMoney")
beego.Router("/su-money/su-money-transaction-records/:suMoneyTransactionRecordId", &controllers.SuMoneyController{}, "Get:GetSuMoneyTransactionRecord")
beego.Router("/su-money/exchange", &controllers.SuMoneyController{}, "Post:ExchangeSuMoney")
beego.Router("/su-money/search-su-money-transaction-record", &controllers.SuMoneyController{}, "Post:SearchSuMoneyTransactionRecord")
beego.Router("/su-money/su-money-transaction-record-statistics", &controllers.SuMoneyController{}, "Post:SuMoneyTransactionRecordStatistics")
beego.Router("/su-money/operation", &controllers.SuMoneyController{}, "Post:OperationSuMoney") // 操作素币(增加,扣除,兑换)
beego.Router("/su-money/su-money-transaction-records/:suMoneyTransactionRecordId", &controllers.SuMoneyController{}, "Get:GetSuMoneyTransactionRecord") // 返回素币事务记录
beego.Router("/su-money/exchange", &controllers.SuMoneyController{}, "Post:ExchangeSuMoney") // 兑换素币
beego.Router("/su-money/search-su-money-transaction-record", &controllers.SuMoneyController{}, "Post:SearchSuMoneyTransactionRecord") // 搜索素币事务记录
beego.Router("/su-money/su-money-transaction-record-statistics", &controllers.SuMoneyController{}, "Post:SuMoneyTransactionRecordStatistics") // 返回素币事务记录统计
/**********************************************现金池*******************************************/
beego.Router("/cash-pool/input", &controllers.SuMoneyController{}, "POST:CashInput") // 现金池投入
beego.Router("/cash-pool/cash-pool-statistics", &controllers.SuMoneyController{}, "GET:CashPool") // 返回现金池统计
beego.Router("/cash-pool/", &controllers.SuMoneyController{}, "GET:ListExchangeActivities") // 返回兑换活动列表
beego.Router("/cash-pool/:activityId", &controllers.SuMoneyController{}, "PUT:UpdateExchangeActivities") // 编辑兑换活动
beego.Router("/cash-pool/", &controllers.SuMoneyController{}, "POST:CreateExchangeActivities") // 新增兑换活动
beego.Router("/cash-pool/:activityId", &controllers.SuMoneyController{}, "DELETE:RemoveExchangeActivities") // 删除兑换活动
beego.Router("/cash-pool/activity/", &controllers.SuMoneyController{}, "GET:ListExchangeActivities") // 返回兑换活动列表
beego.Router("/cash-pool/activity/:activityId", &controllers.SuMoneyController{}, "GET:ListExchangeActivities") // 返回兑换活动
beego.Router("/cash-pool/activity/:activityId", &controllers.SuMoneyController{}, "PUT:UpdateExchangeActivities") // 编辑兑换活动
beego.Router("/cash-pool/activity", &controllers.SuMoneyController{}, "POST:CreateExchangeActivities") // 新增兑换活动
beego.Router("/cash-pool/activity/:activityId", &controllers.SuMoneyController{}, "DELETE:RemoveExchangeActivities") // 删除兑换活动
//beego.Router("/cash-pool/activity/search-exchange-cash-activity", &controllers.SuMoneyController{}, "POST:SearchExchangeCashActivity") // 搜索兑换现金活动
beego.Router("/cash-pool/exchange-list", &controllers.SuMoneyController{}, "GET:ListExchangeList") // 返回素币兑换清单
beego.Router("/cash-pool/exchange-list", &controllers.SuMoneyController{}, "POST:CreateExchangeList") // 新增素币兑换清单
beego.Router("/cash-pool/exchange-list/:personId", &controllers.SuMoneyController{}, "PUT:UpdateExchangeList") // 编辑素币兑换清单
beego.Router("/cash-pool/exchange-list/:personId", &controllers.SuMoneyController{}, "DELETE:RemoveExchangeList") // 删除素币兑换清单
beego.Router("/cash-pool/exchange-list/export", &controllers.SuMoneyController{}, "POST:ExportExchangeList") // 导出素币兑换清单
beego.Router("/cash-pool/exchange-list/import", &controllers.SuMoneyController{}, "POST:ImportExchangeList") // 导入素币兑换清单
beego.Router("/cash-pool/activity/exchange-list/", &controllers.SuMoneyController{}, "GET:ListExchangeList") // 返回素币兑换清单
beego.Router("/cash-pool/activity/exchange-list/:personId", &controllers.SuMoneyController{}, "GET:GetExchangeCashPerson") // 返回素币兑换人员
beego.Router("/cash-pool/activity/exchange-list", &controllers.SuMoneyController{}, "POST:CreateExchangeList") // 新增素币兑换清单
beego.Router("/cash-pool/activity/exchange-list/:personId", &controllers.SuMoneyController{}, "PUT:UpdateExchangeList") // 编辑素币兑换清单
beego.Router("/cash-pool/activity/exchange-list/:personId", &controllers.SuMoneyController{}, "DELETE:RemoveExchangeList") // 删除素币兑换清单
beego.Router("/cash-pool/activity/exchange-list/import", &controllers.SuMoneyController{}, "POST:ImportExchangeList") // 导入素币兑换清单
//beego.Router("/cash-pool/activity/exchange-list/search-exchange-cash-person", &controllers.SuMoneyController{}, "POST:SearchExchangeCashPerson") // 搜索兑换现金人员
}
... ...