From 6e6e9fb50632bc60bb06180fa5a6f9e664e83586 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Sat, 3 Feb 2024 15:31:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=95=86=E6=88=B7=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E8=B4=A2=E5=8A=A1=E8=B4=A6=E5=8D=95=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/merchant/FinancialRecordDao.php | 2 +- .../merchant/FinancialRecordRepository.php | 107 +++++------------- 2 files changed, 31 insertions(+), 78 deletions(-) diff --git a/app/common/dao/system/merchant/FinancialRecordDao.php b/app/common/dao/system/merchant/FinancialRecordDao.php index 48553016..06d3ece8 100755 --- a/app/common/dao/system/merchant/FinancialRecordDao.php +++ b/app/common/dao/system/merchant/FinancialRecordDao.php @@ -84,7 +84,7 @@ class FinancialRecordDao extends BaseDao }) ->when(isset($where['is_mer']) && $where['is_mer'] !== '', function ($query) use ($where) { 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{ $query->where('type','in',[1,2]); } diff --git a/app/common/repositories/system/merchant/FinancialRecordRepository.php b/app/common/repositories/system/merchant/FinancialRecordRepository.php index 938957ac..aaf58a7f 100755 --- a/app/common/repositories/system/merchant/FinancialRecordRepository.php +++ b/app/common/repositories/system/merchant/FinancialRecordRepository.php @@ -56,6 +56,11 @@ class FinancialRecordRepository extends BaseRepository $query = $this->dao->search($where)->order('create_time DESC'); $count = $query->count(); $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'); } @@ -266,7 +271,7 @@ class FinancialRecordRepository extends BaseRepository 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_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); //退款支出金额 - $refund_order = $this->dao->search($where)->where('financial_type', 'refund_order')->sum('number'); - //佣金支出金额 - $_brokerage = $this->dao->search($where)->where('financial_type', 'in', ['brokerage_one', 'brokerage_two'])->sum('number'); - $refund_brokerage = $this->dao->search($where)->where('financial_type', 'in', ['refund_brokerage_one', 'refund_brokerage_two'])->sum('number'); - $brokerage = bcsub($_brokerage, $refund_brokerage, 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); + $refund_order = $this->dao->search($where)->where('financial_type', 'in', ['refund_order', 'supply_chain_refund'])->sum('number'); + //平台佣金 + $commission = $this->dao->search($where)->whereIn('financial_type', ['commission_to_store', 'commission_to_promoter'])->sum('number'); + $commissionRefund = $this->dao->search($where)->whereIn('financial_type', ['commission_to_store_refund', 'commission_to_promoter_refund'])->sum('number'); + $commission = bcsub($commission, $commissionRefund, 2); //商户可提现金额 // $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']); $stat = [ [ 'className' => 'el-icon-s-goods', - 'count' => $count, + 'count' => bcsub($count, 0, 2), 'field' => '元', 'name' => '商户收入' ], @@ -312,27 +313,15 @@ class FinancialRecordRepository extends BaseRepository ], [ 'className' => 'el-icon-s-cooperation', - 'count' => $refund_order, + 'count' => bcsub($refund_order, 0, 2), 'field' => '元', 'name' => '退款支出' ], - [ - 'className' => 'el-icon-s-finance', - 'count' => $brokerage, - 'field' => '元', - 'name' => '佣金支出' - ], [ 'className' => 'el-icon-s-cooperation', - 'count' => $charge, + 'count' => $commission, 'field' => '元', - 'name' => '平台手续费' - ], - [ - 'className' => 'el-icon-s-cooperation', - 'count' => $coupon, - 'field' => '元', - 'name' => '平台优惠券补贴' + 'name' => '平台佣金' ], [ 'className' => 'el-icon-s-cooperation', @@ -483,11 +472,12 @@ class FinancialRecordRepository extends BaseRepository $data['date'] = $date; $data['income'] = [ - 'title' => '订单收入总金额', + 'title' => '收入总金额', 'number' => $income['number'], 'count' => $income['count'] . '笔', 'data' => [ ['订单支付', $income['number_order'] . '元', $income['count_order'] . '笔'], + ['平台佣金', $income['number_commission'] . '元', $income['count_commission'] . '笔'], ['优惠券补贴', $income['number_coupon'] . '元', $income['count_coupon'] . '笔'], ['会员优惠券补贴', $income['number_svipcoupon'] . '元', $income['count_svipcoupon'] . '笔'], ] @@ -497,16 +487,10 @@ class FinancialRecordRepository extends BaseRepository 'number' => $expend['number'], 'count' => $expend['count'] . '笔', 'data' => [ - [ - '平台手续费', - bcsub($expend['number_order_charge'], $expend['number_charge'], 2). '元', - bcsub($expend['count_order_charge'], $expend['count_charge']). '笔', - ], [ '店铺押金', $expend['number_auto_margin'] . '元', $expend['count_auto_margin'] . '笔' - ], [ '自动下单市供应链', @@ -555,7 +539,7 @@ class FinancialRecordRepository extends BaseRepository */ 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){ switch ($merchant['type_id']) { case 16: @@ -600,9 +584,11 @@ class FinancialRecordRepository extends BaseRepository $financialType = ['refund_svip_coupon']; } [$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['number'] = bcadd($data['number_coupon'], $data['number_order'], 2); + $data['number'] = bcadd($data['number'], $data['number_commission'], 2); return $data; } @@ -685,59 +671,26 @@ class FinancialRecordRepository extends BaseRepository } if ($where['is_mer']) { //商户的 //退回收入 - $financialType = ['refund_order']; + $financialType = ['supply_chain_refund']; [$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']] = $this->dao->getDataByType($type, $where, $date, $financialType); - - //转给市级供应链 - $financialType = ['supply_chain']; - [$data['count_supply_chain'], $data['number_supply_chain']] = $this->dao->getDataByType($type, $where, $date, $financialType); + [$data['count_order_charge'], $data['number_order_charge']] = [0, 0]; + [$data['count_supply_chain'], $data['number_supply_chain']] = [0, 0]; //商户押金 $financialType = ['auto_margin']; [$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']] = $this->dao->getDataByType($type, $where, $date, $financialType); - + [$data['count_refund_brokerage'], $data['number_refund_brokerage']] = [0, 0]; //退回给平台的优惠券金额 - $financialType = ['refund_platform_coupon']; - [$data['count_coupon'], $data['number_coupon']] = $this->dao->getDataByType($type, $where, $date, $financialType); + [$data['count_coupon'], $data['number_coupon']] = [0, 0]; //退回给平台的会员优惠券金额 - $financialType = ['refund_svip_coupon']; - [$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); + [$data['count_svipcoupon'], $data['number_svipcoupon']] = [0, 0]; if($data['number_supply_chain']>0){ - $financialType = ['commission_to_cloud_warehouse']; - [$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); + [$data['count_commission_to_cloud_warehouse'], $data['number_commission_to_cloud_warehouse']] = [0, 0]; } - - //退回收入 refund_order + 退回佣金 - $number_2 = bcadd(bcadd($data['number_refund'], $data['number_coupon'], 2), $data['number_svipcoupon'], 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); - + $financialType = ['refund_order', 'supply_chain_refund', 'commission_to_promoter_refund', 'commission_to_store_refund', 'auto_margin']; + [$data['count'], $data['number']] = $this->dao->getDataByType($type, $where, $date, $financialType); + $data['number'] = bcsub($data['number'], 0, 2); } else { //平台的 // 退回 订单实际获得金额