[ 'class' => LoginBehavior::className(), ], ]); } public function actionConfig() { $model = SmsSetting::findOne([ 'cx_mch_id' => $this->cx_mch_id, ]); if($model == null){ $model = new SmsSetting(); } if(\Yii::$app->request->isPost){ $form = new SmsConfigEditForm(); $form->attributes = \Yii::$app->request->post(); $form->cx_mch_id = $this->cx_mch_id; $form->model = $model; $redis_name = "api:cxaibc:ddl_sms:send_sms_pl"; \Yii::$app->redis->set($redis_name,\Yii::$app->request->post('ddl_sms')); $redis_name = "api:cxaibc:bj_sms:send_sms_pl"; \Yii::$app->redis->set($redis_name,\Yii::$app->request->post('bj_sms')); $redis_name = "api:cxaibc:ddl_number:send"; \Yii::$app->redis->set($redis_name,\Yii::$app->request->post('ddl_number')); $redis_name = "api:cxaibc:send:send_time"; \Yii::$app->redis->set($redis_name,\Yii::$app->request->post('send_time')); $redis_name = "api:cxaibc:bj_time_sms:send_sms_pl"; \Yii::$app->redis->set($redis_name,\Yii::$app->request->post('bj_time_sms')); $data = $form->save(); // 删除所有数据 $select_qc = BallCart::find()->select('id,ball_number')->all(); $arr_msg = [ '低电量','发出链路异常告警','发出倾倒告警','超出安全范围','超出门店范围' ]; $redis_name = "api:cxaibc:mqtt:send_setting_v3"; \Yii::$app->redis->del($redis_name); foreach ($select_qc as $key=>$val){ foreach ($arr_msg as $k=>$v){ $md5 = md5("{$val->ball_number}{$v}"); $redis_name = "api:cxaibc:send_sms:lock:{$md5}"; \Yii::$app->redis->del($redis_name); } } return $this->responseHandler($data); } $return_url = ""; $type = $model->isNewRecord ? SmsSetting::TYPE_ALIYUN : $model->type; $redis_name = "api:cxaibc:ddl_sms:send_sms_pl"; $ddl_sms = \Yii::$app->redis->get($redis_name); $redis_name = "api:cxaibc:bj_sms:send_sms_pl"; $bj_sms = \Yii::$app->redis->get($redis_name); $redis_name = "api:cxaibc:ddl_number:send"; $ddl_number = \Yii::$app->redis->get($redis_name); $redis_name = "api:cxaibc:send:send_time"; $send_time = \Yii::$app->redis->get($redis_name); $redis_name = "api:cxaibc:bj_time_sms:send_sms_pl"; $bj_time_sms = \Yii::$app->redis->get($redis_name); return $this->render('config',[ 'return_url' => $return_url, 'model' => $model, 'tpl_list' => SmsTpl::getTplList($type, $this->cx_mch_id), 'ddl_sms' => $ddl_sms, 'bj_sms' => $bj_sms, 'ddl_number' => $ddl_number, 'send_time' => $send_time, 'bj_time_sms' => $bj_time_sms, ]); } }