作者 陈志颖

fix:修改路由方法名

... ... @@ -33,6 +33,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
}()
// TODO 判断公司是否存在
//var cashPoolDao *dao.CashPoolDao
//if value, err := factory.CreateCashPoolDao(map[string]interface{}{
// "transactionContext": transactionContext,
... ... @@ -43,6 +44,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
//}
// TODO 统计系统已兑换现金、未兑换现金、已兑换素币、未兑换素币
var systemUnExchangeCash float64
//systemExchangedCash, err := cashPoolDao.CalculateSystemCash(createCashPoolCommand.CompanyId)
//if err != nil {
... ... @@ -55,7 +57,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
//}
var cashPoolRepository domain.CashPoolRepository
if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -64,6 +66,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
}
// TODO 获取系统未兑换现金
//count, cashPools, err := cashPoolRepository.Find(map[string]interface{}{
// "companyId": createCashPoolCommand.CompanyId,
//})
... ... @@ -94,7 +97,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
CreateTime: time.Now(),
}
if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -128,7 +131,7 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC
transactionContext.RollbackTransaction()
}()
var cashPoolRepository domain.CashPoolRepository
if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -143,19 +146,20 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC
}
// TODO 初始状态下,现金池返回默认值
if count == 0 {
return map[string]interface{}{
return map[string] interface{} {
"cashPoolId": 0,
"cash": 0,
"companyId": 0,
"companyId": getCashPoolQuery.CompanyId,
"exchangedCash": 0,
"unExchangeCash": 0,
"exchangedSuMoney": 0,
"unExchangeSuMoney": 0,
"rate": 0,
"createTime": "2020-11-03T17:23:00.848676+08:00",
"createTime": time.Now(),
}, nil
} else {
return cashPools[0], nil
}
return cashPools[0], nil
}
}
... ... @@ -254,7 +258,6 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashActivity(removeExchang
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())
... ... @@ -265,7 +268,6 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashActivity(removeExchang
defer func() {
transactionContext.RollbackTransaction()
}()
var exchangeCashActivityRepository domain.ExchangeActivityRepository
if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -274,7 +276,6 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashActivity(removeExchang
} else {
exchangeCashActivityRepository = value
}
activity, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"activityId": removeExchangeCashActivityCommand.ActivityId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -334,7 +335,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
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())
... ... @@ -345,7 +345,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
defer func() {
transactionContext.RollbackTransaction()
}()
var exchangeCashActivityRepository domain.ExchangeActivityRepository
if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -354,7 +353,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
} else {
exchangeCashActivityRepository = value
}
activity, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"activityId": updateExchangeCashActivityCommand.ExchangeCashActivityId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -369,6 +367,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
// TODO 更新现金池已兑换素币、已兑换现金值、未兑换素币、未兑换现金值、平均汇率
//var cashPoolRepository domain.CashPoolRepository
//if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
// "transactionContext": transactionContext,
... ... @@ -390,7 +389,6 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
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())
... ... @@ -403,6 +401,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
}()
// TODO 获取兑换活动兑换汇率
//var exchangeCashActivityRepository domain.ExchangeActivityRepository
//activity, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"exchangeCashActivityId": createExchangeCashPersonCommand.ExchangeCashActivityId})
//if err != nil {
... ... @@ -414,12 +413,11 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
// fmt.Print(activity.Rate)
//}
// TODO 清单中现金总额超过现金池时创建失败,提示:“已超过投入现金池的未兑换现金”
// TODO 新增兑换清单时,根据uid判断成员是否存在,判断素币值是否超过本人持有的素币
// TODO 新增兑换人员时,判断成员是否存在,判断素币值是否超过本人持有的素币,以手机账号为判断依据
// TODO 导入兑换清单时,时根据手机账号判断成员是否存在,判断素币是否超过本人持有的素币
newPerson := &domain.ExchangeCashPersonList{
EmployeeInfo: &domain.EmployeeInfo{
... ... @@ -444,7 +442,6 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
} else {
// TODO 更新活动已兑换素币值、已兑换现金值、兑换汇率
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
... ... @@ -457,7 +454,6 @@ func (cashPoolService *CashPoolService) GetExchangeCashPerson(getExchangeCashPer
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())
... ... @@ -468,7 +464,6 @@ func (cashPoolService *CashPoolService) GetExchangeCashPerson(getExchangeCashPer
defer func() {
transactionContext.RollbackTransaction()
}()
var exchangeCashPersonListRepository domain.ExchangeCashPersonListRepository
if value, err := factory.CreateExchangeCashPersonListRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -514,7 +509,6 @@ func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashP
} else {
exchangeCashPersonListRepository = value
}
if count, people, err := exchangeCashPersonListRepository.Find(tool_funs.SimpleStructToMap(listExchangeCashPersonQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -533,7 +527,6 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC
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())
... ... @@ -544,7 +537,6 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC
defer func() {
transactionContext.RollbackTransaction()
}()
var exchangeCashPersonListRepository domain.ExchangeCashPersonListRepository
if value, err := factory.CreateExchangeCashPersonListRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -553,7 +545,6 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC
} else {
exchangeCashPersonListRepository = value
}
person, err := exchangeCashPersonListRepository.FindOne(map[string]interface{}{"id": removeExchangeCashPersonCommand.ListId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -611,7 +602,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
} else {
// TODO 更新个人当前可用素币值,生成素币兑换流水记录(获取更新前的已兑换素币值,判断是扣除还是增加),记录描述:参与素币兑换现金活动(红色表示取活动名称)
// TODO 更新相应兑换活动已兑换素币值、已兑换现金值、兑换汇率
if err := transactionContext.CommitTransaction(); err != nil {
... ...
... ... @@ -20,19 +20,14 @@ 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()
}
... ... @@ -40,20 +35,15 @@ 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()
}
... ... @@ -61,19 +51,14 @@ 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()
}
... ... @@ -102,19 +87,14 @@ 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()
}
... ... @@ -257,9 +237,6 @@ func (controller *SuMoneyController) ListExchangeList () {
listExchangeCashListQuery.Offset = offset
limit, _ := controller.GetInt("limit")
listExchangeCashListQuery.Limit = limit
fmt.Println("hahahhah", listExchangeCashListQuery)
data, err := cashPoolService.ListExchangeCashPerson(listExchangeCashListQuery)
var response utils.JsonResponse
if err != nil {
... ...
... ... @@ -14,19 +14,19 @@ func init() {
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", &controllers.SuMoneyController{}, "GET:GetCashPool") // 返回现金池统计
beego.Router("/cash-pool/input", &controllers.SuMoneyController{}, "Post:CashInput") // 现金池投入
beego.Router("/cash-pool/cash-pool", &controllers.SuMoneyController{}, "Get:GetCashPool") // 返回现金池统计
beego.Router("/cash-pool/activity/", &controllers.SuMoneyController{}, "GET:ListExchangeActivities") // 返回兑换活动列表
beego.Router("/cash-pool/activity/:activityId", &controllers.SuMoneyController{}, "GET:GetExchangeCashActivity") // 返回兑换活动
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/", &controllers.SuMoneyController{}, "Get:ListExchangeActivities") // 返回兑换活动列表
beego.Router("/cash-pool/activity/:activityId", &controllers.SuMoneyController{}, "Get:GetExchangeCashActivity") // 返回兑换活动
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/exchange-list", &controllers.SuMoneyController{}, "GET:ListExchangeList") // 返回素币兑换清单
beego.Router("/cash-pool/activity/exchange-list/:listId", &controllers.SuMoneyController{}, "GET:GetExchangeCashPerson") // 返回素币兑换人员
beego.Router("/cash-pool/activity/exchange-list", &controllers.SuMoneyController{}, "POST:CreateExchangeList") // 新增素币兑换清单
beego.Router("/cash-pool/activity/exchange-list/:listId", &controllers.SuMoneyController{}, "PUT:UpdateExchangeList") // 编辑素币兑换清单
beego.Router("/cash-pool/activity/exchange-list/:listId", &controllers.SuMoneyController{}, "DELETE:RemoveExchangeCashPerson") // 删除素币兑换清单
beego.Router("/cash-pool/activity/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/:listId", &controllers.SuMoneyController{}, "Get:GetExchangeCashPerson") // 返回素币兑换人员
beego.Router("/cash-pool/activity/exchange-list", &controllers.SuMoneyController{}, "Post:CreateExchangeList") // 新增素币兑换清单
beego.Router("/cash-pool/activity/exchange-list/:listId", &controllers.SuMoneyController{}, "Put:UpdateExchangeList") // 编辑素币兑换清单
beego.Router("/cash-pool/activity/exchange-list/:listId", &controllers.SuMoneyController{}, "Delete:RemoveExchangeCashPerson") // 删除素币兑换清单
beego.Router("/cash-pool/activity/exchange-list/import", &controllers.SuMoneyController{}, "Post:ImportExchangeList") // 导入素币兑换清单
}
... ...