梵音定版初始化

This commit is contained in:
2025-08-11 16:56:05 +08:00
commit ada241ce02
5180 changed files with 859246 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
<?php
namespace app\adminapi\model;
use think\Model;
use think\Session;
use think\Db;
class Admin extends Model
{
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $name = 'admin';
/*
* 二级密码校验
*/
//二级密码校验
public function check_secondary_password($pass){
if(empty($pass)){
return ['code' => 0, 'msg' => '二级密码不能为空', 'data' => null];
}
$pass_word = secondary_password();
if(md5($pass) != $pass_word){
return ['code' => 0, 'msg' => '二级密码错误', 'data' => null];
}else{
return ['code' => 1, 'msg' => '成功', 'data' => null];
}
}
}

View File

@@ -0,0 +1,76 @@
<?php
namespace app\adminapi\model;
use think\Model;
use think\Session;
use think\Db;
class Gift extends Model
{
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $name = 'vs_gift';
//礼物类型 1普通 2盲盒 3礼包礼物
public $giftType = [
1 => '普通礼物',
2 => '盲盒礼物',
3 => '礼包礼物'
];
//送礼流水来源1聊天送礼物 2房间语聊送礼 3直播送礼 4动态打赏
public $GiveGiftFromStr = [
1 => '聊天送礼',
2 => '房间语聊送礼',
3 => '直播送礼',
4 => '动态打赏'
];
public function getList($where = [], $page = 1, $limit = 10)
{
$where['delete_time'] = 0;
$list = $this->where($where)->page($page, $limit)->select();
$list = collection($list)->toArray();
return $list;
}
public function getCount($where = [])
{
$where['delete_time'] = 0;
return $this->where($where)->count();
}
public function getOne($where = [])
{
$one = $this->where($where)->find();
return $one;
}
public function add($data)
{
$res = $this->save($data);
if (!$res) {
return false;
}
$guild_id = $this->id;
return $guild_id;
}
public function edit($where = [], $data = [])
{
$res = $this->where($where)->update($data);
return $res;
}
public function del($where = [])
{
$res = $this->where($where)->delete();
return $res;
}
//软删除
public function setDel($where = []){
$res = $this->where($where)->setField('delete_time',time());
if(!$res){
return false;
}
return $res;
}
}

View File

@@ -0,0 +1,146 @@
<?php
namespace app\adminapi\model;
use think\Model;
use think\Session;
use think\Db;
class Guild extends Model
{
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $name = 'vs_guild';
public function getList($where = [], $page = 1, $limit = 10)
{
$list = $this->where($where)->page($page, $limit)->select();
$list = collection($list)->toArray();
return $list;
}
public function getCount($where = [])
{
return $this->where($where)->count();
}
public function getOne($where = [])
{
$one = $this->where($where)->find();
return $one;
}
public function add($data)
{
$res = $this->save($data);
if (!$res) {
return false;
}
$guild_id = $this->id;
return $guild_id;
}
public function edit($where = [], $data = [])
{
$res = $this->where($where)->update($data);
return $res;
}
public function del($where = [])
{
$res = $this->where($where)->delete();
return $res;
}
//软删除
public function setDel($where = []){
$res = $this->where($where)->setField('delete_time',time());
if(!$res){
return false;
}
return $res;
}
//靓号处理
public function getGuildSpecialId(){
$code = $this->order('guild_special_id desc')->value('guild_special_id');
if(empty($code)){
$code = 10000;
}
$code = $code + 1;
$vip_code = db::name('vip_code')->where(['type' => 3, 'status' => 1,'is_use' => 1])->field('code')->select();
if (empty($vip_code)) {
return $code;
}
if (in_array($code, (array)$vip_code)) {
return $code + 2;
}
return $code;
}
/*
* 通过用户ID 获取公会信息
*
*/
public function getGuildByUserId($user_id){
$guild = db::name('vs_guild_user')
->alias('g')
->join('vs_guild gg','g.guild_id = gg.id')
->field('gg.*')
->where(['g.user_id' => $user_id])
->find();
return $guild;
}
/*
*
*工会当日流水
*/
public function getTodayMoney($guild_id,$stoday="",$etoday=""){
$where = [];
if(empty($stoday) && empty($etoday)){
$stoday = strtotime(date('Y-m-d 00:00:00'));
$etoday = strtotime(date('Y-m-d 23:59:59'));
$where['createtime'] = ['between', [$stoday, $etoday]];
}else{
if(!empty($stoday)){
$where['createtime'] = ['>=', strtotime($stoday."00:00:00")];
}
if(!empty($etoday)){
$where['createtime'] = ['<=', strtotime($etoday." 23:59:59")];
}
if(!empty($stoday) && !empty($etoday)){
$where['createtime'] = ['between', [strtotime($stoday." 00:00:00"), strtotime($etoday." 23:59:59")]];
}
}
//获取所有工会房间ID
$room_ids = db::name('vs_guild_user')->where('guild_id', $guild_id)->field('room_id')->select();
$room_ids = array_column($room_ids, 'room_id');
$transaction = db::name('vs_give_gift')
->whereIn('from_id',$room_ids)
->where(['from'=>['in',[2,3,6]]])
->where($where)
->sum('total_price');
return $transaction;
}
/*
* 工会个人流水
*/
public function getUserMoney($guild_id,$user_id,$stoday="",$etoday=""){
if(empty($stoday)){
$stoday = strtotime(date('Y-m-d 00:00:00'));
}
if(empty($etoday)){
$etoday = strtotime(date('Y-m-d 23:59:59'));
}
//获取所有工会房间ID
$room_ids = db::name('vs_guild_user')->where('guild_id', $guild_id)->field('room_id')->select();
$room_ids = array_column($room_ids, 'room_id');
$transaction =0;
$transaction = db::name('vs_give_gift')
->whereIn('from_id',$room_ids)
->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$stoday, $etoday]]])
->sum('total_price');
return $transaction;
}
}

View File

@@ -0,0 +1,93 @@
<?php
namespace app\adminapi\model;
use think\Model;
use think\Session;
use think\Db;
class Room extends Model
{
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $name = 'vs_room';
public $relation_type = [1=>'真爱拍',2=>'友情拍'];
public $room_status = [1=>'正常',2=>'封禁',3=>'关闭'];
//房间操作 日志 类型
//1-禁麦位2-清空消息3-清空魅力值4-加入黑名单5-踢出房间6-关闭麦克风7-申请上麦8-同意上麦9-拒绝上麦10-点歌11-开启PK',
public $room_log_type = [1=>'禁麦位',2=>'清空消息',3=>'清空魅力值',4=>'加入黑名单',5=>'踢出房间',6=>'关闭麦克风',7=>'申请上麦',8=>'同意上麦',9=>'拒绝上麦',10=>'点歌',11=>'开启PK'];
public function getList($where = [], $page = 1, $limit = 10)
{
$list = $this->where($where)->page($page, $limit)->select();
$list = collection($list)->toArray();
return $list;
}
public function getCount($where = [])
{
return $this->where($where)->count();
}
public function getOne($where = [])
{
$one = $this->where($where)->find();
return $one;
}
public function add($data)
{
$res = $this->save($data);
if (!$res) {
return false;
}
$guild_id = $this->id;
return $guild_id;
}
public function edit($where = [], $data = [])
{
$res = $this->where($where)->update($data);
return $res;
}
public function del($where = [])
{
$res = $this->where($where)->delete();
return $res;
}
//软删除
public function setDel($where = []){
$res = $this->where($where)->setField('delete_time',time());
if(!$res){
return false;
}
return $res;
}
/*
* 查询房间流水
*/
public function getRoomFlow($room_id,$stime='',$etime=''){
$give_where = [];
$give_where['from_id'] = $room_id;
$give_where['from'] = ["in",[2,3,6]];
if(!empty($stime)){
$give_where['createtime'] = ['>=',strtotime($stime.' 00:00:00')];
}
if(!empty($etime)){
$give_where['createtime'] = ['<=',strtotime($etime.' 23:59:59')];
}
if(!empty($stime) && !empty($etime)){
$give_where['createtime'] = ['between',[strtotime($stime.' 00:00:00'),strtotime($etime.' 23:59:59')]];
}
$total_price = db::name('vs_give_gift')->where($give_where)
->sum('total_price');
return $total_price;
}
}

View File

@@ -0,0 +1,138 @@
<?php
namespace app\adminapi\model;
use think\Model;
use think\Session;
use think\Db;
class User extends Model
{
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $name = 'user';
public function getList($where = [], $page = 1, $limit = 10)
{
$list = $this->where($where)->page($page, $limit)->select();
$list = collection($list)->toArray();
return $list;
}
public function getCount($where = [])
{
return $this->where($where)->count();
}
public function getOne($where = [])
{
$one = $this->where($where)->find();
return $one;
}
public function add($data)
{
$res = $this->save($data);
if (!$res) {
return false;
}
$guild_id = $this->id;
return $guild_id;
}
public function edit($where = [], $data = [])
{
$res = $this->where($where)->update($data);
return $res;
}
public function del($where = [])
{
$res = $this->where($where)->delete();
return $res;
}
//软删除
public function setDel($where = []){
$res = $this->where($where)->setField('delete_time',time());
if(!$res){
return false;
}
return $res;
}
/*
* 用户注册 (机器人)
*/
public function user_reg($user_name='')
{
$data = [];
$user_code = model('api/Login')->get_user_code(); //获取用户code_id 过滤靓号
$data['user_code'] = $user_code;
$data['username'] = $user_name;
$data['mobile'] = $user_name;
$data['nickname'] = '游客'.$user_code;
$data['joinip'] = request()->ip();
$data['birthday'] = date('Y-m-d');
$data['avatar'] = get_system_config_value('web_site').'/data/avatar/head_pic.png';
$data['profile'] = '这个人很懒,什么都没写';
$data['system'] = '';
$data['login_device'] = '';
$data['createtime'] = time();
$data['logintime'] = time();
$data['status'] = 1;
$data['is_robot'] = 1;
$data['is_sys_tester'] = 1;
$data['init_code'] = model('api/User')->invite_code();
$reslut = model('api/User')->insert($data);
//获取上一步的id
$user_id = model('api/User')->where('user_code',$user_code)->value('id');
if (!$reslut) {
return ['code' => 0, 'msg' => '登录失败le', 'data' => null];
};
//创建钱包
$user_wallet = model('api/UserWallet')->create_data($user_id);
if (!$user_wallet) {
return ['code' => 0, 'msg' => '登录失败1', 'data' => null];
}
//登录token
$login_token = model('api/UserToken')->update_token($user_id);
if(isset($login_token['code']) && $login_token['code'] != 1){
return ['code' => 0, 'msg' => '登录失败3', 'data' => null];
}
$user_data = [];
$user_data['tencent_im'] = "";
$user_data['createtime'] = time();
$user_data['user_id'] = $user_id;
$user_data['wx_openid'] = "";
$user_data['ali_userid'] = "";
$reslut_user_data = model('api/UserData')->save($user_data);
if (!$reslut_user_data) {
return ['code' => 0, 'msg' => '登录失败4', 'data' => null];
}
$return_res[0]['user_id'] = $user_id;
$return_res[0]['user_code'] = $user_code;
$return_res[0]['avatar'] = 'data/avatar/head_pic.png';
$return_res[0]['nickname'] = '游客'.$user_code;
$return_res[0]['token'] = $login_token;
$return_res[0]['tencent_im'] = "";
$return_res[0]['sex'] = 0;
$return_res[0]['mobile'] = $user_name;
$return_res[0]['auth'] = 0;
$return_res[0]['icon'][0] = model('api/UserData')->user_wealth_icon($user_id);//财富图标
$return_res[0]['icon'][1] = model('api/UserData')->user_charm_icon($user_id);//魅力图标
return ['code' => 1, 'msg' => '成功', 'data' => $return_res];
}
}