MainController.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 $guestAccess = ['index'];
  11. public function actionDemo()
  12. {
  13. return $this->renderPartial('demo');
  14. }
  15. //首页 ssh 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. //新客户 ssh 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. //新订单 ssh 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. //我的 ssh 2021.4.8
  64. public function actionMy()
  65. {
  66. $shop = $this->shop;
  67. $balance = $shop['balance'] ?? 0.00;
  68. $txBalance = $shop['txBalance'] ?? 0.00;
  69. $sj = $this->sj;
  70. $shopImg = $shop['avatar'] ?? '';
  71. $deadline = $sj['deadline'] ?? '';
  72. $relation = $this->shopAdmin;
  73. $adminName = $relation['adminName'];
  74. $shopAdminId = $relation['id'];
  75. $mobile = $relation['mobile'] ?? '';
  76. $sjName = $sj['name'] ?? '';
  77. $shopName = $shop['shopName'] ?? '';
  78. $cashAccount = $shop['cashAccount'] ?? '';
  79. $data = [
  80. 'balance' => $balance,
  81. 'txBalance' => $txBalance,
  82. 'deadline' => $deadline,
  83. 'adminName' => $adminName,
  84. 'adminMobile' => $mobile,
  85. 'sjName' => $sjName,
  86. 'shopName' => $shopName,
  87. 'shopImg' => $shopImg,
  88. 'cashAccount' => $cashAccount,
  89. 'shopAdminId' => $shopAdminId,
  90. 'shopId' => $this->shopId,
  91. ];
  92. util::success($data);
  93. }
  94. }