修复:文创豆兑换商品 需要的文创豆计算错误
修复:商品实际支付价格为0 文创豆及基金计算错误 修复:文创豆易出未判断持有数量 导致超出持有数量的文创豆也可以易出
This commit is contained in:
parent
869c82b06c
commit
76c08a9509
|
|
@ -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){
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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']
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);//易出部分比例
|
||||
|
|
|
|||
|
|
@ -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'],
|
||||
|
|
|
|||
Loading…
Reference in New Issue