| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?php
- namespace App\Http\Controllers\Api\v1;
- use App\Http\Controllers\Api\webApp;
- use App\Services\Api\AccountService;
- use App\Services\Api\BalanceLogService;
- /**
- * 账单明细
- * Class AccountController
- * @package App\Http\Controllers\Api
- */
- class AccountController extends webApp
- {
- /**
- * 列表
- * @return array
- */
- public function index()
- {
- $params = request()->post();
- $pageSize = request()->post('pageSize', 15);
- $params['user_id'] = isset($params['user_id']) ? $params['user_id'] : $this->userId;
- $datas = AccountService::make()->getDataList($params, $pageSize);
- if ($datas) {
- return message(1010, true, $datas);
- } else {
- return message(1009, false);
- }
- }
- /**
- * 充值套餐
- * @return array
- */
- public function payMeal()
- {
- $params = request()->post();
- $datas = AccountService::make()->getPayMealList($params);
- if ($datas) {
- return message(1010, true, $datas);
- } else {
- return message(1009, false);
- }
- }
- /**
- * 充值记录
- * @return array
- */
- public function payLog()
- {
- $params = request()->post();
- $pageSize = request()->post('pageSize', 15);
- $params['user_id'] = isset($params['user_id']) ? $params['user_id'] : $this->userId;
- $datas = AccountService::make()->getPayLog($params, $pageSize);
- if ($datas) {
- return message(1010, true, $datas);
- } else {
- return message(1009, false);
- }
- }
- /**
- * 余额明细
- * @return array
- */
- public function balance()
- {
- $params = request()->post();
- $pageSize = request()->post('pageSize', 15);
- $params['user_id'] = isset($params['user_id']) ? $params['user_id'] : $this->userId;
- $datas = BalanceLogService::make()->getDataList($params, $pageSize);
- return message(1010, true, $datas);
- }
- /**
- * 生活充值
- * @return array
- */
- public function pay()
- {
- $params = request()->all();
- try {
- if (!$result = AccountService::make()->recharge($this->userId, $params)) {
- return showJson(AccountService::make()->getError(), false);
- } else {
- return showJson(AccountService::make()->getError(), true, $result);
- }
- } catch (\Exception $exception) {
- $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
- return showJson(1046, false, $error);
- }
- }
- /**
- * 收入提现
- * @return array
- */
- public function withdraw()
- {
- try {
- $params = request()->all();
- if (!$result = BalanceLogService::make()->withdraw($this->userId, $params)) {
- return showJson(BalanceLogService::make()->getError(), false);
- } else {
- return showJson(BalanceLogService::make()->getError(), true, $result);
- }
- } catch (\Exception $exception) {
- $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
- return showJson(1046, false, $error);
- }
- }
- }
|