IndexController.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\modules\admin\controllers\mochat;
  8. use app\models\Store;
  9. use app\models\Option;
  10. use app\models\Order;
  11. use app\constants\OptionSetting;
  12. use app\modules\admin\models\mochat\MochatForm;
  13. use app\modules\admin\models\WechatThirdForm;
  14. /**
  15. * Class GoodsController
  16. * @package app\modules\admin\controllers
  17. */
  18. class IndexController extends BaseController
  19. {
  20. public function actionTest() {
  21. $store_id = get_store_id();
  22. $res = MochatForm::orderList(84, '', 'wrWU_lBwAAW4YpOeq7uKGDwefmmnHtCQ');
  23. return $this->asJson($res);
  24. // $res = MochatForm::employeeList(317, '张');
  25. // return $this->asJson($res);
  26. // $res = MochatForm::contactUnionidToExternalUserid(317, '', '', 'o6mCr1asnPAYMHYw_iBv9P7sOzr0333');
  27. // var_dump($res);die;
  28. $res = MochatForm::sendMsg(time(), 317, 2, 2023, ['coupon_id' => 185, 'goods_id' => 1198]);
  29. return $this->asJson($res);
  30. }
  31. public function actionConf() {
  32. $store_id = get_store_id();
  33. $isopen = MochatForm::isopen($store_id);
  34. $conf = MochatForm::conf($store_id);
  35. $mini = [];
  36. $open_appid = [];
  37. $links = [];
  38. if($isopen){
  39. $mini = WechatThirdForm::getUsedStoreMini($store_id);
  40. if(!$mini){
  41. $open_appid = [
  42. 'code' => 1,
  43. 'msg' => '没有使用中的小程序,请到小程序管理列表查看',
  44. ];
  45. }else{
  46. $form = new WechatThirdForm();
  47. $form->mini_id = $mini->id;
  48. $open_appid = $form->openGet();
  49. }
  50. $links[] = [
  51. 'name' => '客户订单',
  52. 'url' => \Yii::$app->request->hostInfo . '/h5/#/open/mochat/order?_a=order&store_id=' . $store_id,
  53. // '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',
  54. ];
  55. }
  56. return $this->asJson([
  57. 'code' => 0,
  58. 'data' => [
  59. 'isopen' => $isopen,
  60. 'conf' => $conf,
  61. 'open_appid' => $open_appid,
  62. 'mini' => $mini,
  63. 'links' => $links,
  64. ],
  65. ]);
  66. }
  67. public function actionSetConf() {
  68. $store_id = get_store_id();
  69. $conf = [
  70. 'isopen' => input_params('isopen'),
  71. 'mochatUrl' => trim(input_params('mochatUrl'), '/'),
  72. 'mochatUrl_sidebar' => trim(input_params('mochatUrl_sidebar'), '/'),
  73. 'agentId' => input_params('agentId'),
  74. 'sendMsg_wxUserId' => input_params('sendMsg_wxUserId'),
  75. 'sendMsg_wxUserId_name' => input_params('sendMsg_wxUserId_name'),
  76. 'corp_id' => input_params('corp_id'),
  77. 'token' => input_params('token'),
  78. ];
  79. $res = MochatForm::setConf($store_id, array_keys($conf), array_values($conf));
  80. return $this->asJson([
  81. 'code' => 0,
  82. 'msg' => 'ok',
  83. ]);
  84. }
  85. public function actionEmployeeList() {
  86. $store_id = get_store_id();
  87. $name = input_params('name');
  88. $page = input_params('page', 1);
  89. $pageSize = input_params('pageSize', 30);
  90. $res = MochatForm::employeeList($store_id, $name, $page, $pageSize);
  91. return $this->asJson($res);
  92. }
  93. public function actionSetConfMochatUrl() {
  94. $store_id = get_store_id();
  95. $mochatUrl = trim(input_params('mochatUrl'));
  96. $res = MochatForm::setConfMochatUrl($store_id, $mochatUrl);
  97. return $this->asJson($res);
  98. }
  99. public function actionCreateUrl() {
  100. $store_id = get_store_id();
  101. $res = MochatForm::createUrl($store_id);
  102. return $this->asJson($res);
  103. }
  104. public function actionWorkRoomList() {
  105. $store_id = get_store_id();
  106. $page = input_params('page', input_params('pageNo', 1));
  107. $pageSize = input_params('pageSize', 30);
  108. $res = MochatForm::workRoomList($store_id, [
  109. 'page' => $page,
  110. 'perPage' => $pageSize,
  111. ]);
  112. return $this->asJson($res);
  113. }
  114. }