shish преди 1 година
родител
ревизия
01a150e08e
променени са 4 файла, в които са добавени 28 реда и са изтрити 153 реда
  1. 4 3
      app-ghs/controllers/StatController.php
  2. 2 1
      app-ghs/controllers/StatKdController.php
  3. 12 148
      biz-ghs/stat/classes/StatKdClass.php
  4. 10 1
      biz-ghs/stat/classes/StatSaleClass.php

+ 4 - 3
app-ghs/controllers/StatController.php

@@ -77,7 +77,7 @@ class StatController extends BaseController
         if (getenv('YII_ENV') == 'production') {
             //小向花卉
             if ($this->mainId == 23390) {
-                if (in_array($this->adminId, [28456,31105,52528])) {
+                if (in_array($this->adminId, [28456, 31105, 52528])) {
                     $hasPower = 1;
                 }
             }
@@ -103,7 +103,7 @@ class StatController extends BaseController
         set_time_limit(0);
         $mainId = $this->mainId;
         $arr = StatSaleClass::send($mainId);
-        util::success(['list'=>$arr]);
+        util::success(['list' => $arr]);
     }
 
     public function actionIncomeOutItem()
@@ -135,13 +135,14 @@ class StatController extends BaseController
         $income = $respond['income'] ?? 0;
         $expend = $respond['expend'] ?? 0;
         $balance = $respond['balance'] ?? 0;
+        $payCodeIncome = $respond['payCodeIncome'] ?? 0;
 
         //由于损耗而造成少赚的钱
         $wastageRespond = StatSaleClass::wastage($mainId);
         $wastagePrice = $wastageRespond['totalPrice'] ?? 0;
         $wastagePrice = floatval($wastagePrice);
 
-        util::success(['income' => $income, 'expend' => $expend, 'balance' => floatval($balance), 'wastagePrice' => $wastagePrice]);
+        util::success(['income' => $income, 'expend' => $expend, 'balance' => floatval($balance), 'wastagePrice' => $wastagePrice, 'payCodeIncome' => $payCodeIncome]);
     }
 
     //按月统计损耗情况

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

@@ -33,6 +33,7 @@ class StatKdController extends BaseController
         $return = StatKdClass::eachChannelIncome($this->mainId, $this->shop, $contain);
         $incomeList = $return['incomeList'];
         $staffAmountList = $return['staffAmountList'];
+        $payCodeIncome = $return['payCodeIncome'];
         $totalIncome = 0;
         if (!empty($incomeList)) {
             foreach ($incomeList as $item) {
@@ -41,7 +42,7 @@ class StatKdController extends BaseController
                 $totalIncome = floatval($totalIncome);
             }
         }
-        util::success(['list' => $incomeList, 'totalIncome' => $totalIncome, 'staffAmountList' => $staffAmountList]);
+        util::success(['list' => $incomeList, 'totalIncome' => $totalIncome, 'staffAmountList' => $staffAmountList, 'payCodeIncome' => $payCodeIncome]);
     }
 
 }

+ 12 - 148
biz-ghs/stat/classes/StatKdClass.php

@@ -178,7 +178,7 @@ class StatKdClass extends BaseClass
                 $book = $ghsOrder['book'] ?? 0;
                 $staffId = $ghsOrder['shopAdminId'] ?? 0;
                 $staffName = $ghsOrder['shopAdminName'] ?? '';
-                if($staffId==0){
+                if ($staffId == 0) {
                     $staffName = '系统';
                 }
                 if ($status == 0 || $status == 5) {
@@ -192,7 +192,7 @@ class StatKdClass extends BaseClass
                     $staffAmountList[$staffId]['num'] = bcadd($staffAmountList[$staffId]['num'], 1);
                     $staffAmountList[$staffId]['amount'] = bcadd($staffAmountList[$staffId]['amount'], $actPrice, 2);
                 } else {
-                    $staffAmountList[$staffId] = ['num' => 1, 'amount' => $actPrice, 'staffName' => $staffName,'staffId'=>$staffId];
+                    $staffAmountList[$staffId] = ['num' => 1, 'amount' => $actPrice, 'staffName' => $staffName, 'staffId' => $staffId];
                 }
 
                 if ($debtPrice > 0) {
@@ -272,7 +272,9 @@ class StatKdClass extends BaseClass
             }
         }
 
+
         //零售开单
+        $payCodeIncome = 0;
         $hdWhere = ['mainId' => $mainId, 'status' => ['in', [HdOrderClass::ORDER_STATUS_UN_SEND, HdOrderClass::ORDER_STATUS_SENDING, HdOrderClass::ORDER_STATUS_COMPLETE]]];
         $hdWhere['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
         $hdOrderList = HdOrderClass::getAllByCondition($hdWhere, null, '*');
@@ -290,6 +292,8 @@ class StatKdClass extends BaseClass
             $staffId = $ghsOrder['shopAdminId'] ?? 0;
             $staffName = $ghsOrder['shopAdminName'] ?? '';
 
+            $repeat = $hdOrder['repeat'] ?? 0;
+
             if ($onlinePay == dict::getDict('onlinePay', 'yes')) {
 
                 if (isset($staffAmountList[$staffId])) {
@@ -306,6 +310,11 @@ class StatKdClass extends BaseClass
                 $incomeList['system']['num'] = bcadd($incomeList['system']['num'], 1);
                 $incomeList['system']['category']['ls']['amount'] = bcadd($incomeList['system']['category']['ls']['amount'], $mainPay, 2);
                 $incomeList['system']['category']['ls']['num'] = bcadd($incomeList['system']['category']['ls']['num'], 1);
+
+                if ($repeat == 1) {
+                    $payCodeIncome = bcadd($payCodeIncome, $mainPay, 2);
+                }
+
                 if ($cash > 0) {
                     $incomeList['cash']['amount'] = bcadd($incomeList['cash']['amount'], $cash, 2);
                     $incomeList['cash']['num'] = bcadd($incomeList['cash']['num'], 1);
@@ -410,152 +419,7 @@ class StatKdClass extends BaseClass
             }
 
         }
-
-        if ($contain == 1) {
-            //批发结帐收入
-            $clearWhere = ['ghsShopId' => $ghsShopId, 'status' => 2];
-            $clearWhere['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
-            $clearList = ClearClass::getAllByCondition($clearWhere, null, '*');
-            if (!empty($clearList)) {
-                foreach ($clearList as $cKey => $clear) {
-                    $payWay = $clear['payWay'] ?? 0;
-                    $actPrice = $clear['actPrice'] ?? 0;
-                    $onlinePay = $clear['onlinePay'] ?? 0;
-                    $getStaffId = $clear['ghsShopAdminId'] ?? 0;
-                    if ($onlinePay == dict::getDict('onlinePay', 'yes')) {
-                        $incomeList['system']['amount'] = bcadd($incomeList['system']['amount'], $actPrice, 2);
-                        $incomeList['system']['num'] = bcadd($incomeList['system']['num'], 1);
-                        $incomeList['system']['category']['pfJz']['amount'] = bcadd($incomeList['system']['category']['pfJz']['amount'], $actPrice, 2);
-                        $incomeList['system']['category']['pfJz']['num'] = bcadd($incomeList['system']['category']['pfJz']['num'], 1);
-                    } else {
-                        //使用非在线支付
-                        switch ($payWay) {
-                            case dict::getDict('payWay', 'wxPay'):
-                                //员工微信总共收了多少笔多少钱
-                                $incomeList['kfWx']['amount'] = bcadd($incomeList['kfWx']['amount'], $actPrice, 2);
-                                $incomeList['kfWx']['num'] = bcadd($incomeList['kfWx']['num'], 1);
-                                //批发开单、零售开单、批发结账、零售尾款各收了多少现金
-                                $incomeList['kfWx']['category']['pfJz']['amount'] = bcadd($incomeList['kfWx']['category']['pfJz']['amount'], $actPrice, 2);
-                                $incomeList['kfWx']['category']['pfJz']['num'] = bcadd($incomeList['kfWx']['category']['pfJz']['num'], 1);
-                                //客1 客2 客3各收了多少钱
-                                if (isset($incomeList['kfWx']['class'][$getStaffId])) {
-                                    $incomeList['kfWx']['class'][$getStaffId]['amount'] = bcadd($incomeList['kfWx']['class'][$getStaffId]['amount'], $actPrice, 2);
-                                    $incomeList['kfWx']['class'][$getStaffId]['num'] = bcadd($incomeList['kfWx']['class'][$getStaffId]['num'], 1);
-                                }
-                                //每个客服收的明细
-                                if (isset($incomeList['kfWx']['class'][$getStaffId]['itemList']['pfJz'])) {
-                                    $incomeList['kfWx']['class'][$getStaffId]['itemList']['pfJz']['amount'] = floatval(bcadd($incomeList['kfWx']['class'][$getStaffId]['itemList']['pfJz']['amount'], $actPrice, 2));
-                                    $incomeList['kfWx']['class'][$getStaffId]['itemList']['pfJz']['num'] = bcadd($incomeList['kfWx']['class'][$getStaffId]['itemList']['pfJz']['num'], 1);
-                                }
-                                break;
-                            case dict::getDict('payWay', 'alipay'):
-                                $incomeList['aliPay']['amount'] = bcadd($incomeList['aliPay']['amount'], $actPrice, 2);
-                                $incomeList['aliPay']['num'] = bcadd($incomeList['aliPay']['num'], 1);
-                                $incomeList['aliPay']['category']['pfJz']['amount'] = bcadd($incomeList['aliPay']['category']['pfJz']['amount'], $actPrice, 2);
-                                $incomeList['aliPay']['category']['pfJz']['num'] = bcadd($incomeList['aliPay']['category']['pfJz']['num'], 1);
-                                break;
-                            case dict::getDict('payWay', 'cash'):
-                                $incomeList['cash']['amount'] = bcadd($incomeList['cash']['amount'], $actPrice, 2);
-                                $incomeList['cash']['num'] = bcadd($incomeList['cash']['num'], 1);
-                                $incomeList['cash']['category']['pfJz']['amount'] = bcadd($incomeList['cash']['category']['pfJz']['amount'], $actPrice, 2);
-                                $incomeList['cash']['category']['pfJz']['num'] = bcadd($incomeList['cash']['category']['pfJz']['num'], 1);
-                                break;
-                            case dict::getDict('payWay', 'balancePay'):
-                                $incomeList['balancePay']['amount'] = bcadd($incomeList['balancePay']['amount'], $actPrice, 2);
-                                $incomeList['balancePay']['num'] = bcadd($incomeList['balancePay']['num'], 1);
-                                $incomeList['balancePay']['category']['pfJz']['amount'] = bcadd($incomeList['balancePay']['category']['pfJz']['amount'], $actPrice, 2);
-                                $incomeList['balancePay']['category']['pfJz']['num'] = bcadd($incomeList['balancePay']['category']['pfJz']['num'], 1);
-                                break;
-                            case dict::getDict('payWay', 'bankCard'):
-                                $incomeList['bankCard']['amount'] = bcadd($incomeList['aliPay']['amount'], $actPrice, 2);
-                                $incomeList['bankCard']['num'] = bcadd($incomeList['aliPay']['num'], 1);
-                                $incomeList['bankCard']['category']['pfJz']['amount'] = bcadd($incomeList['bankCard']['category']['pfJz']['amount'], $actPrice, 2);
-                                $incomeList['bankCard']['category']['pfJz']['num'] = bcadd($incomeList['bankCard']['category']['pfJz']['num'], 1);
-                                break;
-                            case dict::getDict('payWay', 'unknown'):
-                                $incomeList['other']['amount'] = bcadd($incomeList['aliPay']['amount'], $actPrice, 2);
-                                $incomeList['other']['num'] = bcadd($incomeList['aliPay']['num'], 1);
-                                $incomeList['other']['category']['pfJz']['amount'] = bcadd($incomeList['other']['category']['pfJz']['amount'], $actPrice, 2);
-                                $incomeList['other']['category']['pfJz']['num'] = bcadd($incomeList['other']['category']['pfJz']['num'], 1);
-                                break;
-                            default:
-                        }
-                    }
-                }
-            }
-
-            //零售尾款收入
-            $settleWhere = ['shopId' => $lsShopId, 'status' => 2];
-            $settleWhere['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
-            $settleList = SettleClass::getAllByCondition($settleWhere, null, '*');
-
-            if (!empty($settleList)) {
-                foreach ($settleList as $sKey => $settle) {
-                    $payWay = $settle['payWay'] ?? 0;
-                    $actPrice = $settle['actPrice'] ?? 0;
-                    $getStaffId = $settle['hdShopAdminId'] ?? 0;
-                    $onlinePay = $settle['onlinePay'] ?? 0;
-                    if ($onlinePay == dict::getDict('onlinePay', 'yes')) {
-
-                    } else {
-                        //使用非在线支付
-                        switch ($payWay) {
-                            case dict::getDict('payWay', 'wxPay'):
-                                //员工微信总共收了多少笔多少钱
-                                $incomeList['kfWx']['amount'] = bcadd($incomeList['kfWx']['amount'], $actPrice, 2);
-                                $incomeList['kfWx']['num'] = bcadd($incomeList['kfWx']['num'], 1);
-                                //批发开单、零售开单、批发结账、零售尾款各收了多少现金
-                                $incomeList['kfWx']['category']['lsWk']['amount'] = bcadd($incomeList['kfWx']['category']['lsWk']['amount'], $actPrice, 2);
-                                $incomeList['kfWx']['category']['lsWk']['num'] = bcadd($incomeList['kfWx']['category']['lsWk']['num'], 1);
-                                //客1 客2 客3各收了多少钱
-                                if (isset($incomeList['kfWx']['class'][$getStaffId])) {
-                                    $incomeList['kfWx']['class'][$getStaffId]['amount'] = bcadd($incomeList['kfWx']['class'][$getStaffId]['amount'], $actPrice, 2);
-                                    $incomeList['kfWx']['class'][$getStaffId]['num'] = bcadd($incomeList['kfWx']['class'][$getStaffId]['num'], 1);
-                                }
-                                //每个客服收的明细
-                                if (isset($incomeList['kfWx']['class'][$getStaffId]['itemList']['lsWk'])) {
-                                    $incomeList['kfWx']['class'][$getStaffId]['itemList']['lsWk']['amount'] = floatval(bcadd($incomeList['kfWx']['class'][$getStaffId]['itemList']['lsWk']['amount'], $actPrice, 2));
-                                    $incomeList['kfWx']['class'][$getStaffId]['itemList']['lsWk']['num'] = bcadd($incomeList['kfWx']['class'][$getStaffId]['itemList']['lsWk']['num'], 1);
-                                }
-                                break;
-                            case dict::getDict('payWay', 'alipay'):
-                                $incomeList['aliPay']['amount'] = bcadd($incomeList['aliPay']['amount'], $actPrice, 2);
-                                $incomeList['aliPay']['num'] = bcadd($incomeList['aliPay']['num'], 1);
-                                $incomeList['aliPay']['category']['lsWk']['amount'] = bcadd($incomeList['aliPay']['category']['lsWk']['amount'], $actPrice, 2);
-                                $incomeList['aliPay']['category']['lsWk']['num'] = bcadd($incomeList['aliPay']['category']['lsWk']['num'], 1);
-                                break;
-                            case dict::getDict('payWay', 'cash'):
-                                $incomeList['cash']['amount'] = bcadd($incomeList['cash']['amount'], $actPrice, 2);
-                                $incomeList['cash']['num'] = bcadd($incomeList['cash']['num'], 1);
-                                $incomeList['cash']['category']['lsWk']['amount'] = bcadd($incomeList['cash']['category']['lsWk']['amount'], $actPrice, 2);
-                                $incomeList['cash']['category']['lsWk']['num'] = bcadd($incomeList['cash']['category']['lsWk']['num'], 1);
-                                break;
-                            case dict::getDict('payWay', 'balancePay'):
-                                $incomeList['balancePay']['amount'] = bcadd($incomeList['balancePay']['amount'], $actPrice, 2);
-                                $incomeList['balancePay']['num'] = bcadd($incomeList['balancePay']['num'], 1);
-                                $incomeList['balancePay']['category']['lsWk']['amount'] = bcadd($incomeList['balancePay']['category']['lsWk']['amount'], $actPrice, 2);
-                                $incomeList['balancePay']['category']['lsWk']['num'] = bcadd($incomeList['balancePay']['category']['lsWk']['num'], 1);
-                                break;
-                            case dict::getDict('payWay', 'bankCard'):
-                                $incomeList['bankCard']['amount'] = bcadd($incomeList['aliPay']['amount'], $actPrice, 2);
-                                $incomeList['bankCard']['num'] = bcadd($incomeList['aliPay']['num'], 1);
-                                $incomeList['bankCard']['category']['lsWk']['amount'] = bcadd($incomeList['bankCard']['category']['lsWk']['amount'], $actPrice, 2);
-                                $incomeList['bankCard']['category']['lsWk']['num'] = bcadd($incomeList['bankCard']['category']['lsWk']['num'], 1);
-                                break;
-                            case dict::getDict('payWay', 'unknown'):
-                                $incomeList['other']['amount'] = bcadd($incomeList['aliPay']['amount'], $actPrice, 2);
-                                $incomeList['other']['num'] = bcadd($incomeList['aliPay']['num'], 1);
-                                $incomeList['other']['category']['lsWk']['amount'] = bcadd($incomeList['other']['category']['lsWk']['amount'], $actPrice, 2);
-                                $incomeList['other']['category']['lsWk']['num'] = bcadd($incomeList['other']['category']['lsWk']['num'], 1);
-                                break;
-                            default:
-                        }
-                    }
-
-                }
-            }
-        }
-        return ['incomeList' => $incomeList, 'staffAmountList' => $staffAmountList];
+        return ['incomeList' => $incomeList, 'staffAmountList' => $staffAmountList, 'payCodeIncome' => $payCodeIncome];
 
     }
 

+ 10 - 1
biz-ghs/stat/classes/StatSaleClass.php

@@ -300,6 +300,7 @@ class StatSaleClass extends BaseClass
         }
 
         //零售开单
+        $payCodeIncome = 0;
         $lsIncome = 0;
         $lsSendCost = 0;
         $lsServiceFee = 0;
@@ -308,6 +309,8 @@ class StatSaleClass extends BaseClass
         $hdOrderList = HdOrderClass::getAllByCondition($hdWhere, null, '*');
         foreach ($hdOrderList as $hdKey => $hdOrder) {
             $actPrice = $hdOrder['mainPay'] ?? 0;
+            $onlinePay = $hdOrder['onlinePay'] ?? 1;
+
             if ($hdOrder['tkPrice'] && $hdOrder['tkPrice'] > 0) {
                 $actPrice = bcsub($actPrice, $hdOrder['tkPrice'], 2);
             }
@@ -322,6 +325,12 @@ class StatSaleClass extends BaseClass
                 $lsServiceFee = bcadd($lsServiceFee, $serviceFee, 2);
             }
             $totalOrderNum++;
+
+            if ($onlinePay == 2 && floatval($cash) <= 0) {
+                $payCodeIncome = bcadd($payCodeIncome, $actPrice, 2);
+                $payCodeIncome = floatval($payCodeIncome);
+            }
+
         }
 
         $condition = ['mainId' => $mainId, 'addTime' => ['between', [$currentStartTime, $currentEndTime]],];
@@ -386,7 +395,7 @@ class StatSaleClass extends BaseClass
             $balance = bcsub($balance, $amount, 2);
         }
 
-        return ['income' => $income, 'expend' => $expend, 'balance' => floatval($balance), 'totalOrderNum' => $totalOrderNum];
+        return ['income' => $income, 'expend' => $expend, 'balance' => floatval($balance), 'totalOrderNum' => $totalOrderNum, 'payCodeIncome' => $payCodeIncome];
     }
 
     //按花材统计收入 ssh 20231111