MochatController.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\modules\common\controllers;
  8. use AopClient;
  9. use \app\models\AlipayAcitvityVoucherOrder;
  10. use app\models\ActivityOrdervoucher;
  11. use app\models\AlipayActivityDelivery;
  12. use app\models\AlipayVoucherCode;
  13. use app\models\Option;
  14. use app\models\Store;
  15. use app\models\StoreAliMini;
  16. use app\models\StoreAliMiniVersion;
  17. use app\models\StoreAliShop;
  18. use app\models\StoreMiniToken;
  19. use app\models\User;
  20. use app\models\UserCoupon;
  21. use app\modules\admin\models\AlipayThirdForm;
  22. use app\modules\admin\models\alipay\Card;
  23. use app\utils\Alipay\AlipayProfit;
  24. use app\utils\Alipay\alipaySdk\aop\request\AlipayOpenAuthTokenAppRequest;
  25. use yii\web\Controller;
  26. use app\utils\Delivery\Alipay\ADelivery;
  27. use app\modules\admin\models\mochat\MochatForm;
  28. use app\modules\admin\models\OrderListForm;
  29. use app\models\Order;
  30. class MochatController extends Controller
  31. {
  32. public function actionIndex()
  33. {
  34. $_a = get_params('_a');
  35. if($_a){
  36. return $this->$_a();
  37. }
  38. $agentId = get_params('agentId');
  39. $store_id = get_params('cyy_store_id');
  40. $store = Store::findOne(['is_delete' => 0, 'id' => $store_id]);
  41. if (!$store || empty($agentId)) {
  42. \Yii::error('<====================>授权回调 参数错误, 参数为:' . json_encode($_GET));
  43. echo '授权失败,参数错误';
  44. exit;
  45. }
  46. $res = MochatForm::setConfAgentId($store_id, $agentId);
  47. if ($res['code'] != 0) {
  48. \Yii::error('<====================> token解析失败, 参数为:' . json_encode($res));
  49. echo '授权失败,token解析失败,错误信息:' . $res['msg'];
  50. exit;
  51. }
  52. echo '授权成功!';
  53. exit;
  54. }
  55. /**
  56. * 平台商品订单列表
  57. * @return \yii\web\Response
  58. */
  59. public function actionApi() {
  60. // debug_log(all_params(), __CLASS__ . '.log');
  61. $_a = input_params('_a');
  62. $store_id = input_params('store_id');
  63. // $isopen = MochatForm::isopen($store_id);
  64. // if(!$isopen){
  65. // return $this->asJson([
  66. // 'code' => 1,
  67. // 'msg' => '未授权',
  68. // ]);
  69. // }
  70. if($_a && method_exists($this, $_a)){
  71. $res = $this->$_a($store_id);
  72. return $res;
  73. }
  74. }
  75. /**
  76. * 平台商品订单列表
  77. * @return \yii\web\Response
  78. */
  79. public function orderList($store_id) {
  80. debug_log(all_params(), __CLASS__ . '.log');
  81. // debug_log(post_params(), __CLASS__ . '.log');
  82. // debug_log(get_params(), __CLASS__ . '.log');
  83. // $form = new OrderListForm();
  84. // $form->attributes = all_params();
  85. // $form->store_id = $store_id;
  86. // return $this->asJson($form->search());
  87. }
  88. public function order($store_id) {
  89. $wxExternalUserid = input_params('wxExternalUserid');
  90. $roomId = input_params('roomId', input_params('wxChatId'));
  91. if(empty($wxExternalUserid) && empty($roomId)){
  92. return $this->asJson([
  93. 'code' => 1,
  94. 'msg' => '参数错误,缺少客户id或群id',
  95. ]);
  96. }
  97. $res = MochatForm::orderList($store_id, $wxExternalUserid, $roomId);
  98. return $this->asJson($res);
  99. }
  100. }