MainController.php 1.9 KB

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