From 88498212ff206e9d95fc18ec072f5216659604b7 Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Tue, 16 Jan 2024 17:24:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E8=B5=A0=E9=80=81?= =?UTF-8?q?=E7=9A=84=E9=A2=9D=E5=BA=A6=E6=A0=B9=E6=8D=AE=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E5=AF=B9=E5=BA=94=E5=80=8D=E7=8E=87=E7=9A=84?= =?UTF-8?q?=E5=A2=9E=E9=95=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/system/merchant/Merchant.php | 1 + .../exchangeQuota/OrderPaySuccessEvent.php | 22 ++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/app/controller/admin/system/merchant/Merchant.php b/app/controller/admin/system/merchant/Merchant.php index 7403f28..48ac84a 100644 --- a/app/controller/admin/system/merchant/Merchant.php +++ b/app/controller/admin/system/merchant/Merchant.php @@ -205,6 +205,7 @@ class Merchant extends BaseController 'sub_mchid', ['commission_switch',0], ['mer_integral_platform_rate',0], + ['mer_exchange_quota_multiple',0], ['avg_consumption',0], 'mer_label', ]); diff --git a/app/listener/exchangeQuota/OrderPaySuccessEvent.php b/app/listener/exchangeQuota/OrderPaySuccessEvent.php index dbe2835..e861e5a 100644 --- a/app/listener/exchangeQuota/OrderPaySuccessEvent.php +++ b/app/listener/exchangeQuota/OrderPaySuccessEvent.php @@ -6,6 +6,7 @@ use app\common\model\user\ExchangeIntegralRecord; use app\common\model\user\ExchangeQuota; use app\common\model\user\ExchangeQuotaRecord; use app\common\model\user\User; +use app\common\repositories\system\merchant\MerchantRepository; use think\facade\Log; class OrderPaySuccessEvent{ @@ -37,17 +38,28 @@ class OrderPaySuccessEvent{ // 获取用户当前持有 $userHoldInfo = ExchangeQuota::where('uid',$groupOrder->uid)->findOrEmpty(); if((int)$userHoldInfo->uid <= 0) $userHoldInfo->uid = $groupOrder->uid; + $exchangeQuotaMultiple = (int)systemConfig('exchange_quota_multiple'); // 循环处理单个商品 $insertData = []; foreach($groupOrder->orderList as $orderInfo){ foreach($orderInfo->orderProduct as $orderProductInfo){ - // 判断:商品是否开启赠送兑换额度 当前商品实际支付的金额=赠送的兑换额度 + // 判断:商品是否开启赠送兑换额度 赠送的兑换额度 = 当前商品实际支付的金额 * 倍数 if($orderProductInfo->product->is_give_quota == 1 && $orderProductInfo->product_price > 0){ + // 赠送数量计算 + $giveNum = (float)$orderProductInfo->product_price; + $merExchangeQuotaMultiple = (int)app()->make(MerchantRepository::class) + ->getSearch(['mer_id' => $orderInfo->mer_id]) + ->value('mer_exchange_quota_multiple'); + if($merExchangeQuotaMultiple > 0){ + $giveNum = (float)sprintf("%2.f",$giveNum * $merExchangeQuotaMultiple); + }else if($exchangeQuotaMultiple > 0) { + $giveNum = (float)sprintf("%2.f",$giveNum * $exchangeQuotaMultiple); + } // 赠送 $changeFront = (float)$userHoldInfo->surplus_quota; - $userHoldInfo->total_quota += (float)$orderProductInfo->product_price;// 总额度 - $userHoldInfo->surplus_quota += (float)$orderProductInfo->product_price;// 剩余额度 - $userHoldInfo->freeze_quota += (float)$orderProductInfo->product_price;// 冻结额度 + $userHoldInfo->total_quota += (float)$giveNum;// 总额度 + $userHoldInfo->surplus_quota += (float)$giveNum;// 剩余额度 + $userHoldInfo->freeze_quota += (float)$giveNum;// 冻结额度 // 记录 $insertData[] = [ 'uid' => $orderProductInfo->uid, @@ -55,7 +67,7 @@ class OrderPaySuccessEvent{ 'order_id' => $orderProductInfo->order_id, 'order_product_id' => $orderProductInfo->order_product_id, 'change_type' => 1, - 'change_quantity' => (float)$orderProductInfo->product_price, + 'change_quantity' => (float)$giveNum, 'change_front' => $changeFront, 'change_after' => (float)$userHoldInfo->surplus_quota, 'remark' => "购买商品赠送",