shish 3 лет назад
Родитель
Сommit
d1dea5fae4
1 измененных файлов с 38 добавлено и 15 удалено
  1. 38 15
      biz-ghs/stat/classes/StatKdClass.php

+ 38 - 15
biz-ghs/stat/classes/StatKdClass.php

@@ -85,10 +85,19 @@ class StatKdClass extends BaseClass
             'debt' => [
                 'amount' => 0,
                 'num' => 0,
-                'name' => '欠款',
+                'name' => '待结欠款',
                 'category' => [
-                    'pf' => ['name' => '批发欠款', 'key' => 'pf', 'num' => 0, 'amount' => 0],
-                    'ls' => ['name' => '零售欠款', 'key' => 'ls', 'num' => 0, 'amount' => 0],
+                    'pf' => ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0],
+                    'ls' => ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0],
+                ],
+            ],
+            'debtClear' => [
+                'amount' => 0,
+                'num' => 0,
+                'name' => '已结欠款',
+                'category' => [
+                    'pf' => ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0],
+                    'ls' => ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0],
                 ],
             ],
             'cash' => [
@@ -148,14 +157,21 @@ class StatKdClass extends BaseClass
                 $payWay = $ghsOrder['payWay'] ?? 0;
                 $actPrice = $ghsOrder['actPrice'] ?? 0;
                 $getStaffId = $ghsOrder['getStaffId'] ?? 0;
-                $debtPrice = $ghsOrder['remainDebtPrice'] ?? 0;
+                $debtPrice = $ghsOrder['debtPrice'] ?? 0;
+                $remainDebtPrice = $ghsOrder['remainDebtPrice'] ?? 0;
                 $onlinePay = $ghsOrder['onlinePay'] ?? dict::getDict('onlinePay', 'not');
                 if ($debtPrice > 0) {
-                    //不管是否结清,只要$debtPrice > 0,说明曾经是欠款单
-                    $incomeList['debt']['amount'] = bcadd($incomeList['debt']['amount'], $debtPrice, 2);
-                    $incomeList['debt']['num'] = bcadd($incomeList['debt']['num'], 1);
-                    $incomeList['debt']['category']['pf']['amount'] = bcadd($incomeList['debt']['category']['pf']['amount'], $debtPrice, 2);
-                    $incomeList['debt']['category']['pf']['num'] = bcadd($incomeList['debt']['category']['pf']['num'], 1);
+                    if ($remainDebtPrice > 0) {
+                        $incomeList['debt']['amount'] = bcadd($incomeList['debt']['amount'], $debtPrice, 2);
+                        $incomeList['debt']['num'] = bcadd($incomeList['debt']['num'], 1);
+                        $incomeList['debt']['category']['pf']['amount'] = bcadd($incomeList['debt']['category']['pf']['amount'], $debtPrice, 2);
+                        $incomeList['debt']['category']['pf']['num'] = bcadd($incomeList['debt']['category']['pf']['num'], 1);
+                    } else {
+                        $incomeList['debtClear']['amount'] = bcadd($incomeList['debt']['amount'], $debtPrice, 2);
+                        $incomeList['debtClear']['num'] = bcadd($incomeList['debt']['num'], 1);
+                        $incomeList['debtClear']['category']['pf']['amount'] = bcadd($incomeList['debt']['category']['pf']['amount'], $debtPrice, 2);
+                        $incomeList['debtClear']['category']['pf']['num'] = bcadd($incomeList['debt']['category']['pf']['num'], 1);
+                    }
                 } else {
                     if ($onlinePay == dict::getDict('onlinePay', 'yes')) {
                         //使用在线支付
@@ -225,7 +241,8 @@ class StatKdClass extends BaseClass
             $cash = $hdOrder['cash'] ?? 0;
             $actPrice = $hdOrder['actPrice'] ?? 0;
             $getStaffId = $hdOrder['getStaffId'] ?? 0;
-            $debtPrice = $hdOrder['remainDebtPrice'] ?? 0;
+            $debtPrice = $hdOrder['debtPrice'] ?? 0;
+            $remainDebtPrice = $hdOrder['remainDebtPrice'] ?? 0;
             $onlinePay = $hdOrder['onlinePay'] ?? 0;
             $fromType = $hdOrder['fromType'] ?? 0;
 
@@ -250,11 +267,17 @@ class StatKdClass extends BaseClass
                     //非美团!!!
 
                     if ($debtPrice > 0) {
-                        //不管是否结清,只要$debtPrice > 0,说明曾经是欠款单
-                        $incomeList['debt']['amount'] = bcadd($incomeList['debt']['amount'], $debtPrice, 2);
-                        $incomeList['debt']['num'] = bcadd($incomeList['debt']['num'], 1);
-                        $incomeList['debt']['category']['ls']['amount'] = bcadd($incomeList['debt']['category']['ls']['amount'], $debtPrice, 2);
-                        $incomeList['debt']['category']['ls']['num'] = bcadd($incomeList['debt']['category']['ls']['num'], 1);
+                        if ($remainDebtPrice > 0) {
+                            $incomeList['debt']['amount'] = bcadd($incomeList['debt']['amount'], $debtPrice, 2);
+                            $incomeList['debt']['num'] = bcadd($incomeList['debt']['num'], 1);
+                            $incomeList['debt']['category']['ls']['amount'] = bcadd($incomeList['debt']['category']['ls']['amount'], $debtPrice, 2);
+                            $incomeList['debt']['category']['ls']['num'] = bcadd($incomeList['debt']['category']['ls']['num'], 1);
+                        } else {
+                            $incomeList['debtClear']['amount'] = bcadd($incomeList['debt']['amount'], $debtPrice, 2);
+                            $incomeList['debtClear']['num'] = bcadd($incomeList['debt']['num'], 1);
+                            $incomeList['debtClear']['category']['ls']['amount'] = bcadd($incomeList['debt']['category']['ls']['amount'], $debtPrice, 2);
+                            $incomeList['debtClear']['category']['ls']['num'] = bcadd($incomeList['debt']['category']['ls']['num'], 1);
+                        }
                     }
 
                     //付订金的情况!!