|
|
@@ -11,6 +11,7 @@ use bizGhs\item\classes\ItemClass;
|
|
|
use common\components\dateUtil;
|
|
|
use common\components\dict;
|
|
|
use common\components\util;
|
|
|
+use bizHd\stat\classes\StatOrderClass;
|
|
|
|
|
|
class ConsoleController extends BaseController
|
|
|
{
|
|
|
@@ -51,135 +52,48 @@ class ConsoleController extends BaseController
|
|
|
util::success(['overview' => $overview]);
|
|
|
}
|
|
|
|
|
|
- //概况
|
|
|
+ //概况 ssh 2019.12.19
|
|
|
public function actionProfile()
|
|
|
{
|
|
|
- //查看财务的权限
|
|
|
- $lookMoney = \bizGhs\shop\classes\ShopAdminClass::lookMoneyPower($this->shopAdmin, $this->shop);
|
|
|
-
|
|
|
- $lsIncome = 0;
|
|
|
- $orderCount = 0;
|
|
|
- $yesterdayIncome = 0;
|
|
|
-
|
|
|
- if ($lookMoney == 1) {
|
|
|
- $mainId = $this->mainId;
|
|
|
- $todayStr = date('Y-m-d');
|
|
|
-
|
|
|
- // 今天零售订单总数与收入
|
|
|
- $cacheKey = 'hd_console_profile:' . 'today_'.$todayStr.'_income_' . $this->shopId;
|
|
|
- $cache = \Yii::$app->redis->executeCommand('GET', [$cacheKey]);
|
|
|
- if ($cache) {
|
|
|
- $cacheData = json_decode($cache, true);
|
|
|
- $lsIncome = $cacheData['lsIncome'];
|
|
|
- $orderCount = $cacheData['orderCount'];
|
|
|
- } else {
|
|
|
- $period = dateUtil::formatTime('today', '', '', true);
|
|
|
- $start = $period['startTime'];
|
|
|
- $end = $period['endTime'];
|
|
|
- $currentStartDate = date('Y-m-d', strtotime($start));
|
|
|
- $currentEndDate = date('Y-m-d', strtotime($end));
|
|
|
- $currentStartTime = $currentStartDate . ' 00:00:00';
|
|
|
- $currentEndTime = $currentEndDate . ' 23:59:59';
|
|
|
-
|
|
|
- $where['time'] = ['between', [$start, $end]];
|
|
|
- $where = ['mainId' => $mainId, 'status' => ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]];
|
|
|
- $where['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
|
|
|
- $orderCount = OrderClass::getCount($where);
|
|
|
-
|
|
|
- // $lsIncome = 0;
|
|
|
- // $hdOrderList = OrderClass::getAllByCondition($where, null, 'mainPay, forward, cash');
|
|
|
- // foreach ($hdOrderList as $hdKey => $hdOrder) {
|
|
|
- // $actPrice = $hdOrder['mainPay'] ?? 0;
|
|
|
- // $forward = $hdOrder['forward'] ?? 0;
|
|
|
-
|
|
|
- // if ($forward == 1) { //零售售后付款
|
|
|
- // // $lsAfterSale = bcadd($lsAfterSale, $actPrice, 2);
|
|
|
- // } else {
|
|
|
- // $cash = $hdOrder['cash'] ?? 0;
|
|
|
- // $lsIncome = bcadd($actPrice, $lsIncome, 2);
|
|
|
- // $lsIncome = bcadd($lsIncome, $cash, 2);
|
|
|
- // }
|
|
|
- // }
|
|
|
- $mainId = $this->mainId;
|
|
|
- $respond = StatSaleClass::profile($mainId);
|
|
|
- $incomeList = $respond['income'] ?? [];
|
|
|
- $todaySale = 0;
|
|
|
- if (!empty($incomeList)) {
|
|
|
- //这里有二个地方同时要修改,请搜索关键词:index_show_income
|
|
|
- foreach ($incomeList as $item) {
|
|
|
- if (isset($item['id']) && $item['id'] == 'allot') {
|
|
|
- continue;
|
|
|
- }
|
|
|
- $todaySale = bcadd($todaySale, $item['amount'], 2);
|
|
|
- }
|
|
|
+ //$get = Yii::$app->request->get();
|
|
|
+ $notice = [];
|
|
|
+ $mainId = $this->mainId;
|
|
|
+ $respond = \bizGhs\stat\classes\StatSaleClass::profile($mainId);
|
|
|
+ $incomeList = $respond['income'] ?? [];
|
|
|
+ $todaySale = 0;
|
|
|
+ $yesterdayIncome = 0;
|
|
|
+ if (!empty($incomeList)) {
|
|
|
+ //这里有二个地方同时要修改,请搜索关键词:index_show_income
|
|
|
+ foreach ($incomeList as $item) {
|
|
|
+ if (isset($item['id']) && $item['id'] == 'allot') {
|
|
|
+ continue;
|
|
|
}
|
|
|
- $cacheData = [
|
|
|
- 'lsIncome' => $todaySale,
|
|
|
- 'orderCount' => $orderCount,
|
|
|
- ];
|
|
|
- \Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 1800, json_encode($cacheData, JSON_UNESCAPED_UNICODE)]);
|
|
|
+ $todaySale = bcadd($todaySale, $item['amount'], 2);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- // 昨天零售收入
|
|
|
- $cacheKey = 'hd_console_profile:' . 'yesterday_'.$todayStr.'_income_' . $this->shopId;
|
|
|
- $cache = \Yii::$app->redis->executeCommand('GET', [$cacheKey]);
|
|
|
- if ($cache) {
|
|
|
- $cacheData = json_decode($cache, true);
|
|
|
- $yesterdayIncome = $cacheData['yesterdayIncome'];
|
|
|
- } else {
|
|
|
- // $period = dateUtil::formatTime('yesterday', '', '', true);
|
|
|
- // $start = $period['startTime'];
|
|
|
- // $end = $period['endTime'];
|
|
|
- // $currentStartDate = date('Y-m-d', strtotime($start));
|
|
|
- // $currentEndDate = date('Y-m-d', strtotime($end));
|
|
|
- // $currentStartTime = $currentStartDate . ' 00:00:00';
|
|
|
- // $currentEndTime = $currentEndDate . ' 23:59:59';
|
|
|
- // $where['time'] = ['between', [$start, $end]];
|
|
|
- // $where = ['mainId' => $mainId, 'status' => ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]];
|
|
|
- // $where['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
|
|
|
- // $yesterdayIncome = 0;
|
|
|
- // $hdOrderList = OrderClass::getAllByCondition($where, null, 'mainPay, forward, cash');
|
|
|
- // foreach ($hdOrderList as $hdKey => $hdOrder) {
|
|
|
- // $actPrice = $hdOrder['mainPay'] ?? 0;
|
|
|
- // $forward = $hdOrder['forward'] ?? 0;
|
|
|
-
|
|
|
- // if ($forward == 1) { //零售售后付款
|
|
|
- // // $lsAfterSale = bcadd($lsAfterSale, $actPrice, 2);
|
|
|
- // } else {
|
|
|
- // $cash = $hdOrder['cash'] ?? 0;
|
|
|
- // $yesterdayIncome = bcadd($actPrice, $yesterdayIncome, 2);
|
|
|
- // $yesterdayIncome = bcadd($yesterdayIncome, $cash, 2);
|
|
|
- // }
|
|
|
- // }
|
|
|
+ $orderNum = $respond['totalOrderNum'] ?? 0;
|
|
|
|
|
|
- $mainId = $this->mainId;
|
|
|
- $_GET['searchTime'] = 'yesterday'; // 必须要有的,让其获取昨天的收入
|
|
|
- $respond = StatSaleClass::profile($mainId);
|
|
|
- $incomeList = $respond['income'] ?? [];
|
|
|
- $yesterdayIncome = 0;
|
|
|
- if (!empty($incomeList)) {
|
|
|
- //这里有二个地方同时要修改,请搜索关键词:index_show_income
|
|
|
- foreach ($incomeList as $item) {
|
|
|
- if (isset($item['id']) && $item['id'] == 'allot') {
|
|
|
- continue;
|
|
|
- }
|
|
|
- $yesterdayIncome = bcadd($yesterdayIncome, $item['amount'], 2);
|
|
|
- }
|
|
|
+ //访客数
|
|
|
+ $visitCustom = StatVisitClass::getVisitNum($this->mainId);
|
|
|
+ $wastage = \bizGhs\order\classes\StockWastageOrderClass::getTodayWaste($this->mainId);
|
|
|
+
|
|
|
+ $hsReturn = StatOrderClass::statHsNum($this->mainId);
|
|
|
+ $hsNum = $hsReturn['num'] ?? 0;
|
|
|
+ $mainId = $this->mainId;
|
|
|
+ $_GET['searchTime'] = 'yesterday'; // 必须要有的,让其获取昨天的收入
|
|
|
+ $respond = StatSaleClass::profile($mainId);
|
|
|
+ $incomeList = $respond['income'] ?? [];
|
|
|
+ $yesterdayIncome = 0;
|
|
|
+ if (!empty($incomeList)) {
|
|
|
+ //这里有二个地方同时要修改,请搜索关键词:index_show_income
|
|
|
+ foreach ($incomeList as $item) {
|
|
|
+ if (isset($item['id']) && $item['id'] == 'allot') {
|
|
|
+ continue;
|
|
|
}
|
|
|
-
|
|
|
- $cacheData = [
|
|
|
- 'yesterdayIncome' => $yesterdayIncome,
|
|
|
- ];
|
|
|
- \Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 86400, json_encode($cacheData, JSON_UNESCAPED_UNICODE)]);
|
|
|
+ $yesterdayIncome = bcadd($yesterdayIncome, $item['amount'], 2);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- //访客数
|
|
|
- $visitCustom = StatVisitClass::getVisitNum($this->shopId);
|
|
|
- // $wastage = \bizGhs\order\classes\StockWastageOrderClass::getTodayWaste($this->mainId);
|
|
|
- // $hsReturn = StatOrderClass::statHsNum($this->mainId);
|
|
|
- // $hsNum = $hsReturn['num'] ?? 0;
|
|
|
-
|
|
|
$menu = [
|
|
|
["name" => "商城", "img" => "ghs/home/shop2.png", "url" => "/admin/cg/mall", 'pf' => 1,],
|
|
|
["name" => "改价", "img" => "ghs/home/gj2.png", "url" => "/admin/changePrice/list2", 'pf' => 1,],
|
|
|
@@ -193,17 +107,19 @@ class ConsoleController extends BaseController
|
|
|
["name" => "花束", "img" => "ghs/home/kcyjs2.png", "url" => "/admin/goods/list", 'pf' => 1,],
|
|
|
["name" => "客户充值", "img" => "ghs/home/kcyjs2.png", "url" => "/admin/recharge/rechargeCode", 'pf' => 1,],
|
|
|
];
|
|
|
+
|
|
|
+ //查看财务的权限
|
|
|
+ $lookMoney = \bizGhs\shop\classes\ShopAdminClass::lookMoneyPower($this->shopAdmin, $this->shop);
|
|
|
+
|
|
|
$warning = '';
|
|
|
//$warning = '本月4号凌晨4点~5点系统升级,暂停使用';
|
|
|
+
|
|
|
util::success([
|
|
|
+ 'asset' => $this->main,
|
|
|
+ 'notice' => $notice,
|
|
|
'warning' => $warning,
|
|
|
- 'todayData' => [
|
|
|
- 'visit' => $visitCustom,
|
|
|
- 'income' => $lsIncome, //$todaySale,
|
|
|
- 'order' => $orderCount, //$orderNum,
|
|
|
- // 'wastage' => $wastage,
|
|
|
- // 'bouquet' => $hsNum
|
|
|
- ],
|
|
|
+ 'todayData' => ['visit' => $visitCustom, 'income' => $todaySale, 'order' => $orderNum, 'wastage' => $wastage, 'bouquet' => $hsNum],
|
|
|
+ 'incomeStat' => [],
|
|
|
'yesterdayIncome' => $yesterdayIncome,
|
|
|
'menu' => $menu,
|
|
|
'lookMoney' => $lookMoney,
|