Ejemplo n.º 1
0
 public function actionLock($id)
 {
     $model = $this->findModel($id);
     $sina = new sina();
     $smember = SinaMember::find()->andWhere(['uid' => $model->member_id])->one();
     if ($smember && $smember->status == 1) {
         //$sina = new sina();
         $model->sinamoney = $sina->query_balance($smember->identity_id);
     } else {
         \Yii::$app->getSession()->setFlash('warning', '该用户没用绑定新浪账户');
     }
     if (\App::$app->request->post()) {
         if (\App::$app->request->post()['Info']['balance'] > $model->balance) {
             return $this->render('lock', ['model' => $model]);
         } else {
             sinapay::balanceFreeze($id, \App::$app->request->post()['Info']['balance'], '网站冻结');
             $model->balance -= \App::$app->request->post()['Info']['balance'];
             $model->freeze += \App::$app->request->post()['Info']['balance'];
             $model->save();
             return $this->redirect(['view', 'id' => $model->member_id]);
         }
     } else {
         return $this->render('lock', ['model' => $model]);
     }
 }