$this->shopId, 'debt' => 0, 'debtPrice' => '0.00']; $where['status'] = ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]; $where['addTime'] = ['between', [$todayStartTime, $todayEndTime]]; $todayActIncome = OrderClass::sum($where, 'actPrice'); // 今日实收 $todayActIncome = $todayActIncome === null ? 0 : $todayActIncome; $where = ['shopId' => $this->shopId, 'debt' => 1]; // 查询条件重新赋值 $where['addTime'] = ['between', [$todayStartTime, $todayEndTime]]; $todayDebt = OrderClass::sum($where, 'remainDebtPrice'); // 今日欠款 $todayDebt = $todayDebt === null ? 0 : $todayDebt; $where = ['shopId' => $this->shopId, 'debt' => 1]; // 重新赋值 $totalDebt = OrderClass::sum($where, 'remainDebtPrice'); // 总欠款 $totalDebt = $totalDebt === null ? 0 : $totalDebt; util::success(['todayActIncome' => $todayActIncome, 'todayDebt' => $todayDebt, 'totalDebt' => $totalDebt]); } //今日笔数和总金额 public function actionStrokeCount() { $todayDate = date('Y-m-d'); $todayStartTime = $todayDate . ' 00:00:00'; $todayEndTime = $todayDate . ' 23:59:59'; //线上收入 180笔 12000元 //xhGhsOrder actPrice 字段,条件:debtPrice=0 and status in (2,3,4) and payWay in (0,1) //xhOrder actPrice 字段,条件 status in (2,3,4) and payWay in (0,1) $where = ['shopId' => $this->shopId, 'debt' => 0, 'debtPrice' => '0.00']; $where['status'] = ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]; $where['payWay'] = ['in', [0, 1]]; $where['addTime'] = ['between', [$todayStartTime, $todayEndTime]]; $ghsOnlineCount = OrderClass::getCount($where); // 批发今日收入总笔数 $ghsActIncome = OrderClass::sum($where, 'actPrice'); // 批发今日实收总数 Yii::info('批发今日收入总笔数:' . $ghsOnlineCount . ', 批发今日实收总数:' . $ghsActIncome); unset($where['debt']); unset($where['debtPrice']); $hdActualCount = HdOrderClass::getCount($where); // 花店今日收入总笔数 $hdActualIncome = HdOrderClass::sum($where, 'actPrice'); // 花店今日收入金额总数 Yii::info('花店今日收入总笔数:' . $hdActualCount . ', 花店今日收入金额总数:' . $hdActualIncome); $actualCount = $ghsOnlineCount + $hdActualCount; $actualIncome = bcadd($ghsActIncome, $hdActualIncome, 2); //现金收入 23笔 5980元 //xhGhsOrder actPrice 字段,条件:debtPrice=0 and status in (2,3,4) and payWay=4 //xhOrder actPrice 字段,条件 status in (2,3,4) and payWay=4 $where = ['shopId' => $this->shopId, 'debt' => 0, 'debtPrice' => '0.00']; $where['status'] = ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]; $where['payWay'] = 4; $where['addTime'] = ['between', [$todayStartTime, $todayEndTime]]; $ghsCashCount = OrderClass::getCount($where); // 批发今日现金总笔数 $ghsCashIncome = OrderClass::sum($where, 'actPrice'); // 批发今日现金金额总数 Yii::info('批发今日现金总笔数:' . $ghsCashCount . ', 批发今日现金金额总数:' . $ghsCashIncome); unset($where['debt']); unset($where['debtPrice']); $hdCashCount = HdOrderClass::getCount($where); // 花店今日现金总笔数 $hdCashIncome = HdOrderClass::sum($where, 'actPrice'); // 花店今日现金金额总数 Yii::info('花店今日现金总笔数:' . $hdCashCount . ', 花店今日现金金额总数:' . $hdCashIncome); $cashCount = $ghsCashCount + $hdCashCount; $cashIncome = bcadd($ghsCashIncome, $hdCashIncome, 2); //批发欠款 39笔 13980元 $where = ['shopId' => $this->shopId, 'debt' => 1]; $where['addTime'] = ['between', [$todayStartTime, $todayEndTime]]; $ghsDebtCount = OrderClass::getCount($where); // 批发今日欠款总笔数 $ghsAllDebt = OrderClass::sum($where, 'remainDebtPrice'); // 批发今日总欠款 $totalCount = bcadd($cashCount, $ghsDebtCount); $totalIncome = bcadd($cashIncome, $ghsAllDebt, 2); util::success([ 'actualCount' => $actualCount, 'actualIncome' => $actualIncome, 'cashCount' => $cashCount, 'cashIncome' => $cashIncome, 'debtCount' => $ghsDebtCount, 'allDebt' => $ghsAllDebt, 'totalCount' => $totalCount, 'totalIncome' => $totalIncome, ]); } //概况 ssh 2019.12.19 public function actionProfile() { $get = Yii::$app->request->get(); $isMini = $get['isMini'] ?? 0; $notice = []; $admin = $this->admin; if ($isMini == 1 && !empty($admin)) { $miniOpenId = $admin['ghsMiniOpenId'] ?? ''; if (empty($miniOpenId)) { $notice = [['title' => '绑定微信,下次自动登录后台', 'action' => '去绑定', 'page' => '/admin/staff/miniAutoLogin']]; } } //今天销售 $sale = StatSaleClass::getByCondition(['mainId' => $this->mainId, 'time' => date('Ymd')]); $todaySale = $sale['amount'] ?? 0; $orderNum = $sale['num'] ?? 0; //2021.4.14 lqh 今日支出 $outData = StatOutService::getTodayNum($this->mainId); $todayOut = $outData['amount'] ?? '0.00'; //访客数 $visitCustom = StatVisitClass::getVisitNum($this->mainId); $todayData = ['income' => $todaySale, 'order' => $orderNum, 'expend' => $todayOut, 'visitCustom' => $visitCustom]; $incomeStat = []; $menu = [ ["name" => "商城", "img" => "ghs/home/shop.png", "url" => "/admin/home/mall"], ["name" => "改价", "img" => "ghs/home/gj.png", "url" => "/admin/changePrice/list"], ["name" => "花材", "img" => "ghs/home/hcgl.png", "url" => "/admin/item/list"], ["name" => "供应商", "img" => "ghs/home/icon_ghs.png", "url" => "/pagesPurchase/supplier"], ["name" => "采购单", "img" => "ghs/home/icon_caigou.png", "url" => "/pagesPurchase/order"], ["name" => "报损单", "img" => "ghs/home/kcyjs.png", "url" => "/admin/breakage/list"], ["name" => "预订单", "img" => "ghs/home/kcyjs.png", "url" => "/admin/order/statBook"], ["name" => "新增出库", "img" => "ghs/home/dbck.png", "url" => "/admin/shop/selectShop"], ["name" => "出库记录", "img" => "ghs/home/dbck.png", "url" => "/pagesStorehouse/allot/allotEx"], ["name" => "入库记录", "img" => "ghs/home/dbrk.png", "url" => "/pagesStorehouse/allot/allotPut"], ["name" => "销售结账单", "img" => "ghs/home/kcyjs.png", "url" => "/admin/clear/customList"], ["name" => "采购结账单", "img" => "ghs/home/kcyjs.png", "url" => "/admin/clear/list"], ]; util::success(['asset' => $this->main, 'notice' => $notice, 'todayData' => $todayData, 'incomeStat' => $incomeStat, 'menu' => $menu,]); } //常用初始化 public function actionInit() { $dict = dict::get(); $shop = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : []; util::success(['dict' => $dict, 'shop' => $shop]); } }