AccountController.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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\Http\Validator\AccountValidator;
  13. use App\Services\Common\AccountService;
  14. /**
  15. * 账户明细管理-控制器
  16. * @author laravel开发员
  17. * @since 2020/11/11
  18. * Class AccountController
  19. * @package App\Http\Controllers
  20. */
  21. class AccountController extends Backend
  22. {
  23. /**
  24. * 构造函数
  25. * @author laravel开发员
  26. * @since 2020/11/11
  27. * AccountController constructor.
  28. */
  29. public function __construct()
  30. {
  31. parent::__construct();
  32. $this->service = new AccountService();
  33. }
  34. // 记录
  35. public function index()
  36. {
  37. try {
  38. $pageSize = request()->get('limit', 15);
  39. $list = $this->service->getDataList(request()->all(), $pageSize);
  40. $message = array(
  41. "msg" => '操作成功',
  42. "code" => 0,
  43. "data" => isset($list['list'])? $list['list']:[],
  44. "count" => isset($list['total'])? $list['total']:0,
  45. );
  46. return $message;
  47. } catch (\Exception $exception){
  48. $message = array(
  49. "msg" => '失败:'.$exception->getMessage(),
  50. "code" => -1,
  51. "data" => [],
  52. "count" => 0,
  53. );
  54. return $message;
  55. }
  56. }
  57. /**
  58. * 统计
  59. * @return array
  60. */
  61. public function count()
  62. {
  63. $datas = $this->service->getCount(request()->all());
  64. $message = array(
  65. "msg" => '操作成功',
  66. "code" => 0,
  67. "data" => $datas,
  68. );
  69. return $message;
  70. }
  71. /**
  72. * 调整佣金
  73. * @param AccountValidator $validator
  74. * @return array
  75. */
  76. public function changeBalance(AccountValidator $validator)
  77. {
  78. // 获取参数
  79. $params = $validator->check(request()->all(), 'change');
  80. if(!is_array($params)){
  81. return message($params, false);
  82. }
  83. if(AccountService::make()->changeBalance($params)){
  84. return message(AccountService::make()->getError(), true);
  85. }else{
  86. return message(AccountService::make()->getError(), false);
  87. }
  88. }
  89. // 调整积分
  90. public function changeScore(AccountValidator $validator)
  91. {
  92. // 获取参数
  93. $params = $validator->check(request()->all(), 'change');
  94. if(!is_array($params)){
  95. return message($params, false);
  96. }
  97. if(AccountService::make()->changeScore($params)){
  98. return message(AccountService::make()->getError(), true);
  99. }else{
  100. return message(AccountService::make()->getError(), false);
  101. }
  102. }
  103. }