123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use app\common\model\Accounts;
- use app\common\service\AccountLogService;
- use app\common\service\AccountService;
- use app\common\service\AccountWithdrawService;
- use app\common\service\CategoryService;
- use app\common\service\DemandBiddingService;
- use app\common\service\DemandService;
- use app\common\service\GoodsService;
- use app\common\model\Category;
- use app\common\service\OrderService;
- use app\common\service\UserService;
- use fast\Tree;
- use think\Exception;
- use think\exception\HttpResponseException;
- use think\Validate;
- class Account extends Api
- {
- protected $noNeedLogin = [];
- protected $noNeedRight = ['*'];
- public function logs()
- {
- try {
- $page = $this->request->get('page', 1);
- $page_size = $this->request->get('page_size', 10);
- $tab = $this->request->get('tab', 'all');
- $accountType = $this->request->get('accountType', '');
- $where = [];
- if ($tab != 'all') {
- $where['inc_or_exp'] = $tab == 'income' ? 1 : 2;
- }
- if ($accountType) {
- $where['account_type'] = $accountType == 'amount' ? ['in', ['amount', 'freeze']] : $accountType;
- }
- $list = AccountLogService::getList($where, $page_size, 'id desc')->toArray();
- $this->success('', $list);
- } catch (\Exception $e) {
- if ($e instanceof HttpResponseException) {
- throw $e;
- }
- $this->error($e->getMessage());
- }
- }
- public function info()
- {
- $user_id = $this->auth->id ?? -1;
- $data = AccountService::getOne(['user_id' => $user_id]);
- $this->success('success', $data);
- }
- public function applyWithdraw()
- {
- try {
- $user_id = $this->auth->id ?? -1;
- $amount = $this->request->post('amount', 0);
- $name = $this->request->post('name', '');
- // 验证参数
- $error = $this->validate($this->request->post(), [
- 'name' => 'require',
- 'amount' => 'require|number|between:1,500',
- ], [
- 'name.require' => '微信真实姓名必填',
- 'amount.require' => '提现金额不正确',
- 'amount.number' => '提现金额必须为数字',
- 'amount.between' => '提现金额必须在1到500之间',
- ]);
- if (true !== $error) {
- throw new \Exception($error);
- }
- AccountWithdrawService::applyWithdraw($user_id, $amount, $name);
- $this->success('提现申请成功,1-3个工作日到账');
- } catch (\Exception $e) {
- if ($e instanceof HttpResponseException) {
- throw $e;
- }
- $this->error($e->getMessage());
- }
- }
- }
|