From 477b252cf7fa7ea7892989814681c9cbc1e73b1d Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Sat, 3 Feb 2024 16:59:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=B9=B3=E5=8F=B0=E8=B4=A2?= =?UTF-8?q?=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 --- .../merchant/FinancialRecordRepository.php | 82 ++++++++++++------- 1 file changed, 52 insertions(+), 30 deletions(-) diff --git a/app/common/repositories/system/merchant/FinancialRecordRepository.php b/app/common/repositories/system/merchant/FinancialRecordRepository.php index aaf58a7f..00b01aa7 100755 --- a/app/common/repositories/system/merchant/FinancialRecordRepository.php +++ b/app/common/repositories/system/merchant/FinancialRecordRepository.php @@ -31,7 +31,7 @@ class FinancialRecordRepository extends BaseRepository { 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' ,'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' @@ -126,8 +126,13 @@ class FinancialRecordRepository extends BaseRepository //订单收入总金额 $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); + //供应链金额 + $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', ['refund_brokerage_two', 'refund_brokerage_one'])->sum('number'); @@ -191,6 +196,18 @@ class FinancialRecordRepository extends BaseRepository 'field' => '元', 'name' => '退款支出金额' ], + [ + 'className' => 'el-icon-s-goods', + 'count' => $supply, + 'field' => '元', + 'name' => '供应链成本' + ], + [ + 'className' => 'el-icon-s-order', + 'count' => $supplyRefund, + 'field' => '元', + 'name' => '供应链退款' + ], [ 'className' => 'el-icon-s-cooperation', 'count' => $brokerage, @@ -436,11 +453,15 @@ class FinancialRecordRepository extends BaseRepository 'number' => $expend['number'], 'count' => $expend['count'] . '笔', '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_charge'] . '元', $expend['count_charge'] . '笔'], ['优惠券补贴', $expend['number_coupon'] . '元', $expend['count_coupon'] . '笔'], ['会员优惠券补贴', $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'] = [ @@ -539,7 +560,12 @@ class FinancialRecordRepository extends BaseRepository */ 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){ switch ($merchant['type_id']) { case 16: @@ -692,36 +718,32 @@ class FinancialRecordRepository extends BaseRepository [$data['count'], $data['number']] = $this->dao->getDataByType($type, $where, $date, $financialType); $data['number'] = bcsub($data['number'], 0, 2); } else { //平台的 - // 退回 订单实际获得金额 - - $financialType = ['order_true', 'presell_true','auto_margin']; - [$data['count_order'], $data['number_order']] = $this->dao->getDataByType($type, $where, $date, $financialType); - - $financialType = ['commission_to_entry_merchant']; - [$data['count_merchant'], $data['number_merchant']] = $this->dao->getDataByType($type, $where, $date, $financialType); - $data['count_order']=bcsub($data['count_order'],$data['count_merchant']); - $data['number_order']=bcsub($data['number_order'],$data['number_merchant'], 2); - + // 退款订单 + [$data['count_refund'], $data['number_refund']] = $this->dao->getDataByType($type, $where, $date, ['order_refund']); + $total = $data['number_refund']; + // 供应链订单 + [$data['count_supply_chain'], $data['number_supply_chain']] = $this->dao->getDataByType($type, $where, $date, ['supply_chain']); + $total = bcadd($total, $data['number_supply_chain'], 2); + // 退保证金记录 + [$data['count_margin'], $data['number_margin']] = $this->dao->getDataByType($type, $where, $date, ['auto_margin_refund']); + $total = bcadd($total, $data['number_margin'], 2); //付给商户的优惠券抵扣金额 - $financialType = ['order_platform_coupon']; - [$data['count_coupon'], $data['number_coupon']] = $this->dao->getDataByType($type, $where, $date, $financialType); - + [$data['count_coupon'], $data['number_coupon']] = $this->dao->getDataByType($type, $where, $date, ['order_platform_coupon']); + $total = bcadd($total, $data['number_coupon'], 2); //付给商户的svip优惠券抵扣金额 - $financialType = ['order_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, ['order_svip_coupon']); + $total = bcadd($total, $data['number_svipcoupon'], 2); //付给服务团队和其他的佣金 - [$data['count_refund'], $data['number_refund']] = $this->dao->getDataByType($type, $where, $date, $refund); - [$data['count_commission'], $data['number_commission']] = $this->dao->getDataByType($type, $where, $date, $commission); + $financialType = ['commission_to_store', 'commission_to_courier', 'commission_to_promoter']; + [$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['number_brokerage']+=$data['number_commission']-$data['number_refund']; - - $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); + $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'] = $total; } return $data; }