| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- <?php
- namespace ghs\controllers;
- use biz\shop\classes\ShopClass;
- use bizGhs\order\classes\PurchaseOrderClass;
- use bizGhs\product\classes\ProductClass;
- use bizHd\stat\classes\StatIncomeClass;
- use bizHd\stat\classes\StatOrderClass;
- use common\components\imgUtil;
- use common\components\util;
- use Yii;
- use GatewayClient\Gateway;
- class MainController extends BaseController
- {
- public function actionDemo()
- {
- return $this->renderPartial('demo');
- }
- public function actionIndex()
- {
- return $this->renderPartial('index');
- }
- //新客户 ssh 2019.12.29
- public function actionVisit()
- {
- $data = json_encode(array(
- 'type' => 'msg',
- 'msg' => 'aaaa',
- ));
- $id = 'merchantConsole_' . $this->sjId;
- $online = Gateway::getClientIdByUid($id);
- if ($online) {
- //直接发送
- Gateway::sendToUid($id, json_encode($data));
- } else {
- //保存
- }
- }
- //新订单 ssh 2019.12.29
- public function actionOrder()
- {
- $data = json_encode(array(
- 'type' => 'msg',
- 'msg' => 'aaaa',
- ));
- $id = 'merchantConsole_' . $this->sjId;
- $online = Gateway::getClientIdByUid($id);
- if ($online) {
- //直接发送
- Gateway::sendToUid($id, json_encode($data));
- } else {
- //保存
- }
- }
- //经营概况 ssh 2021.1.27
- public function actionProfile()
- {
- //余额
- $shopInfo = ShopClass::getById($this->shopId);
- //库存情况
- $stockInfo = ProductClass::getProductStockByShopId($this->sjId,$this->shopId);
- //今日销售金额
- $today = StatIncomeClass::getAmountToday($this->shopId);
- //近七天销售金额
- $latestSeven = StatIncomeClass::getAmountWeek($this->shopId);
- //30天销售金额
- $latestThirty = StatIncomeClass::getAmountThirty($this->shopId);
- $base = [
- 'balance' => $shopInfo['balance'],
- 'mayGathering' => $shopInfo['mayGathering'],
- 'mayPay' => 0,
- 'stockCost' => $stockInfo['stockCost'],
- 'stockNum' => 0,
- 'stockBigNum' => $stockInfo['stockBigNum'],
- 'stockSmallNum' => $stockInfo['stockSmallNum'],
- 'stockWarning' => $stockInfo['stockWarning'],
- 'today' => $today,
- 'todayCompareYesterday' => 0,
- 'latestSeven' => $latestSeven,
- 'latestSevenSameTerm' => 0,
- 'latestThirty' => $latestThirty,
- 'latestThirtySameTerm' => 0,
- ];
- //今日订单数
- $saleNum = StatOrderClass::getRiseNumToday($this->shopId);
- //今日销售金额
- $saleAmount =$today;
- //昨日订单数
- $ySaleNum = StatOrderClass::getRiseNumYesterday($this->shopId);
- //昨日销售金额
- $ySaleAmount = StatIncomeClass::getAmountYesterday($this->shopId);
- //7天订单数
- $sevenSaleNum = StatOrderClass::getRiseNumWeek($this->shopId);
- //7天销售金额
- $sevenSaleAmount = $latestSeven;
- //30天订单数
- $thirtySaleNum = StatOrderClass::getRiseNumThirty($this->shopId);
- //30天销售金额
- $thirtySaleAmount = $latestThirty;
- //采购相关信息
- //今日采购数
- //今日采购金额
- $todayPurchaseStat = PurchaseOrderClass::statOrderInfo($this->shopId,"today");
- //昨日采购数
- //昨日采购金额
- $yesterdayPurchaseStat = PurchaseOrderClass::statOrderInfo($this->shopId,"yesterday");
- //7日采购数
- //7日采购金额
- $sevendayPurchaseStat = PurchaseOrderClass::statOrderInfo($this->shopId,"seven");
- //30日采购数
- //30日采购金额
- $thirtydayPurchaseStat = PurchaseOrderClass::statOrderInfo($this->shopId,"thirty");
- $more = [
- 'today' => [
- 'income' => 0,
- 'expend' => 0,
- 'saleNum' => $saleNum,
- 'saleAmount' => $saleAmount,
- 'purchaseNum' => $todayPurchaseStat['totalNum'],
- 'purchaseAmount' => $todayPurchaseStat['totalAmount'],
- ],
- 'yesterday' => [
- 'income' => 0,
- 'expend' => 0,
- 'saleNum' => $ySaleNum,
- 'saleAmount' => $ySaleAmount,
- 'purchaseNum' => $yesterdayPurchaseStat['totalNum'],
- 'purchaseAmount' => $yesterdayPurchaseStat['totalAmount'],
- ],
- 'latestSeven' => [
- 'income' => 0,
- 'expend' => 0,
- 'saleNum' => $sevenSaleNum,
- 'saleAmount' => $sevenSaleAmount,
- 'purchaseNum' => $sevendayPurchaseStat['totalNum'],
- 'purchaseAmount' => $sevendayPurchaseStat['totalAmount'],
- ],
- 'latestThirty' => [
- 'income' => 0,
- 'expend' => 0,
- 'saleNum' => $thirtySaleNum,
- 'saleAmount' => $thirtySaleAmount,
- 'purchaseNum' => $thirtydayPurchaseStat['totalNum'],
- 'purchaseAmount' => $thirtydayPurchaseStat['totalAmount'],
- ],
- ];
- util::success(['base' => $base, 'more' => $more]);
- }
- //我的 ssh 2021.1.30
- public function actionMy()
- {
- $shop = $this->shop;
- $balance = $shop['balance'] ?? 0.00;
- $txBalance = $shop['txBalance'] ?? 0.00;
- $sj = $this->sj;
- $shopImg = $shop['avatar'] ?? '';
- $deadline = $sj['deadline'] ?? '';
- $relation = $this->shopAdmin;
- $adminName = $relation['name'];
- $shopAdminId = $relation['id'];
- $mobile = $relation['mobile'] ?? '';
- $sjName = $sj['name'] ?? '';
- $shopName = $shop['shopName'] ?? '';
- $cashAccount = $shop['cashAccount'] ?? '';
- $data = [
- 'balance' => $balance,
- 'txBalance' => $txBalance,
- 'deadline' => $deadline,
- 'adminName' => $adminName,
- 'adminMobile' => $mobile,
- 'sjName' => $sjName,
- 'shopName' => $shopName,
- 'shopImg' => $shopImg,
- 'cashAccount' => $cashAccount,
- 'shopAdminId' => $shopAdminId,
- 'shopId' => $this->shopId,
- ];
- util::success($data);
- }
- }
|