MainController.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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['name'];
  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. 'sjId'=>$this->sjId,
  92. ];
  93. util::success($data);
  94. }
  95. //经营概况 ssh 2021.1.27
  96. public function actionProfile()
  97. {
  98. $base = [
  99. 'balance' => 5020.00,
  100. 'mayGathering' => 10,
  101. 'mayPay' => 20,
  102. 'stockCost' => 2000,
  103. 'stockNum' => 100,
  104. 'stockWarning' => 5,
  105. 'today' => 90,
  106. 'todayCompareYesterday' => -5,
  107. 'latestSeven' => 9000,
  108. 'latestSevenSameTerm' => 10,
  109. 'latestThirty' => 8000,
  110. 'latestThirtySameTerm' => -9,
  111. ];
  112. $more = [
  113. 'today' => [
  114. 'income' => 10,
  115. 'expend' => 2,
  116. 'saleNum' => 1,
  117. 'saleAmount' => 100,
  118. 'purchaseNum' => 2,
  119. 'purchaseAmount' => 3,
  120. ],
  121. 'yesterday' => [
  122. 'income' => 10,
  123. 'expend' => 2,
  124. 'saleNum' => 1,
  125. 'saleAmount' => 100,
  126. 'purchaseNum' => 2,
  127. 'purchaseAmount' => 3,
  128. ],
  129. 'latestSeven' => [
  130. 'income' => 10,
  131. 'expend' => 2,
  132. 'saleNum' => 1,
  133. 'saleAmount' => 100,
  134. 'purchaseNum' => 2,
  135. 'purchaseAmount' => 3,
  136. ],
  137. 'latestThirty' => [
  138. 'income' => 10,
  139. 'expend' => 2,
  140. 'saleNum' => 1,
  141. 'saleAmount' => 100,
  142. 'purchaseNum' => 2,
  143. 'purchaseAmount' => 3,
  144. ],
  145. ];
  146. util::success(['base' => $base, 'more' => $more]);
  147. }
  148. }