Compare commits
172 Commits
580d204711
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
| 077a0e23e0 | |||
| b65b416e89 | |||
| 3d6d14d6a9 | |||
| e2fb2c4f05 | |||
| 3f30ee6062 | |||
| 0985204f1d | |||
| ee533bbe73 | |||
| 14f9ac26d4 | |||
| 41c6a1d51e | |||
| bdf072663a | |||
| 9600bd5103 | |||
| 5afeecdfc1 | |||
| 89d994554e | |||
| d3687c0565 | |||
| 5de94eb016 | |||
| 40a70c20e2 | |||
| 30b580f374 | |||
| 961e4c7788 | |||
| 4fd29220e9 | |||
| 41c849999a | |||
| 485d460c7b | |||
| 45fe36a98b | |||
| 47f0e0143c | |||
| 906517d103 | |||
| 8683aed1d9 | |||
| 38fb18899b | |||
| 9c1f2793c2 | |||
| 6a58f37a76 | |||
| b18517abf2 | |||
| 0f80219b71 | |||
| fed756efae | |||
| 54848b2864 | |||
| c839743f50 | |||
| 18c88570f0 | |||
| 14660c72be | |||
| 84dac71bd6 | |||
| f4a5b2ced8 | |||
| c7eece32d6 | |||
| d8f244caf0 | |||
| 8089ce8c6a | |||
| 612bb07bec | |||
| 8107d9961e | |||
| de2ec9ff87 | |||
| 742722544c | |||
| cbecd88a3a | |||
| f4fcfef729 | |||
| cee9802959 | |||
| 254aee03e8 | |||
| 1b0043743b | |||
| 46c07ac9e1 | |||
| 3d491faed5 | |||
| 51cb1ac2f4 | |||
| 4bcd069c85 | |||
| 66edc41718 | |||
| bf1b69b1cb | |||
| c2674ea33e | |||
| 15c8098b1f | |||
| 9ca9909e6f | |||
| fcca1cd794 | |||
| 4a5fc09ce4 | |||
| 1160d9f908 | |||
| 5f6c99538f | |||
| 8e4086b4ca | |||
| 765fafe218 | |||
| 14ea649634 | |||
| de6676895a | |||
| 2eeee057f8 | |||
| 466db48ac2 | |||
| e8894d95cf | |||
| aff3440e42 | |||
| fc368aeda4 | |||
| 841f19e551 | |||
| 8b12d46912 | |||
| a8725713aa | |||
| a6420812df | |||
| c26e96f3dd | |||
| 8b3d340456 | |||
| 9fbf23279b | |||
| 786295bc47 | |||
| 31181d74c7 | |||
| 7f82bb539e | |||
| 935ef9f998 | |||
| 5f5954da52 | |||
| d9eb6d01bf | |||
| 4a2fdadfdb | |||
| 7b990a5ecd | |||
| ac2c12c0c9 | |||
| f4da4ffae9 | |||
| 210a325688 | |||
| 3567e02642 | |||
| c7a70cb128 | |||
| 466d94fda4 | |||
| aedf9e1559 | |||
| fcff5c1da5 | |||
| 808a111853 | |||
| a38317a58c | |||
| 486f42bd5b | |||
| 02ce80b8ed | |||
| 1598df9824 | |||
| 2fc52ee53a | |||
| 67703d073f | |||
| ff65b56590 | |||
| f733aefd03 | |||
| 9dcec5fb27 | |||
| bda215d894 | |||
| f1570369bd | |||
| cf6ac7c0b1 | |||
| 853fb0b89e | |||
| fc60a58a9c | |||
| cbf3eaf788 | |||
| 7eeffdce65 | |||
| 07bf0d24f6 | |||
| b8b87401ce | |||
| a7964a0b43 | |||
| b4710619ff | |||
| 42e660d618 | |||
| 8b28b1c96e | |||
| 1212473b9e | |||
| 01cc7a87ed | |||
| f929f33867 | |||
| 232a447217 | |||
| eaddbdcd06 | |||
| 960eb2bb11 | |||
| 764cb6947b | |||
| 605cdb3197 | |||
| 8dda53e52e | |||
| b9bce3f2d6 | |||
| 7b11279d10 | |||
| 509a0cf78f | |||
| ec7f58b365 | |||
| 1325a5ad12 | |||
| 4974ea58b9 | |||
| 6af3558660 | |||
| 41f12df16c | |||
| f8fe14e11c | |||
| 5970783482 | |||
| f137d03073 | |||
| be987c25b5 | |||
| 68b0c3e102 | |||
| 5d05a35d89 | |||
| c15bd51d2a | |||
| 654f4b3281 | |||
| 83d2e9ff8d | |||
| 4c9393ed25 | |||
| e32a3fa46f | |||
| 71120548cb | |||
| 4d991bc6cd | |||
| 0b3159f22e | |||
| 67b2e8801a | |||
| 6252df348e | |||
| 41a2799e41 | |||
| d91252b4d0 | |||
| e2bce9f831 | |||
| 76bd5de916 | |||
| 10d86207ba | |||
| 62bd53e386 | |||
| 64db503c1f | |||
| d721c5290d | |||
| 4f6e40f4f6 | |||
| d2a7b6f4d8 | |||
| afbaafbb7c | |||
| b6297117a1 | |||
| b44227cebc | |||
| 84a2cdf67c | |||
| 0eb1d25bb3 | |||
| 743c4847ec | |||
| ebb8416d2a | |||
| fa0fd7c28b | |||
| 1b7ecc29d8 | |||
| d341107508 | |||
| 29db4c75e0 | |||
| c215815f28 |
@@ -675,23 +675,45 @@ class Activities extends adminApi
|
|||||||
$page_limit = input('page_limit', 30);
|
$page_limit = input('page_limit', 30);
|
||||||
$user_id = input('user_id', '');
|
$user_id = input('user_id', '');
|
||||||
$gift_bag_id = input('gift_bag_id', 1);
|
$gift_bag_id = input('gift_bag_id', 1);
|
||||||
|
$begin_time = input('begin_time', '');
|
||||||
|
$end_time = input('end_time', '');
|
||||||
$where = [];
|
$where = [];
|
||||||
if($user_id){
|
if($user_id){
|
||||||
$where['user_id'] = $user_id;
|
$where['a.user_id'] = $user_id;
|
||||||
}
|
}
|
||||||
if($gift_bag_id){
|
if($gift_bag_id){
|
||||||
$where['gift_bag_id'] = $gift_bag_id;
|
$where['a.gift_bag_id'] = $gift_bag_id;
|
||||||
|
}else{
|
||||||
|
$where['a.gift_bag_id'] = ['in', [1,2]];
|
||||||
}
|
}
|
||||||
$count = db::name('vs_gift_bag_receive_log')->where($where)->count();
|
if($begin_time){
|
||||||
$lists_data = db::name('vs_gift_bag_receive_log')->where($where)->page($page, $page_limit)->order("id desc")->select();
|
$where['a.createtime'] = ['>=', strtotime($begin_time)];
|
||||||
|
}
|
||||||
|
if($end_time){
|
||||||
|
$where['a.createtime'] = ['<=', strtotime($end_time)];
|
||||||
|
}
|
||||||
|
if($begin_time && $end_time){
|
||||||
|
$where['a.createtime'] = ['between', [strtotime($begin_time), strtotime($end_time)]];
|
||||||
|
}
|
||||||
|
$count = db::name('vs_gift_bag_receive_log')->alias('a')->where($where)->count();
|
||||||
|
$lists_data = db::name('vs_gift_bag_receive_log')
|
||||||
|
->alias('a')
|
||||||
|
->join('vs_gift_bag_detail b', 'a.parent_id=b.id')
|
||||||
|
->join('vs_gift c', 'a.gift_id=c.gid')
|
||||||
|
->field('a.*,b.name,b.type,b.quantity,b.foreign_id,c.gift_price,b.name')
|
||||||
|
->where($where)->page($page, $page_limit)->order("id desc")->select();
|
||||||
$lists = [];
|
$lists = [];
|
||||||
foreach ($lists_data as $key => $value) {
|
foreach ($lists_data as $key => $value) {
|
||||||
$gift_bag = db::name('vs_gift_bag')->where('id',$value['gift_bag_id'])->find();
|
$gift_bag = db::name('vs_gift_bag')->where('id',$value['gift_bag_id'])->find();
|
||||||
|
$user = db::name('user')->where('id',$value['user_id'])->find();
|
||||||
$lists[$key]['id'] = $value['id'];
|
$lists[$key]['id'] = $value['id'];
|
||||||
$lists[$key]['user_id'] = $value['user_id'];
|
$lists[$key]['user_id'] = $value['user_id'];
|
||||||
$lists[$key]['user_name'] = $value['user_id'].'-'.db::name('user')->where('id',$value['user_id'])->value('nickname');
|
$lists[$key]['user_name'] = $user['user_code'].'-'.$user['nickname'];
|
||||||
$lists[$key]['gift_bag_type'] = db::name('vs_gift_bag')->where('id',$value['gift_bag_id'])->value('name');
|
$lists[$key]['gift_bag_type'] = db::name('vs_gift_bag')->where('id',$value['gift_bag_id'])->value('name');
|
||||||
$lists[$key]['money'] = $gift_bag['money'];
|
$lists[$key]['money'] = $gift_bag['money'];
|
||||||
|
//礼物
|
||||||
|
$lists[$key]['gift'] = $value['name']."*".$value['quantity'];
|
||||||
|
$lists[$key]['gift_price'] = $value['gift_price'] * $value['quantity'];
|
||||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s',$value['createtime']);
|
$lists[$key]['createtime'] = date('Y-m-d H:i:s',$value['createtime']);
|
||||||
}
|
}
|
||||||
$return_data = [
|
$return_data = [
|
||||||
|
|||||||
@@ -188,9 +188,9 @@ class BlindBox extends adminApi
|
|||||||
if($type){
|
if($type){
|
||||||
$where['type'] = $type;
|
$where['type'] = $type;
|
||||||
}
|
}
|
||||||
if($label){
|
// if($label){
|
||||||
$where['label'] = $label;
|
// $where['label'] = $label;
|
||||||
}
|
// }
|
||||||
$list = db::name("vs_gift")->where($where)->order('sort','asc')->select();
|
$list = db::name("vs_gift")->where($where)->order('sort','asc')->select();
|
||||||
$list_data = [];
|
$list_data = [];
|
||||||
foreach ($list as $k=>$v){
|
foreach ($list as $k=>$v){
|
||||||
@@ -537,7 +537,7 @@ class BlindBox extends adminApi
|
|||||||
if($activities_id == ""){
|
if($activities_id == ""){
|
||||||
$activities_id = 4;
|
$activities_id = 4;
|
||||||
}
|
}
|
||||||
$bag_list = db::name("vs_gift_bag")->field('id,name')->where(['activities_id'=>$activities_id,'status'=>1])->select();
|
$bag_list = db::name("vs_gift_bag")->field('id,name')->where(['activities_id'=>$activities_id])->select();
|
||||||
return V(1,"成功", $bag_list);
|
return V(1,"成功", $bag_list);
|
||||||
}
|
}
|
||||||
//--------------------------盲盒转盘与巡乐会-------------------------------------------------------
|
//--------------------------盲盒转盘与巡乐会-------------------------------------------------------
|
||||||
|
|||||||
@@ -383,6 +383,9 @@ class Decorate extends adminApi
|
|||||||
}else{
|
}else{
|
||||||
$return_list[$k]['name'] = db::name('vs_decorate')->where(['did'=>$v['did']])->value('title');
|
$return_list[$k]['name'] = db::name('vs_decorate')->where(['did'=>$v['did']])->value('title');
|
||||||
}
|
}
|
||||||
|
if(in_array($v['type'],[12,13])){
|
||||||
|
$return_list[$k]['name'] = $return_list[$k]['name'] ." * ".$v['num']." 张";
|
||||||
|
}
|
||||||
$return_list[$k]['base_image'] = db::name('vs_decorate')->where(['did'=>$v['did']])->value('base_image');
|
$return_list[$k]['base_image'] = db::name('vs_decorate')->where(['did'=>$v['did']])->value('base_image');
|
||||||
$return_list[$k]['is_using'] = $v['is_using'];
|
$return_list[$k]['is_using'] = $v['is_using'];
|
||||||
$return_list[$k]['is_using_str'] = $v['is_using']==1?"使用中":"未使用";
|
$return_list[$k]['is_using_str'] = $v['is_using']==1?"使用中":"未使用";
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ class Guild extends adminApi
|
|||||||
$list[$k]['status_str'] = $v['status'] == 1 ? '正常' : '解散';
|
$list[$k]['status_str'] = $v['status'] == 1 ? '正常' : '解散';
|
||||||
$list[$k]['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
|
$list[$k]['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
|
||||||
$list[$k]['updatetime'] = date('Y-m-d H:i:s',$v['updatetime']);
|
$list[$k]['updatetime'] = date('Y-m-d H:i:s',$v['updatetime']);
|
||||||
|
$list[$k]['delete_time'] = $v['delete_time'] ? date('Y-m-d H:i:s',$v['delete_time']) : "无";
|
||||||
$list[$k]['user_id'] = $user['user_code']??"";
|
$list[$k]['user_id'] = $user['user_code']??"";
|
||||||
$list[$k]['intro'] = $v['intro'];
|
$list[$k]['intro'] = $v['intro'];
|
||||||
//幸运币流水
|
//幸运币流水
|
||||||
@@ -699,6 +700,11 @@ class Guild extends adminApi
|
|||||||
//更新公会人数
|
//更新公会人数
|
||||||
db('vs_guild')->where('id', $merge_guild_id)->setInc('num');
|
db('vs_guild')->where('id', $merge_guild_id)->setInc('num');
|
||||||
//拉用户进入工会群聊
|
//拉用户进入工会群聊
|
||||||
|
if($merge_guild_id<=95){
|
||||||
|
$merge_guild_id = "g".$merge_guild_id;
|
||||||
|
}else{
|
||||||
|
$merge_guild_id = $merge_guild_id;
|
||||||
|
}
|
||||||
$rid = 'g'.$merge_guild_id;
|
$rid = 'g'.$merge_guild_id;
|
||||||
$reslut = model('api/Tencent')->add_group_member($rid, $value['user_id']);
|
$reslut = model('api/Tencent')->add_group_member($rid, $value['user_id']);
|
||||||
}
|
}
|
||||||
@@ -708,6 +714,11 @@ class Guild extends adminApi
|
|||||||
return V(0,"失败");
|
return V(0,"失败");
|
||||||
}
|
}
|
||||||
//解散群
|
//解散群
|
||||||
|
if($guild_id<=95){
|
||||||
|
$guild_id = "g".$guild_id;
|
||||||
|
}else{
|
||||||
|
$guild_id = $guild_id;
|
||||||
|
}
|
||||||
model('api/Tencent')->delete_group('g'.$guild_id);
|
model('api/Tencent')->delete_group('g'.$guild_id);
|
||||||
db::commit();
|
db::commit();
|
||||||
return V(1,"成功");
|
return V(1,"成功");
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace app\adminapi\controller;
|
|||||||
|
|
||||||
use app\admin\model\AdminLog;
|
use app\admin\model\AdminLog;
|
||||||
use app\common\controller\adminApi;
|
use app\common\controller\adminApi;
|
||||||
|
use think\Cache;
|
||||||
use think\Config;
|
use think\Config;
|
||||||
use think\Db;
|
use think\Db;
|
||||||
use think\Hook;
|
use think\Hook;
|
||||||
@@ -16,18 +17,20 @@ use think\Validate;
|
|||||||
*/
|
*/
|
||||||
class Lottery extends adminApi
|
class Lottery extends adminApi
|
||||||
{
|
{
|
||||||
|
// Redis实例
|
||||||
|
private $redis;
|
||||||
protected $noNeedLogin = [];
|
protected $noNeedLogin = [];
|
||||||
protected $noNeedRight = [];
|
protected $noNeedRight = [];
|
||||||
public function _initialize()
|
public function _initialize()
|
||||||
{
|
{
|
||||||
parent::_initialize();
|
parent::_initialize();
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* 配置列表
|
* 配置列表
|
||||||
*/
|
*/
|
||||||
public function config_list(){
|
public function config_list(){
|
||||||
$list = db::name("bb_lottery_config")->order('sort desc')->select();
|
$list = db::name("bb_lottery_config")->where(['delete_time' => 0])->order('sort desc')->select();
|
||||||
$list_data = [];
|
$list_data = [];
|
||||||
foreach ($list as $k=>$v){
|
foreach ($list as $k=>$v){
|
||||||
$list_data[$k]['id'] = $v['id'];
|
$list_data[$k]['id'] = $v['id'];
|
||||||
@@ -43,13 +46,114 @@ class Lottery extends adminApi
|
|||||||
* 配置设置
|
* 配置设置
|
||||||
*/
|
*/
|
||||||
public function config_set(){
|
public function config_set(){
|
||||||
|
$bb_lottery_config = Db::name('bb_lottery_config')->column('value', 'key');
|
||||||
|
$small_pool_trigger_times = $bb_lottery_config['small_pool_trigger_times'];//初级开奖的累计次数
|
||||||
|
$lottery_rate = $bb_lottery_config['lottery_rate'];//初级最大爆币率
|
||||||
|
$small_pool_trigger_times_5 = $bb_lottery_config['small_pool_trigger_times_5'];//中级开奖的累计次数
|
||||||
|
$lottery_rate_5 = $bb_lottery_config['lottery_rate_5'];//中级最大爆币率
|
||||||
|
$small_pool_trigger_times_10 = $bb_lottery_config['small_pool_trigger_times_10'];//高级最大爆币率
|
||||||
|
$lottery_rate_10 = $bb_lottery_config['lottery_rate_10'];//高级最大爆币率
|
||||||
$params = $this->request->post();
|
$params = $this->request->post();
|
||||||
|
$small_type = 0;
|
||||||
|
$small_type_5 = 0;
|
||||||
|
$small_type_10 = 0;
|
||||||
|
|
||||||
foreach ($params as $k=>$v){
|
foreach ($params as $k=>$v){
|
||||||
$data = [
|
$data = [
|
||||||
'value'=>$v,
|
'value'=>$v,
|
||||||
];
|
];
|
||||||
db::name("bb_lottery_config")->where(['key'=>$k])->update($data);
|
db::name("bb_lottery_config")->where(['key'=>$k])->update($data);
|
||||||
|
|
||||||
|
if($k=='small_pool_trigger_times'){
|
||||||
|
if($v != $small_pool_trigger_times){
|
||||||
|
$small_type = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($k=='lottery_rate'){
|
||||||
|
if($v != $lottery_rate){
|
||||||
|
$small_type = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($k=='small_pool_trigger_times_5'){
|
||||||
|
if($v != $small_pool_trigger_times_5){
|
||||||
|
$small_type_5 = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($k=='lottery_rate_5'){
|
||||||
|
if($v != $lottery_rate_5){
|
||||||
|
$small_type_5 = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($k=='small_pool_trigger_times_10'){
|
||||||
|
if($v != $small_pool_trigger_times_10){
|
||||||
|
$small_type_10 = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($k=='lottery_rate_10'){
|
||||||
|
if($v != $lottery_rate_10){
|
||||||
|
$small_type_10 = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$this->redis = Cache::store('redis')->handler();
|
||||||
|
if($small_type==1){
|
||||||
|
$prize_amount = $this->redis->get('lottery:small_pool:total_gold');
|
||||||
|
Db::name('bb_lottery_winner_record')->insert([
|
||||||
|
'uid' => 0,
|
||||||
|
'prize_type' => 1,
|
||||||
|
'prize_amount' => $prize_amount,
|
||||||
|
'pool_amount' => $prize_amount,
|
||||||
|
'ratio' => 100,
|
||||||
|
'release_amount' => $prize_amount,
|
||||||
|
'create_time' => time(),
|
||||||
|
'status' => 0 // 未发放
|
||||||
|
]);
|
||||||
|
//修改开启下一轮
|
||||||
|
$dd =$this->redis->get('lottery:small_pool:round');
|
||||||
|
$this->redis->set('lottery:small_pool:round', $dd+1);
|
||||||
|
$this->redis->set('lottery:small_pool:total_times',0);
|
||||||
|
$this->redis->set('lottery:small_pool:total_gold',0);
|
||||||
|
}
|
||||||
|
if($small_type_5==1){
|
||||||
|
$prize_amount_5 = $this->redis->get('lottery:small_pool:total_gold_5');
|
||||||
|
Db::name('bb_lottery_winner_record')->insert([
|
||||||
|
'uid' => 0,
|
||||||
|
'prize_type' => 3,
|
||||||
|
'prize_amount' => $prize_amount_5,
|
||||||
|
'pool_amount' => $prize_amount_5,
|
||||||
|
'ratio' => 100,
|
||||||
|
'release_amount' => $prize_amount_5,
|
||||||
|
'create_time' => time(),
|
||||||
|
'status' => 0 // 未发放
|
||||||
|
]);
|
||||||
|
//修改开启下一轮
|
||||||
|
$dd5 =$this->redis->get('lottery:small_pool:round_5');
|
||||||
|
$this->redis->set('lottery:small_pool:round_5', $dd5+1);
|
||||||
|
$this->redis->set('lottery:small_pool:total_times_5',0);
|
||||||
|
$this->redis->set('lottery:small_pool:total_gold_5',0);
|
||||||
|
}
|
||||||
|
if($small_type_10==1){
|
||||||
|
$prize_amount_10 = $this->redis->get('lottery:small_pool:total_gold_10');
|
||||||
|
Db::name('bb_lottery_winner_record')->insert([
|
||||||
|
'uid' => 0,
|
||||||
|
'prize_type' => 4,
|
||||||
|
'prize_amount' => $prize_amount_10,
|
||||||
|
'pool_amount' => $prize_amount_10,
|
||||||
|
'ratio' => 100,
|
||||||
|
'release_amount' => $prize_amount_10,
|
||||||
|
'create_time' => time(),
|
||||||
|
'status' => 0 // 未发放
|
||||||
|
]);
|
||||||
|
//修改开启下一轮
|
||||||
|
$dd_10 =$this->redis->get('lottery:small_pool:round_10');
|
||||||
|
$this->redis->set('lottery:small_pool:round_10', $dd_10+1);
|
||||||
|
$this->redis->set('lottery:small_pool:total_times_10',0);
|
||||||
|
$this->redis->set('lottery:small_pool:total_gold_10',0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return V(1,"成功");
|
return V(1,"成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +165,18 @@ class Lottery extends adminApi
|
|||||||
$page_limit = input('page_limit', 30);
|
$page_limit = input('page_limit', 30);
|
||||||
$stime = input('stime', '');
|
$stime = input('stime', '');
|
||||||
$etime = input('etime', '');
|
$etime = input('etime', '');
|
||||||
|
$pool_type = input('pool_type', '1');
|
||||||
|
$user_code = input('user_code');
|
||||||
|
if($user_code){
|
||||||
|
$userId = db::name('user')->where(['user_code'=>$user_code])->value('id');
|
||||||
|
if($userId){
|
||||||
|
$where['uid'] = $userId;
|
||||||
|
}else{
|
||||||
|
$where['uid'] = '1';
|
||||||
|
}
|
||||||
|
}
|
||||||
$where = [];
|
$where = [];
|
||||||
|
$where['prize_type'] = $pool_type;
|
||||||
if($stime!==""){
|
if($stime!==""){
|
||||||
$where['create_time'] = ['>=', strtotime($stime)];
|
$where['create_time'] = ['>=', strtotime($stime)];
|
||||||
}
|
}
|
||||||
@@ -72,16 +187,39 @@ class Lottery extends adminApi
|
|||||||
$where['create_time'] = ['between', [strtotime($stime), strtotime($etime)]];
|
$where['create_time'] = ['between', [strtotime($stime), strtotime($etime)]];
|
||||||
}
|
}
|
||||||
$count = db::name('bb_lottery_winner_record')->where($where)->count();
|
$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();
|
$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){
|
foreach ($lists_data as $k=>$v){
|
||||||
$user_info = db::name('user')->where(['id'=>$v['user_id']])->find();
|
if($v['user_id'] > 0){
|
||||||
$lists_data[$k]['user_code'] = $user_info['user_code']??"";
|
$user_info = db::name('user')->where(['id'=>$v['user_id']])->find();
|
||||||
$lists_data[$k]['nickname'] = $user_info['user_code']."-".$user_info['nickname'];
|
$lists_data[$k]['user_code'] = $user_info['user_code']??"";
|
||||||
|
$lists_data[$k]['nickname'] = $user_info['user_code']."-".$user_info['nickname'];
|
||||||
|
}else{
|
||||||
|
$lists_data[$k]['user_code'] = "";
|
||||||
|
$lists_data[$k]['nickname'] = "后台重置,全部释放";
|
||||||
|
}
|
||||||
|
|
||||||
//奖项类型:1-小奖 2-大奖
|
//奖项类型:1-小奖 2-大奖
|
||||||
$lists_data[$k]['prize_type_str'] = $v['prize_type']==1?"小奖":"大奖";
|
if($v['prize_type']==4){
|
||||||
|
$lists_data[$k]['prize_type_str'] = "高级奖";
|
||||||
|
$gift_price = 10;
|
||||||
|
}elseif ($v['prize_type']==2){
|
||||||
|
$gift_price = 1;
|
||||||
|
$lists_data[$k]['prize_type_str'] = "大奖";
|
||||||
|
}elseif ($v['prize_type']==3){
|
||||||
|
$gift_price = 5;
|
||||||
|
$lists_data[$k]['prize_type_str'] = "中级奖";
|
||||||
|
}else{
|
||||||
|
$gift_price = 1;
|
||||||
|
$lists_data[$k]['prize_type_str'] = "小奖";
|
||||||
|
}
|
||||||
|
|
||||||
//状态:1-已发放 0-未发放'
|
//状态:1-已发放 0-未发放'
|
||||||
$lists_data[$k]['status_str'] = $v['status']==1?"已发放":"未发放";
|
$lists_data[$k]['status_str'] = $v['status']==1?"已发放":"未发放";
|
||||||
$lists_data[$k]['createtime'] = date("Y-m-d H:i:s", $v['createtime']);
|
$lists_data[$k]['createtime'] = date("Y-m-d H:i:s", $v['createtime']);
|
||||||
|
$lists_data[$k]['prize_amount'] = floor($v['prize_amount']);
|
||||||
|
$lists_data[$k]['beilv'] = floor($v['prize_amount'] / $gift_price);
|
||||||
}
|
}
|
||||||
$return_data = [
|
$return_data = [
|
||||||
'page' =>$page,
|
'page' =>$page,
|
||||||
@@ -98,23 +236,48 @@ class Lottery extends adminApi
|
|||||||
* 实时统计
|
* 实时统计
|
||||||
*/
|
*/
|
||||||
public function realtime_statistics(){
|
public function realtime_statistics(){
|
||||||
|
$pool_type = input('pool_type', '1');
|
||||||
|
|
||||||
$bb_config = db::name('bb_lottery_config')->field('key,value')->select();
|
$bb_config = db::name('bb_lottery_config')->field('key,value')->select();
|
||||||
$bb_config = array_column($bb_config, null, 'key');
|
$bb_config = array_column($bb_config, null, 'key');
|
||||||
// 循环奖池进度
|
if($pool_type == 4){
|
||||||
//最新轮次
|
$latest_times = db::name('bb_lottery_pool_flow_10')->where(['pool_type'=>1])->max('times');//最新轮次
|
||||||
$latest_times = db::name('bb_lottery_pool_flow')->where(['pool_type'=>1])->max('times');
|
$pool_progress = db::name('bb_lottery_pool_flow_10')->where(['pool_type'=>1,'times'=>$latest_times])->count();//当前进度
|
||||||
$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_10')->where(['pool_type'=>1,'times'=>$latest_times,'type'=>1])->sum('amount');
|
||||||
$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_10']['value']."(".$pool_total_amount."金币)";
|
||||||
$pool_progress_str = $pool_progress."/".$bb_config['small_pool_trigger_times']['value']."(".$pool_total_amount."金币)";
|
//最近中奖用户
|
||||||
|
$last_winner_user_id = db::name('bb_lottery_winner_record')->where(['status'=>1,'prize_type'=>4])->order('id desc')->find();
|
||||||
|
//平台累计收入
|
||||||
|
$platform_total_income = db::name('bb_lottery_winner_record')->where(['prize_type'=>4])->sum('release_amount');
|
||||||
|
}elseif($pool_type == 3){
|
||||||
|
$latest_times = db::name('bb_lottery_pool_flow_5')->where(['pool_type'=>1])->max('times');//最新轮次
|
||||||
|
$pool_progress = db::name('bb_lottery_pool_flow_5')->where(['pool_type'=>1,'times'=>$latest_times])->count();//当前进度
|
||||||
|
$pool_total_amount = db::name('bb_lottery_pool_flow_5')->where(['pool_type'=>1,'times'=>$latest_times,'type'=>1])->sum('amount');
|
||||||
|
//获取配置表中奖池配置
|
||||||
|
$pool_progress_str = $pool_progress."/".$bb_config['small_pool_trigger_times_5']['value']."(".$pool_total_amount."金币)";
|
||||||
|
//最近中奖用户
|
||||||
|
$last_winner_user_id = db::name('bb_lottery_winner_record')->where(['status'=>1,'prize_type'=>3])->order('id desc')->find();
|
||||||
|
//平台累计收入
|
||||||
|
$platform_total_income = db::name('bb_lottery_winner_record')->where(['prize_type'=>3])->sum('release_amount');
|
||||||
|
}else{
|
||||||
|
$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."金币)";
|
||||||
|
//最近中奖用户
|
||||||
|
$last_winner_user_id = db::name('bb_lottery_winner_record')->where(['status'=>1,'prize_type'=>1])->order('id desc')->find();
|
||||||
|
//平台累计收入
|
||||||
|
$platform_total_income = db::name('bb_lottery_winner_record')->where(['prize_type'=>1])->sum('release_amount');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//蓄水池当前金额
|
//蓄水池当前金额
|
||||||
$big_round = db::name('bb_lottery_pool_flow')->where(['pool_type'=>2])->max('times');
|
// $big_round = db::name('bb_lottery_pool_flow')->where(['pool_type'=>2])->max('times');
|
||||||
$bigAddGold = Db::name('bb_lottery_pool_flow')
|
// $bigAddGold = Db::name('bb_lottery_pool_flow')->where(['pool_type' => 2, 'type' => 3, 'times' => $big_round])->sum('amount') ?: 0;
|
||||||
->where(['pool_type' => 2, 'type' => 3, 'times' => $big_round])
|
$bigAddGold = 0;
|
||||||
->sum('amount') ?: 0;
|
|
||||||
//最近中奖用户
|
|
||||||
$last_winner_user_id = db::name('bb_lottery_winner_record')->where(['status'=>1])->order('id desc')->find();
|
|
||||||
if($last_winner_user_id){
|
if($last_winner_user_id){
|
||||||
$last_winner_user_info = db::name('user')->where(['id'=>$last_winner_user_id['uid']])->find();
|
$last_winner_user_info = db::name('user')->where(['id'=>$last_winner_user_id['uid']])->find();
|
||||||
$last_winner_user_text = "用户ID:".$last_winner_user_info['user_code']." 获得 ".$last_winner_user_id['prize_amount']." 金币 (".$last_winner_user_id['ratio']."%)";
|
$last_winner_user_text = "用户ID:".$last_winner_user_info['user_code']." 获得 ".$last_winner_user_id['prize_amount']." 金币 (".$last_winner_user_id['ratio']."%)";
|
||||||
@@ -123,7 +286,8 @@ class Lottery extends adminApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
//平台累计收入
|
//平台累计收入
|
||||||
$platform_total_income = db::name('bb_lottery_pool_flow')->where(['type'=>4])->sum('amount');
|
// $platform_total_income = db::name('bb_lottery_pool_flow')->where(['type'=>4])->sum('amount');
|
||||||
|
|
||||||
$return_data=[
|
$return_data=[
|
||||||
'pool_progress' => $pool_progress_str,
|
'pool_progress' => $pool_progress_str,
|
||||||
'pool_amount_now' => ($bigAddGold)."金币 (".(($bigAddGold)/$bb_config['big_pool_threshold']['value'])."%)",
|
'pool_amount_now' => ($bigAddGold)."金币 (".(($bigAddGold)/$bb_config['big_pool_threshold']['value'])."%)",
|
||||||
@@ -132,4 +296,67 @@ class Lottery extends adminApi
|
|||||||
];
|
];
|
||||||
return V(1,"成功", $return_data);
|
return V(1,"成功", $return_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 抽奖记录
|
||||||
|
*/
|
||||||
|
public function pool_flow_list(){
|
||||||
|
$page = input('page', 1);
|
||||||
|
$page_limit = input('page_limit', 30);
|
||||||
|
$stime = input('stime', '');
|
||||||
|
$etime = input('etime', '');
|
||||||
|
$pool_type = input('pool_type', '1');
|
||||||
|
$user_code = input('user_code');
|
||||||
|
if($user_code){
|
||||||
|
$userId = db::name('user')->where(['user_code'=>$user_code])->value('id');
|
||||||
|
if($userId){
|
||||||
|
$where['uid'] = $userId;
|
||||||
|
}else{
|
||||||
|
$where['uid'] = '1';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($pool_type == 4){
|
||||||
|
$table = 'bb_lottery_gift_record_10';
|
||||||
|
}
|
||||||
|
elseif($pool_type == 3){
|
||||||
|
$table = 'bb_lottery_gift_record_5';
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$table = 'bb_lottery_gift_record';
|
||||||
|
}
|
||||||
|
$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($table)->where($where)->count();
|
||||||
|
$lists_data = db::name($table)
|
||||||
|
->field('id,send_uid,recv_uid,gift_id,gift_gold,recv_gold,small_pool_add,remark,create_time as createtime')
|
||||||
|
->where($where)
|
||||||
|
->order("id desc")
|
||||||
|
->page($page, $page_limit)->select();
|
||||||
|
foreach ($lists_data as $k=>$v){
|
||||||
|
$send_user_info = db::name('user')->field('nickname,user_code')->where(['id'=>$v['send_uid']])->find();
|
||||||
|
$recv_user_info = db::name('user')->field('nickname,user_code')->where(['id'=>$v['recv_uid']])->find();
|
||||||
|
$lists_data[$k]['send_nickname'] = $send_user_info['user_code']."-".$send_user_info['nickname'];
|
||||||
|
$lists_data[$k]['recv_nickname'] = $recv_user_info['user_code']."-".$recv_user_info['nickname'];
|
||||||
|
$lists_data[$k]['gift_name'] = db::name('vs_gift')->where(['gid'=>$v['gift_id']])->value('gift_name');
|
||||||
|
$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);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
146
application/adminapi/controller/Monster.php
Normal file
146
application/adminapi/controller/Monster.php
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\adminapi\controller;
|
||||||
|
|
||||||
|
use app\admin\model\AdminLog;
|
||||||
|
use app\common\controller\adminApi;
|
||||||
|
use think\Cache;
|
||||||
|
use think\Config;
|
||||||
|
use think\Db;
|
||||||
|
|
||||||
|
class Monster extends adminApi
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
//获取列表
|
||||||
|
public function get_monster_list()
|
||||||
|
{
|
||||||
|
$order = input('order', 'id');
|
||||||
|
$sort = input('sort', 'desc');
|
||||||
|
$page = input('page', 1);
|
||||||
|
$limit = input('limit', 20);
|
||||||
|
$reslut = model('Monster')->get_monster_list($order, $sort, $page, $limit);
|
||||||
|
$data = [];
|
||||||
|
$data['code'] = 0;
|
||||||
|
$data['msg'] = '获取成功';
|
||||||
|
$data['count'] = $reslut['data']['count'];
|
||||||
|
$data['data'] = $reslut['data']['list'];
|
||||||
|
return V(1,"成功", $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取详情
|
||||||
|
public function get_monster_info()
|
||||||
|
{
|
||||||
|
$id = input('id', 0);
|
||||||
|
$reslut = model('Monster')->get_monster_info($id);
|
||||||
|
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||||
|
}
|
||||||
|
//编辑
|
||||||
|
public function edit_monster()
|
||||||
|
{
|
||||||
|
|
||||||
|
$data['id'] = input('id', 0);
|
||||||
|
$data['gid'] = input('gid', 0);
|
||||||
|
$data['num'] = input('num', 0);
|
||||||
|
$data['type_name'] = input('type_name', 0);
|
||||||
|
$data['multiple'] = input('multiple', 0);
|
||||||
|
|
||||||
|
$reslut = model('Monster')->edit_monster($data);
|
||||||
|
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取礼物列表
|
||||||
|
public function get_gift_list()
|
||||||
|
{
|
||||||
|
$reslut = model('Monster')->get_gift_list();
|
||||||
|
$data = [];
|
||||||
|
$data['code'] = 0;
|
||||||
|
$data['msg'] = '获取成功';
|
||||||
|
$data['count'] = $reslut['data']['count'];
|
||||||
|
$data['data'] = $reslut['data']['list'];
|
||||||
|
return V(1,"成功", $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//获取列表
|
||||||
|
public function get_monster_multiple_list()
|
||||||
|
{
|
||||||
|
$order = input('order', 'id');
|
||||||
|
$sort = input('sort', 'desc');
|
||||||
|
$page = input('page', 1);
|
||||||
|
$limit = input('limit', 20);
|
||||||
|
$reslut = model('Monster')->get_monster_multiple_list($order, $sort, $page, $limit);
|
||||||
|
$data = [];
|
||||||
|
$data['code'] = 0;
|
||||||
|
$data['msg'] = '获取成功';
|
||||||
|
$data['count'] = $reslut['data']['count'];
|
||||||
|
$data['data'] = $reslut['data']['list'];
|
||||||
|
return V(1,"成功", $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取详情
|
||||||
|
public function get_monster_multiple_info()
|
||||||
|
{
|
||||||
|
$id = input('id', 0);
|
||||||
|
$reslut = model('Monster')->get_monster_multiple_info($id);
|
||||||
|
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||||
|
}
|
||||||
|
//编辑
|
||||||
|
public function edit_monster_multiple()
|
||||||
|
{
|
||||||
|
$data['id'] = input('id', 0);
|
||||||
|
$data['multiple'] = input('multiple', 0);
|
||||||
|
$reslut = model('Monster')->edit_monster_multiple($data);
|
||||||
|
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取列表
|
||||||
|
public function get_monster_log(){
|
||||||
|
$order = input('order', 'id');
|
||||||
|
$sort = input('sort', 'desc');
|
||||||
|
$page = input('page', 1);
|
||||||
|
$limit = input('limit', 20);
|
||||||
|
$reslut = model('Monster')->get_monster_log($order, $sort, $page, $limit);
|
||||||
|
$data = [];
|
||||||
|
$data['code'] = 0;
|
||||||
|
$data['msg'] = '获取成功';
|
||||||
|
$data['count'] = $reslut['data']['count'];
|
||||||
|
$data['data'] = $reslut['data']['list'];
|
||||||
|
$data['totalRow'] = $reslut['data']['totalRow'];
|
||||||
|
return V(1,"成功", $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取列表
|
||||||
|
public function get_user_monster_log(){
|
||||||
|
$mid = input('mid', 0);
|
||||||
|
$order = input('order', 'id');
|
||||||
|
$sort = input('sort', 'desc');
|
||||||
|
$page = input('page', 1);
|
||||||
|
$limit = input('limit', 20);
|
||||||
|
$reslut = model('Monster')->get_user_monster_log($mid, $order, $sort, $page, $limit);
|
||||||
|
$data = [];
|
||||||
|
$data['code'] = 0;
|
||||||
|
$data['msg'] = '获取成功';
|
||||||
|
$data['count'] = $reslut['data']['count'];
|
||||||
|
$data['data'] = $reslut['data']['list'];
|
||||||
|
return V(1,"成功", $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取列表
|
||||||
|
public function get_user_monster_win_log(){
|
||||||
|
$mid = input('mid', 0);
|
||||||
|
$order = input('order', 'id');
|
||||||
|
$sort = input('sort', 'desc');
|
||||||
|
$page = input('page', 1);
|
||||||
|
$limit = input('limit', 20);
|
||||||
|
$reslut = model('Monster')->get_user_monster_win_log($mid, $order, $sort, $page, $limit);
|
||||||
|
$data = [];
|
||||||
|
$data['code'] = 0;
|
||||||
|
$data['msg'] = '获取成功';
|
||||||
|
$data['count'] = $reslut['data']['count'];
|
||||||
|
$data['data'] = $reslut['data']['list'];
|
||||||
|
return V(1,"成功", $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -426,7 +426,7 @@ class Nobility extends adminApi
|
|||||||
if (empty($lid)) {
|
if (empty($lid)) {
|
||||||
return V(0, "请选择爵位");
|
return V(0, "请选择爵位");
|
||||||
}
|
}
|
||||||
$reslut = model('api/Nobility')->buyNobility($user_id,$lid);
|
$reslut = model('api/Nobility')->buyNobility($user_id,$lid,1);
|
||||||
return V($reslut['code'],$reslut['msg'], null);
|
return V($reslut['code'],$reslut['msg'], null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -343,7 +343,12 @@ class Room extends adminApi
|
|||||||
$count = db::name($this->relation)->where($where)->count();
|
$count = db::name($this->relation)->where($where)->count();
|
||||||
$lists = db::name($this->relation)->where($where)->page($page, $page_limit)->select();
|
$lists = db::name($this->relation)->where($where)->page($page, $page_limit)->select();
|
||||||
foreach ($lists as $key => $value) {
|
foreach ($lists as $key => $value) {
|
||||||
$lists[$key]['type_str'] = model('Room')->relation_type[$value['type']];
|
if($value['type'] > 0){
|
||||||
|
$lists[$key]['type_str'] = model('Room')->relation_type[$value['type']];
|
||||||
|
}else{
|
||||||
|
$lists[$key]['type_str'] = '无关系';
|
||||||
|
}
|
||||||
|
|
||||||
$lists[$key]['is_open_movie'] = $value['is_open_movie']==1?'是':'否';
|
$lists[$key]['is_open_movie'] = $value['is_open_movie']==1?'是':'否';
|
||||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||||
}
|
}
|
||||||
@@ -2057,4 +2062,39 @@ class Room extends adminApi
|
|||||||
return V(1, "成功", $return_data);
|
return V(1, "成功", $return_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//房间幸运值流水详情
|
||||||
|
public function room_luck_list(){
|
||||||
|
$page = input('page', 1);
|
||||||
|
$page_limit = input('page_limit', 10);
|
||||||
|
$room_id = input('room_id', '');
|
||||||
|
if(empty($room_id)){
|
||||||
|
return V(0, "房间ID不能为空");
|
||||||
|
}
|
||||||
|
$count = db::name("vs_room_luck_value")->where(['room_id'=>$room_id])->count();
|
||||||
|
$room_host_lists = db::name("vs_room_luck_value")
|
||||||
|
->where(['room_id'=>$room_id])
|
||||||
|
->order('createtime desc')
|
||||||
|
->page($page, $page_limit)->select();
|
||||||
|
if($room_host_lists){
|
||||||
|
foreach ($room_host_lists as $key => $value){
|
||||||
|
$room_host_lists[$key]['send_nickname'] = db::name('user')->where(['id'=>$value['send_uid']])->value('nickname');
|
||||||
|
$room_host_lists[$key]['send_avatar'] = db::name('user')->where(['id'=>$value['send_uid']])->value('avatar');
|
||||||
|
$room_host_lists[$key]['send_user_code'] = db::name('user')->where(['id'=>$value['send_uid']])->value('user_code');
|
||||||
|
$room_host_lists[$key]['recv_nickname'] = db::name('user')->where(['id'=>$value['recv_uid']])->value('nickname');
|
||||||
|
$room_host_lists[$key]['recv_avatar'] = db::name('user')->where(['id'=>$value['recv_uid']])->value('avatar');
|
||||||
|
$room_host_lists[$key]['recv_user_code'] = db::name('user')->where(['id'=>$value['recv_uid']])->value('user_code');
|
||||||
|
$room_host_lists[$key]['gift_name'] = db::name('vs_gift')->where(['gid'=>$value['gift_id']])->value('gift_name');
|
||||||
|
$room_host_lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$return_data = [
|
||||||
|
'page' =>$page,
|
||||||
|
'page_limit' => $page_limit,
|
||||||
|
'count' => $count,
|
||||||
|
'lists' => $room_host_lists
|
||||||
|
];
|
||||||
|
return V(1, "成功", $return_data);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -25,16 +25,18 @@ class SysSet extends adminApi
|
|||||||
|
|
||||||
public $configType = [
|
public $configType = [
|
||||||
'1' => '基础设置',
|
'1' => '基础设置',
|
||||||
'2' => '登录设置',
|
// '2' => '登录设置',
|
||||||
'3' => '支付配置',
|
'3' => '支付配置',
|
||||||
'4' => '提现设置',
|
'4' => '提现设置',
|
||||||
'5' => '推送及IM配置',
|
// '5' => '推送及IM配置',
|
||||||
// '6' => '每日任务设置',
|
// '6' => '每日任务设置',
|
||||||
'7' => '云存储配置',
|
'7' => '第三方配置',
|
||||||
'8' => '房间配置',
|
'8' => '房间配置',
|
||||||
'9' => '弹窗内容设置',
|
// '9' => '弹窗内容设置',
|
||||||
'10' => '邀请奖励',
|
'10' => '邀请奖励',
|
||||||
'11' => '二级密码',
|
'11' => '二级密码',
|
||||||
|
'12' => '情侣任务设置',
|
||||||
|
'13' => '趣味活动中',
|
||||||
];
|
];
|
||||||
public $noAdminConfigType = [
|
public $noAdminConfigType = [
|
||||||
'1' => '基础设置',
|
'1' => '基础设置',
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ class SystemMessage extends adminApi
|
|||||||
if($receiving_id){
|
if($receiving_id){
|
||||||
$data['receiving_id'] = $receiving_id;
|
$data['receiving_id'] = $receiving_id;
|
||||||
}else{
|
}else{
|
||||||
$user_list = db::name('user')->field('id')->select();
|
$user_list = db::name('user')->where('delete_time',0)->where(['sex'=>['<>',0]])->field('id')->select();
|
||||||
$data['receiving_id'] = implode(',', array_column($user_list, 'id'));
|
$data['receiving_id'] = implode(',', array_column($user_list, 'id'));
|
||||||
}
|
}
|
||||||
if($id){
|
if($id){
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class Tasks extends adminApi
|
|||||||
public function task_list(){
|
public function task_list(){
|
||||||
$page = input('page', 1);
|
$page = input('page', 1);
|
||||||
$page_limit = input('page_limit', 10);
|
$page_limit = input('page_limit', 10);
|
||||||
$seach_task_type = input('seach_task_type', '');
|
$seach_task_type = input('task_type', '');
|
||||||
$where=[];
|
$where=[];
|
||||||
if($seach_task_type != ''){
|
if($seach_task_type != ''){
|
||||||
$where['task_type'] = $seach_task_type;
|
$where['task_type'] = $seach_task_type;
|
||||||
@@ -121,5 +121,12 @@ class Tasks extends adminApi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 任务类型列表
|
||||||
|
*/
|
||||||
|
public function task_type_list(){
|
||||||
|
$list = model('api/Tasks')->task_type;
|
||||||
|
return V(1,"成功", $list);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -146,6 +146,8 @@ class User extends adminApi
|
|||||||
$lists[$key]['user_block_time'] = '';
|
$lists[$key]['user_block_time'] = '';
|
||||||
$lists[$key]['mobile_block_time'] = '';
|
$lists[$key]['mobile_block_time'] = '';
|
||||||
$lists[$key]['ip_block_time'] = '';
|
$lists[$key]['ip_block_time'] = '';
|
||||||
|
//禁用理由
|
||||||
|
$lists[$key]['user_block_reason'] = '';
|
||||||
if($is_block_user){
|
if($is_block_user){
|
||||||
$lists[$key]['is_block_user'] = 1;
|
$lists[$key]['is_block_user'] = 1;
|
||||||
if($is_block_user['block_time']==0){
|
if($is_block_user['block_time']==0){
|
||||||
@@ -153,6 +155,7 @@ class User extends adminApi
|
|||||||
}else{
|
}else{
|
||||||
$lists[$key]['user_block_time'] = date('Y-m-d H:i:s',$is_block_user['block_time']);
|
$lists[$key]['user_block_time'] = date('Y-m-d H:i:s',$is_block_user['block_time']);
|
||||||
}
|
}
|
||||||
|
$lists[$key]['user_block_reason'] = model('Block')->getBanReason()[$is_block_user['ban_eason']];
|
||||||
}
|
}
|
||||||
// if($is_block_mobile){
|
// if($is_block_mobile){
|
||||||
// $lists[$key]['is_block_mobile'] = 1;
|
// $lists[$key]['is_block_mobile'] = 1;
|
||||||
@@ -226,6 +229,13 @@ class User extends adminApi
|
|||||||
$status = input('status', 1);
|
$status = input('status', 1);
|
||||||
$ban_eason = input('ban_eason', 0);
|
$ban_eason = input('ban_eason', 0);
|
||||||
$ban_day = input('ban_day', 0);
|
$ban_day = input('ban_day', 0);
|
||||||
|
if(empty($time)){
|
||||||
|
if(!empty($ban_day)){
|
||||||
|
$time = date('Y-m-d H:i:s', time() + $ban_day * 86400);
|
||||||
|
}else{
|
||||||
|
$time = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
$user_info = model('User')->where('id', $user_id)->find();
|
$user_info = model('User')->where('id', $user_id)->find();
|
||||||
if(!$user_info){
|
if(!$user_info){
|
||||||
return V(0, "用户不存在");
|
return V(0, "用户不存在");
|
||||||
@@ -257,10 +267,28 @@ class User extends adminApi
|
|||||||
'type_text' => $type_text,
|
'type_text' => $type_text,
|
||||||
'block_time' => $block_time,
|
'block_time' => $block_time,
|
||||||
'createtime' => time(),
|
'createtime' => time(),
|
||||||
|
'ban_eason' => $ban_eason,
|
||||||
|
'ban_day' => $ban_day,
|
||||||
]);
|
]);
|
||||||
if (!$res) {
|
if (!$res) {
|
||||||
return V(0, "添加失败");
|
return V(0, "添加失败");
|
||||||
}
|
}
|
||||||
|
//加推送单聊消息
|
||||||
|
if($block_time){
|
||||||
|
$content = "您的账号因 含有".model('Block')->getBanReason()[$ban_eason] . "内容 于".date('Y-m-d H:i:s',time())." 被封禁".model('Block')->getBanTime()[$ban_day]." ,".date('Y-m-d H:i:s',$block_time)."解封,如对处罚有异议请及时联系管理员申诉";
|
||||||
|
}else{
|
||||||
|
$content = "您的账号因 含有".model('Block')->getBanReason()[$ban_eason] . "内容 于".date('Y-m-d H:i:s',time())." 被永久封禁".model('Block')->getBanTime()[$ban_day]." ,请及时联系管理员申诉";
|
||||||
|
}
|
||||||
|
|
||||||
|
$text = [
|
||||||
|
'MsgType' => 404,
|
||||||
|
'ToUserId' => $user_id,
|
||||||
|
'Text' => [
|
||||||
|
'text' => $content
|
||||||
|
]
|
||||||
|
];
|
||||||
|
//谁发送给谁,什么消息,是否同步到发送者1是,2否,消息是否只下发给在线用户 1 是,0 否
|
||||||
|
model('api/Tencent')->user_sendmsg("administrator",$user_id,json_encode($text),2,1);
|
||||||
}else{
|
}else{
|
||||||
if($type ==1) {
|
if($type ==1) {
|
||||||
$res = model('User')->where('id', $user_id)->update(['status' => 1]);
|
$res = model('User')->where('id', $user_id)->update(['status' => 1]);
|
||||||
@@ -284,6 +312,16 @@ class User extends adminApi
|
|||||||
TokenLib::delete($token);
|
TokenLib::delete($token);
|
||||||
return V(1,"成功", null);
|
return V(1,"成功", null);
|
||||||
}
|
}
|
||||||
|
//封禁理由
|
||||||
|
public function getBanEason(){
|
||||||
|
$list = model('Block')->getBanReason();
|
||||||
|
return V(1,"成功", $list);
|
||||||
|
}
|
||||||
|
//封禁时长
|
||||||
|
public function getBanDay(){
|
||||||
|
$list = model('Block')->getBanTime();
|
||||||
|
return V(1,"成功", $list);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 设为官方账号
|
* 设为官方账号
|
||||||
@@ -822,6 +860,7 @@ class User extends adminApi
|
|||||||
$type = input('type', 1);
|
$type = input('type', 1);
|
||||||
$type_text = input('type_text', '');
|
$type_text = input('type_text', '');
|
||||||
$block_time = input('block_time', 0);
|
$block_time = input('block_time', 0);
|
||||||
|
$ban_eason = input('ban_eason', 0);
|
||||||
$admin_id = Session::get('admin_id');
|
$admin_id = Session::get('admin_id');
|
||||||
//插入fa_block 表
|
//插入fa_block 表
|
||||||
$res = Db::name('block')->insert([
|
$res = Db::name('block')->insert([
|
||||||
@@ -830,10 +869,27 @@ class User extends adminApi
|
|||||||
'type_text' => $type_text,
|
'type_text' => $type_text,
|
||||||
'block_time' => strtotime($block_time),
|
'block_time' => strtotime($block_time),
|
||||||
'createtime' => time(),
|
'createtime' => time(),
|
||||||
|
'ban_eason' => $ban_eason,
|
||||||
]);
|
]);
|
||||||
if (!$res) {
|
if (!$res) {
|
||||||
return V(0, "添加失败");
|
return V(0, "添加失败");
|
||||||
}
|
}
|
||||||
|
//1账号, 2设备, 3ip 4禁言
|
||||||
|
if($type == 1){
|
||||||
|
$user_id = db::name('user')->where('user_code', $type_text)->value('id');
|
||||||
|
}
|
||||||
|
if($type == 2){
|
||||||
|
$user_id = db::name('user')->where('login_device', $type_text)->value('id');
|
||||||
|
}
|
||||||
|
if($type == 3){
|
||||||
|
$user_id = db::name('user')->where('loginip', $type_text)->value('id');
|
||||||
|
}
|
||||||
|
if(isset($user_id)){
|
||||||
|
$token = db::name('user_token')->where('user_id', $user_id)->value('token');
|
||||||
|
// 删除这个Token,使其失效
|
||||||
|
TokenLib::delete($token);
|
||||||
|
}
|
||||||
|
|
||||||
return V(1,"添加成功", null);
|
return V(1,"添加成功", null);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|||||||
253
application/adminapi/model/Monster.php
Normal file
253
application/adminapi/model/Monster.php
Normal file
@@ -0,0 +1,253 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\adminapi\model;
|
||||||
|
|
||||||
|
use think\Db;
|
||||||
|
use think\Model;
|
||||||
|
|
||||||
|
class Monster extends Model
|
||||||
|
{
|
||||||
|
//列表
|
||||||
|
public function get_monster_list($order, $sort, $page = 1, $limit = 20)
|
||||||
|
{
|
||||||
|
|
||||||
|
$list = db::name('Monster')->order($order, $sort)->page($page, $limit)->select();
|
||||||
|
$total_num = db::name('Monster')->sum('num');
|
||||||
|
foreach ($list as $k => &$v) {
|
||||||
|
$gift_info = db::name('vs_gift')->where('gid', $v['gid'])->find();
|
||||||
|
$v['gift_name'] = $gift_info['gift_name'];
|
||||||
|
$v['base_image'] = localpath_to_netpath($gift_info['base_image']);
|
||||||
|
$v['gift_price'] = $gift_info['gift_price'];
|
||||||
|
$v['rate'] = round(($v['num']/$total_num), 6) * 100;
|
||||||
|
$v['rate'] .= '%';
|
||||||
|
$v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
|
||||||
|
$v['updatetime'] = date('Y-m-d H:i:s', $v['updatetime']);
|
||||||
|
}
|
||||||
|
$data = [];
|
||||||
|
$data['count'] = db::name('Monster')->count();
|
||||||
|
$data['list'] = $list;
|
||||||
|
return ['code' => 1, 'msg' => '获取成功', 'data' => $data];
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取礼物列表
|
||||||
|
public function get_gift_list(){
|
||||||
|
$map = [];
|
||||||
|
// $map[] = ['gid', 'not in', [36,37,38]];
|
||||||
|
$map['type'] = ['=', 2];
|
||||||
|
// $map['label'] = ['=', 18];
|
||||||
|
$map['is_show'] = ['=',1];
|
||||||
|
$map['delete_time'] = ['=', 0];
|
||||||
|
$list = db::name('vs_gift')->where($map)->order('gift_price asc')->select();
|
||||||
|
$data = [];
|
||||||
|
$data['count'] = db::name('vs_gift')->where($map)->count();
|
||||||
|
$data['list'] = $list;
|
||||||
|
return ['code' => 1, 'msg' => '获取成功', 'data' => $data];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//编辑
|
||||||
|
public function edit_monster($data)
|
||||||
|
{
|
||||||
|
if (empty($data)) {
|
||||||
|
return ['code' => 0, 'msg' => '参数异常', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
$monster_info = db::name('Monster')->find($data['id']);
|
||||||
|
if (empty($monster_info)) {
|
||||||
|
return ['code' => 0, 'msg' => '参数异常', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
$map = [];
|
||||||
|
$map['gid'] = ['=', $data['gid']];
|
||||||
|
// $map['type'] = ['=', 1];
|
||||||
|
$map['is_show'] = ['=',1];
|
||||||
|
$map['delete_time'] = ['=', 0];
|
||||||
|
$gift_info = db::name('vs_gift')->where($map)->find();
|
||||||
|
if(!$gift_info){
|
||||||
|
return ['code' => 0, 'msg' => '配置礼物不存在', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
if($monster_info['multiple'] * 10 != $gift_info['gift_price']){
|
||||||
|
return ['code' => 0, 'msg' => '配置礼物的价格必须为倍数的10倍', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
|
||||||
|
$update_data = [];
|
||||||
|
$update_data['type_name'] = $data['type_name'];
|
||||||
|
if($data['multiple']){
|
||||||
|
$update_data['multiple'] = $data['multiple'];
|
||||||
|
}
|
||||||
|
$update_data['gid'] = $data['gid'];
|
||||||
|
$update_data['num'] = $data['num'];
|
||||||
|
$update_data['updatetime'] = time();
|
||||||
|
$reslut = db::name('Monster')->where(['id' => $data['id']])->update($update_data);
|
||||||
|
if (!$reslut) {
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => '修改失败', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
return ['code' => 1, 'msg' => '修改成功', 'data' => null];
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// 回滚事务
|
||||||
|
dump($e);
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => '修改失败', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取信息
|
||||||
|
public function get_monster_info($id)
|
||||||
|
{
|
||||||
|
if (empty($id)) {
|
||||||
|
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||||
|
}
|
||||||
|
$monster_info = db::name('Monster')->where(['id' => $id])->find();
|
||||||
|
return ['code' => 1, 'msg' => '获取成功', 'data' => $monster_info];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//列表
|
||||||
|
public function get_monster_multiple_list($order, $sort, $page = 1, $limit = 20)
|
||||||
|
{
|
||||||
|
|
||||||
|
$list = db::name('monster_multiple')->order($order, $sort)->page($page, $limit)->select();
|
||||||
|
foreach ($list as $k => &$v) {
|
||||||
|
|
||||||
|
}
|
||||||
|
$data = [];
|
||||||
|
$data['count'] = db::name('monster_multiple')->count();
|
||||||
|
$data['list'] = $list;
|
||||||
|
return ['code' => 1, 'msg' => '获取成功', 'data' => $data];
|
||||||
|
}
|
||||||
|
|
||||||
|
//编辑
|
||||||
|
public function edit_monster_multiple($data)
|
||||||
|
{
|
||||||
|
if (empty($data)) {
|
||||||
|
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
$monster_info = db::name('monster_multiple')->find($data['id']);
|
||||||
|
if (empty($monster_info)) {
|
||||||
|
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
|
||||||
|
$update_data = [];
|
||||||
|
$update_data['multiple'] = $data['multiple'];
|
||||||
|
$update_data['updatetime'] = time();
|
||||||
|
$reslut = db::name('monster_multiple')->where(['id' => $data['id']])->update($update_data);
|
||||||
|
if (!$reslut) {
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => '修改失败', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
return ['code' => 1, 'msg' => '修改成功', 'data' => null];
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// 回滚事务
|
||||||
|
dump($e);
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => '修改失败', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取信息
|
||||||
|
public function get_monster_multiple_info($id)
|
||||||
|
{
|
||||||
|
if (empty($id)) {
|
||||||
|
return ['code' => 0, 'msg' => '参数异常', 'data' => null];
|
||||||
|
}
|
||||||
|
$monster_info = db::name('monster_multiple')->where(['id' => $id])->find();
|
||||||
|
return ['code' => 1, 'msg' => '获取成功', 'data' => $monster_info];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//列表
|
||||||
|
public function get_monster_log($order, $sort, $page = 1, $limit = 20)
|
||||||
|
{
|
||||||
|
|
||||||
|
$list = db::name('monster_log')->order($order, $sort)->page($page, $limit)->select();
|
||||||
|
foreach ($list as $k => &$v) {
|
||||||
|
$v['type_name'] = '暂未开奖';
|
||||||
|
$v['gid'] = 0;
|
||||||
|
$v['gift_name'] = '';
|
||||||
|
$v['base_image'] = '';
|
||||||
|
$v['gift_price'] = 0;
|
||||||
|
if($v['is_delete'] == 2){
|
||||||
|
$gift_info = db::name('Monster')->alias('a')->join('vs_gift b', 'a.gid = b.gid')->field('b.gid,b.gift_name,b.base_image,b.gift_price,a.type_name')->where('a.type', $v['win_type'])->find();
|
||||||
|
$v['gid'] = $gift_info['gid'];
|
||||||
|
$v['gift_name'] = $gift_info['gift_name'];
|
||||||
|
$v['base_image'] = localpath_to_netpath($gift_info['base_image']);
|
||||||
|
$v['gift_price'] = $gift_info['gift_price'];
|
||||||
|
$v['type_name'] = $gift_info['type_name'];
|
||||||
|
$v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
|
||||||
|
$v['updatetime'] = date('Y-m-d H:i:s', $v['updatetime']);
|
||||||
|
$v['end_time'] = date('Y-m-d H:i:s', $v['end_time']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$data = [];
|
||||||
|
$data['count'] = db::name('monster_log')->count();
|
||||||
|
$data['list'] = $list;
|
||||||
|
$totalRowData = db::name('monster_log')->field('count(1) as count,SUM(out_amount) as out_amount,SUM(in_amount) as in_amount')->find();
|
||||||
|
unset($totalRowData['count']);
|
||||||
|
$data['totalRow'] = $totalRowData;
|
||||||
|
return ['code' => 1, 'msg' => '获取成功', 'data' => $data];
|
||||||
|
}
|
||||||
|
|
||||||
|
//列表
|
||||||
|
public function get_user_monster_log($mid, $order, $sort, $page = 1, $limit = 20)
|
||||||
|
{
|
||||||
|
|
||||||
|
$list = db::name('user_monster_log')->where('mid', $mid)->order($order, $sort)->page($page, $limit)->select();
|
||||||
|
foreach ($list as $k => &$v) {
|
||||||
|
$user_info = db::name('user')->where('id', $v['uid'])->field('id,nickname,avatar')->find();
|
||||||
|
$v['nickname'] = $user_info['nickname'];
|
||||||
|
$v['avatar'] = localpath_to_netpath($user_info['avatar']);
|
||||||
|
$v['type_name'] = db::name('Monster')->where('type', $v['type'])->value('type_name');
|
||||||
|
$v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
|
||||||
|
$v['updatetime'] = date('Y-m-d H:i:s', $v['updatetime']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
$data['count'] = db::name('user_monster_log')->where('mid', $mid)->count();
|
||||||
|
$data['list'] = $list;
|
||||||
|
return ['code' => 1, 'msg' => '获取成功', 'data' => $data];
|
||||||
|
}
|
||||||
|
|
||||||
|
//列表
|
||||||
|
public function get_user_monster_win_log($mid, $order, $sort, $page = 1, $limit = 20)
|
||||||
|
{
|
||||||
|
|
||||||
|
$list = db::name('user_monster_win_log')->where('mid', $mid)->order($order, $sort)->page($page, $limit)->select();
|
||||||
|
foreach ($list as $k => &$v) {
|
||||||
|
$user_info = db::name('user')->where('id', $v['uid'])->field('id,nickname,avatar')->find();
|
||||||
|
$v['nickname'] = $user_info['nickname'];
|
||||||
|
$v['avatar'] = localpath_to_netpath($user_info['avatar']);
|
||||||
|
$v['type_name'] = db::name('Monster')->where('type', $v['win_type'])->value('type_name');
|
||||||
|
$gift_info = db::name('vs_gift')->where('gid', $v['win_gid'])->field('gid,gift_name,base_image,gift_price')->find();
|
||||||
|
$v['gift_name'] = $gift_info['gift_name'];
|
||||||
|
$v['base_image'] = localpath_to_netpath($gift_info['base_image']);
|
||||||
|
$v['gift_price'] = $gift_info['gift_price'];
|
||||||
|
$v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
|
||||||
|
$v['updatetime'] = date('Y-m-d H:i:s', $v['updatetime']);
|
||||||
|
}
|
||||||
|
$data = [];
|
||||||
|
$data['count'] = db::name('user_monster_win_log')->where('mid', $mid)->count();
|
||||||
|
$data['list'] = $list;
|
||||||
|
return ['code' => 1, 'msg' => '获取成功', 'data' => $data];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -40,7 +40,7 @@ class BlindBoxTurntable extends BaseCom
|
|||||||
$num = input('num',1);
|
$num = input('num',1);
|
||||||
$heart_id = input('heart_id',0);
|
$heart_id = input('heart_id',0);
|
||||||
$auction_id = input('auction_id',0);
|
$auction_id = input('auction_id',0);
|
||||||
if(!in_array($gift_bag_id,[10,11,12])){
|
if(!in_array($gift_bag_id,[10,11,12,61])){
|
||||||
return v(0,'非法活动ID', null);
|
return v(0,'非法活动ID', null);
|
||||||
}
|
}
|
||||||
//删除字符串里所有的空格
|
//删除字符串里所有的空格
|
||||||
@@ -144,7 +144,8 @@ class BlindBoxTurntable extends BaseCom
|
|||||||
* 1.开启 2.关闭
|
* 1.开启 2.关闭
|
||||||
*/
|
*/
|
||||||
public function blind_box_status(){
|
public function blind_box_status(){
|
||||||
$reslut = model('BlindBoxTurntableGift')->blind_box_status();
|
$user_id = $this->uid;
|
||||||
|
$reslut = model('BlindBoxTurntableGift')->blind_box_status($user_id);
|
||||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -22,7 +22,8 @@ class Decorate extends BaseCom
|
|||||||
public function get_type_list()
|
public function get_type_list()
|
||||||
{
|
{
|
||||||
$have_hot = input('have_hot',0);
|
$have_hot = input('have_hot',0);
|
||||||
$reslut = model('Decorate')->get_type_list($have_hot);
|
$from = input('from',1);//来源:1 道具商城 2 个性装扮
|
||||||
|
$reslut = model('Decorate')->get_type_list($have_hot,$from);
|
||||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||||
}
|
}
|
||||||
//获取装饰列表
|
//获取装饰列表
|
||||||
@@ -80,7 +81,9 @@ class Decorate extends BaseCom
|
|||||||
public function set_user_decorate(){
|
public function set_user_decorate(){
|
||||||
$uid = $this->uid;
|
$uid = $this->uid;
|
||||||
$udid = input('udid', 0);
|
$udid = input('udid', 0);
|
||||||
$reslut = model('Decorate')->set_user_decorate($uid,$udid);
|
$room_id = input('room_id', 0);
|
||||||
|
$num = input('num', 1);
|
||||||
|
$reslut = model('Decorate')->set_user_decorate($uid,$udid,$room_id,$num);
|
||||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||||
}
|
}
|
||||||
//取消装扮
|
//取消装扮
|
||||||
@@ -91,4 +94,14 @@ class Decorate extends BaseCom
|
|||||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//房间热度卡使用
|
||||||
|
public function room_hot_card(){
|
||||||
|
$uid = $this->uid;
|
||||||
|
$udid = input('udid', 0);
|
||||||
|
$room_id = input('room_id', 0);
|
||||||
|
$num = input('num', 1);
|
||||||
|
$reslut = model('Decorate')->room_hot_card($uid,$udid,$room_id,$num);
|
||||||
|
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ class Gift extends BaseCom
|
|||||||
{
|
{
|
||||||
$no_label = input('no_label','');
|
$no_label = input('no_label','');
|
||||||
$no_label = explode(',',$no_label);
|
$no_label = explode(',',$no_label);
|
||||||
$reslut = model('Gift')->get_gift_label($no_label);
|
$type = input('type',1);
|
||||||
|
$reslut = model('Gift')->get_gift_label($type,$no_label);
|
||||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
109
application/api/controller/Monster.php
Normal file
109
application/api/controller/Monster.php
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\controller;
|
||||||
|
|
||||||
|
use app\common\controller\BaseCom;
|
||||||
|
use think\Controller;
|
||||||
|
use think\Db;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动:
|
||||||
|
* 1.首充好礼
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class Monster extends BaseCom
|
||||||
|
{
|
||||||
|
//初始化
|
||||||
|
protected function initialize()
|
||||||
|
{
|
||||||
|
//允许跨域
|
||||||
|
header('Access-Control-Allow-Origin: *');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//选择金币列表
|
||||||
|
public function choice_gold_list(){
|
||||||
|
$reslut = model('Monster')->choice_gold_list();
|
||||||
|
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||||
|
|
||||||
|
}
|
||||||
|
//游戏详情
|
||||||
|
public function get_monster_info(){
|
||||||
|
$uid = $this->uid;
|
||||||
|
$reslut = model('Monster')->get_monster_info($uid);
|
||||||
|
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||||
|
}
|
||||||
|
|
||||||
|
//生成/结算喂养怪兽
|
||||||
|
public function create_monster_log(){
|
||||||
|
$uid = $this->uid;
|
||||||
|
$key_name = "api:Monster:create_monster_log";
|
||||||
|
redis_lock_exit($key_name);
|
||||||
|
$reslut = model('Monster')->create_monster_log();
|
||||||
|
redis_unlock($key_name);
|
||||||
|
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||||
|
}
|
||||||
|
|
||||||
|
//喂养怪兽
|
||||||
|
public function open_beat_monster(){
|
||||||
|
$uid = $this->uid;
|
||||||
|
$rid = input('rid', 0);
|
||||||
|
$type = input('type', 0);
|
||||||
|
$num = input('num', 0);
|
||||||
|
$key_name = "api:Monster:open_beat_monster:uid:".$uid;
|
||||||
|
redis_lock_exit($key_name);
|
||||||
|
$reslut = model('Monster')->open_beat_monster($uid, $rid, $type, $num);
|
||||||
|
redis_unlock($key_name);
|
||||||
|
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//规则
|
||||||
|
public function get_monster_note(){
|
||||||
|
$reslut = model('Monster')->get_monster_note();
|
||||||
|
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||||
|
}
|
||||||
|
|
||||||
|
//奖池
|
||||||
|
public function get_monster_box_list(){
|
||||||
|
$reslut = model('Monster')->get_monster_box_list();
|
||||||
|
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//开奖记录
|
||||||
|
public function get_monster_log(){
|
||||||
|
$uid = $this->uid;
|
||||||
|
$page = input('page', 1);
|
||||||
|
$page_limit = input('page_limit', 20);
|
||||||
|
$reslut = model('Monster')->get_monster_log($uid, $page, $page_limit);
|
||||||
|
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||||
|
}
|
||||||
|
|
||||||
|
//我的记录
|
||||||
|
public function get_user_monster_log(){
|
||||||
|
$uid = $this->uid;
|
||||||
|
$page = input('page', 1);
|
||||||
|
$page_limit = input('page_limit', 20);
|
||||||
|
$reslut = model('Monster')->get_user_monster_log($uid, $page, $page_limit);
|
||||||
|
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||||
|
}
|
||||||
|
|
||||||
|
//中奖次数榜单
|
||||||
|
public function get_monster_winner_num_list(){
|
||||||
|
$uid = $this->uid;
|
||||||
|
$time = input('time', 1);
|
||||||
|
$reslut = model('Monster')->get_monster_winner_num_list($uid, $time);
|
||||||
|
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//设置房间期数开关
|
||||||
|
public function operate_room_monster_show_status(){
|
||||||
|
$uid = $this->uid;
|
||||||
|
$rid = input('rid', 0);
|
||||||
|
$is_show_monster_push = input('is_show_monster_push', 1);
|
||||||
|
$reslut = model('Monster')->operate_room_monster_show_status($uid, $rid, $is_show_monster_push);
|
||||||
|
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -39,7 +39,7 @@ class Nobility extends BaseCom
|
|||||||
public function buy_nobility(){
|
public function buy_nobility(){
|
||||||
$lid = input('lid', 0);
|
$lid = input('lid', 0);
|
||||||
$uid = input('uid', $this->uid);
|
$uid = input('uid', $this->uid);
|
||||||
$reslut = model('Nobility')->buyNobility($uid,$lid);
|
$reslut = model('Nobility')->buyNobility($uid,$lid,$is_send);
|
||||||
return V($reslut['code'],$reslut['msg'], null);
|
return V($reslut['code'],$reslut['msg'], null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -445,7 +445,6 @@ class Payment extends Controller
|
|||||||
return V(0, '请选择正确的充值金额', null);
|
return V(0, '请选择正确的充值金额', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$user_id = db::name('user')->where(["user_code" => $user_code])->value('id');
|
$user_id = db::name('user')->where(["user_code" => $user_code])->value('id');
|
||||||
|
|
||||||
//获取用户的手机号
|
//获取用户的手机号
|
||||||
@@ -482,7 +481,6 @@ class Payment extends Controller
|
|||||||
//引用微信sdk
|
//引用微信sdk
|
||||||
Loader::import('WxPay.WxPay', EXTEND_PATH, '.php');
|
Loader::import('WxPay.WxPay', EXTEND_PATH, '.php');
|
||||||
$wx = new \WxPay();
|
$wx = new \WxPay();
|
||||||
// $result = $wx->WxPayMp($data);
|
|
||||||
$result = $wx->WxPayJsapi($data);
|
$result = $wx->WxPayJsapi($data);
|
||||||
return V(1, 'app支付', $result);
|
return V(1, 'app支付', $result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ class Room extends BaseCom
|
|||||||
$room_name = input('room_name', '');
|
$room_name = input('room_name', '');
|
||||||
$room_cover = input('room_cover', '');
|
$room_cover = input('room_cover', '');
|
||||||
$room_intro = input('room_intro', '');
|
$room_intro = input('room_intro', '');
|
||||||
|
$password = input('room_password');
|
||||||
|
|
||||||
$signCount = db::name('vs_user_sign')->where(['parent_user_id' => $this->uid ,'end_time' => ['>', time()]] )->count();
|
$signCount = db::name('vs_user_sign')->where(['parent_user_id' => $this->uid ,'end_time' => ['>', time()]] )->count();
|
||||||
$num = get_system_config_value('sign_num_per_room');
|
$num = get_system_config_value('sign_num_per_room');
|
||||||
@@ -25,7 +26,7 @@ class Room extends BaseCom
|
|||||||
|
|
||||||
$key_name = "api:room:user_create_room:" . $this->uid;
|
$key_name = "api:room:user_create_room:" . $this->uid;
|
||||||
redis_lock_exits($key_name);
|
redis_lock_exits($key_name);
|
||||||
$reslut = model('Room')->user_create_room($this->uid, $room_name, $room_cover, $room_intro,0,0);
|
$reslut = model('Room')->user_create_room($this->uid, $room_name, $room_cover, $room_intro,0,0,$password);
|
||||||
redis_unlock($key_name);
|
redis_unlock($key_name);
|
||||||
|
|
||||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||||
@@ -140,7 +141,10 @@ class Room extends BaseCom
|
|||||||
public function join_room()
|
public function join_room()
|
||||||
{
|
{
|
||||||
$room_id = input('room_id', 0);
|
$room_id = input('room_id', 0);
|
||||||
$password = input('password', '');
|
if($room_id == 0){
|
||||||
|
return V(0, '房间不存在');
|
||||||
|
}
|
||||||
|
$password = input('room_password');
|
||||||
|
|
||||||
//检测系统是否维护中
|
//检测系统是否维护中
|
||||||
$is_maintenance = get_system_config_value('is_maintenance');
|
$is_maintenance = get_system_config_value('is_maintenance');
|
||||||
@@ -190,30 +194,6 @@ class Room extends BaseCom
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//直播间送礼【1.6废弃】
|
|
||||||
//
|
|
||||||
public function room_give_gift()
|
|
||||||
{
|
|
||||||
$key_name = "api:room:gift:" . $this->uid;
|
|
||||||
redis_lock_exit($key_name);
|
|
||||||
$room_id = input('room_id', 0);
|
|
||||||
$gift_id = input('gift_id', 0);
|
|
||||||
$gift_num = input('gift_num', 1);
|
|
||||||
$to_uid = input('to_uid', 0);//收礼人ID,逗号隔开的字符串
|
|
||||||
$type = input('type', 1);//1金币购买 2送背包礼物
|
|
||||||
$pit_number = input('pit_number', 0);
|
|
||||||
$heart_id = input('heart_id', 0);
|
|
||||||
|
|
||||||
$pool_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value');
|
|
||||||
if($gift_id == $pool_gift_id){
|
|
||||||
$reslut = model('Lottery')->gift($this->uid, $to_uid, $gift_id, $room_id,$gift_num);
|
|
||||||
}else{
|
|
||||||
$reslut = model('Room')->room_gift($this->uid, $to_uid, $gift_id, $gift_num, $type, $room_id, $pit_number,$heart_id);
|
|
||||||
}
|
|
||||||
redis_unlock($key_name);
|
|
||||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
|
||||||
}
|
|
||||||
|
|
||||||
//房间送礼 背包一键全清
|
//房间送礼 背包一键全清
|
||||||
public function room_gift_all_clear()
|
public function room_gift_all_clear()
|
||||||
{
|
{
|
||||||
@@ -277,6 +257,8 @@ class Room extends BaseCom
|
|||||||
$reslut = model('HeadLine')->current_headline();
|
$reslut = model('HeadLine')->current_headline();
|
||||||
return V(1, '成功', $reslut);
|
return V(1, '成功', $reslut);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//发(抢)头条
|
//发(抢)头条
|
||||||
public function send_headline()
|
public function send_headline()
|
||||||
{
|
{
|
||||||
@@ -327,11 +309,77 @@ class Room extends BaseCom
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//房间类型列表
|
||||||
|
public function room_type_list()
|
||||||
|
{
|
||||||
|
$http = get_system_config_value("web_site");
|
||||||
|
//1-交友,2-拍卖,7-互娱,8-交友(不要了),9-点唱,10-签约,11-酒吧房
|
||||||
|
$reslut = [
|
||||||
|
[
|
||||||
|
'id' => 1,
|
||||||
|
'name' => '交友',
|
||||||
|
'icon' => $http.'/data/avatar/head_pic.png',
|
||||||
|
'sort' => 1,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 2,
|
||||||
|
'name' => '拍卖',
|
||||||
|
'icon' => $http.'/data/avatar/head_pic.png',
|
||||||
|
'sort' => 2,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 7,
|
||||||
|
'name' => '互娱',
|
||||||
|
'icon' => $http.'/data/avatar/head_pic.png',
|
||||||
|
'sort' => 3,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 9,
|
||||||
|
'name' => '点唱',
|
||||||
|
'icon' => $http.'/data/avatar/head_pic.png',
|
||||||
|
'sort' => 4,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 10,
|
||||||
|
'name' => '签约',
|
||||||
|
'icon' => $http.'/data/avatar/head_pic.png',
|
||||||
|
'sort' => 5,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 11,
|
||||||
|
'name' => '酒吧',
|
||||||
|
'icon' => $http.'/data/avatar/head_pic.png',
|
||||||
|
'sort' => 6,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 99,
|
||||||
|
'name' => '练歌',
|
||||||
|
'icon' => $http.'/data/avatar/head_pic.png',
|
||||||
|
'sort' => 7,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
//根据sort 排序
|
||||||
|
usort($reslut, function ($a, $b) {
|
||||||
|
return $a['sort'] - $b['sort'];
|
||||||
|
});
|
||||||
|
return V(1, '成功', $reslut);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//修改房间类型
|
//修改房间类型
|
||||||
public function change_room_type()
|
public function change_room_type()
|
||||||
{
|
{
|
||||||
$room_id = input('room_id', 0);
|
$room_id = input('room_id', 0);
|
||||||
$type = input('type', 1);//1-交友,2-拍卖,7-互娱,8-交友(不要了),9-点唱,10-签约,11-酒吧房
|
$type = input('type', 1);//1-交友,2-拍卖,7-互娱,9-点唱,10-签约,11-酒吧房,99-练歌
|
||||||
|
|
||||||
|
if(!$room_id || !$type){
|
||||||
|
return V(0, '参数错误');
|
||||||
|
}
|
||||||
|
$owner = db::name('vs_room')->where(['id' => $room_id, 'user_id' => $this->uid])->field('id')->find();
|
||||||
|
$host = db::name('vs_room_host')->where(['room_id' => $room_id, 'user_id' => $this->uid,'delete_time' => null])->find();
|
||||||
|
if(!$owner && !$host){
|
||||||
|
return V(0, '没有权限操作');
|
||||||
|
}
|
||||||
$reslut = model('Room')->change_room_type($this->uid, $room_id, $type);
|
$reslut = model('Room')->change_room_type($this->uid, $room_id, $type);
|
||||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,9 +31,12 @@ class SendGift extends BaseCom
|
|||||||
}
|
}
|
||||||
|
|
||||||
//获取幸运币
|
//获取幸运币
|
||||||
$pool_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value');
|
$pool_gift_ids = Db::name('bb_lottery_config')->column('value', 'key');
|
||||||
if($gift_id == $pool_gift_id){//送的是幸运币
|
//转成数组
|
||||||
$reslut = model('Lottery')->gift($this->uid, $to_uid, $gift_id, $room_id,$gift_num);
|
$pool_gift_id_arr = [$pool_gift_ids['pool_gift_id']??0,$pool_gift_ids['pool_gift_id_5']??0,$pool_gift_ids['pool_gift_id_10']??0];
|
||||||
|
|
||||||
|
if(in_array($gift_id, $pool_gift_id_arr)){//送的是幸运币
|
||||||
|
$reslut = model('Lottery')->gift($this->uid, $to_uid, $gift_id, $room_id,$gift_num,$pool_gift_ids);
|
||||||
redis_unlocks($key_name);
|
redis_unlocks($key_name);
|
||||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -9,12 +9,16 @@ use think\Log;
|
|||||||
class Wechat extends Controller
|
class Wechat extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
private string $appId = 'wx0f0c0c0c0c0c0c0c';
|
||||||
|
private string $appSecret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
|
||||||
|
|
||||||
|
/*
|
||||||
* 核心:用code换取openid的方法
|
* 核心:用code换取openid的方法
|
||||||
* @param string $code 微信回调带来的code
|
* @param string $code 微信回调带来的code
|
||||||
* @return string|bool 成功返回openid,失败返回false
|
* @return string|bool 成功返回openid,失败返回false
|
||||||
*/
|
*/
|
||||||
private function exchangeCodeForOpenId()
|
|
||||||
|
public function exchangeOpenId()
|
||||||
{
|
{
|
||||||
$code = input('code', 0);
|
$code = input('code', 0);
|
||||||
|
|
||||||
@@ -41,7 +45,7 @@ class Wechat extends Controller
|
|||||||
if (curl_errno($ch)) {
|
if (curl_errno($ch)) {
|
||||||
Log::error('[微信授权] 请求失败:' . curl_error($ch));
|
Log::error('[微信授权] 请求失败:' . curl_error($ch));
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
return false;
|
return V(0, '[微信授权] 请求失败:' . curl_error($ch));
|
||||||
}
|
}
|
||||||
|
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
@@ -52,12 +56,12 @@ class Wechat extends Controller
|
|||||||
$data = json_decode($response, true);
|
$data = json_decode($response, true);
|
||||||
|
|
||||||
if (empty($data) || isset($data['errcode'])) {
|
if (empty($data) || isset($data['errcode'])) {
|
||||||
Log::error('[微信授权] 解析失败或返回错误', $data);
|
Log::error('[微信授权] 解析失败或返回错误'.json_encode($data));
|
||||||
return false;
|
return V(0, '[微信授权] 解析失败或返回错误');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 成功获取到openid
|
// 成功获取到openid
|
||||||
return $data['openid'] ?? false;
|
return V(1, '获取成功', $data['openid']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -66,15 +70,17 @@ class Wechat extends Controller
|
|||||||
* @param string $user_code 用户的user_code
|
* @param string $user_code 用户的user_code
|
||||||
* @return array|bool 成功返回用户信息,失败返回false
|
* @return array|bool 成功返回用户信息,失败返回false
|
||||||
*/
|
*/
|
||||||
public function getUserInfo($user_code)
|
public function getUserInfo()
|
||||||
{
|
{
|
||||||
|
$user_code = input('user_code', 0);
|
||||||
$user_info = db::name('user')
|
$user_info = db::name('user')
|
||||||
->field('id user_id,nickname,avatar,mobile')
|
->field('id user_id,nickname,avatar,mobile,user_code')
|
||||||
->where(['u.user_code' => $user_code,'u.status' => ['<>',0]])->find();
|
->where(['user_code' => $user_code,'status' => ['<>',0]])->find();
|
||||||
if(!$user_info){
|
if(!$user_info){
|
||||||
return ['code' => 0, 'msg' => '用户不存在或已注销', 'data' => null];
|
return ['code' => 0, 'msg' => '用户不存在或已注销', 'data' => null];
|
||||||
}
|
}
|
||||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $user_info];
|
|
||||||
|
return V(1, '获取成功', $user_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -83,14 +89,15 @@ class Wechat extends Controller
|
|||||||
* @param string $user_code 用户的user_code
|
* @param string $user_code 用户的user_code
|
||||||
* @return array|bool 充值金额,失败返回false
|
* @return array|bool 充值金额,失败返回false
|
||||||
*/
|
*/
|
||||||
public function getRechargeMoney($user_code)
|
public function getRechargeMoney()
|
||||||
{
|
{
|
||||||
$money_coin = [
|
$money_coin = [
|
||||||
['coin' => '1', 'money' => '0.10'],
|
['coin' => '1', 'money' => '0.10'],
|
||||||
['coin' => '60', 'money' => '6.00'],
|
['coin' => '60', 'money' => '6.00'],
|
||||||
['coin' => '1000', 'money' => '100.00'],
|
['coin' => '1000', 'money' => '100.00'],
|
||||||
];
|
];
|
||||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $money_coin];
|
|
||||||
|
return V(1, '获取成功', $money_coin);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ class Xintiao extends BaseCom
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
//查询房间是否热门房间
|
//查询房间是否热门房间
|
||||||
$is_hot_room = db::name('vs_room')->where(['id' => $room_id,'is_hot' => 1])->find();
|
$is_hot_room = db::name('vs_room')->where(['id' => $room_id,'is_hot' => 2])->find();
|
||||||
if($is_hot_room){
|
if($is_hot_room){
|
||||||
//任务:18-每日在线时长 5 分钟
|
//任务:18-每日在线时长 5 分钟
|
||||||
model('Tasks')->tasks_complete($user_id,18);
|
model('Tasks')->tasks_complete($user_id,18);
|
||||||
|
|||||||
@@ -23,18 +23,18 @@ class BlindBoxTurntableGift extends Model
|
|||||||
public function get_gift_list($gift_bag_id,$room_id)
|
public function get_gift_list($gift_bag_id,$room_id)
|
||||||
{
|
{
|
||||||
$box = db::name('vs_gift_bag')->where('id',$gift_bag_id)->find();
|
$box = db::name('vs_gift_bag')->where('id',$gift_bag_id)->find();
|
||||||
$gifts = db::name('vs_gift_bag_detail')->where('gift_bag_id',$gift_bag_id)->order("id desc")->select();
|
$gifts = db::name('vs_gift_bag_detail')->alias('a')
|
||||||
|
->field('a.*,aa.gid,aa.gift_name,aa.base_image,aa.play_image,aa.gift_price')
|
||||||
|
->join('vs_gift aa','a.foreign_id = aa.gid')
|
||||||
|
->where('gift_bag_id',$gift_bag_id)->order("gift_price desc")->select();
|
||||||
$gift_list = [];
|
$gift_list = [];
|
||||||
foreach ($gifts as $key => $value) {
|
foreach ($gifts as $key => $value) {
|
||||||
$gift_data = db::name('vs_gift')->where('gid',$value['foreign_id'])->where('delete_time',0)->find();
|
$gift_list[$key]['number'] = $key;
|
||||||
if($gift_data){
|
$gift_list[$key]['gift_id'] = $value['gid'];
|
||||||
$gift_list[$key]['number'] = $key;
|
$gift_list[$key]['gift_name'] = $value['gift_name'];
|
||||||
$gift_list[$key]['gift_id'] = $gift_data['gid'];
|
$gift_list[$key]['base_image'] = $value['base_image'];
|
||||||
$gift_list[$key]['gift_name'] = $gift_data['gift_name'];
|
$gift_list[$key]['play_image'] = $value['play_image'];
|
||||||
$gift_list[$key]['base_image'] = $gift_data['base_image'];
|
$gift_list[$key]['gift_price'] = $value['gift_price'];
|
||||||
$gift_list[$key]['play_image'] = $gift_data['play_image'];
|
|
||||||
$gift_list[$key]['gift_price'] = $gift_data['gift_price'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$ext = json_decode($box['ext'],true);
|
$ext = json_decode($box['ext'],true);
|
||||||
$box_gift = Db::name('vs_gift')->where('gid',$ext['gift_id'])->find();
|
$box_gift = Db::name('vs_gift')->where('gid',$ext['gift_id'])->find();
|
||||||
@@ -464,10 +464,32 @@ class BlindBoxTurntableGift extends Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
//盲盒转盘开启状态
|
//盲盒转盘开启状态
|
||||||
public function blind_box_status(){
|
public function blind_box_status($user_id=0){
|
||||||
$gift_bag_ids = [11,12];
|
$gift_bag_ids = [11,12,60,61];
|
||||||
$gift_bag = db::name('vs_gift_bag')->where(['id'=>['in',$gift_bag_ids]])->select();
|
$gift_bag = db::name('vs_gift_bag')->where(['id'=>['in',$gift_bag_ids]])->select();
|
||||||
|
$open_monster_status = get_system_config_value('open_monster_status');
|
||||||
|
$fun_activities_recharge_restrictions = get_system_config_value('fun_activities_recharge_restrictions');
|
||||||
|
if($fun_activities_recharge_restrictions ==0){
|
||||||
|
return ['code' => 0, 'msg' => '趣味活动关闭', 'data' => null];
|
||||||
|
}
|
||||||
|
//用户充值金额
|
||||||
|
$user_recharge_money = db::name('vs_user_recharge')->where(['user_id'=>$user_id,'pay_status'=>2])->sum('money');
|
||||||
|
//内测用户
|
||||||
|
//先从cache中获取
|
||||||
|
$inside_uid = Cache::get('inside_uid');
|
||||||
|
if(!$inside_uid){
|
||||||
|
$inside_uid = get_system_config_value('inside_uid');
|
||||||
|
//缓存 并设置缓存时间
|
||||||
|
Cache::set('inside_uid',$inside_uid,3600);
|
||||||
|
}
|
||||||
|
$inside_uid = explode(',',$inside_uid);
|
||||||
|
if(($user_recharge_money < $fun_activities_recharge_restrictions) && !in_array($user_id,$inside_uid)){
|
||||||
|
return ['code' => 0, 'msg' => '充值金额不足', 'data' => null];
|
||||||
|
}
|
||||||
foreach ($gift_bag as $bag){
|
foreach ($gift_bag as $bag){
|
||||||
|
if($bag['id']==60 && $open_monster_status ==0){
|
||||||
|
$bag['status'] = 0;
|
||||||
|
}
|
||||||
if($bag['status'] == 1){
|
if($bag['status'] == 1){
|
||||||
$result_data[] = [
|
$result_data[] = [
|
||||||
'gift_bag_id' => $bag['id'],
|
'gift_bag_id' => $bag['id'],
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
|||||||
public function draw_gift(int $gift_bag_id, int $user_id, string $gift_user_ids, $num = 1, $room_id = 0, $heart_id = 0, $auction_id = 0)
|
public function draw_gift(int $gift_bag_id, int $user_id, string $gift_user_ids, $num = 1, $room_id = 0, $heart_id = 0, $auction_id = 0)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
$bag_data = db::name("vs_gift_bag")->field('id,status')->where('id', $gift_bag_id)->find();
|
||||||
|
if($bag_data['status']==0){ //其他转盘游戏
|
||||||
|
return ['code' => 0, 'msg' => '游戏已关闭', 'data' => null];
|
||||||
|
}
|
||||||
// 收礼人
|
// 收礼人
|
||||||
$gift_user_ids = explode(',', $gift_user_ids);
|
$gift_user_ids = explode(',', $gift_user_ids);
|
||||||
$total_num = $num * count($gift_user_ids); //总数量
|
$total_num = $num * count($gift_user_ids); //总数量
|
||||||
@@ -1074,9 +1078,13 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
|||||||
{
|
{
|
||||||
$resultList = [];
|
$resultList = [];
|
||||||
foreach ($giftCounts as $gift) {
|
foreach ($giftCounts as $gift) {
|
||||||
|
$gift_data = Db::name('vs_gift')->where(['gid'=>$gift['gift_id']])->find();
|
||||||
$resultList[] = [
|
$resultList[] = [
|
||||||
'gift_id' => $gift['gift_id'],
|
'gift_id' => $gift['gift_id'],
|
||||||
'count' => $gift['count']
|
'count' => $gift['count'],
|
||||||
|
'gift_price' => $gift_data['gift_price'],
|
||||||
|
'gift_name' => $gift_data['gift_name'],
|
||||||
|
'base_image' => $gift_data['base_image'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
@@ -1105,6 +1113,10 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
|||||||
return ['code' => 0, 'msg' => '用户不在房间,无法获取房主信息', 'data' => null];
|
return ['code' => 0, 'msg' => '用户不在房间,无法获取房主信息', 'data' => null];
|
||||||
}
|
}
|
||||||
$gift_bag_id = 13;
|
$gift_bag_id = 13;
|
||||||
|
$bag_data = db::name("vs_gift_bag")->field('id,status')->where('id', $gift_bag_id)->find();
|
||||||
|
if($bag_data['status']==0){ //其他转盘游戏
|
||||||
|
return ['code' => 0, 'msg' => '游戏已关闭', 'data' => null];
|
||||||
|
}
|
||||||
// 1. 获取并缓存盲盒配置
|
// 1. 获取并缓存盲盒配置
|
||||||
$ext = $this->getCachedGiftBag($gift_bag_id); //获取转盘信息
|
$ext = $this->getCachedGiftBag($gift_bag_id); //获取转盘信息
|
||||||
$bag_gift_price = $ext['xlh_box_price'] * $num;
|
$bag_gift_price = $ext['xlh_box_price'] * $num;
|
||||||
@@ -1536,6 +1548,18 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
|||||||
public function draw_gift_drop_bag($gift_bag_id, $user_id, $num = 1, $room_id = 0)
|
public function draw_gift_drop_bag($gift_bag_id, $user_id, $num = 1, $room_id = 0)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
$open_monster_status = get_system_config_value('open_monster_status');
|
||||||
|
$fun_activities_recharge_restrictions = get_system_config_value('fun_activities_recharge_restrictions');
|
||||||
|
if($fun_activities_recharge_restrictions == 0){
|
||||||
|
return ['code' => 0, 'msg' => '趣味活动关闭', 'data' => null];
|
||||||
|
}
|
||||||
|
if($gift_bag_id ==60 && $open_monster_status ==0){ //恋仙传说
|
||||||
|
return ['code' => 0, 'msg' => '游戏已关闭', 'data' => null];
|
||||||
|
}
|
||||||
|
$bag_data = db::name("vs_gift_bag")->field('id,status')->where('id', $gift_bag_id)->find();
|
||||||
|
if(in_array($gift_bag_id,[11,12,61]) && $bag_data['status']==0){ //其他转盘游戏
|
||||||
|
return ['code' => 0, 'msg' => '游戏已关闭', 'data' => null];
|
||||||
|
}
|
||||||
// 参数验证
|
// 参数验证
|
||||||
$validation_result = $this->validateDrawParams($gift_bag_id, $user_id, $num);
|
$validation_result = $this->validateDrawParams($gift_bag_id, $user_id, $num);
|
||||||
if ($validation_result['code'] !== 1) {
|
if ($validation_result['code'] !== 1) {
|
||||||
|
|||||||
@@ -18,8 +18,10 @@ class Decorate extends Model
|
|||||||
protected $createTime = 'createtime';
|
protected $createTime = 'createtime';
|
||||||
protected $updateTime = 'updatetime';
|
protected $updateTime = 'updatetime';
|
||||||
// 定义字段类型 1头像框 2坐骑 3麦圈 6个人靓号 7房间靓号 8公会靓号
|
// 定义字段类型 1头像框 2坐骑 3麦圈 6个人靓号 7房间靓号 8公会靓号
|
||||||
public $TypeArray = [1=>'头像框',12=>'降身卡',2=>'坐骑',9=>'聊天气泡',6=>'个人靓号',7=>'房间靓号',8=>'公会靓号',3=>'麦圈',10=>'CP特效',11=>'CP装扮'];
|
public $TypeArray = [1=>'头像框',12=>'降身卡',2=>'坐骑',9=>'聊天气泡',6=>'个人靓号',7=>'房间靓号',8=>'公会靓号',3=>'麦圈',10=>'CP特效',11=>'CP装扮',13=>"房间热度卡"];
|
||||||
protected $FromType = [1=>'购买',2=>'后台赠送',3=>'礼盒开奖',4=>'好友赠送',5=>'首充赠送',6=>'天降好礼获得',7=>'财富等级特权赠送',8=>'新人充值好礼',9=>'爵位购买赠送',10=>'任务奖励',11=>"每日签到"];
|
protected $FromType = [1=>'购买',2=>'后台赠送',3=>'礼盒开奖',4=>'好友赠送',5=>'首充赠送',6=>'天降好礼获得',7=>'财富等级特权赠送',8=>'新人充值好礼',9=>'爵位购买赠送',10=>'任务奖励',11=>"每日签到"];
|
||||||
|
//特殊装扮(卡片类型 可直接购买 不用配置天数价格)
|
||||||
|
public $SpecialType = [12=>'降身卡',13=>'房间热度卡'];
|
||||||
public function __construct($data = [])
|
public function __construct($data = [])
|
||||||
{
|
{
|
||||||
parent::__construct($data);
|
parent::__construct($data);
|
||||||
@@ -27,7 +29,7 @@ class Decorate extends Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
//获取装扮类型
|
//获取装扮类型
|
||||||
public function get_type_list($have_hot = 0)
|
public function get_type_list($have_hot = 0,$from=1)
|
||||||
{
|
{
|
||||||
$no_show_ids = [7,8,3,10,11];
|
$no_show_ids = [7,8,3,10,11];
|
||||||
$label = $this->TypeArray;
|
$label = $this->TypeArray;
|
||||||
@@ -40,6 +42,11 @@ class Decorate extends Model
|
|||||||
if (in_array($k, $no_show_ids)) {
|
if (in_array($k, $no_show_ids)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if($from==2){
|
||||||
|
if($k==13){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
$data[$i]['id'] = $k;
|
$data[$i]['id'] = $k;
|
||||||
$data[$i]['name'] = $v;
|
$data[$i]['name'] = $v;
|
||||||
++$i;
|
++$i;
|
||||||
@@ -77,9 +84,9 @@ class Decorate extends Model
|
|||||||
'a.type' => $type,
|
'a.type' => $type,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
if($type == 12){
|
if(in_array($type, array_keys($this->SpecialType))){
|
||||||
$map = [
|
$map = [
|
||||||
'type' => 12,
|
'type' => $type,
|
||||||
'delete_time' => 0,
|
'delete_time' => 0,
|
||||||
'show_status' => 1,
|
'show_status' => 1,
|
||||||
'is_buy' => 1
|
'is_buy' => 1
|
||||||
@@ -114,7 +121,7 @@ class Decorate extends Model
|
|||||||
if (!$decorate) {
|
if (!$decorate) {
|
||||||
return ['code' => 0, 'msg' => '参数错误'];
|
return ['code' => 0, 'msg' => '参数错误'];
|
||||||
}
|
}
|
||||||
if($decorate['type'] == 12){
|
if(in_array($decorate['type'], array_keys($this->SpecialType))){
|
||||||
$result['title'] = $decorate['title'];
|
$result['title'] = $decorate['title'];
|
||||||
$result['price'] = (int)$decorate['price'];
|
$result['price'] = (int)$decorate['price'];
|
||||||
$result['base_image'] = localpath_to_netpath($decorate['base_image']);
|
$result['base_image'] = localpath_to_netpath($decorate['base_image']);
|
||||||
@@ -149,7 +156,7 @@ class Decorate extends Model
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function pay_decorate($uid, $did, $day=0,$from_type=1,$give_uid=0,$log_remark="",$num=1){
|
public function pay_decorate($uid, $did, $day=0,$from_type=1,$give_uid=0,$log_remark="",$num=1){
|
||||||
if(empty($day) && $from_type == 12){
|
if(empty($day) && in_array($from_type,array_keys($this->SpecialType))){
|
||||||
$day = 0;
|
$day = 0;
|
||||||
}else{
|
}else{
|
||||||
$day = db::name('vs_decorate_price')->where(['did'=>$did])->order('day asc')->value('day');
|
$day = db::name('vs_decorate_price')->where(['did'=>$did])->order('day asc')->value('day');
|
||||||
@@ -171,7 +178,7 @@ class Decorate extends Model
|
|||||||
if(!$decorate_info){
|
if(!$decorate_info){
|
||||||
return ['code' => 0, 'msg' => '该装扮不存在'.$did, 'data' => null];
|
return ['code' => 0, 'msg' => '该装扮不存在'.$did, 'data' => null];
|
||||||
}
|
}
|
||||||
if($decorate_info['type'] != 12){
|
if(!in_array($decorate_info['type'],array_keys($this->SpecialType))){
|
||||||
//该天数是否存在
|
//该天数是否存在
|
||||||
$map = [];
|
$map = [];
|
||||||
$map = [
|
$map = [
|
||||||
@@ -251,7 +258,7 @@ class Decorate extends Model
|
|||||||
$data['num'] = 1;
|
$data['num'] = 1;
|
||||||
$result = db::name('vs_user_decorate')->insert($data);
|
$result = db::name('vs_user_decorate')->insert($data);
|
||||||
}else{
|
}else{
|
||||||
if($decorate_info['type'] == 12){
|
if(in_array($decorate_info['type'],array_keys($this->SpecialType))){
|
||||||
$result = db::name('vs_user_decorate')->where('udid', $user_decorate_data['udid'])->update([
|
$result = db::name('vs_user_decorate')->where('udid', $user_decorate_data['udid'])->update([
|
||||||
'is_using' => 2,
|
'is_using' => 2,
|
||||||
'num' => $user_decorate_data['num'] + $num,
|
'num' => $user_decorate_data['num'] + $num,
|
||||||
@@ -290,7 +297,7 @@ class Decorate extends Model
|
|||||||
if($decorate_price_info['day'] ==0){
|
if($decorate_price_info['day'] ==0){
|
||||||
$insert_data['end_time'] = 0; //永久礼物
|
$insert_data['end_time'] = 0; //永久礼物
|
||||||
}
|
}
|
||||||
$insert_data['day_num'] = $day;
|
$insert_data['day_num'] = $day??0;
|
||||||
$insert_data['pay_price'] = $pay_price ;
|
$insert_data['pay_price'] = $pay_price ;
|
||||||
$insert_data['special_num'] = $decorate_info['special_num'];
|
$insert_data['special_num'] = $decorate_info['special_num'];
|
||||||
$insert_data['give_uid'] = $give_uid;
|
$insert_data['give_uid'] = $give_uid;
|
||||||
@@ -315,10 +322,10 @@ class Decorate extends Model
|
|||||||
|
|
||||||
//用户装扮列表
|
//用户装扮列表
|
||||||
public function user_decorate($uid, $type,$page=1, $limit=10){
|
public function user_decorate($uid, $type,$page=1, $limit=10){
|
||||||
if($type == 12){
|
if(in_array($type, array_keys($this->SpecialType))){
|
||||||
$reslut = db::name('vs_user_decorate')
|
$reslut = db::name('vs_user_decorate')
|
||||||
->alias('ud')->join('vs_decorate d', 'ud.did = d.did')
|
->alias('ud')->join('vs_decorate d', 'ud.did = d.did')
|
||||||
->field('ud.udid,ud.user_id,ud.is_using,ud.end_time,ud.is_perpetual,ud.special_num,d.title,d.base_image,d.play_image,d.type,ud.num,d.ext_value')
|
->field('ud.udid,ud.user_id,ud.is_using,ud.end_time,ud.is_perpetual,ud.special_num,d.title,d.base_image,d.play_image,d.type,ud.num,d.ext_value,d.price')
|
||||||
->where('ud.user_id', $uid)
|
->where('ud.user_id', $uid)
|
||||||
->where('ud.type', $type)
|
->where('ud.type', $type)
|
||||||
->where(['ud.num'=>[">",0]])
|
->where(['ud.num'=>[">",0]])
|
||||||
@@ -327,7 +334,7 @@ class Decorate extends Model
|
|||||||
}else{
|
}else{
|
||||||
$reslut = db::name('vs_user_decorate')
|
$reslut = db::name('vs_user_decorate')
|
||||||
->alias('ud')->join('vs_decorate d', 'ud.did = d.did')
|
->alias('ud')->join('vs_decorate d', 'ud.did = d.did')
|
||||||
->field('ud.udid,ud.user_id,ud.is_using,ud.end_time,ud.is_perpetual,ud.special_num,d.title,d.base_image,d.play_image,d.type')
|
->field('ud.udid,ud.user_id,ud.is_using,ud.end_time,ud.is_perpetual,ud.special_num,d.title,d.base_image,d.play_image,d.type,d.price')
|
||||||
->where('ud.user_id', $uid)
|
->where('ud.user_id', $uid)
|
||||||
->where('ud.type', $type)
|
->where('ud.type', $type)
|
||||||
->where(['ud.end_time'=>[">=",time()]])
|
->where(['ud.end_time'=>[">=",time()]])
|
||||||
@@ -347,7 +354,7 @@ class Decorate extends Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 设置用户装修
|
// 设置用户装修
|
||||||
public function set_user_decorate($uid,$udid)
|
public function set_user_decorate($uid,$udid,$room_id,$num=1)
|
||||||
{
|
{
|
||||||
$map = [];
|
$map = [];
|
||||||
$map = [
|
$map = [
|
||||||
@@ -358,7 +365,7 @@ class Decorate extends Model
|
|||||||
if (empty($info)) {
|
if (empty($info)) {
|
||||||
return ['code' => 0, 'msg' => '装扮不存在', 'data' => null];
|
return ['code' => 0, 'msg' => '装扮不存在', 'data' => null];
|
||||||
}
|
}
|
||||||
if($info['type'] == 12){
|
if(in_array($info['type'],array_keys($this->SpecialType))){
|
||||||
if ($info['num']-1 < 0) {
|
if ($info['num']-1 < 0) {
|
||||||
return ['code' => 0, 'msg' => '无可用装扮', 'data' => null];
|
return ['code' => 0, 'msg' => '无可用装扮', 'data' => null];
|
||||||
}
|
}
|
||||||
@@ -391,8 +398,8 @@ class Decorate extends Model
|
|||||||
$data = [];
|
$data = [];
|
||||||
$data['is_using'] = 1;
|
$data['is_using'] = 1;
|
||||||
$data['updatetime'] = time();
|
$data['updatetime'] = time();
|
||||||
if($info['type'] == 12){
|
if(in_array($info['type'],array_keys($this->SpecialType))){
|
||||||
$data['num'] = $info['num'] - 1;
|
$data['num'] = $info['num'] - $num;
|
||||||
}
|
}
|
||||||
$reslut = Db::name('vs_user_decorate')->where($map)->update($data);
|
$reslut = Db::name('vs_user_decorate')->where($map)->update($data);
|
||||||
if (!$reslut) {
|
if (!$reslut) {
|
||||||
@@ -426,7 +433,37 @@ class Decorate extends Model
|
|||||||
'createtime'=> time()
|
'createtime'=> time()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}else{
|
}elseif($info['type'] == 13){//房间热度卡 增加房间热度
|
||||||
|
if (empty($room_id)) {
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||||
|
}
|
||||||
|
$room_info = db::name('vs_room')->where(['id' => $room_id])->find();
|
||||||
|
if (empty($room_info)) {
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => '房间不存在', 'data' => null];
|
||||||
|
}
|
||||||
|
$increase_hot_value_all = 0;
|
||||||
|
for ($i = 0; $i < $num; $i++) {
|
||||||
|
$increase_hot_value = db::name('vs_decorate')->where(['did' => $info['did']])->value('ext_value') ?? 0;
|
||||||
|
if ($room_info['today_hot_value'] <= $increase_hot_value) {
|
||||||
|
db::name('vs_room')->where(['id' => $room_id])->update(['today_hot_value' => 0]);
|
||||||
|
} else {
|
||||||
|
db::name('vs_room')->where(['id' => $room_id])->setInc('today_hot_value', $increase_hot_value);
|
||||||
|
}
|
||||||
|
$increase_hot_value_all += $increase_hot_value;
|
||||||
|
}
|
||||||
|
//记录日志
|
||||||
|
db::name('vs_room_hot_up_log')->insert([
|
||||||
|
'did' => $udid,
|
||||||
|
'user_id' => $uid,
|
||||||
|
'room_id' => $room_id,
|
||||||
|
'hot_value' => $increase_hot_value_all,
|
||||||
|
'before_hot_value' => $room_info['today_hot_value'],
|
||||||
|
'end_time' => date('Y-m-d H:00:00', time()),
|
||||||
|
'createtime' => time()
|
||||||
|
]);
|
||||||
|
} else{
|
||||||
//推送信息去所在房间
|
//推送信息去所在房间
|
||||||
//查询当前所在房间
|
//查询当前所在房间
|
||||||
$room_id = db::name('vs_room_visitor')->where(['user_id' => $uid])->order('id' , 'desc')->value('room_id');
|
$room_id = db::name('vs_room_visitor')->where(['user_id' => $uid])->order('id' , 'desc')->value('room_id');
|
||||||
@@ -545,4 +582,159 @@ class Decorate extends Model
|
|||||||
}
|
}
|
||||||
return $reslut;
|
return $reslut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//房间热度卡使用
|
||||||
|
public function room_hot_card($uid,$udid,$room_id,$num=1)
|
||||||
|
{
|
||||||
|
$map = [];
|
||||||
|
if($udid){
|
||||||
|
$map = [
|
||||||
|
'user_id' => $uid,
|
||||||
|
'udid' => $udid
|
||||||
|
];
|
||||||
|
$info = db::name('vs_user_decorate')->where($map)->find();
|
||||||
|
if (empty($info)) {
|
||||||
|
return ['code' => 0, 'msg' => '房间热度卡不存在', 'data' => null];
|
||||||
|
}
|
||||||
|
if ($info['num']-$num < 0) {
|
||||||
|
return ['code' => 0, 'msg' => '无可用房间热度卡', 'data' => null];
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$map = [
|
||||||
|
'user_id' => $uid,
|
||||||
|
'type' => 13,
|
||||||
|
'num' => ['>',0]
|
||||||
|
];
|
||||||
|
$info = db::name('vs_user_decorate')->where($map)->select();
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
if($udid){
|
||||||
|
$map = [
|
||||||
|
'user_id' => $uid,
|
||||||
|
'udid' => $udid
|
||||||
|
];
|
||||||
|
$data = [];
|
||||||
|
$data['is_using'] = 1;
|
||||||
|
$data['updatetime'] = time();
|
||||||
|
$data['num'] = $info['num'] - $num;
|
||||||
|
$reslut = Db::name('vs_user_decorate')->where($map)->update($data);
|
||||||
|
if (!$reslut) {
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => "使用失败", 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($room_id)) {
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||||
|
}
|
||||||
|
$room_info = db::name('vs_room')->where(['id' => $room_id])->find();
|
||||||
|
if (empty($room_info)) {
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => '房间不存在', 'data' => null];
|
||||||
|
}
|
||||||
|
$increase_hot_value = db::name('vs_decorate')->where(['did' => $info['did']])->value('ext_value') ?? 0;
|
||||||
|
$increase_hot_value = $increase_hot_value * $num;
|
||||||
|
db::name('vs_room')->where(['id' => $room_id])->setInc('today_hot_value', $increase_hot_value);
|
||||||
|
//记录日志
|
||||||
|
db::name('vs_room_hot_up_log')->insert([
|
||||||
|
'did' => $info['did'],
|
||||||
|
'user_id' => $uid,
|
||||||
|
'room_id' => $room_id,
|
||||||
|
'hot_value' => $increase_hot_value,
|
||||||
|
'before_hot_value' => $room_info['today_hot_value'],
|
||||||
|
'end_time' => date('Y-m-d H:00:00', time()),
|
||||||
|
'createtime' => time()
|
||||||
|
]);
|
||||||
|
//推送消息
|
||||||
|
$FromUserInfo = db::name('user')->where(['id' => $uid])->find();
|
||||||
|
$text1 = $FromUserInfo['nickname'] . ' 在本房间使用了房间热度卡 提升房间'.$increase_hot_value.'热度';
|
||||||
|
$text = [
|
||||||
|
'FromUserInfo' => $FromUserInfo,
|
||||||
|
'ToUserInfo' => null,
|
||||||
|
'GiftInfo' => [
|
||||||
|
'gift_id' => 0,
|
||||||
|
'gift_name' => '房间热度卡',
|
||||||
|
'gift_icon' => "",
|
||||||
|
'play_image' => "",
|
||||||
|
'base_image' => db::name('vs_decorate')->where(['did' => $info['did']])->value('base_image'),
|
||||||
|
],
|
||||||
|
'gift_num' => $num,
|
||||||
|
'text' => $text1
|
||||||
|
];
|
||||||
|
//聊天室推送系统消息
|
||||||
|
model('Chat')->sendMsg(1005,$room_id,$text);
|
||||||
|
}else{
|
||||||
|
$map = [
|
||||||
|
'user_id' => $uid,
|
||||||
|
'type' => 13,
|
||||||
|
'num' => ['>',0]
|
||||||
|
];
|
||||||
|
$data = [];
|
||||||
|
$data['is_using'] = 1;
|
||||||
|
$data['updatetime'] = time();
|
||||||
|
$data['num'] = 0;
|
||||||
|
$result = Db::name('vs_user_decorate')->where($map)->update($data);
|
||||||
|
if (!$result) {
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => "使用失败", 'data' => null];
|
||||||
|
}
|
||||||
|
if (empty($room_id)) {
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||||
|
}
|
||||||
|
$room_info = db::name('vs_room')->where(['id' => $room_id])->find();
|
||||||
|
if (empty($room_info)) {
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => '房间不存在', 'data' => null];
|
||||||
|
}
|
||||||
|
$increase_hot_value_all = 0;
|
||||||
|
foreach ($info as $key => $value) {
|
||||||
|
$increase_hot_value = db::name('vs_decorate')->where(['did' => $value['did']])->value('ext_value') ?? 0;
|
||||||
|
$increase_hot_value = $increase_hot_value * $value['num'];
|
||||||
|
$increase_hot_value_all += $increase_hot_value;
|
||||||
|
}
|
||||||
|
db::name('vs_room')->where(['id' => $room_id])->setInc('today_hot_value', $increase_hot_value_all);
|
||||||
|
//记录日志
|
||||||
|
db::name('vs_room_hot_up_log')->insert([
|
||||||
|
'did' => 0,
|
||||||
|
'user_id' => $uid,
|
||||||
|
'room_id' => $room_id,
|
||||||
|
'hot_value' => $increase_hot_value_all,
|
||||||
|
'before_hot_value' => $room_info['today_hot_value'],
|
||||||
|
'end_time' => date('Y-m-d H:00:00', time()),
|
||||||
|
'createtime' => time()
|
||||||
|
]);
|
||||||
|
//推送消息
|
||||||
|
$FromUserInfo = db::name('user')->where(['id' => $uid])->find();
|
||||||
|
$text1 = $FromUserInfo['nickname'] . ' 在本房间使用了房间热度卡 提升房间'.$increase_hot_value_all.'热度';
|
||||||
|
$text = [
|
||||||
|
'FromUserInfo' => $FromUserInfo,
|
||||||
|
'ToUserInfo' => null,
|
||||||
|
'GiftInfo' => [
|
||||||
|
'gift_id' => 0,
|
||||||
|
'gift_name' => '房间热度卡',
|
||||||
|
'gift_icon' => "",
|
||||||
|
'play_image' => "",
|
||||||
|
'base_image' => db::name('vs_decorate')->where(['did' => $info['did']])->value('base_image'),
|
||||||
|
],
|
||||||
|
'gift_num' => $num,
|
||||||
|
'text' => $text1
|
||||||
|
];
|
||||||
|
//聊天室推送系统消息
|
||||||
|
model('Chat')->sendMsg(1005,$room_id,$text);
|
||||||
|
}
|
||||||
|
// 提交事务
|
||||||
|
Db::commit();
|
||||||
|
//更新装备缓存
|
||||||
|
$cache_key = 'user_base_info_'.$uid;
|
||||||
|
Cache::rm($cache_key);
|
||||||
|
return ['code' => 1, 'msg' => "设置成功", 'data' => null];
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// 回滚事务
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => "设置失败", 'data' => null];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,9 +18,13 @@ class Gift extends Model
|
|||||||
protected $table = 'fa_vs_gift';
|
protected $table = 'fa_vs_gift';
|
||||||
|
|
||||||
//获取礼物类型
|
//获取礼物类型
|
||||||
public function get_gift_label($no_label = [])
|
public function get_gift_label($type,$no_label = [])
|
||||||
{
|
{
|
||||||
|
if($type == 2) {//打赏 不需要热度卡
|
||||||
|
$no_label = [1013,2];
|
||||||
|
}
|
||||||
$giftType = [];
|
$giftType = [];
|
||||||
|
//礼物
|
||||||
$giftTypeData = db::name('vs_gift_label')
|
$giftTypeData = db::name('vs_gift_label')
|
||||||
->where('delete_time',0)
|
->where('delete_time',0)
|
||||||
->where('tid',1)
|
->where('tid',1)
|
||||||
@@ -30,13 +34,51 @@ class Gift extends Model
|
|||||||
foreach ($giftTypeData as $key => $value) {
|
foreach ($giftTypeData as $key => $value) {
|
||||||
$giftType[$key]['id'] = $value['id'];
|
$giftType[$key]['id'] = $value['id'];
|
||||||
$giftType[$key]['name'] = $value['name'];
|
$giftType[$key]['name'] = $value['name'];
|
||||||
|
$giftType[$key]['sort'] = $value['sort'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//增加房间热度卡
|
||||||
|
if (!in_array(1013, $no_label)) {
|
||||||
|
$giftType[] = ['id' => 1013, 'name' => '房间热度卡', 'sort' => 0];
|
||||||
|
}
|
||||||
|
|
||||||
|
//排序 1013排到最前面去
|
||||||
|
usort($giftType, function($a, $b) {
|
||||||
|
return $a['sort'] <=> $b['sort'];
|
||||||
|
});
|
||||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $giftType];
|
return ['code' => 1, 'msg' => '获取成功', 'data' => $giftType];
|
||||||
}
|
}
|
||||||
|
|
||||||
//拉取礼物列表
|
//拉取礼物列表
|
||||||
public function get_gift_list($label = 0,$room_id = 0,$user_id = 0)
|
public function get_gift_list($label = 0,$room_id = 0,$user_id = 0)
|
||||||
{
|
{
|
||||||
|
if($label == 1013){//房间热度卡
|
||||||
|
$list = db::name('vs_user_decorate')
|
||||||
|
->field('a.udid,a.num,b.title,b.base_image,b.price,b.ext_value')
|
||||||
|
->alias('a')
|
||||||
|
->join('vs_decorate b','a.did=b.did')
|
||||||
|
->where([
|
||||||
|
'a.user_id'=>$user_id,
|
||||||
|
'a.type'=>13,
|
||||||
|
'a.num' => ['>',0]
|
||||||
|
])
|
||||||
|
->order('a.num desc')
|
||||||
|
->select();
|
||||||
|
$return_data = [];
|
||||||
|
if($list){
|
||||||
|
foreach ($list as $k=>$v) {
|
||||||
|
$return_data[$k]['gift_id'] = $v['udid'];
|
||||||
|
$return_data[$k]['gift_name'] = $v['title'];
|
||||||
|
$return_data[$k]['base_image'] = $v['base_image'];
|
||||||
|
$return_data[$k]['gift_price'] = $v['price'];
|
||||||
|
$return_data[$k]['num'] = $v['num'];
|
||||||
|
$return_data[$k]['label'] = 1013;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ['code' => 1, 'msg' => '获取成功', 'data' => $return_data];
|
||||||
|
}
|
||||||
|
//其他礼物类型
|
||||||
|
|
||||||
$is_lock = 0;
|
$is_lock = 0;
|
||||||
if ($label == 13) { // 专属礼物
|
if ($label == 13) { // 专属礼物
|
||||||
$Nobility = model('api/Nobility')->getUserNobilityInfo($user_id);
|
$Nobility = model('api/Nobility')->getUserNobilityInfo($user_id);
|
||||||
@@ -60,19 +102,21 @@ class Gift extends Model
|
|||||||
|
|
||||||
$map['delete_time'] = 0;
|
$map['delete_time'] = 0;
|
||||||
$where['is_show'] = 1;
|
$where['is_show'] = 1;
|
||||||
if ($label && $label != 99) {
|
if ($label == 99) { // 拍卖卡关系选择的礼物
|
||||||
$map['label'] = $label;
|
|
||||||
}
|
|
||||||
if ($label == 99) {
|
|
||||||
$gift_price = get_system_config_value('room_love_auction_cion');
|
$gift_price = get_system_config_value('room_love_auction_cion');
|
||||||
$where['gift_price'] = ['>',$gift_price];
|
$where['gift_price'] = ['>',$gift_price];
|
||||||
$where['label'] = ['<>',2];
|
$where['label'] = ['in',[1,5]];
|
||||||
|
}elseif ($label == 100) {// 哥单礼物
|
||||||
|
$gift_price = get_system_config_value('singer_lowest_cion');//歌单最低价格
|
||||||
|
$where['gift_price'] = ['>',$gift_price];
|
||||||
|
$where['label'] = ['in',[1,5]];
|
||||||
|
}elseif($label == 0){// 其他普通礼物
|
||||||
|
$where['label'] = ['in',[1,5]];
|
||||||
|
}else{
|
||||||
|
$map['label'] = $label;
|
||||||
}
|
}
|
||||||
|
|
||||||
$is_open_blind_box_turntable = 1;
|
$is_open_blind_box_turntable = 1;
|
||||||
// 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,icon')->where($map)->where($where)->order('sort desc, gift_price asc')->select();
|
$list = $this->field('gid as gift_id,gift_name,base_image,gift_price,icon')->where($map)->where($where)->order('sort desc, gift_price asc')->select();
|
||||||
if($label==2){
|
if($label==2){
|
||||||
$list_data = [];
|
$list_data = [];
|
||||||
@@ -91,8 +135,11 @@ class Gift extends Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//爆币
|
//爆币
|
||||||
$pool_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value');
|
$pool_gift_id_arr[] = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value');
|
||||||
if($pool_gift_id == $v['gift_id']){
|
$pool_gift_id_arr[] = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id_5'])->value('value');
|
||||||
|
$pool_gift_id_arr[] = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id_10'])->value('value');
|
||||||
|
|
||||||
|
if(in_array($v['gift_id'],$pool_gift_id_arr)){
|
||||||
$v['gift_bag_name'] = "幸运币活动";
|
$v['gift_bag_name'] = "幸运币活动";
|
||||||
$v['rule'] = "幸运羽币";
|
$v['rule'] = "幸运羽币";
|
||||||
$v['rule_url'] = get_system_config_value('web_site')."/api/Page/page_show?id=35";
|
$v['rule_url'] = get_system_config_value('web_site')."/api/Page/page_show?id=35";
|
||||||
|
|||||||
@@ -1005,10 +1005,10 @@ class GiveGift extends Model
|
|||||||
'createtime' => time()
|
'createtime' => time()
|
||||||
];
|
];
|
||||||
|
|
||||||
$res = Db::name('vs_user_money_log')->insert($data);
|
// $res = Db::name('vs_user_money_log')->insert($data);
|
||||||
if(!$res){
|
// if(!$res){
|
||||||
return false;
|
return false;
|
||||||
}
|
// }
|
||||||
|
|
||||||
//根据类型判断是操作金币还是钻石得增加或减少
|
//根据类型判断是操作金币还是钻石得增加或减少
|
||||||
if($money_type == 1){//1金币
|
if($money_type == 1){//1金币
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ namespace app\api\model;
|
|||||||
|
|
||||||
use app\common\controller\Push;
|
use app\common\controller\Push;
|
||||||
use app\common\service\LotteryService;
|
use app\common\service\LotteryService;
|
||||||
|
use app\common\service\LotteryService5;
|
||||||
|
use app\common\service\LotteryService10;
|
||||||
use think\Db;
|
use think\Db;
|
||||||
use think\Exception;
|
use think\Exception;
|
||||||
use think\Log;
|
use think\Log;
|
||||||
@@ -15,7 +17,7 @@ class Lottery extends Model
|
|||||||
* 送礼参与抽奖接口
|
* 送礼参与抽奖接口
|
||||||
* @return json
|
* @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) {
|
if (ceil($num) != $num) {
|
||||||
return ['code' => 0, 'msg' => '打赏礼物数量必须为整数', 'data' => null];
|
return ['code' => 0, 'msg' => '打赏礼物数量必须为整数', 'data' => null];
|
||||||
@@ -47,7 +49,6 @@ class Lottery extends Model
|
|||||||
//送礼 开启事务
|
//送礼 开启事务
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
//扣除用户金币并记录日志
|
//扣除用户金币并记录日志
|
||||||
// $wallet_update = model('api/GiveGift')->change_user_cion_or_earnings_log($send_uid,$all_gift_price,$room_id,1,10,'用户金币购买幸运币礼物');
|
|
||||||
$wallet_update = model('api/UserWallet')->change_user_cion_log($send_uid, $all_gift_price, $room_id, 10, '用户金币购买幸运币礼物');
|
$wallet_update = model('api/UserWallet')->change_user_cion_log($send_uid, $all_gift_price, $room_id, 10, '用户金币购买幸运币礼物');
|
||||||
if(!$wallet_update){
|
if(!$wallet_update){
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
@@ -62,6 +63,21 @@ class Lottery extends Model
|
|||||||
|
|
||||||
//送给一人礼物的总价格(扣除用户的数额)
|
//送给一人礼物的总价格(扣除用户的数额)
|
||||||
$gift_price = $gift_info['gift_price'] * $num;
|
$gift_price = $gift_info['gift_price'] * $num;
|
||||||
|
//幸运币收益率
|
||||||
|
$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){
|
foreach ($toarray as $k => $to_id){
|
||||||
// 1. 记录礼物赠送
|
// 1. 记录礼物赠送
|
||||||
@@ -70,30 +86,24 @@ class Lottery extends Model
|
|||||||
'recv_uid' => $to_id,
|
'recv_uid' => $to_id,
|
||||||
'gift_id' => $gift_id,
|
'gift_id' => $gift_id,
|
||||||
'gift_gold' => $gift_price,
|
'gift_gold' => $gift_price,
|
||||||
'recv_gold' => $gift_price /2 ,
|
'recv_gold' => $recv_coin,
|
||||||
'small_pool_add' => $gift_price /2 ,
|
'small_pool_add' => $small_pool,
|
||||||
'create_time' => time()
|
'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_log($send_uid,$gift_id,$gift_price,$num,$to_id,2,1,0,'送幸运币');
|
$give_gift = model('api/SendGift')->change_user_give_gift_logs($send_uid,$gift_id,$gift_price,$num,$to_id,2,1,0,'送幸运币');
|
||||||
if(!$give_gift){
|
if(!$give_gift){
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
return ['code' => 0, 'msg' => '送礼失败', 'data' => null];
|
return ['code' => 0, 'msg' => '送礼失败', 'data' => null];
|
||||||
}
|
}
|
||||||
//计算收礼人得益
|
//计算收礼人得益
|
||||||
$receiver_earnings = $gift_price /2/get_system_config_value('rmb_coin_ratio');
|
$receiver_earnings = $recv_coin/get_system_config_value('rmb_coin_ratio');
|
||||||
//增加收益并记录日志
|
//增加收益并记录日志
|
||||||
// $receiver = model('api/GiveGift') -> change_user_cion_or_earnings_log($to_id,$receiver_earnings,$room_id,2,11,'收幸运币礼增加收益');
|
$receiver = model('api/UserWallet')->change_user_earnings_log($to_id,$receiver_earnings,$room_id,11,'收幸运币礼物增加收益');
|
||||||
$receiver = model('api/UserWallet')->change_user_earnings_log($to_id,$receiver_earnings,$room_id,11,'收幸运币礼增加收益');
|
|
||||||
|
|
||||||
// //用户魅力等级更新
|
|
||||||
// $user_level = model('api/Level')->user_level_data_update($to_id,$gift_price,2,$room_id);
|
|
||||||
// if(!$user_level){
|
|
||||||
// Db::rollback();
|
|
||||||
// return ['code' => 0, 'msg' => '用户等级更新失败', 'data' => null];
|
|
||||||
// }
|
|
||||||
//增加房间幸运值
|
//增加房间幸运值
|
||||||
db::name('vs_room')->where(['id' => $room_id])->setInc('luck_value',$gift_price);
|
db::name('vs_room')->where(['id' => $room_id])->setInc('luck_value',$gift_price);
|
||||||
db::name('vs_room_luck_value')->insert( [
|
db::name('vs_room_luck_value')->insert( [
|
||||||
@@ -125,7 +135,7 @@ class Lottery extends Model
|
|||||||
|
|
||||||
//计算爆币
|
//计算爆币
|
||||||
$nums = $num * count($toarray);
|
$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){
|
if($ress['code'] == 0){
|
||||||
return ['code' => 0, 'msg' => $ress['msg'], 'data' => null];
|
return ['code' => 0, 'msg' => $ress['msg'], 'data' => null];
|
||||||
}
|
}
|
||||||
@@ -134,8 +144,76 @@ 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)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$gift_gold = $gift_price;
|
||||||
|
if($poole_type == 5){
|
||||||
|
$text = '中级';
|
||||||
|
$small_prize_play_image = db::name('bb_lottery_config')->where(['key' => 'big_prize_play_image'])->value('value');
|
||||||
|
$service = new LotteryService5();
|
||||||
|
}elseif($poole_type == 10){
|
||||||
|
$text = '高级';
|
||||||
|
$small_prize_play_image = db::name('bb_lottery_config')->where(['key' => 'gao_prize_play_image'])->value('value');
|
||||||
|
$service = new LotteryService10();
|
||||||
|
}else{
|
||||||
|
$text = '初级';
|
||||||
|
$small_prize_play_image = db::name('bb_lottery_config')->where(['key' => 'small_prize_play_image'])->value('value');
|
||||||
|
$service = new LotteryService();
|
||||||
|
}
|
||||||
|
|
||||||
|
for($i=0;$i<$num;$i++){
|
||||||
|
$reslut = $service->handleGift($send_uid, $gift_gold, $giftId);
|
||||||
|
if ($reslut['code'] == 1) {
|
||||||
|
$result = $reslut['data'];
|
||||||
|
//(未开奖时)
|
||||||
|
if ($result['is_small_prize'] == 0) {
|
||||||
|
//不做处理
|
||||||
|
} else {//开奖
|
||||||
|
$beilv = floor($result['small_prize_amount'] / $gift_price);
|
||||||
|
$small_prize_amount = floor($result['small_prize_amount'] / $gift_price) * $gift_price;
|
||||||
|
$wallet_update = model('api/UserWallet')->change_user_cion_log($send_uid,$small_prize_amount,$room_id,58,'参与幸运币活动获得'.$beilv.'倍');
|
||||||
|
if(!$wallet_update){
|
||||||
|
return ['code' => 0, 'msg' => '流水记录失败', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
$tet['text'] = '恭喜用户'.$fromUserInfo['nickname'].'在'.$text.'幸运币活动中获得幸运币'.$beilv.'倍';
|
||||||
|
$tet['type'] = 2;
|
||||||
|
$tet['beilv'] = $beilv;
|
||||||
|
$tet['play_image'] = $small_prize_play_image;
|
||||||
|
$tet['FromUserInfo'] = $fromUserInfo;
|
||||||
|
$tet['user_id'] = $send_uid;
|
||||||
|
model('api/Chat')->sendMsg(1100,$room_id,$tet);
|
||||||
|
|
||||||
|
$push = new Push($send_uid, $room_id);
|
||||||
|
$room_name = Db::name('vs_room')->where(['id' => $room_id, 'apply_status' => 2])->value('room_name');
|
||||||
|
$text = '恭喜'.$fromUserInfo['nickname'] . '在' . $room_name . '房间获得'.$text.'幸运币'. $beilv . '倍';
|
||||||
|
$text_list_new[] = [
|
||||||
|
'text' => $text,
|
||||||
|
'gift_picture' => $gift_info['base_image'],
|
||||||
|
'room_id' => $room_id,
|
||||||
|
'fromUserName' => $fromUserInfo['nickname'],
|
||||||
|
'toUserName' => '',
|
||||||
|
'giftName' => '',
|
||||||
|
'roomId' => $room_id,
|
||||||
|
'number' => 1,
|
||||||
|
];
|
||||||
|
$push->giftBanner($text_list_new);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ['code' => 1, 'msg' => '送礼成功', 'data' => null];
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Log::error('抽奖处理失败:' . $e->getMessage());
|
||||||
|
return ['code' => 0, 'msg' => $e->getMessage(), 'data' => null];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//抽奖(带大奖池)
|
||||||
|
public function lotterys($send_uid,$gift_price,$num,$room_id,$giftId,$fromUserInfo=null,$gift_info=null)
|
||||||
{
|
{
|
||||||
$big_prize_play_image = db::name('bb_lottery_config')->where(['key' => 'big_prize_play_image'])->value('value');
|
$big_prize_play_image = db::name('bb_lottery_config')->where(['key' => 'big_prize_play_image'])->value('value');
|
||||||
$small_prize_play_image = db::name('bb_lottery_config')->where(['key' => 'small_prize_play_image'])->value('value');
|
$small_prize_play_image = db::name('bb_lottery_config')->where(['key' => 'small_prize_play_image'])->value('value');
|
||||||
@@ -143,7 +221,7 @@ class Lottery extends Model
|
|||||||
for($i=0;$i<$num;$i++){
|
for($i=0;$i<$num;$i++){
|
||||||
$gift_gold = $gift_price;
|
$gift_gold = $gift_price;
|
||||||
$service = new LotteryService();
|
$service = new LotteryService();
|
||||||
$reslut = $service->handleGift($send_uid, $gift_gold, $giftId);
|
$reslut = $service->handleGifts($send_uid, $gift_gold, $giftId);
|
||||||
if ($reslut['code'] == 1) {
|
if ($reslut['code'] == 1) {
|
||||||
$result = $reslut['data'];
|
$result = $reslut['data'];
|
||||||
//(未开奖时)
|
//(未开奖时)
|
||||||
|
|||||||
730
application/api/model/Monster.php
Normal file
730
application/api/model/Monster.php
Normal file
@@ -0,0 +1,730 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\model;
|
||||||
|
use app\common\controller\Push;
|
||||||
|
use think\Db;
|
||||||
|
use think\Model;
|
||||||
|
|
||||||
|
class Monster extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
// 开启自动写入时间戳字段
|
||||||
|
protected $autoWriteTimestamp = 'int';
|
||||||
|
// 定义时间戳字段名
|
||||||
|
protected $createTime = 'createtime';
|
||||||
|
protected $updateTime = 'updatetime';
|
||||||
|
|
||||||
|
public static function init()
|
||||||
|
{
|
||||||
|
self::beforeWrite(function ($row) {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//选择金币列表
|
||||||
|
public function choice_gold_list(){
|
||||||
|
$list = db::name('monster_multiple')->field('multiple')->select();
|
||||||
|
$data = [];
|
||||||
|
$data['list'] = $list;
|
||||||
|
return ['code' => 1, 'msg' => '获取成功', 'data' => $data];
|
||||||
|
}
|
||||||
|
|
||||||
|
//游戏详情
|
||||||
|
public function get_monster_info($uid){
|
||||||
|
$config = get_system_config();
|
||||||
|
$user_info = db::name('user_wallet_coin')->where('user_id', $uid)->field('id,coin')->find();
|
||||||
|
if(!$user_info){
|
||||||
|
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
|
||||||
|
}
|
||||||
|
$now_time = time();
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
$data['surplus_time'] = 0;
|
||||||
|
$data['is_finsh'] = 3;
|
||||||
|
$data['win_number'] = 0;
|
||||||
|
// $data['list'] = [];
|
||||||
|
$data['open_monster_price'] = $config['open_monster_price'];
|
||||||
|
$data['integral'] = $user_info['coin'];
|
||||||
|
$data['multiple_list'] = db::name('monster')->field('id,type,type_name,multiple')->order('id asc')->select();
|
||||||
|
foreach ($data['multiple_list'] as $a => &$b){
|
||||||
|
$b['num'] = 0;
|
||||||
|
}
|
||||||
|
//当前是否有开放该活动
|
||||||
|
$monster_log = db::name('monster_log')->order('id desc')->limit(1)->find();
|
||||||
|
if(empty($monster_log)){
|
||||||
|
return ['code' => 0, 'msg' => '获取成功', 'data' => $data];
|
||||||
|
}else{
|
||||||
|
if($monster_log['end_time'] <= $now_time){
|
||||||
|
$is_finish = 1;
|
||||||
|
$data['win_number'] = $monster_log['win_type'];
|
||||||
|
}else{
|
||||||
|
$is_finish = 2;
|
||||||
|
$data['surplus_time'] = $monster_log['end_time'] - $now_time;
|
||||||
|
}
|
||||||
|
$data['is_finsh'] = $is_finish;
|
||||||
|
foreach ($data['multiple_list'] as $a => &$b){
|
||||||
|
$user_monster_feed_log = db::name('user_monster_log')->where('uid', $uid)->where('mid', $monster_log['id'])->where('type', $b['type'])->find();
|
||||||
|
if(!empty($user_monster_feed_log)){
|
||||||
|
$b['num'] = $user_monster_feed_log['num'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ['code' => 1, 'msg' => '获取成功', 'data' => $data];
|
||||||
|
}
|
||||||
|
|
||||||
|
//生成当前国王游戏期数
|
||||||
|
public function create_monster_log(){
|
||||||
|
set_time_limit(0);
|
||||||
|
ini_set('memory_limit', '1024M');
|
||||||
|
|
||||||
|
$config = get_system_config();
|
||||||
|
$now_time = time();
|
||||||
|
$is_push = 5;//不推送
|
||||||
|
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
$map = [];
|
||||||
|
$map['is_delete'] = 1;
|
||||||
|
$monster_log = db::name('monster_log')->where($map)->find();
|
||||||
|
if($monster_log){//当前有未结束的国王游戏期数
|
||||||
|
if($now_time >= $monster_log['end_time']){
|
||||||
|
$key_name = "api:monster:create_monster_log:id".$monster_log['id'];
|
||||||
|
$redis_order_sn = redis_lock_exits($key_name,1,7);
|
||||||
|
if(!$redis_order_sn){
|
||||||
|
return ['code' => 0, 'msg' => '请重试1', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
$win_type = $monster_log['win_type'];
|
||||||
|
$in_amount = 0;
|
||||||
|
|
||||||
|
$win_type = $this->check_win_type_is_loss($win_type, $monster_log);
|
||||||
|
|
||||||
|
$win_gift_info = db::name('vs_gift')->alias('a')->join('monster b', 'a.gid = b.gid')->where('b.type', $win_type)->field('a.gid,a.gift_name,a.gift_price,a.base_image,b.multiple')->find();
|
||||||
|
if(!$win_gift_info){
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => '为配置礼物', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取得奖用户ID
|
||||||
|
$map = [];
|
||||||
|
$map['mid'] = $monster_log['id'];
|
||||||
|
$part_user_array = db::name('user_monster_log')->where($map)->group('uid')->column('uid');
|
||||||
|
$map['type'] = $win_type;
|
||||||
|
$user_array = db::name('user_monster_log')->where($map)->group('uid')->column('uid');
|
||||||
|
if(!empty($user_array)){
|
||||||
|
//有获奖用户
|
||||||
|
$insert_all = [];
|
||||||
|
foreach ($user_array as $a => $b){
|
||||||
|
$map = [];
|
||||||
|
$map['mid'] = $monster_log['id'];
|
||||||
|
$map['uid'] = $b;
|
||||||
|
$map['type'] = $win_type;
|
||||||
|
$user_monster_log = db::name('user_monster_log')->where($map)->find();
|
||||||
|
$wim_num = floor($user_monster_log['price'] * $win_gift_info['multiple'] / $win_gift_info['gift_price']);
|
||||||
|
|
||||||
|
$in_amount += $win_gift_info['gift_price'] * $wim_num;
|
||||||
|
|
||||||
|
//礼物送到背包
|
||||||
|
if($wim_num > 0){
|
||||||
|
$reslut = model('api/UserGiftPack')->change_user_gift_pack($b, $win_gift_info['gid'], $wim_num, model('UserGiftPack')::LY_DRAW_GIFT_GET, '炼仙传说中奖获取');
|
||||||
|
if($reslut['code'] == 0){
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => $reslut['msg'], 'data' => null];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//用户中奖信息
|
||||||
|
$insert = [];
|
||||||
|
$insert['uid'] = $b;
|
||||||
|
$insert['rid'] = $user_monster_log['rid'];
|
||||||
|
$insert['mid'] = $monster_log['id'];
|
||||||
|
$insert['win_type'] = $win_type;
|
||||||
|
$insert['win_gid'] = $win_gift_info['gid'];
|
||||||
|
$insert['price'] = $user_monster_log['price'];
|
||||||
|
$insert['num'] = $wim_num;
|
||||||
|
$insert['createtime'] = time();
|
||||||
|
$insert_all[] = $insert;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$reslut = db::name('user_monster_win_log')->insertAll($insert_all);
|
||||||
|
if(!$reslut){
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => '请重试2', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//结束当前抽卡期数
|
||||||
|
$update = [];
|
||||||
|
$update['win_type'] = $win_type;
|
||||||
|
$update['in_amount'] = $in_amount;
|
||||||
|
$update['is_delete'] = 2;
|
||||||
|
$update['updatetime'] = time();
|
||||||
|
$reslut = db::name('monster_log')->where('id', $monster_log['id'])->update($update);
|
||||||
|
if(!$reslut){
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => '请重试3', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
$is_push = 2;
|
||||||
|
}
|
||||||
|
}else{//当前未有国王游戏期数
|
||||||
|
if($config['open_monster_status'] != 1){
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => '游戏已关闭', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
//距离上次多长时间
|
||||||
|
$map = [];
|
||||||
|
$map['is_delete'] = 2;
|
||||||
|
$last_monster_log = db::name('monster_log')->where($map)->order('id desc')->limit(1)->find();
|
||||||
|
if($last_monster_log){
|
||||||
|
// $interval_time = $last_monster_log['end_time'] + 10 + $config['end_interval_time'];
|
||||||
|
$interval_time = time() - $last_monster_log['end_time'];
|
||||||
|
if($interval_time < $config['end_interval_time']){
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => '距离上次结束尚未超过'.$config['end_interval_time'].'秒', 'data' => null];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//当前国王游戏配置信息
|
||||||
|
$monster_list = db::name('monster')->order('id asc')->select();
|
||||||
|
$monster_data = '';
|
||||||
|
$total_num = 0;
|
||||||
|
$win_number_data = [];
|
||||||
|
foreach ($monster_list as $a => $b){
|
||||||
|
$da = $b['id'].'-'.$b['gid'].'-'.$b['num'].';';
|
||||||
|
$monster_data .= $da;
|
||||||
|
$total_num += $b['num'];
|
||||||
|
for($i = 0; $i < $b['num']; $i++){
|
||||||
|
$win_number_data[] = $b['id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
shuffle($win_number_data);
|
||||||
|
$win_key = array_rand($win_number_data);
|
||||||
|
//随机抽取中奖数字
|
||||||
|
$win_type = $win_number_data[$win_key];
|
||||||
|
|
||||||
|
//生成最新
|
||||||
|
$insert = [];
|
||||||
|
$insert['win_type'] = $win_type;
|
||||||
|
$insert['total_num'] = $total_num;
|
||||||
|
$insert['config_text'] = $monster_data;
|
||||||
|
$insert['createtime'] = $now_time;
|
||||||
|
$insert['end_time'] = $now_time + $config['monster_count_down_time'];
|
||||||
|
$reslut = db::name('monster_log')->insert($insert);
|
||||||
|
if(!$reslut){
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => '生成失败', 'data' => null];
|
||||||
|
}
|
||||||
|
$is_push = 1;//开启推送
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
|
||||||
|
if($is_push == 1){
|
||||||
|
$push_feed_monster_data = $this->get_new_feed_monster_info();
|
||||||
|
|
||||||
|
$push_data = [];
|
||||||
|
$push_data['code'] = 3031;
|
||||||
|
$push_data['msg'] = "探索开始播报";
|
||||||
|
$push_data['data'] = $push_feed_monster_data;
|
||||||
|
// 推送
|
||||||
|
$push = new Push();
|
||||||
|
$push->xianxuan($push_data);
|
||||||
|
}else if($is_push == 2){
|
||||||
|
$push_feed_monster_data = $this->get_new_feed_monster_info();
|
||||||
|
$push_feed_monster_data['win_count'] = count($user_array);
|
||||||
|
$push_feed_monster_data['game_name'] = '国王游戏';
|
||||||
|
$push_feed_monster_data['win_type_name'] = db::name('monster')->where('type', $win_type)->value('type_name');
|
||||||
|
$push_feed_monster_data['gift_name'] = $win_gift_info['gift_name'];
|
||||||
|
$push_feed_monster_data['num'] = 0;
|
||||||
|
$push_feed_monster_data['total_gift_price'] = 0;
|
||||||
|
$push_feed_monster_data['is_push_message'] = 2;
|
||||||
|
$push_feed_monster_data['base_image'] = localpath_to_netpath($win_gift_info['base_image']);
|
||||||
|
|
||||||
|
// if(!empty($part_user_array)){
|
||||||
|
// foreach ($part_user_array as $k => $v){
|
||||||
|
// $push_user_monster_data = [];
|
||||||
|
// $push_user_monster_data['win_type'] = $win_type;
|
||||||
|
// $push_user_monster_data['type_name'] = db::name('monster')->where('type', $win_type)->value('type_name');
|
||||||
|
// //是否中奖
|
||||||
|
// $map = [];
|
||||||
|
// $map['mid'] = $monster_log['id'];
|
||||||
|
// $map['uid'] = $v;
|
||||||
|
// $user_win_info = db::name('user_monster_win_log')->where($map)->find();
|
||||||
|
// if($user_win_info){//中奖
|
||||||
|
// $push_user_monster_data['is_win'] = 1;
|
||||||
|
// $push_user_monster_data['gid'] = $win_gift_info['gid'];
|
||||||
|
// $push_user_monster_data['gift_name'] = $win_gift_info['gift_name'];
|
||||||
|
// $push_user_monster_data['base_image'] = localpath_to_netpath($win_gift_info['base_image']);
|
||||||
|
// $push_user_monster_data['gift_price'] = $win_gift_info['gift_price'];
|
||||||
|
// $push_user_monster_data['num'] = $user_win_info['num'];
|
||||||
|
// $push_user_monster_data['total_gift_price'] = $win_gift_info['gift_price'] * $user_win_info['num'];
|
||||||
|
// $push_feed_monster_data['num'] += $user_win_info['num'];
|
||||||
|
// $push_feed_monster_data['total_gift_price'] += $push_user_monster_data['total_gift_price'];
|
||||||
|
// }else{//未中奖
|
||||||
|
// $push_user_monster_data['is_win'] = 2;
|
||||||
|
// $push_user_monster_data['gid'] = 0;
|
||||||
|
// $push_user_monster_data['gift_name'] = '';
|
||||||
|
// $push_user_monster_data['base_image'] = '';
|
||||||
|
// $push_user_monster_data['gift_price'] = 0;
|
||||||
|
// $push_user_monster_data['num'] = 0;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// $push_data = [];
|
||||||
|
// $push_data['code'] = 3032;
|
||||||
|
// $push_data['msg'] = "抽卡个人结束播报";
|
||||||
|
// $push_data['data'] = $push_user_monster_data;
|
||||||
|
// $push = new Push();
|
||||||
|
// $push->xianxuan($push_data);
|
||||||
|
// // error_log(date('Y-m-d H:i:s').'_'.$v.'_'.$reslut."\r\n", 3, '1111.txt');
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
$push_feed_monster_data['num'] = db::name('user_monster_win_log')->where(['mid'=>$monster_log['id']])->sum('num');
|
||||||
|
if($push_feed_monster_data['num'] > 0){
|
||||||
|
$push_feed_monster_data['is_push_message'] = 1;
|
||||||
|
$push_feed_monster_data['total_gift_price'] = $win_gift_info['gift_price'] * $push_feed_monster_data['num'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$push_data = [];
|
||||||
|
$push_data['code'] = 3033;
|
||||||
|
$push_data['msg'] = "探索结束播报";
|
||||||
|
$push_data['data'] = $push_feed_monster_data;
|
||||||
|
$push = new Push();
|
||||||
|
$push->xianxuan($push_data);
|
||||||
|
|
||||||
|
// $close_data = $this->get_close_monster_win_log();
|
||||||
|
// $push_colse_data = [];
|
||||||
|
// $push_colse_data['code'] = 3034;
|
||||||
|
// $push_colse_data['msg'] = "国王游戏结束播报";
|
||||||
|
// $push_colse_data['data'] = $close_data;
|
||||||
|
// model('api/WebSocketPush')->send_to_all($push_colse_data);
|
||||||
|
}
|
||||||
|
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// 回滚事务
|
||||||
|
dump($e);
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => '失败', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//是否修改中奖类型
|
||||||
|
public function check_win_type_is_loss($win_type, $monster_log){
|
||||||
|
$config = get_system_config();
|
||||||
|
//当前亏损数值是否大于
|
||||||
|
$map = [];
|
||||||
|
$map['is_delete'] = 2;
|
||||||
|
$map['out_amount'] = ['>', 0];
|
||||||
|
$now_monster_out_amount = db::name('monster_log')->where($map)->sum('out_amount');//投入
|
||||||
|
$now_monster_in_amount = db::name('monster_log')->where($map)->sum('in_amount');//产出
|
||||||
|
|
||||||
|
//获取得奖用户ID
|
||||||
|
$map = [];
|
||||||
|
$map['mid'] = [ '=', $monster_log['id']];
|
||||||
|
$map['type'] = ['=', $win_type];
|
||||||
|
$user_array = db::name('user_monster_log')->where($map)->group('uid')->column('uid');
|
||||||
|
|
||||||
|
if(!empty($user_array)){
|
||||||
|
$wim_monster = db::name('monster')->where('type', $win_type)->find();
|
||||||
|
$in_amount = 0;
|
||||||
|
foreach ($user_array as $a => $b){
|
||||||
|
$map = [];
|
||||||
|
$map['mid'] = ['=', $monster_log['id']];
|
||||||
|
$map['uid'] = ['=', $b];
|
||||||
|
$map['type'] = ['=', $win_type];
|
||||||
|
$user_monster_log = db::name('user_monster_log')->where($map)->find();
|
||||||
|
|
||||||
|
//中奖金额
|
||||||
|
$win_price = $user_monster_log['price'] * $wim_monster['multiple'];
|
||||||
|
|
||||||
|
$in_amount += $win_price;
|
||||||
|
}
|
||||||
|
|
||||||
|
$profit = ($now_monster_in_amount + $in_amount) - ($now_monster_out_amount + $monster_log['out_amount']);
|
||||||
|
if($profit > $config['monster_max_loss_price']){//亏损大于3w
|
||||||
|
$type_price_1 = db::name('user_monster_log')->where('mid', $monster_log['id'])->where('type', 1)->sum('price');
|
||||||
|
$win_type_amount_1 = $type_price_1 * 2;
|
||||||
|
$type_price_2 = db::name('user_monster_log')->where('mid', $monster_log['id'])->where('type', 2)->sum('price');
|
||||||
|
$win_type_amount_2 = $type_price_2 * 4;
|
||||||
|
$type_price_3 = db::name('user_monster_log')->where('mid', $monster_log['id'])->where('type', 3)->sum('price');
|
||||||
|
$win_type_amount_3 = $type_price_3 * 6.5;
|
||||||
|
$type_price_4 = db::name('user_monster_log')->where('mid', $monster_log['id'])->where('type', 4)->sum('price');
|
||||||
|
$win_type_amount_4 = $type_price_4 * 10;
|
||||||
|
$type_price_5 = db::name('user_monster_log')->where('mid', $monster_log['id'])->where('type', 5)->sum('price');
|
||||||
|
$win_type_amount_5 = $type_price_5 * 15;
|
||||||
|
$type_price_6 = db::name('user_monster_log')->where('mid', $monster_log['id'])->where('type', 6)->sum('price');
|
||||||
|
$win_type_amount_6 = $type_price_6 * 20;
|
||||||
|
// $type_price_6 = db::name('user_monster_log')->where('mid', $monster_log['id'])->where('type', 6)->sum('price');
|
||||||
|
// $win_type_amount_6 = $type_price_6 * 50;
|
||||||
|
|
||||||
|
// $win_type_amount_arr = [$win_type_amount_1, $win_type_amount_2, $win_type_amount_3, $win_type_amount_4, $win_type_amount_5, $win_type_amount_6];
|
||||||
|
$win_type_amount_arr = [$win_type_amount_1, $win_type_amount_2, $win_type_amount_3, $win_type_amount_4, $win_type_amount_5, $win_type_amount_6];
|
||||||
|
// $win_type_amount_arr = [$win_type_amount_1, $win_type_amount_2, $win_type_amount_3, $win_type_amount_4];
|
||||||
|
$win_type_min = min($win_type_amount_arr);
|
||||||
|
|
||||||
|
// if($win_type_amount_4 == $win_type_min && $win_type_amount_3 == $win_type_min && $win_type_amount_2 == $win_type_min && $win_type_amount_1 == $win_type_min){
|
||||||
|
// $win_type = rand(1,4);
|
||||||
|
// }else
|
||||||
|
if($win_type_amount_1 == $win_type_min){
|
||||||
|
$win_type = 1;
|
||||||
|
}else if($win_type_amount_2 == $win_type_min){
|
||||||
|
$win_type = 2;
|
||||||
|
}else if($win_type_amount_3 == $win_type_min){
|
||||||
|
$win_type = 3;
|
||||||
|
}else if($win_type_amount_4 == $win_type_min){
|
||||||
|
$win_type = 4;
|
||||||
|
}else if($win_type_amount_5 == $win_type_min){
|
||||||
|
$win_type = 5;
|
||||||
|
}else if($win_type_amount_6 == $win_type_min){
|
||||||
|
$win_type = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return $win_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
//当前最新探索信息
|
||||||
|
public function get_new_feed_monster_info(){
|
||||||
|
$now_time = time();
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
$data['surplus_time'] = 0;
|
||||||
|
$data['is_finsh'] = 3;
|
||||||
|
$data['win_number'] = 0;
|
||||||
|
// $data['list'] = [];
|
||||||
|
$data['multiple_list'] = db::name('monster')->field('id,type,type_name,multiple')->order('id asc')->select();
|
||||||
|
|
||||||
|
//当前是否有开放该活动
|
||||||
|
$monster_log = db::name('monster_log')->order('id desc')->limit(1)->find();
|
||||||
|
if(empty($monster_log)){
|
||||||
|
return $data;
|
||||||
|
}else{
|
||||||
|
if($monster_log['end_time'] <= $now_time){
|
||||||
|
$is_finish = 1;
|
||||||
|
$data['win_number'] = $monster_log['win_type'];
|
||||||
|
}else{
|
||||||
|
$is_finish = 2;
|
||||||
|
$data['surplus_time'] = $monster_log['end_time'] - $now_time;
|
||||||
|
}
|
||||||
|
$data['is_finsh'] = $is_finish;
|
||||||
|
}
|
||||||
|
|
||||||
|
//当前参与用户探索列表
|
||||||
|
// $list = db::name('user_monster_feed_log')->alias('a')->join('yy_user b', 'a.uid = b.uid')->join('yy_monster c', 'a.type = c.type')->where('a.mid', $monster_log['id'])->field('a.id,b.uid,b.nick_name,b.base64_nick_name,b.head_pic,c.type_name,a.price')->order('a.id desc')->select();
|
||||||
|
// foreach ($list as $k => &$v){
|
||||||
|
// $v['nick_name'] = mb_convert_encoding(base64_decode($v['base64_nick_name']), 'UTF-8', 'UTF-8');
|
||||||
|
// $v['head_pic'] = localpath_to_netpath($v['head_pic']);
|
||||||
|
// }
|
||||||
|
// $data['list'] = $list;
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
//国王游戏
|
||||||
|
public function open_beat_monster($uid, $rid, $type, $num){
|
||||||
|
$user_info = db::name('user_wallet_coin')->where('user_id', $uid)->field('id,coin')->find();
|
||||||
|
if(!$user_info){
|
||||||
|
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
$config = get_system_config();
|
||||||
|
$now_time = time();
|
||||||
|
|
||||||
|
$monster = db::name('monster')->where('type', $type)->find();
|
||||||
|
if(!$monster){
|
||||||
|
return ['code' => 0, 'msg' => '当前类型不存在', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
$map = [];
|
||||||
|
$map['end_time'] = ['>', time()];
|
||||||
|
$map['is_delete'] = 1;
|
||||||
|
$monster_log = db::name('monster_log')->where($map)->find();
|
||||||
|
if(!$monster_log){
|
||||||
|
return ['code' => 0, 'msg' => '请等待新一轮开启', 'data' => null];
|
||||||
|
}else{
|
||||||
|
$surplus_time = $monster_log['end_time'] - 5;
|
||||||
|
if($surplus_time < time()){
|
||||||
|
return ['code' => 0, 'msg' => '最后五秒内无法参与', 'data' => null];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($num < 1){
|
||||||
|
return ['code' => 0, 'msg' => '次数不能小于1', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
//该星途已探索多少次数
|
||||||
|
$map = [];
|
||||||
|
$map['mid'] = $monster_log['id'];
|
||||||
|
$map['uid'] = $uid;
|
||||||
|
$user_type_num = db::name('user_monster_log')->where($map)->column('type');
|
||||||
|
$map['type'] = $type;
|
||||||
|
$user_monster_num = db::name('user_monster_log')->where($map)->sum('num');
|
||||||
|
if($user_monster_num > 0){
|
||||||
|
if($user_monster_num + $num > $config['open_monster_max_num']){
|
||||||
|
return ['code' => 0, 'msg' => '该玩法次数已达上限', 'data' => null];
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if($num > $config['open_monster_max_num']){
|
||||||
|
return ['code' => 0, 'msg' => '该玩法次数已达上限', 'data' => null];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$user_monster_log = db::name('user_monster_log')->where($map)->find();
|
||||||
|
|
||||||
|
if(count($user_type_num) >= 6 && !in_array($type, $user_type_num)){
|
||||||
|
return ['code' => 0, 'msg' => '玩法类型不能大于六个', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
// $open_monster_ticket = $config['open_monster_ticket'];
|
||||||
|
// $pay_ticket = $num * $open_monster_ticket;
|
||||||
|
// if($user_info['had_ticket_num'] < $pay_ticket){
|
||||||
|
// return ['code' => 201, 'msg' => '用户剩余门票数不足', 'data' => null];
|
||||||
|
// }
|
||||||
|
$money = $num * $config['open_monster_price'];
|
||||||
|
if($user_info['coin'] < $money){
|
||||||
|
return ['code' => 0, 'msg' => '金币不足', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
//扣除用户金币
|
||||||
|
$reslut = model('common/UserWallet')->change_user_money($uid, $money, 1, model('common/UserWallet')::LINGXIAN_TRADITION_LOTTERY_COIN,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::LINGXIAN_TRADITION_LOTTERY_COIN));
|
||||||
|
if ($reslut['code'] != 1) {
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => $reslut['msg'], 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
//是否探索过
|
||||||
|
if($user_monster_log){//已探索则继续
|
||||||
|
$update = [];
|
||||||
|
$update['updatetime'] = time();
|
||||||
|
$reslut = db::name('user_monster_log')->where('id', $user_monster_log['id'])->inc('num', $num)->inc('price', $money)->update($update);
|
||||||
|
if(!$reslut){
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => '请重试', 'data' => null];
|
||||||
|
}
|
||||||
|
}else{//未探索则探索
|
||||||
|
$insert = [];
|
||||||
|
$insert['uid'] = $uid;
|
||||||
|
$insert['rid'] = $rid;
|
||||||
|
$insert['mid'] = $monster_log['id'];
|
||||||
|
$insert['type'] = $type;
|
||||||
|
$insert['num'] = $num;
|
||||||
|
$insert['price'] = $money;
|
||||||
|
$insert['createtime'] = time();
|
||||||
|
$reslut = db::name('user_monster_log')->insert($insert);
|
||||||
|
if(!$reslut){
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => '请重试', 'data' => null];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//用户探索记录表
|
||||||
|
$insert_data = [];
|
||||||
|
$insert_data['uid'] = $uid;
|
||||||
|
$insert_data['rid'] = $rid;
|
||||||
|
$insert_data['mid'] = $monster_log['id'];
|
||||||
|
$insert_data['type'] = $type;
|
||||||
|
$insert_data['num'] = $num;
|
||||||
|
$insert_data['price'] = $money;
|
||||||
|
$insert_data['createtime'] = time();
|
||||||
|
$fid = db::name('user_monster_feed_log')->insertGetId($insert_data);
|
||||||
|
if(!$fid){
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => '请重试', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
//计入当期支出累消
|
||||||
|
$update = [];
|
||||||
|
$update['updatetime'] = time();
|
||||||
|
$reslut = db::name('monster_log')->where('id', $monster_log['id'])->inc('out_amount', $money)->update($update);
|
||||||
|
if(!$reslut){
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => '请重试', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
$user_data = db::name('user')->where('id', $uid)->find();
|
||||||
|
$push_feed_monster_data = [];
|
||||||
|
$push_feed_monster_data['id'] = $fid;
|
||||||
|
$push_feed_monster_data['uid'] = $uid;
|
||||||
|
$push_feed_monster_data['nick_name'] = $user_data['nickname']??"";
|
||||||
|
$push_feed_monster_data['head_pic'] = $user_data['avatar']??"";
|
||||||
|
$push_feed_monster_data['type'] = $type;
|
||||||
|
$push_feed_monster_data['type_name'] = db::name('monster')->where('type', $type)->value('type_name');
|
||||||
|
$push_feed_monster_data['price'] = $money;
|
||||||
|
$push_feed_monster_data['num'] = db::name('user_monster_log')->where('mid',$monster_log['id'])->where('uid', $uid)->where('type', $type)->sum('num');
|
||||||
|
// $push_feed_monster_data['pay_ticket'] = $pay_ticket;
|
||||||
|
$push_feed_monster_data['integral'] = db::name('user_wallet_coin')->where('user_id', $uid)->value('coin');
|
||||||
|
// $push_data = [];
|
||||||
|
// $push_data['code'] = 334;
|
||||||
|
// $push_data['msg'] = "探索公屏播报";
|
||||||
|
// $push_data['data'] = $push_feed_monster_data;
|
||||||
|
// model('api/WebSocketPush')->send_to_all($push_data);
|
||||||
|
|
||||||
|
|
||||||
|
return ['code' => 1, 'msg' => '探索成功', 'data' => $push_feed_monster_data];
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// 回滚事务
|
||||||
|
// dump($e);
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => '探索失败', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//规则
|
||||||
|
public function get_monster_note(){
|
||||||
|
$config = get_system_config();
|
||||||
|
$note = $config['monster_feed_note'];
|
||||||
|
return ['code' => 1, 'msg' => '获取成功', 'data' => $note];
|
||||||
|
|
||||||
|
}
|
||||||
|
//奖池
|
||||||
|
public function get_monster_box_list(){
|
||||||
|
$monster_gift_list = db::name('monster')->alias('a')->join('vs_gift b', 'a.gid = b.gid')->field('a.gid,b.base_image,b.gift_name,b.gift_price')->order('b.gift_price asc')->select();
|
||||||
|
foreach ($monster_gift_list as $k => &$v){
|
||||||
|
$v['base_image'] = localpath_to_netpath($v['base_image']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['code' => 1, 'msg' => '获取成功', 'data' => $monster_gift_list];
|
||||||
|
}
|
||||||
|
//开奖记录
|
||||||
|
public function get_monster_log($uid, $page, $page_limit){
|
||||||
|
$user_info = db::name('user')->where('id', $uid)->find();
|
||||||
|
if(!$user_info){
|
||||||
|
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
$map = [];
|
||||||
|
$map['a.is_delete'] = ['=', 2];
|
||||||
|
$monster_list = db::name('monster_log')->alias('a')->join('monster b', 'a.win_type = b.type')->field('a.id,a.win_type,b.type_name,a.createtime as add_time')->where($map)->order('a.id desc')->page($page, $page_limit)->select();
|
||||||
|
foreach ($monster_list as $k => &$v){
|
||||||
|
$v['is_join'] = 3;
|
||||||
|
$v['gift_name'] = '';
|
||||||
|
$v['base_image'] = '';
|
||||||
|
$v['gift_price'] = 0;
|
||||||
|
$v['num'] = 0;
|
||||||
|
$user_monster_log = db::name('user_monster_log')->where('uid', $uid)->where('mid', $v['id'])->find();
|
||||||
|
if($user_monster_log){
|
||||||
|
$v['is_join'] = 2;
|
||||||
|
$user_monster_win_log = db::name('user_monster_win_log')->where('uid', $uid)->where('mid', $v['id'])->find();
|
||||||
|
if($user_monster_win_log){
|
||||||
|
$v['is_join'] = 1;
|
||||||
|
$gift_info = db::name('vs_gift')->find($user_monster_win_log['win_gid']);
|
||||||
|
$v['gift_name'] = $gift_info['gift_name'];
|
||||||
|
$v['base_image'] = localpath_to_netpath($gift_info['base_image']);
|
||||||
|
$v['gift_price'] = $gift_info['gift_price'];
|
||||||
|
$v['num'] = $user_monster_win_log['num'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return ['code' => 1, 'msg' => '获取成功', 'data' => $monster_list];
|
||||||
|
}
|
||||||
|
|
||||||
|
//我的列表
|
||||||
|
public function get_user_monster_log($uid, $page, $page_limit){
|
||||||
|
$user_info = db::name('user')->where('id', $uid)->find();
|
||||||
|
if(!$user_info){
|
||||||
|
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
// $map = [];
|
||||||
|
// $map[] = ['a.uid', '=', $uid];
|
||||||
|
$user_monster_log = db::name('user_monster_win_log')
|
||||||
|
->alias('a')
|
||||||
|
->join('user b', 'a.uid = b.id')
|
||||||
|
->join('monster c', 'a.win_type = c.type')
|
||||||
|
->join('vs_gift d', 'd.gid = a.win_gid')
|
||||||
|
->field('a.id,a.mid,b.id as uid,b.nickname,b.avatar,a.win_type,c.type_name,d.gift_name,d.base_image,d.gift_price,a.num,a.createtime as add_time')->order('a.id desc')->page($page, $page_limit)->select();
|
||||||
|
foreach ($user_monster_log as $k => &$v){
|
||||||
|
$user_info = db::name('user')->where('id', $v['uid'])->field('id,nickname,avatar')->find();
|
||||||
|
$v['nick_name'] = $user_info['nickname'];
|
||||||
|
$v['head_pic'] = $user_info['avatar'];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['code' => 1, 'msg' => '获取成功', 'data' => $user_monster_log];
|
||||||
|
}
|
||||||
|
|
||||||
|
//中奖次数榜单
|
||||||
|
public function get_monster_winner_num_list($uid, $time){
|
||||||
|
if(in_array($time, [1,2,3])){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$model = db::name('user_monster_win_log')->field('uid, count(id) as win_num');
|
||||||
|
if($time == 1){
|
||||||
|
$model = $model->whereTime('add_time', 'today');
|
||||||
|
}else if($time == 2){
|
||||||
|
$model = $model->whereTime('add_time', 'week');
|
||||||
|
}else if($time == 3){
|
||||||
|
$model = $model->whereTime('add_time', 'month');
|
||||||
|
}
|
||||||
|
$list = $model->group('uid')->order('win_num desc, uid asc')->limit(30)->select();
|
||||||
|
foreach ($list as $k => &$v){
|
||||||
|
$user_info = db::name('user')->where('id', $v['uid'])->field('id,nickname,avatar')->find();
|
||||||
|
$v['nick_name'] = $user_info['nickname'];
|
||||||
|
$v['head_pic'] = $user_info['avatar'];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['code' => 1, 'msg' => '获取成功', 'data' => $list];
|
||||||
|
}
|
||||||
|
|
||||||
|
//设置房间期数开关
|
||||||
|
public function operate_room_monster_show_status($uid, $rid, $is_show_monster_push){
|
||||||
|
$room_info = db::name('vs_room')-> where('id', $rid)->find();
|
||||||
|
if(!$room_info){
|
||||||
|
return ['code' => 0, 'msg' => '该房间不存在', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
$room_admin_uid_arr = explode(',', $room_info['room_admin_uid']);
|
||||||
|
if ($uid != $room_info['room_owner_uid'] && !in_array($uid, $room_admin_uid_arr)) {
|
||||||
|
return ['code' => 0, 'msg' => '无权限操作', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
|
||||||
|
$update = [];
|
||||||
|
$update['is_show_monster_push'] = $is_show_monster_push;
|
||||||
|
$update['update_time'] = time();
|
||||||
|
$reslut = db::name('room')->where('rid', $rid)->update($update);
|
||||||
|
if(!$reslut){
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => '修改失败', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
$data['rid'] = $rid;
|
||||||
|
$data['is_show_monster_push'] = $is_show_monster_push;
|
||||||
|
|
||||||
|
//推送
|
||||||
|
$push_data = [];
|
||||||
|
$push_data['code'] = 3035;
|
||||||
|
$push_data['msg'] = "修改房间期数开关";
|
||||||
|
$push_data['data'] = $data;
|
||||||
|
model('api/WebSocketPush')->send_to_group($rid, $push_data);
|
||||||
|
|
||||||
|
return ['code' => 1, 'msg' => '修改成功', 'data' => $data];
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// 回滚事务
|
||||||
|
// dump($e);
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => '修改失败', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -129,7 +129,7 @@ class Nobility extends Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
//购买爵位
|
//购买爵位
|
||||||
public function buyNobility($user_id,$lid){
|
public function buyNobility($user_id,$lid,$is_send=0){
|
||||||
$nobility_info = db::name('vs_nobility')
|
$nobility_info = db::name('vs_nobility')
|
||||||
->field('lid,name,pay_price,renew_price,pay_coin,day,renew_coin')
|
->field('lid,name,pay_price,renew_price,pay_coin,day,renew_coin')
|
||||||
->where('delete_time', 0)
|
->where('delete_time', 0)
|
||||||
@@ -245,9 +245,11 @@ class Nobility extends Model
|
|||||||
$pay_coin = $nobility_info['pay_coin'] ?? 0;
|
$pay_coin = $nobility_info['pay_coin'] ?? 0;
|
||||||
}
|
}
|
||||||
if($pay_coin > 0){
|
if($pay_coin > 0){
|
||||||
$reslut = model('common/UserWallet')->change_user_money($user_id, $pay_coin, model('common/UserWallet')::MONEYTYPECOIN, model('common/UserWallet')::NOBILITY_PURCHASE_COIN,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::NOBILITY_PURCHASE_COIN));
|
if($is_send != 1){
|
||||||
if (!$reslut) {
|
$reslut = model('common/UserWallet')->change_user_money($user_id, $pay_coin, model('common/UserWallet')::MONEYTYPECOIN, model('common/UserWallet')::NOBILITY_PURCHASE_COIN,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::NOBILITY_PURCHASE_COIN));
|
||||||
return ['code' => 0, 'msg' => '失败', 'data' => null];
|
if (!$reslut) {
|
||||||
|
return ['code' => 0, 'msg' => '失败', 'data' => null];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class Room extends Model
|
|||||||
|
|
||||||
}
|
}
|
||||||
//创建房间 创建
|
//创建房间 创建
|
||||||
public function user_create_room($uid, $room_name,$room_cover,$room_intro,$type = 0,$need_apply=1)
|
public function user_create_room($uid, $room_name,$room_cover,$room_intro,$type = 0,$need_apply=1,$password = '')
|
||||||
{
|
{
|
||||||
$user_mobile = model('api/User')->where('id', $uid)->value('mobile');
|
$user_mobile = model('api/User')->where('id', $uid)->value('mobile');
|
||||||
if ($user_mobile == null) {
|
if ($user_mobile == null) {
|
||||||
@@ -62,6 +62,9 @@ class Room extends Model
|
|||||||
$data['is_open_blind_box_turntable'] = 1;
|
$data['is_open_blind_box_turntable'] = 1;
|
||||||
}
|
}
|
||||||
$data['label_id'] = 1;
|
$data['label_id'] = 1;
|
||||||
|
if(!empty($password)){
|
||||||
|
$data['room_password'] = $password;
|
||||||
|
}
|
||||||
}elseif ($type == 7){//互娱房创建的私密电影屋
|
}elseif ($type == 7){//互娱房创建的私密电影屋
|
||||||
$data['room_number'] = $this->get_user_code();
|
$data['room_number'] = $this->get_user_code();
|
||||||
$data['type_id'] = 6;//cp电影房
|
$data['type_id'] = 6;//cp电影房
|
||||||
@@ -173,6 +176,8 @@ class Room extends Model
|
|||||||
}
|
}
|
||||||
if($password){
|
if($password){
|
||||||
$data['room_password'] = $password;
|
$data['room_password'] = $password;
|
||||||
|
}else{
|
||||||
|
$data['room_password'] = '';
|
||||||
}
|
}
|
||||||
if(!empty($data)){
|
if(!empty($data)){
|
||||||
$reslut = $this->where('id', $room_id)->update($data);
|
$reslut = $this->where('id', $room_id)->update($data);
|
||||||
@@ -227,14 +232,6 @@ class Room extends Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// $list = db::name('vs_room')
|
|
||||||
// ->field('id as room_id,room_number,user_id,room_name,room_cover,room_password,today_hot_value as hot_value,label_id,is_show_room')
|
|
||||||
// ->where($map)
|
|
||||||
// ->order('sort desc,hot_value desc,id asc')
|
|
||||||
// ->page($page, $page_limit)->select();
|
|
||||||
|
|
||||||
$currentTime = date('H:i:s');
|
|
||||||
|
|
||||||
$list = db::name('vs_room')
|
$list = db::name('vs_room')
|
||||||
->field('id as room_id,room_number,user_id,room_name,room_cover,room_password,today_hot_value as hot_value,label_id,is_show_room,start_time,end_time')
|
->field('id as room_id,room_number,user_id,room_name,room_cover,room_password,today_hot_value as hot_value,label_id,is_show_room,start_time,end_time')
|
||||||
->where($map)
|
->where($map)
|
||||||
@@ -966,7 +963,7 @@ class Room extends Model
|
|||||||
return ['code' => 202, 'msg' => '您已经在房间'.$room_names.'中,请先下麦后并退出房间', 'data' => ['room_id' => $room_pit,'msg'=>'您在'.$room_names .'房间游戏中,不支持进入新房间']];
|
return ['code' => 202, 'msg' => '您已经在房间'.$room_names.'中,请先下麦后并退出房间', 'data' => ['room_id' => $room_pit,'msg'=>'您在'.$room_names .'房间游戏中,不支持进入新房间']];
|
||||||
}
|
}
|
||||||
|
|
||||||
if($room['room_password'] != ''){
|
if($room['room_password'] != '' && $user_id != $room['user_id']){
|
||||||
return ['code' => 101, 'msg' => '密码房', 'data' => ''];
|
return ['code' => 101, 'msg' => '密码房', 'data' => ''];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1032,7 +1029,7 @@ class Room extends Model
|
|||||||
Cache::set('room_info_' . $room_id, json_encode($room), 7200);
|
Cache::set('room_info_' . $room_id, json_encode($room), 7200);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($room['room_password']) && $user_id != $room['user_id']){
|
if(isset($room['room_password']) && $room['room_password'] != '' && $user_id != $room['user_id']){
|
||||||
if (empty($password) || $room['room_password'] != $password) {
|
if (empty($password) || $room['room_password'] != $password) {
|
||||||
return ['code' => 0, 'msg' => '密码错误', 'data' => ''];
|
return ['code' => 0, 'msg' => '密码错误', 'data' => ''];
|
||||||
}
|
}
|
||||||
@@ -1237,7 +1234,7 @@ class Room extends Model
|
|||||||
'sexy_coin' => $liao_ta_coin,
|
'sexy_coin' => $liao_ta_coin,
|
||||||
'start_time' => $room['start_time'],
|
'start_time' => $room['start_time'],
|
||||||
'end_time' => $room['end_time'],
|
'end_time' => $room['end_time'],
|
||||||
'password' => $room['password'],
|
'room_password' => $room['room_password'],
|
||||||
];
|
];
|
||||||
|
|
||||||
//当前用户信息
|
//当前用户信息
|
||||||
@@ -1505,7 +1502,7 @@ class Room extends Model
|
|||||||
'sexy_coin' => $liao_ta_coin,
|
'sexy_coin' => $liao_ta_coin,
|
||||||
'start_time' => $room['start_time'],
|
'start_time' => $room['start_time'],
|
||||||
'end_time' => $room['end_time'],
|
'end_time' => $room['end_time'],
|
||||||
'password' => $room['password'],
|
'room_password' => $room['room_password'],
|
||||||
];
|
];
|
||||||
|
|
||||||
//当前用户信息
|
//当前用户信息
|
||||||
@@ -2756,7 +2753,7 @@ class Room extends Model
|
|||||||
$user_info['is_room_owner'] = db::name('vs_room')->where(['id' => $room_id, 'user_id' => $user_id])->find() ? 1 : 0;
|
$user_info['is_room_owner'] = db::name('vs_room')->where(['id' => $room_id, 'user_id' => $user_id])->find() ? 1 : 0;
|
||||||
$user_info['is_follow'] = db::name('user_follow')->where(['user_id' => $uid, 'follow_id' => $user_id,'type' => 1])->find() ? 1 : 0;
|
$user_info['is_follow'] = db::name('user_follow')->where(['user_id' => $uid, 'follow_id' => $user_id,'type' => 1])->find() ? 1 : 0;
|
||||||
//近90天内收到的礼物数量
|
//近90天内收到的礼物数量
|
||||||
$user_info['gift_num'] = db::name('vs_give_gift')->where(['gift_user' => $user_id])->whereTime('createtime', '>', strtotime('-90 day'))->sum('number')?? 0;
|
$user_info['gift_num'] = db::name('user_gift_wall')->where(['user_id' => $user_id])->sum('count')?? 0;
|
||||||
|
|
||||||
$user_info['qinmi'] = null;
|
$user_info['qinmi'] = null;
|
||||||
$user_info['zhenai'] = null;
|
$user_info['zhenai'] = null;
|
||||||
@@ -2946,31 +2943,22 @@ class Room extends Model
|
|||||||
|
|
||||||
|
|
||||||
//修改房间类型
|
//修改房间类型
|
||||||
// $type 1-交友,2-拍卖,7-互娱,8-交友(不要了),9-点唱,10-签约,11-酒吧房
|
// $type 1-交友,2-拍卖,7-互娱,9-点唱,10-签约,11-酒吧房 99-练歌
|
||||||
public function change_room_type($uid,$room_id,$type)
|
public function change_room_type($uid,$room_id,$type)
|
||||||
{
|
{
|
||||||
if(!$uid || !$room_id || !$type){
|
|
||||||
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
|
|
||||||
}
|
|
||||||
$owner = db::name('vs_room')->where(['id' => $room_id, 'user_id' => $uid])->field('id')->find();
|
|
||||||
$host = db::name('vs_room_host')->where(['room_id' => $room_id, 'user_id' => $uid,'delete_time' => null])->find();
|
|
||||||
if(!$owner && !$host){
|
|
||||||
return ['code' => 0, 'msg' => '没有权限操作', 'data' => null];
|
|
||||||
}
|
|
||||||
|
|
||||||
$roomInfo = db::name('vs_room')->where(['id' => $room_id])->find();
|
$roomInfo = db::name('vs_room')->where(['id' => $room_id])->find();
|
||||||
if($roomInfo['type_id'] == $type && $roomInfo['type_id'] != 1){
|
if($roomInfo['type_id'] == $type && $roomInfo['type_id'] != 1){
|
||||||
return ['code' => 0, 'msg' => '房间类型已存在', 'data' => null];
|
return ['code' => 0, 'msg' => '房间类型已存在', 'data' => null];
|
||||||
}
|
}
|
||||||
|
|
||||||
if($roomInfo['type_id'] == 7 && ($roomInfo['step'] == 2 || $roomInfo['step'] == 3)){
|
if($roomInfo['type_id'] == 7 && ($roomInfo['step'] == 2 || $roomInfo['step'] == 3)){
|
||||||
return ['code' => 0, 'msg' => '请先结束交友后在修改房间类型', 'data' => null];
|
return ['code' => 0, 'msg' => '请先结束交友后再修改房间类型', 'data' => null];
|
||||||
}
|
}
|
||||||
|
|
||||||
if($roomInfo['type_id'] == 2){
|
if($roomInfo['type_id'] == 2){
|
||||||
$room_auction = db::name('vs_room_auction')->where(['room_id' => $room_id,'status' => 2])->select();
|
$room_auction = db::name('vs_room_auction')->where(['room_id' => $room_id,'status' => 2])->select();
|
||||||
if($room_auction){
|
if($room_auction){
|
||||||
return ['code' => 0, 'msg' => '请先结束竞拍后在修改房间类型', 'data' => null];
|
return ['code' => 0, 'msg' => '请先结束竞拍后再修改房间类型', 'data' => null];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2979,11 +2967,98 @@ class Room extends Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($roomInfo['type_id'] == 10 && $roomInfo['sign_type'] != 0){
|
if($roomInfo['type_id'] == 10 && $roomInfo['sign_type'] != 0){
|
||||||
return ['code' => 0, 'msg' => '请先结束签约后在修改房间类型', 'data' => null];
|
return ['code' => 0, 'msg' => '请先结束签约再在修改房间类型', 'data' => null];
|
||||||
}
|
}
|
||||||
|
|
||||||
//开启事务
|
if($roomInfo['type_id'] == 1){
|
||||||
db::startTrans();
|
$is_pk = db::name('vs_room_pk')->where(['room_id_a' => $room_id])->where(['status' => ['in',[2,3,4]]])->find();
|
||||||
|
$is_pk1 = db::name('vs_room_pk')->where(['room_id_b' => $room_id])->where(['status' => ['in',[2,3,4]]])->find();
|
||||||
|
if($is_pk || $is_pk1){
|
||||||
|
return ['code' => 0, 'msg' => '请先结束PK再在修改房间类型', 'data' => null];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
//1-交友
|
||||||
|
if($type == 1 || $type == 3 || $type == 4 || $type == 8){
|
||||||
|
$data = [
|
||||||
|
'label_id' => 1,
|
||||||
|
'type_id' => $type,
|
||||||
|
'room_up_pit_type' => 1,//1-排麦模式,2-自由模式
|
||||||
|
'is_song' => 1 //1-等待点歌申请
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
//拍卖
|
||||||
|
if($type == 2){
|
||||||
|
$data = [
|
||||||
|
'label_id' => 3,
|
||||||
|
'type_id' => $type,
|
||||||
|
'room_up_pit_type' => 1,//1-排麦模式,2-自由模式
|
||||||
|
'is_song' => 1 //1-等待点歌申请
|
||||||
|
];
|
||||||
|
//清除房间此前的魅力值
|
||||||
|
db::name('vs_room_user_charm')->where(['room_id' => $room_id])->update(['charm' => 0,'clear_time' => time()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//(互娱)
|
||||||
|
if($type == 7){
|
||||||
|
$data = [
|
||||||
|
'label_id' => 5,
|
||||||
|
'type_id' => $type,
|
||||||
|
'room_up_pit_type' => 1,//1-排麦模式,2-自由模式
|
||||||
|
'step' => 1 //1-等待开始
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
//点唱房 (让别人唱歌)
|
||||||
|
if($type == 9){
|
||||||
|
$data = [
|
||||||
|
'label_id' => 6,
|
||||||
|
'type_id' => $type,
|
||||||
|
'room_up_pit_type' => 1,//1-排麦模式,2-自由模式
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
//签约房
|
||||||
|
if($type == 10){
|
||||||
|
$data = [
|
||||||
|
'label_id' => 7,
|
||||||
|
'type_id' => $type,
|
||||||
|
'room_up_pit_type' => 1,//1-排麦模式,2-自由模式
|
||||||
|
'sign_type' => 0, //0-等待签约
|
||||||
|
'is_hot' => 1,//1-等待上热门
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
//酒吧房
|
||||||
|
if($type == 11){
|
||||||
|
$data = [
|
||||||
|
'label_id' => 8,
|
||||||
|
'type_id' => $type,
|
||||||
|
'room_up_pit_type' => 1,
|
||||||
|
'room_background' => db::name('vs_room_background')->where(['id' => 11])->value('image_url')
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
//练歌房
|
||||||
|
if($type == 99){
|
||||||
|
if($roomInfo['type_id'] == 1 && $roomInfo['type_id'] == 2){
|
||||||
|
return ['code' => 0, 'msg' => '房间类型已存在', 'data' => null];
|
||||||
|
}
|
||||||
|
$res1 = model('RoomSong')->agree_song($uid,$room_id,1);
|
||||||
|
if($res1['code'] == 0){
|
||||||
|
return ['code' => 0, 'msg' => $res1['msg'], 'data' => null];
|
||||||
|
}else{
|
||||||
|
$res = 1;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$res = db::name('vs_room')->where(['id' => $room_id])->update($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$res){
|
||||||
|
return ['code' => 0, 'msg' => '修改失败', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
//在麦位上的用户 全部下麦
|
//在麦位上的用户 全部下麦
|
||||||
$on_pit = db::name('vs_room_pit')->where(['room_id' => $room_id,'user_id' => ['>',0],'pit_number' => ['<>',9]])->select();
|
$on_pit = db::name('vs_room_pit')->where(['room_id' => $room_id,'user_id' => ['>',0],'pit_number' => ['<>',9]])->select();
|
||||||
@@ -3001,70 +3076,6 @@ class Room extends Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [];
|
|
||||||
//1-交友,3、4、8-不要了
|
|
||||||
if($type == 1 || $type == 3 || $type == 4 || $type == 8){
|
|
||||||
$data = [
|
|
||||||
'label_id' => 1,
|
|
||||||
'type_id' => $type,
|
|
||||||
'room_up_pit_type' => 1,
|
|
||||||
'is_song' => 1
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
//拍卖
|
|
||||||
if($type == 2){
|
|
||||||
$data = [
|
|
||||||
'label_id' => 3,
|
|
||||||
'type_id' => $type,
|
|
||||||
'room_up_pit_type' => 1,
|
|
||||||
'is_song' => 1
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
//(互娱)
|
|
||||||
if($type == 7){
|
|
||||||
$data = [
|
|
||||||
'label_id' => 5,
|
|
||||||
'type_id' => $type,
|
|
||||||
'room_up_pit_type' => 1,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
//点唱房 (让别人唱歌)
|
|
||||||
if($type == 9){
|
|
||||||
$data = [
|
|
||||||
'label_id' => 6,
|
|
||||||
'type_id' => $type,
|
|
||||||
'room_up_pit_type' => 1,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
//签约房
|
|
||||||
if($type == 10){
|
|
||||||
$data = [
|
|
||||||
'label_id' => 7,
|
|
||||||
'type_id' => $type,
|
|
||||||
'room_up_pit_type' => 1,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
//酒吧房
|
|
||||||
if($type == 11){
|
|
||||||
$data = [
|
|
||||||
'label_id' => 8,
|
|
||||||
'type_id' => $type,
|
|
||||||
'room_up_pit_type' => 1,
|
|
||||||
'room_background' => db::name('vs_room_background')->where(['id' => 11])->value('image_url')
|
|
||||||
];
|
|
||||||
}
|
|
||||||
$res = db::name('vs_room')->where(['id' => $room_id])->update($data);
|
|
||||||
|
|
||||||
if(!$res){
|
|
||||||
db::rollback();
|
|
||||||
return ['code' => 0, 'msg' => '修改失败', 'data' => null];
|
|
||||||
}
|
|
||||||
|
|
||||||
//如果房间正在点唱中,结束点唱
|
//如果房间正在点唱中,结束点唱
|
||||||
$romm_song = db::name('vs_room_song')->where(['room_id' => $room_id])->order('did desc')->find();
|
$romm_song = db::name('vs_room_song')->where(['room_id' => $room_id])->order('did desc')->find();
|
||||||
if(isset($romm_song) && ($romm_song['status'] == 1 || $romm_song['status'] == 2)){
|
if(isset($romm_song) && ($romm_song['status'] == 1 || $romm_song['status'] == 2)){
|
||||||
@@ -3078,32 +3089,6 @@ class Room extends Model
|
|||||||
//申请上麦的全部下麦
|
//申请上麦的全部下麦
|
||||||
model('RoomPit')->clear_apply_pit_list($uid, $room_id);
|
model('RoomPit')->clear_apply_pit_list($uid, $room_id);
|
||||||
|
|
||||||
if($type == 1 || $type == 3 || $type == 4 || $type == 7 || $type == 8 || $type == 9 || $type == 10 || $type == 11){
|
|
||||||
//查询拍卖房的状态
|
|
||||||
$room_auction = db::name('vs_room_auction')->where(['room_id' => $room_id,'status' => 2])->select();
|
|
||||||
if($room_auction){
|
|
||||||
foreach ($room_auction as $v){
|
|
||||||
model('RoomAuction')->room_auction_end($room_id,$v['auction_id']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//拍卖位上是否有人
|
|
||||||
$an = Cache::get('auction_user_'.$room_id);
|
|
||||||
if($an){
|
|
||||||
//拍卖位下麦
|
|
||||||
model('api/RoomPit')->host_user_pit($uid,$room_id,888,$an,2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if($type == 2){
|
|
||||||
//清除房间此前的魅力值
|
|
||||||
db::name('vs_room_user_charm')->where(['room_id' => $room_id])->update(['charm' => 0,'clear_time' => time()]);
|
|
||||||
//10号麦有人就下去
|
|
||||||
$pit_10 = db::name('vs_room_pit')->where(['room_id' => $room_id,'pit_number' => 10])->find();
|
|
||||||
if($pit_10 && $pit_10['user_id'] > 0){
|
|
||||||
model('RoomPit')->DownPit($pit_10['user_id'], $room_id,10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
db::commit();
|
|
||||||
//推送给前端
|
//推送给前端
|
||||||
$text = [
|
$text = [
|
||||||
'room_id' => $room_id,
|
'room_id' => $room_id,
|
||||||
|
|||||||
@@ -12,7 +12,18 @@ class RoomAuction extends Model
|
|||||||
public function room_relation_list($type_id)
|
public function room_relation_list($type_id)
|
||||||
{
|
{
|
||||||
$list = db::name('vs_relation')->field('id as relation_id,name,type,icon')->where(['type' => $type_id,'delete_time' => 0])->select();
|
$list = db::name('vs_relation')->field('id as relation_id,name,type,icon')->where(['type' => $type_id,'delete_time' => 0])->select();
|
||||||
return ['code' => 1, 'msg' => '操作成功','data' => $list];
|
if($list){
|
||||||
|
$relation_array = [
|
||||||
|
'relation_id' => 0,
|
||||||
|
'name' => '无关系',
|
||||||
|
'type' => 0,
|
||||||
|
'icon' => db::name('vs_relation')->where(['id' => 0])->value('icon'),
|
||||||
|
];
|
||||||
|
$lists = array_merge([$relation_array], (array)$list);
|
||||||
|
}else{
|
||||||
|
$lists = [];
|
||||||
|
}
|
||||||
|
return ['code' => 1, 'msg' => '操作成功','data' => $lists];
|
||||||
}
|
}
|
||||||
|
|
||||||
//礼物计算时间
|
//礼物计算时间
|
||||||
|
|||||||
@@ -546,7 +546,7 @@ class RoomPit extends Model
|
|||||||
array_unshift($list['special'],$special);
|
array_unshift($list['special'],$special);
|
||||||
}
|
}
|
||||||
if($list['special']){
|
if($list['special']){
|
||||||
foreach ($list['special'] as $k => $v){
|
foreach ($list['special'] as &$v){
|
||||||
//查询用户的爵位
|
//查询用户的爵位
|
||||||
$juewei = model('Nobility')->getUserNobilityInfo($v['user_id']);
|
$juewei = model('Nobility')->getUserNobilityInfo($v['user_id']);
|
||||||
if($juewei){
|
if($juewei){
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ class SendGift extends Model
|
|||||||
//查询礼物是否是盲盒
|
//查询礼物是否是盲盒
|
||||||
if($gift_info['label'] == 2){//趣味礼物(盲盒)
|
if($gift_info['label'] == 2){//趣味礼物(盲盒)
|
||||||
//前端没传参数补偿
|
//前端没传参数补偿
|
||||||
if(!$gift_bag_id){
|
if($gift_bag_id <= 0){
|
||||||
if($gid == 302){
|
if($gid == 302){
|
||||||
$gift_bag_id = 7;
|
$gift_bag_id = 7;
|
||||||
}elseif ($gid == 303){
|
}elseif ($gid == 303){
|
||||||
@@ -856,7 +856,7 @@ class SendGift extends Model
|
|||||||
//查询礼物是否是盲盒
|
//查询礼物是否是盲盒
|
||||||
if($gift_info['label'] == 2){//趣味礼物(盲盒)
|
if($gift_info['label'] == 2){//趣味礼物(盲盒)
|
||||||
//前端没传参数补偿
|
//前端没传参数补偿
|
||||||
if(!$gift_bag_id){
|
if($gift_bag_id <= 0){
|
||||||
if($gid == 302){
|
if($gid == 302){
|
||||||
$gift_bag_id = 7;
|
$gift_bag_id = 7;
|
||||||
}elseif ($gid == 303){
|
}elseif ($gid == 303){
|
||||||
@@ -1483,11 +1483,17 @@ class SendGift extends Model
|
|||||||
//获取盲盒配置
|
//获取盲盒配置
|
||||||
if($gift_bag_id){
|
if($gift_bag_id){
|
||||||
$gift_bag = db::name("vs_gift_bag")->where(['id'=>$gift_bag_id])->find();
|
$gift_bag = db::name("vs_gift_bag")->where(['id'=>$gift_bag_id])->find();
|
||||||
|
if($gift_bag['status'] ==0){
|
||||||
|
return ['code' => 0, 'msg' => '当前盲盒已关闭', 'data' => []];
|
||||||
|
}
|
||||||
if(!$gift_bag){
|
if(!$gift_bag){
|
||||||
return ['code' => 0, 'msg' => '当前盲盒不存在', 'data' => []];
|
return ['code' => 0, 'msg' => '当前盲盒不存在', 'data' => []];
|
||||||
}
|
}
|
||||||
$periods = $gift_bag['periods'] ?? 0;
|
$periods = $gift_bag['periods'] ?? 0;
|
||||||
$bag_gift = db::name("vs_gift")->where(['gid'=>$gift_id])->find();// 获取盲盒信息
|
$bag_gift = db::name("vs_gift")->where(['gid'=>$gift_id,'is_show'=>1,'is_can_buy'=>1])->find();// 获取盲盒信息
|
||||||
|
if(empty($bag_gift)){
|
||||||
|
return ['code' => 0, 'msg' => '当前盲盒已关闭', 'data' => []];
|
||||||
|
}
|
||||||
//随机获取一个礼物
|
//随机获取一个礼物
|
||||||
$where = [
|
$where = [
|
||||||
'gift_bag_id' => $gift_bag_id,
|
'gift_bag_id' => $gift_bag_id,
|
||||||
|
|||||||
@@ -405,23 +405,42 @@ class Tencent extends Model
|
|||||||
$im_admin = 'administrator';
|
$im_admin = 'administrator';
|
||||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||||
$rand = rand(111111111,9999999999);
|
$rand = rand(111111111,9999999999);
|
||||||
|
|
||||||
$postUrl = 'https://console.tim.qq.com/v4/openim/sendmsg?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
$postUrl = 'https://console.tim.qq.com/v4/openim/sendmsg?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||||
|
if($uid == 'administrator'){
|
||||||
$curlPost = array(
|
$from_Account ="administrator";
|
||||||
'SyncOtherMachine' => $machine_type,
|
$curlPost = array(
|
||||||
'From_Account' => strval('u'.$uid),
|
'SyncOtherMachine' => $machine_type,
|
||||||
'To_Account' => strval('u'.$receive_uid),
|
'From_Account' => strval($from_Account),
|
||||||
'MsgRandom' => time(),
|
'To_Account' => strval('u'.$receive_uid),
|
||||||
'MsgBody' => array(
|
'MsgRandom' => time(),
|
||||||
array(
|
'SendMsgControl' => ["NoUnread", "NoLastMsg", "NoMsgCheck"],
|
||||||
'MsgType' => 'TIMTextElem',
|
'MsgBody' => array(
|
||||||
'MsgContent' => array(
|
array(
|
||||||
'Text' => $message,
|
'MsgType' => 'TIMCustomElem',
|
||||||
|
'MsgContent' => array(
|
||||||
|
'Data' => $message,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
$from_Account ="u".$uid;
|
||||||
|
$curlPost = array(
|
||||||
|
'SyncOtherMachine' => $machine_type,
|
||||||
|
'From_Account' => strval($from_Account),
|
||||||
|
'To_Account' => strval('u'.$receive_uid),
|
||||||
|
'MsgRandom' => time(),
|
||||||
|
'MsgBody' => array(
|
||||||
|
array(
|
||||||
|
'MsgType' => 'TIMTextElem',
|
||||||
|
'MsgContent' => array(
|
||||||
|
'Text' => $message,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if($OnlineOnlyFlag == 1){
|
if($OnlineOnlyFlag == 1){
|
||||||
$curlPost['OnlineOnlyFlag'] = 1;
|
$curlPost['OnlineOnlyFlag'] = 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -484,18 +484,21 @@ class User extends Model
|
|||||||
foreach ($result as $item){
|
foreach ($result as $item){
|
||||||
$userInfo = [];
|
$userInfo = [];
|
||||||
$top_users_count = 0;
|
$top_users_count = 0;
|
||||||
$users = json_decode($item['give_user_ids'], true);
|
if($item['give_user_ids'] != null){
|
||||||
if($users){
|
$users = json_decode($item['give_user_ids'], true);
|
||||||
foreach ($users as $kk => $user_id){
|
|
||||||
$userInfo[$kk] = db::name('user')->where(['id' => $user_id['user_id']])->field('id user_id,nickname,avatar')->find();
|
if($users && is_array($users)){
|
||||||
$userInfo[$kk]['count'] = $user_id['count'];
|
foreach ($users as $kk => $user_id){
|
||||||
$top_users_count ++;
|
$userInfo[$kk] = db::name('user')->where(['id' => $user_id['user_id']])->field('id user_id,nickname,avatar')->find();
|
||||||
|
$userInfo[$kk]['count'] = $user_id['count'];
|
||||||
|
$top_users_count ++;
|
||||||
|
}
|
||||||
|
//用户信息$userInfo 按照数量 count 排序且保留前三个
|
||||||
|
usort($userInfo, function ($a, $b) {
|
||||||
|
return $b['count'] - $a['count'];
|
||||||
|
});
|
||||||
|
$userInfo = array_slice($userInfo, 0, 3);
|
||||||
}
|
}
|
||||||
//用户信息$userInfo 按照数量 count 排序且保留前三个
|
|
||||||
usort($userInfo, function ($a, $b) {
|
|
||||||
return $b['count'] - $a['count'];
|
|
||||||
});
|
|
||||||
$userInfo = array_slice($userInfo, 0, 3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$data[] = [
|
$data[] = [
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class UserCp extends Model
|
|||||||
->where(['from_user_id' => $to_user_id, 'to_user_id' => $from_user_id,'status' => 0])
|
->where(['from_user_id' => $to_user_id, 'to_user_id' => $from_user_id,'status' => 0])
|
||||||
->find();
|
->find();
|
||||||
|
|
||||||
if($res && $res['createtime'] + 86400 < time()){//24小时内
|
if($res && $res['createtime'] - 86400 < time()){//24小时内
|
||||||
//创建推送信息1:回应送礼 并创建Cp空间,
|
//创建推送信息1:回应送礼 并创建Cp空间,
|
||||||
$data = [
|
$data = [
|
||||||
'from_user_id' => $from_user_id,
|
'from_user_id' => $from_user_id,
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ class UserGiftPack extends Model
|
|||||||
const DAILY_SIGN = 12;
|
const DAILY_SIGN = 12;
|
||||||
//盲盒转盘抽奖所得
|
//盲盒转盘抽奖所得
|
||||||
const BLANK_BOX_DRAW_GIFT_GET = 13;
|
const BLANK_BOX_DRAW_GIFT_GET = 13;
|
||||||
|
//炼仙传说中奖获取
|
||||||
|
const LY_DRAW_GIFT_GET = 14;
|
||||||
|
|
||||||
public static function init()
|
public static function init()
|
||||||
{
|
{
|
||||||
@@ -66,7 +68,8 @@ class UserGiftPack extends Model
|
|||||||
self::NEW_CHARGE_GIFT => '新人充值好礼',
|
self::NEW_CHARGE_GIFT => '新人充值好礼',
|
||||||
self::TASK_REWARD => '任务奖励',
|
self::TASK_REWARD => '任务奖励',
|
||||||
self::DAILY_SIGN => '每日签到',
|
self::DAILY_SIGN => '每日签到',
|
||||||
self::BLANK_BOX_DRAW_GIFT_GET => '盲盒转盘抽奖所得'
|
self::BLANK_BOX_DRAW_GIFT_GET => '盲盒转盘抽奖所得',
|
||||||
|
self::LY_DRAW_GIFT_GET => '炼仙传说中奖获取'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class UserWallet extends Model
|
|||||||
// 15.首充 16.天降好礼充值 17.退出工会扣款 18.房主收益 19.主持人收益 20.抢头条 21.公会长收益,22.提现驳回或提现失败返还,23.财富等级奖励金币领取,24.删除关系扣金币,
|
// 15.首充 16.天降好礼充值 17.退出工会扣款 18.房主收益 19.主持人收益 20.抢头条 21.公会长收益,22.提现驳回或提现失败返还,23.财富等级奖励金币领取,24.删除关系扣金币,
|
||||||
// 25.赠送好友金币,26.好友转赠所得金币,27.小时榜获得金币,28.新人充值好礼,29.发红包(钻石),30.抢红包(金币),31.抢红包(钻石),32.发红包(金币),
|
// 25.赠送好友金币,26.好友转赠所得金币,27.小时榜获得金币,28.新人充值好礼,29.发红包(钻石),30.抢红包(金币),31.抢红包(钻石),32.发红包(金币),
|
||||||
// 33.红包剩余退回(金币),34-红包剩余退回(钻石),35-爵位购买赠送金币(金币),40-后台充值金币,41-后台充值钻石,42-后台扣除金币,43-后台扣除钻石,
|
// 33.红包剩余退回(金币),34-红包剩余退回(钻石),35-爵位购买赠送金币(金币),40-后台充值金币,41-后台充值钻石,42-后台扣除金币,43-后台扣除钻石,
|
||||||
//50-签约,51-签约失败退回,52-首次被签约收入,53.签约师傅每日返还,54-叛徒补偿,55-徒弟收礼返佣,56-续约,57-签到,58-爆币,59-红包手续费
|
//50-签约,51-签约失败退回,52-首次被签约收入,53.签约师傅每日返还,54-叛徒补偿,55-徒弟收礼返佣,56-续约,57-签到,58-爆币,59-红包手续费 60-炼仙传说抽奖扣除金币
|
||||||
public function log_list($uid, $last_id, $page_limit,$in_out_type,$start_time,$end_time,$gift_type)
|
public function log_list($uid, $last_id, $page_limit,$in_out_type,$start_time,$end_time,$gift_type)
|
||||||
{
|
{
|
||||||
// 时间范围处理
|
// 时间范围处理
|
||||||
@@ -76,7 +76,7 @@ class UserWallet extends Model
|
|||||||
$in_out_types = [2,5,6,8,13,14,15,16,22,23,26,27,30,28,33,40,44,51,57,58];
|
$in_out_types = [2,5,6,8,13,14,15,16,22,23,26,27,30,28,33,40,44,51,57,58];
|
||||||
$map['change_type'] = ['in', $in_out_types];
|
$map['change_type'] = ['in', $in_out_types];
|
||||||
}else{//2-支出
|
}else{//2-支出
|
||||||
$in_out_types = [4,7,10,17,20,24,25,32,42,50,56,59];
|
$in_out_types = [4,7,10,17,20,24,25,32,42,50,56,59,60];
|
||||||
$map['change_type'] = ['in', $in_out_types];
|
$map['change_type'] = ['in', $in_out_types];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,14 +233,14 @@ class UserWallet extends Model
|
|||||||
// 15.首充 16.天降好礼充值 17.退出工会扣款 18.房主收益 19.主持人收益 20.抢头条 21.公会长收益,22.提现驳回或提现失败返还,23.财富等级奖励金币领取,24.删除关系扣金币,
|
// 15.首充 16.天降好礼充值 17.退出工会扣款 18.房主收益 19.主持人收益 20.抢头条 21.公会长收益,22.提现驳回或提现失败返还,23.财富等级奖励金币领取,24.删除关系扣金币,
|
||||||
// 25.赠送好友金币,26.好友转赠所得金币,27.小时榜获得金币,28.新人充值好礼,29.发红包(钻石),30.抢红包(金币),31.抢红包(钻石),32.发红包(金币),
|
// 25.赠送好友金币,26.好友转赠所得金币,27.小时榜获得金币,28.新人充值好礼,29.发红包(钻石),30.抢红包(金币),31.抢红包(钻石),32.发红包(金币),
|
||||||
// 33.红包剩余退回(金币),34-红包剩余退回(钻石),35-爵位购买赠送金币(金币),,40-后台充值金币,41-后台充值钻石,42-后台扣除金币,43-后台扣除钻石,
|
// 33.红包剩余退回(金币),34-红包剩余退回(钻石),35-爵位购买赠送金币(金币),,40-后台充值金币,41-后台充值钻石,42-后台扣除金币,43-后台扣除钻石,
|
||||||
//50-签约,51-签约失败退回,52-首次被签约收入,53.签约师傅每日返还,54-叛徒补偿,55-徒弟收礼返佣,56-续约,57-签到,58-爆币,59-红包手续费
|
//50-签约,51-签约失败退回,52-首次被签约收入,53.签约师傅每日返还,54-叛徒补偿,55-徒弟收礼返佣,56-续约,57-签到,58-爆币,59-红包手续费 60-炼仙传说抽奖扣除金币
|
||||||
//资金操作
|
//资金操作
|
||||||
public function change_user_cion_log($user_id,$money,$room_id,$change_type,$remarks)
|
public function change_user_cion_log($user_id,$money,$room_id,$change_type,$remarks)
|
||||||
{
|
{
|
||||||
//增加用户金币类型
|
//增加用户金币类型
|
||||||
$in_types = [2,5,6,8,13,14,15,16,23,26,27,28,30,33,35,40,51,57,58];
|
$in_types = [2,5,6,8,13,14,15,16,23,26,27,28,30,33,35,40,51,57,58,44];
|
||||||
//减少用户金币类型
|
//减少用户金币类型
|
||||||
$out_types = [4,7,10,17,20,24,25,32,42,50,56,59];
|
$out_types = [4,7,10,17,20,24,25,32,42,50,56,59,60];
|
||||||
|
|
||||||
$user_wallet = Db::name('user_wallet_coin')->where(['user_id' => $user_id])->lock(true)->find();
|
$user_wallet = Db::name('user_wallet_coin')->where(['user_id' => $user_id])->lock(true)->find();
|
||||||
if (!$user_wallet) {
|
if (!$user_wallet) {
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class UserZone extends Model
|
|||||||
}
|
}
|
||||||
$map['a.show_status'] = 1;//1:显示 0不显示
|
$map['a.show_status'] = 1;//1:显示 0不显示
|
||||||
$map['a.is_delete'] = 1;//是否删除 1否2是
|
$map['a.is_delete'] = 1;//是否删除 1否2是
|
||||||
// $map['b.status'] = ['<>',0];//是否注销 1正常,2禁止登录,0注销
|
$map['b.status'] = ['<>',0];//是否注销 1正常,2禁止登录,0注销
|
||||||
|
|
||||||
$order_string = 'a.createtime desc'; //排序规则
|
$order_string = 'a.createtime desc'; //排序规则
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ class BaseCom extends Controller
|
|||||||
|
|
||||||
if (empty($token)) {
|
if (empty($token)) {
|
||||||
// 3. Token为空,拒绝访问
|
// 3. Token为空,拒绝访问
|
||||||
return V(0, 'Token不能为空');
|
return V(301, 'Token不能为空');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. 核心验证:检查Token是否有效
|
// 4. 核心验证:检查Token是否有效
|
||||||
|
|||||||
@@ -77,6 +77,8 @@ class Push
|
|||||||
const PUSH_ROOM_PAN_HOUR_PROGRESS = 8001;
|
const PUSH_ROOM_PAN_HOUR_PROGRESS = 8001;
|
||||||
//红包
|
//红包
|
||||||
const PUSH_ROOM_PAN_RED_PROGRESS = 8002;
|
const PUSH_ROOM_PAN_RED_PROGRESS = 8002;
|
||||||
|
//炼仙传说
|
||||||
|
const PUSH_ROOM_PAN_XLXS_PROGRESS = 8003;
|
||||||
|
|
||||||
public $user_id, $room_id, $topic_room, $topic_client;
|
public $user_id, $room_id, $topic_room, $topic_client;
|
||||||
|
|
||||||
@@ -315,6 +317,12 @@ class Push
|
|||||||
$this->push(self::PUSH_ROOM_PAN_RED_PROGRESS, $topic, $data);
|
$this->push(self::PUSH_ROOM_PAN_RED_PROGRESS, $topic, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//炼仙传说
|
||||||
|
public function xianxuan($data){
|
||||||
|
$topic = 'qx_xianxuan';
|
||||||
|
$this->push(self::PUSH_ROOM_PAN_XLXS_PROGRESS, $topic, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// =========================================项目使用结束=====================================================
|
// =========================================项目使用结束=====================================================
|
||||||
|
|||||||
@@ -8,50 +8,39 @@ class LotteryGiftLua
|
|||||||
public static function getLotteryLuaScript()
|
public static function getLotteryLuaScript()
|
||||||
{
|
{
|
||||||
return <<<LUA
|
return <<<LUA
|
||||||
-- 接收参数:send_uid, recv_uid, gift_gold, small_trigger_times, big_threshold, small_round, big_round, big_total_gold
|
-- 接收参数:send_uid, gift_gold, small_trigger_times, big_threshold, small_round, big_round, big_total_gold
|
||||||
local send_uid = ARGV[1]
|
local send_uid = ARGV[1]
|
||||||
local recv_uid = ARGV[2]
|
local gift_gold = tonumber(ARGV[2])
|
||||||
local gift_gold = tonumber(ARGV[3])
|
local small_trigger_times = tonumber(ARGV[3]) or 200 -- 小奖池触发次数
|
||||||
local small_trigger_times = tonumber(ARGV[4])
|
local small_round = tonumber(ARGV[4]) -- 小奖池当前轮次
|
||||||
local big_threshold = tonumber(ARGV[5])
|
local lucky_rate = tonumber(ARGV[5]) -- 收益率
|
||||||
local small_round = tonumber(ARGV[6]) -- 小奖池当前轮次
|
local lottery_rate = tonumber(ARGV[6]) -- 爆币率
|
||||||
local big_round = tonumber(ARGV[7]) -- 大奖池当前轮次
|
|
||||||
local big_total_gold = tonumber(ARGV[8]) -- 大奖池当前轮次金额
|
|
||||||
|
|
||||||
-- 核心约束:强制小轮次 ≥ 大轮次
|
|
||||||
if small_round < big_round then
|
|
||||||
small_round = big_round
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 1. 基础金额拆分
|
-- 1. 基础金额拆分
|
||||||
local recv_gold = gift_gold * 0.5
|
local recv_gold = gift_gold * lucky_rate / 100
|
||||||
local small_pool_add = gift_gold * 0.5
|
local pool_add_rate = 100 - lucky_rate
|
||||||
|
local small_pool_add = gift_gold * pool_add_rate / 100
|
||||||
|
|
||||||
|
|
||||||
-- 2. Redis键定义
|
-- 2. Redis键定义
|
||||||
local small_round_key = "lottery:small_pool:round"
|
local small_round_key = "lottery:small_pool:round"
|
||||||
local small_total_times_key = "lottery:small_pool:total_times"
|
local small_total_times_key = "lottery:small_pool:total_times"
|
||||||
local small_total_gold_key = "lottery:small_pool:total_gold"
|
local small_total_gold_key = "lottery:small_pool:total_gold"
|
||||||
local big_round_key = "lottery:big_pool:round"
|
|
||||||
local big_total_gold_key = "lottery:big_pool:total_gold"
|
|
||||||
|
|
||||||
-- 初始化轮次(确保Redis与入参一致)
|
-- 初始化轮次(确保Redis与入参一致)
|
||||||
redis.call('set', small_round_key, small_round)
|
redis.call('set', small_round_key, small_round)
|
||||||
redis.call('set', big_round_key, big_round)
|
|
||||||
-- 初始化大奖池金额
|
|
||||||
if big_total_gold == 0 or big_total_gold == nil then
|
|
||||||
big_total_gold = tonumber(redis.call('get', big_total_gold_key) or 0)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 3. 小奖池累计更新
|
-- 3. 小奖池累计更新
|
||||||
local small_total_times = tonumber(redis.call('incr', small_total_times_key))
|
local small_total_times = tonumber(redis.call('incr', small_total_times_key))
|
||||||
local small_total_gold = tonumber(redis.call('get', small_total_gold_key) or 0)
|
local small_total_gold = tonumber(redis.call('get', small_total_gold_key) or 0)
|
||||||
small_total_gold = math.floor((small_total_gold + small_pool_add) * 100) / 100
|
small_total_gold = small_total_gold + small_pool_add
|
||||||
redis.call('set', small_total_gold_key, small_total_gold)
|
local small_total_golds = string.format("%.2f", small_total_gold)
|
||||||
|
redis.call('set', small_total_gold_key, small_total_golds)
|
||||||
|
|
||||||
-- 4. 返回结果初始化(区分大小轮次)
|
-- 4. 返回结果初始化(区分大小轮次)
|
||||||
local result = {
|
local result = {
|
||||||
send_uid = send_uid,
|
send_uid = send_uid,
|
||||||
recv_uid = recv_uid,
|
|
||||||
gift_gold = gift_gold,
|
gift_gold = gift_gold,
|
||||||
recv_gold = recv_gold,
|
recv_gold = recv_gold,
|
||||||
small_pool_add = small_pool_add,
|
small_pool_add = small_pool_add,
|
||||||
@@ -59,71 +48,22 @@ local result = {
|
|||||||
small_total_gold = small_total_gold,
|
small_total_gold = small_total_gold,
|
||||||
is_small_prize = 0,
|
is_small_prize = 0,
|
||||||
small_prize_amount = 0,
|
small_prize_amount = 0,
|
||||||
small_remain_amount = 0,
|
|
||||||
is_big_prize = 0,
|
|
||||||
big_prize_amount = 0,
|
|
||||||
big_release_amount = 0,
|
|
||||||
small_round = small_round, -- 小奖池轮次
|
small_round = small_round, -- 小奖池轮次
|
||||||
big_round = big_round, -- 大奖池轮次
|
|
||||||
big_total_gold = big_total_gold,
|
|
||||||
-- 新增:记录要划入下一轮的小奖开奖金额
|
|
||||||
small_prize_to_big_next_round = 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-- 5. 小奖池开奖判断(小轮次+1)
|
-- 5. 小奖池开奖判断(小轮次+1)
|
||||||
if small_total_times >= small_trigger_times then
|
if small_total_times >= small_trigger_times then
|
||||||
result.is_small_prize = 1
|
result.is_small_prize = 1
|
||||||
-- 小奖随机比例
|
-- 小奖随机比例
|
||||||
local small_ratio = math.random(2, 99)
|
local small_ratio = math.random(2, lottery_rate)
|
||||||
result.small_prize_amount = math.floor(small_total_gold * small_ratio / 100 * 100) / 100
|
result.small_prize_amount = math.floor(small_total_gold * small_ratio / 100 * 100) / 100
|
||||||
-- 小奖剩余金额(划入大奖池当前轮次)
|
|
||||||
result.small_remain_amount = math.floor((small_total_gold - result.small_prize_amount) * 100) / 100
|
|
||||||
|
|
||||||
-- 重置小奖池,小轮次+1
|
-- 重置小奖池,小轮次+1
|
||||||
redis.call('set', small_total_times_key, 0)
|
redis.call('set', small_total_times_key, 0)
|
||||||
redis.call('set', small_total_gold_key, 0)
|
redis.call('set', small_total_gold_key, 0)
|
||||||
small_round = small_round + 1
|
small_round = small_round + 1
|
||||||
redis.call('set', small_round_key, small_round)
|
redis.call('set', small_round_key, small_round)
|
||||||
result.small_round = small_round
|
result.small_round = small_round
|
||||||
|
|
||||||
-- 6. 小奖剩余划入大奖池当前轮次
|
|
||||||
big_total_gold = math.floor((big_total_gold + result.small_remain_amount) * 100) / 100
|
|
||||||
redis.call('set', big_total_gold_key, big_total_gold)
|
|
||||||
result.big_total_gold = big_total_gold
|
|
||||||
|
|
||||||
-- 7. 大奖池开奖判断(大轮次+1)
|
|
||||||
if big_total_gold >= big_threshold then
|
|
||||||
result.is_big_prize = 1
|
|
||||||
-- 大奖比例权重
|
|
||||||
local weight_sum = 20 + 50 + 30
|
|
||||||
local random_weight = math.random(1, weight_sum)
|
|
||||||
local big_ratio = random_weight <= 20 and 60 or (random_weight <= 70 and 70 or 80)
|
|
||||||
-- 大奖金额
|
|
||||||
result.big_prize_amount = math.floor(big_total_gold * big_ratio / 100 * 100) / 100
|
|
||||||
result.big_release_amount = math.floor((big_total_gold - result.big_prize_amount) * 100) / 100
|
|
||||||
|
|
||||||
-- 原有逻辑:重置大奖池,大轮次+1
|
|
||||||
redis.call('set', big_total_gold_key, 0)
|
|
||||||
big_round = big_round + 1
|
|
||||||
redis.call('set', big_round_key, big_round)
|
|
||||||
-- 强制保证小轮次≥大轮次
|
|
||||||
if small_round < big_round then
|
|
||||||
small_round = big_round
|
|
||||||
redis.call('set', small_round_key, small_round)
|
|
||||||
result.small_round = small_round
|
|
||||||
end
|
|
||||||
result.big_round = big_round
|
|
||||||
result.big_total_gold = 0
|
|
||||||
|
|
||||||
-- ===================== 新增核心逻辑 =====================
|
|
||||||
-- 小奖开奖金额累加到大奖池下一轮次(新的big_round)
|
|
||||||
result.small_prize_to_big_next_round = result.small_prize_amount
|
|
||||||
-- 原子性更新大奖池下一轮次金额
|
|
||||||
local new_big_total_gold = math.floor(result.small_prize_amount * 100) / 100
|
|
||||||
redis.call('set', big_total_gold_key, new_big_total_gold)
|
|
||||||
result.big_total_gold = new_big_total_gold
|
|
||||||
-- ======================================================
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 返回结果
|
-- 返回结果
|
||||||
@@ -132,6 +72,145 @@ LUA;
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取Lua脚本
|
||||||
|
public static function getLotteryLuaScript5()
|
||||||
|
{
|
||||||
|
return <<<LUA
|
||||||
|
-- 接收参数:send_uid, gift_gold, small_trigger_times, big_threshold, small_round, big_round, big_total_gold
|
||||||
|
local send_uid = ARGV[1]
|
||||||
|
local gift_gold = tonumber(ARGV[2])
|
||||||
|
local small_trigger_times = tonumber(ARGV[3]) or 200 -- 小奖池触发次数
|
||||||
|
local small_round = tonumber(ARGV[4]) -- 小奖池当前轮次
|
||||||
|
local lucky_rate = tonumber(ARGV[5]) -- 收益率
|
||||||
|
local lottery_rate = tonumber(ARGV[6]) -- 爆币率
|
||||||
|
|
||||||
|
-- 1. 基础金额拆分
|
||||||
|
local pool_add_rate = 100 - lucky_rate -- 累加金币率
|
||||||
|
local small_pool_add = gift_gold * pool_add_rate / 100 -- 累加金币
|
||||||
|
|
||||||
|
|
||||||
|
-- 2. Redis键定义
|
||||||
|
local small_round_key = "lottery:small_pool:round_5"
|
||||||
|
local small_total_times_key = "lottery:small_pool:total_times_5"
|
||||||
|
local small_total_gold_key = "lottery:small_pool:total_gold_5"
|
||||||
|
|
||||||
|
-- 初始化轮次(确保Redis与入参一致)
|
||||||
|
redis.call('set', small_round_key, small_round)
|
||||||
|
|
||||||
|
|
||||||
|
-- 3. 小奖池累计更新
|
||||||
|
local small_total_times = tonumber(redis.call('incr', small_total_times_key))
|
||||||
|
local small_total_gold = tonumber(redis.call('get', small_total_gold_key) or 0)
|
||||||
|
small_total_gold = small_total_gold + small_pool_add
|
||||||
|
local small_total_golds = string.format("%.2f", small_total_gold)
|
||||||
|
redis.call('set', small_total_gold_key, small_total_golds)
|
||||||
|
|
||||||
|
-- 4. 返回结果初始化(区分大小轮次)
|
||||||
|
local result = {
|
||||||
|
send_uid = send_uid,
|
||||||
|
gift_gold = gift_gold,
|
||||||
|
small_pool_add = small_pool_add,
|
||||||
|
small_total_times = small_total_times,
|
||||||
|
small_total_gold = small_total_gold,
|
||||||
|
is_small_prize = 0,
|
||||||
|
small_prize_amount = 0,
|
||||||
|
small_round = small_round, -- 小奖池轮次
|
||||||
|
}
|
||||||
|
|
||||||
|
-- 5. 小奖池开奖判断(小轮次+1)
|
||||||
|
if small_total_times >= small_trigger_times then
|
||||||
|
result.is_small_prize = 1
|
||||||
|
-- 小奖随机比例
|
||||||
|
local small_ratio = math.random(2, lottery_rate)
|
||||||
|
result.small_prize_amount = math.floor(small_total_gold * small_ratio / 100 * 100) / 100
|
||||||
|
|
||||||
|
-- 重置小奖池,小轮次+1
|
||||||
|
redis.call('set', small_total_times_key, 0)
|
||||||
|
redis.call('set', small_total_gold_key, 0)
|
||||||
|
small_round = small_round + 1
|
||||||
|
redis.call('set', small_round_key, small_round)
|
||||||
|
result.small_round = small_round
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 返回结果
|
||||||
|
return cjson.encode(result)
|
||||||
|
LUA;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 获取Lua脚本
|
||||||
|
public static function getLotteryLuaScript10()
|
||||||
|
{
|
||||||
|
return <<<LUA
|
||||||
|
-- 接收参数:send_uid, gift_gold, small_trigger_times, big_threshold, small_round, big_round, big_total_gold
|
||||||
|
local send_uid = ARGV[1]
|
||||||
|
local gift_gold = tonumber(ARGV[2])
|
||||||
|
local small_trigger_times = tonumber(ARGV[3]) or 200 -- 小奖池触发次数
|
||||||
|
local small_round = tonumber(ARGV[4]) -- 小奖池当前轮次
|
||||||
|
local lucky_rate = tonumber(ARGV[5]) -- 收益率
|
||||||
|
local lottery_rate = tonumber(ARGV[6]) -- 爆币率
|
||||||
|
|
||||||
|
-- 1. 基础金额拆分
|
||||||
|
local pool_add_rate = 100 - lucky_rate
|
||||||
|
local small_pool_adds = gift_gold * pool_add_rate / 100
|
||||||
|
|
||||||
|
local small_pool_add = string.format("%.2f", small_pool_adds)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- 2. Redis键定义
|
||||||
|
local small_round_key = "lottery:small_pool:round_10"
|
||||||
|
local small_total_times_key = "lottery:small_pool:total_times_10"
|
||||||
|
local small_total_gold_key = "lottery:small_pool:total_gold_10"
|
||||||
|
|
||||||
|
-- 初始化轮次(确保Redis与入参一致)
|
||||||
|
redis.call('set', small_round_key, small_round)
|
||||||
|
|
||||||
|
|
||||||
|
-- 3. 小奖池累计更新
|
||||||
|
local small_total_times = tonumber(redis.call('incr', small_total_times_key))
|
||||||
|
local small_total_gold = tonumber(redis.call('get', small_total_gold_key) or 0)
|
||||||
|
small_total_gold = small_total_gold + small_pool_add
|
||||||
|
local small_total_golds = string.format("%.2f", small_total_gold)
|
||||||
|
redis.call('set', small_total_gold_key, small_total_golds)
|
||||||
|
|
||||||
|
-- 4. 返回结果初始化(区分大小轮次)
|
||||||
|
local result = {
|
||||||
|
send_uid = send_uid,
|
||||||
|
gift_gold = gift_gold,
|
||||||
|
small_pool_add = small_pool_add,
|
||||||
|
small_total_times = small_total_times,
|
||||||
|
small_total_gold = small_total_gold,
|
||||||
|
is_small_prize = 0,
|
||||||
|
small_prize_amount = 0,
|
||||||
|
small_round = small_round, -- 小奖池轮次
|
||||||
|
}
|
||||||
|
|
||||||
|
-- 5. 小奖池开奖判断(小轮次+1)
|
||||||
|
if small_total_times >= small_trigger_times then
|
||||||
|
result.is_small_prize = 1
|
||||||
|
-- 小奖随机比例
|
||||||
|
local small_ratio = math.random(2, lottery_rate)
|
||||||
|
result.small_prize_amount = math.floor(small_total_gold * small_ratio / 100 * 100) / 100
|
||||||
|
|
||||||
|
-- 重置小奖池,小轮次+1
|
||||||
|
redis.call('set', small_total_times_key, 0)
|
||||||
|
redis.call('set', small_total_gold_key, 0)
|
||||||
|
small_round = small_round + 1
|
||||||
|
redis.call('set', small_round_key, small_round)
|
||||||
|
result.small_round = small_round
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 返回结果
|
||||||
|
return cjson.encode(result)
|
||||||
|
LUA;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 获取Lua脚本
|
// 获取Lua脚本
|
||||||
public static function getLotteryLuaScripts()
|
public static function getLotteryLuaScripts()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -123,6 +123,8 @@ class UserWallet extends Model
|
|||||||
const BACKGROUND_DEDUCTION_DIAMOND = 43;
|
const BACKGROUND_DEDUCTION_DIAMOND = 43;
|
||||||
//公会会员付费退出会长收入
|
//公会会员付费退出会长收入
|
||||||
const GUILD_EXIT_DEACON_INCOME = 44;
|
const GUILD_EXIT_DEACON_INCOME = 44;
|
||||||
|
//炼仙传说抽奖扣除金币
|
||||||
|
const LINGXIAN_TRADITION_LOTTERY_COIN = 60;
|
||||||
|
|
||||||
|
|
||||||
//金币支出类型数组
|
//金币支出类型数组
|
||||||
@@ -139,8 +141,9 @@ class UserWallet extends Model
|
|||||||
self::RENEWAL,
|
self::RENEWAL,
|
||||||
self::RED_PACKET_FEE,
|
self::RED_PACKET_FEE,
|
||||||
self::BACKGROUND_DEDUCTION_COIN,
|
self::BACKGROUND_DEDUCTION_COIN,
|
||||||
|
self::LINGXIAN_TRADITION_LOTTERY_COIN,
|
||||||
];
|
];
|
||||||
|
|
||||||
//钻石支出类型数组
|
//钻石支出类型数组
|
||||||
public $diamond_consumption_type_array = [
|
public $diamond_consumption_type_array = [
|
||||||
self::OPERATION_WITHDRAW,
|
self::OPERATION_WITHDRAW,
|
||||||
@@ -219,7 +222,8 @@ class UserWallet extends Model
|
|||||||
self::BACKGROUND_RECHARGE_DIAMOND => '后台充值钻石',
|
self::BACKGROUND_RECHARGE_DIAMOND => '后台充值钻石',
|
||||||
self::BACKGROUND_DEDUCTION_COIN => '后台扣除金币',
|
self::BACKGROUND_DEDUCTION_COIN => '后台扣除金币',
|
||||||
self::BACKGROUND_DEDUCTION_DIAMOND => '后台扣除钻石',
|
self::BACKGROUND_DEDUCTION_DIAMOND => '后台扣除钻石',
|
||||||
self::GUILD_EXIT_DEACON_INCOME => "公会会员付费退出会长收入"
|
self::GUILD_EXIT_DEACON_INCOME => "公会会员付费退出会长收入",
|
||||||
|
self::LINGXIAN_TRADITION_LOTTERY_COIN => '炼仙传说抽奖扣除金币',
|
||||||
];
|
];
|
||||||
if ($type) {
|
if ($type) {
|
||||||
return $status[$type] ?? '';
|
return $status[$type] ?? '';
|
||||||
|
|||||||
@@ -104,6 +104,101 @@ class LotteryService
|
|||||||
throw new Exception('参数错误');
|
throw new Exception('参数错误');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 读取配置+独立轮次
|
||||||
|
$small_trigger_times = intval($this->config['small_pool_trigger_times'] ?? 200);//触发抽奖次数
|
||||||
|
$small_round = intval($this->redis->get('lottery:small_pool:round') ?: 1);//小奖轮次
|
||||||
|
$lucky_rate = intval($this->config['lucky_rate'] ?? 1);//收益率
|
||||||
|
$lottery_rate = intval($this->config['lottery_rate'] ?? 100);//爆币率
|
||||||
|
if($lottery_rate <= 2){
|
||||||
|
throw new Exception('配置错误');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 加载Lua脚本
|
||||||
|
$luaSha = LotteryGiftLua::getLotteryLuaScript();
|
||||||
|
|
||||||
|
// 执行Lua脚本(入参:small_round + big_round)
|
||||||
|
$result = $this->redis->eval($luaSha, [
|
||||||
|
$send_uid,
|
||||||
|
$gift_gold,
|
||||||
|
$small_trigger_times,
|
||||||
|
$small_round,
|
||||||
|
$lucky_rate,
|
||||||
|
$lottery_rate
|
||||||
|
], 0);
|
||||||
|
|
||||||
|
$result = json_decode($result, true);
|
||||||
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
|
throw new Exception('Lua脚本执行失败');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 开启数据库事务
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
// . 1记录小奖池累计流水(未开奖时)
|
||||||
|
if ($result['is_small_prize'] == 0) {
|
||||||
|
$this->addPoolFlow(
|
||||||
|
1, // 小奖池
|
||||||
|
1, // 累计
|
||||||
|
$result['small_pool_add'],
|
||||||
|
$result['small_total_gold'] - $result['small_pool_add'],
|
||||||
|
$result['small_total_gold'],
|
||||||
|
$giftId,
|
||||||
|
$result['small_round'], // 新增:传入轮次
|
||||||
|
"小奖池累计:用户{$send_uid}送礼,轮次{$result['small_round']}"
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$winnerUid = $send_uid; // 奖默认给当前送礼用户
|
||||||
|
// 小奖中奖记录
|
||||||
|
$this->addWinnerRecord(
|
||||||
|
$winnerUid,
|
||||||
|
1, // 小奖
|
||||||
|
$result['small_prize_amount'],//中奖金额
|
||||||
|
$result['small_total_gold'],//奖池总金额
|
||||||
|
$this->getSmallRatio($result['small_prize_amount'], $result['small_total_gold']),//中奖比例
|
||||||
|
$result['small_total_gold'] - floor($result['small_prize_amount']) //释放金额
|
||||||
|
);
|
||||||
|
// 3. 小奖池开奖流水
|
||||||
|
$this->addPoolFlow(
|
||||||
|
1, // 小奖池
|
||||||
|
2, // 开奖扣除
|
||||||
|
$result['small_prize_amount'],
|
||||||
|
$result['small_total_gold'],
|
||||||
|
$result['small_total_gold'] - $result['small_prize_amount'],
|
||||||
|
$giftId,
|
||||||
|
$result['small_round'] - 1, // 开奖轮次为当前轮次-1(已结束的轮次)
|
||||||
|
"小奖池开奖:轮次" . ($result['small_round'] - 1).",中奖金额:{$result['small_prize_amount']}金币"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
return [
|
||||||
|
'code' => 1,
|
||||||
|
'msg' => '处理成功',
|
||||||
|
'data' => $result
|
||||||
|
];
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
throw new Exception($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理送礼抽奖逻辑 (带大奖池)
|
||||||
|
* @param int $send_uid 送礼用户ID
|
||||||
|
* @param float $gift_gold 礼物金币数
|
||||||
|
* @param int $giftId 礼物ID
|
||||||
|
* @return array 处理结果
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function handleGifts($send_uid, $gift_gold, $giftId)
|
||||||
|
{
|
||||||
|
// 参数校验
|
||||||
|
if ($gift_gold <= 0 || !$send_uid) {
|
||||||
|
throw new Exception('参数错误');
|
||||||
|
}
|
||||||
|
|
||||||
// 读取配置+独立轮次+大奖池金额
|
// 读取配置+独立轮次+大奖池金额
|
||||||
$small_trigger_times = intval($this->config['small_pool_trigger_times'] ?? 200);
|
$small_trigger_times = intval($this->config['small_pool_trigger_times'] ?? 200);
|
||||||
$big_threshold = floatval($this->config['big_pool_threshold'] ?? 1000);
|
$big_threshold = floatval($this->config['big_pool_threshold'] ?? 1000);
|
||||||
|
|||||||
253
application/common/service/LotteryService10.php
Normal file
253
application/common/service/LotteryService10.php
Normal file
@@ -0,0 +1,253 @@
|
|||||||
|
<?php
|
||||||
|
namespace app\common\service;
|
||||||
|
|
||||||
|
use app\common\library\LotteryGiftLua;
|
||||||
|
use think\Cache;
|
||||||
|
use think\Db;
|
||||||
|
use think\Exception;
|
||||||
|
|
||||||
|
class LotteryService10
|
||||||
|
{
|
||||||
|
// Redis实例
|
||||||
|
private $redis;
|
||||||
|
// 配置参数
|
||||||
|
private $config;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->redis = Cache::store('redis')->handler();
|
||||||
|
// 加载配置
|
||||||
|
$this->config = Db::name('bb_lottery_config')->column('value', 'key');
|
||||||
|
// 初始化Redis缓存(若Redis数据丢失,从数据库恢复)
|
||||||
|
$this->initRedisFromDb();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存恢复:独立恢复大小轮次+对应金额
|
||||||
|
*/
|
||||||
|
private function initRedisFromDb()
|
||||||
|
{
|
||||||
|
// 1. 恢复小奖池轮次(取pool_type=1的最大times)
|
||||||
|
$maxSmallRound = Db::name('bb_lottery_pool_flow_10')->where('pool_type', 1)->max('times') ?: 1;
|
||||||
|
if (!$this->redis->get('lottery:small_pool:round_10')) {
|
||||||
|
$this->redis->set('lottery:small_pool:round_10', $maxSmallRound);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 恢复小奖池当前轮次的次数/金额
|
||||||
|
$small_round = intval($this->redis->get('lottery:small_pool:round_10'));
|
||||||
|
if (!$this->redis->get('lottery:small_pool:total_times_10')) {
|
||||||
|
$smallTotalTimes = Db::name('bb_lottery_pool_flow_10')
|
||||||
|
->where(['pool_type' => 1, 'type' => 1, 'times' => $small_round])
|
||||||
|
->count();
|
||||||
|
$this->redis->set('lottery:small_pool:total_times_10', $smallTotalTimes);
|
||||||
|
}
|
||||||
|
if (!$this->redis->get('lottery:small_pool:total_gold_10')) {
|
||||||
|
$smallTotalGold = Db::name('bb_lottery_pool_flow_10')
|
||||||
|
->where(['pool_type' => 1, 'type' => 1, 'times' => $small_round])
|
||||||
|
->sum('amount') ?: 0;
|
||||||
|
$this->redis->set('lottery:small_pool:total_gold_10', $smallTotalGold);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理送礼抽奖逻辑
|
||||||
|
* @param int $send_uid 送礼用户ID
|
||||||
|
* @param float $gift_gold 礼物金币数
|
||||||
|
* @param int $giftId 礼物ID
|
||||||
|
* @return array 处理结果
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function handleGift($send_uid, $gift_gold, $giftId)
|
||||||
|
{
|
||||||
|
// 参数校验
|
||||||
|
if ($gift_gold <= 0 || !$send_uid) {
|
||||||
|
throw new Exception('参数错误');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 读取配置+独立轮次
|
||||||
|
$small_trigger_times = intval($this->config['small_pool_trigger_times_10'] ?? 200);//触发抽奖次数
|
||||||
|
$small_round = intval($this->redis->get('lottery:small_pool:round_10') ?: 1);//小奖轮次
|
||||||
|
$lucky_rate = intval($this->config['lucky_rate'] ?? 1);//收益率
|
||||||
|
$lottery_rate = intval($this->config['lottery_rate_10'] ?? 100);//爆币率
|
||||||
|
if($lottery_rate <= 2){
|
||||||
|
throw new Exception('配置错误');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 加载Lua脚本
|
||||||
|
$luaSha = LotteryGiftLua::getLotteryLuaScript10();
|
||||||
|
|
||||||
|
// 执行Lua脚本(入参:small_round + big_round)
|
||||||
|
$result = $this->redis->eval($luaSha, [
|
||||||
|
$send_uid,
|
||||||
|
$gift_gold,
|
||||||
|
$small_trigger_times,
|
||||||
|
$small_round,
|
||||||
|
$lucky_rate,
|
||||||
|
$lottery_rate
|
||||||
|
], 0);
|
||||||
|
|
||||||
|
$result = json_decode($result, true);
|
||||||
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
|
throw new Exception('Lua脚本执行失败');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 开启数据库事务
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
// . 1记录小奖池累计流水(未开奖时)
|
||||||
|
if ($result['is_small_prize'] == 0) {
|
||||||
|
$this->addPoolFlow(
|
||||||
|
1, // 小奖池
|
||||||
|
1, // 累计
|
||||||
|
$result['small_pool_add'],
|
||||||
|
$result['small_total_gold'] - $result['small_pool_add'],
|
||||||
|
$result['small_total_gold'],
|
||||||
|
$giftId,
|
||||||
|
$result['small_round'], // 新增:传入轮次
|
||||||
|
"小奖池累计:用户{$send_uid}送礼,轮次{$result['small_round']}"
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$winnerUid = $send_uid; // 奖默认给当前送礼用户
|
||||||
|
//中奖金额
|
||||||
|
$prizeAmount = floor($result['small_prize_amount'] / $gift_gold) * $gift_gold;
|
||||||
|
// 小奖中奖记录
|
||||||
|
$this->addWinnerRecord(
|
||||||
|
$winnerUid,
|
||||||
|
4, // 高级奖池
|
||||||
|
$prizeAmount,//中奖金额
|
||||||
|
$result['small_total_gold'],//奖池总金额
|
||||||
|
$this->getSmallRatio($result['small_prize_amount'], $result['small_total_gold']),//中奖比例
|
||||||
|
$result['small_total_gold'] - $prizeAmount //释放金额
|
||||||
|
);
|
||||||
|
// 3. 小奖池开奖流水
|
||||||
|
$this->addPoolFlow(
|
||||||
|
1, //
|
||||||
|
4, //
|
||||||
|
$prizeAmount,
|
||||||
|
$result['small_total_gold'],
|
||||||
|
$result['small_total_gold'] - $prizeAmount,
|
||||||
|
$giftId,
|
||||||
|
$result['small_round'] - 1, // 开奖轮次为当前轮次-1(已结束的轮次)
|
||||||
|
"小奖池开奖:轮次" . ($result['small_round'] - 1).",中奖金额:{$result['small_prize_amount']}金币"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
return [
|
||||||
|
'code' => 1,
|
||||||
|
'msg' => '处理成功',
|
||||||
|
'data' => $result
|
||||||
|
];
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
throw new Exception($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加奖池流水
|
||||||
|
* @param int $pool_type 奖池类型:1-小 2-大
|
||||||
|
* @param int $type 流水类型:1-累计 2-开奖 3-划转 4-释放
|
||||||
|
* @param float $amount 金额
|
||||||
|
* @param float $before_amount 操作前金额
|
||||||
|
* @param float $after_amount 操作后金额
|
||||||
|
* @param int $relate_id 关联ID
|
||||||
|
* @param int $times 轮次
|
||||||
|
* @param string $remark 备注
|
||||||
|
*/
|
||||||
|
private function addPoolFlow($pool_type, $type, $amount, $before_amount, $after_amount, $relate_id, $times, $remark)
|
||||||
|
{
|
||||||
|
Db::name('bb_lottery_pool_flow_10')->insert([
|
||||||
|
'pool_type' => $pool_type,
|
||||||
|
'type' => $type,
|
||||||
|
'amount' => $amount,
|
||||||
|
'before_amount' => $before_amount,
|
||||||
|
'after_amount' => $after_amount,
|
||||||
|
'relate_id' => $relate_id,
|
||||||
|
'times' => $times, // 新增:写入轮次
|
||||||
|
'remark' => $remark,
|
||||||
|
'create_time' => time()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加中奖记录
|
||||||
|
* @param int $uid 中奖用户ID
|
||||||
|
* @param int $prize_type 奖项类型:1-小 2-大
|
||||||
|
* @param float $prize_amount 中奖金额
|
||||||
|
* @param float $pool_amount 奖池总金额
|
||||||
|
* @param int $ratio 中奖比例
|
||||||
|
* @param float $release_amount 释放金额
|
||||||
|
*/
|
||||||
|
private function addWinnerRecord($uid, $prize_type, $prize_amount, $pool_amount, $ratio, $release_amount)
|
||||||
|
{
|
||||||
|
Db::name('bb_lottery_winner_record')->insert([
|
||||||
|
'uid' => $uid,
|
||||||
|
'prize_type' => $prize_type,
|
||||||
|
'prize_amount' => $prize_amount,
|
||||||
|
'pool_amount' => $pool_amount,
|
||||||
|
'ratio' => $ratio,
|
||||||
|
'release_amount' => $release_amount,
|
||||||
|
'create_time' => time(),
|
||||||
|
'status' => 1 // 已发放
|
||||||
|
]);
|
||||||
|
// 此处可添加用户金币入账逻辑(如更新用户金币表)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算小奖中奖比例
|
||||||
|
* @param float $prize_amount 中奖金额
|
||||||
|
* @param float $pool_amount 奖池金额
|
||||||
|
* @return int 比例(%)
|
||||||
|
*/
|
||||||
|
private function getSmallRatio($prize_amount, $pool_amount)
|
||||||
|
{
|
||||||
|
return intval(round($prize_amount / $pool_amount * 100));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算大奖中奖比例
|
||||||
|
* @param float $prize_amount 中奖金额
|
||||||
|
* @param float $pool_amount 奖池金额
|
||||||
|
* @return int 比例(%)
|
||||||
|
*/
|
||||||
|
private function getBigRatio($prize_amount, $pool_amount)
|
||||||
|
{
|
||||||
|
return intval(round($prize_amount / $pool_amount * 100));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计中奖数据
|
||||||
|
* @param array $where 筛选条件(如uid、prize_type、time)
|
||||||
|
* @return array 统计结果
|
||||||
|
*/
|
||||||
|
public function statWinner($where = [])
|
||||||
|
{
|
||||||
|
$query = Db::name('bb_lottery_winner_record');
|
||||||
|
if (!empty($where['uid'])) {
|
||||||
|
$query->where('uid', $where['uid']);
|
||||||
|
}
|
||||||
|
if (!empty($where['prize_type'])) {
|
||||||
|
$query->where('prize_type', $where['prize_type']);
|
||||||
|
}
|
||||||
|
if (!empty($where['start_time']) && !empty($where['end_time'])) {
|
||||||
|
$query->whereBetween('create_time', [$where['start_time'], $where['end_time']]);
|
||||||
|
}
|
||||||
|
// 总中奖金额、总释放金额、中奖次数
|
||||||
|
$stat = $query->field([
|
||||||
|
'SUM(prize_amount) as total_prize',
|
||||||
|
'SUM(release_amount) as total_release',
|
||||||
|
'COUNT(id) as total_times'
|
||||||
|
])->find();
|
||||||
|
return [
|
||||||
|
'total_prize' => $stat['total_prize'] ?? 0,
|
||||||
|
'total_release' => $stat['total_release'] ?? 0,
|
||||||
|
'total_times' => $stat['total_times'] ?? 0
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
255
application/common/service/LotteryService5.php
Normal file
255
application/common/service/LotteryService5.php
Normal file
@@ -0,0 +1,255 @@
|
|||||||
|
<?php
|
||||||
|
namespace app\common\service;
|
||||||
|
|
||||||
|
use app\common\library\LotteryGiftLua;
|
||||||
|
use think\Cache;
|
||||||
|
use think\Db;
|
||||||
|
use think\Exception;
|
||||||
|
|
||||||
|
class LotteryService5
|
||||||
|
{
|
||||||
|
// Redis实例
|
||||||
|
private $redis;
|
||||||
|
// 配置参数
|
||||||
|
private $config;
|
||||||
|
private $bigPrizeWeights;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->redis = Cache::store('redis')->handler();
|
||||||
|
// 加载配置
|
||||||
|
$this->config = Db::name('bb_lottery_config')->column('value', 'key');
|
||||||
|
// 初始化Redis缓存(若Redis数据丢失,从数据库恢复)
|
||||||
|
|
||||||
|
$this->initRedisFromDb();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存恢复:独立恢复大小轮次+对应金额
|
||||||
|
*/
|
||||||
|
private function initRedisFromDb()
|
||||||
|
{
|
||||||
|
// 1. 恢复奖池轮次(取pool_type=1的最大times)
|
||||||
|
$maxSmallRound = Db::name('bb_lottery_pool_flow_5')->where('pool_type', 1)->max('times') ?: 1;
|
||||||
|
if (!$this->redis->get('lottery:small_pool:round_5')) {
|
||||||
|
$this->redis->set('lottery:small_pool:round_5', $maxSmallRound);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 恢复奖池当前轮次的次数/金额
|
||||||
|
$small_round = intval($this->redis->get('lottery:small_pool:round_5'));
|
||||||
|
if (!$this->redis->get('lottery:small_pool:total_times_5')) {
|
||||||
|
$smallTotalTimes = Db::name('bb_lottery_pool_flow_5')
|
||||||
|
->where(['pool_type' => 1, 'type' => 1, 'times' => $small_round])
|
||||||
|
->count();
|
||||||
|
$this->redis->set('lottery:small_pool:total_times_5', $smallTotalTimes);
|
||||||
|
}
|
||||||
|
if (!$this->redis->get('lottery:small_pool:total_gold_5')) {
|
||||||
|
$smallTotalGold = Db::name('bb_lottery_pool_flow_5')
|
||||||
|
->where(['pool_type' => 1, 'type' => 1, 'times' => $small_round])
|
||||||
|
->sum('amount') ?: 0;
|
||||||
|
$this->redis->set('lottery:small_pool:total_gold_5', $smallTotalGold);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理送礼抽奖逻辑
|
||||||
|
* @param int $send_uid 送礼用户ID
|
||||||
|
* @param float $gift_gold 礼物金币数
|
||||||
|
* @param int $giftId 礼物ID
|
||||||
|
* @return array 处理结果
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function handleGift($send_uid, $gift_gold, $giftId)
|
||||||
|
{
|
||||||
|
// 参数校验
|
||||||
|
if ($gift_gold <= 0 || !$send_uid) {
|
||||||
|
throw new Exception('参数错误');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 读取配置+独立轮次
|
||||||
|
$small_trigger_times = intval($this->config['small_pool_trigger_times_5'] ?? 200);//触发抽奖次数
|
||||||
|
$small_round = intval($this->redis->get('lottery:small_pool:round_5') ?: 1);//轮次
|
||||||
|
$lucky_rate = intval($this->config['lucky_rate'] ?? 1);//收益率
|
||||||
|
$lottery_rate = intval($this->config['lottery_rate_5'] ?? 100);//爆币率
|
||||||
|
if($lottery_rate <= 2){
|
||||||
|
throw new Exception('配置错误');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 加载Lua脚本
|
||||||
|
$luaSha = LotteryGiftLua::getLotteryLuaScript5();
|
||||||
|
|
||||||
|
// 执行Lua脚本(入参:small_round + big_round)
|
||||||
|
$result = $this->redis->eval($luaSha, [
|
||||||
|
$send_uid,
|
||||||
|
$gift_gold,
|
||||||
|
$small_trigger_times,
|
||||||
|
$small_round,
|
||||||
|
$lucky_rate,
|
||||||
|
$lottery_rate
|
||||||
|
], 0);
|
||||||
|
|
||||||
|
$result = json_decode($result, true);
|
||||||
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
|
throw new Exception('Lua脚本执行失败');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 开启数据库事务
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
// . 1记录小奖池累计流水(未开奖时)
|
||||||
|
if ($result['is_small_prize'] == 0) {
|
||||||
|
$this->addPoolFlow(
|
||||||
|
1, // 中级奖池
|
||||||
|
1, // 累计
|
||||||
|
$result['small_pool_add'],
|
||||||
|
$result['small_total_gold'] - $result['small_pool_add'],
|
||||||
|
$result['small_total_gold'],
|
||||||
|
$giftId,
|
||||||
|
$result['small_round'], // 新增:传入轮次
|
||||||
|
"小奖池累计:用户{$send_uid}送礼,轮次{$result['small_round']}"
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$winnerUid = $send_uid; // 奖默认给当前送礼用户
|
||||||
|
//中奖金额
|
||||||
|
$prizeAmount = floor($result['small_prize_amount'] / $gift_gold) * $gift_gold;
|
||||||
|
// 小奖中奖记录
|
||||||
|
$this->addWinnerRecord(
|
||||||
|
$winnerUid,
|
||||||
|
3, // 中级奖
|
||||||
|
$prizeAmount,//中奖金额
|
||||||
|
$result['small_total_gold'],//奖池总金额
|
||||||
|
$this->getSmallRatio($result['small_prize_amount'], $result['small_total_gold']),//中奖比例
|
||||||
|
$result['small_total_gold'] - $prizeAmount //释放金额
|
||||||
|
);
|
||||||
|
// 3. 小奖池开奖流水
|
||||||
|
$this->addPoolFlow(
|
||||||
|
1, //
|
||||||
|
4, //
|
||||||
|
$prizeAmount,
|
||||||
|
$result['small_total_gold'],
|
||||||
|
$result['small_total_gold'] - $prizeAmount,
|
||||||
|
$giftId,
|
||||||
|
$result['small_round'] - 1, // 开奖轮次为当前轮次-1(已结束的轮次)
|
||||||
|
"小奖池开奖:轮次" . ($result['small_round'] - 1).",中奖金额:{$result['small_prize_amount']}金币"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
return [
|
||||||
|
'code' => 1,
|
||||||
|
'msg' => '处理成功',
|
||||||
|
'data' => $result
|
||||||
|
];
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
throw new Exception($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加奖池流水
|
||||||
|
* @param int $pool_type 奖池类型:1-小 2-大
|
||||||
|
* @param int $type 流水类型:1-累计 2-开奖 3-划转 4-释放
|
||||||
|
* @param float $amount 金额
|
||||||
|
* @param float $before_amount 操作前金额
|
||||||
|
* @param float $after_amount 操作后金额
|
||||||
|
* @param int $relate_id 关联ID
|
||||||
|
* @param int $times 轮次
|
||||||
|
* @param string $remark 备注
|
||||||
|
*/
|
||||||
|
private function addPoolFlow($pool_type, $type, $amount, $before_amount, $after_amount, $relate_id, $times, $remark)
|
||||||
|
{
|
||||||
|
Db::name('bb_lottery_pool_flow_5')->insert([
|
||||||
|
'pool_type' => $pool_type,
|
||||||
|
'type' => $type,
|
||||||
|
'amount' => $amount,
|
||||||
|
'before_amount' => $before_amount,
|
||||||
|
'after_amount' => $after_amount,
|
||||||
|
'relate_id' => $relate_id,
|
||||||
|
'times' => $times, // 新增:写入轮次
|
||||||
|
'remark' => $remark,
|
||||||
|
'create_time' => time()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加中奖记录
|
||||||
|
* @param int $uid 中奖用户ID
|
||||||
|
* @param int $prize_type 奖项类型:1-小 2-大
|
||||||
|
* @param float $prize_amount 中奖金额
|
||||||
|
* @param float $pool_amount 奖池总金额
|
||||||
|
* @param int $ratio 中奖比例
|
||||||
|
* @param float $release_amount 释放金额
|
||||||
|
*/
|
||||||
|
private function addWinnerRecord($uid, $prize_type, $prize_amount, $pool_amount, $ratio, $release_amount)
|
||||||
|
{
|
||||||
|
Db::name('bb_lottery_winner_record')->insert([
|
||||||
|
'uid' => $uid,
|
||||||
|
'prize_type' => $prize_type,
|
||||||
|
'prize_amount' => $prize_amount,
|
||||||
|
'pool_amount' => $pool_amount,
|
||||||
|
'ratio' => $ratio,
|
||||||
|
'release_amount' => $release_amount,
|
||||||
|
'create_time' => time(),
|
||||||
|
'status' => 1 // 已发放
|
||||||
|
]);
|
||||||
|
// 此处可添加用户金币入账逻辑(如更新用户金币表)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算小奖中奖比例
|
||||||
|
* @param float $prize_amount 中奖金额
|
||||||
|
* @param float $pool_amount 奖池金额
|
||||||
|
* @return int 比例(%)
|
||||||
|
*/
|
||||||
|
private function getSmallRatio($prize_amount, $pool_amount)
|
||||||
|
{
|
||||||
|
return intval(round($prize_amount / $pool_amount * 100));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算大奖中奖比例
|
||||||
|
* @param float $prize_amount 中奖金额
|
||||||
|
* @param float $pool_amount 奖池金额
|
||||||
|
* @return int 比例(%)
|
||||||
|
*/
|
||||||
|
private function getBigRatio($prize_amount, $pool_amount)
|
||||||
|
{
|
||||||
|
return intval(round($prize_amount / $pool_amount * 100));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计中奖数据
|
||||||
|
* @param array $where 筛选条件(如uid、prize_type、time)
|
||||||
|
* @return array 统计结果
|
||||||
|
*/
|
||||||
|
public function statWinner($where = [])
|
||||||
|
{
|
||||||
|
$query = Db::name('bb_lottery_winner_record');
|
||||||
|
if (!empty($where['uid'])) {
|
||||||
|
$query->where('uid', $where['uid']);
|
||||||
|
}
|
||||||
|
if (!empty($where['prize_type'])) {
|
||||||
|
$query->where('prize_type', $where['prize_type']);
|
||||||
|
}
|
||||||
|
if (!empty($where['start_time']) && !empty($where['end_time'])) {
|
||||||
|
$query->whereBetween('create_time', [$where['start_time'], $where['end_time']]);
|
||||||
|
}
|
||||||
|
// 总中奖金额、总释放金额、中奖次数
|
||||||
|
$stat = $query->field([
|
||||||
|
'SUM(prize_amount) as total_prize',
|
||||||
|
'SUM(release_amount) as total_release',
|
||||||
|
'COUNT(id) as total_times'
|
||||||
|
])->find();
|
||||||
|
return [
|
||||||
|
'total_prize' => $stat['total_prize'] ?? 0,
|
||||||
|
'total_release' => $stat['total_release'] ?? 0,
|
||||||
|
'total_times' => $stat['total_times'] ?? 0
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -193,7 +193,7 @@ class RedpacketService
|
|||||||
->where('user_id',$userId)
|
->where('user_id',$userId)
|
||||||
->where('createtime', '>=', strtotime(date('Y-m-d')))
|
->where('createtime', '>=', strtotime(date('Y-m-d')))
|
||||||
->count();
|
->count();
|
||||||
if($tady_red_num >= 5){
|
if($tady_red_num <= 5){
|
||||||
model('api/Tasks')->tasks_complete($userId,36);
|
model('api/Tasks')->tasks_complete($userId,36);
|
||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace app\cron\controller;
|
|||||||
|
|
||||||
use app\common\model\Redpacket;
|
use app\common\model\Redpacket;
|
||||||
use app\common\model\UserWallet;
|
use app\common\model\UserWallet;
|
||||||
|
use app\common\controller\Push;
|
||||||
use think\Cache;
|
use think\Cache;
|
||||||
use think\Db;
|
use think\Db;
|
||||||
use Yzh\YunPay;
|
use Yzh\YunPay;
|
||||||
@@ -55,6 +56,10 @@ class PerformPerSecond
|
|||||||
$this->bar_room_time_end();
|
$this->bar_room_time_end();
|
||||||
echo "\n";
|
echo "\n";
|
||||||
|
|
||||||
|
echo "炼仙传说监控:\n";
|
||||||
|
$this->create_monster_log();
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -158,7 +163,7 @@ class PerformPerSecond
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(in_array($value['yun_order_status'],[261,5077,255,254])){
|
if(in_array($value['yun_order_status'],[261,5077,255,254,6050])){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
echo "提现订单查询:".$value['order_sn']."\n";
|
echo "提现订单查询:".$value['order_sn']."\n";
|
||||||
@@ -198,7 +203,7 @@ class PerformPerSecond
|
|||||||
'received_tax_amount' => $result['data']['received_tax_amount'] ?? 0,
|
'received_tax_amount' => $result['data']['received_tax_amount'] ?? 0,
|
||||||
]);
|
]);
|
||||||
// if(in_array($result['data']['code'],[5077,261]) && $value['yun_order_status'] == null){
|
// if(in_array($result['data']['code'],[5077,261]) && $value['yun_order_status'] == null){
|
||||||
if(in_array($result['data']['code'],[5077,261,255,254]) && !in_array($value['yun_order_status'],[5077,261,255,254])){
|
if(in_array($result['data']['code'],[5077,261,255,254,6050]) && !in_array($value['yun_order_status'],[5077,261,255,254,6050])){
|
||||||
// if($result['data']['code']==5077 && $value['yun_order_status'] == null){
|
// if($result['data']['code']==5077 && $value['yun_order_status'] == null){
|
||||||
//该支付宝账户不存在或未开通手机号转账功能。如有疑问,请收款用户联系支付宝客服咨询。
|
//该支付宝账户不存在或未开通手机号转账功能。如有疑问,请收款用户联系支付宝客服咨询。
|
||||||
//退还金币
|
//退还金币
|
||||||
@@ -390,4 +395,17 @@ class PerformPerSecond
|
|||||||
}
|
}
|
||||||
echo "酒吧房间时间结束处理完成\n";
|
echo "酒吧房间时间结束处理完成\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//监控练仙传说
|
||||||
|
public function create_monster_log(){
|
||||||
|
$key_name = "admin:cli:create_monster_log";
|
||||||
|
redis_lock_exit($key_name,1,1);
|
||||||
|
$reslut = model('api/Monster')->create_monster_log();
|
||||||
|
redis_unlock($key_name);
|
||||||
|
if($reslut['code'] == 0){
|
||||||
|
echo date('Y-m-d H:i:s') . "监控练仙传说 执行失败" . $reslut['msg'] . "\r\n";
|
||||||
|
}else{
|
||||||
|
echo date('Y-m-d H:i:s') . "监控练仙传说 执行成功" . $reslut['data'] . "\r\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -33,7 +33,8 @@ class Test
|
|||||||
// $this->task_coin_count();
|
// $this->task_coin_count();
|
||||||
// $this->createGuildSubsidyDataNew();
|
// $this->createGuildSubsidyDataNew();
|
||||||
// $this->repair_guild_room_data();
|
// $this->repair_guild_room_data();
|
||||||
$this->check_guild_room_data();
|
// $this->check_guild_room_data();
|
||||||
|
// $this->merge_guild();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1094,4 +1095,83 @@ class Test
|
|||||||
}
|
}
|
||||||
echo "完成";
|
echo "完成";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function merge_guild(){die("暂停");
|
||||||
|
$guild_id = 10029; // 要合并的
|
||||||
|
$merge_guild_id = 10005; //并入的
|
||||||
|
//解散工会
|
||||||
|
$guild = model('adminapi/Guild')->getOne(['guild_special_id'=>$guild_id]);
|
||||||
|
$merge_guild=model('adminapi/Guild')->getOne(['guild_special_id'=>$merge_guild_id]);
|
||||||
|
// if(empty($guild)){
|
||||||
|
// echo "该工会不存在";
|
||||||
|
// }
|
||||||
|
// if($guild['status'] == 2){
|
||||||
|
// echo "该工会已解散";
|
||||||
|
// }
|
||||||
|
// if(!$merge_guild_id){
|
||||||
|
// echo "请选择并入工会";
|
||||||
|
// }
|
||||||
|
// if(empty($merge_guild)){
|
||||||
|
// echo "并入工会不存在";
|
||||||
|
// }
|
||||||
|
$guild_id = $guild['id'];
|
||||||
|
$merge_guild_id = $merge_guild['id'];
|
||||||
|
// db::startTrans();
|
||||||
|
// try{
|
||||||
|
// $res = model('adminapi/Guild')->edit(['id'=>$guild_id],['status'=>2,'delete_time'=>time()]);
|
||||||
|
$merge_guild_user = db('vs_guild_user')->where(['guild_id'=>$guild_id,'quit_type'=>3,'status'=>1])->select();
|
||||||
|
$use_num = 0;
|
||||||
|
echo "公会名称:".$guild['guild_name']." 公会Id:".$guild_id." 公会人数:".count($merge_guild_user)." 合并公会名称:".$merge_guild['guild_name']." 合并公会Id:".$merge_guild_id."\n";
|
||||||
|
foreach ($merge_guild_user as $key=>$value){
|
||||||
|
// $res = db('vs_guild_user')->insert([
|
||||||
|
// 'user_id'=>$value['user_id'],
|
||||||
|
// 'guild_id'=>$merge_guild_id,
|
||||||
|
// 'room_id'=>$value['room_id'],
|
||||||
|
// 'status'=>$value['status'],
|
||||||
|
// 'is_show_room'=>$value['is_show_room'],
|
||||||
|
// 'remarks'=>"公会合并:从".$guild['guild_name']."合入".$merge_guild['guild_name'],
|
||||||
|
// 'settlement_ratio' =>$value['settlement_ratio'],
|
||||||
|
// 'apply_time'=>time(),
|
||||||
|
// 'createtime'=>time(),
|
||||||
|
// ]);
|
||||||
|
// if(!$res){
|
||||||
|
// db::rollback();
|
||||||
|
// return V(0,"失败");
|
||||||
|
// }
|
||||||
|
//更新公会人数
|
||||||
|
// db('vs_guild')->where('id', $merge_guild_id)->setInc('num');
|
||||||
|
//拉用户进入工会群聊
|
||||||
|
if($merge_guild_id<=95){
|
||||||
|
$merge_guild_id = "g".$merge_guild_id;
|
||||||
|
}else{
|
||||||
|
$merge_guild_id = $merge_guild_id;
|
||||||
|
}
|
||||||
|
$rid = 'g'.$merge_guild_id;
|
||||||
|
// $reslut = model('api/Tencent')->add_group_member($rid, $value['user_id']);
|
||||||
|
// if($reslut['code']==1){
|
||||||
|
// echo "用户:".$value['user_id']."加入群聊:".$rid;
|
||||||
|
// $use_num ++;
|
||||||
|
// }
|
||||||
|
echo 'u'.$value['user_id']."\n";
|
||||||
|
}
|
||||||
|
echo " 成功:".$use_num."\n";
|
||||||
|
// $return = db('vs_guild_user')->where(['guild_id'=>$guild_id,'quit_type'=>0])->update(['quit_type'=>3,'quit_time'=>time(),'updatetime'=>time(),'delete_time'=>time()]);
|
||||||
|
// if (!$return) {
|
||||||
|
// db::rollback();
|
||||||
|
// return V(0,"失败");
|
||||||
|
// }
|
||||||
|
// //解散群
|
||||||
|
// if($guild_id<=95){
|
||||||
|
// $guild_id = "g".$guild_id;
|
||||||
|
// }else{
|
||||||
|
// $guild_id = $guild_id;
|
||||||
|
// }
|
||||||
|
// model('api/Tencent')->delete_group('g'.$guild_id);
|
||||||
|
// db::commit();
|
||||||
|
// return V(1,"成功");
|
||||||
|
// } catch(\Exception $e) {
|
||||||
|
// db::rollback();
|
||||||
|
// return V(0,$e->getMessage());
|
||||||
|
// }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user