shish 4 years ago
parent
commit
80119c763e

+ 18 - 8
app-ghs/controllers/ClearController.php

@@ -16,11 +16,16 @@ class ClearController extends BaseController
     public function actionList()
     {
         $get = Yii::$app->request->get();
-        $where['status'] = 2;
+        $where = [];
+        if (isset($get['status']) && is_numeric($get['status'])) {
+            $where['status'] = $get['status'];
+        }
         $ghsId = $get['ghsId'] ?? 0;
-        $ghs = GhsClass::getById($ghsId, true);
-        GhsClass::valid($ghs, $this->shopId);
-        $where['ghsId'] = $ghsId;
+        if (!empty($ghsId)) {
+            $ghs = GhsClass::getById($ghsId, true);
+            GhsClass::valid($ghs, $this->shopId);
+            $where['ghsId'] = $ghsId;
+        }
         $list = ClearService::getClearList($where);
         util::success($list);
     }
@@ -37,11 +42,16 @@ class ClearController extends BaseController
     public function actionCustomList()
     {
         $get = Yii::$app->request->get();
-        $where['status'] = 2;
+        $where = [];
+        if (isset($get['status']) && is_numeric($get['status'])) {
+            $where['status'] = $get['status'];
+        }
         $customId = $get['customId'] ?? 0;
-        $custom = CustomClass::getById($customId, true);
-        CustomClass::valid($custom, $this->shopId);
-        $where['customId'] = $customId;
+        if (!empty($customId)) {
+            $custom = CustomClass::getById($customId, true);
+            CustomClass::valid($custom, $this->shopId);
+            $where['customId'] = $customId;
+        }
         $list = ClearService::getClearList($where);
         util::success($list);
     }

+ 4 - 1
app-ghs/controllers/ConsoleController.php

@@ -57,7 +57,10 @@ class ConsoleController extends BaseController
             ["name" => "预订单", "img" => "ghs/home/kcyjs.png", "url" => "/admin/order/statBook"],
             ["name" => "花材", "img" => "ghs/home/hcgl.png", "url" => "/admin/item/list"],
             ["name" => "调拨出库", "img" => "ghs/home/dbck.png", "url" => "/pagesStorehouse/allot/allotEx"],
-            ["name" => "调拨入库", "img" => "ghs/home/dbrk.png", "url" => "/pagesStorehouse/allot/allotPut"]
+            ["name" => "调拨入库", "img" => "ghs/home/dbrk.png", "url" => "/pagesStorehouse/allot/allotPut"],
+            ["name" => "员工", "img" => "ghs/home/yggl.png", "url" => "/admin/staff/list"],
+            ["name" => "销售结账单", "img" => "ghs/home/kcyjs.png", "url" => "/admin/clear/customList"],
+            ["name" => "采购结账单", "img" => "ghs/home/kcyjs.png", "url" => "/admin/clear/list"],
         ];
         $agent = $this->shop->agentLevel ?? 0;
         if ($agent == 1) {

+ 33 - 4
app-hd/controllers/ClearController.php

@@ -5,6 +5,7 @@ namespace hd\controllers;
 use biz\ghs\classes\GhsClass;
 use bizGhs\clear\classes\ClearClass;
 use bizGhs\clear\services\ClearService;
+use bizGhs\custom\classes\CustomClass;
 use common\components\util;
 use Yii;
 
@@ -15,11 +16,16 @@ class ClearController extends BaseController
     public function actionList()
     {
         $get = Yii::$app->request->get();
-        $where['status'] = 2;
+        $where = [];
+        if (isset($get['status']) && is_numeric($get['status'])) {
+            $where['status'] = $get['status'];
+        }
         $ghsId = $get['ghsId'] ?? 0;
-        $ghs = GhsClass::getById($ghsId, true);
-        GhsClass::valid($ghs, $this->shopId);
-        $where['ghsId'] = $ghsId;
+        if (!empty($ghsId)) {
+            $ghs = GhsClass::getById($ghsId, true);
+            GhsClass::valid($ghs, $this->shopId);
+            $where['ghsId'] = $ghsId;
+        }
         $list = ClearService::getClearList($where);
         util::success($list);
     }
@@ -32,4 +38,27 @@ class ClearController extends BaseController
         util::success($respond);
     }
 
+    //获取结账单详情 ssh 20220509
+    public function actionDetail()
+    {
+        $id = Yii::$app->request->get('id');
+        $clear = ClearClass::getById($id);
+        if (empty($clear)) {
+            util::fail('没有结账信息');
+        }
+        $customId = $clear['customId'] ?? 0;
+        $custom = CustomClass::getById($customId, true);
+        $customShopId = $custom->shopId ?? 0;
+        if ($customShopId != $this->shopId) {
+            util::fail('没有权限');
+        }
+        $deadline = isset($clear['deadline']) && !empty($clear['deadline']) ? strtotime($clear['deadline']) : 0;
+        $now = time();
+        $remainSecond = bcsub($deadline, $now);
+        $remainSecond = bcsub($remainSecond, 100);
+        $remainSecond = $remainSecond > 0 ? $remainSecond : 0;
+        $clear['remainSecond'] = $remainSecond;
+        util::success($clear);
+    }
+
 }

+ 2 - 2
biz-ghs/clear/classes/ClearClass.php

@@ -224,7 +224,7 @@ class ClearClass extends BaseClass
         }
         $purchaseIds = $info['purchaseIds'] ?? [];
         $cgArr = explode(',', $purchaseIds);
-        $cgList = PurchaseClass::getAllByCondition(['id' => ['in', $cgArr]], null, 'id,orderSn,bigNum,smallNum,realPrice', null);
+        $cgList = PurchaseClass::getAllByCondition(['id' => ['in', $cgArr]], null, '*', null);
         $info['orderList'] = $cgList;
         $info['orderNum'] = count($cgArr);
         $clearStyle = $info['clearStyle'] ?? dict::getDict('clearStyle', 'hd2Gys');
@@ -245,7 +245,7 @@ class ClearClass extends BaseClass
         }
         $saleIds = $info['saleIds'] ?? [];
         $saleArr = explode(',', $saleIds);
-        $saleList = OrderClass::getAllByCondition(['id' => ['in', $saleArr]], null, 'id,orderSn,bigNum,smallNum,realPrice', null);
+        $saleList = OrderClass::getAllByCondition(['id' => ['in', $saleArr]], null, '*', null);
         $info['orderList'] = $saleList;
         $info['orderNum'] = count($saleArr);
         $type = $info['clearStyle'] ?? dict::getDict('clearStyle', 'gys2KmGys');

+ 2 - 2
biz-hd/order/classes/OrderClass.php

@@ -96,7 +96,7 @@ class OrderClass extends BaseClass
             util::fail('没有找到门店信息');
         }
         $mainId = $shop->mainId ?? 0;
-        $main = MainClass::getById($mainId, true);
+        $main = MainClass::getLockById($mainId);
         if (empty($main)) {
             util::fail('没有找到main信息');
         }
@@ -105,7 +105,7 @@ class OrderClass extends BaseClass
         $main->save();
 
         //将花店每月的总订单数作为编号
-        $riseNum = StatOrderCountClass::addOrder($shop);
+        $riseNum = StatOrderCountClass::addOrder($shop, $main);
         $data['sendNum'] = date("d") . $riseNum;
         $data['totalFlow'] = OrderClass::ORDER_TOTAL_FLOW;
         $return = self::add($data, true);