Merge branch 'fix-bugs' into dev
正在显示
5 个修改的文件
包含
47 行增加
和
36 行删除
@@ -7,6 +7,7 @@ import ( | @@ -7,6 +7,7 @@ import ( | ||
7 | 7 | ||
8 | type ExportTransactionRecordCommand struct { | 8 | type ExportTransactionRecordCommand struct { |
9 | Ids []int `json:"ids"` | 9 | Ids []int `json:"ids"` |
10 | + Where map[string]interface{} `json:"where"` | ||
10 | } | 11 | } |
11 | 12 | ||
12 | func (exportTransactionRecordCommand *ExportTransactionRecordCommand) ValidateCommand() error { | 13 | func (exportTransactionRecordCommand *ExportTransactionRecordCommand) ValidateCommand() error { |
@@ -1206,12 +1206,13 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc | @@ -1206,12 +1206,13 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc | ||
1206 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1206 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1207 | } | 1207 | } |
1208 | 1208 | ||
1209 | - fmt.Printf("员工:%+v\n", len(peopleFound)) | ||
1210 | - | ||
1211 | if len(peopleFound) > 0 { // 追加素币兑换或撤回素币兑换 | 1209 | if len(peopleFound) > 0 { // 追加素币兑换或撤回素币兑换 |
1212 | // 获取兑换清单员工已兑换素币 | 1210 | // 获取兑换清单员工已兑换素币 |
1213 | personFoundExchangedSuMoney := peopleFound[0].ExchangedSuMoney | 1211 | personFoundExchangedSuMoney := peopleFound[0].ExchangedSuMoney |
1214 | 1212 | ||
1213 | + fmt.Print(createExchangeCashPersonCommand.ExchangedSuMoney, "\n") | ||
1214 | + fmt.Print(personFoundExchangedSuMoney, "\n") | ||
1215 | + | ||
1215 | if createExchangeCashPersonCommand.ExchangedSuMoney < personFoundExchangedSuMoney { // 当前兑换的素币小于已兑换素币,撤回兑换素币 | 1216 | if createExchangeCashPersonCommand.ExchangedSuMoney < personFoundExchangedSuMoney { // 当前兑换的素币小于已兑换素币,撤回兑换素币 |
1216 | // 减量 | 1217 | // 减量 |
1217 | suMoneyDecrement := peopleFound[0].ExchangedSuMoney - createExchangeCashPersonCommand.ExchangedSuMoney | 1218 | suMoneyDecrement := peopleFound[0].ExchangedSuMoney - createExchangeCashPersonCommand.ExchangedSuMoney |
@@ -324,7 +324,7 @@ func (suMoneyService *SuMoneyService) ListSuMoneyTransactionRecordById(exportSuM | @@ -324,7 +324,7 @@ func (suMoneyService *SuMoneyService) ListSuMoneyTransactionRecordById(exportSuM | ||
324 | transactionContext.RollbackTransaction() | 324 | transactionContext.RollbackTransaction() |
325 | }() | 325 | }() |
326 | 326 | ||
327 | - if len(exportSuMoneyTransactionRecordCommand.Ids) == 0 { | 327 | + if len(exportSuMoneyTransactionRecordCommand.Ids) == 0 && exportSuMoneyTransactionRecordCommand.Where == nil { |
328 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未勾选需要导出的数据") | 328 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未勾选需要导出的数据") |
329 | } | 329 | } |
330 | 330 |
@@ -70,12 +70,16 @@ func (repository *SuMoneyTransactionRecordRepository) FindById(queryOptions map[ | @@ -70,12 +70,16 @@ func (repository *SuMoneyTransactionRecordRepository) FindById(queryOptions map[ | ||
70 | var suMoneyTransactionRecordModels []*models.SuMoneyTransactionRecord | 70 | var suMoneyTransactionRecordModels []*models.SuMoneyTransactionRecord |
71 | suMoneyTransactionRecords := make([]*domain.SuMoneyTransactionRecord, 0) | 71 | suMoneyTransactionRecords := make([]*domain.SuMoneyTransactionRecord, 0) |
72 | query := tx.Model(&suMoneyTransactionRecordModels) | 72 | query := tx.Model(&suMoneyTransactionRecordModels) |
73 | - //if iDs, ok := queryOptions["iDs"]; ok && len(iDs.([]int)) != 0 { | ||
74 | - // query = query.Where(`su_money_transaction_record.id IN (?)`, pg.In(iDs.([]int))) | ||
75 | - //} | ||
76 | - if iDs, ok := queryOptions["ids"]; ok { | 73 | + query = query.Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint") |
74 | + if iDs, ok := queryOptions["ids"]; ok && len(iDs.([]int)) != 0 { | ||
77 | query = query.Where(`su_money_transaction_record.id IN (?)`, pg.In(iDs.([]int))) | 75 | query = query.Where(`su_money_transaction_record.id IN (?)`, pg.In(iDs.([]int))) |
78 | } | 76 | } |
77 | + if where, ok := queryOptions["where"]; ok && where.(map[string]interface{}) != nil { | ||
78 | + if companyId, ok := where.(map[string]interface{})["companyId"]; ok && companyId.(float64) != 0 { | ||
79 | + query = query.Where("e.company_id = ?", companyId) | ||
80 | + } | ||
81 | + } | ||
82 | + //query = query.Where(`e.status = ?`, 1) | ||
79 | if count, err := query.Order("id DESC").SelectAndCount(); err != nil { | 83 | if count, err := query.Order("id DESC").SelectAndCount(); err != nil { |
80 | return 0, suMoneyTransactionRecords, err | 84 | return 0, suMoneyTransactionRecords, err |
81 | } else { | 85 | } else { |
@@ -418,6 +418,7 @@ func (controller *SuMoneyController) ImportExchangeList () { | @@ -418,6 +418,7 @@ func (controller *SuMoneyController) ImportExchangeList () { | ||
418 | response = utils.ResponseError(controller.Ctx, err) | 418 | response = utils.ResponseError(controller.Ctx, err) |
419 | controller.Data["json"] = response | 419 | controller.Data["json"] = response |
420 | controller.ServeJSON() | 420 | controller.ServeJSON() |
421 | + return | ||
421 | } | 422 | } |
422 | 423 | ||
423 | xlsx, err := excelize.OpenReader(file) | 424 | xlsx, err := excelize.OpenReader(file) |
@@ -428,43 +429,46 @@ func (controller *SuMoneyController) ImportExchangeList () { | @@ -428,43 +429,46 @@ func (controller *SuMoneyController) ImportExchangeList () { | ||
428 | 429 | ||
429 | // 文件行数校验 | 430 | // 文件行数校验 |
430 | rows, _ := xlsx.GetRows("Sheet1") | 431 | rows, _ := xlsx.GetRows("Sheet1") |
432 | + | ||
431 | if len(rows) > 302 { | 433 | if len(rows) > 302 { |
432 | err := fmt.Errorf("%s", "导入行数超过300行") | 434 | err := fmt.Errorf("%s", "导入行数超过300行") |
433 | response = utils.ResponseError(controller.Ctx, err) | 435 | response = utils.ResponseError(controller.Ctx, err) |
434 | controller.Data["json"] = response | 436 | controller.Data["json"] = response |
435 | controller.ServeJSON() | 437 | controller.ServeJSON() |
438 | + return | ||
436 | } | 439 | } |
437 | 440 | ||
438 | // 空行记录 | 441 | // 空行记录 |
439 | - nullLine := make([]interface{}, 0) | 442 | + //nullLine := make([]interface{}, 0) |
440 | 443 | ||
441 | // 单元格非空校验 | 444 | // 单元格非空校验 |
442 | - for i, row := range rows { | ||
443 | - if i > 2 { | ||
444 | - for _, _ = range row { | ||
445 | - r2, _ := strconv.ParseFloat(row[2], 64) | ||
446 | - if row[0] == "" || row[1] == "" || r2 == 0 { | ||
447 | - //row = append(row, "单元格包含空字符") | ||
448 | - //nullLine = append(nullLine, row) | ||
449 | - } | ||
450 | - } | ||
451 | - } | ||
452 | - } | ||
453 | - | ||
454 | - if len(nullLine) > 0 { | ||
455 | - ret = map[string]interface{}{ | ||
456 | - "successCount": 0, | ||
457 | - "fail": map[string]interface{}{ | ||
458 | - "tableHeader": tableHeader, | ||
459 | - "tableData": nullLine, | ||
460 | - }, | ||
461 | - } | ||
462 | - response = utils.ResponseData(controller.Ctx, ret) | ||
463 | - controller.Data["json"] = response | ||
464 | - controller.ServeJSON() | ||
465 | - } | ||
466 | - | ||
467 | - // 新增失败记录 | 445 | + //for i, row := range rows { |
446 | + // if i > 2 { | ||
447 | + // for _, _ = range row { | ||
448 | + // if len(row) != 3 { | ||
449 | + // row = append(row, "null") | ||
450 | + // row = append(row, "单元格包含空字符") | ||
451 | + // nullLine = append(nullLine, row) | ||
452 | + // } | ||
453 | + // } | ||
454 | + // } | ||
455 | + //} | ||
456 | + // | ||
457 | + //if len(nullLine) > 0 { | ||
458 | + // ret = map[string]interface{}{ | ||
459 | + // "successCount": 0, | ||
460 | + // "fail": map[string]interface{}{ | ||
461 | + // "tableHeader": tableHeader, | ||
462 | + // "tableData": nullLine, | ||
463 | + // }, | ||
464 | + // } | ||
465 | + // response = utils.ResponseData(controller.Ctx, ret) | ||
466 | + // controller.Data["json"] = response | ||
467 | + // controller.ServeJSON() | ||
468 | + // return | ||
469 | + //} | ||
470 | + // | ||
471 | + //// 新增失败记录 | ||
468 | failureDataList := make([]interface{}, 0) | 472 | failureDataList := make([]interface{}, 0) |
469 | 473 | ||
470 | // 新增成功计数 | 474 | // 新增成功计数 |
@@ -483,8 +487,8 @@ func (controller *SuMoneyController) ImportExchangeList () { | @@ -483,8 +487,8 @@ func (controller *SuMoneyController) ImportExchangeList () { | ||
483 | // 创建兑换素币清单 | 487 | // 创建兑换素币清单 |
484 | _, err := cashPoolService.ImportCreateExchangeCashPerson(createExchangeCashPersonCommand) | 488 | _, err := cashPoolService.ImportCreateExchangeCashPerson(createExchangeCashPersonCommand) |
485 | if err != nil { // 导入失败处理 | 489 | if err != nil { // 导入失败处理 |
486 | - //rows[i] = append(rows[i], err.Error()) | ||
487 | - //failureDataList = append(failureDataList, rows[i]) // 导入失败的记录 | 490 | + rows[i] = append(rows[i], err.Error()) |
491 | + failureDataList = append(failureDataList, rows[i]) // 导入失败的记录 | ||
488 | } else { // 导入成功处理 | 492 | } else { // 导入成功处理 |
489 | successDataCount += 1 | 493 | successDataCount += 1 |
490 | } | 494 | } |
@@ -502,6 +506,7 @@ func (controller *SuMoneyController) ImportExchangeList () { | @@ -502,6 +506,7 @@ func (controller *SuMoneyController) ImportExchangeList () { | ||
502 | response = utils.ResponseData(controller.Ctx, ret) | 506 | response = utils.ResponseData(controller.Ctx, ret) |
503 | controller.Data["json"] = response | 507 | controller.Data["json"] = response |
504 | controller.ServeJSON() | 508 | controller.ServeJSON() |
509 | + return | ||
505 | } | 510 | } |
506 | 511 | ||
507 | // 导出素币兑换清单,选择导出(ids),增加导出失败信息 | 512 | // 导出素币兑换清单,选择导出(ids),增加导出失败信息 |
-
请 注册 或 登录 后发表评论