Просмотр исходного кода

Merge branch 'master' into redesign‌-260706

shish 1 месяц назад
Родитель
Сommit
d07daab849

+ 13 - 18
app-ghs/controllers/ConsoleController.php

@@ -30,21 +30,15 @@ class ConsoleController extends BaseController
         //$lsDebt = \bizHd\order\classes\OrderClass::sum(['mainId' => $this->mainId, 'debt' => 1], 'remainDebtPrice');
         //$lsDebt = $lsDebt === null ? 0 : $lsDebt;
         //$totalDebt = bcadd($pfDebt, $lsDebt, 2);
-        $itemList = ItemClass::getAllByCondition(['mainId' => $this->mainId], null, 'id,stock,avCost,cost,virtualStock,delStatus', null, true);
-        $totalItemNum = 0;
-        $totalCost = 0;
-        if (!empty($itemList)) {
-            foreach ($itemList as $item) {
-                if ($item->virtualStock == 0 && $item->delStatus == 0) {
-                    $stock = $item->stock ?? 0;
-                    $cost = $item->avCost ?? 0;
-                    $totalItemNum = bcadd($stock, $totalItemNum, 2);
-                    $currentCost = bcmul($stock, $cost, 2);
-                    $totalCost = bcadd($currentCost, $totalCost, 2);
-                }
-            }
-        }
-        $totalItemNum = floor($totalItemNum);
+        // 优化慢查询:直接在数据库层聚合库存和成本,避免取出全量数据到PHP内存中循环计算
+        $stat = ItemClass::getByCondition(
+            ['mainId' => $this->mainId, 'virtualStock' => 0, 'delStatus' => 0],
+            false,
+            false,
+            'SUM(stock) as totalItemNum, SUM(stock * avCost) as totalCost'
+        );
+        $totalItemNum = floor($stat['totalItemNum'] ?? 0);
+        $totalCost = round($stat['totalCost'] ?? 0, 2);
         $totalBalance = CustomClass::sum(['ownMainId'=>$this->mainId],'balance');
         $may = $totalBalance<0 ? abs($totalBalance) : 0;
         $overview = [
@@ -244,7 +238,7 @@ class ConsoleController extends BaseController
             ["name" => "报损", "img" => "ghs/home/kcyjs.png", "url" => "/admin/breakage/list"],
             ["name" => "拆散", "img" => "ghs/home/kcyjs.png", "url" => "/admin/part/list"],
             ["name" => "收款流水", "img" => "ghs/home/kcyjs.png", "url" => "/admin/order/scanPay"],
-            ["name" => "收款码", "img" => "ghs/home/shop.png", "url" => "/admin/cg/code"]
+            ["name" => "公告", "img" => "ghs/home/icon_caigou.png", "url" => "/admin/ghsNotice/list"]
         ];
         $menuV3 = [
             ["name" => "商城码", "img" => "ghs/home/shop3.png", "url" => "/admin/home/mall"],
@@ -266,7 +260,7 @@ class ConsoleController extends BaseController
             ["name" => "报损", "img" => "ghs/home/kcyjs.png", "url" => "/admin/breakage/list"],
             ["name" => "拆散", "img" => "ghs/home/kcyjs.png", "url" => "/admin/part/list"],
             ["name" => "收款流水", "img" => "ghs/home/kcyjs.png", "url" => "/admin/order/scanPay"],
-            ["name" => "收款码", "img" => "ghs/home/shop.png", "url" => "/admin/cg/code"]
+            ["name" => "公告", "img" => "ghs/home/icon_caigou.png", "url" => "/admin/ghsNotice/list"]
         ];
         $menuIconMap = [
             '商城码' => 'mall_code',
@@ -289,7 +283,7 @@ class ConsoleController extends BaseController
             '损耗' => 'breakage',
             '拆散' => 'break_up',
             '收款流水' => 'gather_record',
-            '收款码' => 'gather_code',
+            '公告' => 'purchase_record',
             '商城' => 'mall_code',
             '花材(简)' => 'item',
         ];
@@ -346,4 +340,5 @@ class ConsoleController extends BaseController
         util::success(['dict' => $dict, 'shop' => $shop]);
     }
 
+
 }

+ 13 - 1
app-ghs/controllers/TotalDebtChangeController.php

@@ -1,6 +1,7 @@
 <?php
 namespace ghs\controllers;
 use bizGhs\shop\classes\TotalDebtChangeClass;
+use common\components\dateUtil;
 use common\components\util;
 use Yii;
 
@@ -12,9 +13,20 @@ class TotalDebtChangeController extends BaseController
     //欠款变动明细
     public function actionList()
     {
-        //$get = Yii::$app->request->get();
+        $get = Yii::$app->request->get();
         $where = [];
         $where['mainId'] = $this->mainId;
+        $customId = $get['customId'] ?? 0;
+        if (!empty($customId)) {
+            $where['customId'] = (int)$customId;
+        }
+        $searchTime = $get['searchTime'] ?? '';
+        if (!empty($searchTime)) {
+            $startTime = $get['startTime'] ?? '';
+            $endTime = $get['endTime'] ?? '';
+            $period = dateUtil::formatTime($searchTime, $startTime, $endTime);
+            $where['addTime'] = ['between', [$period['startTime'], $period['endTime']]];
+        }
         $list = TotalDebtChangeClass::getChangeList($where);
         util::success($list);
     }

+ 9 - 15
app-hd/controllers/ConsoleController.php

@@ -22,21 +22,15 @@ class ConsoleController extends BaseController
     {
         //不要用缓存!!!!
 
-        $itemList = ItemClass::getAllByCondition(['mainId' => $this->mainId], null, 'id,stock,avCost,cost,virtualStock,delStatus', null, true);
-        $totalItemNum = 0;
-        $totalCost = 0;
-        if (!empty($itemList)) {
-            foreach ($itemList as $item) {
-                if ($item->virtualStock == 0 && $item->delStatus == 0) {
-                    $stock = $item->stock ?? 0;
-                    $cost = $item->avCost ?? 0;
-                    $totalItemNum = bcadd($stock, $totalItemNum, 2);
-                    $currentCost = bcmul($stock, $cost, 2);
-                    $totalCost = bcadd($currentCost, $totalCost, 2);
-                }
-            }
-        }
-        $totalItemNum = floor($totalItemNum);
+        // 优化慢查询:直接在数据库层聚合库存和成本,避免取出全量数据到PHP内存中循环计算
+        $stat = ItemClass::getByCondition(
+            ['mainId' => $this->mainId, 'virtualStock' => 0, 'delStatus' => 0],
+            false,
+            false,
+            'SUM(stock) as totalItemNum, SUM(stock * avCost) as totalCost'
+        );
+        $totalItemNum = floor($stat['totalItemNum'] ?? 0);
+        $totalCost = round($stat['totalCost'] ?? 0, 2);
         $goodsCount = GoodsClass::getCount(['mainId' => $this->mainId]);
         $customCount = CustomClass::getCount(['shopId' => $this->shopId]);
         $orderCount = OrderClass::getCount(['mainId' => $this->mainId, 'status' => 4]);

+ 1 - 0
app-hd/controllers/GhsController.php

@@ -461,6 +461,7 @@ class GhsController extends BaseController
     //寻找附近批发店
     public function actionSearchNearbyGhs()
     {
+        //util::complete();
         $get = Yii::$app->request->get();
         $locationType = $get['locationType'];
         $toLat = $get['lat'] ?? '';

BIN
app-hd/web/buy_list.mp4


BIN
app-hd/web/open_shop.mp4


+ 1 - 1
biz-ghs/shop/classes/GhsNoticeClass.php

@@ -193,7 +193,7 @@ class GhsNoticeClass extends BaseClass
             'content' => is_string($content) ? $content : json_encode($content, JSON_UNESCAPED_UNICODE),
             'position' => $position,
             'sort' => intval($data['sort'] ?? 0),
-            'status' => intval($data['status'] ?? 0) === 1 ? 1 : 0,
+            'status' => intval($data['status'] ?? 1) === 1 ? 1 : 0,
         ];
     }
 

+ 1 - 4
biz-hd/shop/classes/ShopNoticeClass.php

@@ -170,7 +170,7 @@ class ShopNoticeClass extends BaseClass
             'content' => is_string($content) ? $content : json_encode($content, JSON_UNESCAPED_UNICODE),
             'position' => $position,
             'sort' => intval($data['sort'] ?? 0),
-            'status' => intval($data['status'] ?? 0) === 1 ? 1 : 0,
+            'status' => intval($data['status'] ?? 1) === 1 ? 1 : 0,
         ];
     }
 
@@ -241,9 +241,6 @@ class ShopNoticeClass extends BaseClass
     {
         $status = $status === 1 ? 1 : 0;
         $updateData = ['status' => $status];
-        if ($status === 1) {
-            $updateData['publishTime'] = date('Y-m-d H:i:s');
-        }
         if ($staffId > 0) {
             $updateData['staffId'] = $staffId;
         }

+ 1 - 1
biz/shop/classes/ShopClass.php

@@ -562,7 +562,7 @@ class ShopClass extends BaseClass
         ShopYeChangeClass::addChange($change, true);
 
         //平台余额增加
-        PtAssetClass::customKdAddBalance($shop, $amount, $order, $capitalType, $tx);
+        //PtAssetClass::customKdAddBalance($shop, $amount, $order, $capitalType, $tx);
     }
 
     public static function customScanPayAddBalance($main, $shop, $amount, $order, $capitalType)

+ 2 - 0
common/components/constant.php

@@ -18,6 +18,8 @@ class constant
 				['name' => '本月', 'value' => 'thisMonth',],
 				['name' => '上月', 'value' => 'lastMonth',],
 				['name' => '今年', 'value' => 'thisYear',],
+				['name' => '近一周', 'value' => 'last7Days',],
+				['name' => '近30天', 'value' => 'last30Days',],
 				['name' => '自定义', 'value' => 'custom',],
 			],
 		];

+ 18 - 0
common/components/dateUtil.php

@@ -56,6 +56,24 @@ class dateUtil
                     $endTime = date("Ymd", mktime(23, 59, 59, 1, 0, date("Y", strtotime('+1 year'))));
                 }
                 break;
+            case 'last7Days':
+                //近一周(含今天)
+                $startTime = date("Y-m-d 00:00:00", strtotime("-6 days"));
+                $endTime = date("Y-m-d 23:59:59");
+                if ($Stat) {
+                    $startTime = date("Ymd", strtotime("-6 days"));
+                    $endTime = date("Ymd");
+                }
+                break;
+            case 'last30Days':
+                //近30天(含今天)
+                $startTime = date("Y-m-d 00:00:00", strtotime("-29 days"));
+                $endTime = date("Y-m-d 23:59:59");
+                if ($Stat) {
+                    $startTime = date("Ymd", strtotime("-29 days"));
+                    $endTime = date("Ymd");
+                }
+                break;
             case 'lastWeek':
                 //上周
                 $startTime = date("Y-m-d H:i:s", mktime(0, 0, 0, date("m"), date("d") - date("w") + 1 - 7, date("Y")));

+ 2 - 0
common/components/dict.php

@@ -305,6 +305,8 @@ class dict
             ['name' => '本月', 'value' => 'thisMonth',],
             ['name' => '上月', 'value' => 'lastMonth',],
             ['name' => '今年', 'value' => 'thisYear',],
+            ['name' => '近一周', 'value' => 'last7Days',],
+            ['name' => '近30天', 'value' => 'last30Days',],
         ],
 
         //所属平台类型

+ 2 - 2
console/controllers/ItemController.php

@@ -40,8 +40,8 @@ class ItemController extends Controller
     public function actionMigrate()
     {
         if (getenv('YII_ENV') == 'production') {
-            $newMainId = 97789;
-            $oldMainId = 42940;
+            $newMainId = 100880;
+            $oldMainId = 16299;
         } else {
             $newMainId = 762;
             $oldMainId = 644;