巡乐会抽奖接口提交.-bug修改

This commit is contained in:
2025-09-09 14:27:59 +08:00
parent 1d20d608e1
commit 0aecadd263

View File

@@ -503,8 +503,9 @@ class BlindBoxTurntableGift extends Model
$bag_data = db::name("vs_gift_bag")->field('id,name,ext,periods')->where('id',$gift_bag_id)->find();
$ext = json_decode($bag_data['ext'],true);
//判断是否有足够的金币
$bag_gift_price = $ext['xlh_box_price'] * $num;
$user_waller = db::name('user_wallet')->where(['user_id'=>$user_id])->find();
if ($user_waller['coin'] < $ext['xlh_box_price'] * $num) {
if ($user_waller['coin'] < $bag_gift_price) {
return ['code' => 0, 'msg' => '用户金币不足', 'data' => null];
}
$room = db::name('vs_room')->where(['id'=>$room_id])->find();
@@ -529,6 +530,21 @@ class BlindBoxTurntableGift extends Model
db::startTrans();
try{
//扣除抽奖消耗的金币
//扣除用户金币并记录日志
$wallet_update = model('GiveGift')->change_user_cion_or_earnings_log($user_id,$bag_gift_price,$room_id,1,10,'巡乐会抽奖消耗');
if(!$wallet_update){
Db::rollback();
return ['code' => 0, 'msg' => '扣除用户金币失败', 'data' => null];
}
//用户财富等级更新
$user_level = model('Level')->user_level_data_update($user_id,$bag_gift_price,1,$room_id);
if(!$user_level){
Db::rollback();
return ['code' => 0, 'msg' => '用户等级更新失败', 'data' => null];
}
//开始抽奖
for($i = 0; $i < $num; $i++){
//本期当前第多少次后抽奖 总的抽奖次数- 剩余数量
$room_pan = db::name("vs_room_pan")->where(['room_id'=>$room_id,'gift_bag_id'=>$gift_bag_id])->field('remaining_number,periods')->find();