调整平台财务账单查询

This commit is contained in:
luofei 2024-02-03 16:59:21 +08:00
parent 6e6e9fb506
commit 477b252cf7

View File

@ -31,7 +31,7 @@ class FinancialRecordRepository extends BaseRepository
{ {
public $commonFinancialType = [ public $commonFinancialType = [
'order', 'brokerage_one', 'brokerage_two', 'refund_brokerage_one', 'refund_brokerage_two', 'refund_order','order_platform_coupon', 'order', 'order_refund', 'brokerage_one', 'brokerage_two', 'refund_brokerage_one', 'refund_brokerage_two', 'refund_order','order_platform_coupon',
'order_svip_coupon','commission_to_service_team','commission_to_service_team_refund','commission_to_platform','commission_to_platform_refund','commission_to_village','commission_to_village_refund','commission_to_town','commission_to_town_refund' 'order_svip_coupon','commission_to_service_team','commission_to_service_team_refund','commission_to_platform','commission_to_platform_refund','commission_to_village','commission_to_village_refund','commission_to_town','commission_to_town_refund'
,'commission_to_entry_merchant','commission_to_entry_merchant_refund' ,'commission_to_entry_merchant','commission_to_entry_merchant_refund'
,'commission_to_cloud_warehouse','commission_to_cloud_warehouse_refund', 'commission_to_store', 'commission_to_courier', 'commission_to_promoter', 'commission_to_store_refund', 'commission_to_courier_refund', 'commission_to_promoter_refund', 'auto_margin', 'auto_margin_refund', 'supply_chain', 'supply_chain_refund', 'platform_consumption', 'platform_consumption_refund' ,'commission_to_cloud_warehouse','commission_to_cloud_warehouse_refund', 'commission_to_store', 'commission_to_courier', 'commission_to_promoter', 'commission_to_store_refund', 'commission_to_courier_refund', 'commission_to_promoter_refund', 'auto_margin', 'auto_margin_refund', 'supply_chain', 'supply_chain_refund', 'platform_consumption', 'platform_consumption_refund'
@ -126,8 +126,13 @@ class FinancialRecordRepository extends BaseRepository
//订单收入总金额 //订单收入总金额
$count = $this->dao->search($where)->where('financial_type', 'in', ['order', 'order_presell', 'presell'])->sum('number'); $count = $this->dao->search($where)->where('financial_type', 'in', ['order', 'order_presell', 'presell'])->sum('number');
//退款支出金额 //退款支出金额
$refund_order = $this->dao->search($where)->where('financial_type', 'refund_order')->sum('number'); $refund_order = $this->dao->search($where)->where('financial_type', 'order_refund')->sum('number');
$platformProfit = bcsub($count, $refund_order, 2); $platformProfit = bcsub($count, $refund_order, 2);
//供应链金额
$supply = $this->dao->search($where)->where('financial_type', 'supply_chain')->sum('number');
$supplyRefund = $this->dao->search($where)->where('financial_type', 'supply_chain_refund')->sum('number');
$platformProfit = bcsub($platformProfit, $supply, 2);
$platformProfit = bcadd($platformProfit, $supplyRefund, 2);
//佣金支出金额 //佣金支出金额
$brokerage_ = $this->dao->search($where)->where('financial_type', 'in', ['brokerage_one', 'brokerage_two'])->sum('number'); $brokerage_ = $this->dao->search($where)->where('financial_type', 'in', ['brokerage_one', 'brokerage_two'])->sum('number');
$_brokerage = $this->dao->search($where)->where('financial_type', 'in', ['refund_brokerage_two', 'refund_brokerage_one'])->sum('number'); $_brokerage = $this->dao->search($where)->where('financial_type', 'in', ['refund_brokerage_two', 'refund_brokerage_one'])->sum('number');
@ -191,6 +196,18 @@ class FinancialRecordRepository extends BaseRepository
'field' => '元', 'field' => '元',
'name' => '退款支出金额' 'name' => '退款支出金额'
], ],
[
'className' => 'el-icon-s-goods',
'count' => $supply,
'field' => '元',
'name' => '供应链成本'
],
[
'className' => 'el-icon-s-order',
'count' => $supplyRefund,
'field' => '元',
'name' => '供应链退款'
],
[ [
'className' => 'el-icon-s-cooperation', 'className' => 'el-icon-s-cooperation',
'count' => $brokerage, 'count' => $brokerage,
@ -436,11 +453,15 @@ class FinancialRecordRepository extends BaseRepository
'number' => $expend['number'], 'number' => $expend['number'],
'count' => $expend['count'] . '笔', 'count' => $expend['count'] . '笔',
'data' => [ 'data' => [
['应付商户金额', $expend['number_order'] . '元', $expend['count_order'] . '笔'], ['订单退款金额', $expend['number_refund'] . '元', $expend['count_refund'] . '笔'],
['应付商户金额', $expend['number_supply_chain'] . '元', $expend['count_supply_chain'] . '笔'],
['佣金', $expend['number_brokerage'] . '元', $expend['count_brokerage'] . '笔'], ['佣金', $expend['number_brokerage'] . '元', $expend['count_brokerage'] . '笔'],
['返还手续费', $expend['number_charge'] . '元', $expend['count_charge'] . '笔'], ['返还手续费', $expend['number_charge'] . '元', $expend['count_charge'] . '笔'],
['优惠券补贴', $expend['number_coupon'] . '元', $expend['count_coupon'] . '笔'], ['优惠券补贴', $expend['number_coupon'] . '元', $expend['count_coupon'] . '笔'],
['会员优惠券补贴', $expend['number_svipcoupon'] . '元', $expend['count_svipcoupon'] . '笔'], ['会员优惠券补贴', $expend['number_svipcoupon'] . '元', $expend['count_svipcoupon'] . '笔'],
['平台红包补贴', $expend['number_consumption'] . '元', $expend['count_consumption'] . '笔'],
['服务团队佣金', $expend['number_commission'] . '元', $expend['count_commission'] . '笔'],
['保证金退款', $expend['number_margin'] . '元', $expend['count_margin'] . '笔'],
] ]
]; ];
$data['charge'] = [ $data['charge'] = [
@ -539,7 +560,12 @@ class FinancialRecordRepository extends BaseRepository
*/ */
public function countIncome($type, $where, $date, $merchant = []) public function countIncome($type, $where, $date, $merchant = [])
{ {
$financialType = ['order', 'order_presell', 'presell', 'mer_presell', 'commission_to_store', 'commission_to_promoter', 'supply_chain', 'auto_margin_refund']; if ($where['is_mer'] > 0) {
$financialType = ['commission_to_store', 'commission_to_promoter', 'supply_chain', 'auto_margin_refund'];
} else {
$financialType = ['order', 'commission_to_store_refund', 'commission_to_promoter_refund',
'commission_to_courier_refund', 'supply_chain_refund', 'auto_margin', 'platform_consumption_refund'];
}
if ($merchant){ if ($merchant){
switch ($merchant['type_id']) { switch ($merchant['type_id']) {
case 16: case 16:
@ -692,36 +718,32 @@ class FinancialRecordRepository extends BaseRepository
[$data['count'], $data['number']] = $this->dao->getDataByType($type, $where, $date, $financialType); [$data['count'], $data['number']] = $this->dao->getDataByType($type, $where, $date, $financialType);
$data['number'] = bcsub($data['number'], 0, 2); $data['number'] = bcsub($data['number'], 0, 2);
} else { //平台的 } else { //平台的
// 退回 订单实际获得金额 // 退款订单
[$data['count_refund'], $data['number_refund']] = $this->dao->getDataByType($type, $where, $date, ['order_refund']);
$financialType = ['order_true', 'presell_true','auto_margin']; $total = $data['number_refund'];
[$data['count_order'], $data['number_order']] = $this->dao->getDataByType($type, $where, $date, $financialType); // 供应链订单
[$data['count_supply_chain'], $data['number_supply_chain']] = $this->dao->getDataByType($type, $where, $date, ['supply_chain']);
$financialType = ['commission_to_entry_merchant']; $total = bcadd($total, $data['number_supply_chain'], 2);
[$data['count_merchant'], $data['number_merchant']] = $this->dao->getDataByType($type, $where, $date, $financialType); // 退保证金记录
$data['count_order']=bcsub($data['count_order'],$data['count_merchant']); [$data['count_margin'], $data['number_margin']] = $this->dao->getDataByType($type, $where, $date, ['auto_margin_refund']);
$data['number_order']=bcsub($data['number_order'],$data['number_merchant'], 2); $total = bcadd($total, $data['number_margin'], 2);
//付给商户的优惠券抵扣金额 //付给商户的优惠券抵扣金额
$financialType = ['order_platform_coupon']; [$data['count_coupon'], $data['number_coupon']] = $this->dao->getDataByType($type, $where, $date, ['order_platform_coupon']);
[$data['count_coupon'], $data['number_coupon']] = $this->dao->getDataByType($type, $where, $date, $financialType); $total = bcadd($total, $data['number_coupon'], 2);
//付给商户的svip优惠券抵扣金额 //付给商户的svip优惠券抵扣金额
$financialType = ['order_svip_coupon']; [$data['count_svipcoupon'], $data['number_svipcoupon']] = $this->dao->getDataByType($type, $where, $date, ['order_svip_coupon']);
[$data['count_svipcoupon'], $data['number_svipcoupon']] = $this->dao->getDataByType($type, $where, $date, $financialType); $total = bcadd($total, $data['number_svipcoupon'], 2);
//付给服务团队和其他的佣金 //付给服务团队和其他的佣金
[$data['count_refund'], $data['number_refund']] = $this->dao->getDataByType($type, $where, $date, $refund); $financialType = ['commission_to_store', 'commission_to_courier', 'commission_to_promoter'];
[$data['count_commission'], $data['number_commission']] = $this->dao->getDataByType($type, $where, $date, $commission); [$data['count_commission'], $data['number_commission']] = $this->dao->getDataByType($type, $where, $date, $financialType);
$total = bcadd($total, $data['number_commission'], 2);
//平台红包
$financialType = ['platform_consumption'];
[$data['count_consumption'], $data['number_consumption']] = $this->dao->getDataByType($type, $where, $date, $financialType);
$total = bcadd($total, $data['number_consumption'], 2);
$data['count_brokerage']+=$data['count_commission']-$data['count_refund']; $data['count'] = $data['count_refund'] + $data['count_supply_chain'] + $data['count_margin'] + $data['count_coupon'] + $data['count_svipcoupon'] + $data['count_commission'] + $data['count_consumption'];
$data['number_brokerage']+=$data['number_commission']-$data['number_refund']; $data['number'] = $total;
$number = bcadd($data['number_brokerage'], $data['number_order'], 2);
$number_1 = bcadd(bcadd($number, $data['number_coupon'], 2), $data['number_svipcoupon'], 2);
$data['count'] = $data['count_brokerage'] + $data['count_order'] + $data['count_charge'];
$data['number'] = bcadd($number_1, $data['number_charge'], 2);
} }
return $data; return $data;
} }