MainController.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace hd\controllers;
  3. use GatewayClient\Gateway;
  4. use bizHd\ad\services\AdService;
  5. use bizHd\goods\services\CategoryService;
  6. use bizHd\goods\services\GoodsCategoryService;
  7. use common\components\util;
  8. class MainController extends BaseController
  9. {
  10. public $guestAccessAction = ['index'];
  11. public function actionDemo()
  12. {
  13. return $this->renderPartial('demo');
  14. }
  15. //首页 shish 2019.12.2
  16. public function actionIndex()
  17. {
  18. $where = ['merchantId' => $this->sjId, 'type' => 0, 'status' => 1, 'delStatus' => 0];
  19. $adRespond = AdService::getAdList($where);
  20. $ad = [];
  21. if (isset($adRespond['list']) && !empty($adRespond['list'])) {
  22. foreach ($adRespond['list'] as $single) {
  23. $ad[] = ['adImg' => $single['adImgUrl'], 'url' => ''];
  24. }
  25. }
  26. $category = CategoryService::getTopThreeCategory($this->sjId);
  27. $categoryList = !empty($category) ? GoodsCategoryService::getAppointCategoryList($category) : [];
  28. $data = ['ad' => $ad, 'category' => $categoryList, 'columnStyle' => rand(1, 2)];
  29. util::success($data);
  30. }
  31. //新客户 shish 2019.12.29
  32. public function actionVisit()
  33. {
  34. $data = json_encode(array(
  35. 'type' => 'msg',
  36. 'msg' => 'aaaa',
  37. ));
  38. $id = 'merchantConsole_' . $this->sjId;
  39. $online = Gateway::getClientIdByUid($id);
  40. if ($online) {
  41. //直接发送
  42. Gateway::sendToUid($id, json_encode($data));
  43. } else {
  44. //保存
  45. }
  46. }
  47. //新订单 shish 2019.12.29
  48. public function actionOrder()
  49. {
  50. $data = json_encode(array(
  51. 'type' => 'msg',
  52. 'msg' => 'aaaa',
  53. ));
  54. $id = 'merchantConsole_' . $this->sjId;
  55. $online = Gateway::getClientIdByUid($id);
  56. if ($online) {
  57. //直接发送
  58. Gateway::sendToUid($id, json_encode($data));
  59. } else {
  60. //保存
  61. }
  62. }
  63. }