AccountController.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 LARAVEL研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.laravel.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: laravel开发员 <laravel.qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Http\Controllers\Admin;
  12. use App\Services\Common\BalanceLogsService;
  13. /**
  14. * 财务明细管理-控制器(基于 balance_logs 表)
  15. * @author laravel开发员
  16. * @since 2020/11/11
  17. * Class AccountController
  18. * @package App\Http\Controllers
  19. */
  20. class AccountController extends Backend
  21. {
  22. /**
  23. * 获取商家对应的 member_id(用于数据隔离)
  24. * @return int|null
  25. */
  26. private function getMemberId()
  27. {
  28. if ($this->storeId > 0) {
  29. // 如果是商家登录,获取商家对应的 member_id
  30. $storeModel = new \App\Models\StoreModel();
  31. $storeInfo = $storeModel->find($this->storeId);
  32. return $storeInfo ? $storeInfo->user_id : null;
  33. }
  34. return null;
  35. }
  36. /**
  37. * 列表(基于 balance_logs 表)
  38. */
  39. public function index()
  40. {
  41. $service = new BalanceLogsService();
  42. $params = request()->all();
  43. // 获取商家对应的 member_id 用于数据隔离
  44. $memberId = $this->getMemberId();
  45. $result = $service->getList($params, $memberId);
  46. return [
  47. "msg" => $result['msg'] ?? '操作成功',
  48. "code" => $result['code'] ?? 0,
  49. "data" => $result['data'] ?? [],
  50. "count" => $result['count'] ?? 0,
  51. ];
  52. }
  53. /**
  54. * 获取详情(基于 balance_logs 表)
  55. */
  56. public function read()
  57. {
  58. $id = request()->input('id');
  59. if (empty($id)) {
  60. return showJson('参数错误', false);
  61. }
  62. $service = new BalanceLogsService();
  63. $result = $service->getInfo($id, $this->getMemberId());
  64. return showJson($result['msg'], $result['code'] == 0, $result['data'] ?? []);
  65. }
  66. // 财务明细只能查看,不能修改、添加、删除
  67. // 以下方法已禁用
  68. // /**
  69. // * 添加
  70. // */
  71. // public function add()
  72. // {
  73. // $result = $this->service->add();
  74. // return showJson($result['msg'], $result['code'] == 0);
  75. // }
  76. // /**
  77. // * 编辑
  78. // */
  79. // public function edit()
  80. // {
  81. // $result = $this->service->edit();
  82. // return showJson($result['msg'], $result['code'] == 0);
  83. // }
  84. // /**
  85. // * 设置状态
  86. // */
  87. // public function status()
  88. // {
  89. // $result = $this->service->status();
  90. // return showJson($result['msg'], $result['code'] == 0);
  91. // }
  92. // /**
  93. // * 删除
  94. // */
  95. // public function delete()
  96. // {
  97. // $result = $this->service->delete();
  98. // return showJson($result['msg'], $result['code'] == 0);
  99. // }
  100. }