| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <?php
- namespace backend\modules\user\controllers;
- use backend\models\forms\WithdrawForm;
- use backend\models\RateApi;
- use backend\models\searches\SsacWithdrawSearch;
- use backend\models\searches\WithdrawSearch;
- use backend\models\SsacWithdrawApi;
- use backend\models\WithdrawApi;
- use Yii;
- use yii\bootstrap\Html;
- class BankwithdrawController extends BaseController
- {
- /**
- * @return string
- */
- public function actionIndex()
- {
- return $this->render('index', [
- 'rate' => $this->getRate(),
- // 'fee' => $this->getFee(),
- ]);
- }
- /**
- * @return \yii\web\Response
- */
- public function actionAjax()
- {
- $searchModel = new WithdrawSearch();
- $dataProvider = $searchModel->search(Yii::$app->getRequest()->getQueryParams());
- return $this->asJson($searchModel->outResult($dataProvider));
- }
- /**
- * @return \yii\web\Response
- */
- public function actionSave()
- {
- $model = new WithdrawForm();
- if (Yii::$app->getRequest()->getIsPost()) {
- $model->setAttributes(Yii::$app->getRequest()->post());
- if ($model->addWithdraw()) {
- return $this->asJson([
- 'isSuccess' => true,
- 'msg' => '提交成功,请等待审核',
- ]);
- } else {
- return $this->asJson([
- 'isSuccess' => false,
- 'msg' => Html::errorSummary($model, ['header' => '']),
- ]);
- }
- }
- return $this->asJson([
- 'isSuccess' => false,
- 'msg' => 'Bad Request',
- ]);
- }
- public function actionGetSsacUserInfo()
- {
- $api = new SsacWithdrawApi();
- $result = $api->getUserInfo(Yii::$app->getUser()->getId(), Yii::$app->getRequest()->get('addrToken'));
- if ($result['code'] == 1) {
- return $this->asJson(['isSuccess' => true, 'data' => $result['data']]);
- } else {
- return $this->asJson(['isSuccess' => false, 'msg' => $result['message']]);
- }
- }
- public function actionOutGold()
- {
- $api = new SsacWithdrawApi();
- $result = $api->addWithdraw(Yii::$app->getUser()->getId(), Yii::$app->getRequest()->post());
- if ($result['code'] == 1) {
- return $this->asJson([
- 'isSuccess' => true,
- 'msg' => '提交成功,请等待审核',
- ]);
- } else {
- return $this->asJson([
- 'isSuccess' => false,
- 'msg' => $result['message'],
- ]);
- }
- }
- /**
- * @return \yii\web\Response
- */
- public function actionSsacAjax()
- {
- $searchModel = new SsacWithdrawSearch();
- $dataProvider = $searchModel->search(Yii::$app->getRequest()->getQueryParams());
- return $this->asJson($searchModel->outResult($dataProvider));
- }
- /**
- * @return array
- */
- protected function getRate()
- {
- $api = new RateApi();
- $result = $api->getRate();
- if ($result['code'] == 1) {
- return $result['data'];
- } else {
- return [];
- }
- }
- /**
- * @return bool
- * @deprecated
- */
- protected function getFee()
- {
- $api = new WithdrawApi();
- $result = $api->getMonthWithdraw(Yii::$app->getUser()->getId());
- return !empty($result['data']) ? true : false;
- }
- }
|