正在显示
3 个修改的文件
包含
22 行增加
和
28 行删除
| @@ -42,8 +42,8 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co | @@ -42,8 +42,8 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co | ||
| 42 | // cashPoolDao = value | 42 | // cashPoolDao = value |
| 43 | //} | 43 | //} |
| 44 | 44 | ||
| 45 | + // TODO 统计系统已兑换现金、未兑换现金、已兑换素币、未兑换素币 | ||
| 45 | var systemUnExchangeCash float64 | 46 | var systemUnExchangeCash float64 |
| 46 | - | ||
| 47 | //systemExchangedCash, err := cashPoolDao.CalculateSystemCash(createCashPoolCommand.CompanyId) | 47 | //systemExchangedCash, err := cashPoolDao.CalculateSystemCash(createCashPoolCommand.CompanyId) |
| 48 | //if err != nil { | 48 | //if err != nil { |
| 49 | // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 49 | // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| @@ -76,7 +76,9 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co | @@ -76,7 +76,9 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co | ||
| 76 | // systemUnExchangeCash = cashPools[0].UnExchangeCash | 76 | // systemUnExchangeCash = cashPools[0].UnExchangeCash |
| 77 | //} | 77 | //} |
| 78 | 78 | ||
| 79 | + // TODO 计算系统平均兑换汇率 | ||
| 79 | //rate, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", systemExchangedCash / systemChangedSuMoney), 64) // 平均兑换汇率 | 80 | //rate, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", systemExchangedCash / systemChangedSuMoney), 64) // 平均兑换汇率 |
| 81 | + | ||
| 80 | newCashPool := &domain.CashPool{ | 82 | newCashPool := &domain.CashPool{ |
| 81 | CompanyId: createCashPoolCommand.CompanyId, | 83 | CompanyId: createCashPoolCommand.CompanyId, |
| 82 | Cash: createCashPoolCommand.Cash, | 84 | Cash: createCashPoolCommand.Cash, |
| @@ -142,14 +144,14 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC | @@ -142,14 +144,14 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC | ||
| 142 | // TODO 初始状态下,现金池返回默认值 | 144 | // TODO 初始状态下,现金池返回默认值 |
| 143 | if count == 0 { | 145 | if count == 0 { |
| 144 | return map[string]interface{}{ | 146 | return map[string]interface{}{ |
| 145 | - "cashPoolId": 4, | 147 | + "cashPoolId": 0, |
| 146 | "cash": 0, | 148 | "cash": 0, |
| 147 | - "companyId": 101, | ||
| 148 | - "exchangedCash": 100, | ||
| 149 | - "unExchangeCash": 1001, | ||
| 150 | - "exchangedSuMoney": 50, | ||
| 151 | - "unExchangeSuMoney": 11, | ||
| 152 | - "rate": 2, | 149 | + "companyId": 0, |
| 150 | + "exchangedCash": 0, | ||
| 151 | + "unExchangeCash": 0, | ||
| 152 | + "exchangedSuMoney": 0, | ||
| 153 | + "unExchangeSuMoney": 0, | ||
| 154 | + "rate": 0, | ||
| 153 | "createTime": "2020-11-03T17:23:00.848676+08:00", | 155 | "createTime": "2020-11-03T17:23:00.848676+08:00", |
| 154 | }, nil | 156 | }, nil |
| 155 | } | 157 | } |
| @@ -376,8 +378,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang | @@ -376,8 +378,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang | ||
| 376 | // cashPoolRepository = value | 378 | // cashPoolRepository = value |
| 377 | //} | 379 | //} |
| 378 | 380 | ||
| 379 | - | ||
| 380 | - | ||
| 381 | if err := transactionContext.CommitTransaction(); err != nil { | 381 | if err := transactionContext.CommitTransaction(); err != nil { |
| 382 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 382 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 383 | } | 383 | } |
| @@ -385,7 +385,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang | @@ -385,7 +385,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang | ||
| 385 | } | 385 | } |
| 386 | } | 386 | } |
| 387 | 387 | ||
| 388 | -// 新增兑换现金人员 | 388 | +// 新增兑换素币清单 |
| 389 | func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeCashPersonCommand *command.CreateExchangeCashPersonCommand) (interface{}, error) { | 389 | func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeCashPersonCommand *command.CreateExchangeCashPersonCommand) (interface{}, error) { |
| 390 | if err := createExchangeCashPersonCommand.ValidateCommand(); err != nil { | 390 | if err := createExchangeCashPersonCommand.ValidateCommand(); err != nil { |
| 391 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 391 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
| @@ -452,7 +452,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC | @@ -452,7 +452,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC | ||
| 452 | } | 452 | } |
| 453 | } | 453 | } |
| 454 | 454 | ||
| 455 | -// 返回兑换现金人员 | 455 | +// 返回兑换素币清单 |
| 456 | func (cashPoolService *CashPoolService) GetExchangeCashPerson(getExchangeCashPersonQuery *query.GetExchangeCashPersonQuery) (interface{}, error) { | 456 | func (cashPoolService *CashPoolService) GetExchangeCashPerson(getExchangeCashPersonQuery *query.GetExchangeCashPersonQuery) (interface{}, error) { |
| 457 | if err := getExchangeCashPersonQuery.ValidateQuery(); err != nil { | 457 | if err := getExchangeCashPersonQuery.ValidateQuery(); err != nil { |
| 458 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 458 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
| @@ -491,7 +491,7 @@ func (cashPoolService *CashPoolService) GetExchangeCashPerson(getExchangeCashPer | @@ -491,7 +491,7 @@ func (cashPoolService *CashPoolService) GetExchangeCashPerson(getExchangeCashPer | ||
| 491 | } | 491 | } |
| 492 | } | 492 | } |
| 493 | 493 | ||
| 494 | -// 返回兑换现金人员列表 | 494 | +// 返回兑换素币清单列表 |
| 495 | func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashPersonQuery *query.ListExchangeCashPersonQuery) (interface{}, error) { | 495 | func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashPersonQuery *query.ListExchangeCashPersonQuery) (interface{}, error) { |
| 496 | if err := listExchangeCashPersonQuery.ValidateQuery(); err != nil { | 496 | if err := listExchangeCashPersonQuery.ValidateQuery(); err != nil { |
| 497 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 497 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
| @@ -528,7 +528,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashP | @@ -528,7 +528,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashP | ||
| 528 | } | 528 | } |
| 529 | } | 529 | } |
| 530 | 530 | ||
| 531 | -// 移除兑换现金人员 | 531 | +// 移除兑换素币清单 |
| 532 | func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeCashPersonCommand *command.RemoveExchangeCashPersonCommand) (interface{}, error) { | 532 | func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeCashPersonCommand *command.RemoveExchangeCashPersonCommand) (interface{}, error) { |
| 533 | if err := removeExchangeCashPersonCommand.ValidateCommand(); err != nil { | 533 | if err := removeExchangeCashPersonCommand.ValidateCommand(); err != nil { |
| 534 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 534 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
| @@ -37,7 +37,7 @@ func (repository *ExchangeCashPersonListRepository) FindOne(queryOptions map[str | @@ -37,7 +37,7 @@ func (repository *ExchangeCashPersonListRepository) FindOne(queryOptions map[str | ||
| 37 | tx := repository.transactionContext.PgTx | 37 | tx := repository.transactionContext.PgTx |
| 38 | exchangeCashListModel := new(models.ExchangeCashPersonList) | 38 | exchangeCashListModel := new(models.ExchangeCashPersonList) |
| 39 | query := tx.Model(exchangeCashListModel) | 39 | query := tx.Model(exchangeCashListModel) |
| 40 | - if exchangeCashListId, ok := queryOptions["exchangeCashListId"]; ok { | 40 | + if exchangeCashListId, ok := queryOptions["listId"]; ok { |
| 41 | query = query.Where("exchange_cash_person_list.id = ?", exchangeCashListId) | 41 | query = query.Where("exchange_cash_person_list.id = ?", exchangeCashListId) |
| 42 | } | 42 | } |
| 43 | if err := query.First(); err != nil { | 43 | if err := query.First(); err != nil { |
| @@ -245,7 +245,7 @@ func (controller *SuMoneyController) GetExchangeCashActivity () { | @@ -245,7 +245,7 @@ func (controller *SuMoneyController) GetExchangeCashActivity () { | ||
| 245 | controller.ServeJSON() | 245 | controller.ServeJSON() |
| 246 | } | 246 | } |
| 247 | 247 | ||
| 248 | -// 返回兑换现金人员列表 | 248 | +// 返回兑换素币清单列表 |
| 249 | func (controller *SuMoneyController) ListExchangeList () { | 249 | func (controller *SuMoneyController) ListExchangeList () { |
| 250 | cashPoolService := service.NewCashPoolService(nil) | 250 | cashPoolService := service.NewCashPoolService(nil) |
| 251 | listExchangeCashListQuery := &query.ListExchangeCashPersonQuery{} | 251 | listExchangeCashListQuery := &query.ListExchangeCashPersonQuery{} |
| @@ -271,7 +271,7 @@ func (controller *SuMoneyController) ListExchangeList () { | @@ -271,7 +271,7 @@ func (controller *SuMoneyController) ListExchangeList () { | ||
| 271 | controller.ServeJSON() | 271 | controller.ServeJSON() |
| 272 | } | 272 | } |
| 273 | 273 | ||
| 274 | -// 新增兑换现金人员 | 274 | +// 返回兑换素币清单 |
| 275 | func (controller *SuMoneyController) CreateExchangeList () { | 275 | func (controller *SuMoneyController) CreateExchangeList () { |
| 276 | cashPoolService := service.NewCashPoolService(nil) | 276 | cashPoolService := service.NewCashPoolService(nil) |
| 277 | createExchangeCashPersonCommand := &command.CreateExchangeCashPersonCommand{} | 277 | createExchangeCashPersonCommand := &command.CreateExchangeCashPersonCommand{} |
| @@ -287,12 +287,12 @@ func (controller *SuMoneyController) CreateExchangeList () { | @@ -287,12 +287,12 @@ func (controller *SuMoneyController) CreateExchangeList () { | ||
| 287 | controller.ServeJSON() | 287 | controller.ServeJSON() |
| 288 | } | 288 | } |
| 289 | 289 | ||
| 290 | -// 更新兑换现金人员 | 290 | +// 更新兑换素币清单 |
| 291 | func (controller *SuMoneyController) UpdateExchangeList () { | 291 | func (controller *SuMoneyController) UpdateExchangeList () { |
| 292 | cashPoolService := service.NewCashPoolService(nil) | 292 | cashPoolService := service.NewCashPoolService(nil) |
| 293 | updateExchangeCashPersonCommand := &command.UpdateExchangeCashPersonCommand{} | 293 | updateExchangeCashPersonCommand := &command.UpdateExchangeCashPersonCommand{} |
| 294 | json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), updateExchangeCashPersonCommand) | 294 | json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), updateExchangeCashPersonCommand) |
| 295 | - personId, _ := controller.GetInt64(":personId") | 295 | + personId, _ := controller.GetInt64(":listId") |
| 296 | updateExchangeCashPersonCommand.ListId = personId | 296 | updateExchangeCashPersonCommand.ListId = personId |
| 297 | data, err := cashPoolService.UpdateExchangeCashPerson(updateExchangeCashPersonCommand) | 297 | data, err := cashPoolService.UpdateExchangeCashPerson(updateExchangeCashPersonCommand) |
| 298 | var response utils.JsonResponse | 298 | var response utils.JsonResponse |
| @@ -305,7 +305,7 @@ func (controller *SuMoneyController) UpdateExchangeList () { | @@ -305,7 +305,7 @@ func (controller *SuMoneyController) UpdateExchangeList () { | ||
| 305 | controller.ServeJSON() | 305 | controller.ServeJSON() |
| 306 | } | 306 | } |
| 307 | 307 | ||
| 308 | -// 移除兑换现金人员 | 308 | +// 移除兑换素币清单 |
| 309 | func (controller *SuMoneyController) RemoveExchangeCashPerson() { | 309 | func (controller *SuMoneyController) RemoveExchangeCashPerson() { |
| 310 | cashPoolService := service.NewCashPoolService(nil) | 310 | cashPoolService := service.NewCashPoolService(nil) |
| 311 | removeExchangeCashPersonCommand := &command.RemoveExchangeCashPersonCommand{} | 311 | removeExchangeCashPersonCommand := &command.RemoveExchangeCashPersonCommand{} |
| @@ -322,7 +322,7 @@ func (controller *SuMoneyController) RemoveExchangeCashPerson() { | @@ -322,7 +322,7 @@ func (controller *SuMoneyController) RemoveExchangeCashPerson() { | ||
| 322 | controller.ServeJSON() | 322 | controller.ServeJSON() |
| 323 | } | 323 | } |
| 324 | 324 | ||
| 325 | -// 返回素币兑换人员 | 325 | +// 返回兑换素币清单 |
| 326 | func (controller *SuMoneyController) GetExchangeCashPerson () { | 326 | func (controller *SuMoneyController) GetExchangeCashPerson () { |
| 327 | cashPoolService := service.NewCashPoolService(nil) | 327 | cashPoolService := service.NewCashPoolService(nil) |
| 328 | getExchangeCashPersonQuery := &query.GetExchangeCashPersonQuery{} | 328 | getExchangeCashPersonQuery := &query.GetExchangeCashPersonQuery{} |
| @@ -339,14 +339,13 @@ func (controller *SuMoneyController) GetExchangeCashPerson () { | @@ -339,14 +339,13 @@ func (controller *SuMoneyController) GetExchangeCashPerson () { | ||
| 339 | controller.ServeJSON() | 339 | controller.ServeJSON() |
| 340 | } | 340 | } |
| 341 | 341 | ||
| 342 | -// 导入素币兑换清单 | 342 | +// 导入兑换素币清单 |
| 343 | func (controller *SuMoneyController) ImportExchangeList () { | 343 | func (controller *SuMoneyController) ImportExchangeList () { |
| 344 | cashPoolService := service.NewCashPoolService(nil) | 344 | cashPoolService := service.NewCashPoolService(nil) |
| 345 | createExchangeCashPersonCommand := &command.CreateExchangeCashPersonCommand{} | 345 | createExchangeCashPersonCommand := &command.CreateExchangeCashPersonCommand{} |
| 346 | activityId, _ := controller.GetInt64("activityId") | 346 | activityId, _ := controller.GetInt64("activityId") |
| 347 | file, h, _ := controller.GetFile("file") //获取上传的文件 | 347 | file, h, _ := controller.GetFile("file") //获取上传的文件 |
| 348 | ext := path.Ext(h.Filename) | 348 | ext := path.Ext(h.Filename) |
| 349 | - //验证后缀名是否符合要求 | ||
| 350 | AllowExtMap := map[string]bool{ | 349 | AllowExtMap := map[string]bool{ |
| 351 | ".xlsx":true, | 350 | ".xlsx":true, |
| 352 | } | 351 | } |
| @@ -359,12 +358,9 @@ func (controller *SuMoneyController) ImportExchangeList () { | @@ -359,12 +358,9 @@ func (controller *SuMoneyController) ImportExchangeList () { | ||
| 359 | fmt.Println(err) | 358 | fmt.Println(err) |
| 360 | return | 359 | return |
| 361 | } | 360 | } |
| 362 | - | ||
| 363 | var response utils.JsonResponse | 361 | var response utils.JsonResponse |
| 364 | - | ||
| 365 | dataList := make([]interface{}, 0) | 362 | dataList := make([]interface{}, 0) |
| 366 | rows, _ := xlsx.GetRows("Sheet1") | 363 | rows, _ := xlsx.GetRows("Sheet1") |
| 367 | - | ||
| 368 | for i, row := range rows { | 364 | for i, row := range rows { |
| 369 | if i > 0 { | 365 | if i > 0 { |
| 370 | for _, _ = range row { | 366 | for _, _ = range row { |
| @@ -382,13 +378,11 @@ func (controller *SuMoneyController) ImportExchangeList () { | @@ -382,13 +378,11 @@ func (controller *SuMoneyController) ImportExchangeList () { | ||
| 382 | } | 378 | } |
| 383 | } | 379 | } |
| 384 | } | 380 | } |
| 385 | - | ||
| 386 | ret := map[string]interface{}{ | 381 | ret := map[string]interface{}{ |
| 387 | "count": len(dataList), | 382 | "count": len(dataList), |
| 388 | "people": dataList, | 383 | "people": dataList, |
| 389 | } | 384 | } |
| 390 | response = utils.ResponseData(controller.Ctx, ret) | 385 | response = utils.ResponseData(controller.Ctx, ret) |
| 391 | - | ||
| 392 | controller.Data["json"] = response | 386 | controller.Data["json"] = response |
| 393 | controller.ServeJSON() | 387 | controller.ServeJSON() |
| 394 | } | 388 | } |
-
请 注册 或 登录 后发表评论