MainController.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\shop\classes\ShopClass;
  4. use bizGhs\product\classes\ProductClass;
  5. use bizHd\stat\classes\StatIncomeClass;
  6. use bizHd\stat\classes\StatOrderClass;
  7. use common\components\imgUtil;
  8. use common\components\util;
  9. use Yii;
  10. use GatewayClient\Gateway;
  11. class MainController extends BaseController
  12. {
  13. public function actionDemo()
  14. {
  15. return $this->renderPartial('demo');
  16. }
  17. public function actionIndex()
  18. {
  19. return $this->renderPartial('index');
  20. }
  21. //新客户 ssh 2019.12.29
  22. public function actionVisit()
  23. {
  24. $data = json_encode(array(
  25. 'type' => 'msg',
  26. 'msg' => 'aaaa',
  27. ));
  28. $id = 'merchantConsole_' . $this->sjId;
  29. $online = Gateway::getClientIdByUid($id);
  30. if ($online) {
  31. //直接发送
  32. Gateway::sendToUid($id, json_encode($data));
  33. } else {
  34. //保存
  35. }
  36. }
  37. //新订单 ssh 2019.12.29
  38. public function actionOrder()
  39. {
  40. $data = json_encode(array(
  41. 'type' => 'msg',
  42. 'msg' => 'aaaa',
  43. ));
  44. $id = 'merchantConsole_' . $this->sjId;
  45. $online = Gateway::getClientIdByUid($id);
  46. if ($online) {
  47. //直接发送
  48. Gateway::sendToUid($id, json_encode($data));
  49. } else {
  50. //保存
  51. }
  52. }
  53. //经营概况 ssh 2021.1.27
  54. public function actionProfile()
  55. {
  56. //余额
  57. $shopInfo = ShopClass::getById($this->shopId);
  58. //库存情况
  59. $stockInfo = ProductClass::getProductStockByShopId($this->sjId,$this->shopId);
  60. //今日销售金额
  61. $today = StatIncomeClass::getAmountToday($this->shopId);
  62. //近七天销售金额
  63. $latestSeven = StatIncomeClass::getAmountWeek($this->shopId);
  64. //30天销售金额
  65. $latestThirty = StatIncomeClass::getAmountThirty($this->shopId);
  66. $base = [
  67. 'balance' => $shopInfo['balance'],
  68. 'mayGathering' => $shopInfo['mayGathering'],
  69. 'mayPay' => 0,
  70. 'stockCost' => $stockInfo['stockCost'],
  71. 'stockNum' => 0,
  72. 'stockBigNum' => $stockInfo['stockBigNum'],
  73. 'stockSmallNum' => $stockInfo['stockSmallNum'],
  74. 'stockWarning' => $stockInfo['stockWarning'],
  75. 'today' => $today,
  76. 'todayCompareYesterday' => 0,
  77. 'latestSeven' => $latestSeven,
  78. 'latestSevenSameTerm' => 0,
  79. 'latestThirty' => $latestThirty,
  80. 'latestThirtySameTerm' => 0,
  81. ];
  82. //今日订单数
  83. $saleNum = StatOrderClass::getRiseNumToday($this->shopId);
  84. //今日销售金额
  85. $saleAmount =$today;
  86. //昨日订单数
  87. $ySaleNum = StatOrderClass::getRiseNumYesterday($this->shopId);
  88. //昨日销售金额
  89. $ySaleAmount = StatIncomeClass::getAmountYesterday($this->shopId);
  90. //7天订单数
  91. $sevenSaleNum = StatOrderClass::getRiseNumWeek($this->shopId);
  92. //7天销售金额
  93. $sevenSaleAmount = $latestSeven;
  94. //30天订单数
  95. $thirtySaleNum = StatOrderClass::getRiseNumThirty($this->shopId);
  96. //30天销售金额
  97. $thirtySaleAmount = $latestThirty;
  98. //采购相关信息
  99. //今日采购数
  100. //今日采购金额
  101. //昨日采购数
  102. //昨日采购金额
  103. //7日采购数
  104. //7日采购金额
  105. //30日采购数
  106. //30日采购金额
  107. $more = [
  108. 'today' => [
  109. 'income' => 0,
  110. 'expend' => 0,
  111. 'saleNum' => $saleNum,
  112. 'saleAmount' => $saleAmount,
  113. 'purchaseNum' => 2,
  114. 'purchaseAmount' => 3,
  115. ],
  116. 'yesterday' => [
  117. 'income' => 0,
  118. 'expend' => 0,
  119. 'saleNum' => $ySaleNum,
  120. 'saleAmount' => $ySaleAmount,
  121. 'purchaseNum' => 2,
  122. 'purchaseAmount' => 3,
  123. ],
  124. 'latestSeven' => [
  125. 'income' => 0,
  126. 'expend' => 0,
  127. 'saleNum' => $sevenSaleNum,
  128. 'saleAmount' => $sevenSaleAmount,
  129. 'purchaseNum' => 2,
  130. 'purchaseAmount' => 3,
  131. ],
  132. 'latestThirty' => [
  133. 'income' => 0,
  134. 'expend' => 0,
  135. 'saleNum' => $thirtySaleNum,
  136. 'saleAmount' => $thirtySaleAmount,
  137. 'purchaseNum' => 2,
  138. 'purchaseAmount' => 3,
  139. ],
  140. ];
  141. util::success(['base' => $base, 'more' => $more]);
  142. }
  143. //我的 ssh 2021.1.30
  144. public function actionMy()
  145. {
  146. $shop = $this->shop;
  147. $balance = $shop['balance'] ?? 0.00;
  148. $txBalance = $shop['txBalance'] ?? 0.00;
  149. $sj = $this->sj;
  150. $shopImg = $shop['avatar'] ?? '';
  151. $deadline = $sj['deadline'] ?? '';
  152. $relation = $this->shopAdmin;
  153. $adminName = $relation['name'];
  154. $shopAdminId = $relation['id'];
  155. $mobile = $relation['mobile'] ?? '';
  156. $sjName = $sj['name'] ?? '';
  157. $shopName = $shop['shopName'] ?? '';
  158. $cashAccount = $shop['cashAccount'] ?? '';
  159. $data = [
  160. 'balance' => $balance,
  161. 'txBalance' => $txBalance,
  162. 'deadline' => $deadline,
  163. 'adminName' => $adminName,
  164. 'adminMobile' => $mobile,
  165. 'sjName' => $sjName,
  166. 'shopName' => $shopName,
  167. 'shopImg' => $shopImg,
  168. 'cashAccount' => $cashAccount,
  169. 'shopAdminId' => $shopAdminId,
  170. 'shopId' => $this->shopId,
  171. ];
  172. util::success($data);
  173. }
  174. }