service = new WalletService(); } public function fetchRechargeOption() { $this->success($this->service->fetchRechargeOption()); } public function fetchVoucher() { $user = $this->auth->getUser(); $params = (new BaseApiValidate([ 'status' => 'require', 'page' => 'number', 'size' => 'number' ]))->checkBody(); $r = $this->service->fetchVoucher($user->id, "*" === $params["status"] ? [\E_VOUCHER_STATUS::Normal, \E_VOUCHER_STATUS::Use, \E_VOUCHER_STATUS::Expire] : [$params["status"]], $params["page"], $params["size"]); $this->success($r); } public function rechargeBalance() { $user = $this->auth->getUser(); $params = (new BaseApiValidate([ "platform" => "require", 'payment_type' => 'require', 'amount' => 'require|between:1,100000' ], ["amount.between" => "充值面额必须在1~100000之间"]) )->checkBody(); if (!in_array($params["payment_type"], [\E_ORDER_PAY_TYPE::Wechat, \E_ORDER_PAY_TYPE::ALi])) $this->error("支付方式错误"); if (!in_array($params["platform"], ["app", "web", "applet"])) $this->error("platform 错误"); $r = $this->service->rechargeBalance($user->id, $params["payment_type"], $params["amount"], $params["platform"]); $r->code() ? $this->success($r->data()) : $this->error($r->msg()); } public function renew() { $params = (new BaseApiValidate([ "platform" => "require", 'payment_type' => 'require', 'membership_config_id' => 'require|number' ]))->checkBody(); $user = $this->auth->getUser(); $r = (new VipService())->renew($user->id, $params['membership_config_id'], $params["payment_type"], $params["platform"]); $r->code() ? $this->success($r->data()) : $this->error($r->msg()); } public function fetchBill() { $user = $this->auth->getUser(); $params = (new BaseApiValidate([ 'currency_type' => 'require', 'change_types' => 'require', 'page' => 'require|number', 'size' => 'require|number', ]))->checkBody(); if (!in_array($params["currency_type"], [\E_USER_BILL_CURRENCY_TYPE::Money, \E_USER_BILL_CURRENCY_TYPE::Score])) $this->error("currency_type error"); $r = $this->service->fetchBill( $user->id, $params["currency_type"], explode(",", (string)$params["change_types"]), $params["page"], $params["size"] ); $this->success($r); } public function delBills() { $user = $this->auth->getUser(); $params = (new BaseApiValidate([ 'bill_ids' => 'require', ]))->checkBody(); $bill_ids = explode(",", $params["bill_ids"]); $r = $this->service->delBills($user->id, $bill_ids); $r->code() ? $this->success($r->data()) : $this->error($r->msg()); } public function exchangeVoucher() { $user = $this->auth->getUser(); $params = (new BaseApiValidate([ 'voucher_id' => 'require|number' ]))->checkBody(); $r = $this->service->exchangeVoucher($user->id, $params["voucher_id"]); $r->code() ? $this->success($r->data()) : $this->error($r->msg()); } public function deposit() { $user = $this->auth->getUser(); $params = (new BaseApiValidate([ 'platform' => 'require', 'amount' => 'require|between:1,100000', ]))->checkBody(); if (!in_array($params["platform"], [\E_ORDER_PAY_TYPE::Wechat, \E_ORDER_PAY_TYPE::ALi, \E_ORDER_PAY_TYPE::Bank])) $this->error("platform error"); $r = $this->service->deposit( $user->id, $params["platform"], fixed2Float($params["amount"]) ); $r->code() == 1 ? $this->success($r->data(), $r->msg()) : $this->error($r->msg(), null, $r->code()); } }