| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\admin\controllers\mochat;
- use app\models\Store;
- use app\models\Option;
- use app\models\Order;
- use app\constants\OptionSetting;
- use app\modules\admin\models\mochat\MochatForm;
- use app\modules\admin\models\WechatThirdForm;
- /**
- * Class GoodsController
- * @package app\modules\admin\controllers
- */
- class IndexController extends BaseController
- {
-
- public function actionTest() {
- $store_id = get_store_id();
- $res = MochatForm::orderList(84, '', 'wrWU_lBwAAW4YpOeq7uKGDwefmmnHtCQ');
- return $this->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);
- }
- }
|