Account.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Niucloud-admin 企业快速开发的saas管理平台
  4. // +----------------------------------------------------------------------
  5. // | 官方网址:https://www.niucloud.com
  6. // +----------------------------------------------------------------------
  7. // | niucloud团队 版权所有 开源版本可自由商用
  8. // +----------------------------------------------------------------------
  9. // | Author: Niucloud Team
  10. // +----------------------------------------------------------------------
  11. namespace app\api\controller\member;
  12. use app\dict\member\MemberAccountChangeTypeDict;
  13. use app\dict\member\MemberAccountTypeDict;
  14. use app\service\api\member\MemberAccountService;
  15. use core\base\BaseApiController;
  16. use core\exception\AdminException;
  17. use think\db\exception\DbException;
  18. use think\Response;
  19. /**
  20. * 会员账户
  21. * Class Account
  22. * @package app\api\controller\member
  23. */
  24. class Account extends BaseApiController
  25. {
  26. /**
  27. * 积分流水
  28. * @return Response
  29. */
  30. public function point(): Response
  31. {
  32. $data = $this->request->params([
  33. ['from_type', ''],
  34. ['amount_type', 'all'],//全部all 收入income 支出disburse
  35. ['create_time', []],
  36. ]);
  37. $data['account_type'] = MemberAccountTypeDict::POINT;
  38. return success((new MemberAccountService())->getPointPage($data));
  39. }
  40. /**
  41. * 余额流水
  42. * @return Response
  43. */
  44. public function balance(): Response
  45. {
  46. $data = $this->request->params([
  47. ['from_type', '']
  48. ]);
  49. $data['account_type'] = MemberAccountTypeDict::BALANCE;
  50. return success((new MemberAccountService())->getPage($data));
  51. }
  52. /**
  53. * 余额流水(新)
  54. * @return Response
  55. */
  56. public function balanceList(): Response
  57. {
  58. $data = $this->request->params([
  59. ['from_type', ''],
  60. ['trade_type', ''],
  61. ['create_time', []]
  62. ]);
  63. return success((new MemberAccountService())->getBalancePage($data));
  64. }
  65. /**
  66. * 零钱流水
  67. * @return Response
  68. */
  69. public function money(): Response
  70. {
  71. $data = $this->request->params([
  72. ['from_type', '']
  73. ]);
  74. $data['account_type'] = MemberAccountTypeDict::MONEY;
  75. return success((new MemberAccountService())->getPage($data));
  76. }
  77. /**
  78. * 账户记录数量
  79. * @return Response
  80. * @throws DbException
  81. */
  82. public function count(): Response
  83. {
  84. $data = $this->request->params([
  85. ['from_type', ''],
  86. ['account_type', '']
  87. ]);
  88. return success(data:(new MemberAccountService())->getCount($data));
  89. }
  90. /**
  91. * 佣金流水
  92. * @return Response
  93. */
  94. public function commission(): Response
  95. {
  96. $data = $this->request->params([
  97. ['keyword', ''],
  98. ['from_type', ''],
  99. ['account_data_gt', ''],
  100. ['account_data_lt', ''],
  101. ['create_time', []],
  102. ]);
  103. $data['account_type'] = MemberAccountTypeDict::COMMISSION;
  104. return success((new MemberAccountService())->getPage($data));
  105. }
  106. /**
  107. * 账户来源
  108. * @param $account_type
  109. * @return Response
  110. */
  111. public function getFromType($account_type): Response
  112. {
  113. if (!array_key_exists($account_type, MemberAccountTypeDict::getType())) throw new AdminException('MEMBER_TYPE_NOT_EXIST');
  114. return success(MemberAccountChangeTypeDict::getType($account_type));
  115. }
  116. /**
  117. * 会员积分统计数量
  118. * @return Response
  119. * @throws DbException
  120. */
  121. public function pointCount()
  122. {
  123. return success((new MemberAccountService())->getPointCount());
  124. }
  125. }