Esempio n. 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = MWxAction::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['wx_action_id' => $this->wx_action_id]);
     $query->andFilterWhere(['like', 'gh_id', $this->gh_id])->andFilterWhere(['like', 'keyword', $this->keyword])->andFilterWhere(['like', 'type', $this->type])->andFilterWhere(['like', 'action', $this->action]);
     return $dataProvider;
 }
Esempio n. 2
0
<?php

use yii\helpers\Html;
use yii\grid\GridView;
use app\models\MWxAction;
/* @var $this yii\web\View */
/* @var $searchModel common\models\search\MWxActionSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('backend', 'Wechat Actions');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="mwx-action-index">

    <p>
        <?php 
echo Html::a(Yii::t('backend', 'Create Wechat Action'), ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => ['wx_action_id', ['attribute' => 'keyword', 'value' => function ($model, $key, $index, $column) {
    return $model->getKeywordAlias();
}], ['attribute' => 'type', 'value' => function ($model, $key, $index, $column) {
    return MWxAction::getActionTypeOptionName($model->type);
}, 'filter' => MWxAction::getActionTypeOptionName()], 'action:ntext', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete}']]]);
?>

</div>
Esempio n. 3
0
$form = ActiveForm::begin();
?>

	<?php 
echo $form->field($model, 'inputEventType')->dropDownList(MWxAction::getInputEventTypeOptionName());
?>
	

	<div class="keyword">
	<?php 
echo $form->field($model, 'keyword')->textInput(['maxlength' => 128]);
?>
	</div>

	<?php 
echo $form->field($model, 'type')->dropDownList(MWxAction::getActionTypeOptionName());
?>
	

	<div class="text">
        <?php 
echo $form->field($model, 'content')->textarea(['rows' => 3])->label('内容');
?>
	</div>

	<div class="news">
		<?php 
echo $form->field($model, 'title')->textInput(['maxlength' => 256])->label('标题');
?>

        <?php 
Esempio n. 4
0
 /**
  * Finds the MWxAction model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return MWxAction the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = MWxAction::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 5
0
 protected function handleKeyword($keyword)
 {
     //U::W("-------------------------------handleKeyword----------------------------------------");
     $gh_id = $this->getRequest('ToUserName');
     $openid = $this->getRequest('FromUserName');
     $model = MWxAction::findOne(['gh_id' => $gh_id, 'keyword' => $keyword]);
     if ($keyword == "客服") {
         /*如果不是会员就跳转到手机绑定页面,先绑定手机成为会员*/
         //U::W("-------------------------------先绑定手机成为会员----------------------------------------");
         $user = MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]);
         if (empty($user->openidBindMobiles)) {
             //Yii::$app->getSession()->set('RETURN_URL', Url::to());
             //return $this->redirect(['addbindmobile', 'gh_id' => $gh_id, 'openid' => $openid]);
             $respText = "<a href=\"" . Url::to(['wap/addbindmobile', 'gh_id' => $gh_id, 'openid' => $openid], true) . "\">立即成为会员</a>\n\n尊享一对一人工客服!";
             return $this->responseText($respText);
         }
         $arr = $this->WxGetOnlineKfList();
         //auto_accept 客服设置的最大自动接入数
         //accepted_case   客服当前正在接待的会话数
         //U::W("------------------------------------------------------------------------------------");
         //U::W($arr);
         $auto_accept = 0;
         $accepted_case = 0;
         foreach ($arr as $a1) {
             //U::W($a1);
             $auto_accept = $auto_accept + (int) $a1["auto_accept"];
             $accepted_case = $accepted_case + (int) $a1["accepted_case"];
         }
         //U::W("+++++++++++++++++++++++++++++++++KF FULL+++++++++++++++++++++++++++++++++++++++++++++");
         //U::W($auto_accept."-----------\n");
         //U::W($accepted_case."-----------\n");
         if ($auto_accept - $accepted_case > 0) {
             return $this->responseTransfer();
         }
         //U::W("--------------------------------KF FULL--------------------------------------------");
         $respText = "亲~ 客服忙,请稍候再试。\n或直接输入您的问题,将自动进入自动回复。";
         return $this->responseText($respText);
     }
     if ($model === null) {
         return false;
     }
     return $model->getResp($this);
 }