爆币后台接口开发提交
This commit is contained in:
@@ -860,7 +860,7 @@ class BlindBox extends adminApi
|
||||
}
|
||||
if($user_id){
|
||||
$user_id = db::name('user')->where('user_code', $user_id)->value('id');
|
||||
$where['b.user_id'] = $user_id;
|
||||
$where['a.user_id'] = $user_id;
|
||||
}
|
||||
if($periods){
|
||||
$where['b.periods'] = $periods;
|
||||
@@ -871,7 +871,7 @@ class BlindBox extends adminApi
|
||||
->where($where)->count();
|
||||
$lists_data = db::name('vs_room_pan_xlh_log')->alias('a')
|
||||
->join('vs_room_pan_xlh b', 'a.xlh_id = b.id')
|
||||
->field('a.id,b.periods as periods,a.user_id,a.createtime,b.user_id,b.room_id,b.gift_id,b.num,a.is_send,b.pay_price,b.locking_gift_id')
|
||||
->field('a.id,b.periods as periods,a.user_id,a.createtime,b.room_id,b.gift_id,b.num,a.is_send,b.pay_price,b.locking_gift_id')
|
||||
->where($where)
|
||||
->page($page, $page_limit)
|
||||
->order("id desc")
|
||||
@@ -902,7 +902,9 @@ class BlindBox extends adminApi
|
||||
$today = strtotime(date('Y-m-d'));
|
||||
$locking_num = db::name('vs_room_pan_xlh_log')->alias('a')
|
||||
->join('vs_room_pan_xlh b', 'a.xlh_id = b.id')
|
||||
->where('a.createtime','>=',$today)->where(['a.is_send'=>1,'b.room_id'=>$room_id])->sum('a.num');
|
||||
->where('a.createtime','>=',$today)->where(['a.is_send'=>1])
|
||||
->where($where)
|
||||
->sum('a.num');
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
|
||||
@@ -99,6 +99,7 @@ class Gift extends adminApi
|
||||
$lists[$key]['is_can_buy'] = $value['is_can_buy'];
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
$lists[$key]['updatetime'] = date('Y-m-d H:i:s', $value['updatetime']);
|
||||
$lists[$key]['icon'] = $value['icon']??"";
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
@@ -126,6 +127,7 @@ class Gift extends adminApi
|
||||
$is_can_buy = input('is_can_buy', 1);
|
||||
$is_show = input('is_show', 1);
|
||||
$sort = input('sort', 0);
|
||||
$icon = input('icon', '');
|
||||
if($gift_name==""){
|
||||
return V(0,"礼物名称不能为空");
|
||||
}
|
||||
@@ -156,7 +158,8 @@ class Gift extends adminApi
|
||||
'is_show' => $is_show,
|
||||
'sort' => $sort,
|
||||
'createtime' => time(),
|
||||
'updatetime' => time()
|
||||
'updatetime' => time(),
|
||||
'icon' => $icon,
|
||||
];
|
||||
$id = db::name($this->table)->insertGetId($data);
|
||||
if(!$id){
|
||||
@@ -196,6 +199,7 @@ class Gift extends adminApi
|
||||
$is_can_buy = input('is_can_buy', '');
|
||||
$is_show = input('is_show', '');
|
||||
$sort = input('sort', '');
|
||||
$icon = input('icon', '');
|
||||
if($gid == ''){
|
||||
return V(0,"ID不能为空");
|
||||
}
|
||||
@@ -245,6 +249,9 @@ class Gift extends adminApi
|
||||
if($is_show){
|
||||
$data['is_show'] = $is_show;
|
||||
}
|
||||
if($icon){
|
||||
$data['icon'] = $icon;
|
||||
}
|
||||
$result = db::name($this->table)->where(['gid'=>$gid])->update($data);
|
||||
if(!$result){
|
||||
return V(0,"修改失败,礼物内容无更改");
|
||||
|
||||
129
application/adminapi/controller/Lottery.php
Normal file
129
application/adminapi/controller/Lottery.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\adminApi;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Hook;
|
||||
use think\Session;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 等级管理
|
||||
* @internal
|
||||
*/
|
||||
class Lottery extends adminApi
|
||||
{
|
||||
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = [];
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
}
|
||||
/*
|
||||
* 配置列表
|
||||
*/
|
||||
public function config_list(){
|
||||
$list = db::name("bb_lottery_config")->order('sort desc')->select();
|
||||
$list_data = [];
|
||||
foreach ($list as $k=>$v){
|
||||
$list_data[$k]['id'] = $v['id'];
|
||||
$list_data[$k]['key'] = $v['key'];
|
||||
$list_data[$k]['value'] = $v['value'];
|
||||
$list_data[$k]['desc'] = $v['desc'];
|
||||
$list_data[$k]['sort'] = $v['sort'];
|
||||
}
|
||||
return V(1,"成功", $list_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* 配置设置
|
||||
*/
|
||||
public function config_set(){
|
||||
$params = $this->request->post();
|
||||
foreach ($params as $k=>$v){
|
||||
$data = [
|
||||
'value'=>$v,
|
||||
];
|
||||
db::name("bb_lottery_config")->where(['key'=>$k])->update($data);
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
|
||||
/*
|
||||
* 中奖记录
|
||||
*/
|
||||
public function record_list(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$stime = input('stime', '');
|
||||
$etime = input('etime', '');
|
||||
$where = [];
|
||||
if($stime!==""){
|
||||
$where['create_time'] = ['>=', strtotime($stime)];
|
||||
}
|
||||
if($etime!==""){
|
||||
$where['create_time'] = ['<=', strtotime($etime)];
|
||||
}
|
||||
if($stime!=="" && $etime!==""){
|
||||
$where['create_time'] = ['between', [strtotime($stime), strtotime($etime)]];
|
||||
}
|
||||
$count = db::name('bb_lottery_winner_record')->where($where)->count();
|
||||
$lists_data = db::name('bb_lottery_winner_record')->field('id,uid as user_id,prize_type,prize_amount,pool_amount,ratio,release_amount,status,create_time as createtime')->where($where)->page($page, $page_limit)->order("id desc")->select();
|
||||
foreach ($lists_data as $k=>$v){
|
||||
$user_info = db::name('user')->where(['id'=>$v['user_id']])->find();
|
||||
$lists_data[$k]['user_code'] = $user_info['user_code'];
|
||||
$lists_data[$k]['nickname'] = $user_info['user_code']."-".$user_info['nickname'];
|
||||
//奖项类型:1-小奖 2-大奖
|
||||
$lists_data[$k]['prize_type_str'] = $v['prize_type']==1?"小奖":"大奖";
|
||||
//状态:1-已发放 0-未发放'
|
||||
$lists_data[$k]['status_str'] = $v['status']==1?"已发放":"未发放";
|
||||
$lists_data[$k]['createtime'] = date("Y-m-d H:i:s", $v['createtime']);
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists_data,
|
||||
'total_data' => [
|
||||
]
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
|
||||
}
|
||||
/*
|
||||
* 实时统计
|
||||
*/
|
||||
public function realtime_statistics(){
|
||||
$bb_config = db::name('bb_lottery_config')->field('key,value')->select();
|
||||
$bb_config = array_column($bb_config, null, 'key');
|
||||
// 循环奖池进度
|
||||
//最新轮次
|
||||
$latest_times = db::name('bb_lottery_pool_flow')->where(['pool_type'=>1])->max('times');
|
||||
$pool_progress = db::name('bb_lottery_pool_flow')->where(['pool_type'=>1,'times'=>$latest_times])->count();//当前进度
|
||||
$pool_total_amount = db::name('bb_lottery_pool_flow')->where(['pool_type'=>1,'times'=>$latest_times,'type'=>1])->sum('amount');
|
||||
//获取配置表中奖池配置
|
||||
$pool_progress_str = $pool_progress."/".$bb_config['small_pool_trigger_times']['value']."(".$pool_total_amount."金币)";
|
||||
|
||||
//蓄水池当前金额
|
||||
$big_round = db::name('bb_lottery_pool_flow')->where(['pool_type'=>2])->max('times');
|
||||
$bigAddGold = Db::name('bb_lottery_pool_flow')
|
||||
->where(['pool_type' => 2, 'type' => 3, 'times' => $big_round])
|
||||
->sum('amount') ?: 0;
|
||||
//最近中奖用户
|
||||
$last_winner_user_id = db::name('bb_lottery_winner_record')->where(['status'=>1])->order('id desc')->find();
|
||||
$last_winner_user_info = db::name('user')->where(['id'=>$last_winner_user_id['uid']])->find();
|
||||
//平台累计收入
|
||||
$platform_total_income = db::name('bb_lottery_pool_flow')->where(['type'=>4])->sum('amount');
|
||||
$return_data=[
|
||||
'pool_progress' => $pool_progress_str,
|
||||
'pool_amount_now' => ($bigAddGold)."金币 (".(($bigAddGold)/$bb_config['big_pool_threshold']['value'])."%)",
|
||||
'last_winner_user' => "用户ID:".$last_winner_user_info['user_code']." 获得 ".$last_winner_user_id['prize_amount']." 金币 (".$last_winner_user_id['ratio']."%)",
|
||||
'platform_total_income' => $platform_total_income." 金币",
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
}
|
||||
@@ -1362,17 +1362,14 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
// 1001 => [2001 => 0.5],
|
||||
//测试数据
|
||||
// 20060 => [$selected_gift_id => 2],
|
||||
|
||||
// 在这里可以添加更多规则 【正式规则】
|
||||
21222 => [$selected_gift_id => 6],
|
||||
21259 => [$selected_gift_id => 6],
|
||||
21222 => [$selected_gift_id => 6],//10012
|
||||
21259 => [$selected_gift_id => 6],//10049
|
||||
];
|
||||
|
||||
// 如果没有指定用户或该用户没有特殊概率调整,则直接返回原数组
|
||||
if ($user_id <= 0 || !isset($probability_adjustments[$user_id])) {
|
||||
return $gifts;
|
||||
}
|
||||
|
||||
$adjusted_gifts = [];
|
||||
foreach ($gifts as $gift) {
|
||||
$adjusted_gift = $gift;
|
||||
@@ -1380,19 +1377,15 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
if (isset($probability_adjustments[$user_id][$gift['foreign_id']])) {
|
||||
// 降低该礼物的剩余数量权重(相当于降低被抽中的概率)
|
||||
$reduction_factor = $probability_adjustments[$user_id][$gift['foreign_id']];
|
||||
// $adjusted_gift['remaining_number'] = max(1, intval($gift['remaining_number'] * $reduction_factor));
|
||||
//从数组中随机取出一个数
|
||||
//概率数组
|
||||
$pros[0] = 1;
|
||||
for ($i = 1; $i <= $reduction_factor; $i++) {
|
||||
$pros[$i] = 0;
|
||||
// 使用更合理的概率降低方式
|
||||
// reduction_factor为6表示只有原来的1/6概率,即降低5/6概率
|
||||
if (mt_rand(1, $reduction_factor) != 1) {
|
||||
// 按概率移除此礼物(将其剩余数量设为0)
|
||||
$adjusted_gift['remaining_number'] = 0;
|
||||
}
|
||||
$prosandomKey = array_rand($pros);
|
||||
$adjusted_gift['remaining_number'] = $pros[$prosandomKey];
|
||||
}
|
||||
$adjusted_gifts[] = $adjusted_gift;
|
||||
}
|
||||
|
||||
return $adjusted_gifts;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class Gift extends Model
|
||||
// if($room_id){
|
||||
// $is_open_blind_box_turntable = Db::name('vs_room')->where(['id'=>$room_id])->value('is_open_blind_box_turntable');
|
||||
// }
|
||||
$list = $this->field('gid as gift_id,gift_name,base_image,gift_price')->where($map)->where($where)->order('sort asc, gift_price asc')->select();
|
||||
$list = $this->field('gid as gift_id,gift_name,base_image,gift_price,icon')->where($map)->where($where)->order('sort asc, gift_price asc')->select();
|
||||
if($label==2){
|
||||
$list_data = [];
|
||||
foreach ($list as &$v) {
|
||||
|
||||
Reference in New Issue
Block a user