From 79d92394ea2e27927949f4e9223975ff39dfb75a Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Thu, 1 Feb 2024 11:56:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B4=A2=E5=8A=A1=E6=B5=81?= =?UTF-8?q?=E6=B0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dao/store/consumption/CommissionDao.php | 26 +++++++++---------- .../merchant/FinancialRecordRepository.php | 8 ++++++ .../admin/system/merchant/FinancialRecord.php | 9 ++----- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/app/common/dao/store/consumption/CommissionDao.php b/app/common/dao/store/consumption/CommissionDao.php index 31d3ef75..b8fc3de1 100755 --- a/app/common/dao/store/consumption/CommissionDao.php +++ b/app/common/dao/store/consumption/CommissionDao.php @@ -27,6 +27,14 @@ class CommissionDao */ public function firstOrderCommission($order, $financeDao) { + $commission = bcmul($order['pay_price'], 0.01, 2); + if ($commission > 0 && $order['order_type'] == 1) { + // 订单为自提,且佣金大于0 + $financeDao->user = $order->user; + $financeDao->order = $order; + $financeDao->platformOut($commission, 'commission_to_store'); + app()->make(MerchantRepository::class)->addLockMoney($order['mer_id'], 'order', $order['order_id'], $commission); + } $consumption = StoreConsumption::where('status', 1)->where('type', StoreConsumption::TYPE_FIRST_ORDER_COMMISSION)->find(); if (empty($consumption)) { return $financeDao; @@ -36,14 +44,6 @@ class CommissionDao if (!$isFirstOrder) { return $financeDao; } - $commission = bcmul($order['pay_price'], 0.01, 2); - if ($commission > 0 && $order['order_type'] == 1) { - // 订单为自提,且佣金大于0 - $financeDao->user = $order->user; - $financeDao->order = $order; - $financeDao->platformOut($commission, 'first_order_commission'); - app()->make(MerchantRepository::class)->addLockMoney($order['mer_id'], 'order', $order['order_id'], $commission); - } // 给镇合伙人、村合伙人、小组服务团队、店铺分佣,仅直推 $promotionCode = User::where('uid', $order['uid'])->value('promotion_code'); if (!empty($promotionCode)) { @@ -54,7 +54,7 @@ class CommissionDao $commission = bcmul($order['pay_price'], 0.03, 2); $financeDao->user = $user; $financeDao->order = $order; - $financeDao->platformOut($commission, 'first_order_commission'); + $financeDao->platformOut($commission, 'commission_to_promoter'); app()->make(MerchantRepository::class)->addLockMoney($order['mer_id'], 'order', $order['order_id'], $commission); $redPack = bcmul($order['pay_price'], $consumption['config']['red_pack_rate'], 2); if ($redPack > 0) { @@ -97,7 +97,7 @@ class CommissionDao if ($commission > 0) { $financeDao->user = $user; $financeDao->order = $order; - $financialType = $user['type'] == 3 ? 'order_commission' : 'first_order_commission'; // TODO 配送员的佣金类型需要调整 + $financialType = $user['type'] == 4 ? 'commission_to_courier' : 'commission_to_promoter'; $financeDao->platformOut($commission, $financialType); $result[] = $user; } @@ -156,7 +156,7 @@ class CommissionDao { // 是否已经退过佣金 $refunded = FinancialRecord::where('order_id', $refundOrder->order['order_id']) - ->whereIn('financial_type', ['order_commission_refund', 'first_order_commission_refund']) + ->whereIn('financial_type', ['commission_to_store_refund', 'commission_to_courier_refund', 'commission_to_promoter_refund']) ->count(); if ($refunded > 0) { return; @@ -167,13 +167,13 @@ class CommissionDao // 订单为自提,且佣金大于0,下单的店铺退佣金 $financeDao->user = $refundOrder->order->user; $financeDao->order = $refundOrder->order; - $financeDao->platformIn($commission, 'first_order_commission_refund'); + $financeDao->platformIn($commission, 'commission_to_store_refund'); app()->make(MerchantRepository::class)->subLockMoney($refundOrder->order['mer_id'], 'order', $refundOrder->order['order_id'], $commission); } // 退佣金和红包 $financeRecord = FinancialRecord::where('order_id', $refundOrder->order['order_id']) - ->whereIn('financial_type', ['order_commission', 'first_order_commission']) + ->whereIn('financial_type', ['commission_to_store', 'commission_to_courier', 'commission_to_promoter']) ->field('user_id uid,user_info nickname')->select()->toArray(); if (empty($financeRecord)) { return; diff --git a/app/common/repositories/system/merchant/FinancialRecordRepository.php b/app/common/repositories/system/merchant/FinancialRecordRepository.php index 817ceeb3..44923f35 100755 --- a/app/common/repositories/system/merchant/FinancialRecordRepository.php +++ b/app/common/repositories/system/merchant/FinancialRecordRepository.php @@ -31,6 +31,14 @@ use think\facade\Db; */ class FinancialRecordRepository extends BaseRepository { + + public $commonFinancialType = [ + 'order', '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' + ]; + public function __construct(FinancialRecordDao $dao) { $this->dao = $dao; diff --git a/app/controller/admin/system/merchant/FinancialRecord.php b/app/controller/admin/system/merchant/FinancialRecord.php index a33ea9f2..c860bc65 100755 --- a/app/controller/admin/system/merchant/FinancialRecord.php +++ b/app/controller/admin/system/merchant/FinancialRecord.php @@ -37,14 +37,9 @@ class FinancialRecord extends BaseController $merId = $this->request->merId(); if ($merId) { $where['mer_id'] = $merId; - $where['financial_type'] = ['order', 'mer_accoubts', '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']; + $where['financial_type'] = array_merge($this->repository->commonFinancialType, ['mer_accoubts']); } else { - $where['financial_type'] = ['order', 'sys_accoubts', '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']; + $where['financial_type'] = array_merge($this->repository->commonFinancialType, ['sys_accoubts']); } return app('json')->success($this->repository->getList($where, $page, $limit)); }