From 76c08a950912c42c94fa3d254d43ff7dbd1f0a64 Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Fri, 1 Dec 2023 10:17:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=96=87=E5=88=9B?= =?UTF-8?q?=E8=B1=86=E5=85=91=E6=8D=A2=E5=95=86=E5=93=81=20=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E7=9A=84=E6=96=87=E5=88=9B=E8=B1=86=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E9=94=99=E8=AF=AF=20=E4=BF=AE=E5=A4=8D=EF=BC=9A=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=AE=9E=E9=99=85=E6=94=AF=E4=BB=98=E4=BB=B7=E6=A0=BC?= =?UTF-8?q?=E4=B8=BA0=20=20=E6=96=87=E5=88=9B=E8=B1=86=E5=8F=8A=E5=9F=BA?= =?UTF-8?q?=E9=87=91=E8=AE=A1=E7=AE=97=E9=94=99=E8=AF=AF=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=EF=BC=9A=E6=96=87=E5=88=9B=E8=B1=86=E6=98=93=E5=87=BA?= =?UTF-8?q?=E6=9C=AA=E5=88=A4=E6=96=AD=E6=8C=81=E6=9C=89=E6=95=B0=E9=87=8F?= =?UTF-8?q?=20=E5=AF=BC=E8=87=B4=E8=B6=85=E5=87=BA=E6=8C=81=E6=9C=89?= =?UTF-8?q?=E6=95=B0=E9=87=8F=E7=9A=84=E6=96=87=E5=88=9B=E8=B1=86=E4=B9=9F?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E6=98=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../orderGoods/models/PreOrderGoods.php | 2 +- .../price/option/BaseOrderGoodsPrice.php | 2 +- .../src/api/IndexController.php | 5 +-- .../src/models/CulturalSpace.php | 33 +++++++++++-------- .../models/CulturalSpaceLegumesWithdrawal.php | 4 +++ .../src/models/GoodsCulturalSpace.php | 6 ++-- 6 files changed, 32 insertions(+), 20 deletions(-) diff --git a/app/common/modules/orderGoods/models/PreOrderGoods.php b/app/common/modules/orderGoods/models/PreOrderGoods.php index 8cab962c..1c7ba074 100644 --- a/app/common/modules/orderGoods/models/PreOrderGoods.php +++ b/app/common/modules/orderGoods/models/PreOrderGoods.php @@ -172,7 +172,7 @@ class PreOrderGoods extends OrderGoods $current_fee = CulturalFund::uniacid()->value('current_fee'); $this->legumes_rate = $current_fee; $this->legumes_exchange_price = $legumes_exchange_price; - $this->use_legumes_exchange = (float)sprintf("%.2f",$legumes_exchange_price * $current_fee); + $this->use_legumes_exchange = (float)ceil(sprintf("%.2f",$legumes_exchange_price / $current_fee)); } // 判断:当前商品是否存在积分商品设置 /*if((int)$this->pointGoods->id > 0){ diff --git a/app/frontend/modules/orderGoods/price/option/BaseOrderGoodsPrice.php b/app/frontend/modules/orderGoods/price/option/BaseOrderGoodsPrice.php index 2738e2e2..d4b931bf 100644 --- a/app/frontend/modules/orderGoods/price/option/BaseOrderGoodsPrice.php +++ b/app/frontend/modules/orderGoods/price/option/BaseOrderGoodsPrice.php @@ -114,7 +114,7 @@ abstract class BaseOrderGoodsPrice extends OrderGoodsPrice $current_fee = CulturalFund::uniacid()->value('current_fee'); $this->legumes_rate = $current_fee; $this->legumes_exchange_price = $legumes_exchange_price; - $this->use_legumes_exchange = (float)sprintf("%.2f",$legumes_exchange_price * $current_fee); + $this->use_legumes_exchange = (float)ceil(sprintf("%.2f",$legumes_exchange_price / $current_fee)); return $this->use_legumes_exchange; } diff --git a/plugins/cultural-space/src/api/IndexController.php b/plugins/cultural-space/src/api/IndexController.php index 979067e2..2bc2e294 100644 --- a/plugins/cultural-space/src/api/IndexController.php +++ b/plugins/cultural-space/src/api/IndexController.php @@ -230,13 +230,14 @@ class IndexController extends ApiController{ */ public function legumesHold(){ $uid = \YunShop::app()->getMemberId(); - $voucher_number = sprintf("%.6f",CulturalSpace::uniacid()->where('uid',$uid)->value('voucher_number')); + $culturalSpaceInfo = CulturalSpace::uniacid()->where('uid',$uid)->first(); $set = Setting::get('plugin.cultural_space_set'); $withdrawalCommissionRate = 20;//提现手续费比例 return $this->successJson('success',[ - 'voucher_number' => $voucher_number, + 'voucher_number' => $culturalSpaceInfo->voucher_number, + 'goods_legumes' => $culturalSpaceInfo->goods_legumes, 'commission_rate' => $withdrawalCommissionRate, 'task_video_link' => $set['task_video_link'] ]); diff --git a/plugins/cultural-space/src/models/CulturalSpace.php b/plugins/cultural-space/src/models/CulturalSpace.php index 4e5fd914..34b43589 100644 --- a/plugins/cultural-space/src/models/CulturalSpace.php +++ b/plugins/cultural-space/src/models/CulturalSpace.php @@ -177,6 +177,7 @@ class CulturalSpace extends BaseModel $user_voucher_number = 0;//用户凭证数量 $user_voucher_total = 0;//用户总计凭证数量 foreach ($orderGoodsList as $goodsInfo) { + if($goodsInfo['payment_amount'] <= 0) continue; $user_voucher_number = (($goodsInfo['payment_amount'] * $set['user_fund_ratio']) / 100) / $current_fee; //赠送数量 $user_fund_money = round(($goodsInfo['payment_amount'] * $set['order_fund_ratio']) / 100, 2);//资金数量 $fund_money += $user_fund_money; @@ -196,21 +197,25 @@ class CulturalSpace extends BaseModel ]; CulturalOrderFundLog::InsertLog($data_log); //写入日记 } - $this->where('uid', $uid)->increment('voucher_number', $user_voucher_total);//用户增量 - $next_fee = round($fund_money / $voucher_number, 2); - $FundData = [ - 'last_fee' => $last_fee, - 'current_fee' => $next_fee, - 'fund_money' => $fund_money, - 'voucher_number' => $voucher_number, - 'history_number' => $history_number, - 'history_fund_money' => $history_fund_money, - ]; - $culturalFund = new CulturalFund(); - $culturalFund->SaveData($FundData); - if ($user_voucher_number <= $set['min_number']) { - $this->capitalIncrease($set);//小于数量增加积分倍数 + + if($user_voucher_number > 0){ + $this->where('uid', $uid)->increment('voucher_number', $user_voucher_total);//用户增量 + $next_fee = round($fund_money / $voucher_number, 2); + $FundData = [ + 'last_fee' => $last_fee, + 'current_fee' => $next_fee, + 'fund_money' => $fund_money, + 'voucher_number' => $voucher_number, + 'history_number' => $history_number, + 'history_fund_money' => $history_fund_money, + ]; + $culturalFund = new CulturalFund(); + $culturalFund->SaveData($FundData); + if ($user_voucher_number <= $set['min_number']) { + $this->capitalIncrease($set);//小于数量增加积分倍数 + } } + // 获取文创空间用户信息 // 数据操作 DB::commit(); diff --git a/plugins/cultural-space/src/models/CulturalSpaceLegumesWithdrawal.php b/plugins/cultural-space/src/models/CulturalSpaceLegumesWithdrawal.php index e51e79ad..184b412b 100644 --- a/plugins/cultural-space/src/models/CulturalSpaceLegumesWithdrawal.php +++ b/plugins/cultural-space/src/models/CulturalSpaceLegumesWithdrawal.php @@ -5,6 +5,7 @@ namespace Yunshop\CulturalSpace\models; use app\common\facades\Setting; use app\common\models\BaseModel; use app\common\models\Member; +use Exception; use Yunshop\UseStaff\models\UseStaff; class CulturalSpaceLegumesWithdrawal extends BaseModel{ @@ -74,6 +75,9 @@ class CulturalSpaceLegumesWithdrawal extends BaseModel{ $uid = \YunShop::app()->getMemberId(); // 获取设置信息 $set = Setting::get('plugin.cultural_space_set'); + // 判断:持有数量是否充足 + $holdNum = CulturalSpace::uniacid()->where('uid',$uid)->value('voucher_number'); + if($holdNum < $totalNum) throw new Exception('持有数量不足!'); // 获取各个部分的比例 $fundRatio = (float)$set['legumes_fund_ratio'];// 基金池部分比例 $withdrawalRatio = (float)sprintf("%.2f",100 - $fundRatio);//易出部分比例 diff --git a/plugins/cultural-space/src/models/GoodsCulturalSpace.php b/plugins/cultural-space/src/models/GoodsCulturalSpace.php index f9d7d2e7..9ee58233 100644 --- a/plugins/cultural-space/src/models/GoodsCulturalSpace.php +++ b/plugins/cultural-space/src/models/GoodsCulturalSpace.php @@ -74,11 +74,13 @@ class GoodsCulturalSpace extends BaseModel{ 'last_page' => (int)$result['last_page'], ]; // 计算需要使用的文创豆 - $currentFee = (float)CulturalFund::uniacid()->value('current_fee');// 当前费率 + $fundInfo = CulturalFund::getfund(); + $currentFee = $fundInfo['current_fee']; $holdExchangeLegumes = (float)CulturalSpace::uniacid()->where('uid',$uid)->value('goods_legumes');// 当前用户持有的用以兑换商品的文创豆 $data['data'] = array_map(function($item) use ($currentFee,$holdExchangeLegumes){ // 使用的文创豆 - $useLegumes = ceil($item['legumes_exchange_price'] * $currentFee); + $useLegumes = ceil($item['legumes_exchange_price'] / $currentFee); + $useLegumes = $useLegumes <= 1 ? 1 : $useLegumes; return [ 'id' => $item['id'], 'goods_id' => $item['goods_id'],