调整商户后台财务账单查询
This commit is contained in:
parent
c355e918fb
commit
6e6e9fb506
@ -84,7 +84,7 @@ class FinancialRecordDao extends BaseDao
|
|||||||
})
|
})
|
||||||
->when(isset($where['is_mer']) && $where['is_mer'] !== '', function ($query) use ($where) {
|
->when(isset($where['is_mer']) && $where['is_mer'] !== '', function ($query) use ($where) {
|
||||||
if($where['is_mer']){
|
if($where['is_mer']){
|
||||||
$query->where('mer_id',$where['is_mer'])->where('type','in',[0,1]);
|
$query->where('mer_id',$where['is_mer'])->where('type','in',[0,1, 2]);
|
||||||
}else{
|
}else{
|
||||||
$query->where('type','in',[1,2]);
|
$query->where('type','in',[1,2]);
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,11 @@ class FinancialRecordRepository extends BaseRepository
|
|||||||
$query = $this->dao->search($where)->order('create_time DESC');
|
$query = $this->dao->search($where)->order('create_time DESC');
|
||||||
$count = $query->count();
|
$count = $query->count();
|
||||||
$list = $query->page($page, $limit)->select();
|
$list = $query->page($page, $limit)->select();
|
||||||
|
foreach ($list as &$item) {
|
||||||
|
if (!empty($where['mer_id'])) {
|
||||||
|
$item['financial_pm'] = $item['financial_pm'] == 0 ? 1 : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
return compact('count', 'list');
|
return compact('count', 'list');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,7 +271,7 @@ class FinancialRecordRepository extends BaseRepository
|
|||||||
public function getMerchantTitle($where)
|
public function getMerchantTitle($where)
|
||||||
{
|
{
|
||||||
//商户收入
|
//商户收入
|
||||||
$count = $this->dao->search($where)->where('financial_type', 'in', ['order', 'mer_presell'])->sum('number');
|
$count = $this->dao->search($where)->where('financial_type', 'in', ['order', 'mer_presell', 'supply_chain'])->sum('number');
|
||||||
//押金
|
//押金
|
||||||
$auto_margin = $this->dao->search($where)->where('financial_type', 'auto_margin')->sum('number');
|
$auto_margin = $this->dao->search($where)->where('financial_type', 'auto_margin')->sum('number');
|
||||||
$auto_margin_refund = $this->dao->search($where)->where('financial_type', 'auto_margin_refund')->sum('number');
|
$auto_margin_refund = $this->dao->search($where)->where('financial_type', 'auto_margin_refund')->sum('number');
|
||||||
@ -279,22 +284,18 @@ class FinancialRecordRepository extends BaseRepository
|
|||||||
//商户可提现金额
|
//商户可提现金额
|
||||||
$_line = bcsub($mer_money, $extract_minimum_line, 2);
|
$_line = bcsub($mer_money, $extract_minimum_line, 2);
|
||||||
//退款支出金额
|
//退款支出金额
|
||||||
$refund_order = $this->dao->search($where)->where('financial_type', 'refund_order')->sum('number');
|
$refund_order = $this->dao->search($where)->where('financial_type', 'in', ['refund_order', 'supply_chain_refund'])->sum('number');
|
||||||
//佣金支出金额
|
//平台佣金
|
||||||
$_brokerage = $this->dao->search($where)->where('financial_type', 'in', ['brokerage_one', 'brokerage_two'])->sum('number');
|
$commission = $this->dao->search($where)->whereIn('financial_type', ['commission_to_store', 'commission_to_promoter'])->sum('number');
|
||||||
$refund_brokerage = $this->dao->search($where)->where('financial_type', 'in', ['refund_brokerage_one', 'refund_brokerage_two'])->sum('number');
|
$commissionRefund = $this->dao->search($where)->whereIn('financial_type', ['commission_to_store_refund', 'commission_to_promoter_refund'])->sum('number');
|
||||||
$brokerage = bcsub($_brokerage, $refund_brokerage, 2);
|
$commission = bcsub($commission, $commissionRefund, 2);
|
||||||
//平台手续费
|
|
||||||
$refund_true = $this->dao->search($where)->where('financial_type', 'in', ['order_charge', 'presell_charge'])->sum('number');
|
|
||||||
$order_charge = $this->dao->search($where)->where('financial_type', 'refund_charge')->sum('number');
|
|
||||||
$charge = bcsub($refund_true, $order_charge, 2);
|
|
||||||
//商户可提现金额
|
//商户可提现金额
|
||||||
// $bill_order = app()->make(StoreOrderRepository::class)->search(['paid' => 1,'date' => $where['date'],'pay_type' => 0])->sum('pay_price');
|
// $bill_order = app()->make(StoreOrderRepository::class)->search(['paid' => 1,'date' => $where['date'],'pay_type' => 0])->sum('pay_price');
|
||||||
$merLockMoney = app()->make(UserBillRepository::class)->merchantLickMoney($where['is_mer']);
|
$merLockMoney = app()->make(UserBillRepository::class)->merchantLickMoney($where['is_mer']);
|
||||||
$stat = [
|
$stat = [
|
||||||
[
|
[
|
||||||
'className' => 'el-icon-s-goods',
|
'className' => 'el-icon-s-goods',
|
||||||
'count' => $count,
|
'count' => bcsub($count, 0, 2),
|
||||||
'field' => '元',
|
'field' => '元',
|
||||||
'name' => '商户收入'
|
'name' => '商户收入'
|
||||||
],
|
],
|
||||||
@ -312,27 +313,15 @@ class FinancialRecordRepository extends BaseRepository
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
'className' => 'el-icon-s-cooperation',
|
'className' => 'el-icon-s-cooperation',
|
||||||
'count' => $refund_order,
|
'count' => bcsub($refund_order, 0, 2),
|
||||||
'field' => '元',
|
'field' => '元',
|
||||||
'name' => '退款支出'
|
'name' => '退款支出'
|
||||||
],
|
],
|
||||||
[
|
|
||||||
'className' => 'el-icon-s-finance',
|
|
||||||
'count' => $brokerage,
|
|
||||||
'field' => '元',
|
|
||||||
'name' => '佣金支出'
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
'className' => 'el-icon-s-cooperation',
|
'className' => 'el-icon-s-cooperation',
|
||||||
'count' => $charge,
|
'count' => $commission,
|
||||||
'field' => '元',
|
'field' => '元',
|
||||||
'name' => '平台手续费'
|
'name' => '平台佣金'
|
||||||
],
|
|
||||||
[
|
|
||||||
'className' => 'el-icon-s-cooperation',
|
|
||||||
'count' => $coupon,
|
|
||||||
'field' => '元',
|
|
||||||
'name' => '平台优惠券补贴'
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'className' => 'el-icon-s-cooperation',
|
'className' => 'el-icon-s-cooperation',
|
||||||
@ -483,11 +472,12 @@ class FinancialRecordRepository extends BaseRepository
|
|||||||
|
|
||||||
$data['date'] = $date;
|
$data['date'] = $date;
|
||||||
$data['income'] = [
|
$data['income'] = [
|
||||||
'title' => '订单收入总金额',
|
'title' => '收入总金额',
|
||||||
'number' => $income['number'],
|
'number' => $income['number'],
|
||||||
'count' => $income['count'] . '笔',
|
'count' => $income['count'] . '笔',
|
||||||
'data' => [
|
'data' => [
|
||||||
['订单支付', $income['number_order'] . '元', $income['count_order'] . '笔'],
|
['订单支付', $income['number_order'] . '元', $income['count_order'] . '笔'],
|
||||||
|
['平台佣金', $income['number_commission'] . '元', $income['count_commission'] . '笔'],
|
||||||
['优惠券补贴', $income['number_coupon'] . '元', $income['count_coupon'] . '笔'],
|
['优惠券补贴', $income['number_coupon'] . '元', $income['count_coupon'] . '笔'],
|
||||||
['会员优惠券补贴', $income['number_svipcoupon'] . '元', $income['count_svipcoupon'] . '笔'],
|
['会员优惠券补贴', $income['number_svipcoupon'] . '元', $income['count_svipcoupon'] . '笔'],
|
||||||
]
|
]
|
||||||
@ -497,16 +487,10 @@ class FinancialRecordRepository extends BaseRepository
|
|||||||
'number' => $expend['number'],
|
'number' => $expend['number'],
|
||||||
'count' => $expend['count'] . '笔',
|
'count' => $expend['count'] . '笔',
|
||||||
'data' => [
|
'data' => [
|
||||||
[
|
|
||||||
'平台手续费',
|
|
||||||
bcsub($expend['number_order_charge'], $expend['number_charge'], 2). '元',
|
|
||||||
bcsub($expend['count_order_charge'], $expend['count_charge']). '笔',
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
'店铺押金',
|
'店铺押金',
|
||||||
$expend['number_auto_margin'] . '元',
|
$expend['number_auto_margin'] . '元',
|
||||||
$expend['count_auto_margin'] . '笔'
|
$expend['count_auto_margin'] . '笔'
|
||||||
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'自动下单市供应链',
|
'自动下单市供应链',
|
||||||
@ -555,7 +539,7 @@ 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'];
|
$financialType = ['order', 'order_presell', 'presell', 'mer_presell', 'commission_to_store', 'commission_to_promoter', 'supply_chain', 'auto_margin_refund'];
|
||||||
if ($merchant){
|
if ($merchant){
|
||||||
switch ($merchant['type_id']) {
|
switch ($merchant['type_id']) {
|
||||||
case 16:
|
case 16:
|
||||||
@ -600,9 +584,11 @@ class FinancialRecordRepository extends BaseRepository
|
|||||||
$financialType = ['refund_svip_coupon'];
|
$financialType = ['refund_svip_coupon'];
|
||||||
}
|
}
|
||||||
[$data['count_svipcoupon'], $data['number_svipcoupon']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
[$data['count_svipcoupon'], $data['number_svipcoupon']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
||||||
|
[$data['count_commission'], $data['number_commission']] = $this->dao->getDataByType($type, $where, $date, ['commission_to_store', 'commission_to_promoter']);
|
||||||
|
|
||||||
$data['count'] = $data['count_order'];
|
$data['count'] = $data['count_order'];
|
||||||
$data['number'] = bcadd($data['number_coupon'], $data['number_order'], 2);
|
$data['number'] = bcadd($data['number_coupon'], $data['number_order'], 2);
|
||||||
|
$data['number'] = bcadd($data['number'], $data['number_commission'], 2);
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -685,59 +671,26 @@ class FinancialRecordRepository extends BaseRepository
|
|||||||
}
|
}
|
||||||
if ($where['is_mer']) { //商户的
|
if ($where['is_mer']) { //商户的
|
||||||
//退回收入
|
//退回收入
|
||||||
$financialType = ['refund_order'];
|
$financialType = ['supply_chain_refund'];
|
||||||
[$data['count_refund'], $data['number_refund']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
[$data['count_refund'], $data['number_refund']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
||||||
|
|
||||||
//平台手续费
|
//平台手续费
|
||||||
$financialType = ['order_charge', 'presell_charge'];
|
[$data['count_order_charge'], $data['number_order_charge']] = [0, 0];
|
||||||
[$data['count_order_charge'], $data['number_order_charge']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
[$data['count_supply_chain'], $data['number_supply_chain']] = [0, 0];
|
||||||
|
|
||||||
//转给市级供应链
|
|
||||||
$financialType = ['supply_chain'];
|
|
||||||
[$data['count_supply_chain'], $data['number_supply_chain']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
|
||||||
//商户押金
|
//商户押金
|
||||||
$financialType = ['auto_margin'];
|
$financialType = ['auto_margin'];
|
||||||
[$data['count_auto_margin'], $data['number_auto_margin']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
[$data['count_auto_margin'], $data['number_auto_margin']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
||||||
//商户押金退回
|
|
||||||
$financialType = ['auto_margin_refund'];
|
|
||||||
[$data['count_auto_margin_refund'], $data['number_auto_margin_refund']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
|
||||||
$number3 = bcsub($data['number_auto_margin'], $data['number_auto_margin_refund'], 2);
|
|
||||||
$data['count_auto_margin'] = bcsub($data['count_auto_margin'], $data['count_auto_margin_refund']);
|
|
||||||
$data['number_auto_margin'] = $number3;
|
|
||||||
//退回佣金
|
//退回佣金
|
||||||
$financialType = ['refund_brokerage_two', 'refund_brokerage_one'];
|
[$data['count_refund_brokerage'], $data['number_refund_brokerage']] = [0, 0];
|
||||||
[$data['count_refund_brokerage'], $data['number_refund_brokerage']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
|
||||||
|
|
||||||
//退回给平台的优惠券金额
|
//退回给平台的优惠券金额
|
||||||
$financialType = ['refund_platform_coupon'];
|
[$data['count_coupon'], $data['number_coupon']] = [0, 0];
|
||||||
[$data['count_coupon'], $data['number_coupon']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
|
||||||
//退回给平台的会员优惠券金额
|
//退回给平台的会员优惠券金额
|
||||||
$financialType = ['refund_svip_coupon'];
|
[$data['count_svipcoupon'], $data['number_svipcoupon']] = [0, 0];
|
||||||
[$data['count_svipcoupon'], $data['number_svipcoupon']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
|
||||||
// if (!empty($financialType1)){
|
|
||||||
// $financialType2= [explode('_refund',$financialType1[0])[0]];
|
|
||||||
// halt($financialType1,$financialType2);
|
|
||||||
// [$data['count_commission'], $data['number_commission']] = $this->dao->getDataByType($type, $where, $date, $financialType1);
|
|
||||||
// [$data['count_commission2'], $data['number_commission2']] = $this->dao->getDataByType($type, $where, $date, $financialType2);
|
|
||||||
// $data['count_brokerage']+=$data['count_commission2']-$data['count_commission'];
|
|
||||||
// $data['number_brokerage']+=$data['number_commission2']-$data['number_commission'];
|
|
||||||
// }
|
|
||||||
//佣金 brokerage_one,brokerage_two - 退回佣金 refund_brokerage_two,refund_brokerage_one )
|
|
||||||
$number = bcsub($data['number_brokerage'], $data['number_refund_brokerage'], 2);
|
|
||||||
//平台手续费 =( order_charge + 预售手续费 presell_charge - 平台退给商户的手续费 refund_charge )
|
|
||||||
$number_1 = bcsub($data['number_order_charge'], $data['number_charge'], 2);
|
|
||||||
if($data['number_supply_chain']>0){
|
if($data['number_supply_chain']>0){
|
||||||
$financialType = ['commission_to_cloud_warehouse'];
|
[$data['count_commission_to_cloud_warehouse'], $data['number_commission_to_cloud_warehouse']] = [0, 0];
|
||||||
[$data['count_commission_to_cloud_warehouse'], $data['number_commission_to_cloud_warehouse']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
|
||||||
$number_1=bcadd($number_1, $data['number_supply_chain'], 2);
|
|
||||||
$number_1=bcsub( $number_1, $data['number_commission_to_cloud_warehouse'], 2);
|
|
||||||
}
|
}
|
||||||
|
$financialType = ['refund_order', 'supply_chain_refund', 'commission_to_promoter_refund', 'commission_to_store_refund', 'auto_margin'];
|
||||||
//退回收入 refund_order + 退回佣金
|
[$data['count'], $data['number']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
||||||
$number_2 = bcadd(bcadd($data['number_refund'], $data['number_coupon'], 2), $data['number_svipcoupon'], 2);
|
$data['number'] = bcsub($data['number'], 0, 2);
|
||||||
$data['count'] =$data['count_supply_chain']+ $data['count_brokerage'] + $data['count_refund'] + $data['count_order_charge'] + $data['count_refund_brokerage'] + $data['count_svipcoupon'] + $data['count_auto_margin']-$data['count_charge'];
|
|
||||||
$data['number'] = bcadd(bcadd($number3,bcadd($number_2, $number, 2),2), $number_1, 2);
|
|
||||||
|
|
||||||
} else { //平台的
|
} else { //平台的
|
||||||
// 退回 订单实际获得金额
|
// 退回 订单实际获得金额
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user