MainController.php 6.3 KB

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