stanley-king 2 years ago
parent
commit
90604828aa
2 changed files with 25 additions and 11 deletions
  1. 1 1
      helper/refill/policy/quaility.php
  2. 24 10
      helper/statistics/refill_balance.php

+ 1 - 1
helper/refill/policy/quaility.php

@@ -311,8 +311,8 @@ class Quality
                         break;
                         break;
                     }
                     }
                 }
                 }
-                $result = array_reverse($result);
 
 
+                $result = array_reverse($result);
                 return $result;
                 return $result;
             }
             }
         };
         };

+ 24 - 10
helper/statistics/refill_balance.php

@@ -2,6 +2,7 @@
 
 
 namespace statistics;
 namespace statistics;
 use Log;
 use Log;
+use merchantModel;
 
 
 class refill_balance
 class refill_balance
 {
 {
@@ -92,24 +93,36 @@ class refill_balance
     {
     {
         $order_stat = $this->order_stat($type, $cid, $start, $end, $time_type);
         $order_stat = $this->order_stat($type, $cid, $start, $end, $time_type);
 
 
+        $in_calcer = function ($detail)
+        {
+            $result = 0.0;
+            foreach ($detail as $type => $amount) {
+                $result += $amount;
+            }
+            return $result;
+        };
+
         if ($type == 'system') {
         if ($type == 'system') {
-            $in = $this->merchant_evidence_stat(0, $start, $end);
+            $in_detail = $this->merchant_evidence_stat(0, $start, $end);
             $out = $this->provider_amount_stat(0, $start, $end);
             $out = $this->provider_amount_stat(0, $start, $end);
             $cname = 'system';
             $cname = 'system';
 
 
+            $in = $in_calcer($in_detail);
             $balance = ncPriceFormat($in - $out);
             $balance = ncPriceFormat($in - $out);
         } elseif ($type == 'merchant') {
         } elseif ($type == 'merchant') {
-            $in = $this->merchant_evidence_stat($cid, $start, $end);
+            $in_detail = $this->merchant_evidence_stat($cid, $start, $end);
             $out = "0.0000";
             $out = "0.0000";
             $cname = $this->mMerchantNames[$cid];
             $cname = $this->mMerchantNames[$cid];
 
 
+            $in = $in_calcer($in_detail);
             $balance = ncPriceFormat($in - $order_stat['mch_amounts']);
             $balance = ncPriceFormat($in - $order_stat['mch_amounts']);
         } else {
         } else {
-            $in = "0.0000";
+            $in_detail = [];
             $pid = $this->mStoreidPID[$cid];
             $pid = $this->mStoreidPID[$cid];
             $out = $this->provider_amount_stat($pid, $start, $end);
             $out = $this->provider_amount_stat($pid, $start, $end);
             $cname = $this->mProviderNames[$cid];
             $cname = $this->mProviderNames[$cid];
 
 
+            $in = $in_calcer($in_detail);
             $balance = ncPriceFormat($in - $order_stat['channel_amounts']);
             $balance = ncPriceFormat($in - $order_stat['channel_amounts']);
         }
         }
 
 
@@ -135,7 +148,7 @@ class refill_balance
             'channel_amount' => ncPriceFormat($order_stat['channel_amounts']),
             'channel_amount' => ncPriceFormat($order_stat['channel_amounts']),
             'service_amount' => ncPriceFormat(0),
             'service_amount' => ncPriceFormat(0),
             'profit_amount' => ncPriceFormat($order_stat['profit_amounts']),
             'profit_amount' => ncPriceFormat($order_stat['profit_amounts']),
-            'transfer_in' => ncPriceFormat($in),
+            'transfer_in' => json_encode($in_detail),
             'transfer_out' => ncPriceFormat($out),
             'transfer_out' => ncPriceFormat($out),
             'except_amount' => ncPriceFormat(0),
             'except_amount' => ncPriceFormat(0),
             'accumulate_balance' => ncPriceFormat($accumuter($parent_balance)),
             'accumulate_balance' => ncPriceFormat($accumuter($parent_balance)),
@@ -220,19 +233,20 @@ class refill_balance
 
 
     private function merchant_evidence_stat($cid, $start, $end)
     private function merchant_evidence_stat($cid, $start, $end)
     {
     {
-        $cond['status'] = $cond['is_operation'] = 2;
-        $cond['add_type'] = ['neq', 4];
+        $cond['status'] = merchantModel::status_passed;
+        $cond['is_operation'] = merchantModel::oper_deposited;
+
         if($cid > 0) {
         if($cid > 0) {
             $cond['mchid'] = $cid;
             $cond['mchid'] = $cid;
         }
         }
         $cond['check_time&check_time'] = ['_multi' => true, ['egt', $start], ['lt', $end]];
         $cond['check_time&check_time'] = ['_multi' => true, ['egt', $start], ['lt', $end]];
 
 
-        $record = Model('')->table('refill_evidence')
-            ->field('sum(amount) as amounts')
+        $records = Model('')->table('refill_evidence')
+            ->field('add_type,sum(amount) as amounts')
             ->where($cond)
             ->where($cond)
-            ->find();
+            ->select();
 
 
-        return ncPriceFormat($record['amounts']);
+        return $records;
     }
     }
 
 
     private function provider_amount_stat($provider_id, $start, $end)
     private function provider_amount_stat($provider_id, $start, $end)