예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Users::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'directalliancecount' => $this->directalliancecount, 'allalliancecount' => $this->allalliancecount, 'corns' => $this->corns, 'money' => $this->money, 'envelope' => $this->envelope, 'cornsforgrab' => $this->cornsforgrab, 'alliancerewards' => $this->alliancerewards, 'gender' => $this->gender, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'friendcount' => $this->friendcount, 'concerncount' => $this->concerncount, 'isdraw' => $this->isdraw]);
     $query->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'pwd', $this->pwd])->andFilterWhere(['like', 'authKey', $this->authKey])->andFilterWhere(['like', 'fatherid', $this->fatherid])->andFilterWhere(['like', 'nickname', $this->nickname])->andFilterWhere(['like', 'thumb', $this->thumb])->andFilterWhere(['like', 'area', $this->area])->andFilterWhere(['like', 'job', $this->job])->andFilterWhere(['like', 'hobby', $this->hobby])->andFilterWhere(['like', 'signature', $this->signature])->andFilterWhere(['like', 'channel', $this->channel])->andFilterWhere(['like', 'platform', $this->platform]);
     return $dataProvider;
 }
예제 #2
0
 public function actionDelete()
 {
     $data = Yii::$app->request->post();
     if (isset($data['myphone']) && isset($data['concernphone'])) {
         $u1 = Users::find()->where(['phone' => $data['myphone']])->one();
         $u2 = Users::find()->where(['phone' => $data['concernphone']])->one();
         if (!Concerns::findAll(['myid' => $u1['id'], 'concernid' => $u2['id']])) {
             return array('flag' => 1, 'msg' => 'is already not concern!');
         }
         Concerns::deleteAll('myid = :myid and concernid = :concernid', [':myid' => $u1['id'], ':concernid' => $u2['id']]);
         $u2->concerncount--;
         $u2->save();
         return array('flag' => 1, 'msg' => 'delete concern success!');
     } else {
         return array('flag' => 0, 'msg' => 'arg not enough!');
     }
 }
예제 #3
0
 public function actionReply()
 {
     $data = Yii::$app->request->post();
     //$user=new Users();
     $fromphone = Users::find()->select('id')->where(['phone' => $data['fphone']])->one();
     //var_dump($fromphone);
     $model = new Replys();
     if ($data['tphone'] == '') {
         $model->toid = 0;
     } else {
         $tophone = Users::find()->select('id')->where(['phone' => $data['tphone']])->one();
         //var_dump($tophone);
         $model->toid = $tophone['id'];
     }
     // 		$to=Messages::findOne(['id'=>$data['msgid']]);
     // 		if($fromphone['id']!=$to['id']){
     // 			$model3=new Notify();
     // 			$model3->from=$fromphone['id'];
     // 			$model3->to=$to['userid'];
     // 			//$model3->kind='评论';
     // 			$model3->kind=$data['content'];
     // 			$model3->created_at=time();
     // 			$model3->msg_id=$data['msgid'];
     // 			if(!$model3->save()){
     // 				echo json_encode ( array (
     // 						'flag' => 0,
     // 						'msg' => 'Reply failed!'
     // 				));
     // 				return;
     // 			}
     // 		}
     $model->fromid = $fromphone['id'];
     $model->messageid = $data['messageid'];
     $model->content = $data['content'];
     $model->isread = 0;
     $model->created_at = time();
     //var_dump($model);
     if ($model->save()) {
         return array('flag' => 1, 'msg' => 'Reply success!');
     } else {
         return array('flag' => 0, 'msg' => 'Reply failed!');
     }
 }
예제 #4
0
 public function actionDelete()
 {
     $data = Yii::$app->request->post();
     if (isset($data['myphone']) && isset($data['friendphone'])) {
         $u1 = Users::find()->where(['phone' => $data['myphone']])->one();
         $u2 = Users::find()->where(['phone' => $data['friendphone']])->one();
         if (!Friends::findAll(['myid' => $u1['id'], 'friendid' => $u2['id']]) && !Friends::findAll(['myid' => $u2['id'], 'friendid' => $u1['id']])) {
             return array('flag' => 0, 'msg' => 'is already not friend!');
         }
         Friends::deleteAll('myid = :myid and friendid = :friendid or myid = :friendid and friendid = :myid', [':myid' => $u1['id'], ':friendid' => $u2['id']]);
         $easeclient = new Easeapi('YXA6halokJDEEeWMRgvYONLZPQ', 'YXA6pswnZbss8mj351XE3oxuRYm6cek', '13022660999', 'allpeopleleague', 'file');
         $result = json_decode($easeclient->curl('/users/' . $u1->id . '/contacts/users/' . $u2->id, '', 'DELETE'), true);
         return array('flag' => 1, 'msg' => 'delete friend success!');
     } else {
         return array('flag' => 0, 'msg' => 'arg not enough!');
     }
 }
예제 #5
0
 public function actionReply()
 {
     $data = Yii::$app->request->post();
     //$user=new Users();
     $fromphone = Users::find()->select('id')->where(['phone' => $data['fphone']])->one();
     //var_dump($fromphone);
     $model = new Tbreplys();
     if ($data['tphone'] == '') {
         $model->toid = 0;
     } else {
         $tophone = Users::find()->select('id')->where(['phone' => $data['tphone']])->one();
         //var_dump($tophone);
         $model->toid = $tophone['id'];
     }
     // 		$to=Messages::findOne(['id'=>$data['msgid']]);
     // 		if($fromphone['id']!=$to['id']){
     // 			$model3=new Notify();
     // 			$model3->from=$fromphone['id'];
     // 			$model3->to=$to['userid'];
     // 			//$model3->kind='评论';
     // 			$model3->kind=$data['content'];
     // 			$model3->created_at=time();
     // 			$model3->msg_id=$data['msgid'];
     // 			if(!$model3->save()){
     // 				echo json_encode ( array (
     // 						'flag' => 0,
     // 						'msg' => 'Reply failed!'
     // 				));
     // 				return;
     // 			}
     // 		}
     $model->fromid = $fromphone['id'];
     $model->tbmessageid = $data['tbmessageid'];
     $model->content = $data['content'];
     $model->isread = 0;
     $model->created_at = time();
     //var_dump($model);
     $tbmessage = $this->findModel($data['tbmessageid']);
     $connection = Yii::$app->db;
     $transaction = $connection->beginTransaction();
     try {
         if (!$model->save()) {
             throw new Exception("dsfgsdfg");
         }
         $tbmessage->replycount++;
         if (!$tbmessage->save()) {
             throw new Exception("asdfgsdfg");
         }
         $transaction->commit();
     } catch (Exception $e) {
         $transaction->rollBack();
         //var_dump("133435465");
         //Yii::$app->log->logger->
         return array('flag' => 0, 'msg' => 'Reply fail!');
     }
     return array('flag' => 1, 'msg' => 'Reply success!');
 }
예제 #6
0
 public function actionSetchannel()
 {
     $data = Yii::$app->request->post();
     $user = Users::find()->where(['phone' => $data['phone']])->one();
     if ($user) {
         if ($user . updateChannel($data['channel'])) {
             return array('flag' => 1, 'msg' => 'update user channel success');
         } else {
             return array('flag' => 0, 'msg' => 'update user channel fail');
         }
     } else {
         return array('flag' => 0, 'msg' => 'can not find the user');
     }
 }