|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace statistics;
|
|
|
use Log;
|
|
|
+use merchantModel;
|
|
|
|
|
|
class refill_balance
|
|
|
{
|
|
@@ -92,24 +93,36 @@ class refill_balance
|
|
|
{
|
|
|
$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') {
|
|
|
- $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);
|
|
|
$cname = 'system';
|
|
|
|
|
|
+ $in = $in_calcer($in_detail);
|
|
|
$balance = ncPriceFormat($in - $out);
|
|
|
} elseif ($type == 'merchant') {
|
|
|
- $in = $this->merchant_evidence_stat($cid, $start, $end);
|
|
|
+ $in_detail = $this->merchant_evidence_stat($cid, $start, $end);
|
|
|
$out = "0.0000";
|
|
|
$cname = $this->mMerchantNames[$cid];
|
|
|
|
|
|
+ $in = $in_calcer($in_detail);
|
|
|
$balance = ncPriceFormat($in - $order_stat['mch_amounts']);
|
|
|
} else {
|
|
|
- $in = "0.0000";
|
|
|
+ $in_detail = [];
|
|
|
$pid = $this->mStoreidPID[$cid];
|
|
|
$out = $this->provider_amount_stat($pid, $start, $end);
|
|
|
$cname = $this->mProviderNames[$cid];
|
|
|
|
|
|
+ $in = $in_calcer($in_detail);
|
|
|
$balance = ncPriceFormat($in - $order_stat['channel_amounts']);
|
|
|
}
|
|
|
|
|
@@ -135,7 +148,7 @@ class refill_balance
|
|
|
'channel_amount' => ncPriceFormat($order_stat['channel_amounts']),
|
|
|
'service_amount' => ncPriceFormat(0),
|
|
|
'profit_amount' => ncPriceFormat($order_stat['profit_amounts']),
|
|
|
- 'transfer_in' => ncPriceFormat($in),
|
|
|
+ 'transfer_in' => json_encode($in_detail),
|
|
|
'transfer_out' => ncPriceFormat($out),
|
|
|
'except_amount' => ncPriceFormat(0),
|
|
|
'accumulate_balance' => ncPriceFormat($accumuter($parent_balance)),
|
|
@@ -220,19 +233,20 @@ class refill_balance
|
|
|
|
|
|
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) {
|
|
|
$cond['mchid'] = $cid;
|
|
|
}
|
|
|
$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)
|
|
|
- ->find();
|
|
|
+ ->select();
|
|
|
|
|
|
- return ncPriceFormat($record['amounts']);
|
|
|
+ return $records;
|
|
|
}
|
|
|
|
|
|
private function provider_amount_stat($provider_id, $start, $end)
|