| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- <?php
- namespace hd\controllers;
- use biz\stat\classes\StatCgClass;
- use biz\stat\classes\StatRefundClass;
- use biz\stat\classes\StatSaleClass;
- use biz\stat\classes\StatStockInClass;
- use biz\stat\classes\StatStockOutClass;
- use common\components\dateUtil;
- use Yii;
- use common\components\util;
- class StatController extends BaseController
- {
- //按月统计损耗情况
- public function actionWaste()
- {
- ini_set('memory_limit', '2045M');
- set_time_limit(0);
- $mainId = $this->mainId;
- $list = \bizGhs\order\classes\StockWastageOrderClass::getAllByCondition(['mainId' => $mainId], null, '*');
- $arr = [];
- $totalNum = 0;
- $totalCost = 0;
- $totalPrice = 0;
- if (!empty($list)) {
- foreach ($list as $order) {
- $addTime = $order['addTime'];
- $time = date("Ym", strtotime($addTime));
- $date = date("Y年n月", strtotime($addTime));
- $bigNum = $order['bigNum'] ?? 0;
- $cost = $order['cost'] ?? 0;
- $price = $order['price'] ?? 0;
- if (isset($arr[$time])) {
- $arr[$time]['num'] = bcadd($arr[$time]['num'], $bigNum);
- $arr[$time]['cost'] = bcadd($arr[$time]['cost'], $cost, 2);
- $arr[$time]['price'] = bcadd($arr[$time]['price'], $price, 2);
- $arr[$time]['time'] = $date;
- } else {
- $arr[$time]['num'] = $bigNum;
- $arr[$time]['cost'] = $cost;
- $arr[$time]['price'] = $price;
- $arr[$time]['time'] = $date;
- }
- $totalNum = bcadd($totalNum, $bigNum);
- $totalCost = bcadd($totalCost, $cost, 2);
- $totalPrice = bcadd($totalPrice, $price, 2);
- }
- }
- $totalCost = floatval($totalCost);
- $totalPrice = floatval($totalPrice);
- util::success(['list' => $arr, 'totalNum' => $totalNum, 'totalCost' => $totalCost, 'totalPrice' => $totalPrice]);
- }
- //利润表 ssh 20230303
- public function actionProfit()
- {
- ini_set('memory_limit', '2045M');
- set_time_limit(0);
- $lookMoney = \bizGhs\shop\classes\ShopAdminClass::lookMoneyPower($this->shopAdmin, $this->shop);
- if ($lookMoney == 0) {
- util::fail('无法查看');
- }
- $shopAdmin = $this->shopAdmin;
- if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
- util::fail('超管才能查看');
- }
- //惠雅鲜花员工不能看利润表
- $shopAdmin = $this->shopAdmin;
- $adminId = $shopAdmin->adminId ?? 0;
- if (in_array($adminId, [2366, 2812, 4004, 3405, 3407])) {
- util::fail('暂无权限');
- }
- $mainId = $this->mainId;
- $respond = \bizGhs\stat\classes\StatSaleClass::profile($mainId);
- $income = $respond['income'] ?? 0;
- $expend = $respond['expend'] ?? 0;
- $balance = $respond['balance'] ?? 0;
- //由于损耗而造成少赚的钱
- $wastageRespond = \bizGhs\stat\classes\StatSaleClass::wastage($mainId);
- $wastagePrice = $wastageRespond['totalPrice'] ?? 0;
- $wastagePrice = floatval($wastagePrice);
- util::success(['income' => $income, 'expend' => $expend, 'balance' => floatval($balance), 'wastagePrice' => $wastagePrice]);
- }
- //统计列表 ssh 2020.1.5
- public function actionList()
- {
- $type = Yii::$app->request->get('type', 1);
- $incomeStat = [
- 'total' => (185 + 381 + 662 + 443),
- 'list' => [
- ['name' => '2.6', 'num' => 185],
- ['name' => '2.7', 'num' => 381],
- ['name' => '2.8', 'num' => 662],
- ['name' => '2.9', 'num' => 443],
- ],
- ];
- $visitStat = [
- 'total' => (115 + 341 + 622 + 423),
- 'list' => [
- ['name' => '2.6', 'num' => 115],
- ['name' => '2.7', 'num' => 341],
- ['name' => '2.8', 'num' => 622],
- ['name' => '2.9', 'num' => 423],
- ],
- ];
- $userStat = [
- 'total' => (185 + 341 + 622 + 423),
- 'list' => [
- ['name' => '2.6', 'num' => 185],
- ['name' => '2.7', 'num' => 341],
- ['name' => '2.8', 'num' => 622],
- ['name' => '2.9', 'num' => 423],
- ],
- ];
- $fansStat = [
- 'total' => (185 + 241 + 322 + 553),
- 'list' => [
- ['name' => '2.6', 'num' => 185],
- ['name' => '2.7', 'num' => 241],
- ['name' => '2.8', 'num' => 322],
- ['name' => '2.9', 'num' => 553],
- ],
- ];
- $incomeSourceStat = [
- 'total' => (299 + 366 + 2995),
- 'list' => [
- ['name' => '门店', 'num' => 299],
- ['name' => '微信朋友圈', 'num' => 366],
- ['name' => '美团', 'num' => 2995],
- ],
- ];
- $categoryStat = [
- 'total' => (552 + 155 + 295 + 365 + 600 + 504),
- 'list' => [
- ['name' => '花束', 'num' => 552],
- ['name' => '花篮', 'num' => 155],
- ['name' => '蝴蝶兰', 'num' => 295],
- ['name' => '绿植', 'num' => 365],
- ['name' => '永生花', 'num' => 600],
- ['name' => '散花', 'num' => 504],
- ],
- ];
- $useStat = [
- 'total' => (552 + 155 + 295 + 365 + 600 + 504),
- 'list' => [
- ['name' => '年销花', 'num' => 552],
- ['name' => '送爱人', 'num' => 155],
- ['name' => '婚庆', 'num' => 295],
- ['name' => '开业', 'num' => 365],
- ['name' => '送母亲', 'num' => 600],
- ['name' => '生日', 'num' => 504],
- ]
- ];
- $data = ['incomeStat' => $incomeStat,
- 'visitStat' => $visitStat,
- 'userStat' => $userStat,
- 'fansStat' => $fansStat,
- 'incomeSourceStat' => $incomeSourceStat,
- 'categoryStat' => $categoryStat,
- 'useStat' => $useStat,
- ];
- util::success($data);
- }
- }
|