送礼失败 回滚

This commit is contained in:
2026-01-02 16:10:35 +08:00
parent 821ec4183f
commit 9539bc069e

View File

@@ -90,6 +90,7 @@ class GiveGift extends Model
//判断是否有足够的金币
$user_waller = db::name('user_wallet')->where(['user_id'=>$uid])->find();
if ($user_waller['coin'] < $all_gift_price) {
Db::rollback();
return ['code' => 0, 'msg' => '用户金币不足', 'data' => null];
}
//扣除用户金币并记录日志
@@ -109,9 +110,11 @@ class GiveGift extends Model
//背包礼物是否充足
$user_gift_pack = db::name('vs_user_gift_pack')->where(['user_id'=>$uid,'gid'=>$gid])->find();
if (empty($user_gift_pack)) {
Db::rollback();
return ['code' => 0, 'msg' => '用户背包礼物不足', 'data' => null];
}
if ($user_gift_pack['num'] < $num * count($toarray)) {
Db::rollback();
return ['code' => 0, 'msg' => '用户背包礼物不足', 'data' => null];
}
//扣除背包礼物并记录日志