diff --git a/app/common/repositories/system/merchant/FinancialRecordRepository.php b/app/common/repositories/system/merchant/FinancialRecordRepository.php index 0c1337e4..7ee71b7a 100644 --- a/app/common/repositories/system/merchant/FinancialRecordRepository.php +++ b/app/common/repositories/system/merchant/FinancialRecordRepository.php @@ -515,8 +515,14 @@ class FinancialRecordRepository extends BaseRepository $financialType = array_merge($financialType, $financialType1); } - [$data['count_order'], $data['number_order']] = $this->dao->getDataByType($type, $where, $date, $financialType); + if (!empty($financialType1)){ + $financialType1[0]=$financialType1[0].'_refund'; + [$data['count_refund'], $data['number_refund']] = $this->dao->getDataByType($type, $where, $date, $financialType1); + $data['count_order']-=$data['count_refund']; + $data['number_order']-=$data['number_refund']; + } + if ($where['is_mer']) { $financialType = ['order_platform_coupon']; } else { @@ -640,15 +646,17 @@ class FinancialRecordRepository extends BaseRepository $financialType = ['refund_svip_coupon']; [$data['count_svipcoupon'], $data['number_svipcoupon']] = $this->dao->getDataByType($type, $where, $date, $financialType); - if (!empty($financialType1)){ - [$data['count_commission'], $data['number_commission']] = $this->dao->getDataByType($type, $where, $date, $financialType1); - $data['count_brokerage']+=$data['count_commission']; - $data['number_brokerage']+=$data['number_commission']; - } +// 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'], 3); - //平台手续费 =( order_charge + 预售手续费 presell_charge - 平台退给商户的手续费 refund_charge ) $number_1 = bcsub($data['number_order_charge'], $data['number_charge'], 3); diff --git a/app/controller/admin/system/merchant/FinancialRecord.php b/app/controller/admin/system/merchant/FinancialRecord.php index 0832ec74..a33ea9f2 100644 --- a/app/controller/admin/system/merchant/FinancialRecord.php +++ b/app/controller/admin/system/merchant/FinancialRecord.php @@ -141,7 +141,12 @@ class FinancialRecord extends BaseController $where['date'] = empty($date) ? date('Y-m-d',time()) : $date ; $where['type'] = $type; $where['is_mer'] = $this->request->merId() ?? 0 ; - $data = app()->make(ExcelService::class)->exportFinancial($where,$page,$limit); + try { + $merchant = $this->request->merchant(); + }catch (\Exception $e){ + $merchant = []; + } + $data = app()->make(ExcelService::class)->exportFinancial($where,$page,$limit,$merchant); // app()->make(ExcelRepository::class)->create($where, $this->request->adminId(), 'exportFinancial',$where['is_mer']); return app('json')->success($data); } diff --git a/crmeb/services/ExcelService.php b/crmeb/services/ExcelService.php index 94556e6a..aff04c0d 100644 --- a/crmeb/services/ExcelService.php +++ b/crmeb/services/ExcelService.php @@ -317,7 +317,7 @@ class ExcelService * @author Qinii * @day 3/25/21 */ - public function exportFinancial(array $where,int $page, int $limit) + public function exportFinancial(array $where,int $page, int $limit,$merchant=[]) { /* order 收入 公共 新订单 @@ -367,8 +367,9 @@ class ExcelService 'commission_to_entry_merchant_refund'=> '退回平台佣金', 'commission_to_cloud_warehouse_refund'=> '退回平台佣金', ]; - $sys_pm_1 = ['order','presell','order_charge','order_presell','presell_charge','refund_brokerage_one','refund_brokerage_two']; - $mer_pm_1 = ['order','presell','refund_charge','refund_brokerage_one','refund_brokerage_two','mer_presell','order_platform_coupon']; + $sys_pm_1 = ['order','presell','order_charge','order_presell','presell_charge','refund_brokerage_one','refund_brokerage_two','commission_to_platform']; + $mer_pm_1 = ['order','presell','refund_charge','refund_brokerage_one','refund_brokerage_two','mer_presell', + 'order_platform_coupon','commission_to_cloud_warehouse','commission_to_entry_merchant','commission_to_town','commission_to_village','commission_to_service_team']; $date_ = $where['date'];unset($where['date']); $make = app()->make(FinancialRecordRepository::class); @@ -387,10 +388,10 @@ class ExcelService } + $income = $make->countIncome($where['type'],$where,$date_,$merchant); + $expend = $make->countExpend($where['type'],$where,$date_,$merchant); - $income = $make->countIncome($where['type'],$where,$date_); - $expend = $make->countExpend($where['type'],$where,$date_); - $refund = $make->countRefund($where['type'],$where,$date_); +// $refund = $make->countRefund($where['type'],$where,$date_); $charge = bcsub($income['number'],$expend['number'],2); $filename = $title_.'('.$date_.')'.time(); $export = [];