Jelajahi Sumber

Merge branch 'master' of http://git.huaml.com/zhh/huahuibao

shish 2 minggu lalu
induk
melakukan
1e3fabc8c6

+ 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]);
     }
 
+
 }

+ 8 - 2
app-ghs/controllers/OrderController.php

@@ -1113,18 +1113,24 @@ class OrderController extends BaseController
             $where['book'] = $book;
         }
         $searchTime = $get['searchTime'] ?? '';
+        //0搜索的addTime 1搜索的payTime
+        $searchTimeType = $get['searchTimeType'] ?? 0;
         if (!empty($searchTime)) {
             $startTime = $get['startTime'] ?? '';
             $endTime = $get['endTime'] ?? '';
             $period = dateUtil::formatTime($searchTime, $startTime, $endTime);
-            $where['payTime'] = ['between', [$period['startTime'], $period['endTime']]];
+            if ($searchTimeType == 0) {
+                $where['addTime'] = ['between', [$period['startTime'], $period['endTime']]];
+            } else {
+                $where['payTime'] = ['between', [$period['startTime'], $period['endTime']]];
+            }
         }
 
         if ($export == 1) {
             ini_set('memory_limit', '2045M');
             set_time_limit(0);
             if (!isset($where['payTime'])) {
-                util::fail('请选时间段');
+                util::fail('请选 账单日期 和 时间段');
             }
             $start = $where['payTime'][1][0];
             $end = $where['payTime'][1][1];

+ 2 - 1
app-ghs/controllers/TestController.php

@@ -507,7 +507,8 @@ class TestController extends BaseController
             //['name' => '张家口万花汇', 'merchantNo' => '82213805992008D', 'wx' => [901551070, 901551037], 'zfb' => '2088780253600870'],
             //['name' => '深圳每日鲜花批发', 'merchantNo' => '82258405992020E', 'wx' => [902309136, 902307468], 'zfb' => '2088780298610704'],
             //['name' => '滨州花镜鲜花', 'merchantNo' => '82246605992005U', 'wx' => [904373612, 904373338], 'zfb' => '2088780426621723'],
-            ['name' => '广州情意鲜花', 'merchantNo' => '8225810599201U2', 'wx' => [904871059, 904872401], 'zfb' => '2088780455410378'],
+            //['name' => '广州情意鲜花', 'merchantNo' => '8225810599201U2', 'wx' => [904871059, 904872401], 'zfb' => '2088780455410378'],
+            ['name' => '我要花义乌店', 'merchantNo' => '8223380599200A6', 'wx' => [2000005220, 907253683], 'zfb' => '2088780613953851'],
             //['name' => '厦门纯彩花艺', 'merchantNo' => '8223930599200LD', 'wx' => [894984230, 894983290], 'zfb' => '2088680439152343'],
             //['name' => '东莞我要花鲜花', 'merchantNo' => '8226020599200R8', 'wx' => [894794554, 894794917], 'zfb' => '2088680405463378'],
             //['name' => '镇江花珩鲜花批发', 'merchantNo' => '82231405992003N', 'wx' => [894925711, 894925626], 'zfb' => '2088680426877183'],

+ 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]);

+ 11 - 40
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'] ?? '';
@@ -499,7 +500,16 @@ class GhsController extends BaseController
 
     public function actionCommonInfo()
     {
-        $mainId = $this->resolveGhsMainId();
+        $get = Yii::$app->request->get();
+        $ghsId = intval($get['ghsId'] ?? 0);
+        $ghs = GhsClass::getById($ghsId);
+        if(empty($ghs)){
+            util::fail('没有找到批发店');
+        }
+        if($ghs['ownMainId'] != $this->mainId){
+            util::fail('不是你的批发店');
+        }
+        $mainId = $ghs['mainId'] ?? 0;
         // 通用接口返回全部有效公告,前端按 positions 字段筛选展示位置
         $ghsNoticeList = GhsNoticeClass::getClientNoticeList($mainId);
         util::success(['ghsNoticeList' => $ghsNoticeList]);
@@ -517,43 +527,4 @@ class GhsController extends BaseController
         util::success(GhsNoticeClass::getClientDetail($id));
     }
 
-    /**
-     * 根据批发商 ghsId 或 shopId 解析 mainId(列表接口用,勿与公告 id 混用)
-     */
-    protected function resolveGhsMainId(): int
-    {
-        $get = Yii::$app->request->get();
-        $ghsId = intval($get['ghsId'] ?? 0);
-        $shopId = intval($get['shopId'] ?? 0);
-        $ghsShopId = 0;
-
-        if ($ghsId > 0) {
-            $ghs = GhsClass::getById($ghsId);
-            if (empty($ghs)) {
-                util::fail('没有找到批发商');
-            }
-            if (!empty($this->shopId)) {
-                GhsClass::valid($ghs, $this->shopId);
-            }
-            $ghsShopId = intval($ghs['shopId'] ?? 0);
-        } elseif ($shopId > 0) {
-            $ghsShop = ShopClass::getById($shopId, true);
-            if (empty($ghsShop) || $ghsShop->ptStyle != dict::getDict('ptStyle', 'ghs')) {
-                util::fail('没有找到批发店');
-            }
-            $ghsShopId = $shopId;
-        } else {
-            util::fail('参数不对');
-        }
-
-        $ghsShop = ShopClass::getById($ghsShopId, true);
-        if (empty($ghsShop)) {
-            util::fail('没有找到批发商');
-        }
-        $mainId = intval($ghsShop->mainId ?? 0);
-        if ($mainId <= 0) {
-            util::fail('批发商信息不完整');
-        }
-        return $mainId;
-    }
 }

+ 2 - 2
app-hd/controllers/NoticeController.php

@@ -222,7 +222,7 @@ class NoticeController extends PublicController
 
                                 if (getenv('YII_ENV') == 'production') {
                                     //福州我要花、花路鲜花批发、小齐鲜花、花镜打二次小票,有多处要修改搜索关键词tow_print
-                                    $needTwoPrint = [7538, 36707, 76796];
+                                    $needTwoPrint = [7538, 36707, 76796, 94589];
                                 } else {
                                     $needTwoPrint = [644];
                                 }
@@ -443,7 +443,7 @@ class NoticeController extends PublicController
 
                                 if (getenv('YII_ENV') == 'production') {
                                     //福州我要花、花路鲜花批发、花镜打二次小票,有多处要修改搜索关键词tow_print
-                                    $needTwoPrint = [7538, 36707, 76796];
+                                    $needTwoPrint = [7538, 36707, 76796, 94589];
                                 } else {
                                     $needTwoPrint = [];
                                 }

+ 21 - 3
app-hd/controllers/OrderController.php

@@ -1415,7 +1415,6 @@ class OrderController extends BaseController
     {
         $get = Yii::$app->request->get();
         $searchText = $get['searchText'] ?? '';
-        $searchStyle = $get['searchStyle'] ?? 0;
         $shopId = $this->shopId ?? 0;
         if (empty($shopId)) {
             //没有登录不显示数据
@@ -1444,8 +1443,9 @@ class OrderController extends BaseController
         if (!empty($get['shopAdminId'])) {
             $where['shopAdminId'] = $get['shopAdminId'];
         }
-        if ($searchStyle == 1 && !empty($searchText)) {
-            $where['sendNum'] = $searchText;
+        // 按搜索词自动识别:纯数字查货号,否则查姓名
+        if (!empty($searchText)) {
+            $this->appendOrderListSearchWhere($where, $searchText);
         }
         if (isset($get['repeat']) && $get['repeat'] > -1) {
             $where['repeat'] = $get['repeat'];
@@ -1598,4 +1598,22 @@ class OrderController extends BaseController
         util::success(['sedCost' => 10]);
     }
 
+    /**
+     * 订单列表搜索条件:纯数字按货号精确匹配,否则按客户姓名模糊匹配
+     * @param array $where 查询条件(引用传递)
+     * @param string $searchText 搜索关键词
+     */
+    private function appendOrderListSearchWhere(&$where, $searchText)
+    {
+        $searchText = trim((string)$searchText);
+        if ($searchText === '') {
+            return;
+        }
+        if (preg_match('/^\d+$/', $searchText)) {
+            $where['sendNum'] = $searchText;
+            return;
+        }
+        $where['customName'] = ['like', $searchText];
+    }
+
 }

+ 1 - 1
app-hd/controllers/PurchaseController.php

@@ -1172,7 +1172,7 @@ class PurchaseController extends BaseController
             $startTime = $get['startTime'] ?? '';
             $endTime = $get['endTime'] ?? '';
             $period = dateUtil::formatTime($searchTime, $startTime, $endTime);
-            $where['payTime'] = ['between', [$period['startTime'], $period['endTime']]];
+            $where['addTime'] = ['between', [$period['startTime'], $period['endTime']]];
         }
         $ghsId = $get['ghsId'] ?? 0;
         if (!empty($ghsId)) {

TEMPAT SAMPAH
app-hd/web/buy_list.mp4


TEMPAT SAMPAH
app-hd/web/open_shop.mp4


+ 2 - 3
app-mall/controllers/ShopController.php

@@ -51,10 +51,9 @@ class ShopController extends BaseController
                     $custom->save();
                 }
             }
+            StatVisitClass::addHdCustomVisit($shop->id, $user->id);
         }
 
-        StatVisitClass::addHdCustomVisit($shop->id, $user->id);
-
         util::success(['info' => $info, 'hd' => $hd, 'custom' => $custom]);
     }
 
@@ -83,4 +82,4 @@ class ShopController extends BaseController
         util::success(['ad' => $ad, 'shop' => $shop, 'newUserGift' => $newUserGift]);
     }
 
-}
+}

+ 2 - 2
app-pt/views/main/app.php

@@ -237,8 +237,8 @@
             const downloadUrls = {
                 'xiaohuabao': 'https://api.shop.hzghd.com/1312.apk', // 销花宝APP下载链接
                 'huazhanggui': 'https://api.shop.hzghd.com/246.apk', // 花掌柜APP下载链接
-                'huazhanggui_cashier': 'https://api.shop.hzghd.com/209.apk', // 花掌柜收银下载链接
-                'xiaohuabao_cashier': 'https://api.shop.hzghd.com/168.apk' // 销花宝收银下载链接
+                'huazhanggui_cashier': 'https://api.shop.hzghd.com/215.apk', // 花掌柜收银下载链接
+                'xiaohuabao_cashier': 'https://api.shop.hzghd.com/175.apk' // 销花宝收银下载链接
             };
             const url = downloadUrls[appType];
             if (url && url !== '#') {

+ 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',],
         ],
 
         //所属平台类型

+ 1 - 1
common/config/main-local.php

@@ -17,4 +17,4 @@ if (getenv('YII_ENV') == 'production') {
         ],
     ];
 }
-return $config;
+return $config;

+ 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;