public function actionPublish()
 {
     $accountId = $this->getAccountId();
     $redis = Yii::$app->cache->redis;
     $settings = $redis->get(self::SELF_SETTING_PREFIX . $accountId);
     $selfHelpDeskSetting = SelfHelpDeskSetting::findOne(['accountId' => new MongoId($accountId)]);
     if (!empty($settings)) {
         $settings = unserialize($settings);
         $settings['isPublished'] = true;
         $redis->set(self::SELF_SETTING_PREFIX . $accountId, serialize($settings));
         if (empty($selfHelpDeskSetting)) {
             $selfHelpDeskSetting = new SelfHelpDeskSetting();
         }
         $selfHelpDeskSetting['settings'] = $settings['settings'];
         $selfHelpDeskSetting['accountId'] = $settings['accountId'];
         if ($selfHelpDeskSetting->save()) {
             return ['status' => 'ok'];
         } else {
             return ['status' => 'failed'];
         }
     } else {
         if (!empty($selfHelpDeskSetting)) {
             $selfHelpDeskSetting->delete();
         }
         return ['status' => 'ok'];
     }
 }
Exemplo n.º 2
0
 /**
  * Get the detail information of the self helpdesk setting
  *
  * <b>Request Type: </b>GET<br/>
  * <b>Request Endpoint: </b>http://{server-domain}/api/helpdesk/setting/self-helpdesk<br/>
  * <b>Content-type: </b>Application/json<br/>
  * <b>Summary: </b>This api is for get the detail information of the self helpdesk setting.<br/>
  *
  * <b>Response Example: </b>
  * <pre>
  * {
  *     "id": "56187e882736e752058b4578",
  *     "settings": {
  *         "type": "reply",
  *         "content": "您好,很高兴为您服务,您可以输入序号查看一下内容:
  * [1] 卡片申请
  * [2] 办卡寄送进度查询
  * [3] 开卡/办卡
  * [4] 推荐亲友办卡",
  *         "menus": {
  *             "1": {
  *                 "content": "回复数字
  * 1. 绑定
  * 2. 解绑
  * 3. 返回上一级",
  *                 "type": "reply",
  *                 "menus": {
  *                     "1": {
  *                         "content": "您已绑定成功",
  *                         "type": "reply"
  *                     },
  *                     "2": {
  *                         "content": "已为您解绑",
  *                         "type": "reply"
  *                     },
  *                     "3": {
  *                         "content": "返回上一级",
  *                         "type": "back"
  *                     }
  *                 }
  *             },
  *             "2": {
  *                 "content": "回复数字
  * 1. 短信服务绑定
  * 2. 短信服务解绑
  * 3. 绑定手机重置密码
  * 4. 返回上一级",
  *                 "type": "reply",
  *                 "menus": {
  *                     "1": {
  *                         "content": "短信服务绑定成功",
  *                         "type": "reply"
  *                     },
  *                     "2": {
  *                         "content": "短信服务解绑成功",
  *                         "type": "reply"
  *                     },
  *                     "3": {
  *                         "content": "手机重置密码绑定成功",
  *                         "type": "reply"
  *                     },
  *                     "4": {
  *                         "content": "",
  *                         "type": "back"
  *                     }
  *                 }
  *             },
  *             "3": {
  *                 "content": "回复数字
  * 1. 密保绑定状态
  * 2. 密保卡使用状态
  * 3. 返回上一级",
  *                 "type": "reply",
  *                 "menus": {
  *                     "1": {
  *                         "content": "密保绑定成功",
  *                         "type": "reply"
  *                     },
  *                     "2": {
  *                         "content": "密保卡已被使用",
  *                         "type": "reply"
  *                     },
  *                     "3": {
  *                         "content": "",
  *                         "type": "back"
  *                     }
  *                 }
  *             },
  *             "4": {
  *                 "content": "",
  *                 "type": "connect",
  *                 "menus": [ ]
  *             }
  *         }
  *     }
  * }
  * </pre>
  */
 public function actionSelfHelpdesk()
 {
     $accountId = $this->getAccountId();
     if (!$accountId) {
         $accountId = $this->getQuery('cid');
     }
     if (empty($accountId)) {
         throw new BadRequestHttpException("AccountId is required");
     }
     return SelfHelpDeskSetting::findOne(['accountId' => $accountId]);
 }