爆币
This commit is contained in:
@@ -4,6 +4,8 @@ namespace app\api\model;
|
||||
|
||||
use app\common\controller\Push;
|
||||
use app\common\service\LotteryService;
|
||||
use app\common\service\LotteryService5;
|
||||
use app\common\service\LotteryService10;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
use think\Log;
|
||||
@@ -15,7 +17,7 @@ class Lottery extends Model
|
||||
* 送礼参与抽奖接口
|
||||
* @return json
|
||||
*/
|
||||
public function gift($send_uid, $recv_uid,$gift_id, $room_id, $num)
|
||||
public function gift($send_uid, $recv_uid, $gift_id, $room_id, $num, $pool_gift_ids)
|
||||
{
|
||||
if (ceil($num) != $num) {
|
||||
return ['code' => 0, 'msg' => '打赏礼物数量必须为整数', 'data' => null];
|
||||
@@ -65,6 +67,18 @@ class Lottery extends Model
|
||||
$lucky_rate = db::name('bb_lottery_config')->where(['key' => 'lucky_rate'])->value('value');
|
||||
$recv_coin = round($gift_price * $lucky_rate / 100, 2);
|
||||
$small_pool = $gift_price - $recv_coin;
|
||||
|
||||
if($gift_id == $pool_gift_ids['pool_gift_id_5']){
|
||||
$table = 'bb_lottery_gift_record_5';
|
||||
$poole_type = 5;
|
||||
}elseif ($gift_id == $pool_gift_ids['pool_gift_id_10']){
|
||||
$table = 'bb_lottery_gift_record_10';
|
||||
$poole_type = 10;
|
||||
}else{
|
||||
$table = 'bb_lottery_gift_record';
|
||||
$poole_type = 1;
|
||||
}
|
||||
|
||||
foreach ($toarray as $k => $to_id){
|
||||
// 1. 记录礼物赠送
|
||||
$giftRecord = [
|
||||
@@ -77,7 +91,7 @@ class Lottery extends Model
|
||||
'create_time' => time(),
|
||||
'remark' => '幸运币收益率'.$lucky_rate.'%'
|
||||
];
|
||||
$giftId = Db::name('bb_lottery_gift_record')->insertGetId($giftRecord);
|
||||
$giftId = Db::name($table)->insertGetId($giftRecord);
|
||||
|
||||
//收礼记录行为日志
|
||||
$give_gift = model('api/SendGift')->change_user_give_gift_logs($send_uid,$gift_id,$gift_price,$num,$to_id,2,1,0,'送幸运币');
|
||||
@@ -121,7 +135,7 @@ class Lottery extends Model
|
||||
|
||||
//计算爆币
|
||||
$nums = $num * count($toarray);
|
||||
$ress = $this->lottery($send_uid,$gift_info['gift_price'],$nums,$room_id,$gift_id,$FromUserInfo,$gift_info);
|
||||
$ress = $this->lottery($send_uid,$gift_info['gift_price'],$nums,$room_id,$gift_id,$FromUserInfo,$gift_info,$poole_type);
|
||||
if($ress['code'] == 0){
|
||||
return ['code' => 0, 'msg' => $ress['msg'], 'data' => null];
|
||||
}
|
||||
@@ -131,12 +145,19 @@ class Lottery extends Model
|
||||
|
||||
|
||||
//抽奖(不带大奖池)
|
||||
public function lottery($send_uid,$gift_price,$num,$room_id,$giftId,$fromUserInfo=null,$gift_info=null)
|
||||
public function lottery($send_uid,$gift_price,$num,$room_id,$giftId,$fromUserInfo=null,$gift_info=null,$poole_type = 1)
|
||||
{
|
||||
$small_prize_play_image = db::name('bb_lottery_config')->where(['key' => 'small_prize_play_image'])->value('value');
|
||||
try {
|
||||
$gift_gold = $gift_price;
|
||||
$service = new LotteryService();
|
||||
if($poole_type == 5){
|
||||
$service = new LotteryService5();
|
||||
}elseif ($poole_type == 10){
|
||||
$service = new LotteryService10();
|
||||
}else{
|
||||
$service = new LotteryService();
|
||||
}
|
||||
|
||||
for($i=0;$i<$num;$i++){
|
||||
$reslut = $service->handleGift($send_uid, $gift_gold, $giftId);
|
||||
if ($reslut['code'] == 1) {
|
||||
|
||||
Reference in New Issue
Block a user