asJson($res); // $res = MochatForm::employeeList(317, '张'); // return $this->asJson($res); // $res = MochatForm::contactUnionidToExternalUserid(317, '', '', 'o6mCr1asnPAYMHYw_iBv9P7sOzr0333'); // var_dump($res);die; $res = MochatForm::sendMsg(time(), 317, 2, 2023, ['coupon_id' => 185, 'goods_id' => 1198]); return $this->asJson($res); } public function actionConf() { $store_id = get_store_id(); $isopen = MochatForm::isopen($store_id); $conf = MochatForm::conf($store_id); $mini = []; $open_appid = []; $links = []; if($isopen){ $mini = WechatThirdForm::getUsedStoreMini($store_id); if(!$mini){ $open_appid = [ 'code' => 1, 'msg' => '没有使用中的小程序,请到小程序管理列表查看', ]; }else{ $form = new WechatThirdForm(); $form->mini_id = $mini->id; $open_appid = $form->openGet(); } $links[] = [ 'name' => '客户订单', 'url' => \Yii::$app->request->hostInfo . '/h5/#/open/mochat/order?_a=order&store_id=' . $store_id, // 'api' => \Yii::$app->request->hostInfo . '/index.php?r=common/mochat/api&store_id=' . $store_id . '&_a=order&pageNo=1&pageSize=10&wxExternalUserid=xxxxx&roomId=xxxx', ]; } return $this->asJson([ 'code' => 0, 'data' => [ 'isopen' => $isopen, 'conf' => $conf, 'open_appid' => $open_appid, 'mini' => $mini, 'links' => $links, ], ]); } public function actionSetConf() { $store_id = get_store_id(); $conf = [ 'isopen' => input_params('isopen'), 'mochatUrl' => trim(input_params('mochatUrl'), '/'), 'mochatUrl_sidebar' => trim(input_params('mochatUrl_sidebar'), '/'), 'agentId' => input_params('agentId'), 'sendMsg_wxUserId' => input_params('sendMsg_wxUserId'), 'sendMsg_wxUserId_name' => input_params('sendMsg_wxUserId_name'), 'corp_id' => input_params('corp_id'), 'token' => input_params('token'), ]; $res = MochatForm::setConf($store_id, array_keys($conf), array_values($conf)); return $this->asJson([ 'code' => 0, 'msg' => 'ok', ]); } public function actionEmployeeList() { $store_id = get_store_id(); $name = input_params('name'); $page = input_params('page', 1); $pageSize = input_params('pageSize', 30); $res = MochatForm::employeeList($store_id, $name, $page, $pageSize); return $this->asJson($res); } public function actionSetConfMochatUrl() { $store_id = get_store_id(); $mochatUrl = trim(input_params('mochatUrl')); $res = MochatForm::setConfMochatUrl($store_id, $mochatUrl); return $this->asJson($res); } public function actionCreateUrl() { $store_id = get_store_id(); $res = MochatForm::createUrl($store_id); return $this->asJson($res); } public function actionWorkRoomList() { $store_id = get_store_id(); $page = input_params('page', input_params('pageNo', 1)); $pageSize = input_params('pageSize', 30); $res = MochatForm::workRoomList($store_id, [ 'page' => $page, 'perPage' => $pageSize, ]); return $this->asJson($res); } }