Exemplo n.º 1
0
 public function record()
 {
     $user = Yii::$app->session->get('user');
     $model = Withdraw::find()->where(['userId' => $user['userId'], 'state' => Withdraw::STATE_APPLYING])->one();
     if ($model) {
         return false;
     }
     $withdraw = new Withdraw();
     $withdraw->userId = $user['userId'];
     $withdraw->money = $this->money;
     $withdraw->bitcoin = ceil(Scheme::calculateWithdrawBitcoin($user, $this->money));
     //扣除云豆数为向上取整,有小数就整数部分加1
     $withdraw->invoiceMoney = $this->invoiceMoney;
     $withdraw->invoiceNo = $this->invoiceNo;
     $withdraw->createDate = DateFunctions::getCurrentDate();
     $withdraw->state = Withdraw::STATE_APPLYING;
     if (!$withdraw->save()) {
         throw new Exception("Withdraw save error");
     }
     return true;
 }
Exemplo n.º 2
0
 /** 提现金额查询 */
 public function actionSearch()
 {
     $user = Yii::$app->session->get('user');
     $request = Yii::$app->request;
     $query = Yii::$app->session->getFlash('query');
     if ($request->isPost) {
         $type = $request->post('type');
         $content = $request->post('content');
     } else {
         $type = $request->get('type');
         $content = trim($request->get('content'));
     }
     if ($type || !$query) {
         switch ($type) {
             case 'withdraw-more':
                 $query = Withdraw::find()->where(['userId' => $user['userId']])->andWhere(['>=', 'money', $content]);
                 break;
             case 'withdraw-equal':
                 $query = Withdraw::find()->where(['userId' => $user['userId']])->andWhere(['=', 'money', $content]);
                 break;
             case 'withdraw-less':
                 $query = Withdraw::find()->where(['userId' => $user['userId']])->andWhere(['<=', 'money', $content]);
                 break;
             case 'state':
                 $query = Withdraw::find()->where(['userId' => $user['userId']])->andWhere(['state' => $content]);
                 break;
             default:
                 $query = Withdraw::find();
                 break;
         }
     }
     Yii::$app->session->setFlash('query', $query);
     $pagination = new Pagination(['defaultPageSize' => Yii::$app->params['pageSize'], 'totalCount' => $query->count()]);
     $model = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['createDate' => SORT_DESC])->all();
     return $this->render('index', ['models' => $model, 'pages' => $pagination]);
 }
 public function actionSearch()
 {
     $request = Yii::$app->request;
     $session = Yii::$app->session;
     $query = $session->getFlash('query');
     if ($request->isPost) {
         $type = $request->post('type');
         $content = $request->post('content');
     } else {
         $type = $request->get('type');
         $content = trim($request->get('content'));
     }
     if ($type || !$query) {
         switch ($type) {
             case 'nickname':
                 $table_a = Withdraw::tableName();
                 $table_b = Users::tableName();
                 $query = Withdraw::find()->leftJoin($table_b, "{$table_a}.userId={$table_b}.userId")->where(['like', "{$table_b}.nickname", $content]);
                 break;
             case 'money-more':
                 $query = Withdraw::find()->Where(['>=', 'money', $content]);
                 break;
             case 'money-equal':
                 $query = Withdraw::find()->where(['==', 'money', $content]);
                 break;
             case 'money-less':
                 $query = Withdraw::find()->Where(['<=', 'money', $content]);
                 break;
             case 'apply':
                 $query = Withdraw::find()->where(['state' => $content]);
                 break;
             case 'agree':
                 $query = Withdraw::find()->where(['state' => $content]);
                 break;
             case 'refuse':
                 $query = Withdraw::find()->where(['state' => $content]);
                 break;
             case 'role':
                 $role = '';
                 if ($content == 'a' || $content == 'A' || $content == 'A级') {
                     $role = Users::ROLE_A;
                 } elseif (strstr('金牌伙伴', $content)) {
                     $role = Users::ROLE_AA;
                 } elseif (strstr('钻石伙伴', $content)) {
                     $role = Users::ROLE_AAA;
                 } elseif ($content == '管理员') {
                     $role = Users::ROLE_ADMIN;
                 }
                 $table_a = Withdraw::tableName();
                 $table_b = Users::tableName();
                 $query = Withdraw::find()->leftJoin($table_b, "{$table_a}.userId={$table_b}.userId")->where(["{$table_b}.role" => $role]);
                 break;
             default:
                 $query = Withdraw::find()->where(['like', $type, $content]);
                 break;
         }
     }
     Yii::$app->session->setFlash('query', $query);
     $pagination = new Pagination(['defaultPageSize' => Yii::$app->params['pageSize'], 'totalCount' => $query->count()]);
     $model = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['createDate' => SORT_DESC])->all();
     return $this->render('index', ['models' => $model, 'pages' => $pagination]);
 }