作者 陈志颖

feat:添加现金池公共代码

... ... @@ -199,9 +199,7 @@ func (statisticsService *StatisticsService) PersonSuMoneyStatistics(personSuMone
}
}
/**
* 获取系统素币统计
*/
// TODO 获取系统素币统计
func (statisticsService *StatisticsService) SystemSuMoneyStatistics(systemSuMoneyStatisticsCommand *command.SystemSuMoneyStatisticsCommand) (interface{}, error) {
if err := systemSuMoneyStatisticsCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -227,7 +225,6 @@ func (statisticsService *StatisticsService) SystemSuMoneyStatistics(systemSuMone
employeeDao = value
}
if systemSuMoneyStatistics, err := employeeDao.CalculateSystemCash(systemSuMoneyStatisticsCommand.CompanyId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -239,6 +236,13 @@ func (statisticsService *StatisticsService) SystemSuMoneyStatistics(systemSuMone
}
}
// TODO 获取系统现金统计
func (statisticsService *StatisticsService) SystemCashStatistics(systemCashStatisticsCommand *command.SystemCashStatisticsCommand) (interface{}, error) {
return nil, nil
}
func NewStatisticsService(options map[string]interface{}) *StatisticsService {
newStatisticsService := &StatisticsService{}
return newStatisticsService
... ...
... ... @@ -82,66 +82,284 @@ func (cashPoolService *CashPoolService) OperationCashPool(createCashPoolCommand
// TODO 返回现金池
func (cashPoolService *CashPoolService) CashPool(getCashPoolQuery *query.GetCashPoolQuery) (interface{}, error) {
if err := getCashPoolQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
return nil, nil
}
// TODO 返回兑换现金活动
func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCashActivityCommand *query.ListExchangeCashActivityQuery) (interface{}, error) {
func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCashActivityQuery *query.ListExchangeCashActivityQuery) (interface{}, error) {
if err := listExchangeCashActivityQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
return nil, nil
}
// TODO 新增兑换现金活动
func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchangeCashActivityCommand *command.CreateExchangeCashActivityCommand) (interface{}, error) {
if err := createExchangeCashActivityCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
return nil, nil
}
// TODO 返回兑换现金活动列表
func (cashPoolService *CashPoolService) ExchangeCashActivityList(listExchangeCashActivityQuery *query.ListExchangeCashActivityQuery) (interface{}, error) {
if err := listExchangeCashActivityQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
return nil, nil
}
// TODO 移除兑换现金活动
func (cashPoolService *CashPoolService) RemoveExchangeCashActivity(removeExchangeCashActivityCommand *command.RemoveExchangeCashActivityCommand) (interface{}, error) {
if err := removeExchangeCashActivityCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
return nil, nil
}
// TODO 返回兑换现金活动
func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashActivityQuery *query.GetExchangeCashActivityQuery) (interface{}, error) {
if err := getExchangeCashActivityQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
return nil, nil
}
// TODO 更新兑换现金活动
func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchangeCashActivityCommand *command.UpdateExchangeCashActivityCommand) (interface{}, error) {
if err := updateExchangeCashActivityCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
return nil, nil
}
// TODO 新建兑换现金人员
func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeCashPersonCommand *command.CreateExchangeCashPersonCommand) (interface{}, error) {
if err := createExchangeCashPersonCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
return nil, nil
}
// TODO 返回兑换现金人员
func (cashPoolService *CashPoolService) GetExchangeCashPerson(getExchangeCashPersonQuery *query.GetExchangeCashPersonQuery) (interface{}, error) {
if err := getExchangeCashPersonQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
return nil, nil
}
// TODO 返回兑换现金人员列表
func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashPersonQuery *query.ListExchangeCashPersonQuery) (interface{}, error) {
if err := listExchangeCashPersonQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
return nil, nil
}
// TODO 移除兑换现金人员
func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeCashPersonCommand *command.RemoveExchangeCashPersonCommand) (interface{}, error) {
if err := removeExchangeCashPersonCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
return nil, nil
}
// TODO 更新兑换现金人员
func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeCashCommand *command.UpdateExchangeCashPersonCommand) (interface{}, error) {
if err := updateExchangeCashCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
// TODO 新增流水记录
return nil, nil
}
// TODO 导入兑换现金人员
func NewCashPoolService(options map[string]interface{}) *CashPoolService {
newCashPoolService := &CashPoolService{}
return newCashPoolService
... ...
... ... @@ -183,11 +183,6 @@ 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
... ...
... ... @@ -75,14 +75,10 @@ func (controller *StatisticsController) PersonNotificationStatistics() {
// TODO 系统素币统计
func (controller *StatisticsController) SystemSuMoneyStatistics() {
//statisticsService := service.NewStatisticsService(nil)
//systemSuMoneyStatisticsCommand := &command.SystemSuMoneyStatisticsCommand{}
//json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), systemSuMoneyStatisticsCommand)
////data, err := statisticsService
}
// TODO 系统现金统计
func (controller *StatisticsController) SystemCashStatistics() {
//statisticsService := service.NewStatisticsService(nil)
}
\ No newline at end of file
... ...
... ... @@ -75,7 +75,6 @@ func (controller *SuMoneyController) ExchangeSuMoney() {
controller.ServeJSON()
}
// TODO 增加搜索姓名
func (controller *SuMoneyController) SearchSuMoneyTransactionRecord() {
suMoneyService := service.NewSuMoneyService(nil)
searchSuMoneyTransactionRecordCommand := &command.SearchSuMoneyTransactionRecordCommand{}
... ... @@ -409,5 +408,23 @@ func (controller *SuMoneyController) GetExchangeCashPerson () {
// TODO 导入素币兑换清单
func (controller *SuMoneyController) ImportExchangeList () {
cashPoolService := service.NewCashPoolService(nil)
createExchangeCashPersonCommand := &command.CreateExchangeCashPersonCommand{}
// TODO 批量导入
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()
}
\ No newline at end of file
... ...
... ... @@ -22,7 +22,6 @@ func init() {
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/activity/exchange-list/", &controllers.SuMoneyController{}, "GET:ListExchangeList") // 返回素币兑换清单
beego.Router("/cash-pool/activity/exchange-list/:personId", &controllers.SuMoneyController{}, "GET:GetExchangeCashPerson") // 返回素币兑换人员
... ... @@ -30,5 +29,4 @@ func init() {
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") // 搜索兑换现金人员
}
... ...