初始化代码
This commit is contained in:
341
application/admin/model/Admin.php
Normal file
341
application/admin/model/Admin.php
Normal file
@@ -0,0 +1,341 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class Admin extends Model
|
||||
{
|
||||
protected $pk = 'aid';
|
||||
protected $auto = ['update_time'];
|
||||
protected $insert = [
|
||||
'add_time',
|
||||
'system_menu_id_list' => 0,
|
||||
'is_delete' => 1,
|
||||
'delete_time' => 0,
|
||||
];
|
||||
protected $update = ['update_time'];
|
||||
|
||||
protected function setPasswordAttr($value)
|
||||
{
|
||||
return md5($value);
|
||||
}
|
||||
|
||||
protected function setAddTimeAttr()
|
||||
{
|
||||
return time();
|
||||
}
|
||||
|
||||
protected function setUpdateTimeAttr()
|
||||
{
|
||||
return time();
|
||||
}
|
||||
|
||||
public function check_login_token($login_token)
|
||||
{
|
||||
if (empty($login_token)) {
|
||||
return ['code' => 201, 'msg' => '登录失效', 'data' => ''];
|
||||
}
|
||||
$map = [];
|
||||
$map[] = ['login_token', '=', $login_token];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$user_info = db::name('admin')->where($map)->find();
|
||||
if (empty($user_info)) {
|
||||
return ['code' => 201, 'msg' => '登录失效', 'data' => ''];
|
||||
} else {
|
||||
if(time() > $user_info['token_validity_time']){
|
||||
Db::name('admin')->where('aid', $user_info['aid'])->update(['login_token' => '', 'update_time' => time()]);
|
||||
return ['code' => 201, 'msg' => '登录失效', 'data' => ''];
|
||||
} else {
|
||||
if($user_info['token_validity_time'] <= (time() + 3600)) {
|
||||
Db::name('admin')->where('aid', $user_info['aid'])->update(['token_validity_time' => time() + 7200, 'update_time' => time()]);
|
||||
}
|
||||
}
|
||||
return ['code' => 200, 'msg' => '登录成功', 'data' => $user_info['aid']];
|
||||
}
|
||||
}
|
||||
|
||||
//获取管理员信息
|
||||
public function admin_info($login_token)
|
||||
{
|
||||
if (empty($login_token)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => ''];
|
||||
}
|
||||
$info = db::name('admin')->where(['login_token' => $login_token])->field('user_name')->find();
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $info];
|
||||
}
|
||||
public function add_admin($user_name, $password, $re_password)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['user_name', '=', $user_name];
|
||||
$admin_info = db::name('admin')->where($map)->find();
|
||||
if (!empty($admin_info)) {
|
||||
return ['code' => 201, 'msg' => '用户名已存在', 'data' => ''];
|
||||
}
|
||||
$res = check_password_format($password);
|
||||
if($res['code'] == 201) {
|
||||
return $res;
|
||||
}
|
||||
|
||||
if ($password != $re_password) {
|
||||
return ['code' => 201, 'msg' => '两次密码不一致', 'data' => ''];
|
||||
}
|
||||
$phone = input('phone', '');
|
||||
$open_sms_code = input('open_sms_code', 2);
|
||||
if($open_sms_code == 1) {
|
||||
if(empty($phone)) {
|
||||
return ['code' => 201, 'msg' => '手机号不能为空', 'data' => ''];
|
||||
}
|
||||
if(!isMobile($phone)) {
|
||||
return ['code' => 201, 'msg' => '手机号格式错误', 'data' => ''];
|
||||
}
|
||||
$admin_info = Db::name('admin')->where(['phone' => $phone, 'is_delete' => 1])->find();
|
||||
if($admin_info) {
|
||||
return ['code' => 201, 'msg' => '手机号已绑定', 'data' => ''];
|
||||
}
|
||||
}
|
||||
$data = [];
|
||||
$data['user_name'] = $user_name;
|
||||
$data['password'] = $password;
|
||||
$data['phone'] = $phone;
|
||||
$data['open_sms_code'] = $open_sms_code;
|
||||
$validate = validate('admin/admin');
|
||||
$reslut = $validate->scene('adminAdd')->check($data);
|
||||
if ($reslut !== true) {
|
||||
return ['code' => 201, 'msg' => $validate->getError(), 'data' => null];
|
||||
}
|
||||
$Admin = model('admin/admin');
|
||||
$reslut = $Admin->save($data);
|
||||
if ($reslut) {
|
||||
return ['code' => 200, 'msg' => '添加成功', 'data' => ''];
|
||||
} else {
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => ''];
|
||||
}
|
||||
}
|
||||
|
||||
//修改管理员密码
|
||||
public function edit_admin_password($aid, $old_password, $password, $re_password, $phone)
|
||||
{
|
||||
$admin_info = db::name('admin')->where(['aid' => $aid])->find();
|
||||
if (empty($admin_info)) {
|
||||
return ['code' => 201, 'msg' => '信息不存在', 'data' => ''];
|
||||
}
|
||||
if (md5($old_password) != $admin_info['password']) {
|
||||
return ['code' => 201, 'msg' => '原始密码错误', 'data' => ''];
|
||||
}
|
||||
|
||||
$res = check_password_format($password);
|
||||
if($res['code'] == 201) {
|
||||
return $res;
|
||||
}
|
||||
|
||||
if ($password != $re_password) {
|
||||
return ['code' => 201, 'msg' => '两次密码不一致', 'data' => ''];
|
||||
}
|
||||
$data = [];
|
||||
|
||||
$open_sms_code = input('open_sms_code', 2);
|
||||
|
||||
if($open_sms_code == 1) {
|
||||
if(empty($phone)) {
|
||||
return ['code' => 201, 'msg' => '手机号不能为空', 'data' => ''];
|
||||
}
|
||||
if(!isMobile($phone)) {
|
||||
return ['code' => 201, 'msg' => '手机号格式错误', 'data' => ''];
|
||||
}
|
||||
$admin_info = Db::name('admin')->where(['phone' => $phone, 'is_delete' => 1])->where('aid', 'neq', $aid)->find();
|
||||
if($admin_info) {
|
||||
return ['code' => 201, 'msg' => '手机号已绑定', 'data' => ''];
|
||||
}
|
||||
}
|
||||
$data['password'] = md5($password);
|
||||
$validate = validate('admin/admin');
|
||||
$reslut = $validate->scene('adminEditPassword')->check($data);
|
||||
if ($reslut !== true) {
|
||||
return ['code' => 201, 'msg' => $validate->getError(), 'data' => null];
|
||||
}
|
||||
|
||||
if($phone != $admin_info['phone']){
|
||||
$data['phone'] = $phone;
|
||||
}
|
||||
$data['open_sms_code'] = $open_sms_code;
|
||||
$data['update_time'] = time();
|
||||
$reslut = Db::name('admin')->where('aid', $aid)->update($data);
|
||||
if ($reslut) {
|
||||
return ['code' => 200, 'msg' => '修改成功', 'data' => ''];
|
||||
} else {
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => ''];
|
||||
}
|
||||
}
|
||||
//修改管理员权限
|
||||
public function edit_admin_auth($aid, $auth)
|
||||
{
|
||||
$system_menu_id_list = implode(',', $auth);
|
||||
$data = [];
|
||||
$data['system_menu_id_list'] = $system_menu_id_list;
|
||||
$data['update_time'] = time();
|
||||
$res = db::name('admin')->where(['aid' => $aid])->update($data);
|
||||
if ($res) {
|
||||
return ['code' => 200, 'msg' => '修改成功', 'data' => ''];
|
||||
} else {
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => ''];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//获取管理员列表
|
||||
public function get_admin_list($user_name, $page, $page_limit)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
if (!empty($user_name)) {
|
||||
$map[] = ['user_name', 'like', '%' . $user_name . '%'];
|
||||
}
|
||||
|
||||
$list = db::name('admin')->where($map)->order('aid', 'asc')->page($page, $page_limit)->select();
|
||||
$data = [];
|
||||
$data['count'] = db::name('admin')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
public function get_admin_info($aid)
|
||||
{
|
||||
$admin_info = db::name('admin')->find($aid);
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $admin_info];
|
||||
}
|
||||
public function delete_admin($aid)
|
||||
{
|
||||
if ($aid == 1) {
|
||||
return ['code' => 201, 'msg' => '总管理员禁止删除', 'data' => null];
|
||||
}
|
||||
$data = [];
|
||||
$data['is_delete'] = 2;
|
||||
$data['delete_time'] = time();
|
||||
$data['update_time'] = time();
|
||||
$res = db::name('admin')->where(['aid' => $aid])->update($data);
|
||||
if ($res) {
|
||||
return ['code' => 200, 'msg' => '删除成功', 'data' => ''];
|
||||
} else {
|
||||
return ['code' => 201, 'msg' => '删除失败', 'data' => ''];
|
||||
}
|
||||
}
|
||||
|
||||
//管理员日志
|
||||
public function get_admin_log_list($page, $page_limit){
|
||||
$map = [];
|
||||
$map[] = ['type', '=', 1];
|
||||
$list = db::name('operation')->where($map)->order('op_id','desc')->page($page, $page_limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['user_name'] = db::name('admin')->where('aid', $v['id'])->value('user_name');
|
||||
if(strpos($v['url'],'admin/box/get_box_type_list')){
|
||||
$v['operate_name'] = '宝箱礼物列表';
|
||||
}else if(strpos($v['url'],'admin/box/get_box_log_list')){
|
||||
$v['operate_name'] = '每期奖池列表';
|
||||
}else if(strpos($v['url'],'admin/box/edit_box_config')){
|
||||
$v['operate_name'] = '修改宝箱信息';
|
||||
}else if(strpos($v['url'],'admin/box/delete_box_config')){
|
||||
$v['operate_name'] = '删除宝箱信息';
|
||||
}else if(strpos($v['url'],'admin/box/add_give_gift')){
|
||||
$v['operate_name'] = '添加礼物补发';
|
||||
}else if(strpos($v['url'],'admin/box/cancel_give_gift')){
|
||||
$v['operate_name'] = '取消礼物补发';
|
||||
}else if(strpos($v['url'],'admin/box/get_box_give_gift_list')){
|
||||
$v['operate_name'] = '礼物补发列表';
|
||||
}else if(strpos($v['url'],'admin/user/get_user_list')){
|
||||
$v['operate_name'] = '用户列表';
|
||||
}else if(strpos($v['url'],'admin/user/edit_user_info')){
|
||||
$v['operate_name'] = '修改用户信息';
|
||||
}else if(strpos($v['url'],'admin/user/edit_user_money')){
|
||||
$v['operate_name'] = '修改用户资金';
|
||||
}else if(strpos($v['url'],'admin/user/edit_user_password')){
|
||||
$v['operate_name'] = '修改用户密码';
|
||||
}else if(strpos($v['url'],'admin/user/gold_consume_del')){
|
||||
$v['operate_name'] = '清除地阶累消';
|
||||
}else if(strpos($v['url'],'admin/user/drill_consume_del')){
|
||||
$v['operate_name'] = '清除天阶累消';
|
||||
}else if(strpos($v['url'],'admin/user/get_user_gift_pack')){
|
||||
$v['operate_name'] = '用户背包列表';
|
||||
}else if(strpos($v['url'],'admin/user/del_user_gift_pack')){
|
||||
$v['operate_name'] = '删除用户背包礼物';
|
||||
}else if(strpos($v['url'],'admin/config/config_list')){
|
||||
$v['operate_name'] = '系统配置列表';
|
||||
}else if(strpos($v['url'],'admin/config/edit_config')){
|
||||
$v['operate_name'] = '修改配置信息';
|
||||
}else if(strpos($v['url'],'admin/config/del_config')){
|
||||
$v['operate_name'] = '删除配置信息';
|
||||
}else if(strpos($v['url'],'admin/config/add_config')){
|
||||
$v['operate_name'] = '添加配置信息';
|
||||
}else if(strpos($v['url'],'admin/Admin/get_admin_log_list')){
|
||||
$v['operate_name'] = '管理员日志';
|
||||
}else if(strpos($v['url'],'admin/Admin/get_admin_list')){
|
||||
$v['operate_name'] = '管理员列表';
|
||||
}else if(strpos($v['url'],'admin/Admin/add_admin')){
|
||||
$v['operate_name'] = '增加管理员';
|
||||
}else if(strpos($v['url'],'admin/Admin/edit_admin_password')){
|
||||
$v['operate_name'] = '修改管理员密码';
|
||||
}else if(strpos($v['url'],'admin/Admin/edit_admin_auth')){
|
||||
$v['operate_name'] = '修改管理员权限';
|
||||
}else if(strpos($v['url'],'admin/Admin/delete_admin')){
|
||||
$v['operate_name'] = '删除管理员';
|
||||
}
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('operation')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
|
||||
}
|
||||
|
||||
public function quit_admin_login($aid){
|
||||
if(empty($aid)){
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$map = [];
|
||||
$map[] = ['aid','=', $aid];
|
||||
$admin_info = db::name('admin')->where($map)->find();
|
||||
if(!$admin_info){
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$map = [];
|
||||
$map[] = ['aid', '=', $aid];
|
||||
$update_data = [];
|
||||
$update_data['login_token'] = '';
|
||||
$reslut = db::name('admin')->where($map)->update($update_data);
|
||||
if(!$reslut){
|
||||
return ['code' => 201, 'msg' => '退出失败', 'data' => null];
|
||||
}
|
||||
|
||||
return ['code' => 200, 'msg' => '退出成功', 'data' => null];
|
||||
|
||||
}
|
||||
|
||||
//二级密码校验
|
||||
public function check_secondary_password($pass){
|
||||
if(empty($pass)){
|
||||
return ['code' => 201, 'msg' => '二级密码不能为空', 'data' => null];
|
||||
}
|
||||
$pass_word = secondary_password();
|
||||
if(md5($pass) != $pass_word){
|
||||
return ['code' => 201, 'msg' => '二级密码错误', 'data' => null];
|
||||
}else{
|
||||
return ['code' => 200, 'msg' => '成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
//清除登录状态
|
||||
public function clear_admin_token($super_aid, $aid)
|
||||
{
|
||||
if($super_aid != 1) {
|
||||
return ['code' => 201, 'msg' => '无权限操作', 'data' => null];
|
||||
}
|
||||
$result = Db::name('admin')->where('aid', $aid)->update(['login_token' => '', 'error_num' => 0, 'status' => 1, 'update_time' => time()]);
|
||||
if($result) {
|
||||
return ['code' => 200, 'msg' => '处理成功', 'data' => null];
|
||||
}
|
||||
return ['code' => 201, 'msg' => '处理失败', 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
33
application/admin/model/AdminComModel.php
Normal file
33
application/admin/model/AdminComModel.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
|
||||
use think\Model;
|
||||
|
||||
class AdminComModel extends Model
|
||||
{
|
||||
public function append_add_update_time($data, $add_time = true, $update_time = true)
|
||||
{
|
||||
if ($add_time) {
|
||||
$data['add_time'] = time();
|
||||
}
|
||||
if ($update_time) {
|
||||
$data['update_time'] = time();
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function append_add_time($data)
|
||||
{
|
||||
$data['add_time'] = time();
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function append_update_time($data)
|
||||
{
|
||||
$data['update_time'] = time();
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
103
application/admin/model/Agora.php
Normal file
103
application/admin/model/Agora.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class Agora extends Model
|
||||
{
|
||||
protected $insert = [
|
||||
'add_time',
|
||||
];
|
||||
protected $update = ['update_time'];
|
||||
|
||||
|
||||
protected function setAddTimeAttr()
|
||||
{
|
||||
return time();
|
||||
}
|
||||
|
||||
protected function setUpdateTimeAttr()
|
||||
{
|
||||
return time();
|
||||
}
|
||||
|
||||
|
||||
//获取房间音乐列表
|
||||
public function agora_song_list($aid, $song_name, $singer, $order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
$map = [];
|
||||
if (!empty($aid)) {
|
||||
$map[] = ['aid', '=', $aid];
|
||||
}
|
||||
if (!empty($song_name)) {
|
||||
$map[] = ['song_name', 'like', '%' . $song_name . '%'];
|
||||
}
|
||||
if (!empty($singer)) {
|
||||
$map[] = ['singer', 'like', '%' . $singer . '%'];
|
||||
}
|
||||
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$song_list = db::name('agora_song')->where($map)->order($order, $sort)->page($page, $limit)->select();
|
||||
$data = [];
|
||||
$data['count'] = db::name('agora_song')->where($map)->count();
|
||||
$data['list'] = $song_list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//同步歌曲
|
||||
public function synchro_song(){
|
||||
//查看当前数据库存留歌曲
|
||||
$song = db::name('agora_song')->where('is_delete',1)->order('aid desc')->limit(1)->find();
|
||||
if(empty($song)){
|
||||
$datas = model('api/Agora')->agora_song_list(0, 1000, 0);
|
||||
}else{
|
||||
$datas = model('api/Agora')->agora_song_list(0, 1000, $song['song_code']);
|
||||
}
|
||||
if(empty($datas['data']['list'])){
|
||||
return ['code' => 201, 'msg' => '暂无更多歌曲', 'data' => null];
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data_array = [];
|
||||
foreach ($datas['data']['list'] as $k => $v){
|
||||
$data['song_code'] = $v['songCode'];
|
||||
$data['song_name'] = $v['name'];
|
||||
$data['singer'] = $v['singer'];
|
||||
$data['poster'] = $v['poster'];
|
||||
$data['duration'] = $v['duration'];
|
||||
$data['type'] = $v['type'];
|
||||
$data['release_time'] = strtotime($v['releaseTime']);
|
||||
$data['status'] = $v['status'];
|
||||
$data['add_time'] = time();
|
||||
if(!empty($v['mv'])){
|
||||
$data['mv'] = json_encode($v['mv'],true);
|
||||
}
|
||||
$data_array[] = $data;
|
||||
}
|
||||
// dump($data_array);exit;
|
||||
$result = db::name('agora_song')->insertAll($data_array);
|
||||
if($result){
|
||||
return ['code' => 200, 'msg' => '更新成功', 'data' => null];
|
||||
}else{
|
||||
return ['code' => 201, 'msg' => '更新失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//增量歌曲
|
||||
public function increment_song(){
|
||||
//查看当前数据库存留歌曲
|
||||
$song = db::name('agora_song')->where('is_delete', 1)->order('aid desc')->limit(1)->find();
|
||||
if(empty($song)){
|
||||
return ['code' => 201, 'msg' => '请先去同步歌曲', 'data' => null];
|
||||
}else{
|
||||
$datas = model('api/Agora')->agora_new_song_list(1, 1000, $song['add_time']);
|
||||
}
|
||||
|
||||
dump($datas);exit;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
488
application/admin/model/BlindBox.php
Normal file
488
application/admin/model/BlindBox.php
Normal file
@@ -0,0 +1,488 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
|
||||
class BlindBox extends Model
|
||||
{
|
||||
//盲盒礼物列表
|
||||
public function get_blind_box_gift_list($tid)
|
||||
{
|
||||
$tid = 102;
|
||||
$map = [];
|
||||
$map[] = ['a.tid', '=', $tid];
|
||||
$list = db::name('box_config')->alias('a')
|
||||
->leftJoin('gift b', 'a.gid = b.gid')
|
||||
->field('b.gid,b.gift_name,b.gift_price,a.num')
|
||||
->where($map)->order('b.gift_price desc')
|
||||
->select();
|
||||
return ['code' => 200, 'msg' => '获取数据成功', 'data' => $list];
|
||||
}
|
||||
//获取所有不可购买礼物
|
||||
public function get_gift_list()
|
||||
{
|
||||
$tid = 102;
|
||||
$map = [];
|
||||
$map[] = ['is_show', '=', 1];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$map[] = ['is_can_buy', '=', 2];
|
||||
$list = db::name('gift')
|
||||
->field('gid,gift_name,gift_price')
|
||||
->where($map)->order('gift_price desc')
|
||||
->select();
|
||||
return ['code' => 200, 'msg' => '获取数据成功', 'data' => $list];
|
||||
}
|
||||
//限定礼物配置
|
||||
public function get_config_list($stage, $gid, $page = 1, $limit = 20)
|
||||
{
|
||||
$map = [];
|
||||
if(!empty($stage)){
|
||||
$map[] = ['a.stage', '=', $stage];
|
||||
}
|
||||
$list = db::name('blind_box_config')->alias('a')
|
||||
->leftJoin('gift b', 'a.gid = b.gid')
|
||||
->leftJoin('box_type c', 'a.tid = c.tid')
|
||||
->leftJoin('box_config d', 'a.tid = d.tid and a.gid = d.gid')
|
||||
->leftJoin('blind_box_stage e', 'a.stage = e.stage')
|
||||
->field('a.*,b.gift_name,b.gift_price,b.base_image,c.show_name,d.num,e.stage_name')
|
||||
->where($map)->order('id desc')
|
||||
->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
$total_bind_num = Db::name('blind_box_config')->where('stage', $v['stage'])->sum('bind_rate');
|
||||
$v['base_image'] = localpath_to_netpath($v['base_image']);
|
||||
if($total_bind_num > 0) {
|
||||
$v['bind_rate'] = bcmul(bcdiv($v['bind_rate'], $total_bind_num,4), 100, 2) . '%';
|
||||
} else {
|
||||
$v['bind_rate'] = '50%';
|
||||
}
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('blind_box_config')->alias('a')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//添加配置
|
||||
public function add_config($data)
|
||||
{
|
||||
if(empty($data['stage'])) {
|
||||
return ['code' => 201, 'msg' => '请选择阶段', 'data' => null];
|
||||
}
|
||||
if(empty($data['gid'])) {
|
||||
return ['code' => 201, 'msg' => '请选择限定礼物', 'data' => null];
|
||||
}
|
||||
if(empty($data['time_long'])) {
|
||||
return ['code' => 201, 'msg' => '请输入限定礼物增加时长', 'data' => null];
|
||||
}
|
||||
$map = [];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$map[] = ['stage', '=', $data['stage']];
|
||||
$map[] = ['gid', '=', $data['gid']];
|
||||
$info = db::name('blind_box_config')->where($map)->find();
|
||||
if($info){
|
||||
return ['code' => 201, 'msg' => '限定礼物已添加', 'data' => null];
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
//添加
|
||||
$insert = [];
|
||||
$insert['stage'] = $data['stage'];
|
||||
$insert['gid'] = $data['gid'];
|
||||
$insert['time_long'] = $data['time_long'];
|
||||
$insert['tid'] = 102;
|
||||
$insert['add_time'] = time();
|
||||
$insert['bind_rate'] = $data['bind_rate'];
|
||||
$reslut = db::name('blind_box_config')->insert($insert);
|
||||
if(!$reslut){
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '添加失败', 'data' => null];
|
||||
}
|
||||
Db::commit();
|
||||
return ['code' => 200, 'msg' => '添加成功', 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '添加失败', 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
//修改配置
|
||||
public function edit_config($data)
|
||||
{
|
||||
if(empty($data['stage'])) {
|
||||
return ['code' => 201, 'msg' => '请选择阶段', 'data' => null];
|
||||
}
|
||||
if(empty($data['gid'])) {
|
||||
return ['code' => 201, 'msg' => '请选择限定礼物', 'data' => null];
|
||||
}
|
||||
if(empty($data['time_long'])) {
|
||||
return ['code' => 201, 'msg' => '请输入限定礼物增加时长', 'data' => null];
|
||||
}
|
||||
$map = [];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$map[] = ['gid', '=', $data['gid']];
|
||||
$map[] = ['stage', '=', $data['stage']];
|
||||
$map[] = ['id', 'neq', $data['id']];
|
||||
$info = db::name('blind_box_config')->where($map)->find();
|
||||
if($info){
|
||||
return ['code' => 201, 'msg' => '限定礼物已添加', 'data' => null];
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
//添加
|
||||
$insert = [];
|
||||
$insert['stage'] = $data['stage'];
|
||||
$insert['gid'] = $data['gid'];
|
||||
$insert['time_long'] = $data['time_long'];
|
||||
$insert['update_time'] = time();
|
||||
$insert['bind_rate'] = $data['bind_rate'];
|
||||
$reslut = db::name('blind_box_config')->where('id', $data['id'])->update($insert);
|
||||
if(!$reslut){
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
Db::commit();
|
||||
return ['code' => 200, 'msg' => '修改成功', 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
//获取配置信息
|
||||
public function get_config_info($id)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['id', '=', $id];
|
||||
$config_info = db::name('blind_box_config')->where($map)->find();
|
||||
if (empty($config_info)) {
|
||||
return ['code' => 201, 'msg' => '信息不存在', 'data' => ''];
|
||||
}
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $config_info];
|
||||
}
|
||||
public function del_config($id)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['id', '=', $id];
|
||||
$config_info = db::name('blind_box_config')->where($map)->find();
|
||||
if (empty($config_info)) {
|
||||
return ['code' => 201, 'msg' => '信息不存在', 'data' => ''];
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
$result = db::name('blind_box_config')->where('id', $id)->delete();
|
||||
if(!$result){
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '删除失败', 'data' => null];
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
|
||||
return ['code' => 200, 'msg' => '删除成功', 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
dump($e);
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '删除失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
//阶段列表
|
||||
public function get_stage_list($pattern_id, $page = 1, $limit = 20)
|
||||
{
|
||||
|
||||
$map = [];
|
||||
if ($pattern_id) {
|
||||
$map[] = ['pattern_id', '=', $pattern_id];
|
||||
}
|
||||
$list = db::name('blind_box_stage')->alias('a')
|
||||
->leftJoin('gift b', 'a.gid = b.gid')
|
||||
->leftJoin('gift c', 'a.gid_r = c.gid')
|
||||
->field('a.*,b.gift_name,b.gift_price,b.base_image,c.gift_price as gift_price_r,c.gift_name as gift_name_r')
|
||||
->where($map)->order('id desc')
|
||||
->page($page, $limit)->select();
|
||||
foreach ($list as &$v) {
|
||||
$v['base_image'] = localpath_to_netpath($v['base_image']);
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('blind_box_stage')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
public function edit_stage($data)
|
||||
{
|
||||
|
||||
if(empty($data['num'])) {
|
||||
if ($data['id'] != 1) {
|
||||
return ['code' => 201, 'msg' => '请输入阶段数量', 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
if (empty($data['gid'])) {
|
||||
return ['code' => 201, 'msg' => '请选择奖励礼物', 'data' => null];
|
||||
}
|
||||
$map = [];
|
||||
$map[] = ['num', '=', $data['num']];
|
||||
$map[] = ['id', 'neq', $data['id']];
|
||||
$info = db::name('blind_box_stage')->where($map)->find();
|
||||
if($info){
|
||||
return ['code' => 201, 'msg' => '阶段数量已添加', 'data' => null];
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
//添加
|
||||
$insert = [];
|
||||
$insert['num'] = $data['num'];
|
||||
$insert['update_time'] = time();
|
||||
$insert['gid'] = $data['gid'];
|
||||
$insert['gid_r'] = $data['gid_r'];
|
||||
$reslut = db::name('blind_box_stage')->where('id', $data['id'])->update($insert);
|
||||
if(!$reslut){
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
Db::commit();
|
||||
return ['code' => 200, 'msg' => '修改成功', 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
dump($e);
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
//获取阶段信息
|
||||
public function get_stage_info($id)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['id', '=', $id];
|
||||
$config_info = db::name('blind_box_stage')->where($map)->find();
|
||||
if (empty($config_info)) {
|
||||
return ['code' => 201, 'msg' => '信息不存在', 'data' => ''];
|
||||
}
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $config_info];
|
||||
}
|
||||
//获取期数
|
||||
public function get_term_list($status, $page = 1, $limit = 20)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['a.is_delete', '=', 1];
|
||||
if ($status) {
|
||||
$map[] = ['a.status', '=', $status];
|
||||
}
|
||||
$list = db::name('blind_box_term')->alias('a')
|
||||
->leftJoin('box_type b', 'a.tid = b.tid')
|
||||
->field('a.*,b.show_name')
|
||||
->where($map)->order('id desc')
|
||||
->page($page, $limit)->select();
|
||||
$data = [];
|
||||
$data['count'] = db::name('blind_box_term')->alias('a')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//添加期数
|
||||
public function add_term($data)
|
||||
{
|
||||
if(empty($data['time_long'])) {
|
||||
return ['code' => 201, 'msg' => '请输入时长', 'data' => null];
|
||||
}
|
||||
$map = [];
|
||||
$map[] = ['status', '=', 1];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$info = db::name('blind_box_term')->where($map)->find();
|
||||
if($info){
|
||||
return ['code' => 201, 'msg' => '已存在未开启活动,请勿重新添加', 'data' => null];
|
||||
}
|
||||
|
||||
try {
|
||||
//添加
|
||||
$insert = [];
|
||||
$insert['time_long'] = $data['time_long'];
|
||||
$insert['tid'] = 102;
|
||||
$insert['add_time'] = time();
|
||||
$result = db::name('blind_box_term')->insert($insert);
|
||||
|
||||
return ['code' => 200, 'msg' => '添加成功', 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
dump($e);
|
||||
|
||||
return ['code' => 201, 'msg' => '添加失败', 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
//修改期数
|
||||
public function edit_term($data)
|
||||
{
|
||||
$term_info = Db::name('blind_box_term')->find($data['id']);
|
||||
if(empty($term_info)){
|
||||
return ['code' => 201, 'msg' => '信息不存在', 'data' => null];
|
||||
}
|
||||
if ($term_info['status'] != 1) {
|
||||
return ['code' => 201, 'msg' => '该期已启用,无法修改', 'data' => null];
|
||||
}
|
||||
if(empty($data['time_long'])) {
|
||||
return ['code' => 201, 'msg' => '请输入活动时长', 'data' => null];
|
||||
}
|
||||
|
||||
try {
|
||||
//添加
|
||||
$insert = [];
|
||||
$insert['time_long'] = $data['time_long'];
|
||||
$insert['update_time'] = time();
|
||||
$result = db::name('blind_box_term')->where('id', $data['id'])->update($insert);
|
||||
|
||||
|
||||
return ['code' => 200, 'msg' => '修改成功', 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
//获取期数信息
|
||||
public function get_term_info($id)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['id', '=', $id];
|
||||
$config_info = db::name('blind_box_term')->where($map)->find();
|
||||
if (empty($config_info)) {
|
||||
return ['code' => 201, 'msg' => '信息不存在', 'data' => ''];
|
||||
}
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $config_info];
|
||||
}
|
||||
public function del_term($id)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['id', '=', $id];
|
||||
$term_info = db::name('blind_box_term')->where($map)->find();
|
||||
if (empty($term_info)) {
|
||||
return ['code' => 201, 'msg' => '期数不存在', 'data' => ''];
|
||||
}
|
||||
if ($term_info['status'] != 1) {
|
||||
return ['code' => 201, 'msg' => '该期已启用,无法删除', 'data' => null];
|
||||
}
|
||||
|
||||
try {
|
||||
$result = db::name('blind_box_term')->where('id', $id)->update(['is_delete' => 2, 'delete_time' => time()]);
|
||||
|
||||
return ['code' => 200, 'msg' => '删除成功', 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
dump($e);
|
||||
|
||||
return ['code' => 201, 'msg' => '删除失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//开启活动
|
||||
public function open_term($id)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['id', '=', $id];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$term_info = db::name('blind_box_term')->where($map)->find();
|
||||
if (empty($term_info)) {
|
||||
return ['code' => 201, 'msg' => '期数不存在', 'data' => ''];
|
||||
}
|
||||
if ($term_info['status'] != 1) {
|
||||
return ['code' => 201, 'msg' => '该期已启用,无法开启', 'data' => null];
|
||||
}
|
||||
$map = [];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$map[] = ['status', '=', 2];
|
||||
$has_open_term = db::name('blind_box_term')->where($map)->find();
|
||||
if($has_open_term){
|
||||
return ['code' => 201, 'msg' => '已有进行中的期数,请勿重复开启', 'data' => null];
|
||||
}
|
||||
//获取锁定礼物
|
||||
$lock_gift_list = db::name('blind_box_config')
|
||||
->where('tid', 102)
|
||||
->select();
|
||||
$lock_gid_arr = [];
|
||||
$lock_stage_gid_list = [];
|
||||
foreach($lock_gift_list as $v) {
|
||||
if ($v['stage'] > 0) {
|
||||
if($v['bind_rate'] > 0) {
|
||||
for($i=1; $i<=$v['bind_rate']; $i++) {
|
||||
$lock_gid_arr[$v['stage']][] = $v['gid'];
|
||||
}
|
||||
} else {
|
||||
$lock_gid_arr[$v['stage']][] = $v['gid'];
|
||||
}
|
||||
|
||||
$lock_stage_gid_list[$v['stage'] . '-' . $v['gid']] = $v;
|
||||
}
|
||||
}
|
||||
$stage_list = Db::name('blind_box_stage')->order('stage asc')->select();
|
||||
$params = [];
|
||||
foreach ($stage_list as $v) {
|
||||
$stage = $v['stage'];
|
||||
$gid_arr = $lock_gid_arr[$v['stage']] ?? [];
|
||||
if (empty($gid_arr)) {
|
||||
return ['code' => 201, 'msg' => '阶段' . $stage . '未配置礼物', 'data' => null];
|
||||
}
|
||||
shuffle($gid_arr);
|
||||
$gid = $gid_arr[array_rand($gid_arr)];
|
||||
$gid_info = $lock_stage_gid_list[$stage . '-' . $gid] ?? [];
|
||||
if (empty($gid_info)) {
|
||||
return ['code' => 201, 'msg' => '阶段' . $stage . '未配置礼物', 'data' => null];
|
||||
}
|
||||
$temp = [
|
||||
'term_id' => $id,
|
||||
'gid' => $gid,
|
||||
'num' => $v['num'],
|
||||
'multi' => $v['multi'],
|
||||
'time_long' => $gid_info['time_long'],
|
||||
'stage' => $v['stage'],
|
||||
'add_time' => time(),
|
||||
'pattern_id' => $v['pattern_id'],
|
||||
'reward_gid' => $v['gid'],
|
||||
'reward_gid_r' => $v['gid_r'],
|
||||
];
|
||||
$params[] = $temp;
|
||||
}
|
||||
|
||||
$end_time = $term_info['time_long'] * 60;
|
||||
$end_time = $end_time + time();
|
||||
|
||||
$update_data = [
|
||||
'status' => 2,
|
||||
'start_time' => time(),
|
||||
'end_time' => $end_time,
|
||||
'real_end_time' => $end_time,
|
||||
'update_time' => time(),
|
||||
'pattern_id' => 1,
|
||||
];
|
||||
Db::startTrans();
|
||||
try {
|
||||
Db::name('blind_box_term')->where('id', $id)->update($update_data);
|
||||
Db::name('blind_box_term_params')->insertAll($params);
|
||||
Db::commit();
|
||||
$push_data = [
|
||||
'code' => 312,
|
||||
'msg' => '盲盒巡乐开始',
|
||||
'data' => [
|
||||
'term_id' => $id,
|
||||
'over_time' => $term_info['time_long'] * 60
|
||||
]
|
||||
];
|
||||
model('api/WebSocketPush')->send_to_all($push_data);
|
||||
return ['code' => 200, 'msg' => '开启成功', 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
|
||||
Db::rollback();
|
||||
// dump($e);
|
||||
// 回滚事务
|
||||
return ['code' => 201, 'msg' => '开启失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
214
application/admin/model/Block.php
Normal file
214
application/admin/model/Block.php
Normal file
@@ -0,0 +1,214 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
|
||||
class Block extends Model
|
||||
{
|
||||
|
||||
public function get_block_list($type, $type_text, $is_delete, $page = 1, $limit = 20)
|
||||
{
|
||||
$map = [];
|
||||
if(!empty($type)){
|
||||
$map[] = ['type', '=', $type];
|
||||
}
|
||||
if(!empty($type_text)){
|
||||
$map[] = ['type_text', '=', $type_text];
|
||||
}
|
||||
if(!empty($is_delete)){
|
||||
$map[] = ['is_delete', '=', $is_delete];
|
||||
}
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$list = db::name('block')->where($map)->order('id desc')->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['count'] = db::name('block')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
|
||||
public function add_block($aid, $data)
|
||||
{
|
||||
if(empty($data['type_text'])){
|
||||
return ['code' => 201, 'msg' => '封禁内容不能为空', 'data' => null];
|
||||
}
|
||||
|
||||
// if(empty($data['block_note'])){
|
||||
// return ['code' => 201, 'msg' => '封禁原因不能为空', 'data' => null];
|
||||
// }
|
||||
|
||||
// if(empty($data['block_time'])){
|
||||
// return ['code' => 201, 'msg' => '封禁截止日期不能为空', 'data' => null];
|
||||
// }
|
||||
|
||||
// $block_time = $data['block_time'];
|
||||
// $data['block_time'] = strtotime($data['block_time']);
|
||||
|
||||
$map = [];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$map[] = ['type', '=', $data['type']];
|
||||
$map[] = ['type_text', '=', $data['type_text']];
|
||||
$info = db::name('block')->where($map)->find();
|
||||
if($info){
|
||||
return ['code' => 201, 'msg' => '当前封禁内容已添加', 'data' => null];
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
|
||||
//添加
|
||||
$insert = [];
|
||||
$insert['aid'] = $aid;
|
||||
$insert['type'] = $data['type'];
|
||||
$insert['type_text'] = $data['type_text'];
|
||||
// $insert['block_time'] = $data['block_time'];
|
||||
// $insert['block_note'] = $data['block_note'];
|
||||
$insert['add_time'] = time();
|
||||
$reslut = db::name('block')->insert($insert);
|
||||
if(!$reslut){
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '添加失败', 'data' => null];
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
|
||||
return ['code' => 200, 'msg' => '添加成功', 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
dump($e);
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '添加失败', 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
public function del_block($id)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['id', '=', $id];
|
||||
$block_info = db::name('block')->where($map)->find();
|
||||
if (empty($block_info)) {
|
||||
return ['code' => 201, 'msg' => '信息不存在', 'data' => ''];
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
|
||||
//删除封禁
|
||||
$update = [];
|
||||
$update['is_delete'] = 2;
|
||||
$update['update_time'] = time();
|
||||
$reslut = db::name('block')->where('id', $id)->update($update);
|
||||
if(!$reslut){
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '解封失败', 'data' => null];
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
|
||||
return ['code' => 200, 'msg' => '解封成功', 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
dump($e);
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '解封失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//定时任务 房间解禁
|
||||
public function close_room_unfreeze(){
|
||||
$now_time = time();
|
||||
$map = [];
|
||||
$map[] = ['room_status', '=', 2];
|
||||
$map[] = ['block_time', '<=', $now_time];
|
||||
$block_room_list = db::name('room')->where($map)->select();
|
||||
if($block_room_list){
|
||||
foreach ($block_room_list as $k => $v){
|
||||
Db::startTrans();
|
||||
try {
|
||||
//解禁房间
|
||||
$update = [];
|
||||
$update['room_status'] = 1;
|
||||
$update['block_time'] = 0;
|
||||
$update['block_note'] = '';
|
||||
$update['update_time'] = $now_time;
|
||||
$reslut = db::name('room')->where('rid', $v['rid'])->update($update);
|
||||
if(!$reslut){
|
||||
Db::rollback();
|
||||
}
|
||||
//删除解禁记录
|
||||
$where = [];
|
||||
$where[] = ['rid', '=', $v['rid']];
|
||||
$where[] = ['is_delete', '=', 1];
|
||||
$update = [];
|
||||
$update['is_delete'] = 2;
|
||||
$update['update_time'] = $now_time;
|
||||
$reslut = db::name('room_block_log')->where($where)->update($update);
|
||||
if(!$reslut){
|
||||
Db::rollback();
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
dump($e);
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//定时任务 用户解禁
|
||||
public function close_user_unfreeze(){
|
||||
$now_time = time();
|
||||
$map = [];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$map[] = ['block_time', '<=', $now_time];
|
||||
$block_user_list = db::name('block')->where($map)->select();
|
||||
if($block_user_list){
|
||||
foreach ($block_user_list as $k => $v){
|
||||
Db::startTrans();
|
||||
try {
|
||||
if($v['type'] == 2){//解封账号
|
||||
$map = [];
|
||||
$map[] = ['user_name', '=', $v['type_text']];
|
||||
$update = [];
|
||||
$update['login_status'] = 1;
|
||||
$update['update_time'] = time();
|
||||
$reslut = db::name('user')->where($map)->update($update);
|
||||
if(!$reslut){
|
||||
Db::rollback();
|
||||
}
|
||||
}
|
||||
|
||||
//解封记录
|
||||
$update = [];
|
||||
$update['is_delete'] = 2;
|
||||
$update['update_time'] = time();
|
||||
$reslut = db::name('block')->where('id', $v['id'])->update($update);
|
||||
if(!$reslut){
|
||||
Db::rollback();
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
dump($e);
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
1046
application/admin/model/Box.php
Normal file
1046
application/admin/model/Box.php
Normal file
File diff suppressed because it is too large
Load Diff
119
application/admin/model/BoxGiveGift.php
Normal file
119
application/admin/model/BoxGiveGift.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
|
||||
class BoxGiveGift extends Model
|
||||
{
|
||||
protected $pk = 'id';
|
||||
protected $auto = ['update_time'];
|
||||
protected $insert = [
|
||||
'add_time',
|
||||
];
|
||||
protected $update = ['update_time'];
|
||||
|
||||
protected function setAddTimeAttr()
|
||||
{
|
||||
return time();
|
||||
}
|
||||
protected function setUpdateTimeAttr()
|
||||
{
|
||||
return time();
|
||||
}
|
||||
public function get_box_give_gift_list($uid, $gid, $gift_name, $give_status, $deduction_status, $start, $give, $deduction, $page = 1, $limit = 20)
|
||||
{
|
||||
$map = [];
|
||||
if (!empty($uid)) {
|
||||
$map[] = ['a.uid', '=', $uid];
|
||||
}
|
||||
if (!empty($gid)) {
|
||||
$map[] = ['a.gid', '=', $gid];
|
||||
}
|
||||
if(!empty($gift_name)){
|
||||
$map[] = ['b.gift_name', 'like', '%'.$gift_name.'%'];
|
||||
}
|
||||
if(!empty($give_status)){
|
||||
$map[] = ['a.give_status', '=', $give_status];
|
||||
}
|
||||
if(!empty($deduction_status)){
|
||||
$map[] = ['a.deduction_status', '=', $deduction_status];
|
||||
}
|
||||
if(!empty($start)){
|
||||
$map[] = ['a.add_time', '>=', strtotime($start)];
|
||||
}
|
||||
if(!empty($give)){
|
||||
$map[] = ['a.give_time', '>=',strtotime($give)];
|
||||
}
|
||||
if(!empty($deduction)){
|
||||
$map[] = ['a.deduction_time', '>=', strtotime($deduction)];
|
||||
}
|
||||
|
||||
$list = db::name('box_give_gift')->alias('a')->join('yy_gift b', 'a.gid = b.gid')->field('a.*, b.gift_name, b.gift_price, b.base_image')->where($map)->order('id', 'desc')->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
$user_info = db::name('user')->field('uid,user_name,nick_name,base64_nick_name')->where('uid', $v['uid'])->find();
|
||||
$box_type_info = db::name('box_type')->find($v['tid']);
|
||||
$v['type_name'] = $box_type_info['type_name'];
|
||||
$v['rid'] = db::name('room')->where('rid',$v['rid'])->value('room_number');
|
||||
|
||||
// $gift_info = db::name('gift')->find($v['gid']);
|
||||
// if (!empty($gift_info)) {
|
||||
// $v['gift_name'] = $gift_info['gift_name'];
|
||||
// $v['gift_price'] = $gift_info['gift_price'];
|
||||
// $v['base_image'] = localpath_to_netpath($gift_info['base_image']);
|
||||
// } else {
|
||||
// $v['gift_name'] = '';
|
||||
// $v['gift_price'] = 0;
|
||||
// }
|
||||
$v['base_image'] = localpath_to_netpath($v['base_image']);
|
||||
$v['user_name'] = $user_info['user_name'];
|
||||
$v['nick_name'] = mb_convert_encoding(base64_decode($user_info['base64_nick_name']), 'UTF-8', 'UTF-8');
|
||||
}
|
||||
$data = [];
|
||||
$data['list'] = $list;
|
||||
$totalRowData = db::name('box_give_gift')->alias('a')->join('yy_gift b', 'a.gid = b.gid')->field('count(1) as count,SUM(a.num) as num')->where($map)->find();
|
||||
$data['count'] = $totalRowData['count'];
|
||||
unset($totalRowData['count']);
|
||||
//dump($totalRowData);
|
||||
$data['totalRow'] = $totalRowData;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
public function add_give_gift($data)
|
||||
{
|
||||
$data['num'] = 1;
|
||||
|
||||
$validate = validate('admin/BoxGiveGift');
|
||||
$reslut = $validate->scene('adminAdd')->check($data);
|
||||
if ($reslut !== true) {
|
||||
return ['code' => 201, 'msg' => $validate->getError(), 'data' => null];
|
||||
}
|
||||
$BoxGiveGift = model('admin/BoxGiveGift');
|
||||
$reslut = $BoxGiveGift->save($data);
|
||||
if ($reslut) {
|
||||
return ['code' => 200, 'msg' => '添加成功', 'data' => ''];
|
||||
} else {
|
||||
return ['code' => 201, 'msg' => '添加失败', 'data' => ''];
|
||||
}
|
||||
}
|
||||
public function cancel_give_gift($id)
|
||||
{
|
||||
$give_gift = db::name('box_give_gift')->find($id);
|
||||
if($give_gift['is_admin'] == 2){
|
||||
return ['code' => 201, 'msg' => '厅主发放不能删除', 'data' => ''];
|
||||
}
|
||||
|
||||
$map = [];
|
||||
$map[] = ['id', '=', $id];
|
||||
$map[] = ['give_status', '=', 1];
|
||||
$data = [];
|
||||
$data['give_status'] = 3;
|
||||
$data['canel_time'] = time();
|
||||
$reslut = db::name('box_give_gift')->where($map)->update($data);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '更新失败', 'data' => ''];
|
||||
}
|
||||
return ['code' => 200, 'msg' => '更新成功', 'data' => ''];
|
||||
}
|
||||
}
|
||||
26
application/admin/model/BoxType.php
Normal file
26
application/admin/model/BoxType.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class BoxType extends Model
|
||||
{
|
||||
protected $pk = 'tid';
|
||||
protected $auto = ['update_time'];
|
||||
protected $insert = [
|
||||
'add_time',
|
||||
];
|
||||
protected $update = ['update_time'];
|
||||
|
||||
|
||||
protected function setAddTimeAttr()
|
||||
{
|
||||
return time();
|
||||
}
|
||||
|
||||
protected function setUpdateTimeAttr()
|
||||
{
|
||||
return time();
|
||||
}
|
||||
}
|
||||
1004
application/admin/model/Capital.php
Normal file
1004
application/admin/model/Capital.php
Normal file
File diff suppressed because it is too large
Load Diff
128
application/admin/model/Config.php
Normal file
128
application/admin/model/Config.php
Normal file
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
|
||||
class Config extends Model
|
||||
{
|
||||
//获取配置参数
|
||||
public function get_system_config($key = "")
|
||||
{
|
||||
$config = Db::name('config')->cache(10)->order('sort desc')->select();
|
||||
$config_data = [];
|
||||
foreach ($config as $k => $v) {
|
||||
$config_data[$v['key_title']] = $v['key_value'];
|
||||
}
|
||||
if (empty($key)) {
|
||||
return $config_data;
|
||||
} else {
|
||||
if (!isset($config_data[$key]) || $config_data[$key] == "") {
|
||||
return ajaxReturn(201, '配置参数:' . $key . '不存在', null);
|
||||
}
|
||||
return $config_data[$key];
|
||||
}
|
||||
}
|
||||
|
||||
//无缓存获取配置参数
|
||||
public function get_uncache_system_config($key = "")
|
||||
{
|
||||
$config = Db::name('config')->order('sort desc')->select();
|
||||
$config_data = [];
|
||||
foreach ($config as $k => $v) {
|
||||
$config_data[$v['key_title']] = $v['key_value'];
|
||||
}
|
||||
if (empty($key)) {
|
||||
return $config_data;
|
||||
} else {
|
||||
if (!isset($config_data[$key]) || $config_data[$key] == "") {
|
||||
return ajaxReturn(201, '配置参数:' . $key . '不存在', null);
|
||||
}
|
||||
return $config_data[$key];
|
||||
}
|
||||
}
|
||||
|
||||
//配置列表
|
||||
public function config_list($cid, $key_name, $order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
$map = [];
|
||||
if (!empty($cid)) {
|
||||
$map[] = ['cid', '=', $cid];
|
||||
}
|
||||
if (!empty($key_name)) {
|
||||
$map[] = ['key_name|key_value', 'like', '%' . $key_name . '%'];
|
||||
}
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$list = db::name('config')->where($map)->order($order, $sort)->page($page, $limit)->select();
|
||||
|
||||
$data = [];
|
||||
$data['count'] = db::name('config')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
//编辑配置
|
||||
public function edit_config($data)
|
||||
{
|
||||
if (empty($data)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$info = db::name('config')->find($data['cid']);
|
||||
if (empty($info)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$update_data = [];
|
||||
// $update_data['key_title'] = $data['key_title'];
|
||||
// $update_data['key_name'] = $data['key_name'];
|
||||
$update_data['key_value'] = $data['key_value'];
|
||||
$update_data['key_desc'] = $data['key_desc'];
|
||||
$update_data['update_time'] = time();
|
||||
$reslut = db::name('config')->where(['cid' => $data['cid']])->update($update_data);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '修改成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
//添加配置
|
||||
public function add_config($data)
|
||||
{
|
||||
$add_data = [];
|
||||
$add_data['key_title'] = $data['key_title'];
|
||||
$add_data['key_name'] = $data['key_name'];
|
||||
$add_data['key_value'] = $data['key_value'];
|
||||
$add_data['key_desc'] = $data['key_desc'];
|
||||
$add_data['update_time'] = time();
|
||||
$reslut = db::name('config')->insert($add_data);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '添加失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '添加成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//获取配置信息
|
||||
public function config_info($cid)
|
||||
{
|
||||
if (empty($cid)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$gift_info = db::name('config')->where(['cid' => $cid])->find();
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $gift_info];
|
||||
}
|
||||
|
||||
//删除配置
|
||||
public function del_config($cid)
|
||||
{
|
||||
return ['code' => 201, 'msg' => '操作已禁止', 'data' => null];
|
||||
if (empty($cid)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$reslut = db::name('config')->where(['cid' => $cid])->delete();
|
||||
if ($reslut) {
|
||||
return ['code' => 200, 'msg' => '删除成功', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 201, 'msg' => '删除失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
502
application/admin/model/Decorate.php
Normal file
502
application/admin/model/Decorate.php
Normal file
@@ -0,0 +1,502 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
|
||||
class Decorate extends Model
|
||||
{
|
||||
//获取装扮列表
|
||||
public function get_decorate_list($title, $type, $page = 1, $limit = 20)
|
||||
{
|
||||
$map = [];
|
||||
if (!empty($type)) {
|
||||
$map[] = ['type', '=', $type];
|
||||
}
|
||||
if (!empty($title)) {
|
||||
$map[] = ['title', 'like', '%' . $title . '%'];
|
||||
}
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
|
||||
$list = db::name('decorate')->where($map)->order('did desc')->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['base_image'] = localpath_to_netpath($v['base_image']);
|
||||
$v['play_image'] = localpath_to_netpath($v['play_image']);
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('decorate')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
public function get_decorates_list()
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$map[] = ['type', 'in', [1,2,4,5]];
|
||||
$list = db::name('decorate')->where($map)->order('did', 'asc')->select();
|
||||
$data = [];
|
||||
$data['count'] = db::name('decorate')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//编辑装扮
|
||||
public function add_decorate_info($title, $type, $base_image, $play_image, $day, $price, $show_status, $file_type, $plays_image, $is_buy)
|
||||
{
|
||||
// $map = [];
|
||||
// $map[] = ['did', '=', $did];
|
||||
// $map[] = ['is_delete', '=', 1];
|
||||
// $info = db::name('decorate')->where($map)->find();
|
||||
// if (empty($info)) {
|
||||
// return ['code' => 201, 'msg' => '信息不存在', 'data' => null];
|
||||
// }
|
||||
if (!in_array($type, [1, 2, 3, 4, 5,6,7,9])) {
|
||||
return ['code' => 201, 'msg' => '装扮类型参数非法', 'data' => null];
|
||||
}
|
||||
$special_num = input('special_num', 0);
|
||||
$data = [];
|
||||
$data['title'] = $title;
|
||||
$data['type'] = $type;
|
||||
$data['base_image'] = $base_image;
|
||||
// $data['play_image'] = $play_image;
|
||||
$data['file_type'] = $file_type;
|
||||
if($file_type == 1){
|
||||
$data['play_image'] = $play_image;
|
||||
}else{
|
||||
$data['play_image'] = $plays_image;
|
||||
}
|
||||
// $data['day'] = $day;
|
||||
// $data['price'] = $price;
|
||||
$data['is_buy'] = $is_buy;
|
||||
$data['show_status'] = $show_status;
|
||||
$data['is_delete'] = 1;
|
||||
$data['delete_time'] = 0;
|
||||
$data['add_time'] = time();
|
||||
$data['update_time'] = time();
|
||||
if($type == 6 || $type == 7) {
|
||||
if(empty($special_num)) {
|
||||
return ['code' => 201, 'msg' => '请输入靓号号码', 'data' => null];
|
||||
}
|
||||
$map = [];
|
||||
$map[] = ['special_num', '=', $special_num];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$count = Db::name('decorate')->where($map)->count();
|
||||
if($count > 0) {
|
||||
return ['code' => 201, 'msg' => '靓号已存在', 'data' => null];
|
||||
}
|
||||
} else {
|
||||
$special_num = 0;
|
||||
}
|
||||
$data['special_num'] = $special_num;
|
||||
$status = db::name('decorate')->insert($data);
|
||||
if ($status) {
|
||||
return ['code' => 200, 'msg' => '添加成功', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 201, 'msg' => '添加失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//编辑装扮
|
||||
public function get_decorate_info($did)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['did', '=', $did];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$info = db::name('decorate')->where($map)->find();
|
||||
if (empty($info)) {
|
||||
return ['code' => 201, 'msg' => '信息不存在', 'data' => null];
|
||||
}
|
||||
|
||||
$info['http_base_image'] = localpath_to_netpath($info['base_image']);
|
||||
$info['http_play_image'] = localpath_to_netpath($info['play_image']);
|
||||
$info['plays_image'] = $info['play_image'];
|
||||
return ['code' => 200, 'msg' => '编辑成功', 'data' => $info];
|
||||
}
|
||||
public function edit_decorate_info($did, $title, $type, $base_image, $play_image, $show_status, $day, $price, $file_type, $plays_image, $is_buy)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['did', '=', $did];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$info = db::name('decorate')->where($map)->find();
|
||||
if (empty($info)) {
|
||||
return ['code' => 201, 'msg' => '信息不存在', 'data' => null];
|
||||
}
|
||||
if (!in_array($type, [1, 2, 3, 4, 5, 6, 7,9])) {
|
||||
return ['code' => 201, 'msg' => '装扮类型参数非法', 'data' => null];
|
||||
}
|
||||
if (!in_array($show_status, [1, 2])) {
|
||||
return ['code' => 201, 'msg' => '显示状态参数非法', 'data' => null];
|
||||
}
|
||||
$special_num = input('special_num', 0);
|
||||
//修改用户装扮表对应装扮类型
|
||||
$data = [];
|
||||
$data['type'] = $type;
|
||||
$data['update_time'] = time();
|
||||
$map = [];
|
||||
$map[] = ['did', '=', $did];
|
||||
db::name('user_decorate')->where($map)->update($data);
|
||||
|
||||
$data = [];
|
||||
$data['title'] = $title;
|
||||
$data['type'] = $type;
|
||||
$data['base_image'] = $base_image;
|
||||
// $data['play_image'] = $play_image;
|
||||
$data['file_type'] = $file_type;
|
||||
if($file_type == 1){
|
||||
$data['play_image'] = $play_image;
|
||||
}else{
|
||||
$data['play_image'] = $plays_image;
|
||||
}
|
||||
$data['show_status'] = $show_status;
|
||||
// $data['day'] = $day;
|
||||
// $data['price'] = $price;
|
||||
$data['is_buy'] = $is_buy;
|
||||
$data['update_time'] = time();
|
||||
if($type == 6 || $type == 7) {
|
||||
if(empty($special_num)) {
|
||||
return ['code' => 201, 'msg' => '请输入靓号号码', 'data' => null];
|
||||
}
|
||||
$map = [];
|
||||
$map[] = ['special_num', '=', $special_num];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$map[] = ['did', 'neq', $did];
|
||||
$count = Db::name('decorate')->where($map)->count();
|
||||
if($count > 0) {
|
||||
return ['code' => 201, 'msg' => '靓号已存在', 'data' => null];
|
||||
}
|
||||
} else {
|
||||
$special_num = 0;
|
||||
}
|
||||
$data['special_num'] = $special_num;
|
||||
$map = [];
|
||||
$map[] = ['did', '=', $did];
|
||||
$status = db::name('decorate')->where($map)->update($data);
|
||||
if ($status) {
|
||||
return ['code' => 200, 'msg' => '编辑成功', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 201, 'msg' => '编辑失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//删除装扮
|
||||
public function delete_decorate_info($did)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['did', '=', $did];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$info = db::name('decorate')->where($map)->find();
|
||||
if (empty($info)) {
|
||||
return ['code' => 201, 'msg' => '信息不存在', 'data' => null];
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['is_delete'] = 2;
|
||||
$data['delete_time'] = time();
|
||||
$map = [];
|
||||
$map[] = ['did', '=', $did];
|
||||
$status = db::name('decorate')->where($map)->update($data);
|
||||
if ($status) {
|
||||
return ['code' => 200, 'msg' => '删除成功', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 201, 'msg' => '删除失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//清理过期装扮
|
||||
public function clear_user_decorate()
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['end_time', '<', time()];
|
||||
$map[] = ['is_perpetual', '=', 2];
|
||||
$list = Db::name('user_decorate')->where($map)->select();
|
||||
Db::startTrans();
|
||||
try {
|
||||
foreach($list as $v) {
|
||||
if($v['type'] == 7 && $v['rid'] > 0 && $v['is_using'] == 1) {
|
||||
Db::name('room')->where('rid', $v['rid'])->update(['pretty_room_number' => 0]);
|
||||
}
|
||||
if($v['type'] == 6 && $v['is_using'] == 1) {
|
||||
Db::name('user')->where('uid', $v['uid'])->update(['special_uid' => 0]);
|
||||
}
|
||||
if($v['type'] == 7 || $v['type'] == 6) {
|
||||
db::name('decorate')->where(['did' => $v['did']])->update(['is_user_buy' => 2]);
|
||||
}
|
||||
}
|
||||
db::name('user_decorate')->where($map)->delete();
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
return ['code' => 200, 'msg' => "成功", 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
|
||||
Db::rollback();
|
||||
dump($e);
|
||||
// 回滚事务
|
||||
return ['code' => 201, 'msg' => "失败5", 'data' => null];
|
||||
}
|
||||
return '清理成功';
|
||||
}
|
||||
public function give_user_decorate($uid, $did, $day)
|
||||
{
|
||||
if ($day < 1) {
|
||||
return ['code' => 201, 'msg' => '赠送至少一天', 'data' => null];
|
||||
}
|
||||
$map = [];
|
||||
$map[] = ['did', '=', $did];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$decorate_info = db::name('decorate')->where($map)->find();
|
||||
if (empty($decorate_info)) {
|
||||
return ['code' => 201, 'msg' => '装扮信息不存在', 'data' => null];
|
||||
}
|
||||
if($decorate_info['is_user_buy'] == 1){
|
||||
return ['code' => 201, 'msg' => '该装扮已无法赠送', 'data' => null];
|
||||
}
|
||||
$user_info = db::name('user')->where('uid', $uid)->find();
|
||||
if (empty($user_info)) {
|
||||
return ['code' => 201, 'msg' => '用户信息不存在', 'data' => null];
|
||||
}
|
||||
$map = [];
|
||||
$map[] = ['uid', '=', $uid];
|
||||
$map[] = ['did', '=', $did];
|
||||
$user_decorate_data = db::name('user_decorate')->where($map)->find();
|
||||
if (empty($user_decorate_data)) {
|
||||
$data = [];
|
||||
$data['uid'] = $uid;
|
||||
$data['did'] = $did;
|
||||
$data['type'] = $decorate_info['type'];
|
||||
$data['is_using'] = 2;
|
||||
$now_time = time();
|
||||
$data['special_num'] = $decorate_info['special_num'];
|
||||
$data['end_time'] = $now_time + $day * 24 * 3600;
|
||||
$data['add_time'] = $now_time;
|
||||
$data['update_time'] = $now_time;
|
||||
db::name('user_decorate')->insert($data);
|
||||
} else {
|
||||
$change_time = $day * 24 * 3600;
|
||||
db::name('user_decorate')->where('udid', $user_decorate_data['udid'])->setInc('end_time', $change_time);
|
||||
}
|
||||
if($decorate_info['type'] == 6 || $decorate_info['type'] == 7){
|
||||
Db::name('decorate')->where('did', $decorate_info['did'])->update(['is_user_buy' => 1, 'update_time' => time()]);
|
||||
}
|
||||
return ['code' => 200, 'msg' => '赠送成功', 'data' => null];
|
||||
}
|
||||
|
||||
public function get_user_decorate_list($uid, $did, $type, $page, $page_limit)
|
||||
{
|
||||
$map = [];
|
||||
if (!empty($uid)) {
|
||||
$map[] = ['a.uid', '=', $uid];
|
||||
}
|
||||
if (!empty($did)) {
|
||||
$map[] = ['a.did', '=', $did];
|
||||
}
|
||||
if (!empty($type)) {
|
||||
$map[] = ['a.type', '=', $type];
|
||||
}
|
||||
$map[] = ['b.is_delete', '=', 1];
|
||||
$model = Db::name('user_decorate')->alias('a')->join('yy_decorate b', 'a.did = b.did');
|
||||
$model = $model->where($map);
|
||||
$list = $model->order('udid desc')->page($page, $page_limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['base_image'] = localpath_to_netpath($v['base_image']);
|
||||
$v['play_image'] = localpath_to_netpath($v['play_image']);
|
||||
$user_info = db::name('user')->find($v['uid']);
|
||||
$v['nick_name'] = base64_decode($user_info['base64_nick_name']);
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = $model->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
public function delete_user_decorate($udid)
|
||||
{
|
||||
return ['code' => 201, 'msg' => '无法操作', 'data' => null];
|
||||
$map = [];
|
||||
$map[] = ['udid', '=', $udid];
|
||||
db::name('user_decorate')->where($map)->delete();
|
||||
return ['code' => 200, 'msg' => '删除成功', 'data' => null];
|
||||
}
|
||||
|
||||
public function get_head_decorate_list(){
|
||||
$map = [];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$map[] = ['type', '=', 1];
|
||||
$list = db::name('decorate')->where($map)->order('did', 'asc')->select();
|
||||
$data = [];
|
||||
$data['count'] = db::name('decorate')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
public function get_mount_decorate_list(){
|
||||
$map = [];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$map[] = ['type', '=', 2];
|
||||
$list = db::name('decorate')->where($map)->order('did', 'asc')->select();
|
||||
$data = [];
|
||||
$data['count'] = db::name('decorate')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
|
||||
public function get_cp_tx_list(){
|
||||
$map = [];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$map[] = ['type', '=', 9];
|
||||
$list = db::name('decorate')->where($map)->order('did', 'asc')->select();
|
||||
$data = [];
|
||||
$data['count'] = db::name('decorate')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function get_wind_decorate_list(){
|
||||
$map = [];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$map[] = ['type', '=', 3];
|
||||
$list = db::name('decorate')->where($map)->order('did', 'asc')->select();
|
||||
$data = [];
|
||||
$data['count'] = db::name('decorate')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//获取装扮价位列表
|
||||
public function get_decorate_price_list($did, $page = 1, $limit = 20)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$map[] = ['did', '=', $did];
|
||||
$list = db::name('decorate_price')->where($map)->order('id desc')->page($page, $limit)->select();
|
||||
|
||||
$data = [];
|
||||
$data['count'] = db::name('decorate_price')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
//添加装扮价位
|
||||
public function add_decorate_price($did, $price, $day)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['did', '=', $did];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$info = db::name('decorate')->where($map)->find();
|
||||
if (empty($info)) {
|
||||
return ['code' => 201, 'msg' => '信息不存在', 'data' => null];
|
||||
}
|
||||
|
||||
//该装扮价位天数是否存在
|
||||
$map = [];
|
||||
$map[] = ['did', '=', $did];
|
||||
$map[] = ['day', '=', $day];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$decorate_price_info = db::name('decorate_price')->where($map)->find();
|
||||
if($decorate_price_info){
|
||||
return ['code' => 201, 'msg' => '该装扮天数已存在', 'data' => null];
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['did'] = $did;
|
||||
$data['price'] = $price;
|
||||
$data['day'] = $day;
|
||||
$data['is_delete'] = 1;
|
||||
$data['add_time'] = time();
|
||||
$status = db::name('decorate_price')->insert($data);
|
||||
if ($status) {
|
||||
return ['code' => 200, 'msg' => '添加成功', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 201, 'msg' => '添加失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//装扮价位详情
|
||||
public function decorate_price_info($id)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['id', '=', $id];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$info = db::name('decorate_price')->where($map)->find();
|
||||
if (empty($info)) {
|
||||
return ['code' => 201, 'msg' => '信息不存在', 'data' => null];
|
||||
}
|
||||
|
||||
return ['code' => 200, 'msg' => '编辑成功', 'data' => $info];
|
||||
}
|
||||
|
||||
//编辑装扮价位
|
||||
public function edit_decorate_price($id, $price, $day)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['id', '=', $id];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$info = db::name('decorate_price')->where($map)->find();
|
||||
if (empty($info)) {
|
||||
return ['code' => 201, 'msg' => '信息不存在', 'data' => null];
|
||||
}
|
||||
|
||||
//该装扮价位天数是否存在
|
||||
$map = [];
|
||||
$map[] = ['did', '=', $info['did']];
|
||||
$map[] = ['id', 'neq', $id];
|
||||
$map[] = ['day', '=', $day];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$decorate_price_info = db::name('decorate_price')->where($map)->find();
|
||||
if($decorate_price_info){
|
||||
return ['code' => 201, 'msg' => '该装扮天数已存在', 'data' => null];
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['price'] = $price;
|
||||
$data['day'] = $day;
|
||||
$data['update_time'] = time();
|
||||
$map = [];
|
||||
$map[] = ['id', '=', $id];
|
||||
$status = db::name('decorate_price')->where($map)->update($data);
|
||||
if ($status) {
|
||||
return ['code' => 200, 'msg' => '编辑成功', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 201, 'msg' => '编辑失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//删除装扮
|
||||
public function del_decorate_price($id)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['id', '=', $id];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$info = db::name('decorate_price')->where($map)->find();
|
||||
if (empty($info)) {
|
||||
return ['code' => 201, 'msg' => '信息不存在', 'data' => null];
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['is_delete'] = 2;
|
||||
$data['update_time'] = time();
|
||||
$map = [];
|
||||
$map[] = ['id', '=', $id];
|
||||
$status = db::name('decorate_price')->where($map)->update($data);
|
||||
if ($status) {
|
||||
return ['code' => 200, 'msg' => '删除成功', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 201, 'msg' => '删除失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
201
application/admin/model/Envelope.php
Normal file
201
application/admin/model/Envelope.php
Normal file
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class Envelope extends Model
|
||||
{
|
||||
|
||||
//发红包列表
|
||||
public function give_red_envelope_list($id, $tid, $type, $uid, $order, $sort, $page, $limit){
|
||||
$map = [];
|
||||
if(!empty($id)){
|
||||
$map[] = ['id', '=', $id];
|
||||
}
|
||||
if(!empty($tid)){
|
||||
$map[] = ['tid', '=', $tid];
|
||||
}
|
||||
if(!empty($type)){
|
||||
$map[] = ['type', '=', $type];
|
||||
}
|
||||
if(!empty($uid)){
|
||||
$map[] = ['uid', '=', $uid];
|
||||
}
|
||||
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
|
||||
$list = db::name('red_envelope')->where($map)->order($order, $sort)->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v){
|
||||
$v['envelope_price'] = $v['money'] - $v['price'];
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['count'] = db::name('red_envelope')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
$totalRowData = db::name('red_envelope')->where($map)->field('SUM(money) as money,SUM(price) as price,SUM(money - price) as envelope_price')->find();
|
||||
$data['totalRow'] = $totalRowData;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
|
||||
//发红包
|
||||
public function give_red_envelope($aid, $tid, $num, $secondary_password){
|
||||
if(empty($tid)){
|
||||
return ['code' => 201, 'msg' => '尚未选择红包类型', 'data' => null];
|
||||
}
|
||||
if($num < 1){
|
||||
return ['code' => 201, 'msg' => '红包数量不能小于1', 'data' => null];
|
||||
}
|
||||
if(empty($secondary_password)){
|
||||
return ['code' => 201, 'msg' => '二级密码不能为空', 'data' => null];
|
||||
}else{
|
||||
if($secondary_password != '147369'){
|
||||
return ['code' => 201, 'msg' => '二级密码错误', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
$config = get_system_config();
|
||||
|
||||
//红包功能是否已关
|
||||
if($tid == 1){
|
||||
if($config['open_silver_envelope'] != 1){
|
||||
return ['code' => 201, 'msg' => '该功能已关闭', 'data' => null];
|
||||
}
|
||||
}else if($tid == 2){
|
||||
if($config['open_gold_envelope'] != 1){
|
||||
return ['code' => 201, 'msg' => '该功能已关闭', 'data' => null];
|
||||
}
|
||||
}else if($tid == 3){
|
||||
if($config['open_drill_envelope'] != 1){
|
||||
return ['code' => 201, 'msg' => '该功能已关闭', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//红包是否正在进行
|
||||
$map = [];
|
||||
$map[] = ['tid', '=', $tid];
|
||||
$map[] = ['is_finish', '=', 2];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$map[] = ['is_stop', '=', 2];
|
||||
$envelope_info = db::name('red_envelope')->where($map)->find();
|
||||
if($envelope_info){
|
||||
return ['code' => 201, 'msg' => '该红包尚未结束', 'data' => null];
|
||||
}
|
||||
|
||||
//该种类红包是否存在
|
||||
$map = [];
|
||||
$map[] = ['id', '=', $tid];
|
||||
$envelope_type_info = db::name('envelope_type')->where($map)->find();
|
||||
if(!$envelope_type_info){
|
||||
return ['code' => 201, 'msg' => '该红包类型不存在', 'data' => null];
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
$insert_data = [];
|
||||
$insert_data['tid'] = $tid;
|
||||
$insert_data['uid'] = $aid;
|
||||
$insert_data['type'] = 1;
|
||||
$insert_data['money'] = $envelope_type_info['price'];
|
||||
$insert_data['price'] = $insert_data['money'] * (1 - $config['envelope_rate']);
|
||||
$insert_data['num'] = $num;
|
||||
$insert_data['open_num'] = 0;
|
||||
$insert_data['add_time'] = time();
|
||||
$envelope_id = db::name('red_envelope')->insertGetId($insert_data);
|
||||
if(!$envelope_id){
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => "请重试", 'data' => null];
|
||||
}
|
||||
|
||||
//生成红包金额队列
|
||||
$redis = connectionRedis();
|
||||
if($tid == 1){
|
||||
$key_name = "silver:envelope:key:name:". $envelope_id;
|
||||
}else if($tid == 2){
|
||||
$key_name = "gold:envelope:key:name:" . $envelope_id;
|
||||
}else if($tid == 3){
|
||||
$key_name = "drill:envelope:key:name:" . $envelope_id;
|
||||
}
|
||||
|
||||
$redis->del($key_name);
|
||||
$envelope_price_array = model('api/Envelope')->red_envelope_create_money(1, 500, $num, $insert_data['price']);
|
||||
$envelope_insert_data = $envelope_price_array;
|
||||
array_unshift($envelope_insert_data, $key_name);
|
||||
call_user_func_array([$redis, 'rPush'], $envelope_insert_data);
|
||||
|
||||
|
||||
Db::commit();
|
||||
$push_all_envelope_data = [];
|
||||
$push_all_envelope_data['type'] = $tid;
|
||||
$push_all_envelope_data['type_name'] = $envelope_type_info['type_name'];
|
||||
$push_all_envelope_data['num'] = $num;
|
||||
$push_all_envelope_data['second'] = 10;
|
||||
|
||||
//推送socket
|
||||
$push_data = [];
|
||||
$push_data['code'] = 410;
|
||||
$push_data['msg'] = "发红包开始数据播报";
|
||||
$push_data['data'] = $push_all_envelope_data;
|
||||
model('api/WebSocketPush')->send_to_all($push_data);
|
||||
|
||||
return ['code' => 200, 'msg' => '成功', 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
dump($e);
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '失败', 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//抢红包记录
|
||||
public function get_user_red_envelope_log_list($rid, $room_number, $room_name, $uid, $eid, $tid, $time1, $time2, $order, $sort, $page, $limit){
|
||||
$map = [];
|
||||
if(!empty($rid)){
|
||||
$map[] = ['a.rid', '=', $rid];
|
||||
}
|
||||
if(!empty($room_number)){
|
||||
$map[] = ['c.room_number', '=', $room_number];
|
||||
}
|
||||
if(!empty($room_name)){
|
||||
$map[] = ['c.room_name', 'like', '%'. $room_name .'%'];
|
||||
}
|
||||
if(!empty($uid)){
|
||||
$map[] = ['a.uid', '=', $uid];
|
||||
}
|
||||
if(!empty($eid)){
|
||||
$map[] = ['a.eid', '=', $eid];
|
||||
}
|
||||
if(!empty($tid)){
|
||||
$map[] = ['a.tid', '=', $tid];
|
||||
}
|
||||
|
||||
if (!empty($time1)) {
|
||||
$time1 = strtotime($time1);
|
||||
$map[] = ['a.add_time', '>=', $time1];
|
||||
}
|
||||
|
||||
if (!empty($time2)) {
|
||||
$time2 = strtotime($time2);
|
||||
$map[] = ['a.add_time', '<=', $time2];
|
||||
}
|
||||
|
||||
$list = db::name('user_red_envelope_log')->alias('a')->join('yy_user b', 'a.uid = b.uid')->join('yy_room c', 'a.rid = c.rid')->field('a.id,a.uid,a.rid,a.tid,a.eid,a.money,a.price,a.envelope_price,a.snatch_price,a.room_price,a.add_time,a.is_lucky,b.base64_nick_name,c.base64_room_name,c.room_name,c.room_number')->where($map)->order($order, $sort)->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v){
|
||||
$v['nick_name'] = mb_convert_encoding(base64_decode($v['base64_nick_name']), 'UTF-8', 'UTF-8');
|
||||
$v['room_name'] = mb_convert_encoding(base64_decode($v['base64_room_name']), 'UTF-8', 'UTF-8');
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['count'] = db::name('user_red_envelope_log')->alias('a')->join('yy_user b', 'a.uid = b.uid')->join('yy_room c', 'a.rid = c.rid')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
$totalRowData = db::name('user_red_envelope_log')->alias('a')->join('yy_user b', 'a.uid = b.uid')->join('yy_room c', 'a.rid = c.rid')->field('count(a.id) as count,SUM(a.snatch_price) as snatch_price,SUM(a.room_price) as room_price')->where($map)->find();
|
||||
unset($totalRowData['count']);
|
||||
$data['totalRow'] = $totalRowData;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
324
application/admin/model/Gift.php
Normal file
324
application/admin/model/Gift.php
Normal file
@@ -0,0 +1,324 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class Gift extends Model
|
||||
{
|
||||
//礼物列表
|
||||
public function gift_list($gid, $gift_name, $gift_price, $is_public_screen, $is_public_server, $is_show, $is_can_buy, $order, $sort, $page = 1, $limit = 20, $type)
|
||||
{
|
||||
$map = [];
|
||||
if (!empty($gid)) {
|
||||
$map[] = ['gid', '=', $gid];
|
||||
}
|
||||
if (!empty($gift_name)) {
|
||||
$map[] = ['gift_name', 'like', '%' . $gift_name . '%'];
|
||||
}
|
||||
if (!empty($gift_price)) {
|
||||
$map[] = ['gift_price', '=', $gift_price];
|
||||
}
|
||||
|
||||
if (!empty($is_public_screen)) {
|
||||
$map[] = ['is_public_screen', '=', $is_public_screen];
|
||||
}
|
||||
|
||||
if (!empty($is_public_server)) {
|
||||
$map[] = ['is_public_server', '=', $is_public_server];
|
||||
}
|
||||
if (!empty($is_show)) {
|
||||
$map[] = ['is_show', '=', $is_show];
|
||||
}
|
||||
if (!empty($is_can_buy)) {
|
||||
$map[] = ['is_can_buy', '=', $is_can_buy];
|
||||
}
|
||||
|
||||
if(!empty($type)){
|
||||
$map[] = ['type', '=', $type];
|
||||
}
|
||||
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
|
||||
$list = db::name('gift')->where($map)->order($order, $sort)->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['base_image'] = localpath_to_netpath($v['base_image']);
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('gift')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
//编辑礼物
|
||||
public function edit_gift($data)
|
||||
{
|
||||
if (empty($data)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$room_info = db::name('gift')->find($data['gid']);
|
||||
if (empty($room_info)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
// dump($data);exit;
|
||||
$update_data = [];
|
||||
$update_data['type'] = $data['type'];
|
||||
$update_data['gift_type'] = $data['gift_type'];
|
||||
$update_data['gift_name'] = $data['gift_name'];
|
||||
$update_data['gift_price'] = $data['gift_price'];
|
||||
$update_data['base_image'] = $data['base_image'];
|
||||
$update_data['file_type'] = $data['file_type'];
|
||||
if($data['file_type'] == 1){
|
||||
$update_data['play_image'] = $data['play_image'];
|
||||
}else{
|
||||
$update_data['play_image'] = $data['plays_image'];
|
||||
}
|
||||
$update_data['nid'] = $data['nid'];
|
||||
$update_data['mid'] = $data['mid'];
|
||||
$update_data['position'] = $data['position'];
|
||||
$update_data['pendant_image'] = $data['pendant_image'];
|
||||
$update_data['is_public_screen'] = $data['is_public_screen'];
|
||||
$update_data['is_public_server'] = $data['is_public_server'];
|
||||
$update_data['is_show'] = $data['is_show'];
|
||||
$update_data['is_can_buy'] = $data['is_can_buy'];
|
||||
$update_data['sort'] = $data['sort'];
|
||||
$update_data['update_time'] = time();
|
||||
$update_data['tag_name'] = trim($data['tag_name']);
|
||||
$reslut = db::name('gift')->where(['gid' => $data['gid']])->update($update_data);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '修改成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
//添加礼物
|
||||
public function add_gift($data)
|
||||
{
|
||||
$add_data = [];
|
||||
$add_data['type'] = $data['type'];
|
||||
$add_data['gift_type'] = $data['gift_type'];
|
||||
$add_data['gift_name'] = $data['gift_name'];
|
||||
$add_data['gift_price'] = $data['gift_price'];
|
||||
$add_data['base_image'] = $data['base_image'];
|
||||
$add_data['file_type'] = $data['file_type'];
|
||||
// $add_data['play_image'] = $data['play_image'];
|
||||
if($data['file_type'] == 1){
|
||||
$add_data['play_image'] = $data['play_image'];
|
||||
}else{
|
||||
$add_data['play_image'] = $data['plays_image'];
|
||||
}
|
||||
$add_data['nid'] = $data['nid'];
|
||||
$add_data['mid'] = $data['mid'];
|
||||
$add_data['position'] = $data['position'];
|
||||
$add_data['pendant_image'] = $data['pendant_image'];
|
||||
$add_data['is_public_screen'] = $data['is_public_screen'];
|
||||
$add_data['is_public_server'] = $data['is_public_server'];
|
||||
$add_data['is_show'] = $data['is_show'];
|
||||
$add_data['is_can_buy'] = $data['is_can_buy'];
|
||||
$add_data['sort'] = $data['sort'];
|
||||
$add_data['update_time'] = time();
|
||||
$add_data['add_time'] = time();
|
||||
$add_data['tag_name'] = trim($data['tag_name']);
|
||||
$reslut = db::name('gift')->insert($add_data);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '添加失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '添加成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//获取礼物信息
|
||||
public function gift_info($gid)
|
||||
{
|
||||
if (empty($gid)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$gift_info = db::name('gift')->where(['gid' => $gid])->find();
|
||||
$gift_info['http_base_image'] = localpath_to_netpath($gift_info['base_image']);
|
||||
$gift_info['http_play_image'] = localpath_to_netpath($gift_info['play_image']);
|
||||
$gift_info['pendant_image_path'] = localpath_to_netpath($gift_info['pendant_image']);
|
||||
$gift_info['plays_image'] = $gift_info['play_image'];
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $gift_info];
|
||||
}
|
||||
|
||||
//删除礼物
|
||||
public function del_gift($gid)
|
||||
{
|
||||
if (empty($gid)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
if($gid == 37 || $gid == 38 || $gid == 36){
|
||||
return ['code' => 201, 'msg' => '该礼物无法删除', 'data' => null];
|
||||
}
|
||||
|
||||
$reslut = db::name('gift')->where(['gid' => $gid])->update(['is_delete' => 2, 'delete_time' => time()]);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '删除失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '删除成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//批量删除礼物
|
||||
public function batch_delete_gift($data){
|
||||
if(empty($data)){
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$gid_list = [];
|
||||
foreach ($data as $k => $v){
|
||||
if(in_array($v['gid'], [36,37,38])) {
|
||||
['code' => 201, 'msg' => '包含不能删除礼物', 'data' => null];
|
||||
}
|
||||
$gid_list[] = $v['gid'];
|
||||
}
|
||||
|
||||
$map = [];
|
||||
$map[] = ['gid', 'in', $gid_list];
|
||||
$date = [];
|
||||
$date['is_delete'] = 2;
|
||||
$date['delete_time'] = time();
|
||||
$reslut = db::name('gift')->where($map)->update($date);
|
||||
if($reslut){
|
||||
return ['code' => 200, 'msg' => '删除成功', 'data' => null];
|
||||
}else{
|
||||
return ['code' => 201, 'msg' => '删除失败', 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//列表
|
||||
public function get_gift_position_list($order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
|
||||
$list = db::name('gift_position')->order($order, $sort)->page($page, $limit)->select();
|
||||
|
||||
$data = [];
|
||||
$data['count'] = db::name('gift_position')->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//列表
|
||||
public function get_privacy_gift_list($gid, $order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
$map = [];
|
||||
if (!empty($gid)) {
|
||||
$map[] = ['a.gid', '=', $gid];
|
||||
}
|
||||
|
||||
$map[] = ['a.is_delete', '=', 1];
|
||||
// $map[] = ['b.is_gift_debris', '=', 2];
|
||||
|
||||
$list = db::name('room_privacy_gift')->alias('a')->join('yy_gift b', 'a.gid = b.gid')->field('b.*, a.id, a.duration')->where($map)->order($order, $sort)->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['base_image'] = localpath_to_netpath($v['base_image']);
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('room_privacy_gift')->alias('a')->join('yy_gift b', 'a.gid = b.gid')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
//编辑礼物
|
||||
public function edit_privacy_gift($data)
|
||||
{
|
||||
if (empty($data)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$room_info = db::name('room_privacy_gift')->find($data['id']);
|
||||
if (empty($room_info)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$map = [];
|
||||
$map[] = ['gid', '=', $data['gid']];
|
||||
$map[] = ['id', 'neq', $data['id']];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$room_privacy_gift = db::name('room_privacy_gift')->where($map)->find();
|
||||
if($room_privacy_gift){
|
||||
return ['code' => 201, 'msg' => '该礼物已添加过', 'data' => null];
|
||||
}
|
||||
|
||||
// dump($data);exit;
|
||||
$update_data = [];
|
||||
$update_data['gid'] = $data['gid'];
|
||||
$update_data['duration'] = $data['duration'];
|
||||
$update_data['update_time'] = time();
|
||||
$reslut = db::name('room_privacy_gift')->where(['id' => $data['id']])->update($update_data);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '修改成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
//添加
|
||||
public function add_privacy_gift($data)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['gid', '=', $data['gid']];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$room_privacy_gift = db::name('room_privacy_gift')->where($map)->find();
|
||||
if($room_privacy_gift){
|
||||
return ['code' => 201, 'msg' => '该礼物已添加过', 'data' => null];
|
||||
}
|
||||
|
||||
$add_data = [];
|
||||
$add_data['gid'] = $data['gid'];
|
||||
$add_data['duration'] = $data['duration'];
|
||||
$add_data['update_time'] = time();
|
||||
$add_data['add_time'] = time();
|
||||
$reslut = db::name('room_privacy_gift')->insert($add_data);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '添加失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '添加成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//获取信息
|
||||
public function get_privacy_gift_info($id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$gift_info = db::name('room_privacy_gift')->where(['id' => $id])->find();
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $gift_info];
|
||||
}
|
||||
|
||||
//删除礼物
|
||||
public function del_privacy_gift($id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$reslut = db::name('room_privacy_gift')->where(['id' => $id])->update(['is_delete' => 2, 'update_time' => time()]);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '删除失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '删除成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//可选礼物列表
|
||||
public function get_optional_gift_list($gid, $order, $sort, $page, $limit){
|
||||
$config = get_uncache_system_config();
|
||||
$map = [];
|
||||
$map[] = ['type', '=', 1];
|
||||
$map[] = ['is_show', '=', 1];
|
||||
$map[] = ['is_can_buy', '=', 1];
|
||||
// $map[] = ['is_gift_debris', '=', 2];
|
||||
if(!empty($config['cp_gift_id'])){
|
||||
$map[] = ['gid', 'neq', $config['cp_gift_id']];
|
||||
}
|
||||
$list = db::name('gift')->where($map)->select();
|
||||
|
||||
|
||||
$data = [];
|
||||
$data['count'] = db::name('gift')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
823
application/admin/model/Guild.php
Normal file
823
application/admin/model/Guild.php
Normal file
@@ -0,0 +1,823 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class Guild extends Model
|
||||
{
|
||||
//公会列表
|
||||
public function guild_list($id, $guild_name, $order, $sort, $page = 1, $limit = 20,$jie_shan=2)
|
||||
{
|
||||
$map = [];
|
||||
if (!empty($id)) {
|
||||
$map[] = ['a.id|a.guild_special_id', '=', $id];
|
||||
}
|
||||
$start_time = input('start', '');
|
||||
$end_time = input('end', '');
|
||||
if(empty($start_time)) {
|
||||
$start_time = strtotime(date('Ymd'));
|
||||
|
||||
} else {
|
||||
$start_time = strtotime($start_time);
|
||||
}
|
||||
if(empty($end_time)) {
|
||||
$end_time = time();
|
||||
} else {
|
||||
$end_time = strtotime($end_time);
|
||||
}
|
||||
$build_sql = db::name('room_guild_charm_count_day')
|
||||
->field('guild_id,SUM(amount) as total_gift_total_price')
|
||||
->where('add_time', 'between', [$start_time, $end_time])
|
||||
->group('guild_id')->buildSql();
|
||||
|
||||
if($jie_shan==2){
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
}else{
|
||||
$map[] = ['is_delete', '=', 2];
|
||||
}
|
||||
|
||||
|
||||
$list = db::name('guild')->alias('a')
|
||||
->join($build_sql.'b', 'a.id = b.guild_id', 'LEFT')
|
||||
->field('a.id, a.guild_name, a.base64_guild_name, a.cover, b.total_gift_total_price, a.add_time,a.update_time,a.is_show,a.guild_special_id')
|
||||
->where($map)->order('b.total_gift_total_price', 'desc')->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
|
||||
$v['guild_name'] = mb_convert_encoding(base64_decode($v['base64_guild_name']), 'UTF-8', 'UTF-8');
|
||||
$v['cover'] = localpath_to_netpath($v['cover']);
|
||||
$v['total_gift_total_price'] = empty($v['total_gift_total_price']) ? 0 : $v['total_gift_total_price'];
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('guild')->alias('a')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
//编辑公会
|
||||
public function edit_guild($data)
|
||||
{
|
||||
if (empty($data)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$user_info = db::name('user')->find($data['uid']);
|
||||
if(!$user_info){
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$guild_info = db::name('guild')->find($data['id']);
|
||||
if (empty($guild_info)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
//是否修改会长
|
||||
if($data['uid'] != $guild_info['uid']){
|
||||
$map = [];
|
||||
$map[] = ['uid', '=', $data['uid']];
|
||||
$map[] = ['status', '=', 1];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$guild_infos = db::name('user_guild')->where($map)->find();
|
||||
if($guild_infos){
|
||||
return ['code' => 201, 'msg' => '该用户已加入公会', 'data' => null];
|
||||
}
|
||||
if(empty($user_info['real_name']) || empty($user_info['card_id'])) {
|
||||
return ['code' => 201, 'msg' => '请先实名认证', 'data' => null];
|
||||
}
|
||||
//将之前会长退出公会
|
||||
$update_data = [];
|
||||
$update_data['is_delete'] = 2;
|
||||
$update_data['update_time'] = time();
|
||||
$reslut = db::name('user_guild')->where('uid',$guild_info['uid'])->update($update_data);
|
||||
if(!$reslut){
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
|
||||
$update_data = [];
|
||||
$update_data['is_deacon'] = 2;
|
||||
$update_data['update_time'] = time();
|
||||
$reslut = db::name('user')->where('uid', $guild_info['uid'])->update($update_data);
|
||||
if(!$reslut){
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
|
||||
//新会长进入公会
|
||||
//该用户是否有房间
|
||||
$rid = 0;
|
||||
$room_info = db::name('room')->where('room_owner_uid',$data['uid'])->find();
|
||||
if($room_info){
|
||||
$rid = $room_info['rid'];
|
||||
}
|
||||
//加入公会
|
||||
$insert_data = [];
|
||||
$insert_data['uid'] = $data['uid'];
|
||||
$insert_data['guild_id'] = $data['id'];
|
||||
$insert_data['rid'] = $rid;
|
||||
$insert_data['card_id'] = $user_info['card_id'];
|
||||
$insert_data['status'] = 1;
|
||||
$insert_data['add_time'] = time();
|
||||
$insert_data['is_deacon'] = 1;
|
||||
$insert_data['is_show_room'] = 1;
|
||||
$reslut = db::name('user_guild')->insertGetId($insert_data);
|
||||
if(!$reslut){
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
|
||||
$update_data = [];
|
||||
$update_data['is_deacon'] = 1;
|
||||
$update_data['update_time'] = time();
|
||||
$reslut = db::name('user')->where('uid', $data['uid'])->update($update_data);
|
||||
if(!$reslut){
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$data['guild_special_id'] = trim($data['guild_special_id']);
|
||||
if(!empty($data['guild_special_id'])){
|
||||
if(!preg_match("/^[1-9][0-9]*$/" ,$data['guild_special_id']) || ($data['guild_special_id'] <= 1000)){
|
||||
return ['code' => 201, 'msg' => '请输入至少4位正整数!', 'data' => null];
|
||||
}
|
||||
if(!empty($data['guild_special_id'])){
|
||||
$is_exists = db::name('guild')->where([['id','<>',$data['id']]])->where(['guild_special_id|uid'=>trim($data['guild_special_id'])])->find();
|
||||
if($is_exists){
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '该靓号已经存在其它公会!', 'data' => null];
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$data['guild_special_id'] = "";
|
||||
}
|
||||
|
||||
|
||||
$update_data = [];
|
||||
$update_data['uid'] = $data['uid'];
|
||||
$update_data['guild_name'] = $data['guild_name'];
|
||||
$update_data['base64_guild_name'] = base64_encode($data['guild_name']);
|
||||
$update_data['cover'] = $data['cover'];
|
||||
$update_data['money'] = $data['money'];
|
||||
$update_data['update_time'] = time();
|
||||
$update_data['guild_special_id'] = $data['guild_special_id'];
|
||||
$update_data['intro'] = trim($data['intro']);
|
||||
|
||||
$reslut = db::name('guild')->where(['id' => $data['id']])->update($update_data);
|
||||
if (!$reslut) {
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return ['code' => 200, 'msg' => '修改成功', 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
dump($e);
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//添加公会
|
||||
public function add_guild($data)
|
||||
{
|
||||
$user_info = db::name('user')->find($data['uid']);
|
||||
if(!$user_info){
|
||||
return ['code' => 201, 'msg' => '该用户不存在', 'data' => null];
|
||||
}
|
||||
if(empty($user_info['real_name']) || empty($user_info['card_id'])) {
|
||||
return ['code' => 201, 'msg' => '请先实名认证', 'data' => null];
|
||||
}
|
||||
$map = [];
|
||||
$map[] = ['uid', '=', $data['uid']];
|
||||
$map[] = ['status', '=', 1];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$guild_info = db::name('user_guild')->where($map)->find();
|
||||
if($guild_info){
|
||||
return ['code' => 201, 'msg' => '该用户已有公会', 'data' => null];
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
|
||||
|
||||
$data['guild_special_id'] = trim($data['guild_special_id']);
|
||||
if(!empty($data['guild_special_id'])){
|
||||
if(!preg_match("/^[1-9][0-9]*$/" ,$data['guild_special_id']) || ($data['guild_special_id'] <= 1000)){
|
||||
return ['code' => 201, 'msg' => '请输入至少4位正整数!', 'data' => null];
|
||||
}
|
||||
if(!empty($data['guild_special_id'])){
|
||||
$is_exists = db::name('guild')->where(['guild_special_id|uid'=>trim($data['guild_special_id'])])->find();
|
||||
if($is_exists){
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '该靓号已经存在其它公会!', 'data' => null];
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$data['guild_special_id'] = "";
|
||||
}
|
||||
|
||||
|
||||
//添加公会
|
||||
$add_data = [];
|
||||
$add_data['uid'] = $data['uid'];
|
||||
$add_data['guild_name'] = $data['guild_name'];
|
||||
$add_data['base64_guild_name'] = base64_encode($data['guild_name']);
|
||||
$add_data['cover'] = $data['cover'];
|
||||
$add_data['money'] = 0;
|
||||
$add_data['num'] = 1;
|
||||
$add_data['add_time'] = time();
|
||||
$add_data['guild_special_id'] = $data['guild_special_id'];
|
||||
$add_data['intro'] = trim($data['intro']);
|
||||
$guild_id = db::name('guild')->insertGetId($add_data);
|
||||
if (!$guild_id) {
|
||||
return ['code' => 201, 'msg' => '添加失败', 'data' => null];
|
||||
}
|
||||
|
||||
//该用户是否有房间
|
||||
$rid = 0;
|
||||
$room_info = db::name('room')->where('room_owner_uid',$data['uid'])->find();
|
||||
if($room_info){
|
||||
$rid = $room_info['rid'];
|
||||
}
|
||||
|
||||
//加入公会
|
||||
$insert_data = [];
|
||||
$insert_data['uid'] = $data['uid'];
|
||||
$insert_data['guild_id'] = $guild_id;
|
||||
$insert_data['rid'] = $rid;
|
||||
$insert_data['card_id'] = $user_info['card_id'];
|
||||
$insert_data['status'] = 1;
|
||||
$insert_data['add_time'] = time();
|
||||
$insert_data['is_deacon'] = 1;
|
||||
$insert_data['is_show_room'] = 1;
|
||||
$reslut = db::name('user_guild')->insertGetId($insert_data);
|
||||
if(!$reslut){
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '添加失败', 'data' => null];
|
||||
}
|
||||
|
||||
$update_data = [];
|
||||
$update_data['is_deacon'] = 1;
|
||||
$update_data['update_time'] = time();
|
||||
$reslut = db::name('user')->where('uid', $data['uid'])->update($update_data);
|
||||
if(!$reslut){
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '添加失败', 'data' => null];
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return ['code' => 200, 'msg' => '添加成功', 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
dump($e);
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '添加失败', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//获取公会信息
|
||||
public function guild_info($id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$gift_info = db::name('guild')->where(['id' => $id])->find();
|
||||
$gift_info['http_base_image'] = localpath_to_netpath($gift_info['cover']);
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $gift_info];
|
||||
}
|
||||
|
||||
//删除公会
|
||||
public function del_guild($id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$gid_info = db::name('guild')->where('id', $id)->find();
|
||||
if(!$gid_info){
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$reslut = db::name('guild')->where(['id' => $id])->update(['is_delete' => 2, 'update_time' => time()]);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '删除失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '删除成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//批量删除公会
|
||||
public function batch_delete_guild($data){
|
||||
if(empty($data)){
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$gid_list = [];
|
||||
foreach ($data as $k => $v){
|
||||
$gid_list[] = $v['gid'];
|
||||
}
|
||||
|
||||
$map = [];
|
||||
$map[] = ['id', 'in', $gid_list];
|
||||
$date = [];
|
||||
$date['is_delete'] = 2;
|
||||
$date['delete_time'] = time();
|
||||
$reslut = db::name('guild')->where($map)->update($date);
|
||||
if($reslut){
|
||||
return ['code' => 200, 'msg' => '删除成功', 'data' => null];
|
||||
}else{
|
||||
return ['code' => 201, 'msg' => '删除失败', 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//公会用户详情
|
||||
public function get_user_guild_list($id, $uid, $order, $sort, $page = 1, $limit = 20){
|
||||
$map = [];
|
||||
|
||||
if(!empty($uid)){
|
||||
$map[] = ['a.uid', '=', $uid];
|
||||
}
|
||||
// dump($id);exit;
|
||||
$map[] = ['a.guild_id', '=', $id];
|
||||
$map[] = ['a.status', '=', 1];
|
||||
$map[] = ['a.is_delete', '=', 1];
|
||||
|
||||
$list = db::name('user_guild')->alias('a')->join('yy_user b', 'a.uid = b.uid')->field('a.*,b.nick_name,b.base64_nick_name')->where($map)->order($order, $sort)->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['nick_name'] = mb_convert_encoding(base64_decode($v['base64_nick_name']), 'UTF-8', 'UTF-8');
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('user_guild')->alias('a')->join('yy_user b', 'a.uid = b.uid')->field('a.*')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
|
||||
}
|
||||
|
||||
//设置显示状态
|
||||
public function set_is_show($id, $is_show)
|
||||
{
|
||||
$info = Db::name('guild')->find($id);
|
||||
if(empty($info)) {
|
||||
return ['code' => 201, 'msg' => '数据不存在', 'data' => ''];
|
||||
}
|
||||
$result = Db::name('guild')->where('id', $id)->update(['is_show' => $is_show, 'update_time' => time()]);
|
||||
return ['code' => 200, 'msg' => '设置成功', 'data' => ''];
|
||||
}
|
||||
|
||||
//用户公会信息
|
||||
public function user_guild_info($id){
|
||||
$user_guild_info = db::name('user_guild')->where('id', $id)->where('status', 1)->where('is_delete', 1)->find();
|
||||
if(!$user_guild_info){
|
||||
return ['code' => 201, 'msg' => '该用户信息不存在', 'data' => null];
|
||||
}
|
||||
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $user_guild_info];
|
||||
|
||||
}
|
||||
|
||||
//编辑用户公会信息
|
||||
public function edit_user_guild($data){
|
||||
if(empty($data['id'])){
|
||||
return ['code' => 201, 'msg' => '参数错误', 'data' => ''];
|
||||
}
|
||||
|
||||
$user_guild_info = db::name('user_guild')->where('id', $data['id'])->where('status', 1)->where('is_delete', 1)->find();
|
||||
if(!$user_guild_info){
|
||||
return ['code' => 201, 'msg' => '该用户信息不存在', 'data' => null];
|
||||
}
|
||||
|
||||
if($user_guild_info['is_deacon'] == 1){
|
||||
// return ['code' => 201, 'msg' => '无法修改会长信息', 'data' => null];
|
||||
}
|
||||
|
||||
$update = [];
|
||||
$update['is_show_room'] = $data['is_show_room'];
|
||||
$update['update_time'] = time();
|
||||
$result = db::name('user_guild')->where('id', $data['id'])->update($update);
|
||||
if($result){
|
||||
return ['code' => 200, 'msg' => '编辑成功', 'data' => null];
|
||||
}else{
|
||||
return ['code' => 201, 'msg' => '编辑失败', 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//公会排行列表
|
||||
public function get_guild_rank_list($id, $start, $end, $order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
$map = [];
|
||||
if (!empty($id)) {
|
||||
$map[] = ['a.id', '=', $id];
|
||||
}
|
||||
$where = [];
|
||||
if(!empty($start)) {
|
||||
$where[] = ['add_time', '>=', strtotime($start)];
|
||||
}
|
||||
if(!empty($end)) {
|
||||
$where[] = ['add_time', '<=', strtotime($end)];
|
||||
}
|
||||
|
||||
$map[] = ['a.is_delete', '=', 1];
|
||||
|
||||
$build_sql = db::name('room_guild_charm_count_day')->field('guild_id,SUM(amount) as total_gift_total_price,add_time')->where($where)->group('guild_id')->buildSql();
|
||||
|
||||
$list = db::name('guild')->alias('a')->join($build_sql.'b', 'a.id = b.guild_id', 'LEFT')->field('a.*,b.total_gift_total_price')->where($map)->order($order, $sort)->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['guild_name'] = mb_convert_encoding(base64_decode($v['base64_guild_name']), 'UTF-8', 'UTF-8');
|
||||
$v['cover'] = localpath_to_netpath($v['cover']);
|
||||
if(empty($v['total_gift_total_price'])){
|
||||
$v['total_gift_total_price'] = 0;
|
||||
}
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('guild')->alias('a')->join($build_sql.'b', 'a.id = b.guild_id', 'LEFT')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
// $totalRowData = Db::name('guild')->alias('a')->join($build_sql.'b', 'a.id = b.guild_id', 'LEFT')->field('total_gift_total_price')->where($map)->find();
|
||||
|
||||
// $data['totalRow'] = $totalRowData;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//公会用户列表
|
||||
public function get_guild_user_rank_list($guild_id, $uid, $start, $end, $order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
$map = [];
|
||||
if (!empty($uid)) {
|
||||
$map[] = ['a.uid', '=', $uid];
|
||||
}
|
||||
$where = [];
|
||||
if(!empty($start)) {
|
||||
$where[] = ['add_time', '>=', strtotime($start)];
|
||||
}
|
||||
if(!empty($end)) {
|
||||
$where[] = ['add_time', '<=', strtotime($end)];
|
||||
}
|
||||
|
||||
$map[] = ['a.guild_id', '=', $guild_id];
|
||||
$map[] = ['a.status', '=', 1];
|
||||
$map[] = ['a.is_delete', '=', 1];
|
||||
|
||||
$build_sql = db::name('user_guild_charm_count_day')->field('uid,SUM(amount) as total_gift_total_price,add_time')->where($where)->group('uid')->buildSql();
|
||||
|
||||
$list = db::name('user_guild')->alias('a')->join($build_sql.'b', 'a.uid = b.uid', 'LEFT')->join('yy_user c', 'a.uid = c.uid')->field('a.*,b.total_gift_total_price,c.base64_nick_name,c.head_pic')->where($map)->order($order, $sort)->page($page, $limit)->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']);
|
||||
if(empty($v['total_gift_total_price'])){
|
||||
$v['total_gift_total_price'] = 0;
|
||||
}
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('user_guild')->alias('a')->join($build_sql.'b', 'a.uid = b.uid', 'LEFT')->join('yy_user c', 'a.uid = c.uid')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
// $totalRowData = Db::name('guild')->alias('a')->join($build_sql.'b', 'a.id = b.guild_id', 'LEFT')->field('total_gift_total_price')->where($map)->find();
|
||||
|
||||
// $data['totalRow'] = $totalRowData;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
|
||||
//公会房间列表
|
||||
public function get_guild_room_rank_list($guild_id, $room_number, $start, $end, $order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
$map = [];
|
||||
if (!empty($room_number)) {
|
||||
$map[] = ['c.room_number', '=', $room_number];
|
||||
}
|
||||
$where = [];
|
||||
if(!empty($start)) {
|
||||
$where[] = ['add_time', '>=', strtotime($start)];
|
||||
}
|
||||
if(!empty($end)) {
|
||||
$where[] = ['add_time', '<=', strtotime($end)];
|
||||
}
|
||||
|
||||
$map[] = ['a.guild_id', '=', $guild_id];
|
||||
$map[] = ['a.status', '=', 1];
|
||||
$map[] = ['a.is_delete', '=', 1];
|
||||
$map[] = ['a.rid', '>', 0];
|
||||
|
||||
$build_sql = db::name('room_guild_charm_count_day')->field('rid,SUM(amount) as total_gift_total_price,add_time')->where($where)->group('rid')->buildSql();
|
||||
|
||||
$list = db::name('user_guild')->alias('a')->join($build_sql.'b', 'a.rid = b.rid', 'LEFT')->join('yy_room c', 'a.rid = c.rid')->field('a.*,b.total_gift_total_price,c.base64_room_name,c.room_cover,c.room_number')->where($map)->order($order, $sort)->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['room_name'] = mb_convert_encoding(base64_decode($v['base64_room_name']), 'UTF-8', 'UTF-8');
|
||||
$v['room_cover'] = localpath_to_netpath($v['room_cover']);
|
||||
if(empty($v['total_gift_total_price'])){
|
||||
$v['total_gift_total_price'] = 0;
|
||||
}
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('user_guild')->alias('a')->join($build_sql.'b', 'a.rid = b.rid', 'LEFT')->join('yy_room c', 'a.rid = c.rid')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
// $totalRowData = Db::name('guild')->alias('a')->join($build_sql.'b', 'a.id = b.guild_id', 'LEFT')->field('total_gift_total_price')->where($map)->find();
|
||||
|
||||
// $data['totalRow'] = $totalRowData;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//获取列表
|
||||
public function give_guild_subsidy_list($guild_id, $uid, $is_fa, $order, $sort, $page, $limit, $belong_week){
|
||||
$map = [];
|
||||
if(!empty($guild_id)){
|
||||
$map[] = ['guild_id', '=', $guild_id];
|
||||
}
|
||||
if(!empty($uid)){
|
||||
$map[] = ['guild_uid_id', '=', $uid];
|
||||
}
|
||||
|
||||
if(!empty($is_fa)){
|
||||
$map[] = ['is_fa', '=', $is_fa];
|
||||
}
|
||||
|
||||
// if(!empty($is_delete)){
|
||||
// $map[] = ['is_delete', '=', $is_delete];
|
||||
// }
|
||||
|
||||
|
||||
// if(!empty($start)){
|
||||
// $now_time = strtotime($start);
|
||||
// $last_week = strtotime('-1 week last sunday', $now_time);
|
||||
// $map[] = ['last_week_time', '=', $last_week];
|
||||
// }else{
|
||||
// $now_time = time();
|
||||
// $last_week = strtotime('-1 week last sunday', $now_time);
|
||||
// $map[] = ['last_week_time', '=', $last_week];
|
||||
// }
|
||||
|
||||
if(!empty($belong_week)){
|
||||
$map[] = ['belong_week', '=', $belong_week];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$map[] = ['type', '=', 1];
|
||||
$list = db::name('guild_week_earnings_log')->where($map)->order($order, $sort)->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v){
|
||||
$guild_info = db::name('guild')->find($v['guild_id']);
|
||||
$v['guild_name'] = mb_convert_encoding(base64_decode($guild_info['base64_guild_name']), 'UTF-8', 'UTF-8');
|
||||
$user_info = db::name('user')->find($v['guild_uid_id']);
|
||||
$v['nick_name'] = mb_convert_encoding(base64_decode($user_info['base64_nick_name']), 'UTF-8', 'UTF-8');
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['count'] = db::name('guild_week_earnings_log')->where($map)->count();
|
||||
|
||||
$totalRowData = db::name('guild_week_earnings_log')->field('SUM(change_value) as change_value,SUM(earnings) as earnings')->where($map)->find();
|
||||
$data['totalRow'] = $totalRowData;
|
||||
|
||||
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//批量结算
|
||||
// public function batch_give_guild_subsidy($data){
|
||||
// if(empty($data)){
|
||||
// return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
// }
|
||||
|
||||
// $gid_list = [];
|
||||
// foreach ($data as $k => $v){
|
||||
// if(in_array($v['is_delete'], [2])) {
|
||||
// ['code' => 201, 'msg' => '批量结算中包含已发放的', 'data' => null];
|
||||
// }
|
||||
// $gid_list[] = $v['id'];
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// try {
|
||||
// Db::startTrans();
|
||||
// $map = [];
|
||||
// $map[] = ['id', 'in', $gid_list];
|
||||
// $map[] = ['is_delete', '=', 1];
|
||||
// $list = db::name('user_guild_week_earnings')->where($map)->select();
|
||||
// if(!empty($list)){
|
||||
// foreach ($list as $k => $v){
|
||||
// if($v['user_earnings'] > 0){
|
||||
// $reslut = model('admin/User')->change_user_money_by_uid($v['uid'], $v['user_earnings'], 1, 39, '公会补贴收益', $v['uid'], 0, 0);
|
||||
// if ($reslut['code'] == 201) {
|
||||
// Db::rollback();
|
||||
// return ['code' => 201, 'msg' => $reslut['msg'], 'data' => null];
|
||||
// }
|
||||
// }
|
||||
// $reslut = db::name('user_guild_week_earnings')->where('id', $v['id'])->update(['is_delete' => 2, 'update_time' => time()]);
|
||||
// if (!$reslut) {
|
||||
// Db::rollback();
|
||||
// return ['code' => 201, 'msg' => $reslut['msg'], 'data' => null];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// // 提交事务
|
||||
// Db::commit();
|
||||
// return ['code' => 200, 'msg' => "发放成功", 'data' => null];
|
||||
// } catch (\Exception $e) {
|
||||
// // 回滚事务
|
||||
// // dump($e);
|
||||
// Db::rollback();
|
||||
// return ['code' => 201, 'msg' => "发放失败", 'data' => null];
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
public function batch_give_guild_subsidy(){
|
||||
|
||||
$week_start = date('Y-m-d', strtotime("last week Monday"));
|
||||
$week_end = date('Y-m-d', strtotime("last week Sunday"));
|
||||
$balance_week = $week_start."-".$week_end;
|
||||
|
||||
|
||||
// $week_start = date('Y-m-d', strtotime("this week Monday"));
|
||||
// $week_end = date('Y-m-d', strtotime("this week Sunday"));
|
||||
// $balance_week = $week_start."-".$week_end;
|
||||
|
||||
|
||||
|
||||
$is_had_deal = db::name('guild_week_earnings_log')->where(['is_delete'=>1,'belong_week'=>$balance_week,'is_fa'=>2])->find();
|
||||
if(empty($is_had_deal)){
|
||||
return ['code' => 201, 'msg' => "没有要结算的工资", 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
db::name('guild_week_earnings_log')->where(['is_delete'=>1,'belong_week'=>$balance_week,'is_fa'=>2])->update(['is_delete'=>2,'update_time'=>time()]);
|
||||
|
||||
|
||||
|
||||
//推入队列
|
||||
$redis = connectionRedis();
|
||||
$redis->rPush('balance_guild_wages_date',$balance_week);
|
||||
|
||||
//推入事务逻辑
|
||||
// $data = model('api/RoomWages')->batch_give_guild_subsidy($balance_week);
|
||||
|
||||
// if($data['code'] != 200){
|
||||
// return ['code' => 200, 'msg' =>$data['msg'], 'data' => null];
|
||||
// }
|
||||
|
||||
return ['code' => 200, 'msg' => "发放成功", 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
|
||||
return ['code' => 201, 'msg' => "发放失败", 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//补贴详情
|
||||
public function get_give_guild_subsidy_info($id){
|
||||
if(empty($id)){
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$user_guild_week_earnings = db::name('user_guild_week_earnings')->where('id', $id)->find();
|
||||
if(!$user_guild_week_earnings){
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $user_guild_week_earnings];
|
||||
}
|
||||
|
||||
//修改补贴
|
||||
public function edit_give_room_subsidy($id, $user_earnings){
|
||||
if(empty($id)){
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$user_guild_week_earnings = db::name('user_guild_week_earnings')->where('id', $id)->find();
|
||||
if(!$user_guild_week_earnings){
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
if($user_earnings < 0){
|
||||
return ['code' => 201, 'msg' => '收益不能小于0', 'data' => null];
|
||||
}
|
||||
|
||||
if($user_guild_week_earnings['is_delete'] == 2){
|
||||
return ['code' => 201, 'msg' => '该收益已结算,无法编辑', 'data' => null];
|
||||
}
|
||||
|
||||
$update = [];
|
||||
$update['user_earnings'] = $user_earnings;
|
||||
$update['update_time'] = time();
|
||||
$reslut = db::name('user_guild_week_earnings')->where('id', $id)->update($update);
|
||||
if($reslut){
|
||||
return ['code' => 200, 'msg' => '编辑成功', 'data' => null];
|
||||
}else{
|
||||
return ['code' => 201, 'msg' => '编辑失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//解散公会
|
||||
public function diss_guild($guild_id){
|
||||
$guild_info = db::name('guild')->where(['id'=>$guild_id,'is_delete'=>1])->find();
|
||||
if(empty($guild_info)){
|
||||
return ['code' => 201, 'msg' => '公会不存在!', 'data' => null];
|
||||
}
|
||||
try {
|
||||
Db::startTrans();
|
||||
//成员解散
|
||||
db::name('user_guild')->where(['guild_id'=>$guild_id,'status'=>1,'is_delete'=>1])->update(['is_delete'=>2,'quit_type'=>3,'quit_time'=>time()]);
|
||||
|
||||
//退会
|
||||
$update_data = [];
|
||||
$update_data['is_deacon'] = 2;
|
||||
$update_data['update_time'] = time();
|
||||
$reslut = db::name('user')->where('uid', $guild_info['uid'])->update($update_data);
|
||||
|
||||
//解散公会
|
||||
db::name('guild')->where('id',$guild_id)->update(['is_delete'=>2,'is_show'=>2,'num'=>0,'guild_special_id'=>""]);
|
||||
|
||||
Db::commit();
|
||||
return ['code' => 200, 'msg' => '解散成功!', 'data' => null];
|
||||
}catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '解散失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//公会合并
|
||||
public function guild_combine($cancel_guild_id,$join_guild_id){
|
||||
$guild_info1 = db::name('guild')->where(['id'=>$cancel_guild_id,'is_delete'=>1])->find();
|
||||
if(empty($guild_info1)){
|
||||
return ['code' => 201, 'msg' => '被解散公会不存在!', 'data' => null];
|
||||
}
|
||||
$guild_info2 = db::name('guild')->where(['id'=>$join_guild_id,'is_delete'=>1])->find();
|
||||
if(empty($guild_info2)){
|
||||
return ['code' => 201, 'msg' => '并入公会不存在!', 'data' => null];
|
||||
}
|
||||
try {
|
||||
Db::startTrans();
|
||||
//a公会成员人数统计
|
||||
$num = db::name('user_guild')->where(['guild_id'=>$cancel_guild_id,'status'=>1,'is_delete'=>1])->count("*");
|
||||
|
||||
//将a公会成员加入b公会
|
||||
$s_date = date('Y-m-d H:i:s');
|
||||
db::name('user_guild')->where(['guild_id'=>$cancel_guild_id,'status'=>1,'is_delete'=>1])->update(['guild_id'=>$join_guild_id,'is_deacon'=>2,'remarks'=>"{$s_date}公会id:{$cancel_guild_id}合并到公会id:{$join_guild_id}"]);
|
||||
db::name('guild')->where(['id'=>$join_guild_id,'is_delete'=>1])->inc('num',$num)->update(['update_time'=>time()]);
|
||||
|
||||
|
||||
//取消a公会 工会长身份
|
||||
$update_data = [];
|
||||
$update_data['is_deacon'] = 2;
|
||||
$update_data['update_time'] = time();
|
||||
$reslut = db::name('user')->where('uid', $guild_info1['uid'])->update($update_data);
|
||||
db::name('guild')->where(['id'=>$cancel_guild_id])->update(['guild_special_id'=>"",'num'=>0,'is_delete'=>2,'is_show'=>2]);
|
||||
|
||||
Db::commit();
|
||||
|
||||
return ['code' => 200, 'msg' => '合并成功!', 'data' => null];
|
||||
}catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '合并失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
147
application/admin/model/GuildMoneyLog.php
Normal file
147
application/admin/model/GuildMoneyLog.php
Normal file
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class GuildMoneyLog extends Model
|
||||
{
|
||||
//公会流水列表
|
||||
public function get_list($guild_id, $start, $end, $page = 1, $limit = 20)
|
||||
{
|
||||
$map = [];
|
||||
|
||||
if($guild_id) {
|
||||
$map[] = ['a.room_guild_id', '=', $guild_id];
|
||||
}
|
||||
if($start) {
|
||||
$map[] = ['a.add_time', '>=', strtotime($start)];
|
||||
}
|
||||
if($end) {
|
||||
$map[] = ['a.add_time', '<=', strtotime($end)];
|
||||
}
|
||||
$map[] = ['a.room_guild_id', '>', 0];
|
||||
// dump($map);die;
|
||||
$list = db::name('user_send_gift')->alias('a')
|
||||
->field('a.*,b.room_name,b.room_number,b.room_owner_uid,c.guild_name,c.base64_guild_name,c.uid')
|
||||
->leftJoin('yy_room b', 'a.rid = b.rid')
|
||||
->leftJoin('yy_guild c', 'a.room_guild_id = c.id')
|
||||
->where($map)->order('a.add_time', 'desc')->page($page, $limit)->select();
|
||||
$uid_arr = $receive_uid_arr = [];
|
||||
foreach ($list as $val) {
|
||||
$uid_arr[] = $val['uid'];
|
||||
$receive_uid_arr[] = $val['receive_uid'];
|
||||
}
|
||||
$uid_arr = array_merge($uid_arr, $receive_uid_arr);
|
||||
$user_list = Db::name('user')->whereIn('uid', $uid_arr)->column('nick_name', 'uid');
|
||||
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['guild_name'] = mb_convert_encoding(base64_decode($v['base64_guild_name']), 'UTF-8', 'UTF-8');
|
||||
$v['send_nick_name'] = $user_list[$v['uid']] ?? '';
|
||||
$v['receive_nick_name'] = $user_list[$v['receive_uid']] ?? '';
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('user_send_gift')->alias('a')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
$gift_total_price = Db::name('user_send_gift')->alias('a')->where($map)->sum('gift_total_price');
|
||||
$totalRowData = ['gift_total_price' => $gift_total_price];
|
||||
$data['totalRow'] = $totalRowData;
|
||||
// $data['totalRow'] = ['gift_total_price' => strval($gift_total_price)];
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
public function get_guild_room_money_log_list($guild_id, $rid, $start, $end, $page, $limit)
|
||||
{
|
||||
$rid_arr = [];
|
||||
if($rid) {
|
||||
$rid_arr = [$rid];
|
||||
}
|
||||
// else {
|
||||
// $rid_arr = $this->get_guild_room_list($guild_id);
|
||||
// }
|
||||
// dump($rid_arr);die;
|
||||
$map = [];
|
||||
if(!empty($rid_arr)) {
|
||||
$map[] = ['a.rid', 'in', $rid_arr];
|
||||
}
|
||||
if($start) {
|
||||
$map[] = ['a.add_time', '>=', strtotime($start)];
|
||||
}
|
||||
if($end) {
|
||||
$map[] = ['a.add_time', '<=', strtotime($end)];
|
||||
}
|
||||
if($guild_id > 0) {
|
||||
$map[] = ['a.room_guild_id', '=', $guild_id];
|
||||
}
|
||||
$map[] = ['a.room_guild_id', '>', 0];
|
||||
|
||||
$list = db::name('user_send_gift')->alias('a')
|
||||
->field('a.*,b.room_name,b.base64_room_name,b.room_number,b.room_owner_uid,c.guild_name,c.base64_guild_name,c.uid')
|
||||
->leftJoin('yy_room b', 'a.rid = b.rid')
|
||||
->leftJoin('yy_guild c', 'a.room_guild_id = c.id')
|
||||
->where($map)->order('a.add_time', 'desc')->page($page, $limit)->select();
|
||||
$uid_arr = $receive_uid_arr = [];
|
||||
foreach ($list as $val) {
|
||||
$uid_arr[] = $val['uid'];
|
||||
$receive_uid_arr[] = $val['receive_uid'];
|
||||
}
|
||||
$uid_arr = array_merge($uid_arr, $receive_uid_arr);
|
||||
$user_list = Db::name('user')->whereIn('uid', $uid_arr)->column('nick_name', 'uid');
|
||||
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['guild_name'] = mb_convert_encoding(base64_decode($v['base64_guild_name']), 'UTF-8', 'UTF-8');
|
||||
$v['send_nick_name'] = $user_list[$v['uid']] ?? '';
|
||||
$v['receive_nick_name'] = $user_list[$v['receive_uid']] ?? '';
|
||||
$v['room_name'] = mb_convert_encoding(base64_decode($v['base64_room_name']), 'UTF-8', 'UTF-8');
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('user_send_gift')->alias('a')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
$totalRowData = Db::name('user_send_gift')->alias('a')
|
||||
->field('SUM(gift_total_price) as gift_total_price, SUM(room_owner_profit) as room_owner_profit')
|
||||
->where($map)->find();
|
||||
|
||||
$data['totalRow'] = $totalRowData;
|
||||
// $data['totalRow'] = ['gift_total_price' => strval($gift_total_price)];
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//获取工会签约房间列表
|
||||
public function get_guild_room_list($guild_id = 0, $is_move = 0)
|
||||
{
|
||||
$map = [];
|
||||
if($guild_id) {
|
||||
$map[] = ['guild_id', '=', $guild_id];
|
||||
}
|
||||
if($is_move) {
|
||||
$map[] = ['is_delete', '=', $is_move];
|
||||
}
|
||||
$map[] = ['status', '=', 1];
|
||||
|
||||
$uid = Db::name('user_guild')->where($map)->column('uid');
|
||||
$uid_arr = Db::name('user')->where(['uid' => $uid, 'is_sign' => 1])->column('uid');
|
||||
$rid_arr = Db::name('room')->where(['room_owner_uid' => $uid_arr, 'room_status' => 1])->column('rid');
|
||||
return $rid_arr;
|
||||
}
|
||||
|
||||
//获取工会签约房间列表
|
||||
public function get_guild_room_list_by_guild_id($guild_id)
|
||||
{
|
||||
$map = [
|
||||
['a.guild_id', '=', $guild_id],
|
||||
['a.status', '=', 1],
|
||||
['b.is_sign', '=', 1],
|
||||
];
|
||||
$list = Db::name('user_guild')->alias('a')
|
||||
->leftJoin('yy_user b', 'a.uid = b.uid')
|
||||
->leftJoin('yy_room c', 'a.uid = c.room_owner_uid')
|
||||
->field('a.is_delete,c.rid,c.base64_room_name')
|
||||
->where($map)
|
||||
->select();
|
||||
foreach ($list as &$val) {
|
||||
$val['room_name'] = mb_convert_encoding(base64_decode($val['base64_room_name']), 'UTF-8', 'UTF-8');
|
||||
$val['is_delete_title'] = $val['is_delete'] == 1 ? '未离开' : '离开';
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
271
application/admin/model/Jpush.php
Normal file
271
application/admin/model/Jpush.php
Normal file
@@ -0,0 +1,271 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class Jpush extends Model
|
||||
{
|
||||
|
||||
public $client;
|
||||
public $message_data;
|
||||
public function __construct()
|
||||
{
|
||||
$config = get_system_config();
|
||||
$this->client = new \JPush\Client($config['jpush_app_key'], $config['jpush_master_secret']);
|
||||
$this->message_data[1000] = '系统消息';
|
||||
$this->message_data[1001] = '情缘消息';
|
||||
$this->message_data[1002] = '陪玩订单消息';
|
||||
}
|
||||
|
||||
//全体推送
|
||||
public function push_all_notification_message($platform, $title, $message, $data = [])
|
||||
{
|
||||
if (empty($this->message_data[$data['code']])) {
|
||||
return ['code' => 201, 'msg' => '消息类型不存在', 'data' => null];
|
||||
}
|
||||
|
||||
// 完整的推送示例
|
||||
// 这只是使用样例,不应该直接用于实际生产环境中 !!
|
||||
try {
|
||||
$response = $this->client->push();
|
||||
if ($platform == 1) {
|
||||
$response = $response->setPlatform(array('ios'));
|
||||
} elseif ($platform == 2) {
|
||||
$response = $response->setPlatform(array('android'));
|
||||
} elseif ($platform == 3) {
|
||||
$response = $response->setPlatform(array('ios', 'android'));
|
||||
}
|
||||
|
||||
// 一般情况下,关于 audience 的设置只需要调用 addAlias、addTag、addTagAnd 或 addRegistrationId
|
||||
// 这四个方法中的某一个即可,这里仅作为示例,当然全部调用也可以,多项 audience 调用表示其结果的交集
|
||||
// 即是说一般情况下,下面三个方法和没有列出的 addTagAnd 一共四个,只适用一个便可满足大多数的场景需求
|
||||
|
||||
// ->addAlias('alias')
|
||||
// ->addTag(array('tag1', 'tag2'))
|
||||
// ->addRegistrationId($registration_id)
|
||||
|
||||
$response = $response->addAllAudience()
|
||||
->iosNotification($message, array(
|
||||
'title' => $title,
|
||||
//'sound' => 'sound.caf',
|
||||
// 'badge' => '+1',
|
||||
// 'content-available' => true,
|
||||
// 'mutable-content' => true,
|
||||
//'category' => '',
|
||||
'extras' => $data,
|
||||
))
|
||||
->androidNotification($message, array(
|
||||
'title' => $title,
|
||||
// 'builder_id' => 2,
|
||||
'extras' => $data
|
||||
))
|
||||
->options(array(
|
||||
// sendno: 表示推送序号,纯粹用来作为 API 调用标识,
|
||||
// API 返回时被原样返回,以方便 API 调用方匹配请求与返回
|
||||
// 这里设置为 100 仅作为示例
|
||||
|
||||
// 'sendno' => 100,
|
||||
|
||||
// time_to_live: 表示离线消息保留时长(秒),
|
||||
// 推送当前用户不在线时,为该用户保留多长时间的离线消息,以便其上线时再次推送。
|
||||
// 默认 86400 (1 天),最长 10 天。设置为 0 表示不保留离线消息,只有推送当前在线的用户可以收到
|
||||
// 这里设置为 1 仅作为示例
|
||||
|
||||
// 'time_to_live' => 1,
|
||||
|
||||
// apns_production: 表示APNs是否生产环境,
|
||||
// True 表示推送生产环境,False 表示要推送开发环境;如果不指定则默认为推送开发环境
|
||||
|
||||
'apns_production' => false,
|
||||
|
||||
// big_push_duration: 表示定速推送时长(分钟),又名缓慢推送,把原本尽可能快的推送速度,降低下来,
|
||||
// 给定的 n 分钟内,均匀地向这次推送的目标用户推送。最大值为1400.未设置则不是定速推送
|
||||
// 这里设置为 1 仅作为示例
|
||||
|
||||
// 'big_push_duration' => 1
|
||||
))
|
||||
->setSmsMessage(array(
|
||||
'delay_time' => 60,
|
||||
'signid' => 154,
|
||||
'temp_id' => 1,
|
||||
'temp_para' => array(
|
||||
'code' => 357
|
||||
),
|
||||
'active_filter' => false
|
||||
))
|
||||
->send();
|
||||
//print_r($response);
|
||||
return ['code' => 200, 'msg' => '推送成功', 'data' => null];
|
||||
} catch (\JPush\Exceptions\APIConnectionException $e) {
|
||||
// try something here
|
||||
//print $e;
|
||||
return ['code' => 201, 'msg' => '推送失败', 'data' => null];
|
||||
} catch (\JPush\Exceptions\APIRequestException $e) {
|
||||
// try something here
|
||||
// print $e;
|
||||
return ['code' => 201, 'msg' => '推送失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
//个人推送
|
||||
public function push_notification_message($uid, $title, $message, $data = [])
|
||||
{
|
||||
if (empty($this->message_data[$data['code']])) {
|
||||
return ['code' => 201, 'msg' => '消息类型不存在', 'data' => null];
|
||||
}
|
||||
$uid = strval($uid);
|
||||
|
||||
// 完整的推送示例
|
||||
// 这只是使用样例,不应该直接用于实际生产环境中 !!
|
||||
try {
|
||||
$response = $this->client->push()
|
||||
->setPlatform(array('ios', 'android'));
|
||||
// 一般情况下,关于 audience 的设置只需要调用 addAlias、addTag、addTagAnd 或 addRegistrationId
|
||||
// 这四个方法中的某一个即可,这里仅作为示例,当然全部调用也可以,多项 audience 调用表示其结果的交集
|
||||
// 即是说一般情况下,下面三个方法和没有列出的 addTagAnd 一共四个,只适用一个便可满足大多数的场景需求
|
||||
|
||||
// ->addAlias('alias')
|
||||
// ->addTag(array('tag1', 'tag2'))
|
||||
// ->addRegistrationId($registration_id)
|
||||
//->addAllAudience()
|
||||
|
||||
$response = $response->addAlias($uid)
|
||||
|
||||
->setNotificationAlert($message)
|
||||
->iosNotification($message, array(
|
||||
'sound' => 'sound.caf',
|
||||
// 'badge' => '+1',
|
||||
// 'content-available' => true,
|
||||
// 'mutable-content' => true,
|
||||
'category' => 'jiguang',
|
||||
'extras' => $data,
|
||||
))
|
||||
->androidNotification($message, array(
|
||||
'title' => $title,
|
||||
// 'builder_id' => 2,
|
||||
'extras' => $data,
|
||||
))
|
||||
->message($message, array(
|
||||
'title' => $title,
|
||||
// 'content_type' => 'text',
|
||||
'extras' => $data,
|
||||
))->options(array(
|
||||
// sendno: 表示推送序号,纯粹用来作为 API 调用标识,
|
||||
// API 返回时被原样返回,以方便 API 调用方匹配请求与返回
|
||||
// 这里设置为 100 仅作为示例
|
||||
|
||||
// 'sendno' => 100,
|
||||
|
||||
// time_to_live: 表示离线消息保留时长(秒),
|
||||
// 推送当前用户不在线时,为该用户保留多长时间的离线消息,以便其上线时再次推送。
|
||||
// 默认 86400 (1 天),最长 10 天。设置为 0 表示不保留离线消息,只有推送当前在线的用户可以收到
|
||||
// 这里设置为 1 仅作为示例
|
||||
|
||||
// 'time_to_live' => 1,
|
||||
|
||||
// apns_production: 表示APNs是否生产环境,
|
||||
// True 表示推送生产环境,False 表示要推送开发环境;如果不指定则默认为推送开发环境
|
||||
|
||||
'apns_production' => false,
|
||||
|
||||
// big_push_duration: 表示定速推送时长(分钟),又名缓慢推送,把原本尽可能快的推送速度,降低下来,
|
||||
// 给定的 n 分钟内,均匀地向这次推送的目标用户推送。最大值为1400.未设置则不是定速推送
|
||||
// 这里设置为 1 仅作为示例
|
||||
|
||||
// 'big_push_duration' => 1
|
||||
))
|
||||
->setSmsMessage(array(
|
||||
'delay_time' => 60,
|
||||
'signid' => 154,
|
||||
'temp_id' => 1,
|
||||
'temp_para' => array(
|
||||
'code' => 357
|
||||
),
|
||||
'active_filter' => false
|
||||
))
|
||||
->send();
|
||||
print_r($response);
|
||||
} catch (\JPush\Exceptions\APIConnectionException $e) {
|
||||
// try something here
|
||||
//print $e;
|
||||
return ['code' => 201, 'msg' => '推送失败', 'data' => null];
|
||||
} catch (\JPush\Exceptions\APIRequestException $e) {
|
||||
// try something here
|
||||
// print $e;
|
||||
return ['code' => 201, 'msg' => '推送失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
//推送APP内消息
|
||||
public function push_message($uid, $title, $message, $data = [])
|
||||
{
|
||||
|
||||
if (empty($this->message_data[$data['code']])) {
|
||||
return ['code' => 201, 'msg' => '消息类型不存在', 'data' => null];
|
||||
}
|
||||
// 完整的推送示例
|
||||
// 这只是使用样例,不应该直接用于实际生产环境中 !!
|
||||
try {
|
||||
$response = $this->client->push()
|
||||
->setPlatform(array('ios', 'android'));
|
||||
// 一般情况下,关于 audience 的设置只需要调用 addAlias、addTag、addTagAnd 或 addRegistrationId
|
||||
// 这四个方法中的某一个即可,这里仅作为示例,当然全部调用也可以,多项 audience 调用表示其结果的交集
|
||||
// 即是说一般情况下,下面三个方法和没有列出的 addTagAnd 一共四个,只适用一个便可满足大多数的场景需求
|
||||
|
||||
// ->addAlias('alias')
|
||||
// ->addTag(array('tag1', 'tag2'))
|
||||
// ->addRegistrationId($registration_id)
|
||||
//->addAllAudience()
|
||||
|
||||
$response = $response->addAlias($uid)
|
||||
->message($message, array(
|
||||
'title' => $title,
|
||||
// 'content_type' => 'text',
|
||||
'extras' => $data,
|
||||
))
|
||||
->options(array(
|
||||
// sendno: 表示推送序号,纯粹用来作为 API 调用标识,
|
||||
// API 返回时被原样返回,以方便 API 调用方匹配请求与返回
|
||||
// 这里设置为 100 仅作为示例
|
||||
|
||||
// 'sendno' => 100,
|
||||
|
||||
// time_to_live: 表示离线消息保留时长(秒),
|
||||
// 推送当前用户不在线时,为该用户保留多长时间的离线消息,以便其上线时再次推送。
|
||||
// 默认 86400 (1 天),最长 10 天。设置为 0 表示不保留离线消息,只有推送当前在线的用户可以收到
|
||||
// 这里设置为 1 仅作为示例
|
||||
|
||||
// 'time_to_live' => 1,
|
||||
|
||||
// apns_production: 表示APNs是否生产环境,
|
||||
// True 表示推送生产环境,False 表示要推送开发环境;如果不指定则默认为推送开发环境
|
||||
|
||||
'apns_production' => false,
|
||||
|
||||
// big_push_duration: 表示定速推送时长(分钟),又名缓慢推送,把原本尽可能快的推送速度,降低下来,
|
||||
// 给定的 n 分钟内,均匀地向这次推送的目标用户推送。最大值为1400.未设置则不是定速推送
|
||||
// 这里设置为 1 仅作为示例
|
||||
|
||||
// 'big_push_duration' => 1
|
||||
))
|
||||
->setSmsMessage(array(
|
||||
'delay_time' => 60,
|
||||
'signid' => 154,
|
||||
'temp_id' => 1,
|
||||
'temp_para' => array(
|
||||
'code' => 357
|
||||
),
|
||||
'active_filter' => false
|
||||
))
|
||||
->send();
|
||||
print_r($response);
|
||||
} catch (\JPush\Exceptions\APIConnectionException $e) {
|
||||
// try something here
|
||||
//print $e;
|
||||
return ['code' => 201, 'msg' => '推送失败', 'data' => null];
|
||||
} catch (\JPush\Exceptions\APIRequestException $e) {
|
||||
// try something here
|
||||
// print $e;
|
||||
return ['code' => 201, 'msg' => '推送失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
142
application/admin/model/Message.php
Normal file
142
application/admin/model/Message.php
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
|
||||
class Message extends Model
|
||||
{
|
||||
protected $pk = 'smid';
|
||||
protected $auto = ['update_time'];
|
||||
protected $insert = [
|
||||
'add_time',
|
||||
];
|
||||
protected $update = ['update_time'];
|
||||
|
||||
|
||||
protected function setAddTimeAttr()
|
||||
{
|
||||
return time();
|
||||
}
|
||||
|
||||
protected function setUpdateTimeAttr()
|
||||
{
|
||||
return time();
|
||||
}
|
||||
|
||||
public function get_message_list($smid, $title, $order, $sort, $page, $limit)
|
||||
{
|
||||
$map = [];
|
||||
if (!empty($smid)) {
|
||||
$map[] = ['smid', '=', $smid];
|
||||
}
|
||||
if (!empty($title)) {
|
||||
$map[] = ['title', 'like', '%' . $title . '%'];
|
||||
}
|
||||
$user_list = db::name('message')->where($map)->order($order, $sort)->page($page, $limit)->select();
|
||||
$data = [];
|
||||
$data['count'] = db::name('message')->where($map)->count();
|
||||
$data['list'] = $user_list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
public function get_message_info($smid)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['smid', '=', $smid];
|
||||
$info = db::name('message')->where($map)->find();
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $info];
|
||||
}
|
||||
|
||||
// public function add_message($datas)
|
||||
// {
|
||||
// set_time_limit(0);
|
||||
// ini_set('memory_limit', '1024M');
|
||||
|
||||
// $validate = validate('message');
|
||||
// $reslut = $validate->scene('adminAdd')->check($datas);
|
||||
// if ($reslut !== true) {
|
||||
// return ['code' => 201, 'msg' => $validate->getError(), 'data' => null];
|
||||
// }
|
||||
// $message = model('message');
|
||||
// $reslut = $message->save($datas);
|
||||
// $smid = $message->smid;
|
||||
// if ($reslut) {
|
||||
// //批量增加用户消息
|
||||
// $uid_list = db::name('user')->column('uid');
|
||||
// $now_time = time();
|
||||
// $insert_data = [];
|
||||
// foreach ($uid_list as $k => $v) {
|
||||
// $data = [];
|
||||
// $data['type'] = 1;
|
||||
// $data['id'] = $smid;
|
||||
// $data['uid'] = $v;
|
||||
// $data['title'] = $datas['title'];
|
||||
// $data['content'] = $datas['content'];
|
||||
// $data['is_read'] = 1;
|
||||
// $data['read_time'] = 0;
|
||||
// $data['add_time'] = $now_time;
|
||||
// $data['update_time'] = $now_time;
|
||||
// $insert_data[] = $data;
|
||||
// // if (count($insert_data) % 2000 == 0) {
|
||||
// // db::name('user_message')->insertAll($insert_data);
|
||||
// // }
|
||||
// }
|
||||
// if (!empty($insert_data)) {
|
||||
// db::name('user_message')->insertAll($insert_data);
|
||||
// }
|
||||
// return ['code' => 200, 'msg' => '添加成功', 'data' => ''];
|
||||
// } else {
|
||||
// return ['code' => 201, 'msg' => '添加失败', 'data' => ''];
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
public function add_message($data)
|
||||
{
|
||||
set_time_limit(0);
|
||||
ini_set('memory_limit', '1024M');
|
||||
$validate = validate('message');
|
||||
$reslut = $validate->scene('adminAdd')->check($data);
|
||||
if ($reslut !== true) {
|
||||
return ['code' => 201, 'msg' => $validate->getError(), 'data' => null];
|
||||
}
|
||||
$message = model('message');
|
||||
$reslut = $message->save($data);
|
||||
$smid = $message->smid;
|
||||
$data1 = $data;
|
||||
if ($reslut) {
|
||||
//队列插入数据
|
||||
$redis = connectionRedis();
|
||||
$redis->rPush('admin_add_message111',$smid.'-61116-'.$data1['title'].'-61116-'.$data1['content']);
|
||||
return ['code' => 200, 'msg' => '添加成功', 'data' => ''];
|
||||
} else {
|
||||
return ['code' => 201, 'msg' => '添加失败', 'data' => ''];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function edit_message($data)
|
||||
{
|
||||
$validate = validate('message');
|
||||
$reslut = $validate->scene('adminEdit')->check($data);
|
||||
if ($reslut !== true) {
|
||||
return ['code' => 201, 'msg' => $validate->getError(), 'data' => null];
|
||||
}
|
||||
$reslut = model('message')->isUpdate(true)->save($data);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '编辑失败', 'data' => ''];
|
||||
} else {
|
||||
$update_data = [];
|
||||
$update_data['title'] = $data['title'];
|
||||
$update_data['content'] = $data['content'];
|
||||
$update_data['is_show'] = $data['is_show'];
|
||||
db::name('user_message')->where(['smid' => $data['smid']])->update($update_data);
|
||||
return ['code' => 200, 'msg' => '编辑成功', 'data' => ''];
|
||||
}
|
||||
}
|
||||
}
|
||||
244
application/admin/model/Monster.php
Normal file
244
application/admin/model/Monster.php
Normal file
@@ -0,0 +1,244 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\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('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'] .= '%';
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('Monster')->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//获取礼物列表
|
||||
public function get_gift_list(){
|
||||
$map = [];
|
||||
// $map[] = ['gid', 'not in', [36,37,38]];
|
||||
$map[] = ['type', '=', 1];
|
||||
$map[] = ['is_show','=',1];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$list = db::name('gift')->where($map)->order('gift_price asc')->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['base_image'] = localpath_to_netpath($v['base_image']);
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('gift')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
|
||||
|
||||
}
|
||||
|
||||
//编辑
|
||||
public function edit_monster($data)
|
||||
{
|
||||
if (empty($data)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$monster_info = db::name('Monster')->find($data['id']);
|
||||
if (empty($monster_info)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$map = [];
|
||||
$map[] = ['gid', '=', $data['gid']];
|
||||
$map[] = ['type', '=', 1];
|
||||
$map[] = ['is_show','=',1];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$gift_info = db::name('gift')->where($map)->find();
|
||||
if(!$gift_info){
|
||||
return ['code' => 201, 'msg' => '配置礼物不存在', 'data' => null];
|
||||
}
|
||||
|
||||
if($monster_info['multiple'] * 10 != $gift_info['gift_price']){
|
||||
return ['code' => 201, 'msg' => '配置礼物的价格必须为倍数的10倍', 'data' => null];
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
|
||||
$update_data = [];
|
||||
$update_data['type_name'] = $data['type_name'];
|
||||
// $update_data['multiple'] = $data['multiple'];
|
||||
$update_data['gid'] = $data['gid'];
|
||||
$update_data['num'] = $data['num'];
|
||||
$update_data['update_time'] = time();
|
||||
$reslut = db::name('Monster')->where(['id' => $data['id']])->update($update_data);
|
||||
if (!$reslut) {
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return ['code' => 200, 'msg' => '修改成功', 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
dump($e);
|
||||
Db::rollback();
|
||||
return ['code' => 201, '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' => 200, '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' => 200, '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['update_time'] = time();
|
||||
$reslut = db::name('monster_multiple')->where(['id' => $data['id']])->update($update_data);
|
||||
if (!$reslut) {
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return ['code' => 200, 'msg' => '修改成功', 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
dump($e);
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//获取信息
|
||||
public function get_monster_multiple_info($id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$monster_info = db::name('monster_multiple')->where(['id' => $id])->find();
|
||||
return ['code' => 200, '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('yy_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'];
|
||||
}
|
||||
}
|
||||
$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' => 200, '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('uid', $v['uid'])->field('uid,nick_name,base64_nick_name,head_pic')->find();
|
||||
$v['nick_name'] = mb_convert_encoding(base64_decode($user_info['base64_nick_name']), 'UTF-8', 'UTF-8');
|
||||
$v['head_pic'] = localpath_to_netpath($user_info['head_pic']);
|
||||
$v['type_name'] = db::name('Monster')->where('type', $v['type'])->value('type_name');
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['count'] = db::name('user_monster_log')->where('mid', $mid)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, '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('uid', $v['uid'])->field('uid,nick_name,base64_nick_name,head_pic')->find();
|
||||
$v['nick_name'] = mb_convert_encoding(base64_decode($user_info['base64_nick_name']), 'UTF-8', 'UTF-8');
|
||||
$v['head_pic'] = localpath_to_netpath($user_info['head_pic']);
|
||||
$v['type_name'] = db::name('Monster')->where('type', $v['win_type'])->value('type_name');
|
||||
$gift_info = db::name('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'];
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('user_monster_win_log')->where('mid', $mid)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
575
application/admin/model/Multiple.php
Normal file
575
application/admin/model/Multiple.php
Normal file
@@ -0,0 +1,575 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class Multiple extends Model
|
||||
{
|
||||
//类型列表
|
||||
public function get_gift_multiple_type_list($id, $name, $order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
$map = [];
|
||||
if (!empty($id)) {
|
||||
$map[] = ['id', '=', $id];
|
||||
}
|
||||
if (!empty($name)) {
|
||||
$map[] = ['name', 'like', '%' . $name . '%'];
|
||||
}
|
||||
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
|
||||
$list = db::name('gift_multiple_type')->where($map)->order($order, $sort)->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('gift_multiple_type')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//编辑类型
|
||||
public function edit_gift_multiple_type($data)
|
||||
{
|
||||
if (empty($data)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$info = db::name('gift_multiple_type')->find($data['id']);
|
||||
if (empty($info)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$update_data = [];
|
||||
$update_data['name'] = $data['name'];
|
||||
$update_data['update_time'] = time();
|
||||
$reslut = db::name('gift_multiple_type')->where(['id' => $data['id']])->update($update_data);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '修改成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
//添加类型
|
||||
public function add_gift_multiple_type($data)
|
||||
{
|
||||
|
||||
$add_data = [];
|
||||
$add_data['name'] = $data['name'];
|
||||
$add_data['update_time'] = time();
|
||||
$add_data['add_time'] = time();
|
||||
$reslut = db::name('gift_multiple_type')->insert($add_data);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '添加失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '添加成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//获取类型信息
|
||||
public function get_gift_multiple_type_info($id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$info = db::name('gift_multiple_type')->where(['id' => $id])->find();
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $info];
|
||||
}
|
||||
|
||||
//删除类型
|
||||
public function del_gift_multiple_type($id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$reslut = db::name('gift_multiple_type')->where(['id' => $id])->update(['is_delete' => 2, 'update_time' => time()]);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '删除失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '删除成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//列表
|
||||
public function get_gift_multiple_rate_list($pid, $order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
set_time_limit(0);
|
||||
ini_set('memory_limit', '1024M');
|
||||
$redis = connectionRedis();
|
||||
|
||||
$map = [];
|
||||
if (!empty($pid)) {
|
||||
$map[] = ['pid', '=', $pid];
|
||||
}
|
||||
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$count = db::name('gift_multiple_rate')->where($map)->sum('rate_num');
|
||||
$list = db::name('gift_multiple_rate')->where($map)->order($order, $sort)->page($page, $limit)->select();
|
||||
$total_unopen_num = 0;
|
||||
$total_open_num = 0;
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['rate'] = round(($v['rate_num']/$count),6)*100;
|
||||
$v['rate'] = $v['rate'].'%';
|
||||
|
||||
$un_redis_list = [];
|
||||
if(in_array($v['pid'],$un_redis_list)){
|
||||
$v['unopen_num'] = $v['rate_num'];
|
||||
$v['open_num'] = $v['rate_num'];
|
||||
|
||||
}else{
|
||||
$keyname = "multiple:list:type:".$v['pid'];
|
||||
$redis_data_list = $redis->Lrange($keyname, 0, -1);
|
||||
$redis_gift_data = [];
|
||||
foreach ($redis_data_list as $a => $b) {
|
||||
$gift_data = explode('-', $b);
|
||||
if (empty($redis_gift_data[$gift_data[1]])) {
|
||||
$redis_gift_data[$gift_data[1]] = 1;
|
||||
} else {
|
||||
$redis_gift_data[$gift_data[1]]++;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($redis_gift_data[$v['multiple']])) {
|
||||
$v['unopen_num'] = 0;
|
||||
} else {
|
||||
$v['unopen_num'] = $redis_gift_data[$v['multiple']];
|
||||
}
|
||||
// $total_unopen_num += $v['unopen_num'];
|
||||
$sum_num = $count;
|
||||
if(count($redis_data_list) > $sum_num){
|
||||
$count_redis_data_list = count($redis_data_list);
|
||||
$place = ceil($count_redis_data_list/$sum_num);
|
||||
$v['open_num'] = $v['rate_num']*$place - $v['unopen_num'];
|
||||
}else{
|
||||
$v['open_num'] = $v['rate_num'] - $v['unopen_num'];
|
||||
}
|
||||
// $total_open_num += $v['open_num'];
|
||||
}
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('gift_multiple_rate')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//编辑
|
||||
public function edit_gift_multiple_rate($data)
|
||||
{
|
||||
if (empty($data)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$info = db::name('gift_multiple_rate')->find($data['id']);
|
||||
if (empty($info)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$map = [];
|
||||
$map[] = ['multiple', '=', $data['multiple']];
|
||||
$map[] = ['pid', 'neq', $info['pid']];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$gift_multiple_rate = db::name('gift_multiple_rate')->where($map)->find();
|
||||
if($gift_multiple_rate){
|
||||
return ['code' => 201, 'msg' => '该倍率已添加过', 'data' => null];
|
||||
}
|
||||
|
||||
// dump($data);exit;
|
||||
$update_data = [];
|
||||
$update_data['multiple'] = $data['multiple'];
|
||||
$update_data['rate_num'] = $data['rate_num'];
|
||||
$update_data['update_time'] = time();
|
||||
$reslut = db::name('gift_multiple_rate')->where(['id' => $data['id']])->update($update_data);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '修改成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//添加
|
||||
public function add_gift_multiple_rate($data)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['pid', '=', $data['pid']];
|
||||
$map[] = ['multiple', '=', $data['multiple']];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$gift_multiple_rate = db::name('gift_multiple_rate')->where($map)->find();
|
||||
if($gift_multiple_rate){
|
||||
return ['code' => 201, 'msg' => '该倍率已添加过', 'data' => null];
|
||||
}
|
||||
|
||||
$add_data = [];
|
||||
$add_data['pid'] = $data['pid'];
|
||||
$add_data['multiple'] = $data['multiple'];
|
||||
$add_data['rate_num'] = $data['rate_num'];
|
||||
$add_data['update_time'] = time();
|
||||
$add_data['add_time'] = time();
|
||||
$reslut = db::name('gift_multiple_rate')->insert($add_data);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '添加失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '添加成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//获取信息
|
||||
public function get_gift_multiple_rate_info($id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$info = db::name('gift_multiple_rate')->where(['id' => $id])->find();
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $info];
|
||||
}
|
||||
|
||||
//删除
|
||||
public function del_gift_multiple_rate($id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$reslut = db::name('gift_multiple_rate')->where(['id' => $id])->update(['is_delete' => 2, 'update_time' => time()]);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '删除失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '删除成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
public function get_user_send_gift_rate_list($uid, $room_id, $room_uid, $receive_uid, $gid, $gift_name, $start, $end, $order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
$map = [];
|
||||
if (!empty($uid)) {
|
||||
$map[] = ['a.uid', '=', $uid];
|
||||
}
|
||||
|
||||
if (!empty($room_id)) {
|
||||
$map[] = ['c.room_number', '=', $room_id];
|
||||
}
|
||||
if (!empty($room_uid)) {
|
||||
$map[] = ['a.room_uid', '=', $room_uid];
|
||||
}
|
||||
|
||||
if (!empty($receive_uid)) {
|
||||
$map[] = ['a.receive_uid', '=', $receive_uid];
|
||||
}
|
||||
if (!empty($gid)) {
|
||||
$map[] = ['a.gid', '=', $gid];
|
||||
}
|
||||
if (!empty($gift_name)) {
|
||||
$map[] = ['a.gift_name', 'like', '%' . $gift_name . '%'];
|
||||
}
|
||||
|
||||
if (!empty($start)) {
|
||||
$map[] = ['a.add_time', '>=', strtotime($start)];
|
||||
}
|
||||
if (!empty($end)) {
|
||||
$map[] = ['a.add_time', '<=', strtotime($end)];
|
||||
}
|
||||
|
||||
if (empty($order)) {
|
||||
$order = 'a.sid';
|
||||
}
|
||||
if (empty($sort)) {
|
||||
$sort = 'desc';
|
||||
}
|
||||
|
||||
$list = db::name('user_send_gift_rate')
|
||||
->alias('a')->join('yy_user b', 'a.uid = b.uid')->join('yy_room c', 'a.rid = c.rid')
|
||||
->field('a.*,b.nick_name,c.room_name')->where($map)->order($order, $sort)->page($page, $limit)->select();
|
||||
foreach ($list as $k => $v) {
|
||||
$list[$k]['user_nick_name'] = $v['uid'] . '-' . $v['nick_name'];
|
||||
}
|
||||
$data = [];
|
||||
|
||||
$data['list'] = $list;
|
||||
$totalRowData = db::name('user_send_gift_rate')->alias('a')->join('yy_user b', 'a.uid = b.uid')->join('yy_room c', 'a.rid = c.rid')->field('count(a.sid) as count,SUM(a.gift_num) as gift_num,SUM(a.gift_total_price) as gift_total_price,SUM(a.win_price) as win_price,SUM(a.room_owner_profit) as room_owner_profit, SUM(a.room_host_profit) as room_host_profit, SUM(a.receiver_profit) as receiver_profit')->where($map)->find();
|
||||
$data['count'] = $totalRowData['count'];
|
||||
unset($totalRowData['count']);
|
||||
//dump($totalRowData);
|
||||
$data['totalRow'] = $totalRowData;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
|
||||
//获取列表
|
||||
public function room_subsidy($order, $sort, $page, $limit)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$list = db::name('room_subsidy_lucky')->where($map)->order($order, $sort)->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v){
|
||||
if($v['type'] == 2){
|
||||
$v['money'] = $v['money'].'%';
|
||||
}
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('room_subsidy_lucky')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//删除
|
||||
public function room_subsidy_del($id)
|
||||
{
|
||||
|
||||
$del = db::name('room_subsidy_lucky')->where(['id' => $id])->update(['is_delete' => 2]);
|
||||
if ($del) {
|
||||
return ['code' => 200, 'msg' => '删除成功', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 201, 'msg' => '删除失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//获取
|
||||
public function room_subsidy_info($id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$room_subsidy_info = db::name('room_subsidy_lucky')->find($id);
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $room_subsidy_info];
|
||||
}
|
||||
|
||||
//修改
|
||||
public function edit_room_subsidy($id, $level_name, $total_gift_price, $money, $type)
|
||||
{
|
||||
if (empty($id)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$arr = [];
|
||||
$arr['type'] = $type;
|
||||
$arr['level_name'] = $level_name;
|
||||
$arr['total_gift_price'] = $total_gift_price;
|
||||
$arr['money'] = $money;
|
||||
$arr['update_time'] = time();
|
||||
$upd = db::name('room_subsidy_lucky')->where(['id' => $id])->update($arr);
|
||||
if ($upd) {
|
||||
return ['code' => 200, 'msg' => '修改成功', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//添加
|
||||
public function add_room_subsidy($level_name, $total_gift_price, $money, $type)
|
||||
{
|
||||
$arr = [];
|
||||
$arr['type'] = $type;
|
||||
$arr['level_name'] = $level_name;
|
||||
$arr['total_gift_price'] = $total_gift_price;
|
||||
$arr['money'] = $money;
|
||||
$arr['add_time'] = time();
|
||||
$add = db::name('room_subsidy_lucky')->insert($arr);
|
||||
if ($add) {
|
||||
return ['code' => 200, 'msg' => '添加成功', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 201, 'msg' => '添加失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//获取列表
|
||||
public function give_room_subsidy_list($room_number, $uid, $is_delete, $order, $sort, $page, $limit, $start){
|
||||
$map = [];
|
||||
if(!empty($room_number)){
|
||||
$rid = db::name('room')->where('room_number', $room_number)->value('rid');
|
||||
$map[] = ['rid', '=', $rid];
|
||||
}
|
||||
if(!empty($uid)){
|
||||
$map[] = ['uid', '=', $uid];
|
||||
}
|
||||
if(!empty($is_delete)){
|
||||
$map[] = ['is_delete', '=', $is_delete];
|
||||
}
|
||||
if(!empty($start)){
|
||||
$now_time = strtotime($start);
|
||||
$last_week = strtotime('-1 week last sunday', $now_time);
|
||||
$map[] = ['last_week_time', '=', $last_week];
|
||||
}else{
|
||||
$now_time = time();
|
||||
$last_week = strtotime('-1 week last sunday', $now_time);
|
||||
$map[] = ['last_week_time', '=', $last_week];
|
||||
}
|
||||
|
||||
$map[] = ['type', '=', 2];
|
||||
$list = db::name('user_room_week_earnings')->where($map)->order($order, $sort)->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v){
|
||||
$room_info = db::name('room')->find($v['rid']);
|
||||
$v['room_number'] = $room_info['room_number'];
|
||||
$v['room_name'] = mb_convert_encoding(base64_decode($room_info['base64_room_name']), 'UTF-8', 'UTF-8');
|
||||
$user_info = db::name('user')->find($v['uid']);
|
||||
$v['nick_name'] = mb_convert_encoding(base64_decode($user_info['base64_nick_name']), 'UTF-8', 'UTF-8');
|
||||
|
||||
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['count'] = db::name('user_room_week_earnings')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//批量结算
|
||||
public function batch_give_room_subsidy($data){
|
||||
if(empty($data)){
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$gid_list = [];
|
||||
foreach ($data as $k => $v){
|
||||
if(in_array($v['is_delete'], [2])) {
|
||||
return ['code' => 201, 'msg' => '批量结算中包含已发放的', 'data' => null];
|
||||
}
|
||||
$gid_list[] = $v['id'];
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
|
||||
$map = [];
|
||||
$map[] = ['id', 'in', $gid_list];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$list = db::name('user_room_week_earnings')->where($map)->select();
|
||||
if(!empty($list)){
|
||||
foreach ($list as $k => $v){
|
||||
$reslut = model('admin/User')->change_user_money_by_uid($v['uid'], $v['user_earnings'], 1, 35, '房间幸运补贴收益', $v['uid'], 0, $v['rid']);
|
||||
if ($reslut['code'] == 201) {
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => $reslut['msg'], 'data' => null];
|
||||
}
|
||||
$reslut = db::name('user_room_week_earnings')->where('id', $v['id'])->update(['is_delete' => 2, 'update_time' => time()]);
|
||||
if (!$reslut) {
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => $reslut['msg'], 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
return ['code' => 200, 'msg' => "发放成功", 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => "发放失败", 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//补贴详情
|
||||
public function get_give_room_subsidy_info($id){
|
||||
if(empty($id)){
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$user_room_week_earnings = db::name('user_room_week_earnings')->where('id', $id)->find();
|
||||
if(!$user_room_week_earnings){
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $user_room_week_earnings];
|
||||
}
|
||||
|
||||
//修改补贴
|
||||
public function edit_give_room_subsidy($id, $user_earnings){
|
||||
if(empty($id)){
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$user_room_week_earnings = db::name('user_room_week_earnings')->where('id', $id)->find();
|
||||
if(!$user_room_week_earnings){
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
if($user_earnings < 0){
|
||||
return ['code' => 201, 'msg' => '收益不能小于0', 'data' => null];
|
||||
}
|
||||
|
||||
if($user_room_week_earnings['is_delete'] == 2){
|
||||
return ['code' => 201, 'msg' => '该收益已结算,无法编辑', 'data' => null];
|
||||
}
|
||||
|
||||
$update = [];
|
||||
$update['user_earnings'] = $user_earnings;
|
||||
$update['update_time'] = time();
|
||||
$reslut = db::name('user_room_week_earnings')->where('id', $id)->update($update);
|
||||
if($reslut){
|
||||
return ['code' => 200, 'msg' => '编辑成功', 'data' => null];
|
||||
}else{
|
||||
return ['code' => 201, 'msg' => '编辑失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//监控宝箱redis list 剩余宝箱数量 生成
|
||||
//tid 宝箱类型
|
||||
//is_reset 0不重置 1重置
|
||||
public function control_gift_multiple($id = 0, $is_reset = 0)
|
||||
{
|
||||
set_time_limit(0);
|
||||
ini_set('memory_limit', '1024M');
|
||||
$redis = connectionRedis();
|
||||
// dump($id);
|
||||
// dump($is_reset);
|
||||
// exit;
|
||||
$map = [];
|
||||
if (!empty($id)) {
|
||||
$map[] = ['id', '=', $id];
|
||||
}
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$gift_multiple_type_list = db::name('gift_multiple_type')->where($map)->select();
|
||||
$list_len = 0;
|
||||
foreach ($gift_multiple_type_list as $k => $v) {
|
||||
|
||||
$map = [];
|
||||
$map[] = ['pid', '=', $v['id']];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$gift_multiple_rate_list = Db::name('gift_multiple_rate')->where($map)->select();
|
||||
$keyname = "multiple:list:type:" . $v['id'];
|
||||
if ($is_reset == 1) {
|
||||
$redis->del($keyname); //如果重置则删除原队列
|
||||
}
|
||||
//剩余开奖次数少于5000 则补充下一期奖池
|
||||
if ($redis->llen($keyname) < 500) {
|
||||
$insert_data = [];
|
||||
$total_gift_value = 0;
|
||||
|
||||
foreach ($gift_multiple_rate_list as $m => $n) {
|
||||
//更新添加次数
|
||||
for ($q = 0; $q < $n['rate_num']; $q++) {
|
||||
$insert_data[] = $n['multiple'];
|
||||
}
|
||||
}
|
||||
|
||||
shuffle($insert_data);
|
||||
|
||||
if (!empty($gift_multiple_rate_list)) {
|
||||
//插入期日志表
|
||||
$data = [];
|
||||
$data['pid'] = $v['id'];
|
||||
$data['total_num'] = count($insert_data);
|
||||
$data['open_num'] = 0;
|
||||
$data['config_text'] = json_encode($gift_multiple_rate_list);
|
||||
$data['add_time'] = time();
|
||||
$data['update_time'] = time();
|
||||
$bl_id = db::name('gift_multiple_log')->insertGetId($data);
|
||||
foreach ($insert_data as $p => $q) {
|
||||
$insert_data[$p] = $bl_id . '-' . $insert_data[$p];
|
||||
}
|
||||
// shuffle($insert_data);
|
||||
array_unshift($insert_data, $keyname);
|
||||
call_user_func_array([$redis, 'rPush'], $insert_data);
|
||||
}
|
||||
}
|
||||
$list_len = $redis->llen($keyname);
|
||||
//echo date('Y-m-d H:i:s') . " " . $keyname . "宝箱剩余数量:$list_len" . "\r\n";
|
||||
}
|
||||
|
||||
return ['code' => 200, 'msg' => '生成成功', 'data' => "剩余数量: $list_len"];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
153
application/admin/model/NewBox.php
Normal file
153
application/admin/model/NewBox.php
Normal file
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
|
||||
class NewBox extends Model
|
||||
{
|
||||
|
||||
public function get_new_box_list(){
|
||||
$map = [];
|
||||
$map[] = ['a.is_delete', '=', 1];
|
||||
$list = db::name('new_box')
|
||||
->alias('a')
|
||||
->join('yy_gift b', 'a.gid = b.gid')
|
||||
->field('a.*,b.gift_name,b.gift_price,b.base_image')
|
||||
->where($map)
|
||||
->order('a.id', 'desc')->select();
|
||||
foreach($list as &$val) {
|
||||
$val['base_image'] = localpath_to_netpath($val['base_image']);
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('new_box')->alias('a')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function edit_new_box($data)
|
||||
{
|
||||
if(empty($data['total_amount'])) {
|
||||
return ['code' => 201, 'msg' => '请输入金额', 'data' => ''];
|
||||
}
|
||||
if(ceil($data['total_amount']) != $data['total_amount']) {
|
||||
return ['code' => 201, 'msg' => '总金额必须是整数', 'data' => ''];
|
||||
}
|
||||
$total_amount = $data['total_amount'];
|
||||
if(ceil($total_amount/10) != ($total_amount/10)) {
|
||||
return ['code' => 201, 'msg' => '总金额必须是10的倍数', 'data' => ''];
|
||||
}
|
||||
$gid = $data['gid'];
|
||||
if(empty($gid)) {
|
||||
return ['code' => 201, 'msg' => '请选择礼物', 'data' => ''];
|
||||
}
|
||||
$count = Db::name('new_box')->where(['gid' => $gid, 'is_delete' => 1])->where('id','neq', $data['id'])->find();
|
||||
if($count) {
|
||||
return ['code' => 201, 'msg' => '该礼物已配置奖池,请重新选择礼物', 'data' => ''];
|
||||
}
|
||||
$gift_price = Db::name('gift')->where('gid', $gid)->value('gift_price');
|
||||
if($data['total_amount'] < $gift_price) {
|
||||
// return ['code' => 201, 'msg' => '总金额小于礼物价值', 'data' => ''];
|
||||
}
|
||||
$reslut = model('new_box')->isUpdate(true)->save($data);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '编辑失败', 'data' => ''];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '编辑成功', 'data' => ''];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//获取房间信息
|
||||
public function get_new_box_info($tid)
|
||||
{
|
||||
$box_type_info = db::name('new_box')->where(['id' => $tid])->find();
|
||||
if(empty($box_type_info)) {
|
||||
return ['code' => 201, 'msg' => '数据不存在', 'data' => null];
|
||||
}
|
||||
$gift_info = Db::name('gift')->find($box_type_info['gid']);
|
||||
if(empty($gift_info)) {
|
||||
return ['code' => 201, 'msg' => '礼物数据不存在', 'data' => null];
|
||||
}
|
||||
$box_type_info['gift_name'] = $gift_info['gift_name'];
|
||||
$box_type_info['gift_price'] = $gift_info['gift_price'];
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $box_type_info];
|
||||
}
|
||||
|
||||
//开奖期数
|
||||
public function get_new_box_log($nb_id, $status, $page, $page_limit)
|
||||
{
|
||||
$map = [];
|
||||
if($nb_id) {
|
||||
$map[] = ['nb_id', '=', $nb_id];
|
||||
}
|
||||
if($status) {
|
||||
$map[] = ['status', '=', $status];
|
||||
}
|
||||
$list = db::name('new_box_log')
|
||||
->alias('a')
|
||||
->join('yy_gift b', 'a.gid = b.gid')
|
||||
->join('yy_user c', 'a.win_uid = c.uid', 'left')
|
||||
->field('a.*,b.gift_name,b.gift_price,b.base_image,c.base64_nick_name')
|
||||
->where($map)
|
||||
->page($page, $page_limit)
|
||||
->order('a.id', 'desc')->select();
|
||||
foreach($list as &$val) {
|
||||
if($val['base64_nick_name']) {
|
||||
$val['nick_name'] = mb_convert_encoding(base64_decode($val['base64_nick_name']), 'UTF-8', 'UTF-8');
|
||||
} else {
|
||||
$val['nick_name'] = '未中奖';
|
||||
}
|
||||
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('new_box_log')->alias('a')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//开奖记录
|
||||
public function get_user_new_box_log($uid, $nbl_id, $start_time, $end_time, $page, $page_limit)
|
||||
{
|
||||
$map = [];
|
||||
if($nbl_id) {
|
||||
$map[] = ['a.nbl_id', '=', $nbl_id];
|
||||
}
|
||||
if($uid) {
|
||||
$map[] = ['a.uid', '=', $uid];
|
||||
}
|
||||
if($start_time) {
|
||||
$map[] = ['a.add_time', '>=', strtotime($start_time)];
|
||||
}
|
||||
if($end_time) {
|
||||
$map[] = ['a.add_time', '<', strtotime($end_time)];
|
||||
}
|
||||
$list = db::name('user_new_box_log')
|
||||
->alias('a')
|
||||
->join('yy_new_box_log b', 'a.nbl_id = b.id')
|
||||
->join('yy_user c', 'a.uid = c.uid', 'left')
|
||||
->join('yy_gift d', 'b.gid = d.gid', 'left')
|
||||
->field('a.*,d.gift_name,d.base_image,c.base64_nick_name,c.head_pic')
|
||||
->where($map)
|
||||
->page($page, $page_limit)
|
||||
->order('a.id', 'desc')->select();
|
||||
foreach($list as &$val) {
|
||||
$val['nick_name'] = mb_convert_encoding(base64_decode($val['base64_nick_name']), 'UTF-8', 'UTF-8');
|
||||
$val['head_pic'] = localpath_to_netpath($val['head_pic']);
|
||||
$val['base_image'] = localpath_to_netpath($val['base_image']);
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('user_new_box_log')->alias('a')->where($map)->count();
|
||||
$total_pay_amount = db::name('user_new_box_log')->alias('a')->where($map)->sum('pay_amount');
|
||||
$totalRowData['pay_amount'] = $total_pay_amount;
|
||||
$data['totalData'] = $totalRowData;
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
}
|
||||
251
application/admin/model/Nobility.php
Normal file
251
application/admin/model/Nobility.php
Normal file
@@ -0,0 +1,251 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class Nobility extends Model
|
||||
{
|
||||
//列表
|
||||
public function get_nobility_list($order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
|
||||
$list = db::name('nobility')->where($map)->order($order, $sort)->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['image'] = localpath_to_netpath($v['image']);
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('nobility')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
//编辑
|
||||
public function edit_nobility($data)
|
||||
{
|
||||
if (empty($data)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$nobility_info = db::name('nobility')->find($data['lid']);
|
||||
if (empty($nobility_info)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$update_data = [];
|
||||
// $update_data['level'] = $data['level'];
|
||||
$update_data['name'] = $data['name'];
|
||||
$update_data['image'] = $data['image'];
|
||||
// $update_data['change_value'] = $data['change_value'];
|
||||
// $update_data['images'] = $data['images'];
|
||||
$update_data['pay_price'] = $data['pay_price'];
|
||||
$update_data['renew_price'] = $data['renew_price'];
|
||||
$update_data['pay_coin'] = $data['pay_coin'];
|
||||
$update_data['renew_coin'] = $data['renew_coin'];
|
||||
// $update_data['play_image'] = $data['play_image'];
|
||||
// $update_data['is_public_server'] = $data['is_public_server'];
|
||||
// $update_data['is_kick'] = $data['is_kick'];
|
||||
// $update_data['is_show_rank'] = $data['is_show_rank'];
|
||||
// $update_data['is_freedom_micro'] = $data['is_freedom_micro'];
|
||||
// $update_data['is_look_visitor'] = $data['is_look_visitor'];
|
||||
$update_data['day_num'] = $data['day_num'];
|
||||
$update_data['update_time'] = time();
|
||||
$reslut = db::name('nobility')->where(['lid' => $data['lid']])->update($update_data);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '修改成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//获取信息
|
||||
public function nobility_info($lid)
|
||||
{
|
||||
if (empty($lid)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$gift_info = db::name('nobility')->where(['lid' => $lid])->find();
|
||||
$gift_info['image'] = localpath_to_netpath($gift_info['image']);
|
||||
// $gift_info['images'] = localpath_to_netpath($gift_info['images']);
|
||||
// $gift_info['http_play_image'] = localpath_to_netpath($gift_info['play_image']);
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $gift_info];
|
||||
}
|
||||
|
||||
//权限列表
|
||||
public function get_nobility_power_list($order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
$map = [];
|
||||
|
||||
$list = db::name('nobility_power')->where($map)->order($order, $sort)->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['image'] = localpath_to_netpath($v['image']);
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('nobility_power')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//获取信息
|
||||
public function nobility_power_info($id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$gift_info = db::name('nobility_power')->where(['id' => $id])->find();
|
||||
$gift_info['image'] = localpath_to_netpath($gift_info['image']);
|
||||
$gift_info['images'] = localpath_to_netpath($gift_info['images']);
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $gift_info];
|
||||
}
|
||||
|
||||
//编辑
|
||||
public function edit_nobility_power($data)
|
||||
{
|
||||
if (empty($data)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$nobility_info = db::name('nobility_power')->find($data['id']);
|
||||
if (empty($nobility_info)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$update_data = [];
|
||||
$update_data['name'] = $data['name'];
|
||||
$update_data['image'] = $data['image'];
|
||||
$update_data['images'] = $data['images'];
|
||||
$update_data['content'] = $data['content'];
|
||||
$update_data['update_time'] = time();
|
||||
$reslut = db::name('nobility_power')->where(['id' => $data['id']])->update($update_data);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '修改成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//用户爵位列表
|
||||
public function get_user_nobility_list($order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['a.is_delete', '=', 1];
|
||||
$map[] = ['a.status', '=', 1];
|
||||
$list = db::name('user_nobility')->alias('a')->join('yy_user b', 'a.uid = b.uid')->join('yy_nobility c', 'c.lid = a.lid')->field('a.id, b.uid, b.nick_name, b.base64_nick_name, b.head_pic, c.name, a.add_time, a.update_time')->where($map)->order($order, $sort)->page($page, $limit)->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 = [];
|
||||
$data['count'] = db::name('user_nobility')->alias('a')->join('yy_user b', 'a.uid = b.uid')->join('yy_nobility c', 'c.lid = a.lid')->field('a.id')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//列表
|
||||
public function get_nobility_decorate_list($lid, $order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['a.is_delete', '=', 1];
|
||||
$map[] = ['a.lid', '=', $lid];
|
||||
$banner_list = db::name('nobility_decorate')->alias('a')->join('yy_decorate b', 'a.did = b.did')->field('a.*,b.title,b.type,b.base_image')->where($map)->order($order, $sort)->select();
|
||||
foreach ($banner_list as $k => &$v){
|
||||
$v['base_image'] = localpath_to_netpath($v['base_image']);
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('nobility_decorate')->alias('a')->join('yy_decorate b', 'a.did = b.did')->field('a.*,b.title,b.type,b.base_image')->where($map)->count();
|
||||
$data['list'] = $banner_list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//获取
|
||||
public function nobility_decorate_info($id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$report_type = db::name('nobility_decorate')->find($id);
|
||||
$report_type['decorate_id'] = $report_type['did'];
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $report_type];
|
||||
}
|
||||
|
||||
//添加
|
||||
public function add_nobility_decorate($lid, $did, $day_num)
|
||||
{
|
||||
if(empty($lid) || empty($did)){
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
// if($day_num < 1){
|
||||
// return ['code' => 201, 'msg' => '天数不能小于1天', 'data' => null];
|
||||
// }
|
||||
|
||||
$decorate_info = db::name('decorate')->where('did', $did)->find();
|
||||
// if($decorate_info['type'] == 2){
|
||||
// $type = 4;
|
||||
// }else if($decorate_info['type'] == 2){
|
||||
// $type = 2;
|
||||
// }else if($decorate_info['type'] == 3){
|
||||
// $type = 3;
|
||||
// }elseif($decorate_info['type'] == 4){
|
||||
// $type = 6;
|
||||
// }
|
||||
|
||||
$arr = [];
|
||||
$arr['lid'] = $lid;
|
||||
$arr['did'] = $did;
|
||||
$arr['type'] = $decorate_info['type'];
|
||||
// $arr['day_num'] = $day_num;
|
||||
$arr['add_time'] = time();
|
||||
$arr['update_time'] = time();
|
||||
$add = db::name('nobility_decorate')->insert($arr);
|
||||
if ($add) {
|
||||
return ['code' => 200, 'msg' => '添加成功', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 201, 'msg' => '添加失败', 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//修改
|
||||
public function edit_nobility_decorate($id, $did, $day_num = 0)
|
||||
{
|
||||
if (empty($id)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
// if($day_num < 1){
|
||||
// return ['code' => 201, 'msg' => '天数不能小于1天', 'data' => null];
|
||||
// }
|
||||
|
||||
$decorate_info = db::name('decorate')->where('did', $did)->find();
|
||||
// if($decorate_info['type'] == 1){
|
||||
// $type = 4;
|
||||
// }else if($decorate_info['type'] == 2){
|
||||
// $type = 2;
|
||||
// }else if($decorate_info['type'] == 3){
|
||||
// $type = 3;
|
||||
// }elseif($decorate_info['type'] == 4){
|
||||
// $type = 6;
|
||||
// }
|
||||
$type = $decorate_info['type'];
|
||||
$upd = db::name('nobility_decorate')->where(['id' => $id])->update(['did' => $did, 'type' => $type, 'day_num' => $day_num, 'update_time' => time()]);
|
||||
if ($upd) {
|
||||
return ['code' => 200, 'msg' => '修改成功', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//删除
|
||||
public function del_nobility_decorate($id)
|
||||
{
|
||||
$del = db::name('nobility_decorate')->where(['id' => $id])->update(['is_delete' => 2, 'update_time' => time()]);
|
||||
if ($del) {
|
||||
return ['code' => 200, 'msg' => '删除成功', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 201, 'msg' => '删除失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
419
application/admin/model/Play.php
Normal file
419
application/admin/model/Play.php
Normal file
@@ -0,0 +1,419 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class Play extends Model
|
||||
{
|
||||
//游戏列表
|
||||
public function game_list($gid, $game_name, $is_show, $order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
$map = [];
|
||||
if (!empty($gid)) {
|
||||
$map[] = ['gid', '=', $gid];
|
||||
}
|
||||
if (!empty($game_name)) {
|
||||
$map[] = ['game_name', 'like', '%' . $game_name . '%'];
|
||||
}
|
||||
if (!empty($is_show)) {
|
||||
$map[] = ['is_show', '=', $is_show];
|
||||
}
|
||||
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$list = db::name('game')->where($map)->order($order, $sort)->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
$game_level = db::name('game_skill_level')->field('game_level_name')->where(['gid' => $v['gid']])->select();
|
||||
$str = '';
|
||||
foreach ($game_level as $m => $n) {
|
||||
$str .= $n['game_level_name'] . ',';
|
||||
}
|
||||
$v['game_level_name'] = $str;
|
||||
$v['game_ico1'] = localpath_to_netpath($v['game_ico1']);
|
||||
$v['game_ico2'] = localpath_to_netpath($v['game_ico2']);
|
||||
$v['game_ico'] = localpath_to_netpath($v['game_ico']);
|
||||
$v['cover_image'] = localpath_to_netpath($v['cover_image']);
|
||||
$v['skill_image'] = localpath_to_netpath($v['skill_image']);
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('game')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//编辑游戏
|
||||
public function edit_game($data)
|
||||
{
|
||||
if (empty($data)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$game = db::name('game')->find($data['gid']);
|
||||
if (empty($game)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$update_data = [];
|
||||
$update_data['game_name'] = $data['game_name'];
|
||||
$update_data['game_ico'] = $data['game_ico'];
|
||||
$update_data['game_ico1'] = $data['game_ico1'];
|
||||
$update_data['game_ico2'] = $data['game_ico2'];
|
||||
$update_data['cover_image'] = $data['cover_image'];
|
||||
$update_data['skill_image'] = $data['skill_image'];
|
||||
$update_data['is_show'] = $data['is_show'];
|
||||
$update_data['sort'] = $data['sort'];
|
||||
$update_data['update_time'] = time();
|
||||
$reslut = db::name('game')->where(['gid' => $data['gid']])->update($update_data);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '修改成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
//添加游戏
|
||||
public function add_game($data)
|
||||
{
|
||||
|
||||
$update_data['game_name'] = $data['game_name'];
|
||||
$update_data['game_ico'] = $data['game_ico'];
|
||||
$update_data['game_ico1'] = $data['game_ico1'];
|
||||
$update_data['game_ico2'] = $data['game_ico2'];
|
||||
$update_data['cover_image'] = $data['cover_image'];
|
||||
$update_data['skill_image'] = $data['skill_image'];
|
||||
$update_data['is_show'] = $data['is_show'];
|
||||
$update_data['sort'] = $data['sort'];
|
||||
$update_data['update_time'] = time();
|
||||
$update_data['add_time'] = time();
|
||||
$reslut = db::name('game')->insert($update_data);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '添加失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '添加成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//获取游戏信息
|
||||
public function game_info($gid)
|
||||
{
|
||||
if (empty($gid)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$info = db::name('game')->where(['gid' => $gid])->find();
|
||||
$info['http_game_ico'] = localpath_to_netpath($info['game_ico']);
|
||||
$info['http_game_ico1'] = localpath_to_netpath($info['game_ico1']);
|
||||
$info['http_game_ico2'] = localpath_to_netpath($info['game_ico2']);
|
||||
$info['http_cover_image'] = localpath_to_netpath($info['cover_image']);
|
||||
$info['http_skill_image'] = localpath_to_netpath($info['skill_image']);
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $info];
|
||||
}
|
||||
|
||||
//删除游戏
|
||||
public function del_game($gid)
|
||||
{
|
||||
if (empty($gid)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$reslut = db::name('game')->where(['gid' => $gid])->update(['is_delete' => 2, 'delete_time' => time()]);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '删除失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '删除成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//游戏等级列表
|
||||
public function game_skill_level_list($lid, $gid, $game_level_name, $order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
$map = [];
|
||||
if (!empty($lid)) {
|
||||
$map[] = ['a.lid', '=', $lid];
|
||||
}
|
||||
if (!empty($game_level_name)) {
|
||||
$map[] = ['a.game_level_name', 'like', '%' . $game_level_name . '%'];
|
||||
}
|
||||
if (!empty($gid)) {
|
||||
$map[] = ['a.gid', '=', $gid];
|
||||
}
|
||||
|
||||
$map[] = ['a.is_delete', '=', 1];
|
||||
$list = db::name('game_skill_level')->where($map)->alias('a')
|
||||
->join('yy_game b', 'a.gid = b.gid')
|
||||
->field(
|
||||
'a.*,b.game_name'
|
||||
)->where($map)->order($order, $sort)->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['gid_game_name'] = $v['gid'] . '-' . $v['game_name'];
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('game_skill_level')->where($map)->alias('a')
|
||||
->join('yy_game b', 'a.gid = b.gid')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//编辑游戏等级
|
||||
public function edit_game_skill_level($data)
|
||||
{
|
||||
if (empty($data)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$game = db::name('game_skill_level')->find($data['lid']);
|
||||
if (empty($game)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$update_data = [];
|
||||
$update_data['gid'] = $data['gid'];
|
||||
$update_data['game_level_name'] = $data['game_level_name'];
|
||||
$update_data['update_time'] = time();
|
||||
$reslut = db::name('game_skill_level')->where(['lid' => $data['lid']])->update($update_data);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '修改成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
//添加游戏等级
|
||||
public function add_game_skill_level($data)
|
||||
{
|
||||
$add_data = [];
|
||||
$update_data['gid'] = $data['gid'];
|
||||
$update_data['game_level_name'] = $data['game_level_name'];
|
||||
$update_data['update_time'] = time();
|
||||
$update_data['add_time'] = time();
|
||||
$reslut = db::name('game_skill_level')->insert($update_data);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '添加失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '添加成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//获取游戏等级信息
|
||||
public function game_skill_level_info($lid)
|
||||
{
|
||||
if (empty($lid)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$info = db::name('game_skill_level')->where(['lid' => $lid])->find();
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $info];
|
||||
}
|
||||
|
||||
//删除 游戏等级
|
||||
public function del_game_skill_level($lid)
|
||||
{
|
||||
if (empty($lid)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$reslut = db::name('game_skill_level')->where(['lid' => $lid])->update(['is_delete' => 2, 'delete_time' => time()]);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '删除失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '删除成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//陪玩主播 列表
|
||||
public function player_list($uid, $nick_name, $sex, $special_uid, $gid, $real_name, $is_top, $is_recommend, $is_business, $status, $order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
$map = [];
|
||||
if (!empty($uid)) {
|
||||
$map[] = ['a.uid', '=', $uid];
|
||||
}
|
||||
if (!empty($nick_name)) {
|
||||
$map[] = ['b.nick_name', 'like', '%' . $nick_name . '%'];
|
||||
}
|
||||
if (!empty($sex)) {
|
||||
$map[] = ['b.sex', '=', $sex];
|
||||
}
|
||||
if (!empty($special_uid)) {
|
||||
$map[] = ['b.special_uid', '=', $special_uid];
|
||||
}
|
||||
if (!empty($gid)) {
|
||||
$map[] = ['a.gid', '=', $gid];
|
||||
}
|
||||
if (!empty($real_name)) {
|
||||
$map[] = ['b.real_name', 'like', '%' . $real_name . '%'];
|
||||
}
|
||||
if (!empty($is_top)) {
|
||||
$map[] = ['a.is_top', '=', $is_top];
|
||||
}
|
||||
if (!empty($is_recommend)) {
|
||||
$map[] = ['a.is_recommend', '=', $is_recommend];
|
||||
}
|
||||
if (!empty($is_business)) {
|
||||
$map[] = ['a.is_business', '=', $is_business];
|
||||
}
|
||||
if (!empty($status)) {
|
||||
$map[] = ['a.status', '=', $status];
|
||||
}
|
||||
|
||||
$list = db::name('user_player')
|
||||
->alias('a')
|
||||
->join('yy_user b', 'a.uid = b.uid')
|
||||
->field('a.*,b.nick_name,b.sex,b.special_uid,b.real_name')
|
||||
->where($map)->order($order, $sort)->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
$game_name = db::name('game')->where(['gid' => $v['gid']])->value('game_name');
|
||||
$game_skill_level = db::name('game_skill_level')->where(['lid' => $v['lid']])->value('game_level_name');
|
||||
$v['game_level_name'] = $game_name . '-' . $game_skill_level;
|
||||
$v['cover_image'] = localpath_to_netpath($v['cover_image']);
|
||||
$v['skill_image'] = localpath_to_netpath($v['skill_image']);
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('user_player')->alias('a')
|
||||
->join('yy_user b', 'a.uid = b.uid')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//编辑 陪玩主播
|
||||
public function edit_player($data)
|
||||
{
|
||||
if (empty($data)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$info = db::name('user_player')->find($data['pid']);
|
||||
if (empty($info)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$update_data = [];
|
||||
$update_data['price'] = $data['price'];
|
||||
$update_data['skill_image'] = $data['skill_image'];
|
||||
$update_data['cover_image'] = $data['cover_image'];
|
||||
$update_data['introduction'] = $data['introduction'];
|
||||
$update_data['is_top'] = $data['is_top'];
|
||||
$update_data['is_recommend'] = $data['is_recommend'];
|
||||
$update_data['is_business'] = $data['is_business'];
|
||||
$update_data['flag'] = $data['flag'];
|
||||
$update_data['remarks'] = $data['remarks'];
|
||||
$update_data['status'] = $data['status'];
|
||||
$update_data['update_time'] = time();
|
||||
if ($data['status'] != $info['status']) {
|
||||
$update_data['deal_time'] = time();
|
||||
}
|
||||
$user_info = db::name('user')->find($info['uid']);
|
||||
if ($update_data['status'] == 2) {
|
||||
$player_game_list = explode(',', $user_info['player_game_list']);
|
||||
$player_game_list[] = $info['gid'];
|
||||
$player_game_list = array_unique($player_game_list);
|
||||
$user_data = [];
|
||||
$user_data['is_player'] = 2;
|
||||
$user_data['player_game_list'] = trim(implode(',', $player_game_list), ',');
|
||||
db::name('user')->where('uid', $info['uid'])->update($user_data);
|
||||
} else {
|
||||
$player_game_list = explode(',', $user_info['player_game_list']);
|
||||
if (!empty($player_game_list)) {
|
||||
$key_array = array_keys($player_game_list, $info['gid']);
|
||||
if (!empty($key_array)) {
|
||||
unset($player_game_list[$key_array[0]]);
|
||||
$player_game_list = array_unique($player_game_list);
|
||||
$user_data = [];
|
||||
$user_data['is_player'] = 2;
|
||||
$user_data['player_game_list'] = trim(implode(',', $player_game_list), ',');
|
||||
db::name('user')->where('uid', $info['uid'])->update($user_data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
$reslut = db::name('user_player')->where(['pid' => $data['pid']])->update($update_data);
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '修改成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//获取 陪玩主播 信息
|
||||
public function player_info($pid)
|
||||
{
|
||||
if (empty($pid)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$info = db::name('user_player')->where(['pid' => $pid])->find();
|
||||
$info['cover_image'] = localpath_to_netpath($info['cover_image']);
|
||||
$info['skill_image'] = localpath_to_netpath($info['skill_image']);
|
||||
$info['sound'] = localpath_to_netpath($info['sound']);
|
||||
|
||||
$user = db::name('user')->where(['uid' => $info['uid']])->find();
|
||||
$info['nickname_real_name'] = $user['nick_name'] . '-' . $user['real_name'];
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $info];
|
||||
}
|
||||
|
||||
//删除 陪玩主播
|
||||
public function del_player($pid)
|
||||
{
|
||||
if (empty($pid)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$reslut = db::name('user_player')->where(['pid' => $pid])->delete();
|
||||
if (!$reslut) {
|
||||
return ['code' => 201, 'msg' => '删除失败', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 200, 'msg' => '删除成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//陪玩订单 列表
|
||||
public function player_order_list($order_sn, $uid, $player_uid, $price, $service_rate, $status, $is_over, $order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
|
||||
$map = [];
|
||||
if (!empty($order_sn)) {
|
||||
$map[] = ['order_sn', '=', $order_sn];
|
||||
}
|
||||
|
||||
if (!empty($uid)) {
|
||||
$map[] = ['uid', '=', $uid];
|
||||
}
|
||||
if (!empty($player_uid)) {
|
||||
$map[] = ['player_uid', '=', $player_uid];
|
||||
}
|
||||
if (!empty($price)) {
|
||||
$map[] = ['price', '=', $price];
|
||||
}
|
||||
if (!empty($service_rate)) {
|
||||
$map[] = ['service_rate', '=', $service_rate];
|
||||
}
|
||||
if (!empty($status)) {
|
||||
$map[] = ['status', '=', $status];
|
||||
}
|
||||
if (!empty($is_over)) {
|
||||
$map[] = ['is_over', '=', $is_over];
|
||||
}
|
||||
if (empty($order)) {
|
||||
$order = 'oid';
|
||||
}
|
||||
if (empty($sort)) {
|
||||
$sort = 'desc';
|
||||
}
|
||||
$list = db::name('user_player_order')->where($map)->order($order, $sort)->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['game_name'] = db::name('game')->where(['gid' => $v['gid']])->value('game_name');
|
||||
$u_nickname = db::name('user')->where(['uid' => $v['uid']])->value('nick_name');
|
||||
$p_nickname = db::name('user')->where(['uid' => $v['player_uid']])->value('nick_name');
|
||||
$v['uid_nickname'] = $v['uid'] . '-' . $u_nickname;
|
||||
$v['player_uid_nickname'] = $v['player_uid'] . '-' . $p_nickname;
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('user_player_order')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
|
||||
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//获取 陪玩订单 信息
|
||||
public function player_order_info($oid)
|
||||
{
|
||||
if (empty($oid)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$info = db::name('user_player_order')->where(['oid' => $oid])->find();
|
||||
$u_nickname = db::name('user')->where(['uid' => $info['uid']])->value('nick_name');
|
||||
$p_nickname = db::name('user')->where(['uid' => $info['player_uid']])->value('nick_name');
|
||||
$info['uid_nickname'] = $info['uid'] . '-' . $u_nickname;
|
||||
$info['player_uid_nickname'] = $info['player_uid'] . '-' . $p_nickname;
|
||||
$info['game_name'] = db::name('game')->where(['gid' => $info['gid']])->value('game_name');
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $info];
|
||||
}
|
||||
}
|
||||
118
application/admin/model/Relation.php
Normal file
118
application/admin/model/Relation.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
|
||||
use think\Db;
|
||||
|
||||
class Relation extends AdminComModel
|
||||
{
|
||||
//获取数据
|
||||
public function get_list($page = 1, $page_limit = 15)
|
||||
{
|
||||
$list = Db::name('relation')->where('is_delete', 1 )
|
||||
->order('id', 'desc')
|
||||
->page($page, $page_limit)->select();
|
||||
$count = Db::name('relation')->count();
|
||||
|
||||
$data = [];
|
||||
$data['code'] = 0;
|
||||
$data['msg'] = '获取数据成功';
|
||||
$data['data'] = $list;
|
||||
$data['count'] = $count;
|
||||
return json($data);
|
||||
}
|
||||
//添加
|
||||
public function add($name, $color, $day)
|
||||
{
|
||||
if (empty($name) || empty($color) || empty($day)) {
|
||||
return ['code' => 201, 'msg' => '参数错误', 'data' => null];
|
||||
}
|
||||
$type = input('type', 0);
|
||||
if(empty($type)) {
|
||||
return ['code' => 201, 'msg' => '请选择类型', 'data' => null];
|
||||
}
|
||||
$info = Db::name('relation')
|
||||
->where('name', $name)
|
||||
->where('is_delete', 1)
|
||||
->where('type', $type)
|
||||
->find();
|
||||
if ($info) {
|
||||
return ['code' => 201, 'msg' => '话题已存在', 'data' => null];
|
||||
}
|
||||
$data = $this->append_add_update_time([
|
||||
'name' => $name,
|
||||
'color' => $color,
|
||||
'day' => $day,
|
||||
'type' => $type,
|
||||
]);
|
||||
try {
|
||||
Db::name('relation')->insert($data);
|
||||
return ['code' => 200, 'msg' => '添加成功', 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
return ['code' => 201, 'msg' => '添加失败', 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
//获取信息
|
||||
public function get_info($id)
|
||||
{
|
||||
$info = Db::name('relation')->find($id);
|
||||
if (empty($info)) {
|
||||
return ['code' => 201, 'msg' => '数据不存在', 'data' => null];
|
||||
}
|
||||
return ['code' => 200, 'msg' => '获取数据成功', 'data' => $info];
|
||||
}
|
||||
//编辑
|
||||
public function edit($id, $name, $color, $day)
|
||||
{
|
||||
if (empty($id)) {
|
||||
return ['code' => 201, 'msg' => '参数ID错误', 'data' => null];
|
||||
}
|
||||
if (empty($name) || empty($color) || empty($day)) {
|
||||
return ['code' => 201, 'msg' => '参数错误', 'data' => null];
|
||||
}
|
||||
$type = input('type', 0);
|
||||
if(empty($type)) {
|
||||
return ['code' => 201, 'msg' => '请选择类型', 'data' => null];
|
||||
}
|
||||
$info = Db::name('relation')
|
||||
->where('name', $name)
|
||||
->where('is_delete', 1)
|
||||
->where('id', 'neq', $id)
|
||||
->where('type', $type)
|
||||
->find();
|
||||
if ($info) {
|
||||
return ['code' => 201, 'msg' => '话题已存在', 'data' => null];
|
||||
}
|
||||
$result = Db::name('relation')->where('id', $id)
|
||||
->update([
|
||||
'name' => $name,
|
||||
'color' => $color,
|
||||
'day' => $day,
|
||||
'update_time' => time(),
|
||||
'type' => $type,
|
||||
|
||||
]);
|
||||
if ($result) {
|
||||
return ['code' => 200, 'msg' => '修改成功', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
//删除
|
||||
public function del($id)
|
||||
{
|
||||
$info = Db::name('relation')->find( $id);
|
||||
if (empty($info)) {
|
||||
return ['code' => 201, 'msg' => '数据不存在', 'data' => null];
|
||||
}
|
||||
$result = Db::name('relation')->where('id', $id)
|
||||
->update(['is_delete' => 2, 'update_time' => time()]);
|
||||
if ($result) {
|
||||
return ['code' => 200, 'msg' => '删除成功', 'data' => null];
|
||||
}
|
||||
return ['code' => 201, 'msg' => '删除失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
30
application/admin/model/ReloadDb.php
Normal file
30
application/admin/model/ReloadDb.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
|
||||
use think\Db;
|
||||
|
||||
class ReloadDb
|
||||
{
|
||||
private static $time = null;
|
||||
|
||||
/**
|
||||
* 检测或执行主动重连
|
||||
* @author andy3513
|
||||
* @param int $timeout 超时时间
|
||||
* @param array $config 连接参数
|
||||
*/
|
||||
public static function init($timeout = 7200,$config = []){
|
||||
$time = time();
|
||||
if(null === self::$time){
|
||||
self::$time = $time;
|
||||
}
|
||||
$exprie = $time - self::$time;
|
||||
if($exprie >= $timeout){
|
||||
Db::connect($config, true);
|
||||
self::$time = $time;
|
||||
}
|
||||
}
|
||||
}
|
||||
149
application/admin/model/Report.php
Normal file
149
application/admin/model/Report.php
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class Report extends Model
|
||||
{
|
||||
//获取举报列表
|
||||
public function report_list($uid, $to_uid, $nick_name, $to_nick_name, $order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
$map = [];
|
||||
if (!empty($uid)) {
|
||||
$map[] = ['a.uid', '=', $uid];
|
||||
}
|
||||
if (!empty($to_uid)) {
|
||||
$map[] = ['a.to_uid', '=', $to_uid];
|
||||
}
|
||||
if (!empty($nick_name)) {
|
||||
$map[] = ['b.nick_name', 'like', '%' . $nick_name . '%'];
|
||||
}
|
||||
$list = db::name('user_report')
|
||||
->alias('a')->join('yy_user b', 'a.uid = b.uid')
|
||||
->field('a.*,b.nick_name')->where($map)->order($order, $sort)->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
$list[$k]['user_nick_name'] = $v['uid'] . '-' . $v['nick_name'];
|
||||
$to_nick_name = db::name('user')->where(['uid' => $v['to_uid']])->value('nick_name');
|
||||
$list[$k]['to_nick_name'] = $v['to_uid'] . '-' . $to_nick_name;
|
||||
$list[$k]['to_nick_name'] = $v['to_uid'] . '-' . $to_nick_name;
|
||||
$list[$k]['type_name'] = db::name('report_type')->where(['id' => $v['type_id']])->value('type_name');
|
||||
$image_data = explode(',', $v['image']);
|
||||
$v['image_list'] = [];
|
||||
if (!empty($image_data)) {
|
||||
foreach ($image_data as $m => $n) {
|
||||
$v['image_list'][] = localpath_to_netpath($n);
|
||||
}
|
||||
}
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('user_report')->alias('a')->join('yy_user b', 'a.uid = b.uid')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//获取举报详情
|
||||
public function report_info($rid)
|
||||
{
|
||||
if (empty($rid)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$room_type_info = db::name('user_report')->find($rid);
|
||||
$room_type_info['uid_name'] = db::name('user')->where(['uid' => $room_type_info['uid']])->value('nick_name');
|
||||
$room_type_info['to_uid_name'] = db::name('user')->where(['uid' => $room_type_info['to_uid']])->value('nick_name');
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $room_type_info];
|
||||
}
|
||||
|
||||
//修改举报信息
|
||||
public function edit_user_info($rid, $status)
|
||||
{
|
||||
if (empty($rid)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$upd = db::name('user_report')->where(['rid' => $rid])->update(['status' => $status, 'update_time' => time(), 'deal_time' => time()]);
|
||||
if ($upd) {
|
||||
return ['code' => 200, 'msg' => '修改成功', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//删除举报信息
|
||||
public function del_Report($rid)
|
||||
{
|
||||
$del = db::name('user_report')->where(['rid' => $rid])->delete();
|
||||
if ($del) {
|
||||
return ['code' => 200, 'msg' => '删除成功', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 201, 'msg' => '删除失败', 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//举报类型 列表
|
||||
public function report_type_list($order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
|
||||
$banner_list = db::name('report_type')->where($map)->order($order, $sort)->select();
|
||||
$data = [];
|
||||
$data['count'] = db::name('report_type')->where($map)->count();
|
||||
$data['list'] = $banner_list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//获取举报类型
|
||||
public function report_type_info($id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$report_type = db::name('report_type')->find($id);
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $report_type];
|
||||
}
|
||||
|
||||
//添加举报类型
|
||||
public function add_report_type($type_name)
|
||||
{
|
||||
$arr = [];
|
||||
$arr['type_name'] = $type_name;
|
||||
$arr['add_time'] = time();
|
||||
$arr['update_time'] = time();
|
||||
$add = db::name('report_type')->insert($arr);
|
||||
if ($add) {
|
||||
return ['code' => 200, 'msg' => '添加成功', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 201, 'msg' => '添加失败', 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//修改举报类型
|
||||
public function edit_report_type($id, $type_name)
|
||||
{
|
||||
if (empty($id)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$upd = db::name('report_type')->where(['id' => $id])->update(['type_name' => $type_name, 'update_time' => time()]);
|
||||
if ($upd) {
|
||||
return ['code' => 200, 'msg' => '修改成功', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//删除举报类型
|
||||
public function del_report_type($id)
|
||||
{
|
||||
$del = db::name('report_type')->where(['id' => $id])->update(['is_delete' => 2, 'delete_time' => time()]);
|
||||
if ($del) {
|
||||
return ['code' => 200, 'msg' => '删除成功', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 201, 'msg' => '删除失败', 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
1439
application/admin/model/Room.php
Normal file
1439
application/admin/model/Room.php
Normal file
File diff suppressed because it is too large
Load Diff
383
application/admin/model/Sprite.php
Normal file
383
application/admin/model/Sprite.php
Normal file
@@ -0,0 +1,383 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class Sprite extends Model
|
||||
{
|
||||
//列表
|
||||
public function get_monster_list($order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
|
||||
$list = db::name('Sprite')->order($order, $sort)->page($page, $limit)->select();
|
||||
$total_num = db::name('Sprite')->sum('num');
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['rate'] = round($v['num']/$total_num, 6)*100;
|
||||
$v['rate'] = $v['rate'].'%';
|
||||
$gift_info = db::name('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'];
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('Sprite')->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//编辑
|
||||
public function edit_monster($data)
|
||||
{
|
||||
if (empty($data)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$monster_info = db::name('Sprite')->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['gid'] = $data['gid'];
|
||||
$update_data['num'] = $data['num'];
|
||||
$update_data['update_time'] = time();
|
||||
$reslut = db::name('Sprite')->where(['id' => $data['id']])->update($update_data);
|
||||
if (!$reslut) {
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return ['code' => 200, 'msg' => '修改成功', 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
dump($e);
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//获取信息
|
||||
public function get_monster_info($id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$monster_info = db::name('Sprite')->where(['id' => $id])->find();
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $monster_info];
|
||||
}
|
||||
|
||||
|
||||
//列表
|
||||
public function get_monster_multiple_list($order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
|
||||
$list = db::name('sprite_multiple')->order($order, $sort)->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('sprite_multiple')->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//编辑
|
||||
public function edit_monster_multiple($data)
|
||||
{
|
||||
if (empty($data)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$monster_info = db::name('sprite_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['update_time'] = time();
|
||||
$reslut = db::name('sprite_multiple')->where(['id' => $data['id']])->update($update_data);
|
||||
if (!$reslut) {
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return ['code' => 200, 'msg' => '修改成功', 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
dump($e);
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//获取信息
|
||||
public function get_monster_multiple_info($id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$monster_info = db::name('sprite_multiple')->where(['id' => $id])->find();
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $monster_info];
|
||||
}
|
||||
|
||||
|
||||
//列表
|
||||
public function get_monster_log($order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
|
||||
$list = db::name('sprite_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){
|
||||
if($v['is_evil_wind'] == 2){
|
||||
$v['type_name'] = db::name('sprite')->where('id', $v['win_type'])->value('type_name');
|
||||
$v['wind_type_name'] = '单号';
|
||||
}else{
|
||||
if($v['win_type'] == 1){
|
||||
$where = [];
|
||||
$where[] = ['id', 'in', [1,2]];
|
||||
$type_name_arr = db::name('sprite')->where($where)->column('type_name');
|
||||
$type_name_arr = implode(',', $type_name_arr);
|
||||
$v['type_name'] = $type_name_arr;
|
||||
$v['wind_type_name'] = '双号';
|
||||
}else if($v['win_type'] == 2){
|
||||
$where = [];
|
||||
$where[] = ['id', 'in', [1,3]];
|
||||
$type_name_arr = db::name('sprite')->where($where)->column('type_name');
|
||||
$type_name_arr = implode(',', $type_name_arr);
|
||||
$v['type_name'] = $type_name_arr;
|
||||
$v['wind_type_name'] = '双号';
|
||||
}else if($v['win_type'] == 3){
|
||||
$where = [];
|
||||
$where[] = ['id', 'in', [1,4]];
|
||||
$type_name_arr = db::name('sprite')->where($where)->column('type_name');
|
||||
$type_name_arr = implode(',', $type_name_arr);
|
||||
$v['type_name'] = $type_name_arr;
|
||||
$v['wind_type_name'] = '双号';
|
||||
}else if($v['win_type'] == 4){
|
||||
$where = [];
|
||||
$where[] = ['id', 'in', [1,5]];
|
||||
$type_name_arr = db::name('sprite')->where($where)->column('type_name');
|
||||
$type_name_arr = implode(',', $type_name_arr);
|
||||
$v['type_name'] = $type_name_arr;
|
||||
$v['wind_type_name'] = '双号';
|
||||
}else if($v['win_type'] == 5){
|
||||
$where = [];
|
||||
$where[] = ['id', 'in', [2,3]];
|
||||
$type_name_arr = db::name('sprite')->where($where)->column('type_name');
|
||||
$type_name_arr = implode(',', $type_name_arr);
|
||||
$v['type_name'] = $type_name_arr;
|
||||
$v['wind_type_name'] = '双号';
|
||||
}else if($v['win_type'] == 6){
|
||||
$where = [];
|
||||
$where[] = ['id', 'in', [2,4]];
|
||||
$type_name_arr = db::name('sprite')->where($where)->column('type_name');
|
||||
$type_name_arr = implode(',', $type_name_arr);
|
||||
$v['type_name'] = $type_name_arr;
|
||||
$v['wind_type_name'] = '双号';
|
||||
}else if($v['win_type'] == 7){
|
||||
$where = [];
|
||||
$where[] = ['id', 'in', [2,5]];
|
||||
$type_name_arr = db::name('sprite')->where($where)->column('type_name');
|
||||
$type_name_arr = implode(',', $type_name_arr);
|
||||
$v['type_name'] = $type_name_arr;
|
||||
$v['wind_type_name'] = '双号';
|
||||
}else if($v['win_type'] == 8){
|
||||
$where = [];
|
||||
$where[] = ['id', 'in', [3,4]];
|
||||
$type_name_arr = db::name('sprite')->where($where)->column('type_name');
|
||||
$type_name_arr = implode(',', $type_name_arr);
|
||||
$v['type_name'] = $type_name_arr;
|
||||
$v['wind_type_name'] = '双号';
|
||||
}else if($v['win_type'] == 9){
|
||||
$where = [];
|
||||
$where[] = ['id', 'in', [3,5]];
|
||||
$type_name_arr = db::name('sprite')->where($where)->column('type_name');
|
||||
$type_name_arr = implode(',', $type_name_arr);
|
||||
$v['type_name'] = $type_name_arr;
|
||||
$v['wind_type_name'] = '双号';
|
||||
}else{
|
||||
$where = [];
|
||||
$where[] = ['id', 'in', [4,5]];
|
||||
$type_name_arr = db::name('sprite')->where($where)->column('type_name');
|
||||
$type_name_arr = implode(',', $type_name_arr);
|
||||
$v['type_name'] = $type_name_arr;
|
||||
$v['wind_type_name'] = '双号';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('sprite_log')->count();
|
||||
$data['list'] = $list;
|
||||
$totalRowData = db::name('sprite_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' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//列表
|
||||
public function get_user_monster_log($mid, $order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
|
||||
$list = db::name('user_sprite_log')->where('mid', $mid)->where('is_close', 1)->order($order, $sort)->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
$user_info = db::name('user')->where('uid', $v['uid'])->field('uid,nick_name,base64_nick_name,head_pic')->find();
|
||||
$v['nick_name'] = mb_convert_encoding(base64_decode($user_info['base64_nick_name']), 'UTF-8', 'UTF-8');
|
||||
$v['head_pic'] = localpath_to_netpath($user_info['head_pic']);
|
||||
$v['type_name'] = db::name('sprite')->where('type', $v['type'])->value('type_name');
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['count'] = db::name('user_sprite_log')->where('mid', $mid)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//列表
|
||||
public function get_user_monster_win_log($mid, $order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
$list = db::name('user_sprite_win_log')->where('mid', $mid)->order($order, $sort)->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
$user_info = db::name('user')->where('uid', $v['uid'])->field('uid,nick_name,base64_nick_name,head_pic')->find();
|
||||
$v['nick_name'] = mb_convert_encoding(base64_decode($user_info['base64_nick_name']), 'UTF-8', 'UTF-8');
|
||||
$v['head_pic'] = localpath_to_netpath($user_info['head_pic']);
|
||||
// $v['type_name'] = db::name('sprite')->where('type', $v['win_type'])->value('type_name');
|
||||
// $v['multiple'] = db::name('sprite')->where('type', $v['win_type'])->value('multiple');
|
||||
$gift_info = db::name('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['multiple_price'] = $v['multiple'] * $v['price'];
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('user_sprite_win_log')->where('mid', $mid)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//列表
|
||||
public function get_monster_gift_list($order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
$list = db::name('sprite_gift')->alias('a')->join('yy_gift b', 'a.gid = b.gid')->field('a.id, a.gid, b.gift_name, b.base_image, b.gift_price, a.update_time')->order($order, $sort)->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['base_image'] = localpath_to_netpath($v['base_image']);
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('sprite_gift')->alias('a')->join('yy_gift b', 'a.gid = b.gid')->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
|
||||
//获取信息
|
||||
public function get_monster_gift_info($id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$monster_info = db::name('sprite_gift')->where(['id' => $id])->find();
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $monster_info];
|
||||
}
|
||||
|
||||
//编辑
|
||||
public function edit_monster_gift($data){
|
||||
if (empty($data)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$monster_gift_info = db::name('sprite_gift')->find($data['id']);
|
||||
if (empty($monster_gift_info)) {
|
||||
return ['code' => 201, 'msg' => '参数异常1', 'data' => null];
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
|
||||
$update_data = [];
|
||||
// $update_data['multiple'] = $data['multiple'];
|
||||
// $update_data['gid'] = $data['gid'];
|
||||
$update_data['gid'] = $data['gid'];
|
||||
$update_data['update_time'] = time();
|
||||
$reslut = db::name('sprite_gift')->where(['id' => $data['id']])->update($update_data);
|
||||
if (!$reslut) {
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return ['code' => 200, 'msg' => '修改成功', 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
dump($e);
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//列表
|
||||
public function get_exchange_sprite_list($uid, $order, $sort, $page = 1, $limit = 20, $room_number, $start, $end)
|
||||
{
|
||||
$map = [];
|
||||
if(!empty($uid)){
|
||||
$map[] = ['a.uid', '=', $uid];
|
||||
}
|
||||
|
||||
if(!empty($room_number)){
|
||||
$rid = db::name('room')->where('room_number', $room_number)->value('rid');
|
||||
if(!empty($rid)){
|
||||
$map[] = ['a.rid', '=', $rid];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($start)) {
|
||||
$map[] = ['a.add_time', '>=', strtotime($start)];
|
||||
}
|
||||
if (!empty($end)) {
|
||||
$map[] = ['a.add_time', '<=', strtotime($end)];
|
||||
}
|
||||
|
||||
$list = db::name('user_exchange_sprite_log')->alias('a')->join('yy_user b', 'a.uid = b.uid')->where($map)->field('a.id, a.uid, a.rid, b.base64_nick_name, b.head_pic, a.airship, a.add_time')->order($order, $sort)->page($page, $limit)->select();
|
||||
// $gift_info = db::name('gift')->where('gid', 40)->find();
|
||||
foreach ($list as $k => &$v) {
|
||||
$base64_room_name = db::name('room')->where('rid', $v['rid'])->value('base64_room_name');
|
||||
$v['room_name'] = mb_convert_encoding(base64_decode($base64_room_name), 'UTF-8', 'UTF-8');
|
||||
$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']);
|
||||
// $v['gift_name'] = $gift_info['gift_name'];
|
||||
// $v['base_image'] = localpath_to_netpath($gift_info['base_image']);
|
||||
// $v['gift_price'] = $gift_info['gift_price'];
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('user_exchange_sprite_log')->alias('a')->join('yy_user b', 'a.uid = b.uid')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
$totalRowData = db::name('user_exchange_sprite_log')->alias('a')->join('yy_user b', 'a.uid = b.uid')->where($map)->field('SUM(a.airship) as airship')->find();
|
||||
$data['totalRow'] = $totalRowData;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
391
application/admin/model/Statistics.php
Normal file
391
application/admin/model/Statistics.php
Normal file
@@ -0,0 +1,391 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
|
||||
class Statistics extends Model
|
||||
{
|
||||
//获取首页基础统计数据
|
||||
public function welcome_data()
|
||||
{
|
||||
$data = [];
|
||||
//获取系统会员总人数
|
||||
$data['user_all_count'] = db::name('user')->count();
|
||||
//今日会员新增总数
|
||||
$data['user_today_count'] = db::name('user')->whereTime('add_time', 'today')->count();
|
||||
//本周会员新增总数
|
||||
$data['user_week_count'] = db::name('user')->whereTime('add_time', 'week')->count();
|
||||
//获取系统订单总人数
|
||||
$data['user_player_order_all_amount'] = db::name('user_player_order')->sum('total_amount');
|
||||
//今日订单新增总数
|
||||
$data['user_player_order_today_amount'] = db::name('user_player_order')->whereTime('add_time', 'today')->sum('total_amount');
|
||||
//本周订单新增总数
|
||||
$data['user_player_order_week_amount'] = db::name('user_player_order')->whereTime('add_time', 'week')->sum('total_amount');
|
||||
//获取系统充值总人数
|
||||
$data['user_recharge_all_amount'] = db::name('user_recharge')->where(['pay_status' => 2])->sum('money');
|
||||
//今日充值新增总数
|
||||
$data['user_recharge_today_amount'] = db::name('user_recharge')->where(['pay_status' => 2])->whereTime('add_time', 'today')->sum('money');
|
||||
//本周充值新增总数
|
||||
$data['user_recharge_week_amount'] = db::name('user_recharge')->where(['pay_status' => 2])->whereTime('add_time', 'week')->sum('money');
|
||||
//获取系统打赏总人数
|
||||
$data['user_send_gift_all_amount'] = db::name('user_send_gift')->sum('gift_total_price');
|
||||
//今日打赏新增总数
|
||||
$data['user_send_gift_today_amount'] = db::name('user_send_gift')->whereTime('add_time', 'today')->sum('gift_total_price');
|
||||
//本周打赏新增总数
|
||||
$data['user_send_gift_week_amount'] = db::name('user_send_gift')->whereTime('add_time', 'week')->sum('gift_total_price');
|
||||
//充值总积分
|
||||
$map = [];
|
||||
$map[] = ['money_type', '=', 2];
|
||||
$map[] = ['change_type', 'in', [1,9]];
|
||||
$data['platform_recharge_integral_all_amount'] = db::name('user_money_log')->where($map)->sum('change_value');
|
||||
//充值总余额
|
||||
$map = [];
|
||||
$map[] = ['money_type', '=', 1];
|
||||
$map[] = ['change_type', 'in', [1]];
|
||||
$data['platform_recharge_money_all_amount'] = db::name('user_money_log')->where($map)->sum('change_value');
|
||||
//用户总余额
|
||||
$data['user_all_money'] = db::name('user')->sum('money');
|
||||
//用户总积分
|
||||
$data['user_all_integral'] = db::name('user')->sum('integral');
|
||||
//背包礼物总价值
|
||||
$map = [];
|
||||
$map[] = ['a.num', '>', 0];
|
||||
$map[] = ['a.is_tester', '=', 1];
|
||||
$data['pack_gift_all_amount'] = db::name('user_gift_pack')->alias('a')->join('yy_gift b', 'a.gid = b.gid')->where($map)->sum('a.num*b.gift_price');
|
||||
//总支出
|
||||
$map = [];
|
||||
$map[] = ['box_type', 'in', [4,5,6]];
|
||||
$data['all_out_amount'] = db::name('user_box_count')->where($map)->sum('out_amount');
|
||||
//总收入
|
||||
$data['all_in_amount'] = db::name('user_box_count')->where($map)->sum('in_amount');
|
||||
//总盈亏
|
||||
$data['all_profit'] = $data['all_in_amount'] - $data['all_out_amount'];
|
||||
//总爆率
|
||||
if($data['all_out_amount'] > 0){
|
||||
$data['all_rate'] = round($data['all_in_amount']/$data['all_out_amount'],6);
|
||||
}else{
|
||||
$data['all_rate'] = 0;
|
||||
}
|
||||
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
//获取打赏金额每天统计
|
||||
public function get_send_gift_data_by_day()
|
||||
{
|
||||
//购买
|
||||
$sql = "SELECT FROM_UNIXTIME(add_time, '%Y-%m-%d') AS atime,sum(gift_total_price) as gift_total_price
|
||||
FROM yy_user_send_gift where gift_from_type=1 GROUP BY atime ORDER BY atime desc LIMIT 0,72";
|
||||
$list = Db::query($sql);
|
||||
$gift_data1 = [];
|
||||
foreach ($list as $k => $v) {
|
||||
$gift_data1[$v['atime']] = $v['gift_total_price'];
|
||||
}
|
||||
//背包
|
||||
$sql = "SELECT FROM_UNIXTIME(add_time, '%Y-%m-%d') AS atime,sum(gift_total_price) as gift_total_price
|
||||
FROM yy_user_send_gift where gift_from_type=2 GROUP BY atime ORDER BY atime desc LIMIT 0,72";
|
||||
$list = Db::query($sql);
|
||||
$gift_data2 = [];
|
||||
foreach ($list as $k => $v) {
|
||||
$gift_data2[$v['atime']] = $v['gift_total_price'];
|
||||
}
|
||||
|
||||
$now_hour = strtotime(date('Y-m-d'));
|
||||
$x_data = [];
|
||||
$y_data1 = [];
|
||||
$y_data2 = [];
|
||||
$y_data3 = [];
|
||||
for ($i = 0; $i < 72; $i++) {
|
||||
$l_hour = date('Y-m-d', $now_hour - $i * 24 * 3600);
|
||||
$x_data[$i] = $l_hour;
|
||||
if (!empty($gift_data1[$l_hour])) {
|
||||
$y_data2[$i] = $gift_data1[$l_hour];
|
||||
} else {
|
||||
$y_data2[$i] = 0;
|
||||
}
|
||||
if (!empty($gift_data2[$l_hour])) {
|
||||
$y_data3[$i] = $gift_data2[$l_hour];
|
||||
} else {
|
||||
$y_data3[$i] = 0;
|
||||
}
|
||||
$y_data1[$i] = $y_data2[$i] + $y_data3[$i];
|
||||
}
|
||||
$data = [];
|
||||
$data['x_data'] = array_reverse($x_data);
|
||||
$data['y_data1'] = array_reverse($y_data1);
|
||||
$data['y_data2'] = array_reverse($y_data2);
|
||||
$data['y_data3'] = array_reverse($y_data3);
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
//获取打赏金额每小时统计
|
||||
public function get_send_gift_data_by_hour()
|
||||
{
|
||||
//购买
|
||||
$sql = "SELECT FROM_UNIXTIME(add_time, '%Y-%m-%d %H:00:00') AS atime,sum(gift_total_price) as gift_total_price
|
||||
FROM yy_user_send_gift where gift_from_type=1 GROUP BY atime ORDER BY atime desc LIMIT 0,72";
|
||||
$list = Db::query($sql);
|
||||
$gift_data1 = [];
|
||||
foreach ($list as $k => $v) {
|
||||
$gift_data1[$v['atime']] = $v['gift_total_price'];
|
||||
}
|
||||
//背包
|
||||
$sql = "SELECT FROM_UNIXTIME(add_time, '%Y-%m-%d %H:00:00') AS atime,sum(gift_total_price) as gift_total_price
|
||||
FROM yy_user_send_gift where gift_from_type=2 GROUP BY atime ORDER BY atime desc LIMIT 0,72";
|
||||
$list = Db::query($sql);
|
||||
$gift_data2 = [];
|
||||
foreach ($list as $k => $v) {
|
||||
$gift_data2[$v['atime']] = $v['gift_total_price'];
|
||||
}
|
||||
|
||||
$now_hour = strtotime(date('Y-m-d'));
|
||||
$x_data = [];
|
||||
$y_data1 = [];
|
||||
$y_data2 = [];
|
||||
$y_data3 = [];
|
||||
for ($i = 0; $i < 72; $i++) {
|
||||
$l_hour = date('Y-m-d', $now_hour - $i * 3600);
|
||||
$x_data[$i] = $l_hour;
|
||||
if (!empty($gift_data1[$l_hour])) {
|
||||
$y_data2[$i] = $gift_data1[$l_hour];
|
||||
} else {
|
||||
$y_data2[$i] = 0;
|
||||
}
|
||||
if (!empty($gift_data2[$l_hour])) {
|
||||
$y_data3[$i] = $gift_data2[$l_hour];
|
||||
} else {
|
||||
$y_data3[$i] = 0;
|
||||
}
|
||||
$y_data1[$i] = $y_data2[$i] + $y_data3[$i];
|
||||
}
|
||||
$data = [];
|
||||
$data = [];
|
||||
$data['x_data'] = array_reverse($x_data);
|
||||
$data['y_data1'] = array_reverse($y_data1);
|
||||
$data['y_data2'] = array_reverse($y_data2);
|
||||
$data['y_data3'] = array_reverse($y_data3);
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
//不同类型房间统计
|
||||
public function get_room_type_date()
|
||||
{
|
||||
|
||||
$room_type_list = db::name('room_type')->column('type_name', 'tid');
|
||||
$sql = "SELECT tid,count(1) as count FROM `yy_room` GROUP BY tid";
|
||||
$list = Db::query($sql);
|
||||
$x_data = [];
|
||||
$y_data = [];
|
||||
foreach ($list as $k => $v) {
|
||||
if (!empty($room_type_list[$v['tid']])) {
|
||||
$x_data[$k] = $room_type_list[$v['tid']];
|
||||
$y_data[$k]['name'] = $room_type_list[$v['tid']];
|
||||
$y_data[$k]['value'] = $v['count'];
|
||||
}
|
||||
}
|
||||
$data = [];
|
||||
$data['x_data'] = $x_data;
|
||||
$data['y_data'] = $y_data;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//陪玩订单数量统计
|
||||
public function get_payer_order_date()
|
||||
{
|
||||
|
||||
$game_list = db::name('game')->column('game_name', 'gid');
|
||||
$sql = "SELECT gid,count(1) as count,sum(total_amount) AS total_amount FROM `yy_user_player_order` GROUP BY gid";
|
||||
$list = Db::query($sql);
|
||||
$x_data = [];
|
||||
$y_data1 = [];
|
||||
$y_data2 = [];
|
||||
foreach ($list as $k => $v) {
|
||||
if (!empty($game_list[$v['gid']])) {
|
||||
$x_data[$k] = $game_list[$v['gid']];
|
||||
$y_data1[$k]['name'] = $game_list[$v['gid']];
|
||||
$y_data1[$k]['value'] = $v['count'];
|
||||
$y_data2[$k]['name'] = $game_list[$v['gid']];
|
||||
$y_data2[$k]['value'] = $v['total_amount'];
|
||||
}
|
||||
}
|
||||
$data = [];
|
||||
$data['x_data'] = $x_data;
|
||||
$data['y_data1'] = $y_data1;
|
||||
$data['y_data2'] = $y_data2;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
|
||||
public function get_recharge_rank_list($uid, $time_section, $page, $limit)
|
||||
{
|
||||
$map = [];
|
||||
if (!empty($uid)) {
|
||||
$map[] = ['uid', '=', $uid];
|
||||
}
|
||||
$map[] = ['pay_status', '=', 2];
|
||||
if (!empty($time_section)) {
|
||||
$time_section = explode(' - ', $time_section);
|
||||
if (count($time_section) != 2) {
|
||||
return ['code' => 201, 'msg' => '时间区间异常', 'data' => null];
|
||||
} else {
|
||||
$start_time = $time_section[0];
|
||||
$end_time = $time_section[1];
|
||||
|
||||
$start_time_time = strtotime($start_time);
|
||||
$end_time_time = strtotime($end_time);
|
||||
$map[] = ['add_time', 'between', [$start_time_time, $end_time_time]];
|
||||
}
|
||||
}
|
||||
$list = db::name('user_recharge')->field('uid,sum(money) as total_money,sum(integral) as total_integral')->where($map)->group('uid')->order('total_money desc')->page($page, $limit)->select();
|
||||
$where = [];
|
||||
$where[] = ['uid', 'in', array_column($list, 'uid')];
|
||||
$user_data = db::name('user')->where($where)->column('*', 'uid');
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['nick_name'] = mb_convert_encoding(base64_decode($user_data[$v['uid']]['base64_nick_name']), 'UTF-8', 'UTF-8');
|
||||
$v['head_pic'] = localpath_to_netpath($user_data[$v['uid']]['head_pic']);
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('user_recharge')->where($map)->group('uid')->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
public function get_send_gift_rank_list($uid, $time_section, $page, $limit)
|
||||
{
|
||||
$map = [];
|
||||
if (!empty($uid)) {
|
||||
$map[] = ['uid', '=', $uid];
|
||||
}
|
||||
|
||||
if (!empty($time_section)) {
|
||||
$time_section = explode(' - ', $time_section);
|
||||
if (count($time_section) != 2) {
|
||||
return ['code' => 201, 'msg' => '时间区间异常', 'data' => null];
|
||||
} else {
|
||||
$start_time = $time_section[0];
|
||||
$end_time = $time_section[1];
|
||||
|
||||
$start_time_time = strtotime($start_time);
|
||||
$end_time_time = strtotime($end_time);
|
||||
$map[] = ['add_time', 'between', [$start_time_time, $end_time_time]];
|
||||
}
|
||||
}
|
||||
$list = db::name('user_send_gift')->field('uid,sum(gift_total_price) as total_gift_total_price,sum(gift_num) as total_gift_num')->where($map)->group('uid')->order('total_gift_total_price desc')->page($page, $limit)->select();
|
||||
$where = [];
|
||||
$where[] = ['uid', 'in', array_column($list, 'uid')];
|
||||
$user_data = db::name('user')->where($where)->column('*', 'uid');
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['nick_name'] = mb_convert_encoding(base64_decode($user_data[$v['uid']]['base64_nick_name']), 'UTF-8', 'UTF-8');
|
||||
$v['head_pic'] = localpath_to_netpath($user_data[$v['uid']]['head_pic']);
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('user_send_gift')->where($map)->group('uid')->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
public function get_receive_gift_rank_list($uid, $time_section, $page, $limit)
|
||||
{
|
||||
$map = [];
|
||||
if (!empty($uid)) {
|
||||
$map[] = ['receive_uid', '=', $uid];
|
||||
}
|
||||
|
||||
if (!empty($time_section)) {
|
||||
$time_section = explode(' - ', $time_section);
|
||||
if (count($time_section) != 2) {
|
||||
return ['code' => 201, 'msg' => '时间区间异常', 'data' => null];
|
||||
} else {
|
||||
$start_time = $time_section[0];
|
||||
$end_time = $time_section[1];
|
||||
|
||||
$start_time_time = strtotime($start_time);
|
||||
$end_time_time = strtotime($end_time);
|
||||
$map[] = ['add_time', 'between', [$start_time_time, $end_time_time]];
|
||||
}
|
||||
}
|
||||
$list = db::name('user_send_gift')->field('receive_uid,sum(receiver_profit) as total_gift_total_price,sum(gift_num) as total_gift_num')->where($map)->group('receive_uid')->order('total_gift_total_price desc')->page($page, $limit)->select();
|
||||
$where = [];
|
||||
$where[] = ['uid', 'in', array_column($list, 'receive_uid')];
|
||||
$user_data = db::name('user')->where($where)->column('*', 'uid');
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['nick_name'] = mb_convert_encoding(base64_decode($user_data[$v['receive_uid']]['base64_nick_name']), 'UTF-8', 'UTF-8');
|
||||
$v['head_pic'] = localpath_to_netpath($user_data[$v['receive_uid']]['head_pic']);
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('user_send_gift')->where($map)->group('receive_uid')->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
public function get_player_order_rank_list($uid, $time_section, $order, $sort, $page, $limit)
|
||||
{
|
||||
$map = [];
|
||||
if (!empty($uid)) {
|
||||
$map[] = ['player_uid', '=', $uid];
|
||||
}
|
||||
$map[] = ['status', '=', 3];
|
||||
$map[] = ['is_over', '=', 1];
|
||||
if (!empty($time_section)) {
|
||||
$time_section = explode(' - ', $time_section);
|
||||
if (count($time_section) != 2) {
|
||||
return ['code' => 201, 'msg' => '时间区间异常', 'data' => null];
|
||||
} else {
|
||||
$start_time = $time_section[0];
|
||||
$end_time = $time_section[1];
|
||||
|
||||
$start_time_time = strtotime($start_time);
|
||||
$end_time_time = strtotime($end_time);
|
||||
$map[] = ['add_time', 'between', [$start_time_time, $end_time_time]];
|
||||
}
|
||||
}
|
||||
|
||||
$list = db::name('user_player_order')->field('uid,sum(total_amount) as total_total_amount,sum(num) as total_num')->where($map)->group('player_uid')->order('total_total_amount desc')->page($page, $limit)->select();
|
||||
$where = [];
|
||||
$where[] = ['uid', 'in', array_column($list, 'uid')];
|
||||
$user_data = db::name('user')->where($where)->column('*', 'uid');
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['nick_name'] = mb_convert_encoding(base64_decode($user_data[$v['uid']]['base64_nick_name']), 'UTF-8', 'UTF-8');
|
||||
$v['head_pic'] = localpath_to_netpath($user_data[$v['uid']]['head_pic']);
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('user_player_order')->where($map)->group('uid')->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//用户消费排行统计
|
||||
|
||||
public function get_user_consume_rank_list($uid, $time_section, $page, $limit)
|
||||
{
|
||||
$map = [];
|
||||
if (!empty($uid)) {
|
||||
$map[] = ['uid', '=', $uid];
|
||||
}
|
||||
$map[] = ['money_type', '=', 1];
|
||||
$map[] = ['change_value', '<', 0];
|
||||
if (!empty($time_section)) {
|
||||
$time_section = explode(' - ', $time_section);
|
||||
if (count($time_section) != 2) {
|
||||
return ['code' => 201, 'msg' => '时间区间异常', 'data' => null];
|
||||
} else {
|
||||
$start_time = $time_section[0];
|
||||
$end_time = $time_section[1];
|
||||
|
||||
$start_time_time = strtotime($start_time);
|
||||
$end_time_time = strtotime($end_time);
|
||||
$map[] = ['add_time', 'between', [$start_time_time, $end_time_time]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$list = db::name('user_money_log')->field('uid,ABS(SUM(change_value)) as total_change_value')->where($map)->group('uid')->order('total_change_value desc')->page($page, $limit)->select();
|
||||
$where = [];
|
||||
$where[] = ['uid', 'in', array_column($list, 'uid')];
|
||||
$user_data = db::name('user')->where($where)->column('*', 'uid');
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['nick_name'] = mb_convert_encoding(base64_decode($user_data[$v['uid']]['base64_nick_name']), 'UTF-8', 'UTF-8');
|
||||
$v['head_pic'] = localpath_to_netpath($user_data[$v['uid']]['head_pic']);
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('user_money_log')->where($map)->group('uid')->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
}
|
||||
156
application/admin/model/SystemMenu.php
Normal file
156
application/admin/model/SystemMenu.php
Normal file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class SystemMenu extends Model
|
||||
{
|
||||
|
||||
// 获取初始化数据
|
||||
public function getSystemInit($aid = 0)
|
||||
{
|
||||
$homeInfo = [
|
||||
'title' => '首页',
|
||||
'href' => 'page/welcome.html',
|
||||
];
|
||||
$logoInfo = [
|
||||
'title' => '后台 管理',
|
||||
'image' => 'images/logo.png',
|
||||
'href' => 'javascript:;',
|
||||
];
|
||||
$menuInfo = $this->getMenuList($aid);
|
||||
$systemInit = [
|
||||
'homeInfo' => $homeInfo,
|
||||
'logoInfo' => $logoInfo,
|
||||
'menuInfo' => $menuInfo,
|
||||
];
|
||||
return $systemInit;
|
||||
}
|
||||
|
||||
// 获取菜单列表
|
||||
private function getMenuList($aid)
|
||||
{
|
||||
$menuList = Db::name('system_menu')
|
||||
->field('id,pid,title,icon,href,target')
|
||||
->where('status', 1)
|
||||
->where('type', 'in', [1, 2])
|
||||
->order('sort', 'desc')
|
||||
->select();
|
||||
//超级管理员默认有所有权限
|
||||
if ($aid != 1) {
|
||||
$admin_info = db::name('admin')->find($aid);
|
||||
if (empty($admin_info)) {
|
||||
return ['code' => 201, 'msg' => '管理员信息不存在', 'data' => null];
|
||||
}
|
||||
$system_menu_id_list_data = explode(',', $admin_info['system_menu_id_list']);
|
||||
foreach ($menuList as $k => &$v) {
|
||||
if ($v['pid'] != 0) {
|
||||
if (!in_array($v['id'], $system_menu_id_list_data)) {
|
||||
unset($menuList[$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$menuList = $this->buildMenuChild(0, $menuList);
|
||||
return $menuList;
|
||||
}
|
||||
|
||||
//递归获取子菜单
|
||||
private function buildMenuChild($pid, $menuList)
|
||||
{
|
||||
$treeList = [];
|
||||
foreach ($menuList as &$v) {
|
||||
|
||||
if ($pid == $v['pid']) {
|
||||
$node = $v;
|
||||
$child = $this->buildMenuChild($v['id'], $menuList);
|
||||
if (!empty($child)) {
|
||||
$node['child'] = $child;
|
||||
}
|
||||
// todo 后续此处加上用户的权限判断
|
||||
$treeList[] = $node;
|
||||
}
|
||||
}
|
||||
return $treeList;
|
||||
}
|
||||
public function get_all_system_menu_list($aid)
|
||||
{
|
||||
$menuList = Db::name('system_menu')
|
||||
->field('id,pid,title,icon,href,target')
|
||||
->where('status', 1)
|
||||
->where('type', 'in', [1, 2])
|
||||
->order('sort', 'desc')
|
||||
->select();
|
||||
|
||||
$admin_info = db::name('admin')->find($aid);
|
||||
if (empty($admin_info)) {
|
||||
return ['code' => 201, 'msg' => '管理员信息不存在', 'data' => null];
|
||||
}
|
||||
|
||||
$system_menu_id_list_data = explode(',', $admin_info['system_menu_id_list']);
|
||||
$menu_data = [];
|
||||
// dump($menuList);die;
|
||||
foreach ($menuList as $k => &$v) {
|
||||
// $v['is_show'] = 1; //有权限
|
||||
// if (!in_array($v['id'], $system_menu_id_list_data) && $aid != 1) {
|
||||
// $v['is_show'] = 2; //无权限
|
||||
// }
|
||||
$checked = false; //有权限
|
||||
if (in_array($v['id'], $system_menu_id_list_data) ) {
|
||||
|
||||
$checked = true; //无权限
|
||||
}
|
||||
|
||||
$v['checked'] = $checked;
|
||||
$v['spread'] = true;
|
||||
$menu_data[$v['id']] = $v;
|
||||
}
|
||||
foreach ($menu_data as $key => $val) {
|
||||
if ($val['checked'] === true && $val['pid'] != 0) {
|
||||
$menu_data[$val['pid']]['checked'] = false;
|
||||
}
|
||||
}
|
||||
// dump($menu_data);die;
|
||||
// dump($menu_data);die;
|
||||
// $menuList = $this->buildMenuChild(0, $menuList);
|
||||
$menuList = $this->_getManySonData($menu_data);
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $menuList];
|
||||
}
|
||||
|
||||
//树形创建
|
||||
private function _getManySonData($data, $sonName = 'children')
|
||||
{
|
||||
$tree = [];
|
||||
//第一步,将分类id作为数组key,并创建children单元
|
||||
|
||||
foreach ($data as $key => $val) {
|
||||
// dump($val);
|
||||
$tree[$val['id']] = $val;
|
||||
$tree[$val['id']][$sonName] = [];
|
||||
}
|
||||
//第二步,利用引用,将每个分类添加到父类children数组中,这样一次遍历即可形成树形结构。
|
||||
foreach ($tree as $key => $val) {
|
||||
if ($val['pid'] != 0) {
|
||||
$tree[$val['pid']][$sonName][] = &$tree[$key];
|
||||
if ($tree[$key][$sonName] == null) {
|
||||
unset($tree[$key][$sonName]); //如果children为空,则删除该children元素(可选)
|
||||
}
|
||||
}
|
||||
}
|
||||
//第三步,删除无用的非根节点数据
|
||||
foreach ($tree as $key => $val) {
|
||||
if (isset($val['pid']) && $val['pid'] != 0) {
|
||||
unset($tree[$key]);
|
||||
}
|
||||
}
|
||||
$result = [];
|
||||
foreach ($tree as $key => $val) {
|
||||
$result[] = $val;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
208
application/admin/model/Upload.php
Normal file
208
application/admin/model/Upload.php
Normal file
@@ -0,0 +1,208 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use Qiniu\Storage\UploadManager;
|
||||
use Qiniu\Auth;
|
||||
use think\facade\Env;
|
||||
use Qcloud\Cos\Client;
|
||||
|
||||
class Upload extends Model
|
||||
{
|
||||
//单文件上传
|
||||
public function single_file_upload($file, $file_category_name = 'all')
|
||||
{
|
||||
//判断上传方式
|
||||
$config = get_system_config();
|
||||
if ($config['file_upload_type'] == 1) {
|
||||
$reslut = $this->local_upload($file, $file_category_name);
|
||||
} elseif ($config['file_upload_type'] == 2) {
|
||||
$reslut = $this->qiniu_upload($file, $file_category_name);
|
||||
}elseif ($config['file_upload_type'] == 3) {
|
||||
$reslut = $this->tencent_upload($file, $file_category_name);
|
||||
}
|
||||
return $reslut;
|
||||
}
|
||||
|
||||
|
||||
public function server_local_upload($filePath){
|
||||
|
||||
$config = get_system_config();
|
||||
$accessKey = $config['qiniu_access_key'];
|
||||
$secretKey = $config['qiniu_secret_key'];
|
||||
$bucket = $config['qiniu_bucket_name'];
|
||||
// 构建鉴权对象
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
// 生成上传 Token
|
||||
$token = $auth->uploadToken($bucket);
|
||||
// 初始化 UploadManager 对象并进行文件的上传。
|
||||
$uploadMgr = new UploadManager();
|
||||
// 调用 UploadManager 的 putFile 方法进行文件的上传。
|
||||
$local_filePath= Env::get('root_path')."/public/".$filePath;
|
||||
list($ret, $err) = $uploadMgr->putFile($token, $filePath, $local_filePath);
|
||||
if ($err !== null) {
|
||||
return ['code' => 201, 'msg' => "上传失败", 'data' => null];
|
||||
} else {
|
||||
$data = [];
|
||||
$data['image_path'] = $ret['key'];
|
||||
$data['size'] = 0;
|
||||
$data['http_image_path'] = localpath_to_netpath($ret['key']);
|
||||
|
||||
return ['code' => 200, 'msg' => "上传成功", 'data' => $data];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function local_upload($file, $file_category_name = 'all')
|
||||
{
|
||||
// // 获取表单上传文件 例如上传了001.jpg
|
||||
|
||||
// 移动到框架应用根目录/uploads/ 目录下
|
||||
$root_path = 'public/uploads/' . $file_category_name;
|
||||
mkdirs($root_path); //创建文件
|
||||
$info = $file->validate(['ext' => 'jpeg,jpg,png,gif,mp4,mp3,wgt,svga'])->move('./uploads/' . $file_category_name);
|
||||
if ($info) {
|
||||
$file_info = $info->getInfo();
|
||||
// 成功上传后 获取上传信息
|
||||
// 输出 jpg
|
||||
// echo $info->getExtension();
|
||||
// // 输出 20160820/42a79759f284b767dfcb2a0197904287.jpg
|
||||
// echo $info->getSaveName();
|
||||
// // 输出 42a79759f284b767dfcb2a0197904287.jpg
|
||||
// echo $info->getFilename();
|
||||
$image_path = '/uploads/' . $file_category_name . '/' . $info->getSaveName(); //返回的地址
|
||||
$image_path = str_replace("\\", "/", $image_path);
|
||||
$img['image_path'] = $image_path;
|
||||
$img['size'] = $file_info['size'];
|
||||
$img['http_image_path'] = localpath_to_netpath($image_path);
|
||||
return ['code' => 200, 'msg' => '上传成功', 'data' => $img];
|
||||
} else {
|
||||
|
||||
return ['code' => 201, 'msg' => '上传失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
public function qiniu_upload($file, $file_category_name = 'all')
|
||||
{
|
||||
$config = get_system_config();
|
||||
$accessKey = $config['qiniu_access_key'];
|
||||
$secretKey = $config['qiniu_secret_key'];
|
||||
$bucket = $config['qiniu_bucket_name'];
|
||||
|
||||
if (empty($file)) {
|
||||
return ['code' => 201, 'msg' => '请上传文件', 'data' => null];
|
||||
}
|
||||
|
||||
$validate_reslut = $file->validate(['ext' => 'jpeg,jpg,png,gif,mp4,mp3,wgt,svga'])->check();
|
||||
if (!$validate_reslut) {
|
||||
return ['code' => 201, 'msg' => '非法上传存储类型', 'data' => null];
|
||||
}
|
||||
$extension = strtolower(pathinfo($file->getInfo('name'), PATHINFO_EXTENSION));
|
||||
$file_info = $file->getInfo();
|
||||
|
||||
|
||||
// 构建鉴权对象
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
// 生成上传 Token
|
||||
$token = $auth->uploadToken($bucket);
|
||||
// 要上传文件的本地路径
|
||||
$filePath = $file_info['tmp_name'];
|
||||
// 上传到存储后保存的文件名
|
||||
$savename = date('Ymd') . '/' . md5(microtime(true)) . ".$extension";
|
||||
$key = $file_category_name . '/' . $savename;
|
||||
// 初始化 UploadManager 对象并进行文件的上传。
|
||||
$uploadMgr = new UploadManager();
|
||||
// 调用 UploadManager 的 putFile 方法进行文件的上传。
|
||||
list($ret, $err) = $uploadMgr->putFile($token, $key, $filePath);
|
||||
if ($err !== null) {
|
||||
return ['code' => 201, 'msg' => "上传失败", 'data' => null];
|
||||
} else {
|
||||
$data = [];
|
||||
$data['image_path'] = $ret['key'];
|
||||
$data['size'] = $file_info['size'];
|
||||
$data['http_image_path'] = localpath_to_netpath($ret['key']);
|
||||
|
||||
return ['code' => 200, 'msg' => "上传成功", 'data' => $data];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function get_qiniu_upload_token()
|
||||
{
|
||||
$config = get_system_config();
|
||||
$accessKey = $config['qiniu_access_key'];
|
||||
$secretKey = $config['qiniu_secret_key'];
|
||||
$bucket = $config['qiniu_bucket_name'];
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
$token = $auth->uploadToken($bucket);
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => ['token' => $token]];
|
||||
}
|
||||
public function tencent_upload($file, $file_category_name = 'all')
|
||||
{
|
||||
|
||||
$config = get_system_config();
|
||||
$secretId = $config['tencent_secret_id'];
|
||||
// $secretId = 111111;
|
||||
$secretKey = $config['tencent_secret_key'];
|
||||
$region = $config['tencent_territory'];
|
||||
$bucket = $config['tencent_bucket_name'];
|
||||
|
||||
if (empty($file)) {
|
||||
return ['code' => 201, 'msg' => '请上传文件', 'data' => null];
|
||||
}
|
||||
// dump($file);exit;
|
||||
|
||||
$validate_reslut = $file->validate(['ext' => 'jpeg,jpg,png,gif,mp4,mp3,wgt,svga'])->check();
|
||||
// dump($file);exit;
|
||||
if (!$validate_reslut) {
|
||||
return ['code' => 201, 'msg' => '非法上传存储类型', 'data' => null];
|
||||
}
|
||||
|
||||
$extension = strtolower(pathinfo($file->getInfo('name'), PATHINFO_EXTENSION));
|
||||
$file_info = $file->getInfo();
|
||||
|
||||
|
||||
// 构建鉴权对象
|
||||
$cosClient = new Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// 要上传文件的本地路径
|
||||
$filePath = $file_info['tmp_name'];
|
||||
// 上传到存储后保存的文件名
|
||||
$savename = date('Ymd') . '/' . md5(microtime(true)) . ".$extension";
|
||||
$key = $file_category_name . '/' . $savename;
|
||||
// 初始化 UploadManager 对象并进行文件的上传。
|
||||
$file = fopen($filePath, "rb");
|
||||
|
||||
if ($file) {
|
||||
$result = $cosClient->putObject(array(
|
||||
'Bucket' => $bucket,
|
||||
'Key' => $key,
|
||||
'Body' => $file)
|
||||
);
|
||||
|
||||
$data = [];
|
||||
$data['image_path'] = $result['Key'];
|
||||
$data['size'] = $file_info['size'];
|
||||
$data['http_image_path'] = localpath_to_netpath($result['Key']);
|
||||
$data['mp4_task_id'] = '';
|
||||
$data['extension'] = $extension;
|
||||
|
||||
return ['code' => 200, 'msg' => "上传成功", 'data' => $data];
|
||||
}else{
|
||||
return ['code' => 201, 'msg' => "上传失败", 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
1110
application/admin/model/User.php
Normal file
1110
application/admin/model/User.php
Normal file
File diff suppressed because it is too large
Load Diff
10
application/admin/model/UserGiftPack.php
Normal file
10
application/admin/model/UserGiftPack.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class UserGiftPack extends Model
|
||||
{
|
||||
|
||||
}
|
||||
20
application/admin/model/UserGiftPackLog.php
Normal file
20
application/admin/model/UserGiftPackLog.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class UserGiftPackLog extends Model
|
||||
{
|
||||
public static function TypeLable()
|
||||
{
|
||||
//1系统赠送2宝箱获得3个人赠送
|
||||
return [
|
||||
'1' => '系统赠送',
|
||||
'2' => '宝箱获得',
|
||||
'3' => '个人打赏',
|
||||
'4' => '玩法获取',
|
||||
'5' => '盲盒巡音会获取',
|
||||
];
|
||||
}
|
||||
}
|
||||
19
application/admin/model/UserMessage.php
Normal file
19
application/admin/model/UserMessage.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class UserMessage extends Model
|
||||
{
|
||||
protected $pk = 'mid';
|
||||
|
||||
public static function TypeLable()
|
||||
{
|
||||
return [
|
||||
'1' => '系统消息',
|
||||
'2' => '订单消息',
|
||||
'3' => '情缘消息',
|
||||
];
|
||||
}
|
||||
}
|
||||
87
application/admin/model/UserMoneyLog.php
Normal file
87
application/admin/model/UserMoneyLog.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class UserMoneyLog extends Model
|
||||
{
|
||||
protected $pk = 'log_id';
|
||||
|
||||
public static function ChangeTypeLable()
|
||||
{
|
||||
return [
|
||||
'1' => '系统调节',
|
||||
// '2' => '陪玩下单',
|
||||
// '3' => '陪玩超时退款',
|
||||
'4' => '礼物打赏',
|
||||
// '5' => '陪玩接单',
|
||||
'6' => '礼物收赏',
|
||||
'7' => '礼物打赏厅主收益',
|
||||
// '8' => '购买守护',
|
||||
'9' => '余额充值',
|
||||
// '10' => '陪玩订单取消退款',
|
||||
'11' => '兑换消耗余额',
|
||||
'12' => '兑换增加金币',
|
||||
'13' => '提现',
|
||||
// '14' => '推广用户充值返利',
|
||||
'15' => '提现驳回',
|
||||
'16' => '开宝箱',
|
||||
'17' => '用户转赠',
|
||||
// '18' => '发红包支出',
|
||||
// '19' => '抢红包收入',
|
||||
// '20' => '抢红包厅主流水',
|
||||
'21' => '购买装扮',
|
||||
'22' => '会员邀请收益',
|
||||
'23' => '签约成功主持获得金币',
|
||||
'24' => '拍卖签约扣除金币',
|
||||
'25' => '制作人续约',
|
||||
'26' => '前制作人获取签约用户被拍金币',
|
||||
'27' => '新人签约唱歌获取金币',
|
||||
'28' => '礼物打赏主持收益',
|
||||
'29' => '幸运礼物打赏',
|
||||
'30' => '幸运礼物返币',
|
||||
'31' => '幸运礼物收赏',
|
||||
'32' => '幸运礼物打赏厅主收益',
|
||||
'33' => '幸运礼物打赏主持收益',
|
||||
'34' => '房间补贴收益',
|
||||
'35' => '幸运补贴收益',
|
||||
'36' => '购买会员消费',
|
||||
'37' => '更换邀请人消费',
|
||||
'38' => '礼物打赏制作人收益',
|
||||
'39' => '公会补贴收益',
|
||||
'40' => '购买门票消费金币',
|
||||
'41' => '获取门票',
|
||||
'42' => '仲夏夜梦曲投入票数',
|
||||
'43' => '新手签约奖励',
|
||||
// '18' => '开箱获取欧皇钥匙',
|
||||
// '19' => '消耗欧皇钥匙开箱',
|
||||
// '18' => '兑换积攒池',
|
||||
// '19' => '积攒池兑换'
|
||||
'44' => '购买爵位',
|
||||
'18' => '退出公会扣除',
|
||||
'19' => '退出公会增加',
|
||||
'52' => '抢头条',
|
||||
'53' => '删除用户关系',
|
||||
'61' => '龙蛋神谕投币',
|
||||
|
||||
'62' => '每日签到奖励',
|
||||
'63' => '倍数玩法消费',
|
||||
|
||||
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public static function MoneyTypeLable()
|
||||
{
|
||||
return [
|
||||
'1' => '余额',
|
||||
'2' => '金币',
|
||||
'3' => '票数',
|
||||
// '3' => '欧皇钥匙',
|
||||
// '3' => '积攒金额'
|
||||
];
|
||||
}
|
||||
}
|
||||
82
application/admin/model/UserPack.php
Normal file
82
application/admin/model/UserPack.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
|
||||
class UserPack extends Model
|
||||
{
|
||||
//获取配置参数
|
||||
public function add_user_pack_gift($aid, $uid, $gid, $num)
|
||||
{
|
||||
if($aid != 1) {
|
||||
return ['code' => 201, 'msg' => '非超管用户不能向背包送礼物', 'data' => null];
|
||||
}
|
||||
$map = [];
|
||||
$map[] = ['is_delete', '=', 1];
|
||||
$map[] = ['is_show', '=', 1];
|
||||
$map[] = ['is_can_buy', '=', 2];
|
||||
$map[] = ['gid', '=', $gid];
|
||||
$gift_info = Db::name('gift')->where($map)->find();
|
||||
if(empty($gift_info)) {
|
||||
return ['code' => 201, 'msg' => '礼物信息不存在', 'data' => null];
|
||||
}
|
||||
$user_info = Db::name('user')->find($uid);
|
||||
if(empty($user_info)) {
|
||||
return ['code' => 201, 'msg' => '用户信息不存在', 'data' => null];
|
||||
}
|
||||
|
||||
$map = [];
|
||||
$map[] = ['uid', '=', $uid];
|
||||
$map[] = ['gid', '=', $gid];
|
||||
$info = Db::name('user_gift_pack')->where($map)->find();
|
||||
Db::startTrans();
|
||||
try {
|
||||
if($info) {
|
||||
$data = [
|
||||
'total_num' => $info['total_num'] + $num,
|
||||
'num' => $info['num'] + $num,
|
||||
'admin_id' => $aid,
|
||||
'admin_add_num' => $info['admin_add_num'] + $num,
|
||||
'update_time' => time(),
|
||||
];
|
||||
Db::name('user_gift_pack')->where('pid', $info['pid'])->update($data);
|
||||
} else {
|
||||
$data = [
|
||||
'total_num' => $num,
|
||||
'num' => $num,
|
||||
'admin_id' => $aid,
|
||||
'admin_add_num' => $num,
|
||||
'update_time' => time(),
|
||||
'add_time' => time(),
|
||||
'gid' => $gid,
|
||||
'uid' => $uid,
|
||||
];
|
||||
Db::name('user_gift_pack')->insert($data);
|
||||
}
|
||||
$insert_data = [
|
||||
'uid' => $uid,
|
||||
'type' => 5,
|
||||
'gid' => $gid,
|
||||
'change_num' => $num,
|
||||
'after_num' => $num,
|
||||
'gift_price' => $gift_info['gift_price'],
|
||||
'total_gift_price' => $gift_info['gift_price'] * $num,
|
||||
'remarks' => '平台补发',
|
||||
'update_time' => time(),
|
||||
'add_time' => time(),
|
||||
'admin_id' => $aid,
|
||||
];
|
||||
Db::name('user_gift_pack_log')->insert($insert_data);
|
||||
Db::commit();
|
||||
return ['code' => 200, 'msg' => "修改成功", 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
dump($e);
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => "请重试", 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
29
application/admin/model/UserPlayer.php
Normal file
29
application/admin/model/UserPlayer.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class UserPlayer extends Model
|
||||
{
|
||||
protected $auto = ['update_time'];
|
||||
protected $insert = [
|
||||
'add_time',
|
||||
|
||||
'order_duration' => 0,
|
||||
'order_count' => 0,
|
||||
'order_total_amount' => 0,
|
||||
'service_rate' => 0,
|
||||
'last_login_time' => 0,
|
||||
'flag' => '',
|
||||
'is_top' => 1,
|
||||
'is_recommend' => 1,
|
||||
'is_business' => 1,
|
||||
'remarks' => '',
|
||||
'status' => 1,
|
||||
'deal_time' => 0,
|
||||
|
||||
];
|
||||
protected $update = ['update_time'];
|
||||
|
||||
}
|
||||
45
application/admin/model/UserPlayerOrder.php
Normal file
45
application/admin/model/UserPlayerOrder.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class UserPlayerOrder extends Model
|
||||
{
|
||||
public function close_palyer_order()
|
||||
{
|
||||
$player_order_close_max_time = get_system_config('player_order_close_max_time');
|
||||
$close_time = time() - $player_order_close_max_time; //30分钟自动关闭订单
|
||||
$map = [];
|
||||
$map[] = ['status', '=', 1];
|
||||
$map[] = ['is_over', '=', 1];
|
||||
$map[] = ['add_time', '<', $close_time];
|
||||
$list = db::name('user_player_order')->where($map)->select();
|
||||
foreach ($list as $k => $v) {
|
||||
Db::startTrans();
|
||||
try {
|
||||
$data = [];
|
||||
$data['oid'] = $v['oid'];
|
||||
$data['is_over'] = 2;
|
||||
$data['over_close_time'] = time();
|
||||
$reslut = db::name('user_player_order')->update($data);
|
||||
if (!$reslut) {
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '请重试', 'data' => null];
|
||||
}
|
||||
//用户积分返回
|
||||
$reslut = model('admin/User')->change_user_money_by_uid($v['uid'], $v['total_amount'], 2, 3, "陪玩订单超时退款:" . $v['order_sn'], $v['player_uid'], $v['oid']);
|
||||
if ($reslut['code'] != 200) {
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => '请重试', 'data' => null];
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return ['code' => 201, 'msg' => "请重试", 'data' => null];
|
||||
}
|
||||
}
|
||||
return date('Y-m-d H:i:s') . 'success' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
46
application/admin/model/UserRelation.php
Normal file
46
application/admin/model/UserRelation.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class UserRelation extends Model
|
||||
{
|
||||
protected $pk = 'rid';
|
||||
protected $auto = ['update_time'];
|
||||
protected $insert = [
|
||||
'add_time',
|
||||
'status' => 1,
|
||||
'deal_time' => 0,
|
||||
|
||||
];
|
||||
protected $update = ['update_time'];
|
||||
|
||||
protected function setAddTimeAttr()
|
||||
{
|
||||
return time();
|
||||
}
|
||||
|
||||
protected function setUpdateTimeAttr()
|
||||
{
|
||||
return time();
|
||||
}
|
||||
public static function TypeLable()
|
||||
{
|
||||
return [
|
||||
'1' => '情侣',
|
||||
'2' => '师徒',
|
||||
'3' => '守护',
|
||||
];
|
||||
}
|
||||
|
||||
public function get_relation_type_lable($type)
|
||||
{
|
||||
$data = $this->TypeLable();
|
||||
if (empty($data[$type])) {
|
||||
return '';
|
||||
} else {
|
||||
return $data[$type];
|
||||
}
|
||||
}
|
||||
}
|
||||
28
application/admin/model/UserRelationApply.php
Normal file
28
application/admin/model/UserRelationApply.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class UserRelationApply extends Model
|
||||
{
|
||||
protected $pk = 'aid';
|
||||
protected $auto = ['update_time'];
|
||||
protected $insert = [
|
||||
'add_time',
|
||||
'status' => 1,
|
||||
'deal_time' => 0,
|
||||
|
||||
];
|
||||
protected $update = ['update_time'];
|
||||
|
||||
protected function setAddTimeAttr()
|
||||
{
|
||||
return time();
|
||||
}
|
||||
|
||||
protected function setUpdateTimeAttr()
|
||||
{
|
||||
return time();
|
||||
}
|
||||
}
|
||||
130
application/admin/model/Userzone.php
Normal file
130
application/admin/model/Userzone.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class Userzone extends Model
|
||||
{
|
||||
|
||||
//获取举报列表
|
||||
public function user_zone_list($uid, $nick_name, $content, $show_status, $page = 1, $limit = 20)
|
||||
{
|
||||
$map = [];
|
||||
if (!empty($uid)) {
|
||||
$map[] = ['a.uid', '=', $uid];
|
||||
}
|
||||
if (!empty($nick_name)) {
|
||||
$map[] = ['b.nick_name', 'like', '%' . $nick_name . '%'];
|
||||
}
|
||||
if (!empty($content)) {
|
||||
$map[] = ['a.content', 'like', '%' . $content . '%'];
|
||||
}
|
||||
if (!empty($show_status)) {
|
||||
$map[] = ['a.show_status', '=', $show_status];
|
||||
}
|
||||
$list = db::name('user_zone')
|
||||
->alias('a')->join('yy_user b', 'a.uid = b.uid')
|
||||
->field('a.*,b.nick_name')->where($map)->page($page, $limit)->order("zid desc")->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
$list[$k]['user_nick_name'] = $v['uid'] . '-' . $v['nick_name'];
|
||||
$image_data = explode(',', $v['images']);
|
||||
$v['image_list'] = [];
|
||||
if (!empty($image_data)) {
|
||||
foreach ($image_data as $m => $n) {
|
||||
$v['image_list'][] = localpath_to_netpath($n);
|
||||
}
|
||||
}
|
||||
|
||||
$v['sound'] = localpath_to_netpath($v['sound']);
|
||||
$v['video'] = localpath_to_netpath($v['video']);
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('user_zone')->alias('a')->join('yy_user b', 'a.uid = b.uid')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 200, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
//审核发布说说
|
||||
// public function zone_examine($zid, $show_status)
|
||||
// {
|
||||
// $map = [];
|
||||
// $map[] = ['zid', '=', $zid];
|
||||
// $zone_info = db::name('user_zone')->where($map)->find();
|
||||
// if (empty($zone_info)) {
|
||||
// return ['code' => 201, 'msg' => '说说不存在', 'data' => null];
|
||||
// }
|
||||
// if (!in_array($show_status, [1, 2, 3])) {
|
||||
// return ['code' => 201, 'msg' => '审核状态参数错误', 'data' => null];
|
||||
// }
|
||||
// $data = [];
|
||||
// $data['zid'] = $zid;
|
||||
// $data['show_status'] = $show_status; //默认显示
|
||||
// $data['update_time'] = time(); //默认显示
|
||||
// $reslut = db::name('user_zone')->update($data);
|
||||
// if ($reslut) {
|
||||
// return ['code' => 200, 'msg' => '操作成功', 'data' => null];
|
||||
// } else {
|
||||
// return ['code' => 201, 'msg' => '操作失败', 'data' => null];
|
||||
// }
|
||||
// }
|
||||
|
||||
public function get_zone_info($zid)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['zid', '=', $zid];
|
||||
$zone_info = db::name('user_zone')->where($map)->find();
|
||||
if (empty($zone_info)) {
|
||||
return ['code' => 201, 'msg' => '说说不存在', 'data' => null];
|
||||
}
|
||||
$user_info = db::name('user')->find($zone_info['uid']);
|
||||
$zone_info['user_name'] = $user_info['user_name'];
|
||||
$zone_info['nick_name'] = mb_convert_encoding(base64_decode($user_info['base64_nick_name']), 'UTF-8', 'UTF-8');
|
||||
$zone_info['http_sound'] = localpath_to_netpath($zone_info['sound']);
|
||||
|
||||
$zone_info['http_video'] = localpath_to_netpath($zone_info['video']);
|
||||
|
||||
|
||||
$zone_info['image_list'] = '';
|
||||
if (!empty($zone_info['images'])) {
|
||||
$image_data = explode(',', $zone_info['images']);
|
||||
foreach ($image_data as $m => &$n) {
|
||||
$n = localpath_to_netpath($n);
|
||||
}
|
||||
$zone_info['image_list']=join(',',$image_data);
|
||||
|
||||
}
|
||||
|
||||
return ['code' => 200, 'msg' => 'success', 'data' => $zone_info];
|
||||
}
|
||||
|
||||
//审核发布说说
|
||||
public function edit_zone($data)
|
||||
{
|
||||
$map = [];
|
||||
$map[] = ['zid', '=', $data['zid']];
|
||||
$zone_info = db::name('user_zone')->where($map)->find();
|
||||
if (empty($zone_info)) {
|
||||
return ['code' => 201, 'msg' => '说说不存在', 'data' => null];
|
||||
}
|
||||
if (!in_array($data['show_status'], [1, 2, 3])) {
|
||||
return ['code' => 201, 'msg' => '审核状态参数错误', 'data' => null];
|
||||
}
|
||||
if (!in_array($data['is_recommend'], [1, 2])) {
|
||||
return ['code' => 201, 'msg' => '推荐状态参数错误', 'data' => null];
|
||||
}
|
||||
$update_data = [];
|
||||
$update_data['zid'] = $data['zid'];
|
||||
$update_data['is_recommend'] = $data['is_recommend']; //默认显示
|
||||
$update_data['show_status'] = $data['show_status']; //默认显示
|
||||
$update_data['update_time'] = time(); //默认显示
|
||||
$reslut = db::name('user_zone')->update($update_data);
|
||||
if ($reslut) {
|
||||
return ['code' => 200, 'msg' => '操作成功', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 201, 'msg' => '操作失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
1166
application/admin/model/Website.php
Normal file
1166
application/admin/model/Website.php
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user