Compare commits
406 Commits
develop_te
...
f259bab4ed
| Author | SHA1 | Date | |
|---|---|---|---|
| f259bab4ed | |||
| 878f9f8ff7 | |||
| 8575a04639 | |||
| be9dee86dc | |||
| c93d05a1a3 | |||
| 75c4a27556 | |||
| d04e6d7303 | |||
| 8cc3cb3217 | |||
| 1276c4e8d5 | |||
| c5a622148f | |||
| 69e3570600 | |||
| a1010ff2c7 | |||
| e7b14d20f1 | |||
| 3a120b55cb | |||
| 761fc6e86f | |||
| f66f3a2247 | |||
| b570510602 | |||
| 373a8ecedd | |||
| 90b19f20b6 | |||
| 0e6afcaab9 | |||
| 30461d6986 | |||
| aaea1c429a | |||
| 7d327edd21 | |||
| b7ec1b1eda | |||
| 7e04e72070 | |||
| 43e69a2895 | |||
| 446076cc2e | |||
| 13cdbb56ee | |||
| d6ea318358 | |||
| 487f0277fd | |||
| 2046e61c1b | |||
| 34ea8ac762 | |||
| bad55084a1 | |||
| 405b632a8a | |||
| 59d646925f | |||
| 8922fa93f3 | |||
| e29f4bd4df | |||
| 08cd7af663 | |||
| 53964b5398 | |||
| 19bb1d742e | |||
| 29e35435a6 | |||
| b8b935c8b2 | |||
| 50a7226864 | |||
| 522c240771 | |||
| aa5ada0790 | |||
| 14107d60e4 | |||
| 48066e7b13 | |||
| fcad79edf1 | |||
| 91d19f413a | |||
| b0b6ef72a5 | |||
| 9bec4ef093 | |||
| 54abef6b56 | |||
| 7ad88c1e98 | |||
| c83216aa23 | |||
| 6f82b130c0 | |||
| f24de31a92 | |||
| b367d1a97d | |||
| 54bf441b6c | |||
| 2d392039ac | |||
| 4b379b7e53 | |||
| dd2c676ecc | |||
| 1d6b09e20e | |||
| abae40397c | |||
| 3a8ccf4c35 | |||
| 885d1a631a | |||
| 6b08d327ec | |||
| 097b719937 | |||
| 0ac1fc2b46 | |||
| 699d6d4245 | |||
| 767f51d1d6 | |||
| 06983dfe46 | |||
| 8bcee346ff | |||
| a588175a9e | |||
| 2d9edc4c78 | |||
| 2c45e0b38f | |||
| 824fc52717 | |||
| 5002913d70 | |||
| aa0615974b | |||
| 4765a738c0 | |||
| 1806a6a38a | |||
| 515955f65d | |||
| bea3dcd873 | |||
| 7eb9d49ede | |||
| 8f96b4cae3 | |||
| c083b0576f | |||
| 5822832ab3 | |||
| 1623277e26 | |||
| ffbf0c0f37 | |||
| 4d528e0e72 | |||
| a6ac190358 | |||
| 49728c6fcb | |||
| dc5eba281e | |||
| fd1a88cdf6 | |||
| c21d6ed238 | |||
| 401c3f8842 | |||
| 7f266b4b15 | |||
| 4eaa1efdbf | |||
| 2624aa6c56 | |||
| 74db686f47 | |||
| 6582f9ca96 | |||
| 4aa09e49a9 | |||
| 6c1cd57e6a | |||
| 094221ab2b | |||
| 8ef22d87a2 | |||
| a42ae7a94f | |||
| c2b49aad9f | |||
| 1903774cdf | |||
| ce2bf4c7ce | |||
| 8d995cb5b4 | |||
| 059703b1f4 | |||
| dc9d6671a4 | |||
| a4ee889127 | |||
| 9f8e25948a | |||
| 46821425a8 | |||
| 48625c4845 | |||
| 0447163694 | |||
| 323c800751 | |||
| f45b60c9d3 | |||
| aaa1837502 | |||
| 9a27bb7014 | |||
| 96ff53bbea | |||
| 29f7626fc8 | |||
| 0b687e6712 | |||
| b22c9af6a6 | |||
| bc0f052359 | |||
| 64d0812adb | |||
| a3109f6ab4 | |||
| 903496c893 | |||
| a198a31755 | |||
| 8b5a368b17 | |||
| 6c051fa8e7 | |||
| 98a94385a3 | |||
| a0b16e8f72 | |||
| ae1421c495 | |||
| 74759b5599 | |||
| d7838b772a | |||
| fa350cb505 | |||
| fe830e1a52 | |||
| 8b3c6e45ef | |||
| 36e8fec12f | |||
| 963df499b9 | |||
| 7d77ba7745 | |||
| f0bc7ec9ed | |||
| 377392b9dd | |||
| 1057fadb57 | |||
| 97e6c41725 | |||
| 90c4ec7346 | |||
| c22414b2fd | |||
| 9a95595dd8 | |||
| be15b70885 | |||
| 57a0c4f21d | |||
| 53e01f61ad | |||
| 5e37cddc82 | |||
| 446af258b9 | |||
| 35deebd0f8 | |||
| e753695146 | |||
| 4152f46504 | |||
| e293cacd44 | |||
| fbfc0975dd | |||
| d8a299e4a2 | |||
| 4d284c4328 | |||
| 413ff05221 | |||
| 334dca1b5d | |||
| 23bcf3f864 | |||
| a6bf88c22d | |||
| 737fb817d3 | |||
| 40879dd516 | |||
| 280d4be22b | |||
| dd3622adf0 | |||
| fc543ed9c1 | |||
| 26e4b4ac82 | |||
| 0660edfeeb | |||
| ffb073bf92 | |||
| 155a66d84c | |||
| c9b1d4c541 | |||
| 598dd3c471 | |||
| bd5cf6a0c5 | |||
| e4c73706bb | |||
| 8b9fd4d927 | |||
| 31c9d2a325 | |||
| 77c7e300f5 | |||
| 55e48b5e13 | |||
| 42785f219f | |||
| 5bc428b5f1 | |||
| 9c7dbe9b4d | |||
| 843b16f5cd | |||
| ce4e9ff0d7 | |||
| 46c4671920 | |||
| 8e59118d68 | |||
| 727132bef1 | |||
| 9066ea946f | |||
| d091589dac | |||
| bcafb4fae6 | |||
| c6ca1094bf | |||
| f509962c9b | |||
| ae8f35f54e | |||
| 7e6fdad0cf | |||
| e859b65659 | |||
| feb8dff689 | |||
| dae88e5ae6 | |||
| 3c8aa521ae | |||
| f7239cd9d4 | |||
| 9c9af7ce1f | |||
| 965718a18e | |||
| 716dcb810e | |||
| 8536183aad | |||
| 6e3b88c61c | |||
| bfbdcb8708 | |||
| b7f782db4a | |||
| d5c597db92 | |||
| f392b8c2ae | |||
| ae30b71aed | |||
| 9144f06859 | |||
| 74c496efbe | |||
| eddb1e2fc0 | |||
| 7e64fe73a9 | |||
| d81c2c977d | |||
| fcf5dcf94a | |||
| e1c45ea6cf | |||
| 5495e82905 | |||
| 805bbf9d00 | |||
| db01e57029 | |||
| f4c8c1ac9c | |||
| c04bcb7072 | |||
| 52893ee84f | |||
| a6a844ade0 | |||
| b3e63d74ac | |||
| 05aedf2231 | |||
| 971d11c27d | |||
| b79dc9236c | |||
| 24abbba56d | |||
| 89992325e5 | |||
| d4201cf3a6 | |||
| 94f6521907 | |||
| 16db1ccf1f | |||
| cd4e70b4d7 | |||
| ff52c3fee9 | |||
| d60e9cb0e0 | |||
| 3087e7aa6a | |||
| 92cf24a9dd | |||
| 7b428dc9ab | |||
| 14fc8ce0a3 | |||
| f8efd223ee | |||
| 227ad92a2f | |||
| 05915ae64a | |||
| b5834b4c33 | |||
| 136a819ccf | |||
| 2249223d31 | |||
| bf214611c3 | |||
| 174c9fd7b3 | |||
| 1291553ed9 | |||
| fff27c609b | |||
| c25ea4edc4 | |||
| fac55d0614 | |||
| 519ba46165 | |||
| 040f3312fa | |||
| 9612381897 | |||
| 2d2aaf3372 | |||
| 778e067540 | |||
| 13dfbd7e0c | |||
| 6f883cabdc | |||
| 9eebfd8268 | |||
| 1cedc4d547 | |||
| b7538b0340 | |||
| 5b467fca78 | |||
| 3cc5ee00b8 | |||
| da10e294ae | |||
| 1c17ec17ce | |||
| eeba316880 | |||
| 95768638ac | |||
| 99c95a92e1 | |||
| 40af6214b2 | |||
| 9095851f33 | |||
| ac4897f0ac | |||
| 38732a626a | |||
| 726d1c7c55 | |||
| f4edac6ef5 | |||
| fb9963d49f | |||
| 53d38e816c | |||
| f11fc0a099 | |||
| 12b6d1b866 | |||
| 8791579969 | |||
| d1f5dbf5e9 | |||
| d1d07197f1 | |||
| b46bef67df | |||
| 8ee7b255f3 | |||
| 38705cc76a | |||
| 5a76970fb4 | |||
| 33bc871529 | |||
| 71f24f26c8 | |||
| dd71e57903 | |||
| fef69f0640 | |||
| d96931c7e5 | |||
| 5ffe2fc3df | |||
| 132e9df303 | |||
| 581122b4d9 | |||
| 88682f65ce | |||
| de17f54160 | |||
| fcf19e80a4 | |||
| 41f10bc387 | |||
| 8221bfb85b | |||
| a701321417 | |||
| ff961f42ee | |||
| a3f6327739 | |||
| 0d758d8587 | |||
| 499f9407b6 | |||
| d1cdb23175 | |||
| cb6516bfea | |||
| ba78531cbe | |||
| b30efada95 | |||
| 203aeb3842 | |||
| c2765a0260 | |||
| c0a175092f | |||
| a6bc94af50 | |||
| 7373d66506 | |||
| 07ed282141 | |||
| 3972716675 | |||
| 0e80ab61a2 | |||
| 20071a4f40 | |||
| 3c5db83d4c | |||
| c1c79075d1 | |||
| 0aa351cd63 | |||
| 624a9478de | |||
| 2865e800e6 | |||
| 928f86011a | |||
| 4086c8282f | |||
| 005533fd27 | |||
| f5e8fad6bd | |||
| 5c6b6e028b | |||
| f1acf8db53 | |||
| 93b21b4ee0 | |||
| 891087cf7a | |||
| 618623432a | |||
| 165e0565b5 | |||
| 630e67693f | |||
| fce818807e | |||
| 4a254d9f28 | |||
| 52d41e9e36 | |||
| 34b74335c2 | |||
| 1119e366ee | |||
| 632527da5c | |||
| 78c06adaf8 | |||
| 8d6beb7884 | |||
| 68d1fe3cf6 | |||
| 93e7cb60e8 | |||
| 569bdbf4ce | |||
| f54a9b6728 | |||
| 686f24e090 | |||
| 09147525a0 | |||
| 149546ee8e | |||
| 1535a5cc33 | |||
| d5703bd99a | |||
| b1ff156a6c | |||
| df06595007 | |||
| 2a7179abe5 | |||
| 4be7ddc1c2 | |||
| c438fb049e | |||
| 70d5e2fc80 | |||
| 3824fae695 | |||
| 55161e242e | |||
| fbcc2a0483 | |||
| befc1bf41e | |||
| 55abd48d30 | |||
| 7a6695c7ed | |||
| 239815839a | |||
| a385776538 | |||
| 96822cf248 | |||
| 35a90fef3b | |||
| 67ae480665 | |||
| 5420a24800 | |||
| 002f20af78 | |||
| 30ad1e720d | |||
| 999a5603be | |||
| ffa9cc98ed | |||
| f81b84cf39 | |||
| c366cc34b0 | |||
| 98be6cc43e | |||
| 9dba7647c5 | |||
| 7f55f1997a | |||
| 88ebe674de | |||
| cedc621e95 | |||
| 4187931abd | |||
| a8b3d30ac6 | |||
| f439929e6d | |||
| b68db7b6c5 | |||
| ffd2769bad | |||
| 150aa8f5c7 | |||
| b3e52f9c3d | |||
| 07c71c04ba | |||
| 358dd0f2b7 | |||
| a1324cf390 | |||
| c0509263d4 | |||
| 33e9b3612a | |||
| 0fe00cf140 | |||
| 0d2bdb5f18 | |||
| 9e3ef5090a | |||
| 7a8a6ed462 | |||
| 3cd1ab90d6 | |||
| fd2809c1a8 | |||
| b47dc76429 | |||
| 0dcc0bfa80 | |||
| 4cdbc6a7cc | |||
| 7b827874e0 | |||
| 8538410fec | |||
| def606d3a0 | |||
| 2f5457107c |
@@ -60,7 +60,7 @@ class Auth extends \fast\Auth
|
||||
}
|
||||
$admin->loginfailure = 0;
|
||||
$admin->logintime = time();
|
||||
$admin->loginip = request()->ip();
|
||||
$admin->loginip = request()->server('HTTP_X_REAL_IP') ?: request()->server('HTTP_X_FORWARDED_FOR') ?: request()->ip();
|
||||
$admin->token = Random::uuid();
|
||||
$admin->save();
|
||||
Session::set("admin", $admin->toArray());
|
||||
@@ -229,6 +229,7 @@ class Auth extends \fast\Auth
|
||||
if ($this->logined) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$admin = Session::get('admin');
|
||||
if (!$admin) {
|
||||
$admin = Cache::get("admin_" . $token);
|
||||
@@ -239,6 +240,7 @@ class Auth extends \fast\Auth
|
||||
// Session::set("admin.safecode", $this->getEncryptSafecode($admin));
|
||||
}
|
||||
}
|
||||
|
||||
if (!$admin) {
|
||||
return false;
|
||||
}
|
||||
@@ -246,6 +248,7 @@ class Auth extends \fast\Auth
|
||||
if (!$my) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//校验安全码,可用于判断关键信息发生了变更需要重新登录
|
||||
// if (!isset($admin['safecode']) || $this->getEncryptSafecode($my) !== $admin['safecode']) {
|
||||
// $this->logout();
|
||||
@@ -259,12 +262,13 @@ class Auth extends \fast\Auth
|
||||
}
|
||||
}
|
||||
//判断管理员IP是否变动
|
||||
if (Config::get('fastadmin.loginip_check')) {
|
||||
if (!isset($admin['loginip']) || $admin['loginip'] != request()->ip()) {
|
||||
$this->logout();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// if (Config::get('fastadmin.loginip_check')) {
|
||||
// if (!isset($admin['loginip']) || $admin['loginip'] != request()->ip()) {
|
||||
// $this->logout();
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
$this->logined = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -77,6 +77,7 @@ class AdminLog extends Model
|
||||
}
|
||||
$title = implode(' / ', $title);
|
||||
}
|
||||
$login_ip = request()->server('HTTP_X_REAL_IP') ?: request()->server('HTTP_X_FORWARDED_FOR') ?: request()->ip();
|
||||
self::create([
|
||||
'title' => $title,
|
||||
'content' => !is_scalar($content) ? json_encode($content, JSON_UNESCAPED_UNICODE) : $content,
|
||||
@@ -84,7 +85,7 @@ class AdminLog extends Model
|
||||
'admin_id' => $admin_id,
|
||||
'username' => $username,
|
||||
'useragent' => substr(request()->server('HTTP_USER_AGENT'), 0, 255),
|
||||
'ip' => xss_clean(strip_tags(request()->ip()))
|
||||
'ip' => $login_ip//xss_clean(strip_tags(request()->ip()))
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -372,6 +372,8 @@ class BlindBox extends adminApi
|
||||
}
|
||||
$gift_id = input('gift_id', '');
|
||||
$description = input('description', '');
|
||||
$status = input('status', 1);
|
||||
|
||||
$introd =$_POST['introd']??"";
|
||||
if(empty($gift_id)){
|
||||
return V(0,"请配置礼物");
|
||||
@@ -386,7 +388,10 @@ class BlindBox extends adminApi
|
||||
'introd' => $introd,
|
||||
];
|
||||
$ext = json_encode($ext);
|
||||
$res = db::name('vs_gift_bag')->where(['id'=>$gift_bag_id])->update(['ext'=>$ext]);
|
||||
$res = db::name('vs_gift_bag')->where(['id'=>$gift_bag_id])->update([
|
||||
'ext'=>$ext,
|
||||
'status' => $status,
|
||||
]);
|
||||
if($res){
|
||||
return V(1,"成功");
|
||||
}else{
|
||||
@@ -406,6 +411,7 @@ class BlindBox extends adminApi
|
||||
'gift_id' => $ext_data['gift_id'],
|
||||
'description' => $ext_data['description'],
|
||||
'introd' => stripcslashes($ext_data['introd']),
|
||||
'status' => $gift_bag['status'],
|
||||
];
|
||||
if($gift_bag){
|
||||
return V(1,"成功",$ext);
|
||||
@@ -732,11 +738,11 @@ class BlindBox extends adminApi
|
||||
$room_id = input('room_id', '');
|
||||
$gift_bag_id = input('gift_bag_id', '');
|
||||
$periods = input('periods', '');
|
||||
$stime = input('stime', '');
|
||||
$etime = input('etime', '');
|
||||
$stime = input('stime', date('Y-m-d'));
|
||||
$etime = input('etime', date('Y-m-d h:i:s', time()));
|
||||
$where = [];
|
||||
if($room_id){
|
||||
$where['room_id'] = $room_id;
|
||||
$where['room_number'] = $room_id;
|
||||
}
|
||||
if($gift_id){
|
||||
$where['gift_id'] = $gift_id;
|
||||
|
||||
@@ -62,7 +62,7 @@ class Decorate extends adminApi
|
||||
$return_list[$k]['admin_name'] = db::name('admin')->where(['id'=>$v['admin_id']])->value('nickname')??"--";
|
||||
$return_list[$k]['ext_value'] = $v['ext_value'] ?? 0;
|
||||
$return_list[$k]['price'] = $v['price'] ?? 0;
|
||||
|
||||
$return_list[$k]['special_num'] = $v['special_num'] ?? '';
|
||||
|
||||
}
|
||||
$return_data = [
|
||||
@@ -97,6 +97,11 @@ class Decorate extends adminApi
|
||||
if($type==""){
|
||||
return V(0,"参数错");
|
||||
}
|
||||
if(in_array($type, [6,7,8])){
|
||||
if($special_num==""){
|
||||
return V(0,"请填写靓号");
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'title' => $title,
|
||||
@@ -152,6 +157,11 @@ class Decorate extends adminApi
|
||||
$special_num = input('special_num', '');
|
||||
$ext_value = input('ext_value', '');
|
||||
$price = input('price', '');
|
||||
if(in_array($type, [6,7,8])){
|
||||
if($special_num==""){
|
||||
return V(0,"请填写靓号");
|
||||
}
|
||||
}
|
||||
$data = [];
|
||||
if($title!=""){
|
||||
$data['title'] = $title;
|
||||
@@ -276,7 +286,15 @@ class Decorate extends adminApi
|
||||
return V(0,"该价格已存在");
|
||||
}
|
||||
//计算折扣取整
|
||||
$discount = round($price/$original_price, 2)*10;
|
||||
if($price==0 || $original_price==0){
|
||||
$discount = 0;
|
||||
}else{
|
||||
$discount = round($price/$original_price, 2)*10;
|
||||
if($discount >= 10){
|
||||
$discount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'did' => $did,
|
||||
'day' => $day,
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
namespace app\adminapi\controller;
|
||||
ini_set('memory_limit', '512M'); // 临时增加到512MB
|
||||
use app\common\controller\adminApi;
|
||||
use app\common\library\GiftTableManager;
|
||||
use think\Db;
|
||||
use think\Log;
|
||||
|
||||
class GiveGift extends adminApi
|
||||
{
|
||||
@@ -27,10 +29,16 @@ class GiveGift extends adminApi
|
||||
$from_id = input('from_id', '');//礼物来源id
|
||||
$gift_id = input('gift_id', '');//礼物id
|
||||
$from = input('from', '');// 来源类型,1聊天送礼物 2房间语聊送礼 3直播送礼 4动态打赏 5系统任务 6-cp房间送礼
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
|
||||
$where=[];
|
||||
//获取当前月份的开始时间和结束时间
|
||||
$firstDay = date('Y-m-01');
|
||||
$lastDay = date('Y-m-t 23:59:59');
|
||||
$start_time = input('start_time', $firstDay);
|
||||
$end_time = input('end_time', $lastDay);
|
||||
$start_time = empty($start_time) ? $firstDay : $start_time;
|
||||
$end_time = empty($end_time) ? $lastDay : $end_time;
|
||||
$search_time = [];
|
||||
$search_time = [strtotime($start_time), strtotime($end_time)];
|
||||
$where = [];
|
||||
$gwhere = [];
|
||||
if($send_user != ''){
|
||||
$user_id = db::name('user')->where('user_code', $send_user)->value('id');
|
||||
@@ -73,25 +81,40 @@ class GiveGift extends adminApi
|
||||
$gwhere['gg.createtime'] = ['<=', strtotime($end_time)];
|
||||
}
|
||||
}
|
||||
$page_array = [];
|
||||
$page_array = [
|
||||
'page' => !empty($page)?$page:1,
|
||||
'page_limit' => !empty($page_limit)?$page_limit:10,
|
||||
];
|
||||
$gift_list = model('Gift')->getGiftRecords($search_time,$where,$page_array);
|
||||
//礼物总数
|
||||
$gift_num = db::name('vs_give_gift')->where($where)->sum('number');
|
||||
$gift_num = $gift_list['number'];
|
||||
//总金额
|
||||
$total_price = db::name('vs_give_gift')->where($where)->sum('total_price');
|
||||
$total_price = $gift_list['total_price'];
|
||||
//平台收益
|
||||
$app_earning = 0;
|
||||
//接收人收益
|
||||
$receive_earning = 0;
|
||||
//房主收益
|
||||
$room_owner_earning = 0;
|
||||
|
||||
// 获取所有送礼记录
|
||||
$lists = db::name('vs_give_gift')->where($where)->order('id', 'desc')->page($page, $page_limit)->select();
|
||||
$count = db::name('vs_give_gift')->where($where)->count();
|
||||
$lists = $gift_list['lists'];
|
||||
$count = $gift_list['count'];
|
||||
// $lists = db::name('vs_give_gift')->where($where)->order('id', 'desc')->page($page, $page_limit)->select();
|
||||
// $count = db::name('vs_give_gift')->where($where)->count();
|
||||
$earning_list = [];
|
||||
if(!empty($where)){
|
||||
$tables = GiftTableManager::getTablesByTimeRange(
|
||||
strtotime($start_time),
|
||||
strtotime($end_time)
|
||||
);
|
||||
if(empty($tables)){
|
||||
$tables[0] = "fa_vs_give_gift";
|
||||
}
|
||||
$table_name = substr($tables[0], 3);//截取可查询的表名
|
||||
$earning_list = db::name('vs_give_gift_ratio_log')
|
||||
->alias('egl')
|
||||
->join('vs_give_gift gg', 'egl.give_gift_id = gg.id')
|
||||
->join($table_name.' gg', 'egl.give_gift_id = gg.id')
|
||||
->where($gwhere) // 替换为实际的筛选条件
|
||||
->field('egl.app_earning,egl.gift_user_earning,egl.room_owner_earning')
|
||||
->select();
|
||||
@@ -114,10 +137,11 @@ class GiveGift extends adminApi
|
||||
array_column($lists, 'user_id'),
|
||||
array_column($lists, 'gift_user')
|
||||
);
|
||||
$room_ids = array_filter(array_merge(
|
||||
array_column($lists, 'room_id'),
|
||||
array_column($lists, 'from_id')
|
||||
));
|
||||
// $room_ids = array_filter(array_merge(
|
||||
// array_column($lists, 'room_id'),
|
||||
// array_column($lists, 'from_id')
|
||||
// ));
|
||||
$room_ids = array_column($lists, 'from_id');
|
||||
$gift_ids_list = array_column($lists, 'gift_id');
|
||||
|
||||
// 批量获取用户信息
|
||||
@@ -149,7 +173,7 @@ class GiveGift extends adminApi
|
||||
if (!empty($gift_ids_list)) {
|
||||
$gift_list = db::name('vs_gift')
|
||||
->where('gid', 'in', array_unique($gift_ids_list))
|
||||
->field('gid,gift_name,gift_price')
|
||||
->field('gid,gift_name,gift_price,type,label')
|
||||
->select();
|
||||
foreach ($gift_list as $gift) {
|
||||
$gifts[$gift['gid']] = $gift;
|
||||
@@ -182,8 +206,11 @@ class GiveGift extends adminApi
|
||||
// 礼物信息
|
||||
$gift_info = isset($gifts[$value['gift_id']]) ? $gifts[$value['gift_id']] : null;
|
||||
$value['gift_name'] = $gift_info ? $gift_info['gift_name'].'-'.$value['gift_id'] : '';
|
||||
$value['gift_price'] = $gift_info ? $gift_info['gift_price'] : 0;
|
||||
|
||||
if($gift_info && $gift_info['label']==2){
|
||||
$value['gift_price'] ="未知(盲盒)";
|
||||
}else{
|
||||
$value['gift_price'] = $gift_info ? $gift_info['gift_price'] : 0;
|
||||
}
|
||||
// 房间信息处理
|
||||
if($value['from'] == 1){
|
||||
$value['room'] = '聊天送礼';
|
||||
@@ -231,4 +258,5 @@ class GiveGift extends adminApi
|
||||
$start = ($page - 1) * $limit;
|
||||
return array_slice($array, $start, $limit);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -606,44 +606,44 @@ class Guild extends adminApi
|
||||
$guild_id = input('guild_id', '');
|
||||
$merge_guild_id = input('merge_guild_id', '');
|
||||
//解散工会
|
||||
$guild = model('Guild')->getOne(['id'=>$guild_id]);
|
||||
$guild = model('Guild')->getOne(['guild_special_id'=>$guild_id]);
|
||||
$merge_guild=model('Guild')->getOne(['guild_special_id'=>$merge_guild_id]);
|
||||
if(empty($guild)){
|
||||
return V(0,"该工会不存在");
|
||||
}
|
||||
if($guild['status'] == 2){
|
||||
return V(0,"该工会已解散");
|
||||
}
|
||||
if(!$merge_guild_id){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
if(empty($merge_guild)){
|
||||
return V(0,"并入工会不存在");
|
||||
}
|
||||
$guild_id = $guild['id'];
|
||||
$merge_guild_id = $merge_guild['id'];
|
||||
db::startTrans();
|
||||
try{
|
||||
$res = model('Guild')->edit(['id'=>$guild_id],['status'=>2,'delete_time'=>time()]);
|
||||
//并入工会
|
||||
if(!$merge_guild_id){
|
||||
db::rollback();
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$merge_guild = model('Guild')->getOne(['id'=>$merge_guild_id]);
|
||||
if(empty($merge_guild)){
|
||||
db::rollback();
|
||||
return V(0,"并入工会不存在");
|
||||
}
|
||||
$merge_guild_user = db('vs_guild_user')->where(['guild_id'=>$merge_guild_id,'quit_type'=>0])->select();
|
||||
$merge_guild_user = db('vs_guild_user')->where(['guild_id'=>$guild_id,'quit_type'=>0,'status'=>1])->select();
|
||||
foreach ($merge_guild_user as $key=>$value){
|
||||
$res = db('vs_guild_user')->insert([
|
||||
'user_id'=>$value['user_id'],
|
||||
'guild_id'=>$merge_guild_id,
|
||||
'room_id'=>$value['room_id'],
|
||||
'coin'=>$value['coin'],
|
||||
'status'=>$value['status'],
|
||||
'is_deacon'=>$value['is_deacon'],
|
||||
'is_show_room'=>$value['is_show_room'],
|
||||
'remarks'=>$value['remarks'],
|
||||
'apply_time'=>$value['apply_time'],
|
||||
'remarks'=>"公会合并:从".$guild['guild_name']."合入".$merge_guild['guild_name'],
|
||||
'settlement_ratio' =>$value['settlement_ratio'],
|
||||
'apply_time'=>time(),
|
||||
'createtime'=>time(),
|
||||
]);
|
||||
if(!$res){
|
||||
db::rollback();
|
||||
return V(0,"失败");
|
||||
}
|
||||
//更新公会人数
|
||||
db('vs_guild')->where('id', $merge_guild_id)->setInc('num');
|
||||
//拉用户进入工会群聊
|
||||
$rid = 'g'.$merge_guild_id;
|
||||
$reslut = model('api/Tencent')->add_group_member($rid, $value['user_id']);
|
||||
@@ -654,7 +654,7 @@ class Guild extends adminApi
|
||||
return V(0,"失败");
|
||||
}
|
||||
//解散群
|
||||
model('Tencent')->delete_group('g'.$guild_id);
|
||||
model('api/Tencent')->delete_group('g'.$guild_id);
|
||||
db::commit();
|
||||
return V(1,"成功");
|
||||
} catch(\Exception $e) {
|
||||
|
||||
@@ -75,7 +75,7 @@ class Lottery extends adminApi
|
||||
$lists_data = db::name('bb_lottery_winner_record')->field('id,uid as user_id,prize_type,prize_amount,pool_amount,ratio,release_amount,status,create_time as createtime')->where($where)->page($page, $page_limit)->order("id desc")->select();
|
||||
foreach ($lists_data as $k=>$v){
|
||||
$user_info = db::name('user')->where(['id'=>$v['user_id']])->find();
|
||||
$lists_data[$k]['user_code'] = $user_info['user_code'];
|
||||
$lists_data[$k]['user_code'] = $user_info['user_code']??"";
|
||||
$lists_data[$k]['nickname'] = $user_info['user_code']."-".$user_info['nickname'];
|
||||
//奖项类型:1-小奖 2-大奖
|
||||
$lists_data[$k]['prize_type_str'] = $v['prize_type']==1?"小奖":"大奖";
|
||||
@@ -115,13 +115,19 @@ class Lottery extends adminApi
|
||||
->sum('amount') ?: 0;
|
||||
//最近中奖用户
|
||||
$last_winner_user_id = db::name('bb_lottery_winner_record')->where(['status'=>1])->order('id desc')->find();
|
||||
$last_winner_user_info = db::name('user')->where(['id'=>$last_winner_user_id['uid']])->find();
|
||||
if($last_winner_user_id){
|
||||
$last_winner_user_info = db::name('user')->where(['id'=>$last_winner_user_id['uid']])->find();
|
||||
$last_winner_user_text = "用户ID:".$last_winner_user_info['user_code']." 获得 ".$last_winner_user_id['prize_amount']." 金币 (".$last_winner_user_id['ratio']."%)";
|
||||
}else{
|
||||
$last_winner_user_text = "无";
|
||||
}
|
||||
|
||||
//平台累计收入
|
||||
$platform_total_income = db::name('bb_lottery_pool_flow')->where(['type'=>4])->sum('amount');
|
||||
$return_data=[
|
||||
'pool_progress' => $pool_progress_str,
|
||||
'pool_amount_now' => ($bigAddGold)."金币 (".(($bigAddGold)/$bb_config['big_pool_threshold']['value'])."%)",
|
||||
'last_winner_user' => "用户ID:".$last_winner_user_info['user_code']." 获得 ".$last_winner_user_id['prize_amount']." 金币 (".$last_winner_user_id['ratio']."%)",
|
||||
'last_winner_user' => $last_winner_user_text,
|
||||
'platform_total_income' => $platform_total_income." 金币",
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
|
||||
@@ -4,6 +4,8 @@ namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\adminApi;
|
||||
use app\common\library\GiftTableManager;
|
||||
use think\Cache;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Hook;
|
||||
@@ -220,6 +222,14 @@ class Room extends adminApi
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
}
|
||||
$lists[]=[
|
||||
'createtime' => '',
|
||||
'deletetime' => 0,
|
||||
'id' => -1,
|
||||
'type_name' => '练歌房',
|
||||
'status' => 1,
|
||||
'sort' => 99
|
||||
];
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
@@ -474,7 +484,12 @@ class Room extends adminApi
|
||||
$where['room_status'] = $search_status;
|
||||
}
|
||||
if($type_id!==''){
|
||||
$where['type_id'] = $type_id;
|
||||
if($type_id == -1){
|
||||
$where['type_id'] = 1;
|
||||
$where['label_id'] = 2;
|
||||
}else{
|
||||
$where['type_id'] = $type_id;
|
||||
}
|
||||
}else{
|
||||
$where['type_id'] = ['<>',6];
|
||||
}
|
||||
@@ -509,8 +524,14 @@ class Room extends adminApi
|
||||
$lists[$key]['user_name'] = model('User')->where(['id'=>$value['user_id']])->value('nickname');
|
||||
$lists[$key]['room_name'] = $value['room_name'];
|
||||
$lists[$key]['room_cover'] = $value['room_cover'];
|
||||
$lists[$key]['room_type_str'] = db::name($this->table_room_type)->where(['id'=>$value['type_id']])->value('type_name');
|
||||
$lists[$key]['room_label_str'] = db::name($this->table_room_label)->where(['id'=>$value['label_id']])->value('label_name');
|
||||
if($value['type_id']==1 && $value['label_id']==2){
|
||||
$lists[$key]['room_type_str'] = "练歌房";
|
||||
$lists[$key]['room_label_str'] = "练歌房";
|
||||
$value['type_id']=-1;
|
||||
}else{
|
||||
$lists[$key]['room_type_str'] = db::name($this->table_room_type)->where(['id'=>$value['type_id']])->value('type_name');
|
||||
$lists[$key]['room_label_str'] = db::name($this->table_room_label)->where(['id'=>$value['label_id']])->value('label_name');
|
||||
}
|
||||
$lists[$key]['is_recommend'] = $value['is_recommend'] != 1 ? '是' : '否';
|
||||
$lists[$key]['is_top'] = $value['is_top'] != 1 ? '是' : '否';
|
||||
$lists[$key]['is_hot'] = $value['is_hot'] != 1 ? '是' : '否';
|
||||
@@ -641,6 +662,10 @@ class Room extends adminApi
|
||||
}
|
||||
$room_data['growth_week_subsidy'] = round($weekSubsidy, 2);
|
||||
|
||||
if($room_data['type_id']==1 && $room_data['label_id']==2){
|
||||
$room_data['type_id']=-1;
|
||||
}
|
||||
|
||||
return V(1,"成功", $room_data);
|
||||
}
|
||||
|
||||
@@ -695,86 +720,69 @@ class Room extends adminApi
|
||||
$type = input('type', 1);//1:全部流水 2:日流水 3:周流水 4:月流水
|
||||
$stime = input('stime', '');
|
||||
$etime = input('etime', '');
|
||||
|
||||
$firstDay = date('Y-m-01');
|
||||
$lastDay = date('Y-m-t 23:59:59');
|
||||
$begin_time_table = empty($stime) ? $firstDay : $stime;
|
||||
$end_time_table = empty($etime) ? $lastDay : $etime;
|
||||
if($room_id == ''){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
if($type == 1){
|
||||
$begin_time = 1748676768;//2025-06-00 15:32:48
|
||||
$end_time = time();
|
||||
$where['a.createtime'] = ['between', [$begin_time, $end_time]];
|
||||
}elseif ($type == 2){
|
||||
//日流水
|
||||
$begin_time = strtotime(date('Y-m-d 00:00:00',time()));
|
||||
$end_time = time();
|
||||
$where['a.createtime'] = ['between', [$begin_time, $end_time]];
|
||||
}
|
||||
elseif ($type == 3){
|
||||
//周流水
|
||||
//本周一
|
||||
$begin_time = strtotime(date('Y-m-d 00:00:00', strtotime('this week')));
|
||||
$end_time = time();
|
||||
$where['a.createtime'] = ['between', [$begin_time, $end_time]];
|
||||
}
|
||||
elseif ($type == 4){
|
||||
$begin_time = strtotime(date('Y-m-01'));
|
||||
$end_time = time();
|
||||
$where['a.createtime'] = ['between', [$begin_time, $end_time]];
|
||||
}
|
||||
if($stime != '' && $etime != ''){
|
||||
$begin_time = strtotime($stime);
|
||||
$end_time = strtotime($etime);
|
||||
$where['a.createtime'] = ['between', [$begin_time, $end_time]];
|
||||
}elseif($stime != '' && $etime == ''){
|
||||
$begin_time = strtotime($stime);
|
||||
$end_time = time();
|
||||
$where['a.createtime'] = ['between', [$begin_time, $end_time]];
|
||||
}elseif($etime != '' && $stime == ''){
|
||||
$end_time = strtotime($etime);
|
||||
$where['a.createtime'] = ['<=', $etime];
|
||||
}
|
||||
|
||||
$count = db::name('vs_give_gift')->alias('a')
|
||||
->field('a.id')
|
||||
->join('user b', 'a.user_id = b.id', 'left')
|
||||
->join('user c', 'a.gift_user = c.id', 'left')
|
||||
->join('vs_gift d', 'a.gift_id = d.gid', 'left')
|
||||
->where('a.from',2)
|
||||
->where('a.from_id',$room_id)
|
||||
->where($where)
|
||||
->count();
|
||||
$list = db::name('vs_give_gift')->alias('a')
|
||||
->field('a.number,a.createtime,a.total_price,a.type,b.nickname,b.avatar,c.nickname as gift_nickname,c.avatar as gift_avatar,d.gift_name,a.from,a.from_id')
|
||||
->join('user b', 'a.user_id = b.id', 'left')
|
||||
->join('user c', 'a.gift_user = c.id', 'left')
|
||||
->join('vs_gift d', 'a.gift_id = d.gid', 'left')
|
||||
->where('a.from',2)
|
||||
->where('a.from_id',$room_id)
|
||||
->where($where)
|
||||
->order('a.id desc')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
$params['from_id'] = $room_id;
|
||||
$ext_params['start_time'] = strtotime($begin_time_table);
|
||||
$ext_params['end_time'] = strtotime($end_time_table);
|
||||
$params['page'] = $page;
|
||||
$params['limit'] = $page_limit;
|
||||
$res = model('api/GiveGiftBases')->getGiftRecords($params,$ext_params);
|
||||
$list = $res['data'];
|
||||
$count = $res['total'];
|
||||
$list_data = [];
|
||||
foreach ($list as &$value) {
|
||||
$value['time'] = date('Y-m-d', $value['createtime']);
|
||||
$value['sender_nickname'] = db::name('user')->where('id', $value['user_id'])->value('nickname');
|
||||
$value['sender_avatar'] = db::name('user')->where('id', $value['user_id'])->value('avatar');
|
||||
$value['receive_nickname'] = db::name('user')->where('id', $value['gift_user'])->value('nickname');
|
||||
$value['receive_avatar'] = db::name('user')->where('id', $value['gift_user'])->value('avatar');
|
||||
$value['gift_name'] = db::name('vs_gift')->where('gid', $value['gift_id'])->value('gift_name');
|
||||
|
||||
}
|
||||
if($list){
|
||||
foreach ($list as &$v){
|
||||
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
|
||||
$v['content'] = $v['nickname'].' 给 '.$v['gift_nickname'].' 送了 '.$v['gift_name'].' x '.$v['number'];
|
||||
$v['content'] = $v['sender_nickname'].' 给 '.$v['receive_nickname'].' 送了 '.$v['gift_name'].' x '.$v['number'];
|
||||
// 来源:1聊天送礼物 2房间语聊送礼 3直播送礼 4动态打赏
|
||||
$v['from_str'] = model('Gift')->GiveGiftFromStr[$v['from']];
|
||||
|
||||
$v['from_str'] = model('adminapi/Gift')->GiveGiftFromStr[$v['from']];
|
||||
}
|
||||
}
|
||||
$where =[];
|
||||
$where['createtime'] = ['between', [strtotime($begin_time_table), strtotime($end_time_table)]];
|
||||
$all_total_price = 0;
|
||||
$tables = GiftTableManager::getTablesByTimeRange(
|
||||
strtotime($begin_time_table),
|
||||
strtotime($end_time_table)
|
||||
);
|
||||
if($tables){
|
||||
foreach ($tables as $table_name){
|
||||
//表前缀
|
||||
$table_prefix = config('database.prefix');
|
||||
$table_name = str_replace($table_prefix, '', $table_name);
|
||||
$total_price = db::name($table_name)
|
||||
->where('from',2)
|
||||
->where('from_id',$room_id)
|
||||
->where($where)->sum('total_price');
|
||||
$all_total_price += $total_price;
|
||||
}
|
||||
}
|
||||
//幸运流水总计
|
||||
$total_lucky_coin = db::name('vs_room_luck_value')->alias('a')->where('room_id',$room_id)->where($where)->sum('luck_value');
|
||||
$total_lucky_coin = db::name('vs_room_luck_value')->where('room_id',$room_id)->where($where)->sum('luck_value');
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $list,
|
||||
'total' =>[
|
||||
'total_price' => db::name('vs_give_gift')->alias('a')
|
||||
->join('user b', 'a.user_id = b.id', 'left')
|
||||
->where('a.from',2)
|
||||
->where('a.from_id',$room_id)
|
||||
->where($where)->sum('total_price'),
|
||||
'total_price' => $all_total_price,
|
||||
'total_lucky_coin' => $total_lucky_coin,
|
||||
]
|
||||
];
|
||||
@@ -950,8 +958,27 @@ class Room extends adminApi
|
||||
if($sort !== ""){
|
||||
$data['sort'] = $sort;
|
||||
}
|
||||
if($type_id==-1){
|
||||
model('api/RoomSong')->agree_song(1,$room_id,1);
|
||||
unset($data['type_id']);
|
||||
}
|
||||
if($type_id==1){
|
||||
$data['label_id'] = 1;
|
||||
//推送给前端
|
||||
$text = [
|
||||
'room_id' => $room_id,
|
||||
'type' => $type_id,
|
||||
'text' => '房间类型已修改type--'.$type_id
|
||||
];
|
||||
model('api/Chat')->sendMsg(1012,$room_id,$text);
|
||||
}
|
||||
if($type_id == 9){
|
||||
$data['label_id'] = 6;
|
||||
}
|
||||
$data['updatetime'] = time();
|
||||
$res = db::name('vs_room')->where('id',$room_id)->update($data);
|
||||
if($res){
|
||||
Cache::rm('room_info_'.$room_id);
|
||||
return V(1,"成功");
|
||||
}
|
||||
else{
|
||||
|
||||
@@ -46,7 +46,7 @@ class SingerSong extends adminApi
|
||||
->join('user u', 'ss.user_id=u.id', 'left')
|
||||
->field('ss.*,u.nickname,u.avatar,u.user_code,u.mobile,u.sex')
|
||||
->where($where)
|
||||
->order('ss.id desc')
|
||||
->order('ss.status asc ,ss.id desc')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
if($list){
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\common\controller\adminApi;
|
||||
use app\common\library\GiftTableManager;
|
||||
use think\Db;
|
||||
use Yzh\YunPay;
|
||||
|
||||
@@ -11,6 +12,7 @@ class Statistical extends adminApi
|
||||
//初始化
|
||||
public function _initialize()
|
||||
{
|
||||
set_time_limit(0);
|
||||
parent::_initialize();
|
||||
}
|
||||
|
||||
@@ -85,6 +87,12 @@ class Statistical extends adminApi
|
||||
$search_uid = input('search_uid', '');
|
||||
$begin_time = input('begin_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
|
||||
$firstDay = date('Y-m-01');
|
||||
$lastDay = date('Y-m-t 23:59:59');
|
||||
$begin_time = empty($begin_time) ? $firstDay : $begin_time;
|
||||
$end_time = empty($end_time) ? $lastDay : $end_time;
|
||||
|
||||
$where=[];
|
||||
$group = 'user_id';
|
||||
if($type == 2){
|
||||
@@ -117,11 +125,20 @@ class Statistical extends adminApi
|
||||
if(!empty($begin_time) && !empty($end_time)){
|
||||
$where['createtime'] = ['between',[strtotime($begin_time),strtotime($end_time)]];
|
||||
}
|
||||
$count = db::name('vs_give_gift')
|
||||
|
||||
$tables = GiftTableManager::getTablesByTimeRange(
|
||||
strtotime($begin_time),
|
||||
strtotime($end_time)
|
||||
);
|
||||
if(empty($tables)){
|
||||
$tables[0] = "fa_vs_give_gift";
|
||||
}
|
||||
$table_name = substr($tables[0], 3);//截取可查询的表名
|
||||
$count = db::name($table_name)
|
||||
->where($where)
|
||||
->group($group)
|
||||
->count();
|
||||
$lists = db::name('vs_give_gift')
|
||||
$lists = db::name($table_name)
|
||||
->field('id,createtime,user_id,gift_user,sum(total_price) as total_price,sum(number) as number')
|
||||
->where($where)
|
||||
->group($group)
|
||||
@@ -185,13 +202,13 @@ class Statistical extends adminApi
|
||||
// 1.系统调节 2.充值 3.提现 4.金币转增(送出) 5.每日任务奖励 6.充值返利 7.购买装扮
|
||||
// 8.礼盒奖励 9.房间补贴 10.购买礼物 11.收礼增加收益 12.工会补贴 13.转赠金币(接收) 14.收益兑换
|
||||
// 15.首充 16.天降好礼充值 17.退出工会扣款 18.房主收益 19.主持人收益 20.抢头条 21.公会长收益
|
||||
$where['change_type'] = ['in', [4,7,10,17,20]];
|
||||
$count = db::name('vs_user_money_log')
|
||||
$where['change_type'] = ['in', [4,7,10,17,20,24,25,32,42,50,56,59]];
|
||||
$count = db::name('user_coin_log')
|
||||
->where($where)
|
||||
->group('user_id')
|
||||
->count();
|
||||
$lists = db::name('vs_user_money_log')
|
||||
->field('log_id,createtime,user_id,sum(change_value) as change_value')
|
||||
$lists = db::name('user_coin_log')
|
||||
->field('id,createtime,user_id,sum(coin) as change_value')
|
||||
->where($where)
|
||||
->group('user_id')
|
||||
->order('change_value desc')
|
||||
@@ -209,7 +226,7 @@ class Statistical extends adminApi
|
||||
'count' => $count,
|
||||
'lists' => $lists,
|
||||
'total' =>[
|
||||
'total_price' => db::name('vs_user_money_log')->where($where)->sum('change_value')
|
||||
'total_price' => db::name('user_coin_log')->where($where)->sum('coin')
|
||||
]
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
@@ -244,13 +261,21 @@ class Statistical extends adminApi
|
||||
if(!empty($begin_time) && !empty($end_time)){
|
||||
$where['createtime'] = ['between',[strtotime($begin_time),strtotime($end_time)]];
|
||||
}
|
||||
$tables = GiftTableManager::getTablesByTimeRange(
|
||||
strtotime($begin_time),
|
||||
strtotime($end_time)
|
||||
);
|
||||
if(empty($tables)){
|
||||
$tables[0] = "fa_vs_give_gift";
|
||||
}
|
||||
$table_name = substr($tables[0], 3);//截取可查询的表名
|
||||
//不为空
|
||||
$where['from'] = 2;
|
||||
$count = db::name('vs_give_gift')
|
||||
$count = db::name($table_name)
|
||||
->where($where)
|
||||
->group('from_id')
|
||||
->count();
|
||||
$lists = db::name('vs_give_gift')
|
||||
$lists = db::name($table_name)
|
||||
->field('id,createtime,user_id,gift_user,sum(total_price) as total_price,sum(number) as number,from_id')
|
||||
->where($where)
|
||||
->group('from_id')
|
||||
@@ -303,7 +328,7 @@ class Statistical extends adminApi
|
||||
'count' => $count,
|
||||
'lists' => $lists,
|
||||
'total' =>[
|
||||
'total_price' => db::name('vs_give_gift')->where($where)->sum('total_price'),
|
||||
'total_price' => db::name($table_name)->where($where)->sum('total_price'),
|
||||
'total_lucky_coin' => db::name('vs_room_luck_value')->where($where_lucky)->sum('luck_value'),
|
||||
]
|
||||
];
|
||||
@@ -521,28 +546,35 @@ class Statistical extends adminApi
|
||||
$search_user_id = 0;
|
||||
$search_gift_bag_id = 0;
|
||||
if($search_id){
|
||||
$search_user_id= db::name('user')->where('user_code', $search_id)->value('id');
|
||||
$where['b.user_code'] = $search_id;
|
||||
}
|
||||
if($search_name){
|
||||
$where['b.nickname'] = ['like', '%'.$search_name.'%'];
|
||||
$search_user_id= db::name('user')->where('nickname', $search_name)->value('id');
|
||||
}
|
||||
if($search_task_id){
|
||||
$where['a.task_id'] = $search_task_id;
|
||||
$search_gift_bag_id = db::name('vs_tasks')->where('id', $search_task_id)->value('tasks_bag_id');
|
||||
}
|
||||
if($search_task_name){
|
||||
$where['c.task_name'] = ['like', '%'.$search_task_name.'%'];
|
||||
$search_gift_bag_id = db::name('vs_tasks')->where('task_name', $search_task_name)->value('tasks_bag_id');
|
||||
}
|
||||
if($begin_time !== ''){
|
||||
$where['a.collection_time'] = ['>=', strtotime($begin_time)];
|
||||
if(!empty($begin_time) && !empty($end_time)){
|
||||
$where['a.collection_time'] = ['between', [strtotime($begin_time), strtotime($end_time)]];
|
||||
}else{
|
||||
if(!empty($begin_time)){
|
||||
$where['a.collection_time'] = ['>=', strtotime($begin_time)];
|
||||
}elseif(!empty($end_time)){
|
||||
$where['a.collection_time'] = ['<=', strtotime($end_time)];
|
||||
}
|
||||
}
|
||||
if($end_time !== ''){
|
||||
$where['a.collection_time'] = ['<=', strtotime($end_time)];
|
||||
if(!empty($begin_time) && !empty($end_time)){
|
||||
$where['a.createtime'] = ['between', [strtotime($begin_time), strtotime($end_time)]];
|
||||
}else{
|
||||
if(!empty($begin_time)){
|
||||
$where['a.createtime'] = ['>=', strtotime($begin_time)];
|
||||
}elseif(!empty($end_time)){
|
||||
$where['a.createtime'] = ['<=', strtotime($end_time)];
|
||||
}
|
||||
}
|
||||
|
||||
// 添加条件:只统计已领取的任务奖励
|
||||
// $where['a.is_claimed'] = 1;
|
||||
|
||||
@@ -632,28 +664,42 @@ class Statistical extends adminApi
|
||||
//奖品价值
|
||||
$data_list[$listkey]['reward_price'] = 0;
|
||||
|
||||
$data_list[$listkey]['completion_time'] = date('Y-m-d H:i:s', $list['completion_time']);
|
||||
$data_list[$listkey]['collection_time'] = date('Y-m-d H:i:s', $list['collection_time']);
|
||||
|
||||
// 计算奖励信息
|
||||
if (isset($bag_details[$list['tasks_bag_id']])) {
|
||||
$reward_info = $bag_details[$list['tasks_bag_id']];
|
||||
foreach ($reward_info as $value) {
|
||||
//价格
|
||||
$reward_price = 0;
|
||||
if($value['type'] == 1){
|
||||
$reward_name = $value['quantity'].$value['name'];
|
||||
$reward_price = $value['gold'] * $value['quantity'];
|
||||
}elseif($value['type'] == 2){
|
||||
$reward_name = $value['name'].'x'.$value['quantity'];
|
||||
$gift_price = isset($gift_prices[$value['foreign_id']]) ? $gift_prices[$value['foreign_id']] : 0;
|
||||
$reward_price = $gift_price * $value['quantity'];
|
||||
}elseif($value['type'] == 3){
|
||||
$reward_name = $value['name'].'x'.$value['days'].'天';
|
||||
//$reward_price = isset($decorate_prices[$value['foreign_id']]) ? $decorate_prices[$value['foreign_id']] : 0;
|
||||
}else{
|
||||
$reward_name = $value['quantity'].$value['name'];
|
||||
//$reward_price = $value['gold'] * $value['quantity'];
|
||||
if($list['task_id']==1){
|
||||
$sign_in_info = Db::name('vs_user_tasks_sign_in')->where(['user_id'=>$list['user_id'],'sign_in_date'=>date('Y-m-d', $list['createtime'])])->order('id desc')->find();
|
||||
if($sign_in_info){
|
||||
$data_list[$listkey]['reward_str'] = ($bag_details[$list['tasks_bag_id']][$sign_in_info['continuous']-1]['gold']
|
||||
* $bag_details[$list['tasks_bag_id']][$sign_in_info['continuous']-1]['quantity'])
|
||||
.$bag_details[$list['tasks_bag_id']][$sign_in_info['continuous']-1]['name'];
|
||||
$data_list[$listkey]['reward_price'] = $bag_details[$list['tasks_bag_id']][$sign_in_info['continuous']-1]['gold']
|
||||
* $bag_details[$list['tasks_bag_id']][$sign_in_info['continuous']-1]['quantity'];
|
||||
}
|
||||
}else{
|
||||
$reward_info = $bag_details[$list['tasks_bag_id']];
|
||||
foreach ($reward_info as $value) {
|
||||
//价格
|
||||
$reward_price = 0;
|
||||
if($value['type'] == 1){
|
||||
$reward_name = $value['quantity'].$value['name'];
|
||||
$reward_price = $value['gold'] * $value['quantity'];
|
||||
}elseif($value['type'] == 2){
|
||||
$reward_name = $value['name'].'x'.$value['quantity'];
|
||||
$gift_price = isset($gift_prices[$value['foreign_id']]) ? $gift_prices[$value['foreign_id']] : 0;
|
||||
$reward_price = $gift_price * $value['quantity'];
|
||||
}elseif($value['type'] == 3){
|
||||
$reward_name = $value['name'].'x'.$value['days'].'天';
|
||||
//$reward_price = isset($decorate_prices[$value['foreign_id']]) ? $decorate_prices[$value['foreign_id']] : 0;
|
||||
}else{
|
||||
$reward_name = $value['quantity'].$value['name'];
|
||||
//$reward_price = $value['gold'] * $value['quantity'];
|
||||
}
|
||||
$data_list[$listkey]['reward_str'] .= $reward_name." ";
|
||||
$data_list[$listkey]['reward_price'] += $reward_price;
|
||||
}
|
||||
$data_list[$listkey]['reward_str'] .= $reward_name." ";
|
||||
$data_list[$listkey]['reward_price'] += $reward_price;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -661,42 +707,125 @@ class Statistical extends adminApi
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'total_reward_price' => $this->get_claimed_reward_price($begin_time, $end_time,$search_user_id,$search_gift_bag_id),
|
||||
'total_reward_price' => 0,//$this->get_claimed_reward_price($begin_time, $end_time,$search_user_id,$search_gift_bag_id),
|
||||
'lists' => $data_list,
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
//每日任务领取金币统计
|
||||
public function get_claimed_reward_price_show(){
|
||||
$search_id = input('search_uid', '');
|
||||
$search_name = input('search_name', '');
|
||||
$search_task_id = input('search_task_id', '');
|
||||
$search_task_name = input('search_task_name', '');
|
||||
$begin_time = input('begin_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
$search_user_id = 0;
|
||||
if($search_id){
|
||||
$search_user_id= db::name('user')->where('user_code', $search_id)->value('id');
|
||||
}
|
||||
if($search_name){
|
||||
$search_user_id= db::name('user')->where('nickname', $search_name)->value('id');
|
||||
}
|
||||
$search_gift_bag_id = 0;
|
||||
if($search_task_name){
|
||||
$search_gift_bag_id = db::name('vs_tasks')->where('task_name', $search_task_name)->value('tasks_bag_id');
|
||||
}
|
||||
if($search_task_id){
|
||||
$search_gift_bag_id = db::name('vs_tasks')->where('id', $search_task_id)->value('tasks_bag_id');
|
||||
}
|
||||
$total_reward_price = $this->get_claimed_reward_price($begin_time, $end_time,$search_user_id,$search_gift_bag_id);
|
||||
return V(1,"成功", ['total_reward_price' => $total_reward_price]);
|
||||
}
|
||||
//获取已领取任务奖励的总价值
|
||||
public function get_claimed_reward_price($stime="",$etime="",$search_user_id=0,$search_gift_bag_id=0){
|
||||
//获取所有已领取的任务奖励礼包
|
||||
$where = [];
|
||||
if(!empty($stime)){
|
||||
$where['a.createtime'] = ['>=', strtotime($stime)];
|
||||
}
|
||||
if(!empty($etime)){
|
||||
$where['a.createtime'] = ['<=', strtotime($etime)];
|
||||
}
|
||||
if($search_user_id > 0){
|
||||
$where['a.user_id'] = $search_user_id;
|
||||
}
|
||||
if($search_gift_bag_id > 0){
|
||||
$where['a.gift_bag_id'] = $search_gift_bag_id;
|
||||
}
|
||||
$tasks_bag_details = db::name('vs_gift_bag_receive_log')
|
||||
->alias('a')
|
||||
->join('vs_gift_bag_detail b', 'a.parent_id=b.id')
|
||||
->field('a.createtime,b.type,b.foreign_id,b.quantity,b.gold')
|
||||
->where(['b.type'=>['in', [1,2]]])
|
||||
->where('a.gift_bag_id','>=',18)
|
||||
->where('a.gift_bag_id','<=',51)
|
||||
->where($where)
|
||||
->select();
|
||||
if(!empty($etime) && strtotime($etime)<="1767114849"){//2025-12-31 01:14:09
|
||||
if(!empty($stime) && !empty($etime)){
|
||||
$where['a.createtime'] = ['between', [strtotime($stime), strtotime($etime)]];
|
||||
}else{
|
||||
if(!empty($stime)){
|
||||
$where['a.createtime'] = ['>=', strtotime($stime)];
|
||||
}elseif(!empty($etime)){
|
||||
$where['a.createtime'] = ['<=', strtotime($etime)];
|
||||
}
|
||||
}
|
||||
$tasks_bag_details = db::name('vs_gift_bag_receive_log')
|
||||
->alias('a')
|
||||
->join('vs_gift_bag_detail b', 'a.parent_id=b.id', 'INNER')
|
||||
->field('a.createtime,b.type,b.foreign_id,b.quantity,b.gold')
|
||||
->where(['b.type'=>['in', [1,2]]])
|
||||
->whereBetween('a.gift_bag_id', [18, 51])
|
||||
->where($where)
|
||||
->select();
|
||||
}else{
|
||||
if(!empty($stime) && strtotime($stime)<="1767114849" && strtotime($etime)>"1767114849"){
|
||||
$old_tasks_bag_details = db::name('vs_gift_bag_receive_log')
|
||||
->alias('a')
|
||||
->join('vs_gift_bag_detail b', 'a.parent_id=b.id', 'INNER')
|
||||
->field('a.createtime,b.type,b.foreign_id,b.quantity,b.gold')
|
||||
->where(['b.type'=>['in', [1,2]]])
|
||||
->whereBetween('a.gift_bag_id', [18, 51])
|
||||
->whereBetween('a.createtime', [strtotime($stime), 1767114849])
|
||||
->where($where)
|
||||
->select();
|
||||
$new_tasks_bag_details = db::name('vs_gift_bag_receive_tasks_log')
|
||||
->alias('a')
|
||||
->join('vs_gift_bag_detail b', 'a.parent_id=b.id', 'INNER')
|
||||
->field('a.createtime,b.type,b.foreign_id,b.quantity,b.gold')
|
||||
->where(['b.type'=>['in', [1,2]]])
|
||||
->whereBetween('a.gift_bag_id', [18, 51])
|
||||
->whereBetween('a.createtime', [1767114849, strtotime($etime)])
|
||||
->where($where)
|
||||
->select();
|
||||
$tasks_bag_details = array_merge($old_tasks_bag_details, $new_tasks_bag_details);
|
||||
}else{
|
||||
if(!empty($stime) && !empty($etime)){
|
||||
$where['a.createtime'] = ['between', [strtotime($stime), strtotime($etime)]];
|
||||
}else{
|
||||
if(!empty($stime)){
|
||||
$where['a.createtime'] = ['>=', strtotime($stime)];
|
||||
}elseif(!empty($etime)){
|
||||
$where['a.createtime'] = ['<=', strtotime($etime)];
|
||||
}
|
||||
}
|
||||
$tasks_bag_details = db::name('vs_gift_bag_receive_tasks_log')
|
||||
->alias('a')
|
||||
->join('vs_gift_bag_detail b', 'a.parent_id=b.id', 'INNER')
|
||||
->field('a.createtime,b.type,b.foreign_id,b.quantity,b.gold')
|
||||
->where(['b.type'=>['in', [1,2]]])
|
||||
->whereBetween('a.gift_bag_id', [18, 51])
|
||||
->where($where)
|
||||
->select();
|
||||
}
|
||||
}
|
||||
$total_reward_price = 0;
|
||||
// 批量获取礼物价格以减少数据库查询
|
||||
$gift_ids = [];
|
||||
foreach ($tasks_bag_details as $detail) {
|
||||
if($detail['type'] == 2) {
|
||||
$gift_ids[] = $detail['foreign_id'];
|
||||
}
|
||||
}
|
||||
|
||||
$gift_prices = [];
|
||||
if (!empty($gift_ids)) {
|
||||
$gifts = db::name('vs_gift')->where('gid', 'in', array_unique($gift_ids))->column('gift_price', 'gid');
|
||||
$gift_prices = $gifts ?: [];
|
||||
}
|
||||
|
||||
foreach ($tasks_bag_details as $detail){
|
||||
if($detail['type'] == 1){
|
||||
$total_reward_price += $detail['gold'] * $detail['quantity'];
|
||||
}else{
|
||||
$gift_price = db::name('vs_gift')->where('gid',$detail['foreign_id'])->value('gift_price');
|
||||
$gift_price = isset($gift_prices[$detail['foreign_id']]) ? $gift_prices[$detail['foreign_id']] : 0;
|
||||
$total_reward_price += $gift_price * $detail['quantity'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ class SystemMessage extends adminApi
|
||||
$data['title'] = $title;
|
||||
}
|
||||
|
||||
$content = input('content', '');
|
||||
$content = input('content', ''); //$_POST['content'] ?? '';
|
||||
if($content){
|
||||
$data['content'] = $content;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use think\Db;
|
||||
use think\Hook;
|
||||
use think\Session;
|
||||
use think\Validate;
|
||||
use app\common\library\Token as TokenLib;
|
||||
|
||||
/**
|
||||
* 后台首页
|
||||
@@ -95,7 +96,7 @@ class User extends adminApi
|
||||
a.login_device,
|
||||
a.loginip,
|
||||
c.coin,
|
||||
c.earnings,
|
||||
d.earnings,
|
||||
b.is_real,
|
||||
a.init_code,
|
||||
a.status
|
||||
@@ -109,18 +110,20 @@ class User extends adminApi
|
||||
if($order_type=='coin'){
|
||||
$order = "c.coin ".$order_type_val_str;
|
||||
}elseif($order_type=='earnings'){
|
||||
$order = "c.earnings ".$order_type_val_str;
|
||||
$order = "d.earnings ".$order_type_val_str;
|
||||
}
|
||||
$user_data = db::name('user')->alias('a')
|
||||
->join('(SELECT * FROM fa_user_auth WHERE id IN (SELECT MAX(id) FROM fa_user_auth GROUP BY mobile)) b', 'a.mobile = b.mobile', 'LEFT')
|
||||
->join('user_wallet c', 'a.id = c.user_id','LEFT')
|
||||
->join('user_wallet_coin c', 'a.id = c.user_id','LEFT')
|
||||
->join('user_wallet_earnings d', 'a.id = d.user_id','LEFT')
|
||||
->where($where)
|
||||
->field($field)
|
||||
->order($order);
|
||||
$lists = $user_data->page($page, $page_limit)->select();
|
||||
$count = db::name('user')->alias('a')
|
||||
->join('(SELECT * FROM fa_user_auth WHERE id IN (SELECT MAX(id) FROM fa_user_auth GROUP BY mobile)) b', 'a.mobile = b.mobile', 'LEFT')
|
||||
->join('user_wallet c', 'a.id = c.user_id','LEFT')
|
||||
->join('user_wallet_coin c', 'a.id = c.user_id','LEFT')
|
||||
->join('user_wallet_earnings d', 'a.id = d.user_id','LEFT')
|
||||
->where($where)
|
||||
->field($field)
|
||||
->count();
|
||||
@@ -170,18 +173,20 @@ class User extends adminApi
|
||||
}
|
||||
$total_coin = db::name('user')->alias('a')
|
||||
->join('(SELECT * FROM fa_user_auth WHERE id IN (SELECT MAX(id) FROM fa_user_auth GROUP BY mobile)) b', 'a.mobile = b.mobile', 'LEFT')
|
||||
->join('user_wallet c', 'a.id = c.user_id','LEFT')
|
||||
->join('user_wallet_coin c', 'a.id = c.user_id','LEFT')
|
||||
->join('user_wallet_earnings d', 'a.id = d.user_id','LEFT')
|
||||
->where(['a.delete_time'=>0])
|
||||
->where($where)
|
||||
->field($field)
|
||||
->sum('c.coin');
|
||||
$total_earnings = db::name('user')->alias('a')
|
||||
->join('(SELECT * FROM fa_user_auth WHERE id IN (SELECT MAX(id) FROM fa_user_auth GROUP BY mobile)) b', 'a.mobile = b.mobile', 'LEFT')
|
||||
->join('user_wallet c', 'a.id = c.user_id','LEFT')
|
||||
->join('user_wallet_coin c', 'a.id = c.user_id','LEFT')
|
||||
->join('user_wallet_earnings d', 'a.id = d.user_id','LEFT')
|
||||
->where(['a.delete_time'=>0])
|
||||
->where($where)
|
||||
->field($field)
|
||||
->sum('c.earnings');
|
||||
->sum('d.earnings');
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
@@ -272,6 +277,9 @@ class User extends adminApi
|
||||
Db::name('block')->where($map)->delete();
|
||||
Db::name('sms_error')->where(['mobile' => $user_info['mobile']])->delete();
|
||||
}
|
||||
$token = db::name('user_token')->where('user_id', $user_id)->value('token');
|
||||
// 删除这个Token,使其失效
|
||||
TokenLib::delete($token);
|
||||
return V(1,"成功", null);
|
||||
}
|
||||
|
||||
@@ -373,7 +381,7 @@ class User extends adminApi
|
||||
$user_data['user_info']['wealth_level_icon'] = $user['wealth_level_icon'];
|
||||
$user_data['user_info']['user_code'] = $user['user_code'];
|
||||
$user_data['user_info']['mobile'] = $user['mobile'];
|
||||
$user_data['user_info']['sex'] = $user['sex']==1 ? '男' : '女';
|
||||
$user_data['user_info']['sex'] = $user['sex'];
|
||||
$user_data['user_info']['birthday'] = $user['birthday'];
|
||||
$user_data['user_info']['system'] = $user['system'];
|
||||
$user_data['user_info']['age'] = $user['age'];
|
||||
@@ -587,7 +595,7 @@ class User extends adminApi
|
||||
a.user_code,
|
||||
a.login_device,
|
||||
c.coin,
|
||||
c.earnings,
|
||||
d.earnings,
|
||||
b.is_real,
|
||||
a.init_code,
|
||||
a.status,
|
||||
@@ -595,12 +603,14 @@ class User extends adminApi
|
||||
';
|
||||
$count = db::name('user')->alias('a')
|
||||
->join('fa_user_auth b', 'a.mobile = b.mobile','LEFT')
|
||||
->join('user_wallet c', 'a.id = c.user_id','LEFT')
|
||||
->join('user_wallet_coin c', 'a.id = c.user_id','LEFT')
|
||||
->join('user_wallet_earnings d', 'a.id = d.user_id','LEFT')
|
||||
->where($where)
|
||||
->count();
|
||||
$user_data = db::name('user')->alias('a')
|
||||
->join('fa_user_auth b', 'a.mobile = b.mobile','LEFT')
|
||||
->join('user_wallet c', 'a.id = c.user_id','LEFT')
|
||||
->join('user_wallet_coin c', 'a.id = c.user_id','LEFT')
|
||||
->join('user_wallet_earnings d', 'a.id = d.user_id','LEFT')
|
||||
->where($where)
|
||||
->field($field)
|
||||
->order('a.id desc');
|
||||
@@ -897,20 +907,29 @@ class User extends adminApi
|
||||
]);
|
||||
}
|
||||
//查他的钱包
|
||||
$wallet = db::name('user_wallet')->where(['user_id'=>$user_id])->find();
|
||||
if($wallet){
|
||||
db::name('user_wallet')->where(['id'=>$wallet['id']])->update([
|
||||
//清空金币表
|
||||
$wallet_coin = db::name('user_wallet_coin')->where(['user_id'=>$user_id])->find();
|
||||
if($wallet_coin){
|
||||
db::name('user_wallet_coin')->where(['id'=>$wallet_coin['id']])->update([
|
||||
'coin' => 0,
|
||||
'updatetime' => time(),
|
||||
]);
|
||||
}
|
||||
//清空钻石表
|
||||
$wallet_earnings = db::name('user_wallet_earnings')->where(['user_id'=>$user_id])->find();
|
||||
if($wallet_earnings){
|
||||
db::name('user_wallet_earnings')->where(['id'=>$wallet_earnings['id']])->update([
|
||||
'earnings' => 0,
|
||||
'updatetime' => time(),
|
||||
]);
|
||||
}
|
||||
|
||||
//他的装扮
|
||||
$dress = db::name('vs_user_decorate')->where(['user_id'=>$user_id])->select();
|
||||
if($dress){
|
||||
foreach ($dress as $key => $value) {
|
||||
if($value['end_time'] > time()){
|
||||
db::name('vs_user_decorate')->where(['id'=>$value['id']])->update([
|
||||
db::name('vs_user_decorate')->where(['udid'=>$value['udid']])->update([
|
||||
'is_perpetual' => 2,
|
||||
'end_time' => time(),
|
||||
'updatetime' => time(),
|
||||
|
||||
@@ -178,8 +178,46 @@ class UserZone extends adminApi
|
||||
public function del_comment(){
|
||||
$id = input('id', 0);
|
||||
$res = db::name('user_zone_comment')->where(['id'=>$id])->update(['is_delete'=> 2,'updatetime'=> time()]);
|
||||
if($res){
|
||||
$zone_id = db::name('user_zone_comment')->where(['id'=>$id])->value('zone_id');
|
||||
//删除评论下的回复
|
||||
$dd = db::name('user_zone_comment')->where('pid', $id)->find();
|
||||
if($dd){
|
||||
$reslut1 = db::name('user_zone_comment')->where('pid', $id)->update(['is_delete' => 2,'updatetime' => time()]);
|
||||
if (!$reslut1) {
|
||||
return ['code' => 0, 'msg' => '请重试!!', 'data' => null];
|
||||
}
|
||||
}
|
||||
//减少评论数量
|
||||
$num = db::name('user_zone_comment')->where('pid', $id)->count();
|
||||
if($num > 0){
|
||||
$num = $num + 1;
|
||||
}else{
|
||||
$num = 1;
|
||||
}
|
||||
$reslut2 = db::name('user_zone')->where('id', $zone_id)->setDec('comment_num', $num);
|
||||
if (!$reslut2) {
|
||||
return ['code' => 0, 'msg' => '请重试!!', 'data' => null];
|
||||
}
|
||||
}
|
||||
return V($res ? 1 : 0, $res ? '删除成功' : '删除失败');
|
||||
}
|
||||
|
||||
public function comment_zone()
|
||||
{
|
||||
$id = input('id', 0);
|
||||
$content = input('content', '');
|
||||
$comment_data = db::name('user_zone_comment')->where(['id'=>$id])->find();
|
||||
$zid = $comment_data['zone_id'];
|
||||
$pid = $id;
|
||||
$reply_to = input('reply_to', 0);
|
||||
if(!$reply_to){
|
||||
$reply_to = $comment_data['user_id'];
|
||||
}
|
||||
$reslut = model('api/UserZone')->comment_zone(21216, $zid, $content,$pid, $reply_to);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//动态置顶或显示操作操作
|
||||
public function zone_top_or_show(){
|
||||
$id = input('id', 0);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace app\adminapi\model;
|
||||
|
||||
use app\common\library\GiftTableManager;
|
||||
use think\Log;
|
||||
use think\Model;
|
||||
use think\Session;
|
||||
use think\Db;
|
||||
@@ -19,14 +21,19 @@ class Gift extends Model
|
||||
public $giftType = [
|
||||
1 => '普通礼物',
|
||||
2 => '盲盒礼物',
|
||||
3 => '礼包礼物'
|
||||
3 => '礼包礼物',
|
||||
6 => '酒吧房礼物'
|
||||
];
|
||||
//送礼流水来源:1聊天送礼物 2房间语聊送礼 3直播送礼 4动态打赏
|
||||
public $GiveGiftFromStr = [
|
||||
1 => '聊天送礼',
|
||||
2 => '房间语聊送礼',
|
||||
3 => '直播送礼',
|
||||
4 => '动态打赏'
|
||||
4 => '动态打赏',
|
||||
5 => '房心愿礼物',
|
||||
6 => '酒吧房自定义礼物',
|
||||
7 => '酒吧房普通礼物',
|
||||
8 => '酒吧房小黑屋礼物'
|
||||
];
|
||||
|
||||
public function getList($where = [], $page = 1, $limit = 10)
|
||||
@@ -73,4 +80,104 @@ class Gift extends Model
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取送礼记录
|
||||
*/
|
||||
|
||||
public function getGiftRecords($search_time,$where,$page_array)
|
||||
{
|
||||
// 获取需要查询的表
|
||||
$tables = GiftTableManager::getTablesByTimeRange(
|
||||
$search_time[0],
|
||||
$search_time[1]
|
||||
);
|
||||
//数组排序fa_vs_give_gift_202601 表明数字大的排在前面
|
||||
arsort($tables);
|
||||
if(empty($tables)){
|
||||
$tables[0] = "fa_vs_give_gift";
|
||||
}
|
||||
$gift_count = 0;
|
||||
$gift_total_price = 0;
|
||||
$gift_number = 0;
|
||||
$all_lists = []; // 存储所有查询结果
|
||||
$remaining_page_offset = ($page_array['page'] - 1) * $page_array['page_limit']; // 需要跳过的记录数
|
||||
$collected_count = 0; // 已收集的记录数
|
||||
if($tables){
|
||||
foreach ($tables as $table) {
|
||||
$table_name = substr($table, 3);//截取可查询的表名
|
||||
|
||||
// 获取当前表的总记录数
|
||||
$count = db::name($table_name)->where($where)->count();
|
||||
|
||||
if($count > 0){
|
||||
// 如果还需要跳过记录
|
||||
if($remaining_page_offset > 0){
|
||||
// 如果当前表的记录数大于需要跳过的记录数
|
||||
if($count > $remaining_page_offset){
|
||||
// 从当前表中获取所需数据,跳过前面的记录
|
||||
$table_lists = db::name($table_name)
|
||||
->where($where)
|
||||
->order('createtime', 'desc')
|
||||
->limit($remaining_page_offset, $page_array['page_limit'])
|
||||
->select();
|
||||
|
||||
// 添加到结果中
|
||||
foreach($table_lists as $item){
|
||||
if($collected_count < $page_array['page_limit']){
|
||||
$all_lists[] = $item;
|
||||
$collected_count++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$remaining_page_offset = 0; // 已经跳过所需的记录
|
||||
} else {
|
||||
// 当前表的所有记录都需要跳过
|
||||
$remaining_page_offset -= $count;
|
||||
}
|
||||
} else if($collected_count < $page_array['page_limit']) {
|
||||
// 如果不需要跳过记录,且还没有收集足够的数据
|
||||
$remaining_needed = $page_array['page_limit'] - $collected_count;
|
||||
|
||||
// 从当前表获取剩余所需的数据
|
||||
$table_lists = db::name($table_name)
|
||||
->where($where)
|
||||
->order('createtime', 'desc')
|
||||
->limit($remaining_needed)
|
||||
->select();
|
||||
|
||||
// 添加到结果中
|
||||
foreach($table_lists as $item){
|
||||
if($collected_count < $page_array['page_limit']){
|
||||
$all_lists[] = $item;
|
||||
$collected_count++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$total_price = db::name($table_name)->where($where)->sum('total_price');
|
||||
$number = db::name($table_name)->where($where)->sum('number');
|
||||
$gift_count += $count;
|
||||
$gift_total_price += $total_price;
|
||||
$gift_number += $number;
|
||||
|
||||
// 如果已经收集到足够数据,跳出循环
|
||||
if($collected_count >= $page_array['page_limit']){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$result = [
|
||||
'lists' => $all_lists,
|
||||
'count' => $gift_count,
|
||||
'total_price' => $gift_total_price,
|
||||
'number' => $gift_number,
|
||||
];
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,9 +72,9 @@ class Room extends Model
|
||||
*/
|
||||
public function getRoomFlow($room_id,$stime='',$etime=''){
|
||||
$give_where = [];
|
||||
$give_where['from_id'] = $room_id;
|
||||
$give_where['room_id'] = $room_id;
|
||||
// $give_where['from'] = ["in",[2,3,6]];
|
||||
$give_where['from'] = 2;
|
||||
// $give_where['from'] = 2;
|
||||
if(!empty($stime)){
|
||||
$give_where['createtime'] = ['>=',strtotime($stime)];
|
||||
}
|
||||
@@ -85,8 +85,8 @@ class Room extends Model
|
||||
// $give_where['createtime'] = ['between',[strtotime($stime),strtotime($etime)]];
|
||||
$give_where['createtime'] = [['>=',strtotime($stime)],['<',strtotime($etime)]];
|
||||
}
|
||||
$total_price = db::name('vs_give_gift')->where($give_where)
|
||||
->sum('total_price');
|
||||
$total_price = db::name('vs_guild_flow')->where($give_where)
|
||||
->sum('flow_price');
|
||||
return $total_price;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,4 +48,16 @@ class Banner extends controller
|
||||
$reslut = model('Banner')->banner_list($show_type);
|
||||
return V(1,'操作成功', $reslut);
|
||||
}
|
||||
|
||||
//平台客服获取接口
|
||||
public function app_customer_service()
|
||||
{
|
||||
$platform_customer_service = get_system_config_value('platform_customer_service');
|
||||
$user_id = model('User')->where('user_code', $platform_customer_service)->value('id');
|
||||
$reslut = [
|
||||
'user_id' => $user_id,
|
||||
'user_name' => "客服",
|
||||
];
|
||||
return V(1, '成功', $reslut);
|
||||
}
|
||||
}
|
||||
|
||||
101
application/api/controller/BarRoom.php
Normal file
101
application/api/controller/BarRoom.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Cache;
|
||||
use think\Db;
|
||||
|
||||
class BarRoom extends BaseCom
|
||||
{
|
||||
|
||||
//麦位时长列表
|
||||
public function get_pit_time_list(){
|
||||
$reslut = model('BarRoom')->get_pit_duration_list();
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//房间麦位时长设置
|
||||
public function set_pit_time(){
|
||||
$room_id = input('room_id', 0);
|
||||
$time = input('time', 0);
|
||||
$user_id = $this->uid;
|
||||
if (!$room_id || !$time) {
|
||||
return V(0, '参数错误');
|
||||
}
|
||||
//判断用户是否是主持
|
||||
$user_is_on_pit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $user_id])->value('pit_number');
|
||||
if($user_is_on_pit != 9){
|
||||
return V(0, '没有权限');
|
||||
}
|
||||
$reslut = model('BarRoom')->set_pit_duration($room_id, $time);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//约Ta礼物详情
|
||||
public function get_gift_info_ta(){
|
||||
$room_id = input('room_id', 0);
|
||||
$to_user_id =input('to_user_id', 0);
|
||||
$reslut = model('BarRoom')->get_gift_info_ta($room_id, $to_user_id, $this->uid);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//撩TA
|
||||
public function liao_ta(){
|
||||
$room_id = input('room_id', 0);
|
||||
$to_user_id =input('to_user_id', 0);
|
||||
$user_id = $this->uid;
|
||||
$type = input('type', 0);
|
||||
if($type == 1){
|
||||
if($user_id == $to_user_id){
|
||||
return V(0, '不能撩自己');
|
||||
}
|
||||
$reslut = model('BarRoom')->liao_ta($room_id,$user_id,$to_user_id);
|
||||
}else{
|
||||
$reslut = model('BarRoom')->one_key_liao_ta($room_id,$user_id);
|
||||
}
|
||||
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//约TA
|
||||
public function meeting_ta(){
|
||||
$key_name = "api:meeting:ta:" . $this->uid;
|
||||
redis_lock_exits($key_name);
|
||||
$room_id = input('room_id', 0);
|
||||
$user_id =input('user_id', 0);
|
||||
$gift_id =input('gift_id', 0);
|
||||
if(!$room_id || !$user_id || !$gift_id){
|
||||
redis_unlocks($key_name);
|
||||
return V(0, '参数错误');
|
||||
}
|
||||
//获取缓存
|
||||
$meet_user_id = Cache::get('meeting_user_id_'.$user_id);
|
||||
if($meet_user_id == $user_id){
|
||||
redis_unlocks($key_name);
|
||||
return V(0, '佳人有约!');
|
||||
}
|
||||
//设置缓存
|
||||
Cache::set('meeting_user_id_'.$user_id, $user_id, 20);
|
||||
|
||||
$reslut = model('BarRoom')->meeting_ta($this->uid,$room_id,$user_id,$gift_id);
|
||||
if($reslut['code'] != 1){
|
||||
//删除缓存
|
||||
Cache::rm('meeting_user_id_'.$user_id);
|
||||
}
|
||||
redis_unlocks($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//小黑屋列表
|
||||
public function black_room_list(){
|
||||
$room_id = input('room_id', 0);
|
||||
$reslut = model('BarRoom')->black_room_list($room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
@@ -43,10 +43,12 @@ class BlindBoxTurntable extends BaseCom
|
||||
if(!in_array($gift_bag_id,[10,11,12])){
|
||||
return v(0,'非法活动ID', null);
|
||||
}
|
||||
//删除字符串里所有的空格
|
||||
$gift_user_ids = preg_replace('/\s+/', '', $gift_user_ids);
|
||||
if($gift_bag_id==10){
|
||||
$reslut = model('BlindBoxTurntableGiftDrawWorldNew')->draw_gift($gift_bag_id, $user_id, $gift_user_ids,$num,$room_id,$heart_id,$auction_id);
|
||||
$reslut = model('api/BlindBoxTurntableGiftDrawWorldNew')->draw_gift($gift_bag_id, $user_id, $gift_user_ids,$num,$room_id,$heart_id,$auction_id);
|
||||
}else{
|
||||
$reslut = model('BlindBoxTurntableGiftDrawWorldNew')->draw_gift_drop_bag($gift_bag_id, $user_id,$num,$room_id);
|
||||
$reslut = model('api/BlindBoxTurntableGiftDrawWorldNew')->draw_gift_drop_bag($gift_bag_id, $user_id,$num,$room_id);
|
||||
}
|
||||
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
@@ -78,13 +80,13 @@ class BlindBoxTurntable extends BaseCom
|
||||
/*
|
||||
* 获取全服抽奖记录
|
||||
*/
|
||||
public function get_all_record(){
|
||||
$gift_bag_id = input('gift_bag_id',0);
|
||||
$page = input('page',1);
|
||||
$page_size = input('page_size',12);
|
||||
$reslut = model('BlindBoxTurntableGift')->get_all_record($gift_bag_id,$page,$page_size);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
// public function get_all_record(){
|
||||
// $gift_bag_id = input('gift_bag_id',0);
|
||||
// $page = input('page',1);
|
||||
// $page_size = input('page_size',12);
|
||||
// $reslut = model('BlindBoxTurntableGift')->get_all_record($gift_bag_id,$page,$page_size);
|
||||
// return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
// }
|
||||
/*
|
||||
* 巡乐会
|
||||
*/
|
||||
|
||||
@@ -147,701 +147,6 @@ class Ceshi extends Controllers
|
||||
return V(1, '成功', $reslut);
|
||||
}
|
||||
|
||||
//清空数据 禁用 慎用 !!!!!!
|
||||
//清空数据 禁用 慎用 !!!!!!
|
||||
//清空数据 禁用 慎用 !!!!!!
|
||||
public function qing_chu_data()
|
||||
{
|
||||
//ip
|
||||
$ip = request()->ip();
|
||||
//白名单
|
||||
$white_list = $this -> allowIp;
|
||||
if (!in_array($ip, $white_list)) {
|
||||
return V(301, '非法访问!');
|
||||
}
|
||||
$i = 0;
|
||||
$res = [];
|
||||
//开启事务
|
||||
Db::startTrans();
|
||||
// $reslut = db::name('admin')->where('username','<>', 'admin')->delete();
|
||||
// if($reslut){
|
||||
// $i ++ ;
|
||||
// }else{
|
||||
// //数组末尾添加元素
|
||||
// array_push($res, '管理员删除失败!');
|
||||
// }
|
||||
$reslut1 = db::name('admin_log')->where('id','<>', 1)->delete();
|
||||
if($reslut1){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '管理员日志删除失败!');
|
||||
}
|
||||
|
||||
$reslut3 = db::name('block')->where('id','>', 0)->delete();
|
||||
if($reslut3){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '封禁表删除失败!');
|
||||
}
|
||||
|
||||
$reslut6 = db::name('sms')->where('id','>', 0)->delete();
|
||||
if($reslut6){
|
||||
$i ++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '短信发送记录删除失败!');
|
||||
}
|
||||
|
||||
$reslut7 = db::name('system_message')->where('id','>', 0)->delete();
|
||||
if($reslut7){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '系统消息删除失败!');
|
||||
}
|
||||
// $reslut8 = db::name('topic')->where('id','>', 0)->delete();
|
||||
// if($reslut8){
|
||||
// $i++ ;
|
||||
// }else{
|
||||
// //数组末尾添加元素
|
||||
// array_push($res, '话题删除失败!');
|
||||
// }
|
||||
|
||||
|
||||
$user = db::name('user')->where('id','>', 0)->select();
|
||||
// if($user){
|
||||
// foreach ($user as &$v){
|
||||
// if($v['id']){
|
||||
// $j = 0;
|
||||
// $data[$j] = [
|
||||
// 'UserID' => 'u'.$v['id'],
|
||||
// ];
|
||||
// }
|
||||
// // model('Tencent')->account_deletes($data);
|
||||
// }
|
||||
// }
|
||||
|
||||
$reslut9 = db::name('user')->where('id','>', 0)->delete();
|
||||
if($reslut9){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户删除失败!');
|
||||
}
|
||||
|
||||
|
||||
$reslut10 = db::name('user_album')->where('id','>', 0)->delete();
|
||||
if($reslut10){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户相册删除失败!');
|
||||
}
|
||||
|
||||
$reslut11 = db::name('user_album_image')->where('id','>', 0)->delete();
|
||||
if($reslut11){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户相册图片删除失败!');
|
||||
}
|
||||
|
||||
$reslut12 = db::name('user_auth')->where('id','>', 0)->delete();
|
||||
if($reslut12){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户实名删除失败!');
|
||||
}
|
||||
|
||||
$reslut13 = db::name('user_avatar_log')->where('id','>', 0)->delete();
|
||||
if($reslut13){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户头像修改记录删除失败!');
|
||||
}
|
||||
|
||||
$reslut14 = db::name('user_black')->where('id','>', 0)->delete();
|
||||
if($reslut14){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户黑名单删除失败!');
|
||||
}
|
||||
|
||||
$reslut141 = db::name('user_coin_transfer')->where('id','>', 0)->delete();
|
||||
if($reslut141){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户金币转让删除失败!');
|
||||
}
|
||||
|
||||
$reslut15 = db::name('user_data')->where('id','>', 0)->delete();
|
||||
if($reslut15){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户数据删除失败!');
|
||||
}
|
||||
$reslut16 = db::name('user_exchange')->where('id','>', 0)->delete();
|
||||
if($reslut16){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户积分兑换记录删除失败!');
|
||||
}
|
||||
$reslut17 = db::name('user_follow')->where('id','>', 0)->delete();
|
||||
if($reslut17){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户关注删除失败!');
|
||||
}
|
||||
$reslut18 = db::name('user_message')->where('id','>', 0)->delete();
|
||||
if($reslut18){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户消息删除失败!');
|
||||
}
|
||||
// $reslut19 = db::name('user_money_log')->where('id','>', 0)->delete();
|
||||
// if($reslut19){
|
||||
// $i++ ;
|
||||
// }else{
|
||||
// //数组末尾添加元素
|
||||
// array_push($res, '用户余额记录删除失败!');
|
||||
// }
|
||||
$reslut20 = db::name('user_token')->where('id','>', 0)->delete();
|
||||
if($reslut20){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户token删除失败!');
|
||||
}
|
||||
$reslut21 = db::name('user_visit_log')->where('id','>', 0)->delete();
|
||||
if($reslut21){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户访问记录删除失败!');
|
||||
}
|
||||
$reslut22 = db::name('user_wallet')->where('id','>', 0)->delete();
|
||||
if($reslut22){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户钱包删除失败!');
|
||||
}
|
||||
$reslut23 = db::name('user_zone')->where('id','>', 0)->delete();
|
||||
if($reslut23){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户空间删除失败!');
|
||||
}
|
||||
$reslut24 = db::name('user_zone_comment')->where('id','>', 0)->delete();
|
||||
if($reslut24){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户空间评论删除失败!');
|
||||
}
|
||||
$reslut25 = db::name('user_zone_like')->where('id','>', 0)->delete();
|
||||
if($reslut25){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户空间点赞删除失败!');
|
||||
}
|
||||
$reslut26 = db::name('user_zone_rewards')->where('id','>', 0)->delete();
|
||||
if($reslut26){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户空间打赏列表删除失败!');
|
||||
}
|
||||
$reslut261 = db::name('user_zone_topic')->where('id','>', 0)->delete();
|
||||
if($reslut261){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '动态话题关联删除失败!');
|
||||
}
|
||||
|
||||
$reslut262 = db::name('vs_activities_receive')->where('id','>', 0)->delete();
|
||||
if($reslut262){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '活动参加删除失败!');
|
||||
}
|
||||
|
||||
$reslut263 = db::name('vs_admin_recharge_log')->where('arid','>', 0)->delete();
|
||||
if($reslut263){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '后台充值删除失败!');
|
||||
}
|
||||
|
||||
$reslut27 = db::name('vs_gift_bag_receive_log')->where('id','>', 0)->delete();
|
||||
if($reslut27){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户礼物发放删除失败!');
|
||||
}
|
||||
$reslut28 = db::name('vs_give_gift')->where('id','>', 0)->delete();
|
||||
if($reslut28){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户送礼记录删除失败!');
|
||||
}
|
||||
|
||||
$reslut29 = db::name('vs_give_gift_ratio_log')->where('id','>', 0)->delete();
|
||||
if($reslut29){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户送礼当前利率记录删除失败!');
|
||||
}
|
||||
|
||||
//解散群
|
||||
$group = db::name('vs_guild')->select();
|
||||
foreach ($group as &$value){
|
||||
model('Tencent')->delete_group('g'.$value['id']);
|
||||
}
|
||||
$reslut30 = db::name('vs_guild')->where('id','>', 0)->delete();
|
||||
if($reslut30){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户工会删除失败!');
|
||||
}
|
||||
|
||||
$reslut31 = db::name('vs_guild_subsidy')->where('id','>', 0)->delete();
|
||||
if($reslut31){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户工会补贴删除失败!');
|
||||
}
|
||||
|
||||
$reslut32 = db::name('vs_guild_user')->where('id','>', 0)->delete();
|
||||
if($reslut32){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户工会用户删除失败!');
|
||||
}
|
||||
|
||||
$reslut33 = db::name('vs_guild_user_quit_log')->where('id','>', 0)->delete();
|
||||
if($reslut33){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户退出工会记录删除失败!');
|
||||
}
|
||||
|
||||
$reslut34 = db::name('vs_headline')->where('id','>', 0)->delete();
|
||||
if($reslut34){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '头条记录删除失败!');
|
||||
}
|
||||
|
||||
//删除腾讯房间
|
||||
$room = db::name('vs_room')->select();
|
||||
// foreach ($room as &$value){
|
||||
// // model('Tencent')->delete_group('room'.$value['id']);
|
||||
// }
|
||||
$reslut35 = db::name('vs_room')->where('id','>', 0)->delete();
|
||||
if($reslut35){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间删除失败!');
|
||||
}
|
||||
|
||||
$reslut36 = db::name('vs_room_auction')->where('auction_id','>', 0)->delete();
|
||||
if($reslut36){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间竞拍删除失败!');
|
||||
}
|
||||
|
||||
$reslut37 = db::name('vs_room_auction_bid_log')->where('id','>', 0)->delete();
|
||||
if($reslut37){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间竞拍记录删除失败!');
|
||||
}
|
||||
|
||||
$reslut371 = db::name('vs_room_auction_relation')->where('id','>', 0)->delete();
|
||||
if($reslut371){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户拍得关系删除失败!');
|
||||
}
|
||||
|
||||
$reslut372 = db::name('vs_room_auction_relation_top')->where('id','>', 0)->delete();
|
||||
if($reslut372){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '关系卡、位 置顶表删除失败!');
|
||||
}
|
||||
|
||||
$reslut373 = db::name('vs_room_background')->where('id','>', 2)->delete();
|
||||
if($reslut373){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间背景图片表删除失败!');
|
||||
}
|
||||
|
||||
$reslut38 = db::name('vs_room_black')->where('id','>', 0)->delete();
|
||||
if($reslut38){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间黑名单删除失败!');
|
||||
}
|
||||
|
||||
$reslut39 = db::name('vs_room_cp_movie')->where('cp_id','>', 0)->delete();
|
||||
if($reslut39){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, 'cp房间删除失败!');
|
||||
}
|
||||
|
||||
$reslut40 = db::name('vs_room_host')->where('id','>', 0)->delete();
|
||||
if($reslut40){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间主持删除失败!');
|
||||
}
|
||||
|
||||
$reslut41 = db::name('vs_room_operation_log')->where('id','>', 0)->delete();
|
||||
if($reslut41){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间日志删除失败!');
|
||||
}
|
||||
|
||||
$reslut42 = db::name('vs_room_pit')->where('id','>', 0)->delete();
|
||||
if($reslut42){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间坑位删除失败!');
|
||||
}
|
||||
|
||||
$reslut43 = db::name('vs_room_pit_apply')->where('id','>', 0)->delete();
|
||||
if($reslut43){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间坑位申请删除失败!');
|
||||
}
|
||||
|
||||
$reslut44 = db::name('vs_room_pit_apply_help')->where('id','>', 0)->delete();
|
||||
if($reslut44){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间坑位申请帮助删除失败!');
|
||||
}
|
||||
|
||||
$reslut45 = db::name('vs_room_pit_apply_help_gift')->where('id','>', 0)->delete();
|
||||
if($reslut45){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间坑位申请帮助礼物删除失败!');
|
||||
}
|
||||
|
||||
$reslut46 = db::name('vs_room_pit_simulate')->where('id','>', 0)->delete();
|
||||
if($reslut46){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间坑位模拟删除失败!');
|
||||
}
|
||||
|
||||
$reslut47 = db::name('vs_room_pk')->where('pk_id','>', 0)->delete();
|
||||
if($reslut47){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间pk删除失败!');
|
||||
}
|
||||
|
||||
$reslut48 = db::name('vs_room_song')->where('did','>', 0)->delete();
|
||||
if($reslut48){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间歌曲删除失败!');
|
||||
}
|
||||
|
||||
$reslut49 = db::name('vs_room_subsidy')->where('id','>', 0)->delete();
|
||||
if($reslut49){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间补贴删除失败!');
|
||||
}
|
||||
|
||||
$reslut50 = db::name('vs_room_user_charm')->where('id','>', 0)->delete();
|
||||
if($reslut50){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间用户魅力删除失败!');
|
||||
}
|
||||
|
||||
$reslut51 = db::name('vs_room_user_muted')->where('id','>', 0)->delete();
|
||||
if($reslut51){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间用户禁言删除失败!');
|
||||
}
|
||||
|
||||
$reslut52 = db::name('vs_room_visitor')->where('id','>', 0)->delete();
|
||||
if($reslut52){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间访客删除失败!');
|
||||
}
|
||||
|
||||
$reslut53 = db::name('vs_suggest')->where('id','>', 0)->delete();
|
||||
if($reslut53){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '建议删除失败!');
|
||||
}
|
||||
|
||||
$reslut54 = db::name('vs_user_daily_tasks')->where('id','>', 0)->delete();
|
||||
if($reslut54){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户日常任务删除失败!');
|
||||
}
|
||||
|
||||
$reslut55 = db::name('vs_user_decorate')->where('udid','>', 0)->delete();
|
||||
if($reslut55){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户装扮表删除失败!');
|
||||
}
|
||||
|
||||
$reslut56 = db::name('vs_user_decorate_log')->where('udid','>', 0)->delete();
|
||||
if($reslut56){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户装扮日志删除失败!');
|
||||
}
|
||||
|
||||
$reslut57 = db::name('vs_user_exp_day')->where('id','>', 0)->delete();
|
||||
if($reslut57){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户每日经验删除失败!');
|
||||
}
|
||||
|
||||
$reslut58 = db::name('vs_user_gift_pack')->where('pid','>', 0)->delete();
|
||||
if($reslut58){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户礼物背包删除失败!');
|
||||
}
|
||||
|
||||
$reslut59 = db::name('vs_user_gift_pack_log')->where('id','>', 0)->delete();
|
||||
if($reslut59){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户礼物背包日志删除失败!');
|
||||
}
|
||||
|
||||
$reslut60 = db::name('vs_user_inform')->where('id','>', 0)->delete();
|
||||
if($reslut60){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户举报删除失败!');
|
||||
}
|
||||
|
||||
$reslut61 = db::name('vs_user_invited')->where('id','>', 0)->delete();
|
||||
if($reslut61){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户邀请删除失败!');
|
||||
}
|
||||
|
||||
$reslut62 = db::name('vs_user_invited_income_log')->where('id','>', 0)->delete();
|
||||
if($reslut62){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户邀请收入日志删除失败!');
|
||||
}
|
||||
|
||||
$reslut63 = db::name('vs_user_live_remind')->where('id','>', 0)->delete();
|
||||
if($reslut63){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户直播提醒删除失败!');
|
||||
}
|
||||
|
||||
$reslut64 = db::name('vs_user_money_log')->where('log_id','>', 0)->delete();
|
||||
if($reslut64){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户钱包日志删除失败!');
|
||||
}
|
||||
|
||||
$reslut641 = db::name('vs_user_pk_close')->where('id','>', 0)->delete();
|
||||
if($reslut641){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户钱包日志删除失败!');
|
||||
}
|
||||
|
||||
$reslut65 = db::name('vs_user_recharge')->where('rid','>', 0)->delete();
|
||||
if($reslut65){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户充值删除失败!');
|
||||
}
|
||||
|
||||
$reslut66 = db::name('vs_user_tasks_sign_in')->where('id','>', 0)->delete();
|
||||
if($reslut66){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户任务签到删除失败!');
|
||||
}
|
||||
|
||||
$reslut661 = db::name('vs_user_withdrawal')->where('wid','>', 0)->delete();
|
||||
if($reslut661){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户提现表删除失败!');
|
||||
}
|
||||
|
||||
$reslut662 = db::name('vs_user_zone_manjiujiang')->where('id','>', 0)->delete();
|
||||
if($reslut662){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户发动态满九张图表删除失败!');
|
||||
}
|
||||
|
||||
$reslut67 = db::name('vs_wealth_level_log')->where('id','>', 0)->delete();
|
||||
if($reslut67){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '财富等级日志删除失败!');
|
||||
}
|
||||
$reslut68 = db::name('vs_user_friending')->where('id','>', 0)->delete();
|
||||
if($reslut68){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户好友删除失败!');
|
||||
}
|
||||
$reslut69 = db::name('vs_user_friending_heart')->where('id','>', 0)->delete();
|
||||
if($reslut69){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户好友心跳删除失败!');
|
||||
}
|
||||
$reslut70 = db::name('vs_room_hot_value_log')->where('id','>', 0)->delete();
|
||||
if($reslut70){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间热度值日志删除失败!');
|
||||
}
|
||||
|
||||
$reslut71 = db::name('vs_blind_box_turntable_results_log')->where('id','>', 0)->delete();
|
||||
if($reslut71){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '盲盒转盘结果日志删除失败!');
|
||||
}
|
||||
$reslut72 = db::name('vs_blind_box_turntable_log')->where('id','>', 0)->delete();
|
||||
if($reslut72){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '盲盒转盘日志删除失败!');
|
||||
}
|
||||
$reslut73 = db::name('vs_room_pan_xlh')->where('id','>', 0)->delete();
|
||||
if($reslut73){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间寻乐会删除失败!');
|
||||
}
|
||||
$reslut74 = db::name('vs_room_pan_xlh_log')->where('id','>', 0)->delete();
|
||||
if($reslut74){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间寻乐会日志删除失败!');
|
||||
}
|
||||
$reslut75 = db::name('vs_room_pan')->where('id','>', 0)->delete();
|
||||
if($reslut75){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间盘删除失败!');
|
||||
}
|
||||
$reslut76 = db::name('vs_gift_bag_receive_pan_log')->where('id','>', 0)->delete();
|
||||
if($reslut76){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '礼物背包领取盘日志删除失败!');
|
||||
}
|
||||
|
||||
//数据提交
|
||||
db::commit();
|
||||
return V(1, '成功'.$i.'条数据!', $res);
|
||||
}
|
||||
|
||||
|
||||
//测试富文本消息
|
||||
public function test_rich_text(){
|
||||
|
||||
@@ -95,6 +95,15 @@ class Cron
|
||||
$cron = new \app\cron\controller\RoomHourRanking();
|
||||
$cron->index();
|
||||
}
|
||||
//每日执行(每天23点59分执行)
|
||||
/*
|
||||
* 每日任务开始
|
||||
*
|
||||
*/
|
||||
public function DayTask(){
|
||||
$cron = new \app\cron\controller\AppTodayStatistical();
|
||||
$cron->index();
|
||||
}
|
||||
|
||||
//临时
|
||||
public function teset(){
|
||||
|
||||
@@ -43,7 +43,7 @@ class Decorate extends BaseCom
|
||||
$data = [];
|
||||
$reslut = model('Decorate')->get_decorate_detail($did);
|
||||
//当前用户金币
|
||||
$user_coin = db::name('user_wallet')->where(['user_id' => $this->uid])->value('coin');
|
||||
$user_coin = db::name('user_wallet_coin')->where(['user_id' => $this->uid])->value('coin');
|
||||
$data['user_info']['user_id'] = $this->uid;
|
||||
$data['user_info']['user_coin'] = intval($user_coin);
|
||||
$data['decorate'] = $reslut['data'];
|
||||
@@ -55,7 +55,7 @@ class Decorate extends BaseCom
|
||||
$did = input('did', 0);
|
||||
$day = input('day', 1);
|
||||
$user_id = input('user_id', 0);
|
||||
$num = input('num', 0);
|
||||
$num = input('num', 1);
|
||||
$keyname = "api:Decorate:pay_decorate:uid:".$uid;
|
||||
redis_lock_exit($keyname);
|
||||
if($user_id){//购买装扮 赠送好友
|
||||
|
||||
48
application/api/controller/GiftNew.php
Normal file
48
application/api/controller/GiftNew.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
|
||||
class GiftNew extends BaseCom
|
||||
{
|
||||
|
||||
/*
|
||||
* 获取礼物列表
|
||||
* @param int $label 礼物标签
|
||||
* @param int $type 类型:1-房间送礼礼物,2-排麦设置插麦礼物,3-拍卖位选择拍卖礼物,4-歌手添加歌单礼物,5-动态打赏礼物
|
||||
* @return array
|
||||
*/
|
||||
public function get_gift_list()
|
||||
{
|
||||
$key_name = "api:gift_new:get_gift_list:" . $this->uid;
|
||||
redis_lock_exits($key_name);
|
||||
$label = input('label', 0);
|
||||
$type = input('type');
|
||||
if (empty($type)) {
|
||||
return V(0, 'type参数错误');
|
||||
}
|
||||
$reslut = model('GiftNew')->get_gift_list($this->uid, $type, $label);
|
||||
redis_unlocks($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
/*
|
||||
* 酒吧房-自定义礼物设置
|
||||
*/
|
||||
public function set_custom_gift(){
|
||||
$gift_id = input('gift_id', 0);
|
||||
$room_id = input('room_id', 0);
|
||||
$gift_remark_name = input('gift_remark_name', '');
|
||||
$reslut = model('GiftNew')->set_custom_gift($this->uid, $gift_id, $room_id, $gift_remark_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
/*
|
||||
* 获取自定义礼物列表
|
||||
*/
|
||||
public function get_custom_gift_list(){
|
||||
$user_id = input('user_id', 0); //收礼人用户Id
|
||||
$reslut = model('GiftNew')->get_custom_gift_list($user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
@@ -192,7 +192,8 @@ class Guild extends BaseCom
|
||||
$guild_id = input('guild_id', 0);
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 20);
|
||||
$reslut = model('Guild')->get_guild_user_list($guild_id,$uid,$page,$page_limit);
|
||||
$seach = input('search', '');
|
||||
$reslut = model('Guild')->get_guild_user_list($guild_id,$uid,$page,$page_limit,$seach);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
|
||||
}
|
||||
|
||||
@@ -33,11 +33,11 @@ class Login extends Controller
|
||||
{
|
||||
$user_name = input('user_login', '');
|
||||
$password = input('password', '');
|
||||
$system = input('system','');
|
||||
$system = input('system');
|
||||
if(empty($system)){
|
||||
$system = request()->header('system');
|
||||
}
|
||||
$login_device = input('deviceId','');
|
||||
$login_device = input('deviceId');
|
||||
if(empty($login_device)){
|
||||
$login_device = request()->header('deviceId');
|
||||
}
|
||||
@@ -56,11 +56,11 @@ class Login extends Controller
|
||||
*/
|
||||
public function phone_code(){
|
||||
|
||||
$system = input('system','');
|
||||
$system = input('system');
|
||||
if(empty($system)){
|
||||
$system = request()->header('system');
|
||||
}
|
||||
$login_device = input('deviceId','');
|
||||
$login_device = input('deviceId');
|
||||
if(empty($login_device)){
|
||||
$login_device = request()->header('deviceId');
|
||||
}
|
||||
@@ -95,11 +95,11 @@ class Login extends Controller
|
||||
public function one_click_login()
|
||||
{
|
||||
$loginToken = input('login_token', '');
|
||||
$system = input('system','');
|
||||
$system = input('system');
|
||||
if(empty($system)){
|
||||
$system = request()->header('system');
|
||||
}
|
||||
$login_device = input('deviceId','');
|
||||
$login_device = input('deviceId');
|
||||
if(empty($login_device)){
|
||||
$login_device = request()->header('deviceId');
|
||||
}
|
||||
@@ -116,10 +116,17 @@ class Login extends Controller
|
||||
}
|
||||
//检测是否注销过
|
||||
$config_time = get_system_config_value('cancel_no_login');
|
||||
$is_del = db::name('user')->where(['mobile' => $mobile,'delete_time' => ['<>', 0]])->find();
|
||||
if ($is_del) {
|
||||
if (time() - $is_del['delete_time'] < $config_time * 24 * 3600) {//30天内注销过
|
||||
return V(0, '注销30天内,不可操作。');
|
||||
$is_del = db::name('user')->where(['mobile' => $mobile,'delete_time' => ['<>', 0]])->order('delete_time', 'desc')->find();
|
||||
|
||||
//获取手机号绑定的账号数
|
||||
$count = db::name('user')->where(['mobile' => $mobile])->count();
|
||||
//获取注销的账号数
|
||||
$count_del = db::name('user')->where(['mobile' => $mobile,'delete_time' => ['<>', 0]])->count();
|
||||
if ($count == $count_del) {
|
||||
if ($is_del) {
|
||||
if (time() - $is_del['delete_time'] < $config_time * 24 * 3600) {//30天内注销过
|
||||
return V(0, '注销30天内,不可操作。');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,8 +142,8 @@ class Login extends Controller
|
||||
public function multi_account_login()
|
||||
{
|
||||
$user_name = input('user_login');
|
||||
$system = input('system','');
|
||||
$login_device = input('deviceId','');
|
||||
$system = input('system');
|
||||
$login_device = input('deviceId');
|
||||
if(empty($login_device)){
|
||||
$login_device = request()->header('deviceId');
|
||||
}
|
||||
@@ -154,11 +161,11 @@ class Login extends Controller
|
||||
public function wechatLogin()
|
||||
{
|
||||
$code = input('code');
|
||||
$system = input('system','');
|
||||
$system = input('system');
|
||||
if(empty($system)){
|
||||
$system = request()->header('system');
|
||||
}
|
||||
$login_device = input('deviceId','');
|
||||
$login_device = input('deviceId');
|
||||
if(empty($login_device)){
|
||||
$login_device = request()->header('deviceId');
|
||||
}
|
||||
@@ -254,11 +261,11 @@ class Login extends Controller
|
||||
public function aliLogin()
|
||||
{
|
||||
$authCode = input('auth_code');
|
||||
$system = input('system','');
|
||||
$system = input('system');
|
||||
if(empty($system)){
|
||||
$system = request()->header('system');
|
||||
}
|
||||
$login_device = input('deviceId','');
|
||||
$login_device = input('deviceId');
|
||||
if(empty($login_device)){
|
||||
$login_device = request()->header('deviceId');
|
||||
}
|
||||
@@ -306,11 +313,11 @@ class Login extends Controller
|
||||
*/
|
||||
public function iosLogin()
|
||||
{
|
||||
$system = input('system','');
|
||||
$system = input('system');
|
||||
if(empty($system)){
|
||||
$system = request()->header('system');
|
||||
}
|
||||
$login_device = input('deviceId','');
|
||||
$login_device = input('deviceId');
|
||||
if(empty($login_device)){
|
||||
$login_device = request()->header('deviceId');
|
||||
}
|
||||
@@ -373,11 +380,11 @@ class Login extends Controller
|
||||
//注销
|
||||
public function cancel()
|
||||
{
|
||||
$system = input('system','');
|
||||
$system = input('system');
|
||||
if(empty($system)){
|
||||
$system = request()->header('system');
|
||||
}
|
||||
$login_device = input('deviceId','');
|
||||
$login_device = input('deviceId');
|
||||
if(empty($login_device)){
|
||||
$login_device = request()->header('deviceId');
|
||||
}
|
||||
|
||||
@@ -40,14 +40,14 @@ class Ranking extends BaseCom
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//公会榜
|
||||
//公会榜【废弃】
|
||||
public function guild_ranking()
|
||||
{
|
||||
$reslut = $this->model->guild_ranking();
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//真爱榜
|
||||
//真爱榜【心动榜】
|
||||
public function love_ranking()
|
||||
{
|
||||
$reslut = $this->model->love_rankings();
|
||||
|
||||
@@ -116,4 +116,12 @@ class Redpacket extends BaseCom
|
||||
}
|
||||
return V(1, '获取成功', $result);
|
||||
}
|
||||
|
||||
//红包配置信息
|
||||
public function appConfig(){
|
||||
|
||||
$result['red_packet_min_amount'] = get_system_config_value('red_packet_min_amount') ?? 0;
|
||||
$result['red_packet_fee'] = get_system_config_value('red_packet_fee') ?? 0;
|
||||
return V(1, '获取成功', $result);
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,7 @@ class Room extends BaseCom
|
||||
$end_time = input('end_time', '');
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 15);
|
||||
$reslut = model('Room')->room_turnover_detail($room_id, $start_time, $end_time, $page, $page_limit);
|
||||
$reslut = model('Room')->room_turnover_detail($this->uid, $room_id, $start_time, $end_time, $page, $page_limit);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
@@ -122,6 +122,9 @@ class Room extends BaseCom
|
||||
public function before_join_room_check()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间不存在');
|
||||
}
|
||||
$reslut = model('Room')->before_join_room_check($this->uid, $room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -139,18 +142,23 @@ class Room extends BaseCom
|
||||
$is_maintenance = get_system_config_value('is_maintenance');
|
||||
//获取内侧账号
|
||||
$inside_uid = get_system_config_value('inside_uid');
|
||||
//先转为数组
|
||||
$inside_uid = explode(',',$inside_uid);
|
||||
if($inside_uid && $is_maintenance == 3){
|
||||
//排除小房间
|
||||
$room_type = db::name('vs_room')->where('id',$room_id)->value('type_id');
|
||||
if($room_type != 6){
|
||||
//先转为数组 不是内侧账号 返回301
|
||||
$inside_uid = explode(',',$inside_uid);
|
||||
//room id = 9 是武松打鼠的房间 暂定为内侧房间
|
||||
if(in_array($this->uid,$inside_uid) && $room_id != 9 && $room_id != 37){
|
||||
return V(0, '不可访问');
|
||||
}
|
||||
}
|
||||
}
|
||||
//内侧账号 才可进入
|
||||
//暂定为内侧房间
|
||||
if(!in_array($this->uid,$inside_uid) && ($room_id == 9 || $room_id == 37 || $room_id == 8)){
|
||||
return V(0, '内侧房间,不可访问');
|
||||
}
|
||||
|
||||
$reslut = model('Room')->join_room($this->uid, $room_id, $password);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
@@ -160,6 +168,9 @@ class Room extends BaseCom
|
||||
public function quit_room()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if(!$room_id){
|
||||
return V(0, '房间不存在');
|
||||
}
|
||||
$user_id = input('user_id', 0);
|
||||
$reslut = model('Room')->quit_room($this->uid, $room_id,$user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
@@ -175,7 +186,8 @@ class Room extends BaseCom
|
||||
}
|
||||
|
||||
|
||||
//直播间送礼
|
||||
//直播间送礼【1.6废弃】
|
||||
//
|
||||
public function room_give_gift()
|
||||
{
|
||||
$key_name = "api:room:gift:" . $this->uid;
|
||||
@@ -225,6 +237,9 @@ class Room extends BaseCom
|
||||
public function room_online_list()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if(!$room_id){
|
||||
return V(0, '房间不存在');
|
||||
}
|
||||
$page = input('page', 1);
|
||||
$limit = input('limit', 15);
|
||||
$reslut = model('Room')->room_online_list($room_id, $page, $limit);
|
||||
@@ -235,6 +250,9 @@ class Room extends BaseCom
|
||||
public function room_user_home()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if(!$room_id){
|
||||
return V(0, '房间不存在');
|
||||
}
|
||||
$user_id = input('user_id', 0);
|
||||
$reslut = model('Room')->room_user_home($this->uid,$room_id, $user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
@@ -309,7 +327,7 @@ class Room extends BaseCom
|
||||
public function change_room_type()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$type = input('type', 1);//1-交友,2-拍卖,7-互娱,8-交友(不要了),9-点唱,10-签约
|
||||
$type = input('type', 1);//1-交友,2-拍卖,7-互娱,8-交友(不要了),9-点唱,10-签约,11-酒吧房
|
||||
$reslut = model('Room')->change_room_type($this->uid, $room_id, $type);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -335,6 +353,9 @@ class Room extends BaseCom
|
||||
public function room_info()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if(!$room_id){
|
||||
return V(0, '房间不存在');
|
||||
}
|
||||
$reslut = model('Room')->room_info($this->uid, $room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -447,22 +468,7 @@ class Room extends BaseCom
|
||||
|
||||
|
||||
//用户重连
|
||||
public function user_reconnect()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$reslut = model('Room')->user_reconnect($this->uid, $room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//用户在房间内切后台保留机制
|
||||
public function user_in_room_background()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$type = input('type', 1);//1-切后台,2-切前台
|
||||
$reslut = model('Room')->user_in_room_background($this->uid, $room_id,$type);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//给用户发送房间内消息
|
||||
public function send_room_message()
|
||||
|
||||
@@ -68,11 +68,12 @@ class RoomAuction extends BaseCom
|
||||
$gift_id = input('gift_id');
|
||||
$num = input('num');
|
||||
$type = input('type',1);//1金币购买 2送背包礼物
|
||||
$gift_bag_id = input('gift_bag_id',0);
|
||||
$pool_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value');
|
||||
if($gift_id == $pool_gift_id){
|
||||
return V(0, '此礼物不能进行此操作');
|
||||
}
|
||||
$reslut = model('RoomAuction')->room_auction_join($auction_id,$user_id,$gift_id,$num,$type);
|
||||
$reslut = model('RoomAuction')->room_auction_join($auction_id,$user_id,$gift_id,$num,$type,$gift_bag_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,33 +7,46 @@ use think\Db;
|
||||
|
||||
class RoomPit extends BaseCom
|
||||
{
|
||||
|
||||
//申请上麦
|
||||
public function apply_pit()
|
||||
{
|
||||
$key_name = "api:room:apply_pit:" . $this->uid;
|
||||
|
||||
$room_id = input('room_id', 0);
|
||||
$pit_number = input('pit_number', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$res = model('Room')->get_room_label($room_id);
|
||||
if($res['code'] != 1){
|
||||
$pit_number = input('pit_number', 0);
|
||||
|
||||
$key_name = "api:room:apply_pit:" . $this->uid;
|
||||
redis_lock_exits($key_name);
|
||||
|
||||
$room_type = model('Room')->get_room_type($room_id);
|
||||
if($room_type == 0){
|
||||
return V(0, '房间不存在', null);
|
||||
}
|
||||
|
||||
$room_label = $res['data']['label_id'];
|
||||
$room_type = $res['data']['type_id'];
|
||||
redis_lock_exits($key_name);
|
||||
if(($room_label == 1 && ($room_type == 1 || $room_type == 3 || $room_type == 4 || $room_type == 8))|| $room_type == 2 || $room_type == 7 || $room_type == 9 || $room_type == 10){
|
||||
$reslut = model('RoomPit')->apply_pit($this->uid, $room_id,$pit_number);
|
||||
}elseif ($room_label == 2 && ($room_type == 1 || $room_type == 3 || $room_type == 4 || $room_type == 8)){
|
||||
$gift_id = input('gift_id', 0);//酒吧房上其他麦需要带礼物
|
||||
if($room_type == 2){
|
||||
$reslut = model('RoomSong')->apply_kpit($this->uid, $room_id,$pit_number);
|
||||
}elseif($room_type == 11){
|
||||
//9麦位,10麦位 不做$gift_id校验
|
||||
if($pit_number != 9 && $pit_number != 10){
|
||||
//有麦位就是换麦
|
||||
$pit_infos = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $this->uid])->value('pit_number')??0;
|
||||
if($pit_infos == 10){
|
||||
return V(0, '此房间不允许嘉宾直接换麦', null);
|
||||
}
|
||||
if($gift_id == 0 && $pit_infos == 0){
|
||||
return V(0, '请选择礼物', null);
|
||||
}
|
||||
}
|
||||
$type = input('type', 0);//2-抱麦后的上麦
|
||||
$reslut = model('RoomPit')->apply_pit($this->uid, $room_id, $pit_number,$gift_id,$type);
|
||||
}else{
|
||||
redis_unlocks($key_name);
|
||||
return V(0, '房间不存在', null);
|
||||
$reslut = model('RoomPit')->apply_pit($this->uid, $room_id, $pit_number);
|
||||
}
|
||||
redis_unlocks($key_name);
|
||||
|
||||
//用户操作记录
|
||||
//1-禁麦位,2-清空消息,3-清空魅力值,4-加入黑名单,5-踢出房间,6-关闭麦克风,7-申请上麦,8-同意上麦,9-拒绝上麦,10-点歌,11-开启PK',
|
||||
model('Room')->room_operation_record($this->uid,$room_id,7,0,$pit_number);
|
||||
|
||||
@@ -44,6 +57,9 @@ class RoomPit extends BaseCom
|
||||
public function apply_pit_list()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$reslut = model('RoomPit')->apply_pit_list($this->uid, $room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -52,7 +68,13 @@ class RoomPit extends BaseCom
|
||||
public function help_apply_pit()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$user_id = input('user_id', 0);
|
||||
if($user_id == 0){
|
||||
return V(0, '请选择助力用户', null);
|
||||
}
|
||||
$reslut = model('RoomPit')->help_apply_pit($this->uid, $room_id, $user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -61,7 +83,13 @@ class RoomPit extends BaseCom
|
||||
public function agree_pit()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$user_id = input('user_id', 0);//逗号分割
|
||||
if($user_id == 0){
|
||||
return V(0, '请选择同意用户', null);
|
||||
}
|
||||
$reslut = model('RoomPit')->agree_pit($this->uid, $room_id, $user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -70,6 +98,9 @@ class RoomPit extends BaseCom
|
||||
public function refuse_pit()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$user_id = input('user_id', 0);//逗号分割
|
||||
$reslut = model('RoomPit')->clear_apply_pit_list($this->uid, $room_id, $user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
@@ -79,6 +110,9 @@ class RoomPit extends BaseCom
|
||||
public function clear_apply_pit_list()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$reslut = model('RoomPit')->clear_apply_pit_list($this->uid, $room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -87,7 +121,13 @@ class RoomPit extends BaseCom
|
||||
public function set_room_pit_apply_help_gift()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$gift_id = input('gift_id', 0);
|
||||
if($gift_id == 0){
|
||||
return V(0, '请选择礼物', null);
|
||||
}
|
||||
$gift_price = input('gift_price', 0);
|
||||
$pool_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value');
|
||||
if($gift_id == $pool_gift_id){
|
||||
@@ -101,26 +141,27 @@ class RoomPit extends BaseCom
|
||||
public function down_pit()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$pit_number = input('pit_number', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$res = model('Room')->get_room_label($room_id);
|
||||
if($res['code'] != 1){
|
||||
$pit_number = input('pit_number', 0);
|
||||
|
||||
$room_type = model('Room')->get_room_type($room_id);
|
||||
if($room_type == 0){
|
||||
return V(0, '房间不存在', null);
|
||||
}
|
||||
$room_label = $res['data']['label_id'];
|
||||
$room_type = $res['data']['type_id'];
|
||||
|
||||
if($room_type == 10){
|
||||
$upit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $this->uid])->value('pit_number');
|
||||
if($upit == 2){
|
||||
return V(0, '师父麦,不能操作', null);
|
||||
}
|
||||
}
|
||||
if(($room_label == 1 && ($room_type == 1 || $room_type == 3 || $room_type == 4 || $room_type == 8)) || $room_type == 2 || $room_type == 7 || $room_type == 9 || $room_type == 10){
|
||||
$reslut = model('RoomPit')->DownPit($this->uid, $room_id,$pit_number);
|
||||
}elseif ($room_label == 2 && ($room_type == 1 || $room_type == 3 || $room_type == 4 || $room_type == 8)){
|
||||
|
||||
if($room_type == 2){
|
||||
$reslut = model('RoomSong')->down_kpit($this->uid, $room_id);
|
||||
}else{
|
||||
$reslut = model('RoomPit')->DownPit($this->uid, $room_id,$pit_number);
|
||||
}
|
||||
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
@@ -132,7 +173,10 @@ class RoomPit extends BaseCom
|
||||
$key_name = "api:room:change_room_up_pit_type:" . $this->uid;
|
||||
redis_lock_exit($key_name);
|
||||
$room_id = input('room_id', 0);
|
||||
// $user_id = input('user_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
|
||||
$reslut = model('RoomPit')->change_room_up_pit_type($this->uid, $room_id);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
@@ -142,8 +186,14 @@ class RoomPit extends BaseCom
|
||||
public function host_user_pit()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$pit_number = input('pit_number', 0);
|
||||
$user_id = input('user_id', 0);//
|
||||
$user_id = input('user_id', 0);
|
||||
if($user_id == 0){
|
||||
return V(0, '请选择用户', null);
|
||||
}
|
||||
$type = input('type', 0);//1-抱麦 2-踢下去
|
||||
$reslut = model('RoomPit')->host_user_pit($this->uid, $room_id,$pit_number,$user_id,$type);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
@@ -154,6 +204,9 @@ class RoomPit extends BaseCom
|
||||
public function refuse_sign_room_host_invite()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$reslut = model('RoomPit')->refuse_sign_room_host_invite($this->uid, $room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ class RoomSong extends BaseCom
|
||||
|
||||
//同意、拒绝点歌
|
||||
public function agree_song(){
|
||||
return V(0, '暂不支持此类型的操作');
|
||||
$room_id = input('room_id');
|
||||
$type = input('type',1);//1同意 2拒绝
|
||||
$res = model('RoomSong')->agree_song($this->uid,$room_id,$type);
|
||||
@@ -48,6 +49,23 @@ class RoomSong extends BaseCom
|
||||
return V($res['code'], $res['msg'], $res['data']);
|
||||
}
|
||||
|
||||
//删除歌曲
|
||||
public function del_song(){
|
||||
$room_song_id = input('did');
|
||||
$room_id = input('room_id');
|
||||
$res = model('RoomSong')->del_song($this->uid,$room_song_id,$room_id);
|
||||
return V($res['code'], $res['msg'], $res['data']);
|
||||
}
|
||||
|
||||
|
||||
//已点列表搜索
|
||||
public function search_song(){
|
||||
$room_id = input('room_id');
|
||||
$search_user = input('search_user');
|
||||
$res = model('RoomSong')->search_song($room_id,$search_user);
|
||||
return V($res['code'], $res['msg'], $res['data']);
|
||||
}
|
||||
|
||||
|
||||
//上移歌 $type 1上移 2置顶
|
||||
public function up_song(){
|
||||
|
||||
66
application/api/controller/SendGift.php
Normal file
66
application/api/controller/SendGift.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Db;
|
||||
|
||||
class SendGift extends BaseCom
|
||||
{
|
||||
|
||||
/*
|
||||
* 送礼
|
||||
* @param int $gift_id
|
||||
*/
|
||||
public function send_gift()
|
||||
{
|
||||
$key_name = "api:send:gift:" . $this->uid;
|
||||
redis_lock_exits($key_name);
|
||||
|
||||
$room_id = input('room_id/d', 0);//房间ID
|
||||
$gift_id = input('gift_id/d', 0);//礼物ID
|
||||
$gift_num = (int)input('gift_num/d', 1);//礼物数量
|
||||
$to_uid = input('to_uid', 0);//收礼人ID,逗号隔开的字符串
|
||||
$type = input('type/d', 1);//1金币购买 2送背包礼物
|
||||
$heart_id = input('heart_id/d', 0);//助力时的 ID
|
||||
$gift_bag_id = input('gift_bag_id/d', 0);//盲盒类型ID 7-初级,8-中级,9-高级
|
||||
|
||||
if($room_id <= 0 || $gift_id <= 0 || $to_uid <= 0 || $type <= 0){
|
||||
redis_unlocks($key_name);
|
||||
return V(0, '参数错误');
|
||||
}
|
||||
|
||||
//获取幸运币
|
||||
$pool_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value');
|
||||
if($gift_id == $pool_gift_id){//送的是幸运币
|
||||
$reslut = model('Lottery')->gift($this->uid, $to_uid, $gift_id, $room_id,$gift_num);
|
||||
redis_unlocks($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}else{
|
||||
//获取房间类型 1:交友/pk(二卡八),2:练歌房(声网点歌),3:亲密拍,4:真爱拍,6:私密房,7:互娱房,9:点唱/歌手房,10:签约房,11:酒吧房
|
||||
$room_type = model('Room')->get_room_type($room_id);
|
||||
|
||||
//送礼 (送礼用户,收礼用户组,礼物ID,数量,礼物类型,房间ID )
|
||||
$reslut = model('SendGift')->send_gift($this->uid, $to_uid, $gift_id, $gift_num, $type, $room_id, $gift_bag_id, $heart_id);
|
||||
|
||||
if($room_type == 2){//2:练歌房(声网点歌)
|
||||
if($reslut['code'] == 1){
|
||||
$room_pits = model('RoomSong')->get_charm_rank($room_id);
|
||||
if($room_pits['code'] == 1){
|
||||
$room_pit = $room_pits['data'];
|
||||
//推送给前端
|
||||
$text = [
|
||||
'userCharmList' => $room_pit,
|
||||
];
|
||||
model('Chat')->sendMsg(1019,$room_id,$text);//K歌房送礼后魅力变化 排序变化
|
||||
}
|
||||
}
|
||||
redis_unlocks($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
redis_unlocks($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,6 +86,7 @@ class Sign extends BaseCom
|
||||
return V(0, '参数错误');
|
||||
}
|
||||
$sign = db::name('vs_room_sign')->where('id', $sign_id)->field('room_id,sign_user_id')->find();
|
||||
|
||||
$user_id = $sign['sign_user_id'];
|
||||
$room_id = $sign['room_id'];
|
||||
|
||||
|
||||
@@ -34,9 +34,16 @@ class Sms extends Api
|
||||
//检测是否注销过
|
||||
$config_time = get_system_config_value('cancel_no_login');
|
||||
$is_del = db::name('user')->where(['mobile' => $mobile,'delete_time' => ['<>', 0]])->find();
|
||||
if ($is_del) {
|
||||
if (time() - $is_del['delete_time'] < $config_time * 24 * 3600) {//30天内注销过
|
||||
return V(0, '注销30天内,不可操作。');
|
||||
|
||||
//获取手机号绑定的账号数
|
||||
$count = db::name('user')->where(['mobile' => $mobile])->count();
|
||||
//获取注销的账号数
|
||||
$count_del = db::name('user')->where(['mobile' => $mobile,'delete_time' => ['<>', 0]])->count();
|
||||
if ($count == $count_del) {
|
||||
if ($is_del) {
|
||||
if (time() - $is_del['delete_time'] < $config_time * 24 * 3600) {//30天内注销过
|
||||
return V(0, '注销30天内,不可操作。');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,22 @@ class Theme extends controller
|
||||
$reslut['theme_name'] = $theme['theme_name'];
|
||||
$reslut['is_open'] = 1;
|
||||
}
|
||||
return V(1,'操作成功', $reslut);
|
||||
|
||||
//版本号
|
||||
$app_version = request()->header('App-Version');
|
||||
$system = request()->header('system');
|
||||
$api_version = 0;
|
||||
if ($system == 'iOS') {
|
||||
$api_versions = db::name('version')->where(['type' => 2, 'status' => 1])->order('id', 'desc')->find();
|
||||
//app的版本和用户使用的当前版本比对
|
||||
//$api_versions['newversion'] 是数据库当前的版本 也是用户使用的版本
|
||||
//$app_version 有可能是appstore里面的审核版本 审核版本比用户的版本高
|
||||
//审核版本给前端返回1
|
||||
$result = version_compare($api_versions['newversion'],$app_version);
|
||||
if ($result < 0) {//-1:前面版本小于后面版本,0:相等,1:前面版本大于后面版本
|
||||
$api_version = 1;
|
||||
}
|
||||
}
|
||||
return V(1,'操作成功', $reslut,$api_version);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,12 +13,8 @@ class UserCp extends BaseCom
|
||||
$user_id = input('user_id', 0);
|
||||
$gift_id = input('gift_id', 0);
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id){
|
||||
$from_type = 2;
|
||||
}else{
|
||||
$from_type = 1;
|
||||
}
|
||||
$reslut = model('GiveGift')->give_gift($this->uid, $user_id, $gift_id, 1,$from_type,1,$room_id);
|
||||
|
||||
$reslut = model('SendGift')->send_gift($this->uid, $user_id, $gift_id, 1,1,$room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
@@ -193,7 +193,8 @@ class UserData extends BaseCom
|
||||
redis_lock_exit($key_name);
|
||||
$real_name = input('real_name');
|
||||
$card_number = input('card_number');
|
||||
|
||||
//去掉前后空格
|
||||
$card_number = trim($card_number);
|
||||
$reslut = model('UserData')->real_name($this->uid,$real_name, $card_number);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
|
||||
@@ -14,43 +14,19 @@ class UserWallet extends BaseCom
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
// //给前端的类型组装一个
|
||||
// public function gift_type()
|
||||
// {
|
||||
// // 1.系统调节 2.充值 3.提现 4.金币转增(送出) 5.每日任务奖励 6.充值返利 7.购买装扮
|
||||
// // 8.礼盒奖励 9.房间补贴 10.购买礼物 11.收礼增加收益 12.工会补贴 13.转赠金币(接收) 14.收益兑换
|
||||
// $data = [
|
||||
//// ['id' => 1, 'name' => '系统调节'],
|
||||
// ['id' => 2, 'name' => '充值'],
|
||||
// ['id' => 3, 'name' => '提现'],
|
||||
// ['id' => 4, 'name' => '金币转增'],
|
||||
// ['id' => 5, 'name' => '每日任务奖励'],
|
||||
// ['id' => 6, 'name' => '充值返利'],
|
||||
// ['id' => 7, 'name' => '购买装扮'],
|
||||
// ['id' => 8, 'name' => '礼盒奖励'],
|
||||
// ['id' => 9, 'name' => '房间补贴'],
|
||||
// ['id' => 10, 'name' => '购买礼物'],
|
||||
// ['id' => 11, 'name' => '收礼增加收益'],
|
||||
// ['id' => 12, 'name' => '工会补贴'],
|
||||
// ['id' => 13, 'name' => '金币转增'],
|
||||
// ['id' => 14, 'name' => '收益兑换'],
|
||||
// ['id' => 15, 'name' => '送礼'],
|
||||
// ];
|
||||
// return V(1, '获取成功', $data);
|
||||
// }
|
||||
|
||||
//金币(钻石)明细
|
||||
public function log_list()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
// 1. 接收参数(前端传递:last_id=上一页最后一条的id,page_limit=每页条数)
|
||||
$last_id = input('last_id', 0); // 第一页 last_id=0
|
||||
$page_limit = input('page_limit', 30);
|
||||
$in_out_type = input('in_out_type', 1);//1收入2支出
|
||||
$gift_type = input('gift_type', 1);//1金币,2收益(钻石)
|
||||
//开始时间
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
$start_time = input('start_time', '');//开始时间
|
||||
$end_time = input('end_time', '');//结束时间
|
||||
|
||||
$reslut = model('UserWallet')->log_list($this->uid, $page, $page_limit,$in_out_type,$start_time,$end_time,$gift_type);
|
||||
$reslut = model('UserWallet')->log_list($this->uid, $last_id, $page_limit,$in_out_type,$start_time,$end_time,$gift_type);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ class UserZone extends BaseCom
|
||||
$api_version = 0;
|
||||
if ($system == 'iOS') {
|
||||
$api_versions = db::name('version')->where(['type' => 2, 'status' => 1])->order('id', 'desc')->find();
|
||||
$result = version_compare($api_versions['apiversion'],$app_version);
|
||||
$result = version_compare($api_versions['newversion'],$app_version);
|
||||
if ($result < 0) {
|
||||
$api_version = 1;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ use think\Log;
|
||||
|
||||
use app\common\controller\Push;
|
||||
|
||||
class Xxiaoshi extends Controller
|
||||
class Xxiaoshi extends Controllers
|
||||
{
|
||||
|
||||
public function test()
|
||||
@@ -49,4 +49,363 @@ class Xxiaoshi extends Controller
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function queryUserRecharge()
|
||||
{
|
||||
// 1. 构建键值对数组(左侧为键,右侧为对应的值列表)
|
||||
// $userTimeData = [
|
||||
// [21238, 1768437495],
|
||||
// [21238, 1768438042],
|
||||
// [21238, 1768537071],
|
||||
// [21238, 1768537086],
|
||||
// [21238, 1768537102],
|
||||
// [21238, 1768537116],
|
||||
// [21238, 1768537130],
|
||||
// [21263, 1768538654],
|
||||
// [21283, 1768538494],
|
||||
// [21283, 1768538505],
|
||||
// [21346, 1768620290],
|
||||
// [21355, 1768562702],
|
||||
// [21521, 1768480294],
|
||||
// [21521, 1768535126],
|
||||
// [21521, 1768559545],
|
||||
// [21521, 1768559583],
|
||||
// [21521, 1768561603],
|
||||
// [21521, 1768561942],
|
||||
// [21549, 1768472710],
|
||||
// [21549, 1768473170],
|
||||
// [22109, 1768576512],
|
||||
// [22215, 1768448033],
|
||||
// [22230, 1768453987],
|
||||
// [22230, 1768494691],
|
||||
// [22230, 1768606319],
|
||||
// [22247, 1768568982],
|
||||
// [22349, 1768463236],
|
||||
// [22349, 1768463510],
|
||||
// [22349, 1768498328],
|
||||
// [22349, 1768534547],
|
||||
// [22349, 1768575347],
|
||||
// [22349, 1768575906],
|
||||
// [22349, 1768576001],
|
||||
// [22349, 1768576134],
|
||||
// [22349, 1768576484],
|
||||
// [22353, 1768493303],
|
||||
// [22353, 1768493644],
|
||||
// [22367, 1768450215],
|
||||
// [22367, 1768450295],
|
||||
// [22367, 1768450411],
|
||||
// [22367, 1768556122],
|
||||
// [22367, 1768557842],
|
||||
// [22367, 1768560574],
|
||||
// [22397, 1768489651],
|
||||
// [22397, 1768489678],
|
||||
// [22403, 1768615100],
|
||||
// [22403, 1768615185],
|
||||
// [22474, 1768610625],
|
||||
// [22489, 1768539082],
|
||||
// [22513, 1768469607],
|
||||
// [22513, 1768622078], // 新增的时间戳
|
||||
// [22546, 1768467110],
|
||||
// [22546, 1768480214],
|
||||
// [22546, 1768480289],
|
||||
// [22546, 1768617480],
|
||||
// [22546, 1768619884],
|
||||
// [22765, 1768555869],
|
||||
// [22765, 1768613623],
|
||||
// [22960, 1768478779],
|
||||
// [22960, 1768562093],
|
||||
// [22960, 1768562790],
|
||||
// [23160, 1768495390],
|
||||
// [23273, 1768546462],
|
||||
// [23317, 1768445313],
|
||||
// [23317, 1768499667],
|
||||
// [23317, 1768500101],
|
||||
// [23317, 1768500124],
|
||||
// [23317, 1768500550],
|
||||
// [23317, 1768502888],
|
||||
// [23317, 1768580934],
|
||||
// [23317, 1768580952],
|
||||
// [23317, 1768582152],
|
||||
// [23381, 1768484820],
|
||||
// [23381, 1768558830],
|
||||
// [23381, 1768562317],
|
||||
// [23418, 1768546419],
|
||||
// [23418, 1768556020],
|
||||
// [23428, 1768615120],
|
||||
// [23620, 1768438590],
|
||||
// [23620, 1768446478],
|
||||
// [23620, 1768446636],
|
||||
// [23620, 1768446926],
|
||||
// [23620, 1768446971],
|
||||
// [23620, 1768446983],
|
||||
// [23620, 1768446994],
|
||||
// [23768, 1768500957],
|
||||
// [23934, 1768487148],
|
||||
// [23979, 1768483941],
|
||||
// [23979, 1768484887],
|
||||
// [23979, 1768485349],
|
||||
// [23979, 1768488207],
|
||||
// [23979, 1768606496],
|
||||
// [23996, 1768537785],
|
||||
// [23996, 1768583372],
|
||||
// [24049, 1768480652],
|
||||
// [24049, 1768574886],
|
||||
// [24049, 1768575149],
|
||||
// [24049, 1768575263],
|
||||
// [24049, 1768575306],
|
||||
// [24049, 1768576026],
|
||||
// [24049, 1768576057],
|
||||
// [24049, 1768576122],
|
||||
// [24049, 1768576324],
|
||||
// [24049, 1768576359],
|
||||
// [24049, 1768576411],
|
||||
// [24049, 1768576450],
|
||||
// [24049, 1768576547],
|
||||
// [24049, 1768576572],
|
||||
// [24049, 1768576752],
|
||||
// [24049, 1768576788],
|
||||
// [24049, 1768610848],
|
||||
// [24049, 1768610956],
|
||||
// [24123, 1768476419],
|
||||
// [24123, 1768563117],
|
||||
// [24208, 1768480841],
|
||||
// [24221, 1768621532], // 新增的user_id和时间戳
|
||||
// [24224, 1768434963],
|
||||
// [24239, 1768575140],
|
||||
// [24262, 1768474400],
|
||||
// [24268, 1768562981],
|
||||
// [24268, 1768563148],
|
||||
// [24376, 1768495419],
|
||||
// [24402, 1768573575],
|
||||
// [24402, 1768573664],
|
||||
// [24497, 1768611030],
|
||||
// [24497, 1768611043],
|
||||
// [24559, 1768573337],
|
||||
// [24619, 1768444049],
|
||||
// [24724, 1768436254],
|
||||
// [24724, 1768436335],
|
||||
// [24724, 1768436370],
|
||||
// [24724, 1768436566],
|
||||
// [24724, 1768463485],
|
||||
// [24724, 1768463533],
|
||||
// [24724, 1768485920],
|
||||
// [24724, 1768486241],
|
||||
// [24724, 1768559795],
|
||||
// [24724, 1768575533],
|
||||
// [24724, 1768575836],
|
||||
// [24724, 1768575846],
|
||||
// [24724, 1768576947],
|
||||
// [24724, 1768577192],
|
||||
// [24724, 1768584426],
|
||||
// [24724, 1768591790],
|
||||
// [24724, 1768592625],
|
||||
// [24809, 1768574941],
|
||||
// [24914, 1768469768],
|
||||
// [24914, 1768478779],
|
||||
// [24914, 1768529233],
|
||||
// [24914, 1768547882],
|
||||
// [24949, 1768446759],
|
||||
// [24949, 1768468114],
|
||||
// [24949, 1768471318],
|
||||
// [24949, 1768489660],
|
||||
// [24949, 1768489679],
|
||||
// [24949, 1768489694],
|
||||
// [24949, 1768489908],
|
||||
// [24949, 1768489995],
|
||||
// [24949, 1768491042],
|
||||
// [24949, 1768491189],
|
||||
// [24949, 1768495030],
|
||||
// [24949, 1768495287],
|
||||
// [24949, 1768528803],
|
||||
// [24949, 1768621300], // 新增的时间戳
|
||||
// [25102, 1768486444],
|
||||
// [25102, 1768492650],
|
||||
// [25264, 1768469925],
|
||||
// [25297, 1768482093],
|
||||
// [25297, 1768523171],
|
||||
// [25297, 1768524115],
|
||||
// [25356, 1768453712],
|
||||
// [25356, 1768564162],
|
||||
// [25436, 1768567177],
|
||||
// [25504, 1768445533],
|
||||
// [25504, 1768474538],
|
||||
// [25504, 1768474550],
|
||||
// [25504, 1768549836],
|
||||
// [25504, 1768550533],
|
||||
// [25504, 1768551277],
|
||||
// [25504, 1768611155],
|
||||
// [25614, 1768463575],
|
||||
// [25614, 1768493369],
|
||||
// [25668, 1768550315],
|
||||
// [25668, 1768550900],
|
||||
// [25668, 1768551157],
|
||||
// [25689, 1768534840],
|
||||
// [25689, 1768534859],
|
||||
// [25689, 1768535523],
|
||||
// [25689, 1768606149],
|
||||
// [25689, 1768606164],
|
||||
// [25782, 1768440770],
|
||||
// [25868, 1768441940],
|
||||
// [25884, 1768446752],
|
||||
// [25884, 1768453213],
|
||||
// [25884, 1768478849],
|
||||
// [25909, 1768451888],
|
||||
// [25909, 1768452147],
|
||||
// [25909, 1768452512],
|
||||
// [25909, 1768452685],
|
||||
// [25909, 1768453007],
|
||||
// [25977, 1768465353],
|
||||
// [25977, 1768466422],
|
||||
// [25977, 1768466948],
|
||||
// [25977, 1768495780],
|
||||
// [26002, 1768474369],
|
||||
// [26010, 1768563140],
|
||||
// [26260, 1768595503],
|
||||
// [26333, 1768480346],
|
||||
// [26471, 1768463341],
|
||||
// [26471, 1768535162],
|
||||
// [26685, 1768544823],
|
||||
// [26846, 1768467107],
|
||||
// [26865, 1768526248],
|
||||
// [26910, 1768495212],
|
||||
// [26910, 1768495674],
|
||||
// [26932, 1768451859],
|
||||
// [26932, 1768452304],
|
||||
// [26932, 1768467016],
|
||||
// [26932, 1768467086],
|
||||
// [26961, 1768551610],
|
||||
// [26961, 1768551630],
|
||||
// [26961, 1768551741],
|
||||
// [26961, 1768617367],
|
||||
// [27063, 1768595933],
|
||||
// [27152, 1768544596],
|
||||
// [27172, 1768453726],
|
||||
// [27306, 1768467885],
|
||||
// [27306, 1768480720],
|
||||
// [27619, 1768480089],
|
||||
// [27619, 1768547882],
|
||||
// [27619, 1768547902],
|
||||
// [27619, 1768564945],
|
||||
// [27848, 1768445845],
|
||||
// [27848, 1768446640],
|
||||
// [27980, 1768485183],
|
||||
// [28015, 1768463456],
|
||||
// [28015, 1768464122],
|
||||
// [28226, 1768539447],
|
||||
// [28226, 1768539558],
|
||||
// [28226, 1768539674],
|
||||
// [28226, 1768539800],
|
||||
// [28226, 1768539899],
|
||||
// [28226, 1768539972],
|
||||
// [28226, 1768540093],
|
||||
// [28226, 1768540167],
|
||||
// [28226, 1768540273],
|
||||
// [28304, 1768454349],
|
||||
// [28357, 1768441100],
|
||||
// [28443, 1768471092],
|
||||
// [28443, 1768538447],
|
||||
// [28443, 1768540270],
|
||||
// [28443, 1768547826],
|
||||
// [28443, 1768556907],
|
||||
// [28443, 1768557771],
|
||||
// [28443, 1768564068],
|
||||
// [28443, 1768564085],
|
||||
// [28551, 1768481077],
|
||||
// [28551, 1768481222],
|
||||
// [28551, 1768548678],
|
||||
// [28551, 1768580500],
|
||||
// [28551, 1768580517],
|
||||
// [28561, 1768449441],
|
||||
// [28769, 1768553650],
|
||||
// [28769, 1768553902],
|
||||
// [28855, 1768568390],
|
||||
// [28924, 1768472667],
|
||||
// [28924, 1768490582],
|
||||
// [28924, 1768490656],
|
||||
// [28924, 1768490721],
|
||||
// [28924, 1768490844],
|
||||
// [28924, 1768490949],
|
||||
// [28924, 1768491079],
|
||||
// [28924, 1768491176],
|
||||
// [28924, 1768491285],
|
||||
// [28924, 1768569855],
|
||||
// [28924, 1768570809],
|
||||
// [28993, 1768444688],
|
||||
// [29420, 1768491595],
|
||||
// [30113, 1768544251],
|
||||
// [30190, 1768457671],
|
||||
// [30190, 1768457788],
|
||||
// [30190, 1768457926],
|
||||
// [30190, 1768458180],
|
||||
// [30190, 1768458568],
|
||||
// [30190, 1768458786],
|
||||
// [30190, 1768458886],
|
||||
// [30190, 1768459131],
|
||||
// [30190, 1768459373],
|
||||
// [30442, 1768529725],
|
||||
// [30551, 1768580619]
|
||||
// ];
|
||||
|
||||
if(isset($userTimeData)){
|
||||
$userTimeData = [];
|
||||
}
|
||||
$dtae = [];
|
||||
// 2. 循环数组,遍历每个键对应的所有值
|
||||
foreach ($userTimeData as $item) {
|
||||
$userId = $item[0]; // 获取用户ID
|
||||
$timestamp = $item[1]; // 获取时间戳
|
||||
// 批量查询(推荐,减少数据库连接次数)
|
||||
$rechargeData = Db::name('vs_user_recharge')
|
||||
->field('updatetime, pay_status, user_id, money')
|
||||
->where(['updatetime' => $timestamp,'pay_status' => 2 ])
|
||||
->select(); // 转为普通数组方便处理
|
||||
|
||||
if($rechargeData){
|
||||
foreach ($rechargeData as $recharge){
|
||||
$dtae[] = [
|
||||
'p_user' => $userId,
|
||||
'user_id' => $recharge['user_id'],
|
||||
'createtime' => $recharge['updatetime'],
|
||||
'money' => $recharge['money'],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// var_dump($dtae);
|
||||
echo "\n";
|
||||
echo "=========";
|
||||
var_dump(count($dtae));
|
||||
echo "\n";
|
||||
$invite = [];
|
||||
$invited_draw_conf = get_system_config_value('invited_draw');//分成比例
|
||||
if($dtae){
|
||||
foreach ($dtae as $item){
|
||||
$invit = db::name('vs_user_invited')->where(['user_id' => $item['p_user'],'sub_user_id' => $item['user_id']])->find();
|
||||
if($invit){
|
||||
$invited_draw = $invited_draw_conf / 100;
|
||||
$invited_draw_money = $item['money'] * $invited_draw;
|
||||
//增加余额并记录日志
|
||||
// $wallet_update = model('api/UserWallet')->change_user_earnings_log($item['p_user'],$invited_draw_money,0,6,'邀请用户充值返利'.$item['createtime']);
|
||||
// if(!$wallet_update){
|
||||
// Log::record("邀请用户充值返利(补发)失败:".$item['p_user'],"info");
|
||||
// echo "邀请用户充值返利失败".$item['p_user'];
|
||||
// }
|
||||
sleep(1);
|
||||
$invite[] = [
|
||||
'p_user' => $item['p_user'],
|
||||
'user_id' => $item['user_id'],
|
||||
'createtime' => $item['createtime'],
|
||||
'money' => $item['money'],
|
||||
'invited_draw_money' => $invited_draw_money,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "=========";
|
||||
echo "\n";
|
||||
// var_dump($invite);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,9 +12,10 @@ class Banner extends Model
|
||||
1 => '引导页',
|
||||
2 => '启动页',
|
||||
3 => '首页轮播图',
|
||||
4 => '房间首页',
|
||||
4 => '房间首页轮播图',
|
||||
5 => '工会列表页广告位',
|
||||
6 => '我的页面'
|
||||
6 => '我的主页广告位',
|
||||
7 => '道具商城广告位'
|
||||
];
|
||||
//1纯展示 2文章 3房间 4个人主页 5外站'
|
||||
public $Type = [
|
||||
|
||||
240
application/api/model/BarRoom.php
Normal file
240
application/api/model/BarRoom.php
Normal file
@@ -0,0 +1,240 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Cache;
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
|
||||
/*
|
||||
* 酒吧房
|
||||
*/
|
||||
class BarRoom extends Model
|
||||
{
|
||||
// 开启自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = true;
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = 'updatetime';
|
||||
// 麦位时长配置
|
||||
protected $pitDuration = [
|
||||
'1' => 5,
|
||||
'2' => 10,
|
||||
'3' => 15,
|
||||
'4' => 20,
|
||||
'5' => 25,
|
||||
'6' => 30,
|
||||
];
|
||||
|
||||
//麦位时长列表
|
||||
public function get_pit_duration_list(){
|
||||
foreach ($this->pitDuration as $key => $value) {
|
||||
$list[] = [
|
||||
'time' => $value,
|
||||
'time_str' => $value.'分钟',
|
||||
];
|
||||
}
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $list];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//设置房间麦位时长
|
||||
public function set_pit_duration($room_id,$time){
|
||||
$room = db::name('vs_room')->where(['id' => $room_id, 'delete_time' => 0, 'room_status' => 1])->find();
|
||||
if(!$room){
|
||||
return ['code' => 0, 'msg' => '房间不存在', 'data' => null];
|
||||
}
|
||||
$room_data = db::name('vs_room_bar')->where('id',$room['id'])->find();
|
||||
if($room_data){
|
||||
if($room_data['pit_time'] != $time){
|
||||
db::name('vs_room_bar')->where('id',$room_id)->update(['pit_time' => $time]);
|
||||
}
|
||||
}else{
|
||||
db::name('vs_room_bar')->insert([
|
||||
'id' => $room_id,
|
||||
'pit_time' => $time,
|
||||
]);
|
||||
}
|
||||
//推送麦位时长
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//上麦选择礼物
|
||||
public function join_pit_choose_gift($user_id,$room_id,$gift_id){
|
||||
$pit_gift = db::name('vs_room_bar_pit_gift')->where(['room_id' => $room_id,'user_id' => $user_id])->find();
|
||||
$pit_time = db::name('vs_room_bar')->where('id',$room_id)->value('pit_time')??5;
|
||||
$end_time = time() + ($pit_time * 60);
|
||||
if($pit_gift){
|
||||
// 使用WHERE条件和影响行数验证确保并发安全
|
||||
$result = db::name('vs_room_bar_pit_gift')
|
||||
->where(['id' => $pit_gift['id']])
|
||||
->update([
|
||||
'gift_id' => $gift_id,
|
||||
'end_time' => $end_time,
|
||||
'updatetime' => time(),
|
||||
'delete_time' => 0,
|
||||
]);
|
||||
} else{
|
||||
// 执行插入操作
|
||||
$result = db::name('vs_room_bar_pit_gift')->insert([
|
||||
'room_id' => $room_id,
|
||||
'user_id' => $user_id,
|
||||
'gift_id' => $gift_id,
|
||||
'end_time' => $end_time,
|
||||
'createtime' => time(),
|
||||
]);
|
||||
}
|
||||
if(!$result){
|
||||
return ['code' => 0, 'msg' => '失败', 'data' => null];
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//约Ta礼物详情
|
||||
public function get_gift_info_ta($room_id,$to_user_id,$user_id){
|
||||
$return_data = [];
|
||||
$pit_gift = db::name('vs_room_bar_pit_gift')->where(['room_id' => $room_id,'user_id' => $to_user_id, 'delete_time' => 0])->find();
|
||||
if($pit_gift){
|
||||
$gift = db::name('vs_gift')->where(['gid' => $pit_gift['gift_id'], 'delete_time' => 0])->find();
|
||||
if(empty($gift)){
|
||||
return ['code' => 0, 'msg' => '礼物不存在', 'data' => null];
|
||||
}
|
||||
//当前用户钱包余额(金币)
|
||||
$wallet_coin = db::name('user_wallet_coin')->where(['user_id' => $user_id])->value('coin') ?? 0;
|
||||
$return_data = [
|
||||
'gift_id' => $pit_gift['gift_id'],
|
||||
'gift_name' => $gift['gift_name'],
|
||||
'base_image' => $gift['base_image'],
|
||||
'gift_price' => $gift['gift_price'],
|
||||
'user_wallet_coin' => $wallet_coin,
|
||||
];
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => $return_data];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//撩TA
|
||||
public function liao_ta($room_id,$user_id,$to_user_id){
|
||||
//查询撩TA礼物
|
||||
$liao_ta_gif = $this->get_liao_ta_gift();
|
||||
$liao_ta_gif_id = $liao_ta_gif['gid']??0;
|
||||
//调用送礼接口
|
||||
$re = model("api/SendGift")->send_gift($user_id,$to_user_id,$liao_ta_gif_id,1,1,$room_id);
|
||||
if($re['code'] != 1){
|
||||
return ['code' => 0, 'msg' => $re['msg'], 'data' => null];
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//一键全撩
|
||||
public function one_key_liao_ta($room_id,$user_id){
|
||||
//查询撩TA礼物
|
||||
$liao_ta_gif = $this->get_liao_ta_gift();
|
||||
$liao_ta_gif_id = $liao_ta_gif['gid']??0;
|
||||
//查询麦上用户
|
||||
$room_pit_Users = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => ['<',7],'user_id'=>['>',0],'status' => 1])->column('user_id');
|
||||
if(empty($room_pit_Users)){
|
||||
return ['code' => 0, 'msg' => '没有麦上用户', 'data' => null];
|
||||
}
|
||||
$to_user_ids = [];
|
||||
|
||||
foreach ($room_pit_Users as $key => $value) {
|
||||
if($user_id == $value){//自己
|
||||
continue;
|
||||
}
|
||||
//调用送礼接口
|
||||
$to_user_ids[] = $value;
|
||||
}
|
||||
|
||||
$to_user_ids = implode(',',$to_user_ids);
|
||||
$re = model("api/SendGift")->send_gift($user_id,$to_user_ids,$liao_ta_gif_id,1,1,$room_id);
|
||||
if($re['code'] != 1){
|
||||
return ['code' => 0, 'msg' => $re['msg'], 'data' => null];
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
//获取撩TA礼物
|
||||
public function get_liao_ta_gift(){
|
||||
$cache_key = 'gift_list_17';
|
||||
//2,缓存获取
|
||||
$gift_data = json_decode(Cache::get($cache_key), true);
|
||||
//获取到就返回
|
||||
if($gift_data){
|
||||
return $gift_data;
|
||||
}
|
||||
//查询撩TA礼物
|
||||
$where = [];
|
||||
$where['type'] = 6;
|
||||
$where['label'] = 17;
|
||||
$where['is_show'] = 1;
|
||||
$where['is_can_buy'] = 1;
|
||||
$where['delete_time'] = 0;
|
||||
$gift_data = db::name('vs_gift')->where($where)->order('gid desc')->find();
|
||||
//设置缓存
|
||||
Cache::set($cache_key, json_encode($gift_data), 3600*24);
|
||||
return $gift_data;
|
||||
}
|
||||
|
||||
|
||||
//约TA
|
||||
public function meeting_ta($user_id,$room_id,$meet_user_id,$gift_id){
|
||||
//走送礼流程
|
||||
$res = model("api/SendGift")->send_gift($user_id,$meet_user_id,$gift_id,1,1,$room_id);
|
||||
if($res['code'] != 1){
|
||||
return ['code' => 0, 'msg' => $res['msg'], 'data' => null];
|
||||
}
|
||||
|
||||
//预测版块 上线前注释掉 ======👇======
|
||||
//获取 房间ID
|
||||
// $room_last_id = db::name('vs_room')->order('id desc')->value('id');
|
||||
// if($room_last_id >= 19998){
|
||||
// return ['code' => 0, 'msg' =>'房间已满,暂时不能创建房间,请联系运营或管理', 'data' => null];
|
||||
// }
|
||||
//预测版块 上线前注释掉======👆======
|
||||
|
||||
|
||||
//创建私密房间 并告知前端拉谁进入
|
||||
$room_ids = model('api/Room')->user_create_room($user_id,'酒吧私密房',get_system_config_value('web_site').'/data/avatar/head_pic.png','酒吧房产生的一次性房间',11);
|
||||
if($room_ids['code'] != 1){
|
||||
return ['code' => 0, 'msg' => $room_ids['msg'], 'data' => null];
|
||||
}else{
|
||||
//记录小房间
|
||||
$datda = [
|
||||
'room_id' => $room_ids['data'],
|
||||
'p_room_id' => $room_id,
|
||||
'user_id' => $user_id,
|
||||
'meet_user_id' => $meet_user_id,
|
||||
'end_time' => time() + get_system_config_value('bar_room_timea') * 60,
|
||||
'createtime' => time(),
|
||||
'status' => 1 //1-正常,2-结束
|
||||
];
|
||||
db::name('vs_room_bar_movie')->insert($datda);
|
||||
|
||||
$text['text'] = '约TA并创建房间';
|
||||
$text['room_id'] = $room_ids['data'];//前端用来让用户跳转的房间id
|
||||
$text['user_id'] = $user_id;
|
||||
$text['meet_user_id'] = $meet_user_id;
|
||||
model('api/Chat')->sendMsg(1201,$room_id,$text);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//小黑屋列表
|
||||
public function black_room_list($room_id){
|
||||
$list = db::name('vs_room_bar_movie')->where(['p_room_id' => $room_id,'status' => 1,'end_time' => ['>',time()]])->select();
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => $list];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -182,11 +182,10 @@ class BlindBoxTurntableGift extends Model
|
||||
$roomtype = Db::name('vs_room')->where(['id' => $room_id])->value('type_id');
|
||||
if($roomtype == 6){
|
||||
//推送消息
|
||||
$hot_value = db::name('vs_give_gift')->where('from_id', $room_id)->where('from',6)
|
||||
->sum('total_price');
|
||||
$hot_value = db::name('vs_room')->where('id', $room_id)->value('hot_value');
|
||||
$text1 = [
|
||||
'room_id' => $room_id,
|
||||
'hot_value' => $hot_value * 10,
|
||||
'hot_value' => $hot_value,
|
||||
'text' => '房间心动值变化'
|
||||
];
|
||||
//聊天室推送系统消息
|
||||
|
||||
@@ -24,7 +24,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
// 连接到Redis服务器
|
||||
$this->redis->connect(config('redis.host'), config('redis.port')); // 根据实际配置调整主机和端口
|
||||
// 选择数据库1
|
||||
$this->redis->select(1);
|
||||
$this->redis->select(10);
|
||||
$this->cache_time = 60*60; //缓存一小时
|
||||
} catch (\Exception $e) {
|
||||
Log::record('Redis连接失败: ' . $e->getMessage(), 'error');
|
||||
@@ -35,7 +35,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
/**
|
||||
* 重构后的抽奖方法 - 优化响应速度
|
||||
*/
|
||||
public function draw_gift($gift_bag_id, $user_id, $gift_user_ids, $num = 1, $room_id = 0, $heart_id = 0,$auction_id = 0)
|
||||
public function draw_gift(int $gift_bag_id, int $user_id, string $gift_user_ids, $num = 1, $room_id = 0, $heart_id = 0, $auction_id = 0)
|
||||
{
|
||||
try {
|
||||
// 收礼人
|
||||
@@ -50,7 +50,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
return $validationResult;
|
||||
}
|
||||
//2.预计算抽奖结果
|
||||
$precomputeResult = $this->precomputeDrawResults($gift_bag_id, $total_num, $gift_user_ids,$periods );
|
||||
$precomputeResult = $this->precomputeDrawResults($gift_bag_id, $total_num, $gift_user_ids,$periods,$user_id );
|
||||
$precomputedResults = $precomputeResult['precomputedResults']; //预计算结果集
|
||||
$availableGiftss = $precomputeResult['precomputedResultss']; //可用礼物/需更新的礼物/需更新
|
||||
|
||||
@@ -69,7 +69,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
'precomputedResults' => $precomputedResults,
|
||||
];
|
||||
$this->redis->setex($key, 86400 * 7, "超出数量".json_encode($errorData));
|
||||
return ['code' => 0, 'msg' => '网络加载失败,请重试!', 'data' => null];
|
||||
return ['code' => 0, 'msg' => '活动火爆,请稍后重试!', 'data' => null];
|
||||
}
|
||||
$giftCounts = $this->countGifts($precomputedResults);
|
||||
foreach ($giftCounts as $giftId => $count) {
|
||||
@@ -85,7 +85,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
'giftUserCountsJianCha' => $count,
|
||||
];
|
||||
$this->redis->setex($key, 86400 * 7, "礼物数量超出限制 ".json_encode($errorData));
|
||||
return ['code' => 0, 'msg' => '网络加载失败,请重试!', 'data' => null];
|
||||
return ['code' => 0, 'msg' => '活动火爆,请稍后重试!', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,23 +130,28 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
if ($this->redis) {
|
||||
$this->redis->setex($key, 86400 * 7, $e->getMessage() . ' ' . json_encode($errorData));
|
||||
}
|
||||
return ['code' => 0, 'msg' => "网络加载失败,请重试!", 'data' => null];
|
||||
return ['code' => 0, 'msg' => "活动火爆,请稍后重试!", 'data' => null];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 预计算抽奖结果
|
||||
*/
|
||||
private function precomputeDrawResults($gift_bag_id, $total_num, $gift_user_ids,$periods)
|
||||
private function precomputeDrawResults($gift_bag_id, $total_num, $gift_user_ids,$periods,$user_id)
|
||||
{
|
||||
//查询需要关禁闭的用户user_code
|
||||
$pan_xian_userids = get_system_config_value('pan_xian_userids');
|
||||
$pan_xian_userids_id = db::name('user')->where(['user_code'=>['in',$pan_xian_userids]])->column('id');//用户user_code转Id
|
||||
|
||||
$pan_total_draw_times = $this->getCachedPanDrawTimes($gift_bag_id); //总抽奖次数
|
||||
$pan_total_remaining = $this->getCachedPanTotalRemaining($gift_bag_id); //剩余数量
|
||||
//获取可用礼物
|
||||
$availableGifts = $this->getAvailableGifts($gift_bag_id,$pan_total_draw_times+$total_num);
|
||||
$availableGifts = $this->getAvailableGifts($gift_bag_id,$pan_total_draw_times+$total_num,$user_id);
|
||||
$giftInfoMap = $this->getCachedPanGiftInfoMap($gift_bag_id);//预加载礼物信息
|
||||
$remaining_available_gifts = [];
|
||||
if (empty($availableGifts) ||$pan_total_remaining ==0) {
|
||||
//重置奖池
|
||||
$availableGifts = $this->resetPoolAndReload($gift_bag_id);
|
||||
$periods = $this->getCachedGiftBag($gift_bag_id)['periods']??$periods; // 获取新期数
|
||||
if (empty($availableGifts)) {
|
||||
throw new \Exception('重置奖池后仍无可用礼物');
|
||||
}
|
||||
@@ -209,6 +214,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
}
|
||||
}
|
||||
$pan_total_draw_times = $this->getCachedPanDrawTimes($gift_bag_id,"clear");//总抽奖次数重置
|
||||
$periods = $this->getCachedGiftBag($gift_bag_id)['periods']??$periods; // 获取新期数
|
||||
}
|
||||
// 再从新奖池中分配剩余所需礼物
|
||||
if ($newGiftsNeeded > 0 && !empty($availableGifts)) {
|
||||
@@ -227,6 +233,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
if(!$selectedGift){
|
||||
//重置奖池
|
||||
$availableGifts = $this->resetPoolAndReload($gift_bag_id);
|
||||
$periods = $this->getCachedGiftBag($gift_bag_id)['periods']??$periods; // 获取新期数
|
||||
if (empty($availableGifts)) {
|
||||
throw new \Exception('重置奖池后仍无可用礼物');
|
||||
}
|
||||
@@ -241,6 +248,32 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
$selectedGift = $this->selectGiftWithAliasMethod($aliasTableForNew);
|
||||
}
|
||||
$gift = $giftInfoMap[$selectedGift['foreign_id']]??[];
|
||||
|
||||
//关禁闭
|
||||
if(in_array($user_id,$pan_xian_userids_id)){
|
||||
$gift_bag_detail_duo = db::name("vs_gift_bag_detail")->where([ 'gift_bag_id' => $gift_bag_id,'remaining_number' => ['>',0]])->order('remaining_number', 'desc')->find();
|
||||
if($gift_bag_detail_duo){
|
||||
$selectedGift = $gift_bag_detail_duo;
|
||||
$gift = $giftInfoMap[$gift_bag_detail_duo['foreign_id']]??[];
|
||||
}
|
||||
}
|
||||
|
||||
//防止过高爆率,检查本期用户概率
|
||||
//当前用户在本期的(补偿 防止漏洞 超过预期 把盘拉平)
|
||||
//总抽奖金额(支出)
|
||||
// $total_money = db::name('vs_gift_bag_receive_log')->where(['gift_bag_id' => $gift_bag_id,'user_id' => $user_id,'periods'=>$periods])->sum('bag_price');
|
||||
// //总礼物价值(收入)
|
||||
// $total_gift_money = db::name('vs_gift_bag_receive_log')->where(['gift_bag_id' => $gift_bag_id,'user_id' => $user_id,'periods'=>$periods])->sum('gift_price');
|
||||
// if($total_money>0 && $total_gift_money>0){
|
||||
// $ratio =round(($total_gift_money / $total_money),3) ?? 0;
|
||||
// if($ratio > 1.03){
|
||||
// $gift_bag_detail_duo = db::name("vs_gift_bag_detail")->where([ 'gift_bag_id' => $gift_bag_id,'remaining_number' => ['>',0]])->order('remaining_number', 'desc')->find();
|
||||
// if($gift_bag_detail_duo){
|
||||
// $gift = $giftInfoMap[$gift_bag_detail_duo['foreign_id']]??[];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
$precomputedResults[] = [
|
||||
'gift_user_id' => $giftUserId,
|
||||
'gift_bag_detail' => $selectedGift,
|
||||
@@ -304,6 +337,17 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
if (in_array($user_id, $gift_user_ids)) {
|
||||
return ['code' => 0, 'msg' => "收礼人不能包含自己", 'data' => null];
|
||||
}
|
||||
foreach ($gift_user_ids as $gift_user_id){
|
||||
//查询是否实名认证
|
||||
$is_real = model('UserData')->real_name_info($gift_user_id);
|
||||
if($is_real['code']==0){
|
||||
return ['code' => 0, 'msg' => '收礼用户中有未实名,暂不支持收礼', 'data' => null];
|
||||
}else{
|
||||
if($is_real['data']['is_real'] !=1){
|
||||
return ['code' => 0, 'msg' => '收礼用户中有未实名,暂不支持收礼', 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
// 验证用户ID
|
||||
if (empty($user_id)) {
|
||||
return ['code' => 0, 'msg' => '用户ID不能为空', 'data' => null];
|
||||
@@ -313,7 +357,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
return ['code' => 0, 'msg' => '盲盒ID不能为空', 'data' => null];
|
||||
}
|
||||
// 检查用户金币
|
||||
$user_waller = db::name('user_wallet')
|
||||
$user_waller = db::name('user_wallet_coin')
|
||||
->where(['user_id' => $user_id])
|
||||
->find();
|
||||
if (!$user_waller) {
|
||||
@@ -374,7 +418,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
* @param $gift_bag_id
|
||||
* @param $total_draw_times 总抽奖次数
|
||||
*/
|
||||
private function getAvailableGifts($gift_bag_id, $pan_total_draw_times = 0)
|
||||
private function getAvailableGifts($gift_bag_id, $pan_total_draw_times = 0,$user_id=0)
|
||||
{
|
||||
$gift_bag_detail_data = $this->getCachedGiftBagDetail($gift_bag_id);
|
||||
$gift_detail_data = [];
|
||||
@@ -383,6 +427,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
$gift_detail_data[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
return $gift_detail_data;
|
||||
}
|
||||
|
||||
@@ -407,7 +452,14 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
Cache::rm("pan_gift_bag_detail".$gift_bag_id);
|
||||
|
||||
// 重新获取可用礼物
|
||||
return $this->getAvailableGifts($gift_bag_id);
|
||||
$getAvailableGifts = $this->getAvailableGifts($gift_bag_id);
|
||||
if(array_sum(array_column($getAvailableGifts, 'remaining_number')) < array_sum(array_column($getAvailableGifts, 'quantity'))){
|
||||
// 清除缓存
|
||||
Cache::rm("pan_gift_bag".$gift_bag_id);
|
||||
Cache::rm("pan_gift_bag_detail".$gift_bag_id);
|
||||
throw new \Exception('系统繁忙,请稍后再试!');
|
||||
}
|
||||
return $getAvailableGifts;
|
||||
} finally {
|
||||
// 释放锁
|
||||
$this->redis->del($lockKey);
|
||||
@@ -689,7 +741,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
$this->batchInsertGiftBagReceiveLog($bag_data,$user_id, $boxTurntableLog,$room_id, $precomputedResults);
|
||||
|
||||
// 5. 发送礼物
|
||||
$result = $this->sendGiftsToRecipients($precomputedResults, $room_id,$user_id,$heart_id,$auction_id);
|
||||
$result = $this->sendGiftsToRecipients($bag_data,$precomputedResults, $room_id,$user_id,$heart_id,$auction_id);
|
||||
if (isset($result['code']) && $result['code'] !== 1) {
|
||||
throw new \Exception($result['msg']);
|
||||
}
|
||||
@@ -718,20 +770,13 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
private function deductUserCoins($user_id, $bagGiftPrice, $room_id , $bag_data=[])
|
||||
{
|
||||
// 使用悲观锁查询用户钱包
|
||||
$userWallet = db::name('user_wallet')
|
||||
$userWallet = db::name('user_wallet_coin')
|
||||
->where(['user_id' => $user_id])
|
||||
->find();
|
||||
if (!$userWallet || $userWallet['coin'] < $bagGiftPrice) {
|
||||
throw new \Exception('用户金币不足');
|
||||
}
|
||||
$walletUpdate = model('GiveGift')->change_user_cion_or_earnings_log(
|
||||
$user_id,
|
||||
$bagGiftPrice,
|
||||
$room_id,
|
||||
1,
|
||||
10,
|
||||
$bag_data['gift_bag_name'] .'抽奖消耗'
|
||||
);
|
||||
$walletUpdate = model('api/UserWallet')->change_user_cion_log($user_id, $bagGiftPrice, $room_id, 10, $bag_data['gift_bag_name'] .'抽奖消耗');
|
||||
if (!$walletUpdate) {
|
||||
throw new \Exception('扣除用户金币失败');
|
||||
}
|
||||
@@ -815,7 +860,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
/**
|
||||
* 发送礼物给接收者
|
||||
*/
|
||||
private function sendGiftsToRecipients($precomputedResults, $room_id,$user_id,$heart_id,$auction_id)
|
||||
private function sendGiftsToRecipients($bag_data,$precomputedResults, $room_id,$user_id,$heart_id,$auction_id)
|
||||
{
|
||||
// 统计每个用户每个礼物的数量
|
||||
$giftUserCounts = [];
|
||||
@@ -837,28 +882,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
if($userGift['count'] > 9){ //防止礼物超发,礼物超10个则不发送
|
||||
continue;
|
||||
}
|
||||
$giveGiftExt = [
|
||||
'gift_id' => $userGift['gift_id'],
|
||||
'count' => $userGift['count'],
|
||||
'gift_price' => $userGift['gift_price'],
|
||||
'all_gift_price' => $userGift['gift_price'] * $userGift['count'],
|
||||
'is_draw_gift' => 1
|
||||
];
|
||||
if(!empty($auction_id)){ //竞拍
|
||||
model('RoomAuction')->room_auction_join($auction_id,$user_id,$userGift['gift_id'],$userGift['count'],2,$giveGiftExt);
|
||||
}else{
|
||||
$res = model('Room')->room_gift(
|
||||
$user_id,
|
||||
$userGift['gift_user_id'],
|
||||
$userGift['gift_id'],
|
||||
$userGift['count'],
|
||||
1,
|
||||
$room_id,
|
||||
0,
|
||||
$heart_id,
|
||||
$giveGiftExt
|
||||
);
|
||||
}
|
||||
$res = model("api/SendGift")->single_send_gift_pan($user_id,$userGift['gift_user_id'],$userGift['gift_id'],$userGift['count'],1,$room_id,$bag_data['gift_bag_id'], $heart_id,$auction_id);
|
||||
if (isset($res) && $res['code'] != 1) {
|
||||
Log::record('发送礼物失败: ' . $res['msg'] . $userGift['gift_user_id'], "info");
|
||||
return ['code' => 0, 'msg' => $res['msg'], 'data' => null];
|
||||
@@ -869,13 +893,19 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
/**
|
||||
* 统计礼物数量
|
||||
*/
|
||||
private function countGifts($precomputedResults)
|
||||
private function countGifts($precomputedResults,$key_type = 1)
|
||||
{
|
||||
$giftCounts = [];
|
||||
foreach ($precomputedResults as $result) {
|
||||
$giftId = $result['gift_bag_detail']['foreign_id'];
|
||||
if (!isset($giftCounts[$giftId])) {
|
||||
$giftCounts[$giftId] = [
|
||||
$gift_user_id = $result['gift_user_id'];
|
||||
if($key_type ==1){
|
||||
$key = $giftId;
|
||||
}else{
|
||||
$key = $giftId.'_'.$gift_user_id;
|
||||
}
|
||||
if (!isset($giftCounts[$key])) {
|
||||
$giftCounts[$key] = [
|
||||
'gift_user_id' => $result['gift_user_id'],
|
||||
'gift_id' => $giftId,
|
||||
'count' => 0,
|
||||
@@ -883,7 +913,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
'quantity' => $result['gift_bag_detail']['quantity']
|
||||
];
|
||||
}
|
||||
$giftCounts[$giftId]['count']++;
|
||||
$giftCounts[$key]['count']++;
|
||||
}
|
||||
return $giftCounts;
|
||||
}
|
||||
@@ -911,7 +941,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
private function batchInsertBlindBoxResults($precomputedResults, $boxTurntableLog)
|
||||
{
|
||||
// 统计每个用户每个礼物的数量
|
||||
$giftUserCounts = $this->countGifts($precomputedResults);
|
||||
$giftUserCounts = $this->countGifts($precomputedResults,2);
|
||||
// 批量插入
|
||||
$batchInsertData = [];
|
||||
foreach ($giftUserCounts as $userGift) {
|
||||
@@ -1099,18 +1129,11 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
$current_batch = min($batch_size, $num - $total_processed); // 当前批次处理数量
|
||||
// 批量扣除金币(只在第一次事务中处理)
|
||||
if ($total_processed == 0) {
|
||||
$user_waller = db::name('user_wallet')->where(['user_id' => $user_id])->find();
|
||||
$user_waller = db::name('user_wallet_coin')->where(['user_id' => $user_id])->find();
|
||||
if (!$user_waller || $user_waller['coin'] < $bag_gift_price) {
|
||||
return ['code' => 0, 'msg' => '用户金币不足', 'data' => null];
|
||||
}
|
||||
$wallet_update = model('GiveGift')->change_user_cion_or_earnings_log(
|
||||
$user_id,
|
||||
$bag_gift_price,
|
||||
$room_id,
|
||||
1,
|
||||
10,
|
||||
$ext['gift_bag_name'].'抽奖消耗'
|
||||
);
|
||||
$wallet_update = model('api/UserWallet')->change_user_cion_log($user_id, $bag_gift_price, $room_id, 10, $ext['gift_bag_name'].'抽奖消耗');
|
||||
if (!$wallet_update) {
|
||||
throw new \Exception('扣除用户金币失败');
|
||||
}
|
||||
@@ -1126,11 +1149,15 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
}
|
||||
}
|
||||
|
||||
//查询需要关禁闭的用户user_code
|
||||
$pan_xian_userids = get_system_config_value('pan_xian_userids');
|
||||
$pan_xian_userids_id = db::name('user')->where(['user_code'=>['in',$pan_xian_userids]])->column('id');//用户user_code转Id
|
||||
|
||||
// 处理当前批次的抽奖
|
||||
$inventory_updates = []; // 用于记录库存变化
|
||||
for ($i = 0; $i < $current_batch; $i++) {
|
||||
$total_draw_times = $this->getCachedPanDrawTimes($gift_bag_id) ?? 0; //已抽奖次数
|
||||
$availableGifts = $this->getAvailableGifts($gift_bag_id,$total_draw_times); //获取可用礼物
|
||||
$availableGifts = $this->getAvailableGifts($gift_bag_id,$total_draw_times,$user_id); //获取可用礼物
|
||||
if (empty($availableGifts)) {
|
||||
$availableGifts = $this->resetPoolAndReload($gift_bag_id);
|
||||
if (empty($availableGifts)) {
|
||||
@@ -1150,6 +1177,16 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
$inventory_updates[$selected_gift['id']] = ($inventory_updates[$selected_gift['id']] ?? 0) + 1;
|
||||
// 记录抽中结果
|
||||
$gift_id = $selected_gift['foreign_id'];
|
||||
|
||||
//关禁闭
|
||||
if(in_array($user_id,$pan_xian_userids_id)){
|
||||
$gift_bag_detail_duo = db::name("vs_gift_bag_detail")->where([ 'gift_bag_id' => $gift_bag_id,'remaining_number' => ['>',0]])->order('remaining_number', 'desc')->find();
|
||||
if($gift_bag_detail_duo){
|
||||
$gift_id = $gift_bag_detail_duo['foreign_id'];
|
||||
}
|
||||
}
|
||||
//关禁闭-end
|
||||
|
||||
$drawn_gifts[$gift_id] = ($drawn_gifts[$gift_id] ?? 0) + 1;
|
||||
// 处理主奖品
|
||||
if ($gift_id == $ext['locking_condition']['selected_gift_id']) {
|
||||
@@ -1158,6 +1195,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
$pan_xlh_num = $pan_xlh['num'] ?? 0;
|
||||
}
|
||||
$pan_xlh_num++;
|
||||
$pan_xlh_num_bf = $pan_xlh_num;
|
||||
cache::set('pan_xlh_num_'.$gift_bag_id.'_'.$pan_xlh['id'], $pan_xlh_num,$this->cache_time);
|
||||
$main_prize_updates[] = [
|
||||
'num' => $pan_xlh_num,
|
||||
@@ -1301,7 +1339,11 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
}
|
||||
// 8. 处理推送消息
|
||||
if ($is_zhong_jiang == 1) {
|
||||
$pan_xlh_num = cache::get('pan_xlh_num_'.$gift_bag_id.'_'.$pan_xlh['id']);
|
||||
if(cache::get('pan_xlh_num_'.$gift_bag_id.'_'.$pan_xlh['id'])){
|
||||
$pan_xlh_num = cache::get('pan_xlh_num_'.$gift_bag_id.'_'.$pan_xlh['id']);
|
||||
}else{
|
||||
$pan_xlh_num = $pan_xlh_num_bf;
|
||||
}
|
||||
$this->handlePrizeNotification($user_id, $room_id, $pan_xlh_num, $pan_xlh['id'],$ext['locking_condition']['locking_gift_id']);
|
||||
}
|
||||
//删除缓存
|
||||
@@ -1365,8 +1407,8 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
//测试数据
|
||||
// 20060 => [$selected_gift_id => 2],
|
||||
// 在这里可以添加更多规则 【正式规则】
|
||||
21222 => [$selected_gift_id => 6],//10012
|
||||
21259 => [$selected_gift_id => 6],//10049
|
||||
// 21222 => [$selected_gift_id => 6],//10012
|
||||
// 21259 => [$selected_gift_id => 6],//10049
|
||||
];
|
||||
// 如果没有指定用户或该用户没有特殊概率调整,则直接返回原数组
|
||||
if ($user_id <= 0 || !isset($probability_adjustments[$user_id])) {
|
||||
@@ -1413,8 +1455,8 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
}
|
||||
|
||||
if ($add_end_time <= 30) {
|
||||
Cache::set($cache_key, 30, 30);
|
||||
return 30;
|
||||
Cache::set($cache_key, 10, 10);
|
||||
return 10;
|
||||
}
|
||||
|
||||
return $add_end_time;
|
||||
@@ -1495,7 +1537,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
|
||||
// 获取转盘信息和用户钱包
|
||||
$bag_data = $this->getCachedGiftBag($gift_bag_id);
|
||||
$user_wallet = Db::name('user_wallet')->where(['user_id' => $user_id])->find();
|
||||
$user_wallet = Db::name('user_wallet_coin')->where(['user_id' => $user_id])->find();
|
||||
|
||||
if (!$user_wallet) {
|
||||
return ['code' => 0, 'msg' => '用户钱包不存在', 'data' => null];
|
||||
@@ -1507,7 +1549,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
}
|
||||
|
||||
// 检查奖池状态并准备礼物
|
||||
$pool_status = $this->prepareGiftPool($gift_bag_id, $num);
|
||||
$pool_status = $this->prepareGiftPool($gift_bag_id, $num,$user_id);
|
||||
if ($pool_status['code'] !== 1) {
|
||||
throw new \Exception($pool_status['msg']);
|
||||
}
|
||||
@@ -1528,7 +1570,8 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
$available_gifts,
|
||||
$remaining_available_gifts,
|
||||
$num,
|
||||
$periods
|
||||
$periods,
|
||||
$user_id
|
||||
);
|
||||
|
||||
if ($draw_result['code'] !== 1) {
|
||||
@@ -1586,7 +1629,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
$this->redis->setex($key, 86400 * 7, $e->getMessage() . ' ' . json_encode($error_data));
|
||||
}
|
||||
|
||||
return ['code' => 0, 'msg' => "网络加载失败,请重试!", 'data' => null];
|
||||
return ['code' => 0, 'msg' => "活动火爆,请稍后重试!", 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1613,11 +1656,11 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
/**
|
||||
* 准备奖池
|
||||
*/
|
||||
private function prepareGiftPool($gift_bag_id, $num)
|
||||
private function prepareGiftPool($gift_bag_id, $num,$user_id)
|
||||
{
|
||||
$pan_total_draw_times = $this->getCachedPanDrawTimes($gift_bag_id);
|
||||
$pan_total_remaining = $this->getCachedPanTotalRemaining($gift_bag_id);
|
||||
$available_gifts = $this->getAvailableGifts($gift_bag_id, $pan_total_draw_times + $num);
|
||||
$available_gifts = $this->getAvailableGifts($gift_bag_id, $pan_total_draw_times + $num,$user_id);
|
||||
|
||||
$remaining_gifts = [];
|
||||
|
||||
@@ -1631,6 +1674,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
$this->getCachedPanDrawTimes($gift_bag_id, "clear");
|
||||
} else if ($pan_total_remaining < $num) {
|
||||
// 如果剩余数量不足,保存当前剩余礼物作为上期剩余
|
||||
// 但只分配实际剩余数量的礼物,避免超额分配
|
||||
$remaining_gifts = $available_gifts;
|
||||
$available_gifts = $this->resetPoolAndReload($gift_bag_id);
|
||||
|
||||
@@ -1639,6 +1683,9 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
}
|
||||
|
||||
$this->getCachedPanDrawTimes($gift_bag_id, "clear");
|
||||
} else {
|
||||
// 剩余数量足够,直接使用当前奖池
|
||||
// 不需要特殊处理,正常流程即可
|
||||
}
|
||||
|
||||
return [
|
||||
@@ -1654,32 +1701,114 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
/**
|
||||
* 执行礼物抽取
|
||||
*/
|
||||
private function performGiftDrawing($gift_bag_id, $available_gifts, $remaining_gifts, $num, $periods)
|
||||
private function performGiftDrawing($gift_bag_id, $available_gifts, $remaining_gifts, $num, $periods,$user_id=0)
|
||||
{
|
||||
//查询需要关禁闭的用户user_code
|
||||
$pan_xian_userids = get_system_config_value('pan_xian_userids');
|
||||
$pan_xian_userids_id = db::name('user')->where(['user_code'=>['in',$pan_xian_userids]])->column('id');//用户user_code转Id
|
||||
|
||||
$drawn_gifts = [];
|
||||
$precomputed_results = [];
|
||||
$available_giftss = [];
|
||||
$inventory_updates = [];
|
||||
$old_gift_num = 0;
|
||||
|
||||
// 先处理上期剩余的礼物
|
||||
// 先处理上期剩余的礼物,但要严格控制数量,避免超额分配
|
||||
if (!empty($remaining_gifts)) {
|
||||
foreach ($remaining_gifts as $remaining_gift) {
|
||||
$gift_id = $remaining_gift['foreign_id'];
|
||||
$drawn_gifts[$gift_id] = ($drawn_gifts[$gift_id] ?? 0) + 1;
|
||||
// 获取上期实际剩余数量
|
||||
$remaining_total = array_sum(array_column($remaining_gifts, 'remaining_number'));
|
||||
// 计算实际可从剩余礼物中分配的数量
|
||||
$actual_old_gift_num = min($num, $remaining_total);
|
||||
|
||||
$gift_queue = []; // 初始化礼物队列
|
||||
foreach ($remaining_gifts as $remaining_gift) {
|
||||
$gift_id = $remaining_gift['foreign_id'];//礼物ID
|
||||
|
||||
//关禁闭
|
||||
if(in_array($user_id,$pan_xian_userids_id)){
|
||||
$gift_bag_detail_duo = db::name("vs_gift_bag_detail")->where([ 'gift_bag_id' => $gift_bag_id,'remaining_number' => ['>',0]])->order('remaining_number', 'desc')->find();
|
||||
if($gift_bag_detail_duo){
|
||||
$gift_id = $gift_bag_detail_duo['foreign_id'];
|
||||
$remaining_gift = $gift_bag_detail_duo;
|
||||
}
|
||||
}
|
||||
//关禁闭-end
|
||||
|
||||
//查询上期这个礼物抽取数量----------------
|
||||
$count_num = Db::name('vs_gift_bag_receive_pan_log')->where(['gift_bag_id' => $gift_bag_id,'gift_id' => $gift_id,'periods'=>$periods-1])->count();
|
||||
$error_gifts[$gift_id] =[
|
||||
//上期抽中数量
|
||||
'count_num'=>$count_num,
|
||||
'quantity'=>$remaining_gift['quantity'],
|
||||
'remaining_number'=>$remaining_gift['remaining_number'] // 添加实际剩余数量
|
||||
];
|
||||
|
||||
//上期这个礼物抽走数量与礼物上限数量相同剔除这个礼物
|
||||
if ($count_num >= $remaining_gift['quantity']){
|
||||
//错误日志记录--------
|
||||
$key = 'blind_box_draw_shengyu1_errors_' . date('Y-m-d-H-i-s');
|
||||
$errorData=[
|
||||
'gift_bag_id' => $gift_bag_id,
|
||||
'available_gifts' => $available_gifts,
|
||||
'remaining_gifts' => $remaining_gifts,
|
||||
'num' => $num,
|
||||
'gift_id' => $gift_id,
|
||||
'periods' => $periods,
|
||||
];
|
||||
$this->redis->setex($key, 86400 * 7, "礼物数量超出限制 ".json_encode($errorData));
|
||||
//错误日志记录--------end
|
||||
//剔除该礼物
|
||||
continue;
|
||||
}
|
||||
|
||||
// 将礼物按剩余数量添加到队列中
|
||||
for ($i = 0; $i < $remaining_gift['remaining_number']; $i++) {
|
||||
$gift_queue[] = $remaining_gift;
|
||||
}
|
||||
}
|
||||
// 从礼物队列中分配礼物,直到达到实际需要的数量
|
||||
for ($i = 0; $i < $actual_old_gift_num && $i < count($gift_queue); $i++) {
|
||||
$selected_gift = $gift_queue[$i];
|
||||
$gift_id = $selected_gift['foreign_id'];
|
||||
|
||||
//查询上把这个礼物抽取数量------防止并发多出容错----------
|
||||
$drawn_gifts[$gift_id] = ($drawn_gifts[$gift_id] ?? 0) + 1;
|
||||
$precomputed_results[] = [
|
||||
'gift_id' => $gift_id,
|
||||
'gift_detail_id' => $remaining_gift['id'],
|
||||
'gift_bag_detail' => $remaining_gift,
|
||||
'gift_detail_id' => $selected_gift['id'],
|
||||
'gift_bag_detail' => $selected_gift,
|
||||
'gift' => Db::name('vs_gift')->where(['gid' => $gift_id])->find(),
|
||||
'gift_user_id' => 0,
|
||||
'periods' => $periods,
|
||||
];
|
||||
$old_gift_num++;
|
||||
}
|
||||
//防止上把数据错误
|
||||
foreach ($drawn_gifts as $gift_id => $count){
|
||||
//正常数量
|
||||
$normal_num = $error_gifts[$gift_id]['quantity'] - $error_gifts[$gift_id]['count_num'];
|
||||
if($count > $normal_num){
|
||||
//错误日志记录--------
|
||||
$key = 'blind_box_draw_shengyu2_errors_' . date('Y-m-d-H-i-s');
|
||||
$errorData=[
|
||||
'gift_bag_id' => $gift_bag_id,
|
||||
'available_gifts' => $available_gifts,
|
||||
'remaining_gifts' => $remaining_gifts,
|
||||
'num' => $num,
|
||||
'gift_id' => $gift_id,
|
||||
'periods' => $periods,
|
||||
'error_gifts'=>$error_gifts,
|
||||
'normal_num'=>$normal_num
|
||||
];
|
||||
$this->redis->setex($key, 86400 * 7, "礼物数量超出限制 ".json_encode($errorData));
|
||||
//错误日志记录--------end
|
||||
$drawn_gifts[$gift_id] = $normal_num;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 计算还需要抽取的数量
|
||||
$remaining_count = $num - count($remaining_gifts);
|
||||
$remaining_count = max(0, $num - $old_gift_num);
|
||||
|
||||
// 抽取新礼物
|
||||
for ($i = 0; $i < $remaining_count; $i++) {
|
||||
@@ -1687,6 +1816,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
|
||||
if (!$selected_gift) {
|
||||
$gift_bag_detail = $this->resetPoolAndReload($gift_bag_id);
|
||||
$periods = $this->getCachedGiftBag($gift_bag_id)['periods']??$periods; // 获取新期数
|
||||
$selected_gift = $this->selectGiftFromAvailable($gift_bag_detail);
|
||||
|
||||
if (!$selected_gift) {
|
||||
@@ -1710,7 +1840,6 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
'gift_user_id' => 0,
|
||||
'periods' => $periods,
|
||||
];
|
||||
|
||||
$available_giftss[] = $result_entry;
|
||||
$precomputed_results[] = $result_entry;
|
||||
|
||||
|
||||
@@ -151,6 +151,15 @@ class Chat extends Model
|
||||
//爆币房推送信息
|
||||
// BlindCoinRoom = 1100,
|
||||
|
||||
//酒吧房撩TA推送
|
||||
// BarRoomLiaoTa = 1200,
|
||||
//酒吧房开私密房
|
||||
// BarRoomOpenPrivateRoom = 1201,
|
||||
//酒吧房抱麦
|
||||
// BarRoomUpSeat = 1202,
|
||||
//酒吧房上麦后设置自定义礼物设置
|
||||
// BarRoomSetCustomGift = 1203,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Cache;
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
@@ -87,12 +88,22 @@ class Decorate extends Model
|
||||
->order('price asc')
|
||||
->select();
|
||||
}else{
|
||||
$list = DB::name($this->table)->alias('a')->join('fa_vs_decorate_price b', 'a.did = b.did')->field('a.did,a.title,a.type,a.base_image,a.play_image,min(b.price) as price,special_num')->where($map)->group('b.did')->order('price asc')->select();
|
||||
$list = DB::name($this->table)
|
||||
->alias('a')->join('fa_vs_decorate_price b', 'a.did = b.did')
|
||||
->field('a.did,a.title,a.type,a.base_image,a.play_image,min(b.price) as price,special_num,b.original_price,b.discount')->where($map)->group('b.did')->order('price asc')->select();
|
||||
}
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['base_image'] = localpath_to_netpath($v['base_image']);
|
||||
$v['play_image'] = localpath_to_netpath($v['play_image']);
|
||||
$v['price'] = (int)$v['price'];
|
||||
if(isset($v['discount'])){
|
||||
if($v['discount']<=0 || $v['discount']>=10){
|
||||
$v['discount'] = 0;
|
||||
$v['discount_str'] = "无折扣";
|
||||
}else{
|
||||
$v['discount_str'] = $v['discount']."折";
|
||||
}
|
||||
}
|
||||
}
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $list];
|
||||
}
|
||||
@@ -115,6 +126,7 @@ class Decorate extends Model
|
||||
$result['title'] = $decorate['title'];
|
||||
foreach ($decorate_price as $k => $v) {
|
||||
$result['price_list'][$k]['price'] = (int)$v['price'];
|
||||
$result['price_list'][$k]['original_price'] = $v['original_price'];
|
||||
$result['price_list'][$k]['discount'] = $v['discount'];
|
||||
$result['price_list'][$k]['day'] = $v['day'];
|
||||
//月
|
||||
@@ -137,6 +149,11 @@ class Decorate extends Model
|
||||
*
|
||||
*/
|
||||
public function pay_decorate($uid, $did, $day=0,$from_type=1,$give_uid=0,$log_remark="",$num=1){
|
||||
if(empty($day) && $from_type == 12){
|
||||
$day = 0;
|
||||
}else{
|
||||
$day = db::name('vs_decorate_price')->where(['did'=>$did])->order('day asc')->value('day');
|
||||
}
|
||||
if(empty($log_remark)){
|
||||
$log_remark = $this->FromType[$from_type];
|
||||
}
|
||||
@@ -177,7 +194,7 @@ class Decorate extends Model
|
||||
}
|
||||
}else{
|
||||
$decorate_price_info = [
|
||||
'price' => $decorate_info['price'],
|
||||
'price' => $decorate_info['price'] * $num,
|
||||
'day' => 0
|
||||
];
|
||||
}
|
||||
@@ -292,7 +309,7 @@ class Decorate extends Model
|
||||
}catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => "请重试", 'data' => null];
|
||||
return ['code' => 0, 'msg' => "请重试".$e->getMessage(), 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -121,22 +121,22 @@ class Family extends Model
|
||||
// 优化今日收益计算逻辑
|
||||
$todayStart = strtotime(date('Y-m-d'));
|
||||
if($v['createtime'] < $todayStart){
|
||||
$lists[$k]['today_earnings'] = round(db::name('vs_user_money_log')
|
||||
->where(['user_id' => $v['user_id'],'money_type' => 2,'change_type' =>11,'createtime' => ['between',[$todayStart,time()]]])
|
||||
->sum('change_value'), 4);//今日收益
|
||||
$lists[$k]['today_earnings'] = round(db::name('user_earnings_log')
|
||||
->where(['user_id' => $v['user_id'],'change_type' =>11,'createtime' => ['between',[$todayStart,time()]]])
|
||||
->sum('earnings'), 4);//今日收益
|
||||
}else{
|
||||
$lists[$k]['today_earnings'] = round(db::name('vs_user_money_log')
|
||||
->where(['user_id' => $v['user_id'],'money_type' => 2,'change_type' =>11,'createtime' => ['between',[$v['createtime'],time()]]])
|
||||
->sum('change_value'), 4);//今日收益
|
||||
$lists[$k]['today_earnings'] = round(db::name('user_earnings_log')
|
||||
->where(['user_id' => $v['user_id'],'change_type' =>11,'createtime' => ['between',[$v['createtime'],time()]]])
|
||||
->sum('earnings'), 4);//今日收益
|
||||
}
|
||||
|
||||
// 昨日收益计算逻辑优化
|
||||
$yesterdayStart = strtotime(date('Y-m-d', strtotime('-1 day')));
|
||||
$yesterdayEnd = strtotime(date('Y-m-d'));
|
||||
if($v['createtime'] <= $todayStart) {
|
||||
$lists[$k]['yesterday_earnings'] = round(db::name('vs_user_money_log')
|
||||
->where(['user_id' => $v['user_id'], 'money_type' => 2, 'change_type' => 11, 'createtime' => ['between', [$yesterdayStart, $yesterdayEnd]]])
|
||||
->sum('change_value'), 4);
|
||||
$lists[$k]['yesterday_earnings'] = round(db::name('user_earnings_log')
|
||||
->where(['user_id' => $v['user_id'], 'change_type' => 11, 'createtime' => ['between', [$yesterdayStart, $yesterdayEnd]]])
|
||||
->sum('earnings'), 4);
|
||||
}else{
|
||||
$lists[$k]['yesterday_earnings'] = 0;
|
||||
}
|
||||
|
||||
@@ -113,15 +113,17 @@ class Friend extends Model
|
||||
$return['user2_nickname'] = db::name('user')->where(['id'=>$originalPairs['user2_id']])->value('nickname');
|
||||
$return['heart_value'] = $originalPairs['heart_value'];
|
||||
$return['heart_id'] = $originalPairs['id'];
|
||||
$room_updatatime = db::name('vs_room')->where(['id' => $room_id,'step' => $step])->value('updatetime');
|
||||
if($room_updatatime){ //60秒内没操作 则创建关系无
|
||||
if(time() - $room_updatatime > 60){
|
||||
// $room_updatatime = db::name('vs_room')->where(['id' => $room_id,'step' => $step])->value('updatetime');
|
||||
$room_updatatime = db::name('vs_user_friending')->where(['id' => $id])->value('update_time');
|
||||
if($room_updatatime){ //180秒内没操作 则创建关系无(元旦 泽喜 说的)
|
||||
if(time() - $room_updatatime > 180){
|
||||
$this->createRelation(0,$room_id,$id,$return['user1_id'],$return['user2_id'],0);
|
||||
return ['code' => 1, 'msg' => '操作成功!', 'data' => $return];
|
||||
}
|
||||
}else{
|
||||
// 修改当前交友阶段
|
||||
db::name('vs_room')->where(['id' => $room_id])->update(['step' => $step,'updatetime' => time()]);
|
||||
db::name('vs_user_friending')->where(['id' => $id])->update(['update_time' => time()]);
|
||||
}
|
||||
}else{
|
||||
$step = 1;//结束下一轮
|
||||
@@ -131,7 +133,7 @@ class Friend extends Model
|
||||
$on_pit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => ['<',7],'user_id' => ['<>',0]])->select();
|
||||
if($on_pit){
|
||||
foreach ($on_pit as $pit){
|
||||
model('RoomPit')->DownPit($pit['user_id'], $room_id,$pit['pit_number']);
|
||||
model('api/RoomPit')->DownPit($pit['user_id'], $room_id,$pit['pit_number']);
|
||||
}
|
||||
}
|
||||
$return = null;
|
||||
@@ -139,7 +141,7 @@ class Friend extends Model
|
||||
|
||||
//结束交友游戏
|
||||
if($step == 1){
|
||||
db::name('vs_user_friending')->where(['id' => $id])->update(['status' => 2]);
|
||||
db::name('vs_user_friending')->where(['id' => $id])->update(['status' => 2,'update_time' => time()]);
|
||||
}
|
||||
//推送给前端消息
|
||||
$text['text'] = $step == 1 ? '交友结束' : '牵手良缘';
|
||||
@@ -147,7 +149,7 @@ class Friend extends Model
|
||||
$text['friend_user'] = $return;
|
||||
$text['friend_id'] = $id;
|
||||
model('api/Chat')->sendMsg(1049,$room_id,$text);
|
||||
model('Room')->clear_user_charm(db::name('vs_room')->where(['id' => $room_id])->value('user_id'), $room_id);
|
||||
model('api/Room')->clear_user_charm(db::name('vs_room')->where(['id' => $room_id])->value('user_id'), $room_id);
|
||||
return ['code' => 1, 'msg' => '操作成功!', 'data' => $return];
|
||||
}
|
||||
|
||||
@@ -166,11 +168,16 @@ class Friend extends Model
|
||||
$originalPairs = db::name('vs_user_friending_heart')
|
||||
->where(['id'=>$friending_heart['id']])
|
||||
->update(['status' => 3,'friend_config_id' =>$friending_config_id]);
|
||||
|
||||
$msg = '';
|
||||
// 修改当前交友阶段
|
||||
$res = db::name('vs_room')->where(['id' => $room_id])->update(['step' => 1]);
|
||||
$res2 = db::name('vs_user_friending')->where(['id' => $friend_id])->update(['status' => 2]);
|
||||
if ($originalPairs && $res && $res2) {
|
||||
|
||||
if ($originalPairs) {
|
||||
// 修改当前交友阶段
|
||||
$res = db::name('vs_room')->where(['id' => $room_id])->update(['step' => 1]);
|
||||
if($res){
|
||||
$res2 = db::name('vs_user_friending')->where(['id' => $friend_id])->update(['status' => 2,'update_time' => time()]);
|
||||
}
|
||||
|
||||
//所有人下麦
|
||||
$on_pit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => ['<',7],'user_id' => ['<>',0]])->select();
|
||||
if($on_pit){
|
||||
@@ -256,10 +263,14 @@ class Friend extends Model
|
||||
|
||||
return ['code' => 1, 'msg' => '创建关系成功!'.$msg, 'data' => null];
|
||||
} else {
|
||||
$ress = db::name('vs_user_friending')->where(['id' => $friend_id])->update(['status' => 2]);
|
||||
$re2s = db::name('vs_room')->where(['id' => $room_id])->update(['step' => 1]);
|
||||
$ress = 0;
|
||||
if($re2s){
|
||||
$ress = db::name('vs_user_friending')->where(['id' => $friend_id])->update(['status' => 2,'update_time' => time()]);
|
||||
}
|
||||
|
||||
//推送给前端消息
|
||||
$text['status1'] = $ress.'<=>'.$re2s.'<=>'.$res.'<=>'.$res2.'<=>'.$originalPairs;
|
||||
$text['status1'] = $ress.'<=>'.$re2s.'<=>'.$originalPairs;
|
||||
$text['text'] = '交友结束';
|
||||
$text['step'] = 1;//1 等待邂逅 2 心动连线 3 牵手良缘
|
||||
model('api/Chat')->sendMsg(1049,$room_id,$text);
|
||||
@@ -270,27 +281,20 @@ class Friend extends Model
|
||||
|
||||
|
||||
//退出私密房间
|
||||
public function outRoom($user_id,$room_id){
|
||||
public function outRoom($type,$room_id){
|
||||
//推送给前端消息
|
||||
$text['text'] = '退出私密小屋';
|
||||
model('api/Chat')->sendMsg(1055,$room_id,$text);
|
||||
|
||||
|
||||
// //查询在房间的用户
|
||||
// $users = db::name('vs_room_visitor')->where(['room_id'=>$room_id])->select();
|
||||
// if($users){
|
||||
// //退出房间
|
||||
// foreach ($users as $v){
|
||||
// //退出房间
|
||||
// model('Room')->quit_room($v['user_id'], $room_id,$v['user_id']);
|
||||
// }
|
||||
// }else{
|
||||
// model('Room')->quit_room($user_id, $room_id,$user_id);
|
||||
// }
|
||||
|
||||
//注销房间
|
||||
db::name('vs_room')->where(['id'=>$room_id])->update(['room_status'=>3]);
|
||||
db::name('vs_room_cp_movie')->where(['room_id'=>$room_id])->update(['status'=>4]);
|
||||
if($type){//交友、拍卖
|
||||
db::name('vs_room_cp_movie')->where(['room_id'=>$room_id])->update(['status'=>4]);
|
||||
}else{//酒吧房私密
|
||||
db::name('vs_room_bar_movie')->where(['room_id'=>$room_id])->update(['status'=>2]);
|
||||
}
|
||||
//删除腾讯群组
|
||||
model('api/Tencent')->delete_group('room'.$room_id);
|
||||
|
||||
return ['code' => 1, 'msg' => '退出成功!', 'data' => null];
|
||||
@@ -310,16 +314,12 @@ class Friend extends Model
|
||||
* @param $room_id 房间id
|
||||
* @param $pit_number 坑位
|
||||
*/
|
||||
public function room_give_gift($uid, $to_uid, $gift_id, $gift_num, $from_type, $type, $room_id, $pit_number, $heart_id,$give_gift_ext)
|
||||
public function room_give_gift($uid, $to_uid,$room_id,$res,$heart_id = 0)
|
||||
{
|
||||
$res = model('GiveGift')->give_gift($uid, $to_uid, $gift_id, $gift_num, $from_type, $type, $room_id, $pit_number,0,$give_gift_ext);
|
||||
if($res['code'] != 1){
|
||||
return $res;
|
||||
}
|
||||
|
||||
//送礼成功后续操作
|
||||
//查看当前时间是否在交友表的创建时间和结束时间段内 用来区分是否要拉取心动值高的用户上麦
|
||||
$friend = db::name('vs_user_friending')->where(['room_id' => $room_id,'status' => 1])->order('id desc')->find();
|
||||
|
||||
//查看当前时间是否在交友表的创建时间和结束时间段内 用来区分是否要拉取心动值高的用户上麦
|
||||
if($friend && time() >= $friend['create_time'] && time() <= $friend['end_time']){
|
||||
$heart_exp = get_system_config_value('coin_charm_exp');//金币与魅力值转换比
|
||||
$sumPrice = $res['data']['gift_total'] * $heart_exp;
|
||||
@@ -327,7 +327,7 @@ class Friend extends Model
|
||||
|
||||
if($heart_id){//有这个值就是助力 不参加抢麦操作
|
||||
db::name('vs_user_friending_heart')->where(['id' => $heart_id])->setInc('heart_value', $sumPrice);
|
||||
$this->pullHeartChange($room_id,$friend['id']);//聊天室心动值变化通知
|
||||
// $this->pullHeartChange($room_id,$friend['id']);//聊天室心动值变化通知 注释掉是因为下面那个函数会处理
|
||||
//生成新排名 判断抱上麦 还是换麦
|
||||
$this->pullUserPit($room_id,$friend['id']);
|
||||
}else{
|
||||
@@ -335,7 +335,7 @@ class Friend extends Model
|
||||
$host = $this->is_host($uid,$to_uid,$room_id);
|
||||
$user_idd = explode(",", $user_idd); // 将字符串转换为数组
|
||||
//判断是否是主持
|
||||
if($host['is_preside'] == 1){
|
||||
if($host && $host['is_preside'] == 1){
|
||||
if(!in_array($uid,$host['is_preside_user'])){//主持不是当前送礼人,那就是在收礼人中
|
||||
//从数组中剔除主持人 && $is_preside_user!= UID
|
||||
$user_idd = array_diff($user_idd, $host['is_preside_user']); // 从数组中移除
|
||||
@@ -371,13 +371,13 @@ class Friend extends Model
|
||||
foreach ($user_ids as $value) {
|
||||
//判断收礼人是否是主持
|
||||
if (in_array($value, $host)) {
|
||||
$is_preside = 1;
|
||||
$is_preside = 1;//是主持
|
||||
$is_preside_user[] = $value;
|
||||
}
|
||||
}
|
||||
//送礼人是主持或嘉宾
|
||||
if (in_array($uid, $host)) {
|
||||
$is_preside = 1;
|
||||
$is_preside = 1;//是嘉宾
|
||||
$is_preside_user[] = $uid;
|
||||
}
|
||||
return ['is_preside' =>$is_preside,'is_preside_user' => $is_preside_user];
|
||||
@@ -750,7 +750,7 @@ class Friend extends Model
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//获取此阶段的1-6麦位 全部返给前端 前端比对 里面没有自己 则闭麦……
|
||||
$getRoomNullPit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => ['<',7]])->select();
|
||||
$data_users = [];
|
||||
foreach($getRoomNullPit as $key_data => $value_data){
|
||||
|
||||
@@ -68,7 +68,7 @@ class Gift extends Model
|
||||
// if($room_id){
|
||||
// $is_open_blind_box_turntable = Db::name('vs_room')->where(['id'=>$room_id])->value('is_open_blind_box_turntable');
|
||||
// }
|
||||
$list = $this->field('gid as gift_id,gift_name,base_image,gift_price,icon')->where($map)->where($where)->order('sort asc, gift_price asc')->select();
|
||||
$list = $this->field('gid as gift_id,gift_name,base_image,gift_price,icon')->where($map)->where($where)->order('sort desc, gift_price asc')->select();
|
||||
if($label==2){
|
||||
$list_data = [];
|
||||
foreach ($list as &$v) {
|
||||
@@ -104,9 +104,9 @@ class Gift extends Model
|
||||
}
|
||||
}
|
||||
}
|
||||
usort($list_data, function($a, $b) {
|
||||
return $a['gift_id'] <=> $b['gift_id'];
|
||||
});
|
||||
// usort($list_data, function($a, $b) {
|
||||
// return $a['gift_id'] <=> $b['gift_id'];
|
||||
// });
|
||||
$list = $list_data;
|
||||
}
|
||||
|
||||
|
||||
184
application/api/model/GiftNew.php
Normal file
184
application/api/model/GiftNew.php
Normal file
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Cache;
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
|
||||
class GiftNew extends Model
|
||||
{
|
||||
/*
|
||||
* 获取礼物列表
|
||||
* @param int $label 礼物标签
|
||||
* @param int $type 类型:1-房间送礼礼物,2-排麦设置插麦礼物,3-拍卖位选择拍卖礼物,4-歌手添加歌单礼物,5-动态打赏礼物, 6-酒吧房
|
||||
*/
|
||||
public function get_gift_list($user_id, $type, $label)
|
||||
{
|
||||
$is_lock = 0;
|
||||
if ($label == 13) { // 专属礼物
|
||||
$Nobility = model('api/Nobility')->getUserNobilityInfo($user_id);
|
||||
$power_list_ids = array_column($Nobility['power_list'],'id');
|
||||
if(!in_array(5,$power_list_ids)){
|
||||
$is_lock = 1;
|
||||
}
|
||||
}
|
||||
|
||||
//1,先从缓存获取
|
||||
if($is_lock){//根据这个判断是不是爵位礼物 创建不同的key
|
||||
$cache_key = 'gift_list_'.$label.'_'.$is_lock;
|
||||
}else{
|
||||
$cache_key = 'gift_list_'.$label;
|
||||
}
|
||||
//2,缓存获取
|
||||
$list = json_decode(Cache::get($cache_key), true);
|
||||
//获取到就返回
|
||||
if($list){
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $list];
|
||||
}
|
||||
|
||||
//================================从这里开始写逻辑==================================
|
||||
//根据type的值分析拉起礼物的场合 加$label的条件 给出对应的列表
|
||||
|
||||
//根据类型组装查询条件
|
||||
$where['is_show'] = 1;
|
||||
$where['delete_time'] = 0;
|
||||
if ($label == 99) {
|
||||
$gift_price = get_system_config_value('room_love_auction_cion');
|
||||
$where['gift_price'] = ['>',$gift_price];
|
||||
$where['label'] = ['<>',2];
|
||||
}
|
||||
switch ($type) {
|
||||
case 1:
|
||||
$where['label'] = $label;
|
||||
break;
|
||||
case 2:
|
||||
$where['label'] = 5;
|
||||
break;
|
||||
case 3:
|
||||
$where['type'] = 1;
|
||||
//爆币id
|
||||
$bb_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value');
|
||||
$where['gid'] = ['<>',$bb_gift_id];//拍卖位选礼物 不能是爆币这个礼物
|
||||
break;
|
||||
case 4:
|
||||
$where['type'] = 1;
|
||||
$where['gift_price'] = ['>',128];//歌单礼物价格要大于128 老板26年1月2号提的要求
|
||||
break;
|
||||
case 5:
|
||||
$where['type'] = 1;
|
||||
break;
|
||||
case 6:
|
||||
$where['type'] = 6;
|
||||
$where['label'] = $label;
|
||||
break;
|
||||
}
|
||||
$list = db::name('vs_gift')
|
||||
->field('gid as gift_id,gift_name,base_image,gift_price,icon')
|
||||
->where($where)->order('sort desc, gift_price asc')->select();
|
||||
|
||||
if($label==2){
|
||||
foreach ($list as &$v) {
|
||||
//获取盲盒列表
|
||||
$box_list = Db::name('vs_gift_bag')->where(['status'=>1])->where(['activities_id'=>["in",[4,5]]])->select();
|
||||
foreach ($box_list as $key =>$box) {
|
||||
$ext = json_decode($box['ext'],true);
|
||||
if ($ext['gift_id'] == $v['gift_id']) {
|
||||
$v['gift_bag_name'] = $box['name'];
|
||||
$v['rule'] = $ext['description'];
|
||||
$v['rule_url'] = get_system_config_value('web_site')."/api/Page/get_gift_box_rule?box_id=".$box["id"];
|
||||
$v['activities_id'] = $box['activities_id'];
|
||||
$v['gift_bag'] = $box['id'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
//爆币
|
||||
$pool_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value');
|
||||
if($pool_gift_id == $v['gift_id']){
|
||||
$v['gift_bag_name'] = "幸运币活动";
|
||||
$v['rule'] = "幸运羽币";
|
||||
$v['rule_url'] = get_system_config_value('web_site')."/api/Page/page_show?id=35";
|
||||
$v['activities_id'] = 88;
|
||||
$v['gift_bag'] = 0;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
foreach ($list as $key =>&$v) {
|
||||
$v['is_lock'] = $is_lock;
|
||||
if($label==14){ //酒吧房自定义礼物 自定义
|
||||
$gift_remark_name =db::name('vs_user_custom_gift')->where(['user_id' => $user_id,'gift_id'=>$v['gift_id'],'delete_time'=>0])->value('gift_remark_name');
|
||||
$v['gift_remark_name'] = $gift_remark_name ?? '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//================================到这里结束逻辑==================================
|
||||
if($label!=14) {//非自定义礼物走缓存
|
||||
//设置缓存
|
||||
Cache::set($cache_key, json_encode($list), 3600);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $list];
|
||||
}
|
||||
|
||||
|
||||
//自定义礼物设置
|
||||
public function set_custom_gift($user_id, $gift_id, $room_id, $gift_remark_name){
|
||||
$gift_info = db::name('vs_gift')->where(['gid' => $gift_id, 'delete_time' => 0, 'is_show' => 1])->find();
|
||||
if(!$gift_info){
|
||||
return ['code' => 0, 'msg' => '礼物不存在','data' =>null];
|
||||
}
|
||||
|
||||
$user_custom_gift = db::name('vs_user_custom_gift')->where(['user_id' => $user_id,'gift_id'=>$gift_id])->find();
|
||||
if($user_custom_gift){
|
||||
db::name('vs_user_custom_gift')->where(['id' => $user_custom_gift['id']])->update(['gift_remark_name'=>$gift_remark_name,'updatetime'=>time()]);
|
||||
}else{
|
||||
$res = db::name('vs_user_custom_gift')->insert([
|
||||
'user_id' => $user_id,
|
||||
'gift_id'=>$gift_id,
|
||||
'gift_remark_name'=>$gift_remark_name,
|
||||
'createtime'=>time()
|
||||
]);
|
||||
if(!$res){
|
||||
return ['code' => 0, 'msg' => '设置失败','data' =>null];
|
||||
}
|
||||
}
|
||||
|
||||
$user_custom_gift_count = db::name('vs_user_custom_gift')->where(['user_id' => $user_id,'gift_remark_name' => ['<>', '']])->count();
|
||||
|
||||
if($user_custom_gift_count == 0){
|
||||
$type = 0;//删除
|
||||
}else{
|
||||
$type = 1;
|
||||
}
|
||||
|
||||
if(!$room_id){
|
||||
$room_id = db::name('vs_room_visitor')->where(['user_id' => $user_id])->order('id desc')->value('room_id');
|
||||
}
|
||||
|
||||
$user_on_pit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $user_id])->value('pit_number');
|
||||
if($user_on_pit){
|
||||
$text['text'] = '设置自定义礼物';
|
||||
$text['type'] = $type;
|
||||
$text['user_id'] = $user_id;
|
||||
$text['pit_number'] = $user_on_pit;
|
||||
//聊天室推送系统消息
|
||||
model('api/Chat')->sendMsg(1203,$room_id,$text);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '设置成功','data' =>null];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//自定义礼物列表
|
||||
public function get_custom_gift_list($user_id){
|
||||
$list = db::name('vs_user_custom_gift')
|
||||
->alias('a')
|
||||
->join('vs_gift b','a.gift_id = b.gid')
|
||||
->field('a.id,b.gid as gift_id,a.gift_remark_name,b.gift_name,b.base_image,b.gift_price,b.icon')
|
||||
->where(['a.user_id' => $user_id,'a.delete_time'=>0,'a.gift_remark_name'=>['<>','']])
|
||||
->order('a.sort desc ,a.updatetime desc')
|
||||
->select();
|
||||
return ['code' => 1, 'msg' => '获取成功','data' =>$list];
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
468
application/api/model/GiveGiftBases.php
Normal file
468
application/api/model/GiveGiftBases.php
Normal file
@@ -0,0 +1,468 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use app\common\model\GiveGiftBase;
|
||||
use think\Cache;
|
||||
use think\Log;
|
||||
use think\Model;
|
||||
|
||||
class GiveGiftBases extends Model
|
||||
{
|
||||
|
||||
protected $giftModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->giftModel = new GiveGiftBase();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取送礼记录
|
||||
*/
|
||||
|
||||
public function getGiftRecords($params,$ext_params=[])
|
||||
{
|
||||
// $params = $this->request->param();
|
||||
|
||||
$where = [];
|
||||
$options = [];
|
||||
|
||||
// 构建查询条件
|
||||
if (!empty($params['from_id'])) {
|
||||
$where['from_id'] = $params['from_id'];
|
||||
}
|
||||
if (!empty($params['user_id'])) {
|
||||
$where['user_id'] = $params['user_id'];
|
||||
}
|
||||
if (!empty($params['gift_user'])) {
|
||||
$where['gift_user'] = $params['gift_user'];
|
||||
}
|
||||
if (!empty($params['gift_id'])) {
|
||||
$where['gift_id'] = $params['gift_id'];
|
||||
}
|
||||
if (!empty($params['type'])) {
|
||||
$where['type'] = $params['type'];
|
||||
}
|
||||
if (!empty($params['from'])) {
|
||||
$where['from'] = $params['from'];
|
||||
}
|
||||
if (!empty($params['gift_type'])) {
|
||||
$where['gift_type'] = $params['gift_type'];
|
||||
}
|
||||
|
||||
// 时间范围
|
||||
if (!empty($ext_params)) {
|
||||
if (!empty($ext_params['start_time'])) {
|
||||
$options['start_time'] = $ext_params['start_time'];
|
||||
}
|
||||
if (!empty($ext_params['end_time'])) {
|
||||
$options['end_time'] = $ext_params['end_time'];
|
||||
}
|
||||
}else{
|
||||
if (!empty($params['start_time'])) {
|
||||
$options['start_time'] = strtotime($params['start_time']);
|
||||
}
|
||||
if (!empty($params['end_time'])) {
|
||||
$options['end_time'] = strtotime($params['end_time'] . ' 23:59:59');
|
||||
}
|
||||
}
|
||||
|
||||
// 分页参数
|
||||
$options['page'] = $params['page'] ?? 1;
|
||||
$options['limit'] = min($params['limit'] ?? 20, 100); // 限制最大100条
|
||||
|
||||
// 排序
|
||||
if (!empty($params['order'])) {
|
||||
$options['order'] = $params['order'];
|
||||
}
|
||||
|
||||
// 查询数据
|
||||
$result = $this->giftModel->getGiftRecords($where, $options);
|
||||
|
||||
Log::info("查询送礼记录,条件: " . json_encode($where) . ", 结果数: " . count($result['data']));
|
||||
|
||||
// $this->success('获取成功', $result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 房间送礼统计
|
||||
*/
|
||||
public function getRoomStatistics($params)
|
||||
{
|
||||
$fromId = $this->request->param('from_id/d', 0);
|
||||
$startTime = $this->request->param('start_time/d', strtotime('-7 days'));
|
||||
$endTime = $this->request->param('end_time/d', time());
|
||||
|
||||
if (!$fromId) {
|
||||
$this->error('房间ID不能为空');
|
||||
}
|
||||
|
||||
// 尝试从缓存获取
|
||||
$cacheKey = "gift:room:stats:{$fromId}:" . date('Ymd', $startTime) . '-' . date('Ymd', $endTime);
|
||||
$cachedData = Cache::get($cacheKey);
|
||||
|
||||
if ($cachedData !== false) {
|
||||
Log::info("从缓存获取房间统计: {$cacheKey}");
|
||||
$this->success('获取成功', $cachedData);
|
||||
}
|
||||
|
||||
$where = ['from_id' => $fromId];
|
||||
$options = [
|
||||
'start_time' => $startTime,
|
||||
'end_time' => $endTime,
|
||||
];
|
||||
|
||||
// 统计房间总数据
|
||||
$totalStats = $this->giftModel->getGiftStatistics($where, $options);
|
||||
|
||||
// 按送礼人分组统计
|
||||
$userStats = $this->giftModel->getGiftStatistics($where, array_merge($options, [
|
||||
'group_by' => 'user_id'
|
||||
]));
|
||||
|
||||
// 按收礼人分组统计
|
||||
$receiverStats = $this->giftModel->getGiftStatistics($where, array_merge($options, [
|
||||
'group_by' => 'gift_user'
|
||||
]));
|
||||
|
||||
$result = [
|
||||
'room_id' => $fromId,
|
||||
'time_range' => [
|
||||
'start_time' => $startTime,
|
||||
'end_time' => $endTime,
|
||||
'start_date' => date('Y-m-d H:i:s', $startTime),
|
||||
'end_date' => date('Y-m-d H:i:s', $endTime),
|
||||
],
|
||||
'total_stats' => $totalStats,
|
||||
'user_stats' => $userStats,
|
||||
'receiver_stats' => $receiverStats,
|
||||
];
|
||||
|
||||
// 缓存5分钟
|
||||
Cache::set($cacheKey, $result, 300);
|
||||
|
||||
Log::info("房间统计计算完成: {$fromId}, 送礼人数: " . count($userStats) . ", 收礼人数: " . count($receiverStats));
|
||||
|
||||
$this->success('获取成功', $result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用户送礼统计
|
||||
*/
|
||||
public function getUserStatistics($params,$type)
|
||||
{
|
||||
if($type==1){
|
||||
$userId = $params['user_id'];
|
||||
}else{
|
||||
$userId = $params['gift_user'];
|
||||
}
|
||||
|
||||
$startTime = $params['start_time'];
|
||||
$endTime = $params['end_time'];
|
||||
|
||||
if (!$userId) {
|
||||
return ['code'=>0,'msg'=>'用户ID不能为空','data'=>null];
|
||||
}
|
||||
|
||||
if($type==1){
|
||||
$where = ['user_id' => $userId];
|
||||
}else{
|
||||
$where = ['gift_user' => $userId];
|
||||
}
|
||||
|
||||
$options = [
|
||||
'start_time' => $startTime,
|
||||
'end_time' => $endTime,
|
||||
];
|
||||
|
||||
// 用户总送礼统计
|
||||
$totalStats = $this->giftModel->getGiftStatistics($where, $options);
|
||||
|
||||
// 按房间分组统计
|
||||
$roomStats = $this->giftModel->getGiftStatistics($where, array_merge($options, [
|
||||
'group_by' => 'from_id'
|
||||
]));
|
||||
|
||||
// 按收礼人分组统计
|
||||
$receiverStats = $this->giftModel->getGiftStatistics($where, array_merge($options, [
|
||||
'group_by' => 'gift_user'
|
||||
]));
|
||||
|
||||
$result = [
|
||||
'user_id' => $userId,
|
||||
'time_range' => [
|
||||
'start_time' => $startTime,
|
||||
'end_time' => $endTime,
|
||||
'start_date' => date('Y-m-d H:i:s', $startTime),
|
||||
'end_date' => date('Y-m-d H:i:s', $endTime),
|
||||
],
|
||||
'total_stats' => $totalStats,
|
||||
'room_stats' => $roomStats,
|
||||
'receiver_stats' => $receiverStats,
|
||||
];
|
||||
|
||||
// 缓存5分钟
|
||||
// Cache::set($cacheKey, $result, 300);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 收礼统计
|
||||
*/
|
||||
public function getReceiveStatistics()
|
||||
{
|
||||
$giftUser = $this->request->param('gift_user/d', 0);
|
||||
$startTime = $this->request->param('start_time/d', strtotime('-30 days'));
|
||||
$endTime = $this->request->param('end_time/d', time());
|
||||
|
||||
if (!$giftUser) {
|
||||
$this->error('用户ID不能为空');
|
||||
}
|
||||
|
||||
$cacheKey = "gift:receive:stats:{$giftUser}:" . date('Ymd', $startTime) . '-' . date('Ymd', $endTime);
|
||||
$cachedData = Cache::get($cacheKey);
|
||||
|
||||
if ($cachedData !== false) {
|
||||
Log::info("从缓存获取收礼统计: {$cacheKey}");
|
||||
$this->success('获取成功', $cachedData);
|
||||
}
|
||||
|
||||
$where = ['gift_user' => $giftUser];
|
||||
$options = [
|
||||
'start_time' => $startTime,
|
||||
'end_time' => $endTime,
|
||||
];
|
||||
|
||||
// 总收礼统计
|
||||
$totalStats = $this->giftModel->getGiftStatistics($where, $options);
|
||||
|
||||
// 按房间分组统计
|
||||
$roomStats = $this->giftModel->getGiftStatistics($where, array_merge($options, [
|
||||
'group_by' => 'from_id'
|
||||
]));
|
||||
|
||||
// 按送礼人分组统计
|
||||
$giverStats = $this->giftModel->getGiftStatistics($where, array_merge($options, [
|
||||
'group_by' => 'user_id'
|
||||
]));
|
||||
|
||||
$result = [
|
||||
'gift_user' => $giftUser,
|
||||
'time_range' => [
|
||||
'start_time' => $startTime,
|
||||
'end_time' => $endTime,
|
||||
'start_date' => date('Y-m-d H:i:s', $startTime),
|
||||
'end_date' => date('Y-m-d H:i:s', $endTime),
|
||||
],
|
||||
'total_stats' => $totalStats,
|
||||
'room_stats' => $roomStats,
|
||||
'giver_stats' => $giverStats,
|
||||
];
|
||||
|
||||
// 缓存5分钟
|
||||
Cache::set($cacheKey, $result, 300);
|
||||
|
||||
Log::info("收礼统计计算完成: {$giftUser}, 房间数: " . count($roomStats) . ", 送礼人数: " . count($giverStats));
|
||||
|
||||
$this->success('获取成功', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取送礼趋势
|
||||
*/
|
||||
public function getGiftTrend()
|
||||
{
|
||||
$params = $this->request->param();
|
||||
|
||||
$startTime = $params['start_time'] ?? strtotime('-7 days');
|
||||
$endTime = $params['end_time'] ?? time();
|
||||
$interval = $params['interval'] ?? 'day';
|
||||
|
||||
if (!in_array($interval, ['day', 'week', 'month'])) {
|
||||
$interval = 'day';
|
||||
}
|
||||
|
||||
$cacheKey = "gift:trend:" . date('Ymd', $startTime) . '-' . date('Ymd', $endTime) . ":{$interval}";
|
||||
$cachedData = Cache::get($cacheKey);
|
||||
|
||||
if ($cachedData !== false) {
|
||||
$this->success('获取成功', $cachedData);
|
||||
}
|
||||
|
||||
$trendData = $this->giftModel->getTrendStatistics($startTime, $endTime, $interval);
|
||||
|
||||
// 缓存10分钟
|
||||
Cache::set($cacheKey, $trendData, 600);
|
||||
|
||||
$this->success('获取成功', [
|
||||
'trend_data' => $trendData,
|
||||
'interval' => $interval,
|
||||
'time_range' => [
|
||||
'start_time' => $startTime,
|
||||
'end_time' => $endTime
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function getGiftList()
|
||||
{
|
||||
$params = $this->request->param();
|
||||
|
||||
$where = [];
|
||||
$options = [];
|
||||
|
||||
// 构建查询条件
|
||||
$searchFields = ['from_id', 'user_id', 'gift_user', 'gift_id', 'type', 'from', 'gift_type'];
|
||||
foreach ($searchFields as $field) {
|
||||
if (!empty($params[$field])) {
|
||||
$where[$field] = $params[$field];
|
||||
}
|
||||
}
|
||||
|
||||
// 时间范围
|
||||
if (!empty($params['start_time'])) {
|
||||
$options['start_time'] = strtotime($params['start_time']);
|
||||
}
|
||||
if (!empty($params['end_time'])) {
|
||||
$options['end_time'] = strtotime($params['end_time']);
|
||||
}
|
||||
|
||||
// 搜索关键词
|
||||
if (!empty($params['search'])) {
|
||||
// 可以扩展搜索逻辑
|
||||
}
|
||||
|
||||
// 分页参数
|
||||
$options['page'] = $params['page'] ?? 1;
|
||||
$options['limit'] = $params['limit'] ?? $this->pageSize;
|
||||
|
||||
// 查询数据
|
||||
$result = $this->giftModel->getGiftRecords($where, $options);
|
||||
|
||||
// 转换时间格式
|
||||
foreach ($result['data'] as &$item) {
|
||||
$item['createtime_text'] = $item['createtime'] ? date('Y-m-d H:i:s', $item['createtime']) : '';
|
||||
$item['updatetime_text'] = $item['updatetime'] ? date('Y-m-d H:i:s', $item['updatetime']) : '';
|
||||
}
|
||||
|
||||
$total = $result['total'];
|
||||
$data = $result['data'];
|
||||
$result = array("total" => $total, "rows" => $data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取送礼排行
|
||||
*/
|
||||
|
||||
public function getGiftRanking($params,$type)
|
||||
{
|
||||
$where = [];
|
||||
$options = [];
|
||||
|
||||
// 时间范围
|
||||
if (!empty($params['start_time'])) {
|
||||
$options['start_time'] = $params['start_time'];
|
||||
}
|
||||
if (!empty($params['end_time'])) {
|
||||
$options['end_time'] = $params['end_time'];
|
||||
}
|
||||
|
||||
// 分页参数
|
||||
$options['page'] = $params['page'] ?? 1;
|
||||
$options['limit'] = min($params['limit'] ?? 20, 100); // 限制最大100条
|
||||
|
||||
if($type == 1){
|
||||
$options['group_by'] = 'user_id';
|
||||
}else{
|
||||
$options['group_by'] = 'gift_user';
|
||||
}
|
||||
|
||||
|
||||
// 查询数据
|
||||
$result = $this->giftModel->getGiftStatisticsRanking($where, $options);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计收礼用户 的送礼用户的分组和
|
||||
*/
|
||||
|
||||
public function getToUserStatistics($params)
|
||||
{
|
||||
$where = [];
|
||||
$options = [];
|
||||
|
||||
// 时间范围
|
||||
if (!empty($params['start_time'])) {
|
||||
$options['start_time'] = $params['start_time'];
|
||||
}
|
||||
if (!empty($params['end_time'])) {
|
||||
$options['end_time'] = $params['end_time'];
|
||||
}
|
||||
if (!empty($params['from_id'])) {
|
||||
$where['from_id'] = $params['from_id'];
|
||||
}
|
||||
if (!empty($params['gift_user'])) {
|
||||
$where['gift_user'] = $params['gift_user'];
|
||||
}
|
||||
|
||||
// 分页参数
|
||||
$options['page'] = $params['page'] ?? 1;
|
||||
$options['limit'] = min($params['limit'] ?? 20, 100); // 限制最大100条
|
||||
|
||||
$options['group_by'] = 'user_id';
|
||||
|
||||
// 查询数据
|
||||
$result = $this->giftModel->getToUserStatistics($where, $options);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取房间内送礼排行
|
||||
*/
|
||||
|
||||
public function getRoomGiftRanking($params,$type)
|
||||
{
|
||||
$where = [];
|
||||
$options = [];
|
||||
|
||||
// 时间范围
|
||||
if (!empty($params['start_time'])) {
|
||||
$options['start_time'] = $params['start_time'];
|
||||
}
|
||||
if (!empty($params['end_time'])) {
|
||||
$options['end_time'] = $params['end_time'];
|
||||
}
|
||||
// 构建查询条件
|
||||
if (!empty($params['from_id'])) {
|
||||
$where['from_id'] = $params['from_id'];
|
||||
}
|
||||
|
||||
// 分页参数
|
||||
$options['page'] = $params['page'] ?? 1;
|
||||
$options['limit'] = min($params['limit'] ?? 20, 100); // 限制最大100条
|
||||
|
||||
if($type == 1){
|
||||
$options['group_by'] = 'user_id';
|
||||
}else{
|
||||
$options['group_by'] = 'gift_user';
|
||||
}
|
||||
|
||||
|
||||
// 查询数据
|
||||
$result = $this->giftModel->getGiftStatisticsRanking($where, $options);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -117,12 +117,14 @@ class Guild extends Model
|
||||
*/
|
||||
public function join_guild_apply($guild_id,$user_id=0)
|
||||
{
|
||||
$user_info = model('User')->get_user_info($user_id);
|
||||
if(!$user_info){
|
||||
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
|
||||
}
|
||||
if($user_info['is_real']!=1 || empty($user_info['card_id'])){
|
||||
return ['code' => 0, 'msg' => '请先实名认证', 'data' => null];
|
||||
//查询是否实名认证
|
||||
$is_real = model('api/UserData')->real_name_info($user_id);
|
||||
if($is_real['code']==0){
|
||||
return ['code' => 0, 'msg' => '请先实名认证','data' => null];
|
||||
}else{
|
||||
if($is_real['data']['is_real'] !=1){
|
||||
return ['code' => 0, 'msg' => '请先实名认证','data' => null];
|
||||
}
|
||||
}
|
||||
//公会是否存在
|
||||
$guild_info = db::name('vs_guild')->where(['id'=>$guild_id,'delete_time'=>0])->find();
|
||||
@@ -166,7 +168,7 @@ class Guild extends Model
|
||||
}
|
||||
//是否有房间
|
||||
$rid = 0;
|
||||
$room_info = db::name('vs_room')->where('user_id', $user_id)->find();
|
||||
$room_info = db::name('vs_room')->where(['user_id'=>$user_id,'delete_time'=>0,'type_id'=>['<>',6]])->find();
|
||||
if($room_info){
|
||||
$rid = $room_info['id'];
|
||||
}
|
||||
@@ -184,8 +186,8 @@ class Guild extends Model
|
||||
//增加公会人数
|
||||
db::name('vs_guild')->where('id', $guild_info['id'])->setInc('num', 1);
|
||||
//拉用户进入工会群聊
|
||||
// model('Tencent')->add_group_member('g'.$guild_id, $user_id);
|
||||
// model('Tencent')->send_group_system_notification('g'.$guild_id,"欢迎".$user_info['nickname'].'加入公会');
|
||||
// model('api/Tencent')->add_group_member('g'.$guild_id, $user_id);
|
||||
// model('api/Tencent')->send_group_system_notification('g'.$guild_id,"欢迎".$user_info['nickname'].'加入公会');
|
||||
|
||||
return ['code' => 1, 'msg' => '提交成功', 'data' => null];
|
||||
}else{
|
||||
@@ -291,8 +293,13 @@ class Guild extends Model
|
||||
db::name('vs_guild')->where('id', $guild_info['id'])->setInc('num', 1);
|
||||
//拉用户进入工会群聊
|
||||
$user_nickname = db::name('user')->where('id', $is_operate['user_id'])->value('nickname');
|
||||
model('api/Tencent')->add_group_member('g'.$is_operate['guild_id'], $is_operate['user_id']);
|
||||
model('api/Tencent')->send_group_system_notification('g'.$is_operate['guild_id'],"欢迎".$user_nickname.'加入公会');
|
||||
if($is_operate['guild_id']<=95){ //事故处理-114以前的群被删了
|
||||
$guild_id = "g".$is_operate['guild_id'];
|
||||
}else{
|
||||
$guild_id = $is_operate['guild_id'];
|
||||
}
|
||||
model('api/Tencent')->add_group_member('g'.$guild_id, $is_operate['user_id']);
|
||||
model('api/Tencent')->send_group_system_notification('g'.$guild_id,"欢迎".$user_nickname.'加入公会');
|
||||
//发系统信息
|
||||
$content = "恭喜加入{$guild_info['guild_name']}工会,您的个人收益增加{$ratiog}%,目前总收益{$ratio}%";
|
||||
model('api/UserMessage')->send_system_message($is_operate['user_id'], "加入公会成功通知", $content, 1);
|
||||
@@ -357,7 +364,7 @@ class Guild extends Model
|
||||
if($reslut){
|
||||
//减少公会人数
|
||||
db::name('vs_guild')->where('id', $guild_info['id'])->setDec('num');
|
||||
model('Tencent')->delete_group_member('g'.$guild_id, $user_id);
|
||||
model('api/Tencent')->delete_group_member('g'.$guild_id, $user_id);
|
||||
return ['code' => 1, 'msg' => '踢出成功','data' => null];
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => '踢出失败','data' => null];
|
||||
@@ -366,6 +373,9 @@ class Guild extends Model
|
||||
|
||||
//退出公会
|
||||
public function quit_guild($uid, $guild_id,$type){
|
||||
//去除字符里的g
|
||||
$guild_id = str_replace('g', '', $guild_id);
|
||||
$guild_id = intval($guild_id);
|
||||
$config = get_system_config();
|
||||
$user_info = db::name('user')->find($uid);
|
||||
if(!$user_info){
|
||||
@@ -429,7 +439,16 @@ class Guild extends Model
|
||||
}
|
||||
//减少公会人数
|
||||
db::name('vs_guild')->where('id', $guild_info['id'])->setDec('num');
|
||||
model('Tencent')->delete_group_member('g'.$guild_id, $uid);
|
||||
if($guild_info['id']<=95){
|
||||
$guild_id = "g".$guild_info['id'];
|
||||
}else{
|
||||
$guild_id = $guild_info['id'];
|
||||
}
|
||||
model('api/Tencent')->delete_group_member('g'.$guild_id, $uid);
|
||||
|
||||
//付费退出费用给公会长
|
||||
$res = model('common/UserWallet')->change_user_money($guild_info['user_id'], $quit_guild_gold, model('common/UserWallet')::MONEYTYPECOIN, model('common/UserWallet')::GUILD_EXIT_DEACON_INCOME,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::GUILD_EXIT_DEACON_INCOME));
|
||||
|
||||
Db::commit();
|
||||
return ['code' => 1, 'msg' => '退出成功', 'data' => null];
|
||||
}else{
|
||||
@@ -536,8 +555,13 @@ class Guild extends Model
|
||||
return ['code' => 0, 'msg' => '审核失败', 'data' => null];
|
||||
}
|
||||
//减少公会人数
|
||||
db::name('vs_guild')->where('id', $apply_id)->setDec('num');
|
||||
model('Tencent')->delete_group_member('g'.$apply_id, $apply_info['user_id']);
|
||||
db::name('vs_guild')->where('id', $apply_info['guild_id'])->setDec('num');
|
||||
if($apply_info['guild_id']['id']<=95){
|
||||
$guild_id = "g".$apply_info['guild_id']['id'];
|
||||
}else{
|
||||
$guild_id = $apply_info['guild_id']['id'];
|
||||
}
|
||||
model('api/Tencent')->delete_group_member('g'.$guild_id, $apply_info['user_id']);
|
||||
} else {
|
||||
$update_data = [];
|
||||
$update_data['status'] = 2;
|
||||
@@ -570,7 +594,12 @@ class Guild extends Model
|
||||
//解散公会
|
||||
db::name('vs_guild')->where('id',$guild_id)->update(['delete_time'=>time(),'status'=>2]);
|
||||
//解散群
|
||||
model('Tencent')->delete_group('g'.$guild_id);
|
||||
if($guild_id<=95){
|
||||
$guild_id = "g".$guild_id;
|
||||
}else{
|
||||
$guild_id = $guild_id;
|
||||
}
|
||||
model('api/Tencent')->delete_group('g'.$guild_id);
|
||||
Db::commit();
|
||||
return ['code' => 1, 'msg' => '解散成功!', 'data' => null];
|
||||
}catch (\Exception $e) {
|
||||
@@ -666,25 +695,29 @@ class Guild extends Model
|
||||
//本周流水
|
||||
//本周的第一天
|
||||
$week = strtotime(date('Y-m-d 00:00:00', strtotime('this week Monday')));
|
||||
$guild_user = db::name('vs_guild_user')->where(['guild_id' => $guild_id])->select();
|
||||
$transaction = 0;
|
||||
foreach ($guild_user as $k => $v){
|
||||
$week_start_time_seach = $week;
|
||||
$week_end_time_seach = time();
|
||||
if($v['createtime'] && $week_start_time_seach < $v['createtime']){
|
||||
$week_start_time_seach = $v['createtime'];
|
||||
}
|
||||
if($v['quit_time'] && ($week_end_time_seach > $v['quit_time'])){
|
||||
$week_end_time_seach = $v['quit_time'];
|
||||
}
|
||||
$transaction_one = db::name('vs_give_gift')
|
||||
->whereIn('from_id',$v['room_id'])
|
||||
->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$week_start_time_seach, $week_end_time_seach]]])
|
||||
->sum('total_price');
|
||||
$transaction += $transaction_one;
|
||||
|
||||
}
|
||||
$total_transaction = $transaction;
|
||||
// $guild_user = db::name('vs_guild_user')->where(['guild_id' => $guild_id])->select();
|
||||
// $transaction = 0;
|
||||
// foreach ($guild_user as $k => $v){
|
||||
// $week_start_time_seach = $week;
|
||||
// $week_end_time_seach = time();
|
||||
// if($v['createtime'] && $week_start_time_seach < $v['createtime']){
|
||||
// $week_start_time_seach = $v['createtime'];
|
||||
// }
|
||||
// if($v['quit_time'] && ($week_end_time_seach > $v['quit_time'])){
|
||||
// $week_end_time_seach = $v['quit_time'];
|
||||
// }
|
||||
// $transaction_one = db::name('vs_give_gift')
|
||||
// ->whereIn('from_id',$v['room_id'])
|
||||
// ->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$week_start_time_seach, $week_end_time_seach]]])
|
||||
// ->sum('total_price');
|
||||
// $transaction += $transaction_one;
|
||||
//
|
||||
// }
|
||||
// $total_transaction = $transaction;
|
||||
$total_transaction = db::name('vs_guild_flow')
|
||||
->where(['guild_id' => $guild_id])
|
||||
->where(['createtime' => ['between', [$week, time()]]])
|
||||
->sum('flow_price');
|
||||
$ss = 0;
|
||||
if($total_transaction){
|
||||
//根据工会流水 获取补贴比例 单位%
|
||||
@@ -807,30 +840,31 @@ class Guild extends Model
|
||||
return ['code' => 0, 'msg' => '公会不存在!', 'data' => null];
|
||||
}
|
||||
//工会总流水
|
||||
$all_guild_room = db::name('vs_guild_user')->where(['guild_id' => $guild_id,'status'=>1,"delete_time"=>0])->select();
|
||||
$total_transaction = 0;
|
||||
foreach ($all_guild_room as $key => $value) {
|
||||
$start_time = $seach_start_time;
|
||||
$end_time = $seach_end_time;
|
||||
if(!$start_time){
|
||||
$start_time_all = $value['createtime'];
|
||||
$end_time_all = time();
|
||||
}else{
|
||||
$start_time_all = strtotime($start_time." 00:00:00");
|
||||
$end_time_all = strtotime($end_time." 23:59:59");
|
||||
}
|
||||
if($value['createtime'] && $start_time_all < $value['createtime']){
|
||||
$start_time_all = $value['createtime'];
|
||||
}
|
||||
if($value['quit_time'] && ($end_time_all > $value['quit_time'])){
|
||||
$end_time_all = $value['quit_time'];
|
||||
}
|
||||
$transaction = db::name('vs_give_gift')
|
||||
->where('from_id',$value['room_id'])
|
||||
->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$start_time_all, $end_time_all]]])
|
||||
->sum('total_price');
|
||||
$total_transaction = $total_transaction+$transaction;
|
||||
}
|
||||
// $all_guild_room = db::name('vs_guild_user')->where(['guild_id' => $guild_id,'status'=>1,"delete_time"=>0])->select();
|
||||
// $total_transaction = 0;
|
||||
// foreach ($all_guild_room as $key => $value) {
|
||||
// $start_time = $seach_start_time;
|
||||
// $end_time = $seach_end_time;
|
||||
// if(!$start_time){
|
||||
// $start_time_all = $value['createtime'];
|
||||
// $end_time_all = time();
|
||||
// }else{
|
||||
// $start_time_all = strtotime($start_time." 00:00:00");
|
||||
// $end_time_all = strtotime($end_time." 23:59:59");
|
||||
// }
|
||||
// if($value['createtime'] && $start_time_all < $value['createtime']){
|
||||
// $start_time_all = $value['createtime'];
|
||||
// }
|
||||
// if($value['quit_time'] && ($end_time_all > $value['quit_time'])){
|
||||
// $end_time_all = $value['quit_time'];
|
||||
// }
|
||||
// $transaction = db::name('vs_give_gift')
|
||||
// ->where('from_id',$value['room_id'])
|
||||
// ->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$start_time_all, $end_time_all]]])
|
||||
// ->sum('total_price');
|
||||
// $total_transaction = $total_transaction+$transaction;
|
||||
// }
|
||||
|
||||
//查询工会所有房间流水
|
||||
$list = db::name('vs_guild_user')->where(['guild_id'=>$guild_id,'delete_time'=>0,'status'=>1,'room_id'=>['<>',0]])
|
||||
->order('id asc')
|
||||
@@ -841,31 +875,31 @@ class Guild extends Model
|
||||
$room_data = [];
|
||||
$i=0;
|
||||
foreach ($list as $k=>$v){
|
||||
$start_time = $seach_start_time;
|
||||
$end_time = $seach_end_time;
|
||||
if(!$start_time){
|
||||
$start_time_seach = $value['createtime'];
|
||||
$end_time_seach = time();
|
||||
}else{
|
||||
$start_time_seach = strtotime($start_time." 00:00:00");
|
||||
$end_time_seach = strtotime($end_time." 23:59:59");
|
||||
}
|
||||
if($value['createtime'] && $start_time_all < $value['createtime']){
|
||||
$start_time_seach = $value['createtime'];
|
||||
}
|
||||
if($value['quit_time'] && ($end_time_all > $value['quit_time'])){
|
||||
$end_time_seach = $value['quit_time'];
|
||||
}
|
||||
// $start_time = $seach_start_time;
|
||||
// $end_time = $seach_end_time;
|
||||
// if(!$start_time){
|
||||
// $start_time_seach = $value['createtime'];
|
||||
// $end_time_seach = time();
|
||||
// }else{
|
||||
// $start_time_seach = strtotime($start_time." 00:00:00");
|
||||
// $end_time_seach = strtotime($end_time." 23:59:59");
|
||||
// }
|
||||
// if($value['createtime'] && $start_time_all < $value['createtime']){
|
||||
// $start_time_seach = $value['createtime'];
|
||||
// }
|
||||
// if($value['quit_time'] && ($end_time_all > $value['quit_time'])){
|
||||
// $end_time_seach = $value['quit_time'];
|
||||
// }
|
||||
$room_info = db::name('vs_room')->where(['id'=>$v['room_id'],'room_status'=>1,'delete_time'=>0])->find();
|
||||
if($room_info){
|
||||
$room_data[$i]['room_id'] = $room_info['id'];
|
||||
$room_data[$i]['room_number'] = model('Decorate')->user_decorate_detail($room_info['id'],7);
|
||||
$room_data[$i]['room_name'] = $room_info['room_name'];
|
||||
$room_data[$i]['room_cover'] = localpath_to_netpath($room_info['room_cover']);
|
||||
$room_data[$i]['total_price'] = db::name('vs_give_gift')
|
||||
->where('from_id',$v['room_id'])
|
||||
->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$start_time_seach, $end_time_seach]]])
|
||||
->sum('total_price');
|
||||
$room_data[$i]['total_price'] = db::name('vs_guild_flow')
|
||||
->where('room_id',$v['room_id'])
|
||||
->where(['createtime' => ['between', [$seach_start_time, $seach_end_time]]])
|
||||
->sum('flow_price');
|
||||
$i++;
|
||||
}
|
||||
|
||||
@@ -875,7 +909,7 @@ class Guild extends Model
|
||||
'page' => $page,
|
||||
'limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'total_transaction' => $total_transaction ? $total_transaction : 0,
|
||||
'total_transaction' => $guild_info['income'] ? $guild_info['income'] : 0,
|
||||
'list' => $room_data,
|
||||
];
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $return_data];
|
||||
@@ -888,7 +922,7 @@ class Guild extends Model
|
||||
* @return array
|
||||
*/
|
||||
public function user_is_join($user_id){
|
||||
$guild = Db::name('vs_guild_user')->where(['user_id'=>$user_id,'delete_time'=>0])->find();
|
||||
$guild = Db::name('vs_guild_user')->where(['user_id'=>$user_id,'delete_time'=>0])->order('id desc,apply_time desc')->find();
|
||||
if(empty($guild)){
|
||||
return 0;
|
||||
}else{
|
||||
@@ -904,20 +938,40 @@ class Guild extends Model
|
||||
/*
|
||||
* 获取公会成员列表
|
||||
*/
|
||||
public function get_guild_user_list($guild_ids,$user_id,$page=1,$page_limit=30){
|
||||
public function get_guild_user_list($guild_ids,$user_id,$page=1,$page_limit=30,$seach=""){
|
||||
//获取$guild_id的第一个字母
|
||||
$guild_id_first_letter = substr($guild_ids, 0, 1);
|
||||
$guild_id = substr($guild_ids, 1);
|
||||
|
||||
if (substr($guild_ids, 0, 2) === 'gg') {
|
||||
$guild_id = substr($guild_ids, 2);
|
||||
|
||||
} elseif (substr($guild_ids, 0, 1) === 'g') {
|
||||
$guild_id = substr($guild_ids, 1);
|
||||
|
||||
} else {
|
||||
$guild_id = substr($guild_ids, 1);
|
||||
}
|
||||
|
||||
$seach_where = [];
|
||||
if($seach){
|
||||
if(is_numeric($seach)){
|
||||
$seach_where = ['b.user_code' => ['like', $seach . '%']];
|
||||
}else{
|
||||
$seach_where = ['b.nickname' => ['like', '%' . $seach . '%']];
|
||||
}
|
||||
}
|
||||
if($guild_id_first_letter == 'g'){
|
||||
$count = Db::name('vs_guild_user')
|
||||
->alias('a')
|
||||
->join('user b','a.user_id = b.id')
|
||||
->where($seach_where)
|
||||
->where(['a.guild_id'=>$guild_id,'a.status'=>1,'a.delete_time'=>0])
|
||||
->count();
|
||||
$list = Db::name('vs_guild_user')
|
||||
->alias('a')
|
||||
->join('user b', 'a.user_id = b.id')
|
||||
->field('a.id, a.user_id, a.guild_id, b.nickname, b.avatar, b.user_code, a.createtime')
|
||||
->where($seach_where)
|
||||
->where(['a.guild_id' => $guild_id, 'a.status' => 1,'a.delete_time' => 0])
|
||||
->order('a.id asc')
|
||||
->page($page, $page_limit)
|
||||
@@ -927,6 +981,7 @@ class Guild extends Model
|
||||
$list = db::name('vs_family')->alias('a')
|
||||
->join('user b','a.user_id = b.id')
|
||||
->field('b.is_online,b.market_value,b.nickname,b.avatar,b.user_code,a.user_id,a.createtime')
|
||||
->where($seach_where)
|
||||
->where(['a.pid' => $myFamilyPid,'a.deletetime' => 0,'a.type' => 0])
|
||||
->order('a.id asc')
|
||||
->page($page, $page_limit)
|
||||
@@ -934,6 +989,7 @@ class Guild extends Model
|
||||
|
||||
$count = db::name('vs_family')->alias('a')
|
||||
->join('user b','a.user_id = b.id')
|
||||
->where($seach_where)
|
||||
->where(['a.pid' => $myFamilyPid,'a.deletetime' => 0,'a.type' => 0])
|
||||
->count();
|
||||
}
|
||||
@@ -943,7 +999,7 @@ class Guild extends Model
|
||||
foreach ($member_array as $k=> $v){
|
||||
$member_array_str[] = 'u' . $v;
|
||||
}
|
||||
$group_member_info = model('Tencent')->get_group_member_info($guild_ids,$member_array_str);
|
||||
$group_member_info = model('api/Tencent')->get_group_member_info($guild_ids,$member_array_str);
|
||||
if($group_member_info['code'] == 0){
|
||||
return V($group_member_info['code'],$group_member_info['msg'], $group_member_info['data']);
|
||||
}
|
||||
@@ -958,6 +1014,12 @@ class Guild extends Model
|
||||
'Member'=>'普通群成员',
|
||||
'NotMember'=>'非群成员'
|
||||
];
|
||||
//禁言用户列表
|
||||
$mute_list = model('api/Tencent')->get_group_mute_list($guild_ids);
|
||||
$mute_user_list = [];
|
||||
if($mute_list['code'] == 1){
|
||||
$mute_user_list = array_column($mute_list['data'], 'Member_Account');
|
||||
}
|
||||
foreach ($list as $key => $value) {
|
||||
if($user_id == $value['user_id']){
|
||||
$list[$key]['is_self'] = 1;
|
||||
@@ -977,6 +1039,12 @@ class Guild extends Model
|
||||
->where(['a.user_id' => $value['user_id'], 'a.is_delete' => 1])
|
||||
->find();
|
||||
$list[$key]['in_room_id'] = $in_room['room_id'] ?? 0;
|
||||
//用户是否被禁言
|
||||
if(in_array('u'.$value['user_id'], $mute_user_list)){
|
||||
$list[$key]['is_mute'] = 1;
|
||||
}else{
|
||||
$list[$key]['is_mute'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -997,18 +1065,38 @@ class Guild extends Model
|
||||
if(!$guild_ids){
|
||||
return ['code' => 0, 'msg' => '参数错误'];
|
||||
}
|
||||
//获取$guild_id的第一个字母
|
||||
$guild_id_first_letter = substr($guild_ids, 0, 1);
|
||||
$guild_id = substr($guild_ids, 1);
|
||||
if($guild_id_first_letter == 'g'){
|
||||
if (substr($guild_ids, 0, 2) === 'gg') {
|
||||
$guild_id = substr($guild_ids, 2);
|
||||
$guild_info = db::name('vs_guild')->where(['id'=>$guild_id,'status'=>1,'delete_time'=>0])->find();
|
||||
$cover = $guild_info['cover'] ?? "";
|
||||
}else{
|
||||
} elseif (substr($guild_ids, 0, 1) === 'g') {
|
||||
$guild_id = substr($guild_ids, 1);
|
||||
$guild_info = db::name('vs_guild')->where(['id'=>$guild_id,'status'=>1,'delete_time'=>0])->find();
|
||||
$cover = $guild_info['cover'] ?? "";
|
||||
} else {
|
||||
$guild_id = substr($guild_ids, 1);
|
||||
$guild_info = db::name('vs_family')->where(['id'=>$guild_id])->find();
|
||||
$cover = db::name('user')->where(['id'=>$guild_info['user_id']])->value('avatar');
|
||||
}
|
||||
//获取字符串里有几个g
|
||||
// $guild_id_count = substr_count($guild_ids, 'g');
|
||||
// $guild_id_first_letter = substr($guild_ids, 0, 1);
|
||||
// if($guild_id_count == 2){
|
||||
// //获取$guild_id的第一个字母
|
||||
// $guild_id = substr($guild_ids, 2);
|
||||
// }else{
|
||||
// //获取$guild_id的第一个字母
|
||||
// $guild_id = substr($guild_ids, 1);
|
||||
// }
|
||||
// if($guild_id_first_letter == 'g'){
|
||||
// $guild_info = db::name('vs_guild')->where(['id'=>$guild_id,'status'=>1,'delete_time'=>0])->find();
|
||||
// $cover = $guild_info['cover'] ?? "";
|
||||
// }else{
|
||||
// $guild_info = db::name('vs_family')->where(['id'=>$guild_id])->find();
|
||||
// $cover = db::name('user')->where(['id'=>$guild_info['user_id']])->value('avatar');
|
||||
// }
|
||||
|
||||
$group_member_info = model('Tencent')->get_group_info($guild_ids);
|
||||
$group_member_info = model('api/Tencent')->get_group_info($guild_ids);
|
||||
if($group_member_info['code']!=1){
|
||||
return ['code' => 0, 'msg' => '群聊不存在',null];
|
||||
}
|
||||
@@ -1023,7 +1111,8 @@ class Guild extends Model
|
||||
'is_deacon' => $is_deacon,
|
||||
'user_list' => $user_list['data']['list'],
|
||||
'name' => $group_member_info['data'][0]['Name'],
|
||||
'notification' => $group_member_info['data'][0]['Notification']
|
||||
'notification' => $group_member_info['data'][0]['Notification'],
|
||||
'mute_all_member' => $group_member_info['data'][0]['MuteAllMember'] == 'On' ? 1 : 0,
|
||||
];
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $return_data];
|
||||
|
||||
@@ -1032,7 +1121,8 @@ class Guild extends Model
|
||||
* 设置群聊信息
|
||||
*/
|
||||
public function set_guild_info($guild_id,$name,$notice,$avatar){
|
||||
$return = model('Tencent')->modify_group_base_info($guild_id, $name,$avatar, $notice);
|
||||
$guild_id = 'g'.$guild_id;
|
||||
$return = model('api/Tencent')->modify_group_base_info($guild_id, $name,$avatar, $notice);
|
||||
return ['code' => $return['code'], 'msg' => $return['msg'], 'data' => $return['data']];
|
||||
}
|
||||
|
||||
@@ -1043,7 +1133,9 @@ class Guild extends Model
|
||||
*/
|
||||
public function my_guild($user_id)
|
||||
{
|
||||
$guild_user = Db::name('vs_guild_user')->where(['user_id'=>$user_id,'status'=>1,'delete_time'=>0])->find();
|
||||
$guild_user = Db::name('vs_guild_user')->where(['user_id'=>$user_id,'status'=>1,'delete_time'=>0])
|
||||
->order('createtime desc')
|
||||
->find();
|
||||
if(empty($guild_user)){
|
||||
return ['code' => 0, 'msg' => '您没有加入任何公会', 'data'=>null];
|
||||
}
|
||||
@@ -1069,10 +1161,9 @@ class Guild extends Model
|
||||
//本周的第一天
|
||||
$week = strtotime(date('Y-m-d 00:00:00', strtotime('this week Monday')));
|
||||
$week_end_time = time();
|
||||
$guild_data['week_income'] = db::name('vs_give_gift')
|
||||
->whereIn('gift_user',$user_id)
|
||||
$guild_data['week_income'] = db::name('vs_guild_flow')->where(['guild_id'=>$info['id']])
|
||||
->where(['createtime' => ['between', [$week, $week_end_time]]])
|
||||
->sum('total_price');
|
||||
->sum('flow_price');
|
||||
//厅主收益
|
||||
$guild_data['room_author_ratio'] = $guild_user['room_id']==0 ? 0 : get_system_config_value('room_author_ratio');
|
||||
//礼物分成
|
||||
@@ -1080,7 +1171,13 @@ class Guild extends Model
|
||||
//付费退出公会所需金
|
||||
$guild_data['quit_guild_gold'] = get_system_config_value('quit_guild_gold');
|
||||
//工会群组ID
|
||||
$guild_data['guild_group_id'] = "g".$info['id'];
|
||||
if($info['id']<=95){
|
||||
$guild_id = "g".$info['id'];
|
||||
}else{
|
||||
$guild_id = $info['id'];
|
||||
}
|
||||
$guild_data['guild_group_id'] = $guild_id;
|
||||
$guild_data['guild_id'] = $guild_id;
|
||||
//工会基础信息
|
||||
$guild_data_info = Db::name('vs_guild_data')->where(['guild_id'=>$info['id']])->find();
|
||||
$guild_data['agreement'] = $guild_data_info['agreement'] ?? '';
|
||||
@@ -1093,12 +1190,18 @@ class Guild extends Model
|
||||
*/
|
||||
public function join_guild($guild_id,$user_id=0,$settlement_ratio = 0)
|
||||
{
|
||||
$user_info = model('User')->get_user_info($user_id);
|
||||
$user_info = db::name('user')->where(['id'=>$user_id])->find();
|
||||
if(!$user_info){
|
||||
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
|
||||
}
|
||||
if($user_info['is_real']!=1 || empty($user_info['card_id'])){
|
||||
return ['code' => 0, 'msg' => '请先实名认证', 'data' => null];
|
||||
//查询是否实名认证
|
||||
$is_real = model('api/UserData')->real_name_info($user_id);
|
||||
if($is_real['code']==0){
|
||||
return ['code' => 0, 'msg' => '请先实名认证','data' => null];
|
||||
}else{
|
||||
if($is_real['data']['is_real'] !=1){
|
||||
return ['code' => 0, 'msg' => '请先实名认证','data' => null];
|
||||
}
|
||||
}
|
||||
//公会是否存在
|
||||
$guild_info = db::name('vs_guild')->where(['id'=>$guild_id,'delete_time'=>0])->find();
|
||||
@@ -1142,7 +1245,7 @@ class Guild extends Model
|
||||
}
|
||||
//是否有房间
|
||||
$rid = 0;
|
||||
$room_info = db::name('vs_room')->where('user_id', $user_id)->find();
|
||||
$room_info = db::name('vs_room')->where(['user_id'=>$user_id,'delete_time'=>0,'type_id'=>['<>',6]])->find();
|
||||
if($room_info){
|
||||
$rid = $room_info['id'];
|
||||
}
|
||||
@@ -1168,8 +1271,11 @@ class Guild extends Model
|
||||
//增加公会人数
|
||||
db::name('vs_guild')->where('id', $guild_info['id'])->setInc('num', 1);
|
||||
//拉用户进入工会群聊
|
||||
model('Tencent')->add_group_member('g'.$guild_id, $user_id);
|
||||
model('Tencent')->send_group_system_notification('g'.$guild_id,"欢迎".$user_info['nickname'].'加入公会');
|
||||
if($guild_id<=95){ //事故处理-114以前的群被删了
|
||||
$guild_id = "g".$guild_id;
|
||||
}
|
||||
model('api/Tencent')->add_group_member('g'.$guild_id, $user_id);
|
||||
model('api/Tencent')->send_group_system_notification('g'.$guild_id,"欢迎".$user_info['nickname'].'加入公会');
|
||||
//发系统信息
|
||||
$content = "恭喜加入{$guild_info['guild_name']}工会,您的个人收益增加{$configs['room_gift_guild_ratio']}%,目前总收益{$insert_data['settlement_ratio']}%";
|
||||
model('api/UserMessage')->send_system_message($user_id, "加入公会成功通知", $content, 1);
|
||||
|
||||
@@ -41,7 +41,7 @@ class HeadLine extends Model
|
||||
}
|
||||
}
|
||||
//检测用户余额
|
||||
$user_coin = model('UserWallet')->where('user_id' ,$uid)->value('coin');
|
||||
$user_coin = db::name('user_wallet_coin')->where('user_id' ,$uid)->value('coin');
|
||||
if($user_coin < $money) {
|
||||
return ['code' => 0, 'msg' => '余额不足!', 'data' => null];
|
||||
}
|
||||
@@ -81,26 +81,13 @@ class HeadLine extends Model
|
||||
}
|
||||
|
||||
//扣除用户余额
|
||||
$res4 = model('UserWallet')->where('user_id' ,$uid)->setDec('coin', $money);
|
||||
if(!$res4) {
|
||||
$wallet_update = model('api/UserWallet')->change_user_cion_log($uid,$money,$room_id,20,'发布头条');
|
||||
if(!$wallet_update){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '扣除用户余额失败!', 'data' => null];
|
||||
return ['code' => 0, 'msg' => '网络错误-1', 'data' => null];
|
||||
}
|
||||
//记录扣除用户余额
|
||||
$res5 =db::name('vs_user_money_log')->insert([
|
||||
'user_id' => $uid,
|
||||
'change_type' => 20,
|
||||
'money_type' => 1,
|
||||
'change_value' => $money,
|
||||
'from_id' => $res3,
|
||||
'remarks' => '发布头条扣除余额',
|
||||
'createtime' => time(),
|
||||
]);
|
||||
if(!$res5) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '记录扣除用户余额失败!', 'data' => null];
|
||||
}
|
||||
//给所有直播间发送消息 这个接口是要钱的 需要购买 暂时先藏起来
|
||||
|
||||
//给所有直播间发送消息
|
||||
$ToUserInfo = Db::name('user')->where(['id' => $uid])->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$text = [
|
||||
'type' => 1,
|
||||
|
||||
@@ -57,35 +57,24 @@ class Invited extends Model
|
||||
}
|
||||
|
||||
//下级充值推荐人收益计算
|
||||
public function invited_reward($sub_user_id,$money){
|
||||
//查询上级
|
||||
$invited_user_id = $this->where('sub_user_id', $sub_user_id)->value('user_id');
|
||||
if(!$invited_user_id){
|
||||
return ['code' => 0, 'msg' => "未绑定上级用户", 'data' => null];
|
||||
public function invited_reward($sub_user_id,$money,$invited_user_id){
|
||||
//查询下级用户充值总金额
|
||||
$sub_user_all_money = db::name('vs_user_recharge')
|
||||
->where('user_id', $sub_user_id)
|
||||
->where('pay_status',2)->sum('money');
|
||||
if($sub_user_all_money > 1000){
|
||||
return ['code' => 1, 'msg' => "下级充值金额大于1000元不需返利", 'data' => null];
|
||||
}
|
||||
|
||||
$invited_draw_conf = get_system_config_value('invited_draw');//分成比例
|
||||
$invited_draw = $invited_draw_conf / 100;
|
||||
$invited_draw_money = $money * $invited_draw;
|
||||
$invited_draw_money = $invited_draw_money / intval(get_system_config_value('rmb_coin_ratio')); //金币换算成钻石
|
||||
//修改用户资金
|
||||
$reslut = model('common/UserWallet')->change_user_money($invited_user_id, $invited_draw_money, model('common/UserWallet')::MONEYTYPEARNINGS, model('common/UserWallet')::OPERATION_INVITE_REBATE, '邀请用户充值返利');
|
||||
if($reslut['code'] == 1){
|
||||
//记录日志
|
||||
$data = [];
|
||||
$data['user_id'] = $invited_user_id;
|
||||
$data['sub_user_id'] = $sub_user_id;
|
||||
$data['coin'] = $money;
|
||||
$data['earnings'] = $invited_draw_money;
|
||||
$data['proportion'] = $invited_draw_conf;
|
||||
$data['createtime'] = time();
|
||||
$data['updatetime'] = time();
|
||||
$res = Db::name('vs_user_invited_income_log')->insert($data);
|
||||
if ($res) {
|
||||
return ['code' => 1, 'msg' => "操作成功", 'data' => null];
|
||||
}
|
||||
}else{
|
||||
return ['code' => $reslut['code'], 'msg' => $reslut['code'], 'data' => null];
|
||||
//增加余额并记录日志
|
||||
$wallet_update = model('api/UserWallet')->change_user_earnings_log($invited_user_id,$invited_draw_money,0,6,'邀请用户充值返利');
|
||||
if(!$wallet_update){
|
||||
return ['code' => 0, 'msg' => "邀请给上级返利失败", 'data' => null];
|
||||
}
|
||||
return ['code' => 1, 'msg' => "操作成功", 'data' => null];
|
||||
}
|
||||
|
||||
//账单明细
|
||||
|
||||
@@ -33,7 +33,7 @@ class Lottery extends Model
|
||||
//送给所有人的总价格
|
||||
$all_gift_price = $gift_info['gift_price'] * $num * count($toarray);
|
||||
//判断是否有足够的金币
|
||||
$user_waller = db::name('user_wallet')->where(['user_id'=>$send_uid])->find();
|
||||
$user_waller = db::name('user_wallet_coin')->where(['user_id'=>$send_uid])->find();
|
||||
if ($user_waller['coin'] < $all_gift_price) {
|
||||
return ['code' => 0, 'msg' => '用户金币不足', 'data' => null];
|
||||
}
|
||||
@@ -47,7 +47,8 @@ class Lottery extends Model
|
||||
//送礼 开启事务
|
||||
Db::startTrans();
|
||||
//扣除用户金币并记录日志
|
||||
$wallet_update = model('api/GiveGift')->change_user_cion_or_earnings_log($send_uid,$all_gift_price,$room_id,1,10,'用户金币购买礼物');
|
||||
// $wallet_update = model('api/GiveGift')->change_user_cion_or_earnings_log($send_uid,$all_gift_price,$room_id,1,10,'用户金币购买幸运币礼物');
|
||||
$wallet_update = model('api/UserWallet')->change_user_cion_log($send_uid, $all_gift_price, $room_id, 10, '用户金币购买幸运币礼物');
|
||||
if(!$wallet_update){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '扣除用户金币失败', 'data' => null];
|
||||
@@ -76,7 +77,7 @@ class Lottery extends Model
|
||||
$giftId = Db::name('bb_lottery_gift_record')->insertGetId($giftRecord);
|
||||
|
||||
//收礼记录行为日志
|
||||
$give_gift = model('api/GiveGift')->change_user_give_gift_log($send_uid,$gift_id,$gift_price,$num,$to_id,2,1,0,0);
|
||||
$give_gift = model('api/SendGift')->change_user_give_gift_log($send_uid,$gift_id,$gift_price,$num,$to_id,2,1,0,'送幸运币');
|
||||
if(!$give_gift){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '送礼失败', 'data' => null];
|
||||
@@ -84,7 +85,8 @@ class Lottery extends Model
|
||||
//计算收礼人得益
|
||||
$receiver_earnings = $gift_price /2/get_system_config_value('rmb_coin_ratio');
|
||||
//增加收益并记录日志
|
||||
$receiver = model('api/GiveGift') -> change_user_cion_or_earnings_log($to_id,$receiver_earnings,$room_id,2,11,'收礼增加收益');
|
||||
// $receiver = model('api/GiveGift') -> change_user_cion_or_earnings_log($to_id,$receiver_earnings,$room_id,2,11,'收幸运币礼增加收益');
|
||||
$receiver = model('api/UserWallet')->change_user_earnings_log($to_id,$receiver_earnings,$room_id,11,'收幸运币礼增加收益');
|
||||
|
||||
// //用户魅力等级更新
|
||||
// $user_level = model('api/Level')->user_level_data_update($to_id,$gift_price,2,$room_id);
|
||||
@@ -151,7 +153,8 @@ class Lottery extends Model
|
||||
// 大奖
|
||||
if ($result['is_big_prize'] == 1) {//$result['big_prize_amount'],//中奖金额
|
||||
$beilv = floor($result['big_prize_amount'] / $gift_price);
|
||||
$wallet_update = model('api/GiveGift')->change_user_cion_or_earnings_log($send_uid,$result['big_prize_amount'],$room_id,1,58,'参与幸运币活动获得'.$beilv.'倍');
|
||||
// $wallet_update = model('api/GiveGift')->change_user_cion_or_earnings_log($send_uid,$result['big_prize_amount'],$room_id,1,58,'参与幸运币活动获得'.$beilv.'倍');
|
||||
$wallet_update = model('api/UserWallet')->change_user_cion_log($send_uid,$result['big_prize_amount'],$room_id,58,'参与幸运币活动获得'.$beilv.'倍');
|
||||
if(!$wallet_update){
|
||||
return ['code' => 0, 'msg' => '流水记录失败', 'data' => null];
|
||||
}
|
||||
@@ -162,7 +165,8 @@ class Lottery extends Model
|
||||
$tet['play_image'] = $big_prize_play_image;
|
||||
} else { // 小奖 $result['small_prize_amount'],//中奖金额
|
||||
$beilv = floor($result['small_prize_amount'] / $gift_price);
|
||||
$wallet_update = model('api/GiveGift')->change_user_cion_or_earnings_log($send_uid,$result['small_prize_amount'],$room_id,1,58,'参与幸运币活动获得'.$beilv.'倍');
|
||||
// $wallet_update = model('api/GiveGift')->change_user_cion_or_earnings_log($send_uid,$result['small_prize_amount'],$room_id,1,58,'参与幸运币活动获得'.$beilv.'倍');
|
||||
$wallet_update = model('api/UserWallet')->change_user_cion_log($send_uid,$result['small_prize_amount'],$room_id,58,'参与幸运币活动获得'.$beilv.'倍');
|
||||
if(!$wallet_update){
|
||||
return ['code' => 0, 'msg' => '流水记录失败', 'data' => null];
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ class MarketValue extends Model
|
||||
* * @return array
|
||||
*/
|
||||
public function change($user_id,$change_value,$type){
|
||||
$change_value = abs($change_value);
|
||||
$before = db::name('user')->where('id',$user_id)->value('market_value');
|
||||
if($type == 0 || $type == 3){
|
||||
$result = db::name('user')->where('id',$user_id)->setInc('market_value',$change_value);
|
||||
|
||||
@@ -177,12 +177,12 @@ class Nobility extends Model
|
||||
|
||||
}else{ //升级
|
||||
$is_renew = 2;
|
||||
if($user_nobility_info['end_time'] > time()){
|
||||
$old_end_time = $user_nobility_info['end_time'];
|
||||
}else{
|
||||
$old_end_time = time();
|
||||
}
|
||||
$end_time = $old_end_time + $nobility_info['day'] * 86400;
|
||||
// if($user_nobility_info['end_time'] > time()){
|
||||
// $old_end_time = $user_nobility_info['end_time'];
|
||||
// }else{
|
||||
// $old_end_time = time();
|
||||
// }
|
||||
$end_time = time() + $nobility_info['day'] * 86400; //结束时间重置
|
||||
$data = [
|
||||
'lid' => $lid,
|
||||
'user_id' => $user_id,
|
||||
@@ -219,17 +219,7 @@ class Nobility extends Model
|
||||
'createtime' => time(),
|
||||
];
|
||||
db::name('vs_user_nobility_log')->insert($log_data);
|
||||
//发放装扮
|
||||
$nobility_decorate = db::name('vs_nobility_decorate')
|
||||
->field('id,did,dpid,day')
|
||||
->where('delete_time', 0)
|
||||
->where('lid', $lid)
|
||||
->select();
|
||||
if($nobility_decorate){
|
||||
foreach ($nobility_decorate as $key => $value) {
|
||||
model('api/Decorate')->pay_decorate($user_id,$value['did'],$value['day'],9);
|
||||
}
|
||||
}
|
||||
|
||||
//发放金币
|
||||
if($is_renew == 1){
|
||||
$pay_coin = $nobility_info['renew_coin'] ?? 0;
|
||||
@@ -260,6 +250,18 @@ class Nobility extends Model
|
||||
return ['code' => 0, 'msg' => '失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//发放装扮
|
||||
$nobility_decorate = db::name('vs_nobility_decorate')
|
||||
->field('id,did,dpid,day')
|
||||
->where('delete_time', 0)
|
||||
->where('lid', $lid)
|
||||
->select();
|
||||
if($nobility_decorate){
|
||||
foreach ($nobility_decorate as $key => $value) {
|
||||
model('api/Decorate')->pay_decorate($user_id,$value['did'],$value['day'],9);
|
||||
}
|
||||
}
|
||||
//更新装备缓存
|
||||
$cache_key = 'user_base_info_'.$user_id;
|
||||
Cache::rm($cache_key);
|
||||
@@ -302,7 +304,7 @@ class Nobility extends Model
|
||||
}
|
||||
}else{ //升级
|
||||
$old_nobility_info = db::name('vs_nobility')
|
||||
->field('lid,name,pay_price,pay_coin')
|
||||
->field('lid,name,pay_price,pay_coin,day')
|
||||
->where('delete_time', 0)
|
||||
->where('lid', $user_nobility_info['lid'])
|
||||
->find();
|
||||
@@ -312,8 +314,12 @@ class Nobility extends Model
|
||||
if($surplus_time > 0){
|
||||
//小时
|
||||
$surplus_time_hour = floor($surplus_time / 3600); //向下取整
|
||||
if($nobility_info['pay_price']!=0 && $nobility_info['day']!=0){
|
||||
$price = $nobility_info['pay_price'] - bcmul($surplus_time_hour * (($old_nobility_info['pay_price'] / $nobility_info['day']) / 24),1,2); //一小时的价格算
|
||||
if($surplus_time_hour / 24 > $old_nobility_info['day']*2){
|
||||
return ['code' => 0, 'msg' => '已超过2倍有效期,无法升级', 'data' => null];
|
||||
// $surplus_time_hour = $old_nobility_info['day'] * 24 * 2;
|
||||
}
|
||||
if($nobility_info['pay_price']!=0 && $old_nobility_info['day']!=0){
|
||||
$price = $nobility_info['pay_price'] - bcmul($surplus_time_hour * (($old_nobility_info['pay_price'] / $old_nobility_info['day']) / 24),1,2); //一小时的价格算
|
||||
}
|
||||
}else{
|
||||
$price = $nobility_info['pay_price'];
|
||||
|
||||
@@ -41,116 +41,107 @@ class Ranking extends Model
|
||||
public function ranking($ranking_type)
|
||||
{
|
||||
$where['a.createtime'] = ['between', [$this->begin_time, $this->end_time]];
|
||||
$my_ranking = db::name('user')
|
||||
->field('user_code,avatar,nickname,id as user_id,user_code,sex')
|
||||
->where('id',$this->user_id)->find();
|
||||
$my_ranking['icon'][0] = model('UserData')->user_wealth_icon($my_ranking['user_id']);//财富图标
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['diff'] = 0;
|
||||
if($ranking_type == 1){//1财富榜,2魅力榜
|
||||
$lists = db::name('vs_give_gift')->alias('a')
|
||||
->join('user b', 'a.user_id = b.id')
|
||||
->field('a.user_id,b.nickname,b.avatar,b.user_code,sum(a.total_price) * 10 as total')
|
||||
->where($where)
|
||||
->order('total desc')
|
||||
->group('a.user_id')
|
||||
// ->page($this->page, $this->page_limit)
|
||||
->select();
|
||||
|
||||
$params['start_time']=$this->begin_time;
|
||||
$params['end_time']=$this->end_time;
|
||||
|
||||
if($ranking_type == 1){//1财富榜
|
||||
$lists = model('GiveGiftBases')->getGiftRanking($params,1);
|
||||
//把$lists 根据total倒序并只取前20名
|
||||
usort($lists, function($a, $b) {
|
||||
return $b['total'] <=> $a['total']; // 按total降序排序
|
||||
});
|
||||
$lists = array_slice($lists, 0, 20); // 取前20名
|
||||
|
||||
if($lists){
|
||||
$my_ranking = [];
|
||||
foreach ($lists as $key => &$value) {
|
||||
$lists[$key]['icon'][0] = model('UserData')->user_wealth_icon($value['user_id']);//财富图标
|
||||
$lists[$key]['icon'][1] = model('UserData')->user_charm_icon($value['user_id']);//魅力图标
|
||||
$value['total'] = $value['total'] * 10;
|
||||
$value['nickname'] = db::name('user')->where('id',$value['user_id'])->value('nickname');
|
||||
$value['user_code'] = db::name('user')->where('id',$value['user_id'])->value('user_code');
|
||||
$value['avatar'] = db::name('user')->where('id',$value['user_id'])->value('avatar');
|
||||
$lists[$key]['rank'] = $key + 1;
|
||||
if ($this->user_id == $value['user_id']) {
|
||||
$my_ranking = $lists[$key];
|
||||
$my_ranking['diff'] = $key == 0 ? 0 : ($lists[$key - 1]['total'] - $value['total']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$my_ranking && $lists && defined('UID')) {
|
||||
$my_ranking_data = db::name('vs_give_gift')->alias('a')
|
||||
->join('user b', 'a.user_id = b.id')
|
||||
->field('a.user_id,b.nickname,b.avatar,b.user_code,sum(a.total_price) * 10 as total')
|
||||
->where($where)
|
||||
->where('a.user_id',$this->user_id)
|
||||
->page($this->page, $this->page_limit)
|
||||
->select();
|
||||
$my_ranking_data['icon'][0] = model('UserData')->user_wealth_icon($my_ranking_data['user_id']);//财富图标
|
||||
$my_ranking_data['icon'][1] = model('UserData')->user_charm_icon($my_ranking_data['user_id']);//魅力图标
|
||||
$lists_last_number = $lists[count($lists) - 1]['total'] ?? 0;
|
||||
//自己不在前20名
|
||||
if (!$my_ranking) {
|
||||
$lists_last_number = $lists[count($lists) - 1]['total'] ?? 0;
|
||||
//获取自己的送礼记录
|
||||
$params['user_id'] = $this->user_id;
|
||||
$my_ranking_datas = model('GiveGiftBases')->getUserStatistics($params,1);
|
||||
|
||||
if (!isset($my_ranking_data['user_id']) || !$my_ranking_data['user_id']) {
|
||||
$my_ranking = db::name('user')
|
||||
->field('user_code,avatar,nickname,id as user_id,user_code,sex')
|
||||
->where('id',$this->user_id)->find();
|
||||
$my_ranking['icon'][0] = model('UserData')->user_wealth_icon($my_ranking['user_id']);//财富图标
|
||||
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['user_id'] = $my_ranking_datas['user_id'];
|
||||
$my_ranking['total'] = $my_ranking_datas['total_price']??0;
|
||||
$my_ranking['nickanme'] = db::name('user')->where('id',$this->user_id)->value('nickname');
|
||||
$my_ranking['user_code'] = db::name('user')->where('id',$this->user_id)->value('user_code');
|
||||
$my_ranking['avatar'] = db::name('user')->where('id',$this->user_id)->value('avatar');
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['diff'] = numberFormat($lists_last_number);
|
||||
} else {
|
||||
$my_ranking = $my_ranking_data;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['total'] = numberFormat($my_ranking['total']);
|
||||
$my_ranking['diff'] = numberFormat($lists_last_number - ($my_ranking_data['total'] ?: 0));
|
||||
$my_ranking['diff'] = numberFormat($lists_last_number - ($my_ranking['total'] ?: 0));
|
||||
}
|
||||
}else{
|
||||
$my_ranking = db::name('user')
|
||||
->field('user_code,avatar,nickname,id as user_id,sex')
|
||||
->where('id',$this->user_id)->find();
|
||||
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['diff'] = 0;
|
||||
}
|
||||
|
||||
//2魅力榜
|
||||
}else{
|
||||
$lists = db::name('vs_give_gift')->alias('a')
|
||||
->join('user b', 'a.gift_user = b.id')
|
||||
->field('a.gift_user as user_id,b.nickname,b.avatar,b.user_code,sum(a.total_price) * 10 as total')
|
||||
->where($where)
|
||||
->order('total desc')
|
||||
->group('a.gift_user')
|
||||
// ->page($this->page, $this->page_limit)
|
||||
->select();
|
||||
$lists = model('GiveGiftBases')->getGiftRanking($params,2);
|
||||
|
||||
//把$lists 根据total倒序并只取前20名
|
||||
usort($lists, function($a, $b) {
|
||||
return $b['total'] <=> $a['total']; // 按total降序排序
|
||||
});
|
||||
$lists = array_slice($lists, 0, 20); // 取前20名
|
||||
|
||||
if($lists){
|
||||
$my_ranking = [];
|
||||
foreach ($lists as $key => &$value) {
|
||||
$lists[$key]['icon'][0] = model('UserData')->user_wealth_icon($value['user_id']);//财富图标
|
||||
$lists[$key]['icon'][1] = model('UserData')->user_charm_icon($value['user_id']);//魅力图标
|
||||
$value['nickname'] = db::name('user')->where('id',$value['gift_user'])->value('nickname');
|
||||
$value['user_code'] = db::name('user')->where('id',$value['gift_user'])->value('user_code');
|
||||
$value['avatar'] = db::name('user')->where('id',$value['gift_user'])->value('avatar');
|
||||
$value['user_id'] = $value['gift_user'];
|
||||
$lists[$key]['rank'] = $key + 1;
|
||||
if ($this->user_id == $value['user_id']) {
|
||||
if ($this->user_id == $value['gift_user']) {
|
||||
$my_ranking = $lists[$key];
|
||||
$my_ranking['diff'] = $key == 0 ? 0 : ($lists[$key - 1]['total'] - $value['total']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$my_ranking && $lists && defined('UID')) {
|
||||
$my_ranking_data = db::name('vs_give_gift')->alias('a')
|
||||
->join('user b', 'a.gift_user = b.id')
|
||||
->field('a.gift_user as user_id,b.nickname,b.avatar,b.user_code,sum(a.total_price) * 10 as total')
|
||||
->where($where)
|
||||
->where('a.gift_user',$this->user_id)
|
||||
->select();
|
||||
//自己不在前20名
|
||||
if (!$my_ranking) {
|
||||
$lists_last_number = $lists[count($lists) - 1]['total'] ?? 0;
|
||||
//获取自己的收礼记录
|
||||
$params['gift_user'] = $this->user_id;
|
||||
$my_ranking_datas = model('GiveGiftBases')->getUserStatistics($params,2);
|
||||
|
||||
$my_ranking_data['icon'][0] = model('UserData')->user_wealth_icon($my_ranking_data['user_id']);//财富图标
|
||||
$my_ranking_data['icon'][1] = model('UserData')->user_charm_icon($my_ranking_data['user_id']);//魅力图标
|
||||
$lists_last_number = $lists[count($lists) - 1]['total'] ?? 0;
|
||||
|
||||
if (!isset($my_ranking_data['user_id']) || !$my_ranking_data['user_id']) {
|
||||
$my_ranking = db::name('user')
|
||||
->field('user_code,avatar,nickname,id as user_id,user_code,sex')
|
||||
->where('id',$this->user_id)->find();
|
||||
$my_ranking['icon'][0] = model('UserData')->user_wealth_icon($my_ranking['user_id']);//财富图标
|
||||
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['user_id'] = $my_ranking_datas['user_id'];
|
||||
$my_ranking['total'] = $my_ranking_datas['total_price']??0;
|
||||
$my_ranking['nickname'] = db::name('user')->where('id',$this->user_id)->value('nickname');
|
||||
$my_ranking['user_code'] = db::name('user')->where('id',$this->user_id)->value('user_code');
|
||||
$my_ranking['avatar'] = db::name('user')->where('id',$this->user_id)->value('avatar');
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['diff'] = numberFormat($lists_last_number);
|
||||
} else {
|
||||
$my_ranking = $my_ranking_data;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['total'] = numberFormat($my_ranking['total']);
|
||||
$my_ranking['diff'] = numberFormat($lists_last_number - ($my_ranking_data['total'] ?: 0));
|
||||
$my_ranking['diff'] = numberFormat($lists_last_number - ($my_ranking['total'] ?: 0));
|
||||
}
|
||||
}else{
|
||||
$my_ranking = db::name('user')
|
||||
->field('user_code,avatar,nickname,id as user_id,sex')
|
||||
->where('id',$this->user_id)->find();
|
||||
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['diff'] = 0;
|
||||
}
|
||||
}
|
||||
//截取20条
|
||||
$lists = array_slice($lists,0,20);
|
||||
|
||||
$data = [
|
||||
'my_ranking' => $my_ranking,
|
||||
'lists' => $lists
|
||||
@@ -159,299 +150,55 @@ class Ranking extends Model
|
||||
return ['code'=>1,'msg'=>'获取成功','data'=>$data];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//房间榜
|
||||
public function room_ranking()
|
||||
{
|
||||
//金币与魅力比例
|
||||
$ratio = get_system_config_value('coin_charm_exp');
|
||||
$where['a.createtime'] = ['between', [$this->begin_time, $this->end_time]];
|
||||
$where['b.type_id'] = ['<>', 6];
|
||||
$where['b.room_status'] = 1;
|
||||
$field = ['sum(a.total_price) *'.$ratio.' as total,b.room_name,a.from_id as room_id,b.room_cover,b.room_number'];
|
||||
$lists = db::name('vs_give_gift')->alias('a')
|
||||
->join('vs_room b','a.from_id = b.id','left')
|
||||
->where($where)->field($field)->group('a.from_id')
|
||||
->order('total desc')
|
||||
// ->page($this->page, $this->page_limit)
|
||||
->select();
|
||||
$my_ranking = null;
|
||||
if($lists){
|
||||
//获取当前用户的房间id
|
||||
$myRoom = db::name('vs_room')->where(['user_id' => UID ,'room_status' => 1])->find();
|
||||
if($myRoom){
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['rank'] = $key + 1;
|
||||
if ($myRoom['id'] == $value['room_id']) {
|
||||
$my_ranking = $lists[$key];
|
||||
$my_ranking['diff'] = $key == 0 ? 0 : ($lists[$key - 1]['total'] - $value['total']);
|
||||
}
|
||||
// $lists[$key]['total'] = numberFormat($value['total']);
|
||||
}
|
||||
//时间转为天
|
||||
$begin_time = date('Y-m-d',$this->begin_time);
|
||||
$end_time = date('Y-m-d',$this->end_time);
|
||||
|
||||
if (!$my_ranking && $lists && defined('UID')) {
|
||||
$where1['a.createtime'] = ['between', [$this->begin_time, $this->end_time]];
|
||||
$where1['b.type_id'] = ['<>', 6];
|
||||
$my_ranking_data = db::name('vs_give_gift')->alias('a')
|
||||
->join('vs_room b','a.from_id = b.id','left')
|
||||
->where(['a.from_id' => $myRoom['id']])
|
||||
->where($where1)
|
||||
->field('a.from_id as room_id,sum(a.total_price) as total,b.room_name,b.room_cover,b.room_number')->find();
|
||||
$lists_last_number = $lists[count($lists) - 1]['total'] ?? 0;
|
||||
$diff = numberFormat($lists_last_number - ($my_ranking_data['total'] ?: 0));
|
||||
$diff = $diff<=0 ? 0 : $diff;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['total'] = numberFormat($my_ranking_data['total']);
|
||||
$my_ranking['diff'] = $diff;
|
||||
$my_ranking['room_name'] = $my_ranking_data['room_name'];
|
||||
$my_ranking['room_cover'] = $my_ranking_data['room_cover'];
|
||||
if(!$my_ranking_data['room_name']){
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['diff'] = $diff;
|
||||
$my_ranking['room_name'] = $myRoom['room_name'];
|
||||
$my_ranking['room_cover'] = $myRoom['room_cover'];
|
||||
}
|
||||
}
|
||||
}else{
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['rank'] = $key + 1;
|
||||
}
|
||||
$lists_last_number = $lists[count($lists) - 1]['total'] ?? 0;
|
||||
//获取当前用户的房间id
|
||||
$myRoom = db::name('vs_room')->where(['user_id' => UID ,'room_status' => 1])->find();
|
||||
if($myRoom){
|
||||
$my_ranking['room_name'] = $myRoom['room_name'];
|
||||
$my_ranking['room_cover'] = $myRoom['room_cover'];
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['diff'] = numberFormat($lists_last_number);
|
||||
}else{
|
||||
$my_ranking['room_name'] = '';
|
||||
$my_ranking['room_cover'] = '';
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['diff'] = numberFormat($lists_last_number);
|
||||
}
|
||||
|
||||
}
|
||||
}else{
|
||||
//获取当前用户的房间id
|
||||
$myRoom = db::name('vs_room')->where(['user_id' => UID ,'room_status' => 1])->find();
|
||||
//获取当前用户的房间id
|
||||
$myRoom = db::name('vs_room')->where(['user_id' => UID ,'room_status' => 1])->find();
|
||||
if($myRoom){
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['total'] = 0;
|
||||
$totla = db::name('room_daily_income')
|
||||
->where(['room_id' => $myRoom['id'],'date' => ['between', [$begin_time, $end_time]]])->sum('income')??0 ;
|
||||
$my_ranking['total'] = $totla * $ratio;
|
||||
$my_ranking['diff'] = 0;
|
||||
$my_ranking['room_name'] = $myRoom['room_name'];
|
||||
$my_ranking['room_cover'] = $myRoom['room_cover'];
|
||||
}
|
||||
//截取20条
|
||||
$lists = array_slice($lists,0,20);
|
||||
$data = [
|
||||
'my_ranking' => $my_ranking,
|
||||
'lists' => $lists
|
||||
];
|
||||
return ['code'=>1,'msg'=>'获取成功','data'=>$data];
|
||||
}
|
||||
|
||||
//公会榜
|
||||
public function guild_ranking()
|
||||
{
|
||||
$where['createtime'] = ['between', [$this->begin_time, $this->end_time]];
|
||||
|
||||
//所有工会
|
||||
$guilds = db::name('vs_guild')->where(['status' => 1])->select();
|
||||
if($guilds){
|
||||
foreach ($guilds as $k=>$value){
|
||||
$total = 0;
|
||||
$roomids[$k] = db::name('vs_guild_user')->where(['guild_id' => $value['id']])->field('room_id')->select();
|
||||
if($roomids[$k]){
|
||||
foreach ($roomids[$k] as $key => $value1){
|
||||
$toomType = db::name('vs_room')->where(['id' => $value1['room_id']])->where($where)->value('type_id');
|
||||
if($toomType == 6){
|
||||
continue;
|
||||
}
|
||||
$total += db::name('vs_give_gift')->where(['from_id' => $value1['room_id']])->sum('total_price');
|
||||
}
|
||||
}
|
||||
$guilds[$k]['total'] = $total;
|
||||
}
|
||||
//剔除$guilds[$k]['total'] = 0的
|
||||
$guilds = array_filter($guilds, function ($value) {
|
||||
return $value['total'] > 0;
|
||||
});
|
||||
//根据$guilds[$k]['total']排序
|
||||
array_multisort(array_column($guilds, 'total'), SORT_DESC, $guilds);
|
||||
}
|
||||
|
||||
$lists = $guilds ;
|
||||
// $my_ranking = null;
|
||||
$my_ranking['guild_name'] = '';
|
||||
$my_ranking['cover'] = '';
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['diff'] = 0;
|
||||
if($lists){
|
||||
//获取当前用户的工会
|
||||
$myGuild = db::name('vs_guild_user')->where(['user_id' => UID])->find();
|
||||
if($myGuild){
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['rank'] = $key + 1;
|
||||
// $lists[$key]['total'] = numberFormat($value['total']);
|
||||
if ($myGuild['guild_id'] == $value['id']) {
|
||||
$my_ranking = $lists[$key];
|
||||
$my_ranking['diff'] = $key == 0 ? 0 : ($lists[$key - 1]['total'] - $value['total']);
|
||||
}
|
||||
}
|
||||
if (!$my_ranking && $lists && defined('UID')) {
|
||||
$my_rankings = null;
|
||||
//当前工会的所有房间
|
||||
$myguildroom = db::name('vs_guild_user')->where(['guild_id' => $myGuild['guild_id']])->field('room_id')->select();
|
||||
foreach ($myguildroom as $key => $gvalue1){
|
||||
$my_rankings['total'] += db::name('vs_give_gift')->where(['from_id' => $gvalue1['room_id']])->where($where)->sum('total_price');
|
||||
}
|
||||
|
||||
$lists_last_number = $lists[count($lists) - 1]['total'] ?? 0;
|
||||
$diff = numberFormat($lists_last_number - ($my_rankings['total'] ?: 0));
|
||||
$diff = $diff<=0 ? 0 : $diff;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['total'] = numberFormat($my_rankings['total']);
|
||||
$my_ranking['diff'] = $diff;
|
||||
$my_ranking['guild_name'] = $myGuild['room_name'];
|
||||
$my_ranking['cover'] = $myGuild['cover'];
|
||||
if(!$my_rankings){
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['diff'] = $diff;
|
||||
$my_ranking['guild_name'] = '';
|
||||
$my_ranking['cover'] = '';
|
||||
}
|
||||
}
|
||||
}else{
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['rank'] = $key + 1;
|
||||
}
|
||||
$lists_last_number = $lists[count($lists) - 1]['total'] ?? 0;
|
||||
//获取当前用户所在工会
|
||||
$myGuild = db::name('vs_guild_user')->where(['user_id' => UID])->find();
|
||||
if($myGuild){
|
||||
$my_ranking['guild_name'] = db::name('vs_guild')->where(['id' => $myGuild['guild_id']])->value('guild_name');
|
||||
$my_ranking['cover'] = db::name('vs_guild')->where(['id' => $myGuild['guild_id']])->value('cover');
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['diff'] = numberFormat($lists_last_number);
|
||||
}else{
|
||||
$my_ranking['guild_name'] = '';
|
||||
$my_ranking['cover'] = '';
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['diff'] = numberFormat($lists_last_number);
|
||||
}
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
'my_ranking' => $my_ranking,
|
||||
'lists' => $lists
|
||||
];
|
||||
return ['code'=>1,'msg'=>'获取成功','data'=>$data];
|
||||
}
|
||||
|
||||
//真爱榜
|
||||
public function love_ranking()
|
||||
{
|
||||
$where['c.createtime'] = ['between', [$this->begin_time, $this->end_time]];
|
||||
$where['a.status'] = 1;
|
||||
$where['a.type'] = 0;
|
||||
$field = ['a.user_id,a.user_id1,sum(c.total_price) as total,a.room_id,b.room_cover,b.room_intro as room_name'];
|
||||
$lists = db::name('vs_room_cp_movie')->alias('a')
|
||||
->join('vs_room b','a.room_id = b.id','left')
|
||||
->join('vs_give_gift c','a.room_id = c.from_id','left')
|
||||
->where($where)->field($field)->group('a.room_id')
|
||||
->order('total desc')
|
||||
->page($this->page, $this->page_limit)
|
||||
->select();
|
||||
$my_ranking = null;
|
||||
if($lists){
|
||||
//获取当前用户的房间id $this->user_id
|
||||
$myRoom = db::name('vs_room_cp_movie')->where(['user_id' => UID ,'status' => 1])->find();
|
||||
if(!$myRoom){
|
||||
$myRoom = db::name('vs_room_cp_movie')->where(['user_id1' => UID ,'status' => 1])->find();
|
||||
}
|
||||
if($myRoom){
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['rank'] = $key + 1;
|
||||
$lists[$key]['user_avatar'] = db::name('user')->where(['id' => $value['user_id']])->value('avatar');
|
||||
$lists[$key]['user_avatar1'] = db::name('user')->where(['id' => $value['user_id1']])->value('avatar');
|
||||
$lists[$key]['nickname'] = db::name('user')->where(['id' => $value['user_id']])->value('nickname');
|
||||
$lists[$key]['nickname1'] = db::name('user')->where(['id' => $value['user_id1']])->value('nickname');
|
||||
if ($myRoom['room_id'] == $value['room_id']) {
|
||||
$my_ranking = $lists[$key];
|
||||
$my_ranking['diff'] = $key == 0 ? 0 : ($lists[$key - 1]['total'] - $value['total']);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$my_ranking && $lists) {
|
||||
$where1['c.createtime'] = ['between', [$this->begin_time, $this->end_time]];
|
||||
$where1['a.status'] = 1;
|
||||
$my_ranking_data = db::name('vs_room_cp_movie')->alias('a')
|
||||
->join('vs_room b','a.room_id = b.id','left')
|
||||
->join('vs_give_gift c','a.room_id = c.from_id','left')
|
||||
->where(['c.from_id' => $myRoom['room_id']])
|
||||
->where($where1)
|
||||
->field('a.user_id,a.user_id1,a.room_id,sum(c.total_price) as total,b.room_intro as room_name,b.room_cover')->find();
|
||||
$lists_last_number = $lists[count($lists) - 1]['total'] ?? 0;
|
||||
$diff = numberFormat($lists_last_number - ($my_ranking_data['total'] ?: 0));
|
||||
$diff = max($diff, 0);
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['total'] = numberFormat($my_ranking_data['total']);
|
||||
$my_ranking['diff'] = $diff;
|
||||
$my_ranking['room_name'] = $my_ranking_data['room_name'];
|
||||
$my_ranking['room_cover'] = $my_ranking_data['room_cover'];
|
||||
$my_ranking['user_avatar'] = db::name('user')->where(['id' => $my_ranking_data['user_id']])->value('avatar');
|
||||
$my_ranking['user_avatar1'] = db::name('user')->where(['id' => $my_ranking_data['user_id1']])->value('avatar');
|
||||
|
||||
if(!$my_ranking_data['room_name']){
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['diff'] = $diff;
|
||||
$my_ranking['room_name'] = '';
|
||||
$my_ranking['room_cover'] = '';
|
||||
}
|
||||
}
|
||||
}else{
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['rank'] = $key + 1;
|
||||
$lists[$key]['user_avatar'] = db::name('user')->where(['id' => $value['user_id']])->value('avatar');
|
||||
$lists[$key]['user_avatar1'] = db::name('user')->where(['id' => $value['user_id1']])->value('avatar');
|
||||
$lists[$key]['nickname'] = db::name('user')->where(['id' => $value['user_id']])->value('nickname');
|
||||
$lists[$key]['nickname1'] = db::name('user')->where(['id' => $value['user_id1']])->value('nickname');
|
||||
}
|
||||
}
|
||||
}else{
|
||||
//获取当前用户的房间id $this->user_id
|
||||
$myRoom = db::name('vs_room_cp_movie')->where(['user_id' => UID ,'status' => 1])->find();
|
||||
if(!$myRoom){
|
||||
$myRoom = db::name('vs_room_cp_movie')->where(['user_id1' => UID ,'status' => 1])->find();
|
||||
}
|
||||
if($myRoom){
|
||||
$where1['a.status'] = 1;
|
||||
$where1['a.type'] = 0;
|
||||
$my_ranking_data = db::name('vs_room_cp_movie')->alias('a')
|
||||
->join('vs_room b','a.room_id = b.id','left')
|
||||
->where(['a.cp_id' => $myRoom['cp_id']])
|
||||
->where($where1)
|
||||
->field('a.user_id,a.user_id1,a.room_id,b.room_intro as room_name,b.room_cover')->find();
|
||||
$myRoom['id'] = 0;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['diff'] = 0;
|
||||
$my_ranking['room_name'] = '';
|
||||
$my_ranking['room_cover'] = '';
|
||||
}
|
||||
|
||||
$diff =0;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['diff'] = $diff;
|
||||
$my_ranking['room_name'] = $my_ranking_data['room_name'];
|
||||
$my_ranking['room_cover'] = $my_ranking_data['room_cover'];
|
||||
$my_ranking['user_avatar'] = db::name('user')->where(['id' => $my_ranking_data['user_id']])->value('avatar');
|
||||
$my_ranking['user_avatar1'] = db::name('user')->where(['id' => $my_ranking_data['user_id1']])->value('avatar');
|
||||
$my_ranking['nickname'] = db::name('user')->where(['id' => $my_ranking_data['user_id']])->value('nickname');
|
||||
$my_ranking['nickname1'] = db::name('user')->where(['id' => $my_ranking_data['user_id1']])->value('nickname');
|
||||
$lists = db::name('room_daily_income')->alias('a')
|
||||
->join('vs_room b','a.room_id = b.id','left')
|
||||
->field('a.room_id,sum(a.income) * ' . $ratio . ' as total,b.room_name,b.room_cover,b.room_number')
|
||||
->where(['a.date' => ['between', [$begin_time, $end_time]]])
|
||||
->group('a.room_id')
|
||||
->order('total desc')
|
||||
->limit(20)
|
||||
->select();
|
||||
// var_dump($lists);exit;
|
||||
if($lists){
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['rank'] = $key + 1;
|
||||
if ($myRoom['id'] == $value['room_id']) {
|
||||
$my_ranking = $lists[$key];
|
||||
$my_ranking['diff'] = $key == 0 ? 0 : ($lists[$key - 1]['total'] - $value['total']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'my_ranking' => $my_ranking,
|
||||
'lists' => $lists
|
||||
@@ -459,6 +206,7 @@ class Ranking extends Model
|
||||
return ['code'=>1,'msg'=>'获取成功','data'=>$data];
|
||||
}
|
||||
|
||||
|
||||
//真爱榜
|
||||
public function love_rankings()
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -110,7 +110,7 @@ class RoomAuction extends Model
|
||||
|
||||
|
||||
//参与竞拍
|
||||
public function room_auction_join($auction_id,$user_id,$gift_id,$num,$type,$ext=[])
|
||||
public function room_auction_join($auction_id,$user_id,$gift_id,$num,$type,$gift_bag_id=0)
|
||||
{
|
||||
if(!$auction_id){
|
||||
return ['code' => 0, 'msg' => '拍卖已经结束','data' => null];
|
||||
@@ -122,13 +122,13 @@ class RoomAuction extends Model
|
||||
return ['code' => 0, 'msg' => '礼物ID不能为空','data' => null];
|
||||
}
|
||||
$auction = db::name('vs_room_auction')->where('auction_id',$auction_id)->field('room_id,gift_price,user_id,status')->find();
|
||||
$gift_price = db::name('vs_gift')->where('gid',$gift_id)->value('gift_price') ?? 0;
|
||||
// $gift_price = db::name('vs_gift')->where('gid',$gift_id)->value('gift_price') ?? 0;
|
||||
if($user_id == $auction['user_id']){
|
||||
return ['code' => 0, 'msg' => '不能参与自己的竞拍!','data' => null];
|
||||
}
|
||||
|
||||
//走送礼流程
|
||||
$ree = model('GiveGift')->give_gift($user_id,$auction['user_id'],$gift_id,$num,2,$type,$auction['room_id'],0,0,$ext);
|
||||
$ree = model('api/SendGift')->send_gift($user_id,$auction['user_id'],$gift_id,$num,$type,$auction['room_id'],$gift_bag_id);
|
||||
if($ree['code'] != 1){
|
||||
return ['code' => $ree['code'], 'msg' => $ree['msg'],'data' => null];
|
||||
}
|
||||
@@ -181,6 +181,32 @@ class RoomAuction extends Model
|
||||
$v['avatar'] = db::name('user')->where('id',$v['user_id'])->value('avatar');
|
||||
$v['sex'] = db::name('user')->where('id',$v['user_id'])->value('sex');
|
||||
}
|
||||
//获取 用户列表中的用户ID
|
||||
$user_ids = array_column((array)$list,'user_id');
|
||||
//获取上一次的这几个用户 缓存中获取
|
||||
$cache_list = Cache::get('room_auction_list_' . $auction_id);
|
||||
if($cache_list){
|
||||
//取交集(上次和本次都在线的)
|
||||
$user_idss = array_intersect($user_ids,$cache_list);
|
||||
if($user_idss){
|
||||
//取差集(上次的所有和这次还在的,剩余的就是该下线的) 那就是该下线的用户
|
||||
$user_ids_old = array_diff($user_idss,$cache_list);
|
||||
if($user_ids_old){
|
||||
foreach ($user_ids_old as $vvl){
|
||||
db::name('vs_room_visitor')->where(['room_id' => $auction['room_id'],'user_id' => $vvl])->update(['is_onpit' => 1]);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
foreach ($cache_list as $vl){
|
||||
db::name('vs_room_visitor')->where(['room_id' => $auction['room_id'],'user_id' => $vl])->update(['is_onpit' => 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
//没有就设置这个几个上线(在线列表的时候使用)
|
||||
foreach ($user_ids as $vv){
|
||||
db::name('vs_room_visitor')->where(['room_id' => $auction['room_id'],'user_id' => $vv])->update(['is_onpit' => 0]);
|
||||
}
|
||||
Cache::set('room_auction_list_' . $auction_id,$user_ids);
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
@@ -509,6 +535,7 @@ class RoomAuction extends Model
|
||||
'text' => '房间拍卖类型已修改'
|
||||
];
|
||||
model('api/Chat')->sendMsg(1027,$room_id,$text);
|
||||
Cache::rm('room_info_'.$room_id);
|
||||
return ['code' => 1, 'msg' => '操作成功,','data' => null];
|
||||
}
|
||||
}
|
||||
94
application/api/model/RoomDailyIncome.php
Normal file
94
application/api/model/RoomDailyIncome.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class RoomDailyIncome extends Model
|
||||
{
|
||||
// 定义表名(如果表名和模型名一致可省略,这里显式定义更清晰)
|
||||
protected $name = 'room_daily_income';
|
||||
|
||||
// 开启自动时间戳(TP5.1默认用时间戳格式,对应create_time/update_time)
|
||||
// protected $autoWriteTimestamp = true;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 累加用户当日收益(核心方法)
|
||||
* @param int $userId 用户ID
|
||||
* @param float $amount 新增收益金额(正数)
|
||||
* @return bool
|
||||
*/
|
||||
public function addDailyIncome($roomId, $amount)
|
||||
{
|
||||
$today = date('Y-m-d'); // 今日日期
|
||||
|
||||
$today_res = $this->where([
|
||||
'room_id' => $roomId,
|
||||
'date' => $today
|
||||
])->find();
|
||||
if($today_res){
|
||||
$res = $this->where([
|
||||
'room_id' => $roomId,
|
||||
'date' => $today
|
||||
])->update([
|
||||
'income' => $today_res['income'] +$amount,
|
||||
'update_time'=> time(),
|
||||
]);
|
||||
if($res){return true;}
|
||||
}else{
|
||||
$res = $this->insert([
|
||||
'room_id' => $roomId,
|
||||
'income' => $amount,
|
||||
'date' => $today,
|
||||
'create_time'=> time(),
|
||||
'update_time'=> time(),
|
||||
]);
|
||||
if($res){return true;}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询房间某一天收益
|
||||
* @param int $roomId 房间ID
|
||||
* @param string $today 日期(格式:YYYY-MM-DD)
|
||||
* @return float 收益(无收益则返回0)
|
||||
*/
|
||||
public function getTodayIncome($roomId,$today = 0)
|
||||
{
|
||||
if (!$today) {
|
||||
$today = date('Y-m-d');
|
||||
}
|
||||
$result = $this->where([
|
||||
'room_id' => $roomId,
|
||||
'date' => $today
|
||||
])->value('income');
|
||||
|
||||
return $result ? floatval($result) : 0.00;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户时间段内的收益总和
|
||||
* @param int $userId 用户ID
|
||||
* @param string $startDate 开始日期(格式:YYYY-MM-DD)
|
||||
* @param string $endDate 结束日期(格式:YYYY-MM-DD)
|
||||
* @return float 时间段总收益(无收益则返回0)
|
||||
*/
|
||||
public function getIncomeByPeriod($roomId, $startDate, $endDate)
|
||||
{
|
||||
// 校验日期格式(可选,增强健壮性)
|
||||
if (!strtotime($startDate) || !strtotime($endDate)) {
|
||||
return 0.00;
|
||||
}
|
||||
|
||||
$total = $this->where([
|
||||
'room_id' => $roomId,
|
||||
'date' => ['between', [$startDate, $endDate]]
|
||||
])->sum('income');
|
||||
|
||||
return $total ? floatval($total) : 0.00;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,80 +3,20 @@
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Log;
|
||||
use think\Model;
|
||||
use think\Env;
|
||||
|
||||
class RoomHourRanking extends Model
|
||||
{
|
||||
//房间小时榜
|
||||
public function room_hour_rankings($page, $page_limit,$start_time = null, $end_time = null)
|
||||
{
|
||||
//当前小时开始时间
|
||||
if($start_time == null){
|
||||
$start_time = strtotime(date('Y-m-d H:00:00'));
|
||||
}
|
||||
|
||||
//结束时间
|
||||
if($end_time == null){
|
||||
$end_time = strtotime(date('Y-m-d H:59:59'));
|
||||
}
|
||||
|
||||
//判断是否开启
|
||||
$open_time = db::name('vs_hour_ranking_config')->where('id', 1)->value('open_time');
|
||||
if ($open_time == 0) {
|
||||
return ['code' => 0, 'msg' => '排行榜暂未开启', 'data' => null];
|
||||
}
|
||||
|
||||
//是否开启巡乐会
|
||||
$is_open_xlh = db::name('vs_hour_ranking_config')->where('id', 1)->value('is_open_xlh');
|
||||
|
||||
// 更进一步的优化版本:
|
||||
$subQuery = Db::name('vs_give_gift')
|
||||
->where('from', 2)
|
||||
->whereBetween('createtime', [$start_time, $end_time])
|
||||
->buildSql();
|
||||
|
||||
$profit = db::name('vs_room')->alias('a')
|
||||
->join([$subQuery => 'b'], 'a.id = b.from_id', 'left')
|
||||
->join('vs_room_label c', 'a.label_id = c.id','left')
|
||||
->field('a.id as room_id,a.user_id,a.room_name,a.label_id,a.room_cover,IFNULL(SUM(b.total_price), 0) as total_price,c.label_icon')
|
||||
->where('a.room_status', 1)
|
||||
->where('a.apply_status', 2)
|
||||
->where('a.type_id', '<>', 6)
|
||||
->group('a.id')
|
||||
->order('total_price', 'desc')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
|
||||
if($profit){
|
||||
foreach ($profit as &$v) {
|
||||
$v['total_price'] = $v['total_price'] * get_system_config_value('coin_charm_exp');
|
||||
if($v['room_id'] > 0 && $is_open_xlh == 1){
|
||||
$xlh_status = model('BlindBoxTurntableGift')->get_user_xlh_info($v['room_id']);
|
||||
$v['xlh_status'] = $xlh_status['xlh_status'];
|
||||
}else{
|
||||
$v['xlh_status'] = 0;
|
||||
}
|
||||
//查询房间是否有红包
|
||||
if($v['room_id'] > 0){
|
||||
$red_pack_status = Db::name('redpacket')->where(['room_id' => $v['room_id'], 'status' => ['<=',1]])->count();
|
||||
$v['redpacket_status'] = $red_pack_status;
|
||||
}else{
|
||||
$v['redpacket_status'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
//当前小时开始时间 和结束时间 00:00-00:59 这样的格式
|
||||
$time_range = date('H:') . '00-' . date('H:'). '59';
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => ['time_range' => $time_range, 'lists' =>$profit]];
|
||||
}
|
||||
|
||||
|
||||
//房间小时榜(更正版)
|
||||
public function room_hour_ranking($page, $page_limit,$start_time = null, $end_time = null)
|
||||
{
|
||||
//当前小时开始时间
|
||||
if($start_time == null){
|
||||
$start_time = strtotime(date('Y-m-d H:00:00'));
|
||||
// $start_time = strtotime(date('Y-m-d H:00:00'));
|
||||
$start_time = date('Y-m-d H:00:00');
|
||||
}
|
||||
|
||||
//结束时间
|
||||
@@ -90,66 +30,149 @@ class RoomHourRanking extends Model
|
||||
return ['code' => 0, 'msg' => '排行榜暂未开启', 'data' => null];
|
||||
}
|
||||
|
||||
//是否开启巡乐会
|
||||
$is_open_xlh = db::name('vs_hour_ranking_config')->where('id', 1)->value('is_open_xlh');
|
||||
// 查询这个时间段内收礼的房间ID集合,并实现分页
|
||||
$room_query = Db::name('vs_give_gift')
|
||||
->where(['from' => 2, 'from_id' => ['>',0]])
|
||||
->whereBetween('createtime', [$start_time, $end_time])
|
||||
->group('from_id')
|
||||
->field('from_id, SUM(total_price) as total_price');
|
||||
$coin_exp = get_system_config_value('coin_charm_exp');
|
||||
|
||||
// 应用分页限制
|
||||
$room_ids_with_price = $room_query
|
||||
->order('total_price', 'desc')
|
||||
->limit(($page - 1) * $page_limit, $page_limit)
|
||||
$rankList = Db::name('room_gift_hourly_sum')->alias('a')
|
||||
->join('vs_room b', 'a.room_id = b.id', 'left') // 关联房间表取名称/封面
|
||||
->join('vs_room_label c', 'b.label_id = c.id','left')
|
||||
->field('a.room_id, a.gift_amount * '.$coin_exp.' as total_price, a.gift_count, b.room_name, b.room_cover, b.label_id, c.label_icon')
|
||||
->where(['a.stat_hour' => $start_time,'a.room_id' => ['>',0]])
|
||||
->order('total_price DESC')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
|
||||
$profit = [];
|
||||
if($room_ids_with_price){
|
||||
foreach ($room_ids_with_price as $k => $item){
|
||||
$room_id = $item['from_id'];
|
||||
$profit[$k] = db::name('vs_room')->alias('a')
|
||||
->join('vs_give_gift b', 'a.id = b.from_id', 'left')
|
||||
->join('vs_room_label c', 'a.label_id = c.id','left')
|
||||
->field('a.id as room_id,a.room_name,a.label_id,a.room_cover,SUM(b.total_price) as total_price,c.label_icon')
|
||||
->where('a.type_id', '<>', 6)
|
||||
->where('a.id', $room_id)
|
||||
->whereBetween('b.createtime', [$start_time, $end_time])
|
||||
->find();
|
||||
|
||||
if(!empty($profit[$k])) {
|
||||
$profit[$k]['total_price'] = $profit[$k]['total_price'] * get_system_config_value('coin_charm_exp');
|
||||
|
||||
// 查询巡乐会状态
|
||||
if($room_id > 0 && $is_open_xlh == 1){
|
||||
$xlh_status = model('BlindBoxTurntableGift')->get_user_xlh_info($room_id);
|
||||
$profit[$k]['xlh_status'] = $xlh_status['xlh_status'] ?? 0;
|
||||
} else {
|
||||
$profit[$k]['xlh_status'] = 0;
|
||||
}
|
||||
|
||||
// 查询房间红包状态
|
||||
if($room_id > 0){
|
||||
$red_pack_status = Db::name('redpacket')->where(['room_id' => $room_id, 'status' => ['<=', 1]])->count();
|
||||
$profit[$k]['redpacket_status'] = $red_pack_status;
|
||||
} else {
|
||||
$profit[$k]['redpacket_status'] = 0;
|
||||
}
|
||||
} else {
|
||||
unset($profit[$k]);
|
||||
}
|
||||
|
||||
if($rankList){
|
||||
foreach ($rankList as &$item){
|
||||
$item['redpacket_status'] = Db::name('redpacket')->where(['room_id' => $item['room_id'], 'status' => ['<=', 1]])->count();
|
||||
}
|
||||
}
|
||||
|
||||
// 过滤掉空值并重新索引数组
|
||||
if($profit){
|
||||
$profit = array_values(array_filter($profit));
|
||||
}
|
||||
|
||||
// 查询这个时间段内收礼的房间ID集合,并实现分页
|
||||
// $room_query = Db::name('vs_give_gift')
|
||||
// ->where(['from' => 2, 'from_id' => ['>',0]])
|
||||
// ->whereBetween('createtime', [$start_time, $end_time])
|
||||
// ->group('from_id')
|
||||
// ->field('from_id, SUM(total_price) as total_price');
|
||||
//
|
||||
// // 应用分页限制
|
||||
// $room_ids_with_price = $room_query
|
||||
// ->order('total_price', 'desc')
|
||||
// ->limit(($page - 1) * $page_limit, $page_limit)
|
||||
// ->select();
|
||||
//
|
||||
// $profit = [];
|
||||
// if($room_ids_with_price){
|
||||
// foreach ($room_ids_with_price as $k => $item){
|
||||
// $room_id = $item['from_id'];
|
||||
// $profit[$k] = db::name('vs_room')->alias('a')
|
||||
// ->join('vs_give_gift b', 'a.id = b.from_id', 'left')
|
||||
// ->join('vs_room_label c', 'a.label_id = c.id','left')
|
||||
// ->field('a.id as room_id,a.room_name,a.label_id,a.room_cover,SUM(b.total_price) as total_price,c.label_icon')
|
||||
// ->where('a.type_id', '<>', 6)
|
||||
// ->where('a.id', $room_id)
|
||||
// ->whereBetween('b.createtime', [$start_time, $end_time])
|
||||
// ->find();
|
||||
//
|
||||
// if(!empty($profit[$k])) {
|
||||
// $profit[$k]['total_price'] = $profit[$k]['total_price'] * get_system_config_value('coin_charm_exp');
|
||||
//
|
||||
// // 查询巡乐会状态
|
||||
// if($room_id > 0 && $is_open_xlh == 1){
|
||||
// $xlh_status = model('BlindBoxTurntableGift')->get_user_xlh_info($room_id);
|
||||
// $profit[$k]['xlh_status'] = $xlh_status['xlh_status'] ?? 0;
|
||||
// } else {
|
||||
// $profit[$k]['xlh_status'] = 0;
|
||||
// }
|
||||
//
|
||||
// // 查询房间红包状态
|
||||
// if($room_id > 0){
|
||||
// $red_pack_status = Db::name('redpacket')->where(['room_id' => $room_id, 'status' => ['<=', 1]])->count();
|
||||
// $profit[$k]['redpacket_status'] = $red_pack_status;
|
||||
// } else {
|
||||
// $profit[$k]['redpacket_status'] = 0;
|
||||
// }
|
||||
// } else {
|
||||
// unset($profit[$k]);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 过滤掉空值并重新索引数组
|
||||
// if($profit){
|
||||
// $profit = array_values(array_filter($profit));
|
||||
// }
|
||||
|
||||
//当前小时开始时间 和结束时间 00:00-00:59 这样的格式
|
||||
$time_range = date('H:') . '00-' . date('H:'). '59';
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => ['time_range' => $time_range, 'lists' =>$profit]];
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => ['time_range' => $time_range, 'lists' =>$rankList]];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 核心方法:原生SQL实现每小时送礼流水累加(适配无duplicate()的TP/FastAdmin版本)
|
||||
* @param int $room_id 房间ID
|
||||
* @param float $amount 本次送礼金额(如10.00)
|
||||
* @param int $count 本次送礼次数(默认1)
|
||||
* @return bool 操作是否成功
|
||||
*/
|
||||
public function addGiftHourlySum($room_id, $amount, $count = 1)
|
||||
{
|
||||
// 1. 生成当前小时标识(固定为整点,保证每小时数据独立)
|
||||
$stat_hour = date('Y-m-d H:00:00');
|
||||
$now = date('Y-m-d H:i:s'); // 统一时间变量,避免重复生成
|
||||
|
||||
// 2. 获取数据库表前缀(自动适配FastAdmin配置,避免硬编码)
|
||||
$tablePrefix = Env::get('database.prefix', 'fa_');
|
||||
$tableName = $tablePrefix . 'room_gift_hourly_sum';
|
||||
|
||||
// 3. 构造SQL:所有参数替换为?(位置占位符),按顺序排列
|
||||
$sql = "INSERT INTO {$tableName}
|
||||
(room_id, stat_hour, gift_amount, gift_count, create_time, update_time)
|
||||
VALUES
|
||||
(?, ?, ?, ?, ?, ?) -- 新增部分的6个?
|
||||
ON DUPLICATE KEY UPDATE
|
||||
gift_amount = gift_amount + ?,
|
||||
gift_count = gift_count + ?,
|
||||
update_time = ?";
|
||||
|
||||
// 4. 构造参数数组:严格按SQL中?的顺序排列(核心!)
|
||||
$params = [
|
||||
// 新增部分的6个参数(对应VALUES后的6个?)
|
||||
$room_id, // ?1: room_id
|
||||
$stat_hour, // ?2: stat_hour
|
||||
$amount, // ?3: 新增的gift_amount
|
||||
$count, // ?4: 新增的gift_count
|
||||
$now, // ?5: create_time
|
||||
$now, // ?6: 新增的update_time
|
||||
// 更新部分的3个参数(对应ON DUPLICATE KEY UPDATE后的3个?)
|
||||
$amount, // ?7: 累加的gift_amount
|
||||
$count, // ?8: 累加的gift_count
|
||||
$now // ?9: 更新的update_time
|
||||
];
|
||||
|
||||
try {
|
||||
// 5. 执行原生SQL
|
||||
$result = Db::execute($sql, $params);
|
||||
// 执行成功返回影响行数(新增=1,更新=2),失败返回false
|
||||
if ($result === false) {
|
||||
// 6. 失败则记录异常日志
|
||||
Log::error("送礼流水累加失败:房间ID:{$room_id} | 金额:{$amount}");
|
||||
}
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
// 记录详细错误日志(含SQL和参数,方便排查)
|
||||
Log::error("送礼流水累加失败:{$e->getMessage()}
|
||||
| 房间ID:{$room_id} | 金额:{$amount}
|
||||
| SQL:{$sql}
|
||||
| 参数:" . json_encode($params));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -52,7 +52,15 @@ class RoomPit extends Model
|
||||
//用户上麦
|
||||
public function OnPit($user_id,$room_id,$pit_number)
|
||||
{
|
||||
$on = $this->where(['room_id' => $room_id, 'pit_number' => $pit_number])->update(['user_id' => $user_id]);
|
||||
$roomtype = db::name('vs_room')->where(['id' => $room_id])->value('type_id');
|
||||
if($roomtype == 11 && $pit_number != 9 && $pit_number != 10){
|
||||
$pit_time = db::name('vs_room_bar')->where('id',$room_id)->value('pit_time') ?? 5;
|
||||
$text['end_time'] = time()+$pit_time * 60;
|
||||
}else{
|
||||
$text['end_time'] = 0;
|
||||
}
|
||||
|
||||
$on = $this->where(['room_id' => $room_id, 'pit_number' => $pit_number])->update(['user_id' => $user_id,'end_time' => $text['end_time']]);
|
||||
if(!$on){
|
||||
return ['code' => 0, 'msg' => '上麦失败', 'data' => null];
|
||||
}
|
||||
@@ -60,8 +68,8 @@ class RoomPit extends Model
|
||||
$FromUserInfo = model('api/User')->get_user_base_info($user_id);
|
||||
$FromUserInfo['is_online'] = db::name('vs_room_visitor')->where(['user_id' => $user_id,'room_id' => $room_id])->value('is_online');
|
||||
$FromUserInfo['charm'] = db::name('vs_room_user_charm')->where(['user_id' => $user_id,'room_id' => $room_id])->value('charm');
|
||||
$FromUserInfo['had_custom_gift'] = db::name('vs_user_custom_gift')->where(['user_id' => $user_id,'gift_remark_name' => ['<>','']])->find()?1:0;
|
||||
|
||||
$roomtype = db::name('vs_room')->where(['id' => $room_id])->value('type_id');
|
||||
if($roomtype == 10){
|
||||
if($pit_number == 1){
|
||||
$pit_text = '签约麦';
|
||||
@@ -83,7 +91,7 @@ class RoomPit extends Model
|
||||
//查询房间是否隐藏
|
||||
$is_hide = db::name('vs_room')->where(['id' => $room_id])->value('is_show_room');
|
||||
if($is_hide == 2){
|
||||
db::name('vs_room')->where(['id' => $room_id])->update(['is_show_room' => 1]);
|
||||
// db::name('vs_room')->where(['id' => $room_id])->update(['is_show_room' => 1]);
|
||||
}
|
||||
}elseif ($pit_number == 10) {
|
||||
$pit_text = '嘉宾麦';
|
||||
@@ -142,7 +150,7 @@ class RoomPit extends Model
|
||||
}
|
||||
|
||||
//用户下麦
|
||||
public function DownPit($user_id,$room_id,$pit_number,$type = 0)
|
||||
public function DownPit($user_id,$room_id,$pit_number = 0,$type = 0)
|
||||
{
|
||||
$roomtype = db::name('vs_room')->where(['id' => $room_id])->value('type_id');
|
||||
|
||||
@@ -166,6 +174,7 @@ class RoomPit extends Model
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($roomtype == 10){
|
||||
if($pit_number == 1){
|
||||
$pit_text = '签约麦';
|
||||
@@ -237,7 +246,7 @@ class RoomPit extends Model
|
||||
if(!$pit_info){
|
||||
return ['code' => 0, 'msg' => '该用户已不在'.$pit_text, 'data' => null];
|
||||
}
|
||||
$down = $this->where(['id' => $pit_info['id'] ])->update(['user_id' => 0, 'before_pit_number' => 0]);
|
||||
$down = $this->where(['id' => $pit_info['id'] ])->update(['user_id' => 0, 'before_pit_number' => 0,'end_time' => 0]);
|
||||
if(!$down){
|
||||
return ['code' => 0, 'msg' => '下麦失败', 'data' => null];
|
||||
}
|
||||
@@ -270,11 +279,8 @@ class RoomPit extends Model
|
||||
|
||||
|
||||
//申请上麦
|
||||
public function apply_pit($user_id,$room_id,$pit_number = 0)
|
||||
public function apply_pit($user_id,$room_id,$pit_number = 0,$gift_id = 0,$type = 0)
|
||||
{
|
||||
if($room_id <= 0){
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
//查询房间状态
|
||||
$room_info = db::name('vs_room')->where(['id' => $room_id, 'apply_status' => 2])->field('id,room_status,room_up_pit_type,type_id,label_id,step')->find();
|
||||
if(!$room_info){
|
||||
@@ -295,7 +301,7 @@ class RoomPit extends Model
|
||||
}
|
||||
|
||||
//检查是否在坑位上
|
||||
$pit_infos = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $user_id])->field('id,pit_number')->find();
|
||||
$pit_infos = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $user_id])->field('id,pit_number,end_time')->find();
|
||||
if($pit_number == 9){
|
||||
//检查用户是否是房主或主持
|
||||
$is_room_owner =db::name('vs_room')->where(['id' => $room_id, 'user_id' => $user_id])->field('id')->find();
|
||||
@@ -331,9 +337,9 @@ class RoomPit extends Model
|
||||
}
|
||||
|
||||
//自由麦
|
||||
if($room_info['room_up_pit_type'] == 2){
|
||||
if($room_info['room_up_pit_type'] == 2 || $type == 2){
|
||||
if($pit_number > 0){
|
||||
if($room_info['label_id'] == 5){//交友(互娱)
|
||||
if($room_info['label_id'] == 5 || $room_info['label_id'] == 8){//互娱||酒吧
|
||||
if($pit_number == 7 || $pit_number == 8){
|
||||
return ['code' => 0, 'msg' => '该麦位已锁定了', 'data' => null];
|
||||
}
|
||||
@@ -353,7 +359,7 @@ class RoomPit extends Model
|
||||
return ['code' => 0, 'msg' => '该麦位被锁定', 'data' => null];
|
||||
}
|
||||
}else{
|
||||
if($room_info['label_id'] == 5){//交友
|
||||
if($room_info['label_id'] == 5 || $room_info['label_id'] == 8){//互娱||酒吧
|
||||
$pit_number = $this->getRoomNullPitWithout($room_id, [7,8,9,10]);
|
||||
}else{
|
||||
$pit_number = $this->getRoomNullPitWithout($room_id, [9, 10]);
|
||||
@@ -370,8 +376,8 @@ class RoomPit extends Model
|
||||
if($pit_infos['pit_number'] == 9){
|
||||
return ['code' => 0, 'msg' => '主持不允许换麦', 'data' => null];
|
||||
}
|
||||
$exchange1 = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $pit_infos['pit_number']])->update([ 'user_id' => 0]);
|
||||
$exchange = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $pit_number])->update([ 'user_id' => $user_id]);
|
||||
$exchange1 = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $pit_infos['pit_number']])->update([ 'user_id' => 0, 'end_time' => 0]);
|
||||
$exchange = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $pit_number])->update([ 'user_id' => $user_id,'end_time' => $pit_infos['end_time']]);
|
||||
if(!$exchange || !$exchange1){
|
||||
return ['code' => 0, 'msg' => '换麦失败', 'data' => null];
|
||||
}
|
||||
@@ -391,7 +397,9 @@ class RoomPit extends Model
|
||||
$text['FromUserInfo'] = $FromUserInfo;
|
||||
$text['from_pit_number'] = $pit_infos['pit_number'];
|
||||
$text['to_pit_number'] = $pit_number;
|
||||
$text['end_time'] = $pit_infos['end_time'];
|
||||
model('Chat')->sendMsg(1039,$room_id,$text);
|
||||
|
||||
//查看此房间是否处于pk中
|
||||
$is_pk = db::name('vs_room_pk')->where(['room_id_a' => $room_id])->where(['status' => ['in',[2,3,4]]])->value('room_id_b') ?? 0;
|
||||
if(!$is_pk){
|
||||
@@ -404,6 +412,14 @@ class RoomPit extends Model
|
||||
}
|
||||
return ['code' => 1, 'msg' => '上麦成功', 'data' => null];
|
||||
}else{
|
||||
//上麦设置礼物
|
||||
if($room_info['label_id'] == 8){
|
||||
$gift_info = model('api/BarRoom')->join_pit_choose_gift($user_id,$room_id,$gift_id);
|
||||
if($gift_info['code'] != 1){
|
||||
return ['code' => 0, 'msg' => '设置礼物失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
$ompit = $this->OnPit($user_id,$room_id,$pit_number);//用户上了这个房间的几号麦位
|
||||
if($ompit['code'] != 1){
|
||||
return ['code' => 0, 'msg' => '上麦失败', 'data' => null];
|
||||
@@ -460,6 +476,14 @@ class RoomPit extends Model
|
||||
return ['code' => 0, 'msg' => '用户已在麦上,请先下麦后再申请', 'data' => null];
|
||||
}
|
||||
|
||||
//上麦设置礼物
|
||||
if($room_info['label_id'] == 8){
|
||||
$gift_info = model('api/BarRoom')->join_pit_choose_gift($user_id,$room_id,$gift_id);
|
||||
if($gift_info['code'] != 1){
|
||||
return ['code' => 0, 'msg' => '设置礼物失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//放入等待区
|
||||
$data = [
|
||||
'room_id' => $room_id,
|
||||
@@ -483,22 +507,22 @@ class RoomPit extends Model
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//申请上麦列表
|
||||
public function apply_pit_list($userId,$room_id)
|
||||
{
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
|
||||
$where = [
|
||||
'a.room_id' => $room_id,
|
||||
'a.status' => 0,
|
||||
];
|
||||
|
||||
//常规通道 type: 0普通通道,1优先通道
|
||||
$list['regular'] = db::name('vs_room_pit_apply')->alias('a')->join('user b','a.user_id = b.id')
|
||||
->where($where)->where('a.type',0)->field('a.user_id,a.rank_value,b.nickname,b.avatar')
|
||||
->order('a.rank_value desc')->select();
|
||||
$list['regular'] = db::name('vs_room_pit_apply')->alias('a')
|
||||
->join('user b','a.user_id = b.id')
|
||||
->where($where)->where('a.type',0)
|
||||
->field('a.user_id,a.rank_value,b.nickname,b.avatar')
|
||||
->order('a.rank_value desc')
|
||||
->select();
|
||||
foreach ($list['regular'] as $k => $v){
|
||||
//查询用户的爵位
|
||||
$jue_wei = model('Nobility')->getUserNobilityInfo($v['user_id']);
|
||||
@@ -554,12 +578,6 @@ class RoomPit extends Model
|
||||
//上麦助力
|
||||
public function help_apply_pit($user_id,$room_id,$apply_id)
|
||||
{
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
if(!$apply_id){
|
||||
return ['code' => 0, 'msg' => '请选择助力用户', 'data' => null];
|
||||
}
|
||||
|
||||
//查询当前房间设置的助力;礼物
|
||||
$gift_info = db::name('vs_room_pit_apply_help_gift')->where(['room_id' => $room_id])->field('id,gift_id,gift_price')->find();
|
||||
@@ -567,24 +585,15 @@ class RoomPit extends Model
|
||||
return ['code' => 0, 'msg' => '当前房间没有设置助力礼物', 'data' => null];
|
||||
}
|
||||
|
||||
// $res = model('Room')->get_room_label($room_id);
|
||||
// $room_label = $res['data']['label_id'];
|
||||
// $room_type = $res['data']['type_id'];
|
||||
// if($room_label == 1 && ($room_type == 1 || $room_type == 3 || $room_type == 4)){
|
||||
// $apply_type = 1;
|
||||
// }elseif ($room_label == 2 && ($room_type == 1 || $room_type == 3 || $room_type == 4)){
|
||||
// $apply_type = 2;
|
||||
// }
|
||||
|
||||
//助力
|
||||
$data = [
|
||||
'user_id' => $user_id,
|
||||
'help_user_id' => $apply_id,
|
||||
'room_id' => $room_id,
|
||||
'rank_value' => $gift_info['gift_price'],
|
||||
// 'apply_type' => $apply_type,
|
||||
'createtime'=> time(),
|
||||
];
|
||||
|
||||
//开启事务
|
||||
db::startTrans();
|
||||
$reslut = db::name('vs_room_pit_apply_help')->insert($data);
|
||||
@@ -614,7 +623,8 @@ class RoomPit extends Model
|
||||
}
|
||||
|
||||
//走送礼流程(用户,在房间中,给谁(插队上麦给当前主持人),送了什么礼物,多少个)
|
||||
$give_gift = model('GiveGift')->give_gift($user_id,$room_host_id,$gift_info['gift_id'],1,2,1,$room_id,9);
|
||||
$give_gift = model('SendGift')->send_gift($user_id,$room_host_id,$gift_info['gift_id'],1,1,$room_id);
|
||||
// $give_gift = model('GiveGift')->give_gift($user_id,$room_host_id,$gift_info['gift_id'],1,2,1,$room_id,9);
|
||||
if($give_gift['code'] != 1){
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => $give_gift['msg'].'助力失败。', 'data' => null];
|
||||
@@ -628,12 +638,6 @@ class RoomPit extends Model
|
||||
//同意上麦
|
||||
public function agree_pit($user_id,$room_id,$apply_id,$tpe = 0)
|
||||
{
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
if(!$apply_id){
|
||||
return ['code' => 0, 'msg' => '请选择申请用户', 'data' => null];
|
||||
}
|
||||
|
||||
$res = model('Room')->get_room_label($room_id);
|
||||
$room_label = $res['data']['label_id'];
|
||||
@@ -644,29 +648,14 @@ class RoomPit extends Model
|
||||
$apply_type = 2;//K歌
|
||||
}elseif($room_type == 2){
|
||||
$apply_type = 3;//拍卖
|
||||
}elseif($room_type == 7){
|
||||
$apply_type = 7;//交友
|
||||
}elseif($room_type == 7 || $room_type == 11){//互娱和酒吧
|
||||
$apply_type = 7;
|
||||
}elseif($room_type == 10){
|
||||
$apply_type = 10;//签约
|
||||
}else{
|
||||
$apply_type = 1;//聊天
|
||||
}
|
||||
|
||||
// if($apply_type == 1){
|
||||
// //判断当前用户是否是房主或在主持麦位上的主持
|
||||
// $is_room_owner = model('Room')->where(['id' => $room_id, 'user_id' => $user_id])->field('id')->find();
|
||||
// $is_room_host = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $user_id,'pit_number' => 9])->field('id')->find();
|
||||
// if(!$is_room_owner && !$is_room_host){
|
||||
// return ['code' => 0, 'msg' => '您不是房主 或 不在主持位,没有权限操作', 'data' => null];
|
||||
// }
|
||||
// }else{
|
||||
// $is_room_host = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $user_id,'pit_number' => 9])->field('id')->find();
|
||||
// if(!$is_room_host){
|
||||
// return ['code' => 0, 'msg' => '您不在主持位,没有权限操作', 'data' => null];
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
$to_user = explode(',',$apply_id);
|
||||
|
||||
if(count($to_user) >= 1){
|
||||
@@ -885,25 +874,12 @@ class RoomPit extends Model
|
||||
//清空上麦申请
|
||||
public function clear_apply_pit_list($userId,$room_id,$apply_id = 0)
|
||||
{
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
//判断当前用户是否是房主或主持
|
||||
$is_room_owner = model('Room')->where(['id' => $room_id, 'user_id' => $userId])->field('id')->find();
|
||||
$is_room_host = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $userId,'pit_number' => 9])->field('id')->find();
|
||||
if(!$is_room_owner && !$is_room_host){
|
||||
return ['code' => 0, 'msg' => '您不是房主 或 不在主持麦,没有权限操作', 'data' => null];
|
||||
}
|
||||
// $res = model('Room')->get_room_label($room_id);
|
||||
// $room_label = $res['data']['label_id'];
|
||||
// $room_type = $res['data']['type_id'];
|
||||
// if($room_label == 1 && ($room_type == 1 || $room_type == 3 || $room_type == 4)){
|
||||
// $apply_type = 1;
|
||||
// }elseif ($room_label == 2 && ($room_type == 1 || $room_type == 3 || $room_type == 4)){
|
||||
// $apply_type = 2;
|
||||
// }else{
|
||||
// $apply_type = 1;
|
||||
// }
|
||||
|
||||
if($apply_id){
|
||||
$to_user = explode(',',$apply_id);
|
||||
@@ -937,12 +913,6 @@ class RoomPit extends Model
|
||||
//设置插麦礼物
|
||||
public function set_room_pit_apply_help_gift($user_id,$room_id,$gift_id,$gift_price)
|
||||
{
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
if(!$gift_id){
|
||||
return ['code' => 0, 'msg' => '请选择礼物', 'data' => null];
|
||||
}
|
||||
//礼物不能是CP礼物
|
||||
$cp_gift_ids = explode(',', get_system_config_value('cp_gift_id'));
|
||||
if (in_array($gift_id, $cp_gift_ids)) {
|
||||
@@ -990,10 +960,6 @@ class RoomPit extends Model
|
||||
//修改房间上麦模式
|
||||
public function change_room_up_pit_type($user_id,$room_id)
|
||||
{
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
|
||||
//判断当前用户是否有权限
|
||||
$owner = db::name('vs_room')->where(['id' => $room_id, 'user_id' => $user_id])->field('id')->find();
|
||||
$host = db::name('vs_room_host')->where(['room_id' => $room_id, 'user_id' => $user_id,'delete_time' => null])->find();
|
||||
@@ -1031,15 +997,6 @@ class RoomPit extends Model
|
||||
//1-抱麦 2-踢下去
|
||||
public function host_user_pit($user_id,$room_id,$pit_number,$accept_user_id,$type)
|
||||
{
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
|
||||
if(!$accept_user_id){
|
||||
return ['code' => 0, 'msg' => '请选择用户', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
$room_type = db::name('vs_room')->where(['id' => $room_id])->value('type_id');
|
||||
if($type == 1){//抱麦
|
||||
//判断该用户是否在主持麦上
|
||||
@@ -1051,8 +1008,18 @@ class RoomPit extends Model
|
||||
if($accept_user_is_on_pit){
|
||||
return ['code' => 0, 'msg' => '该用户已在麦位上', 'data' => null];
|
||||
}
|
||||
if($room_type == 7 && ($pit_number == 7 || $pit_number == 8)){
|
||||
return ['code' => 0, 'msg' => '互娱房 不能上7、8号麦位', 'data' => null];
|
||||
if($room_type == 7 || $room_type == 11){
|
||||
if($pit_number == 7 || $pit_number == 8){
|
||||
return ['code' => 0, 'msg' => '此类型房间 不能上7、8号麦位', 'data' => null];
|
||||
}
|
||||
}
|
||||
if($room_type == 11 && $pit_number != 10){
|
||||
$text['text'] = '邀请你上麦';
|
||||
$text['user_id'] = $accept_user_id;
|
||||
$text['pit_number'] = $pit_number;
|
||||
//聊天室推送系统消息
|
||||
model('Chat')->sendMsg(1202,$room_id,$text);
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}
|
||||
$room_label = db::name('vs_room')->where(['id' => $room_id])->value('label_id');
|
||||
if($room_type == 1 && $room_label == 2 && !$pit_number){
|
||||
@@ -1184,11 +1151,11 @@ class RoomPit extends Model
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
if($room_type == 7){
|
||||
if($room_type == 7 || $room_type == 11){
|
||||
//查询当前空麦位
|
||||
$empty_pit = $this->getRoomNullPitWithout($room_id, [7,8,9, 10]);
|
||||
$empty_pit = $this->getRoomNullPitWithout($room_id, [7,8,9,10]);
|
||||
}else{
|
||||
$empty_pit = $this->getRoomNullPitWithout($room_id, [9, 10]);
|
||||
$empty_pit = $this->getRoomNullPitWithout($room_id, [9,10]);
|
||||
}
|
||||
|
||||
if(!$empty_pit){
|
||||
|
||||
@@ -83,10 +83,12 @@ class RoomSong extends Model
|
||||
|
||||
//同意点歌
|
||||
public function agree_song($user_id,$room_id,$type){
|
||||
$owner = db::name('vs_room')->where(['id' => $room_id, 'user_id' => $user_id])->field('id')->find();
|
||||
$host = db::name('vs_room_host')->where(['room_id' => $room_id, 'user_id' => $user_id,'delete_time' => null])->find();
|
||||
if(!$owner && !$host){
|
||||
return ['code' => 0, 'msg' => '没有权限操作', 'data' => null];
|
||||
if($user_id != 1){
|
||||
$owner = db::name('vs_room')->where(['id' => $room_id, 'user_id' => $user_id])->field('id')->find();
|
||||
$host = db::name('vs_room_host')->where(['room_id' => $room_id, 'user_id' => $user_id,'delete_time' => null])->find();
|
||||
if(!$owner && !$host){
|
||||
return ['code' => 0, 'msg' => '没有权限操作', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//此房间类型为特殊存在,修改房间类型的时候 要判断一下条件
|
||||
@@ -137,7 +139,7 @@ class RoomSong extends Model
|
||||
->where('user_id','>',0)->select();
|
||||
if(!empty($roomPit)){
|
||||
foreach ($roomPit as $k=>$v){
|
||||
model('RoomPit')->DownPit($v['user_id'],$room_id,$v['pit_number']);
|
||||
model('api/RoomPit')->DownPit($v['user_id'],$room_id,$v['pit_number']);
|
||||
}
|
||||
}
|
||||
Cache::rm('room_info_'.$room_id);
|
||||
@@ -145,7 +147,7 @@ class RoomSong extends Model
|
||||
$text = [
|
||||
'text' => '房间类型变成k歌--2'
|
||||
];
|
||||
model('Chat')->sendMsg(1012,$room_id,$text);
|
||||
model('api/Chat')->sendMsg(1012,$room_id,$text);
|
||||
}else{
|
||||
$res = db::name('vs_room')->where('id',$room_id)->update(['is_song'=>4]);
|
||||
if(!$res){
|
||||
@@ -159,7 +161,7 @@ class RoomSong extends Model
|
||||
'FromUserInfo' => $FromUserInfo,
|
||||
'action' => 4 //拒绝申请点歌
|
||||
];
|
||||
model('Chat')->sendMsg(1013,$room_id,$text);
|
||||
model('api/Chat')->sendMsg(1013,$room_id,$text);
|
||||
}
|
||||
}
|
||||
//删除申请缓存
|
||||
@@ -173,7 +175,7 @@ class RoomSong extends Model
|
||||
public function song($room_id,$user_id,$song_code,$song_name,$singer,$poster,$duration){
|
||||
$action = 0;//初始值,1-申请点歌,2-切歌,3-下一首歌曲变化,4-拒绝申请点歌
|
||||
//查询当前房间中的场次状态
|
||||
$times_status = db::name('vs_room_song')->where('room_id',$room_id)->field('times,times_status')->order('did desc')->find();
|
||||
$times_status = db::name('vs_room_song')->where('room_id',$room_id)->field('times,times_status')->order('times desc,sort desc')->find();
|
||||
if(!empty($times_status)){//已经有歌曲
|
||||
if($times_status['times_status'] == 2){//这一场次结束了
|
||||
$data['sort'] = 10000;//排序,新场次第一首歌
|
||||
@@ -211,6 +213,18 @@ class RoomSong extends Model
|
||||
$action = 2;//走切歌,当前要唱的歌
|
||||
}
|
||||
|
||||
//本房间内总共还有多少首歌曲未唱
|
||||
$room_song = db::name('vs_room_song')->where(['room_id' => $room_id,'times' => $data['times'],'status' => 1])->count();
|
||||
if($room_song >= 60){
|
||||
return ['code'=>0,'msg'=>'房间内未唱歌曲已达上限,请待演唱完一首后再点歌','data'=>null];
|
||||
}
|
||||
|
||||
//查询当前用户还有几首没有唱
|
||||
$user_song = db::name('vs_room_song')->where(['user_id' => $user_id,'room_id' => $room_id,'times' => $data['times'],'status' => 1])->count();
|
||||
if($user_song >= 3){
|
||||
return ['code'=>0,'msg'=>'已经点了三首歌曲了!演唱后再点','data'=>null];
|
||||
}
|
||||
|
||||
$data['room_id'] = $room_id;
|
||||
$data['user_id'] = $user_id;
|
||||
|
||||
@@ -259,13 +273,16 @@ class RoomSong extends Model
|
||||
//把这个信息存储到redis
|
||||
Cache::set("api:room:song:nextInfo:" . $room_id, $did);
|
||||
}
|
||||
$text = [
|
||||
'action' => $action,
|
||||
'total' => $total,
|
||||
'songInfo' => $nowInfo,
|
||||
'nextInfo' => $nextInfo
|
||||
];
|
||||
model('Chat')->sendMsg(1013,$room_id,$text);
|
||||
if($action){
|
||||
$text = [
|
||||
'action' => $action,
|
||||
'total' => $total,
|
||||
'songInfo' => $nowInfo,
|
||||
'nextInfo' => $nextInfo
|
||||
];
|
||||
model('Chat')->sendMsg(1013,$room_id,$text);
|
||||
}
|
||||
|
||||
//1-禁麦位,2-清空消息,3-清空魅力值,4-加入黑名单,5-踢出房间,6-关闭麦克风,7-申请上麦,8-同意上麦,9-拒绝上麦,10-点歌,11-开启PK',
|
||||
model('Room')->room_operation_record($user_id,$room_id,10,0,0,$did);
|
||||
return ['code'=>1,'msg'=>'申请成功','data'=>null];
|
||||
@@ -281,6 +298,55 @@ class RoomSong extends Model
|
||||
foreach ($list as &$v){
|
||||
$v['nickname'] = db::name('user')->where('id',$v['user_id'])->value('nickname');
|
||||
$v['avatar'] = db::name('user')->where('id',$v['user_id'])->value('avatar');
|
||||
$v['user_code'] = db::name('user')->where('id',$v['user_id'])->value('user_code');
|
||||
$v['dress'] = model('Decorate')->user_decorate_detail($v['user_id'], 1);
|
||||
}
|
||||
}
|
||||
return ['code'=>1,'msg'=>'操作成功','data'=>$list];
|
||||
}
|
||||
|
||||
|
||||
//删除已点歌曲
|
||||
public function del_song($user_id,$did,$room_id){
|
||||
//查询当前用户是否是在9号麦的主持
|
||||
$is_host = db::name('vs_room_pit')->where(['user_id' => $user_id,'room_id' => $room_id,'pit_number' =>9])->find();
|
||||
if(!$is_host){
|
||||
return ['code'=>0,'msg'=>'您没有权限操作','data'=>null];
|
||||
}
|
||||
$is_song = db::name('vs_room_song')->where(['did' => $did,'status' => 2])->find();
|
||||
if($is_song){
|
||||
return ['code'=>0,'msg'=>'演唱中不能删除','data'=>null];
|
||||
}
|
||||
$next_song = Cache::get("api:room:song:nextInfo:" . $room_id);
|
||||
if($did == $next_song){
|
||||
return ['code'=>0,'msg'=>'下一首播放歌曲不能删除','data'=>null];
|
||||
}
|
||||
$res = db::name('vs_room_song')->where(['did' => $did,'status' => 1])->delete();
|
||||
if(!$res){
|
||||
return ['code'=>0,'msg'=>'操作失败','data'=>null];
|
||||
}
|
||||
return ['code'=>1,'msg'=>'操作成功','data'=>null];
|
||||
}
|
||||
|
||||
|
||||
//已点歌曲搜索
|
||||
public function search_song($room_id,$search_user){
|
||||
$userId = db::name('user')->where(['user_code' => $search_user])->value('id');
|
||||
if(!$userId){
|
||||
$userId = db::name('vs_user_decorate')
|
||||
->where(['special_num' => $search_user,'type'=> 6,'is_using' => 1])
|
||||
->value('user_id');
|
||||
}
|
||||
|
||||
$list = db::name('vs_room_song')
|
||||
->field('did,room_id,song_code,song_name,singer,poster,duration,sort,user_id')
|
||||
->where(['room_id' => $room_id,'status' => 1,'times_status' => 1,'user_id' =>$userId])
|
||||
->order('sort desc')->select();
|
||||
if($list){
|
||||
foreach ($list as &$v){
|
||||
$v['nickname'] = db::name('user')->where('id',$v['user_id'])->value('nickname');
|
||||
$v['avatar'] = db::name('user')->where('id',$v['user_id'])->value('avatar');
|
||||
$v['user_code'] = db::name('user')->where('id',$v['user_id'])->value('user_code');
|
||||
$v['dress'] = model('Decorate')->user_decorate_detail($v['user_id'], 1);
|
||||
}
|
||||
}
|
||||
@@ -298,49 +364,110 @@ class RoomSong extends Model
|
||||
return ['code'=>0,'msg'=>'您没有权限操作','data'=>null];
|
||||
}
|
||||
//根据房间ID查询当前房间中正在排序的歌曲 并获取当前排序的前一位的ID
|
||||
$sort_up = db::name('vs_room_song')->where(['room_id' => $sort['room_id'],'status' => 1,'times' =>$sort['times'],'times_status' => 1])->field('did')->order('sort desc')->select();
|
||||
$sort_up = db::name('vs_room_song')
|
||||
->where(['room_id' => $sort['room_id'],'status' => 1,'times' =>$sort['times'],'times_status' => 1])
|
||||
->field('did,status,song_code,song_name,singer,poster,duration,user_id')->order('sort desc')->select();
|
||||
|
||||
if($sort_up[0]['did'] == $room_song_id){
|
||||
return ['code'=>0,'msg'=>'已经是第一首歌了','data'=>null];
|
||||
}
|
||||
|
||||
$sort_ups = 1000;//默认值
|
||||
$now_room_song = 0;
|
||||
if($type == 1){ //上移
|
||||
foreach ($sort_up as $k=>$v){
|
||||
if($v['did'] == $room_song_id){
|
||||
$sort_ups = $sort_up[$k-1]['did'];
|
||||
}
|
||||
if($v['status'] == 2){
|
||||
$now_room_song = 1;
|
||||
}
|
||||
}
|
||||
$fa_zhi = 0;
|
||||
}else{ //置顶
|
||||
foreach ($sort_up as $k=>$v){
|
||||
$sort_ups = $sort_up[0]['did'];
|
||||
}
|
||||
$sort_ups = $sort_up[0]['did'];
|
||||
$now_room_song = db::name('vs_room_song')
|
||||
->where(['room_id' => $sort['room_id'],'status' => 2,'times' =>$sort['times'],'times_status' => 1])
|
||||
->find() ? 1 : 0;
|
||||
$fa_zhi = 9;//阈值 为了防止置顶后被上移歌曲覆盖
|
||||
}
|
||||
//获取现在正在排队的第一的排序号
|
||||
$sortt = db::name('vs_room_song')->where('did',$sort_ups)->value('sort');
|
||||
$sort_upp = $sortt + 1 + $fa_zhi;
|
||||
$sort_upp = $sortt + 1 + $fa_zhi;//计算需要挪动的歌曲的排序号并修改它
|
||||
$res = db::name('vs_room_song')->where('did',$room_song_id)->update(['sort'=>$sort_upp]);
|
||||
if(!$res){
|
||||
return ['code'=>0,'msg'=>'操作失败','data'=>null];
|
||||
}
|
||||
$data = db::name('vs_room_song')->where(['room_id' => $sort['room_id'],'status' => 1,'times' =>$sort['times'],'times_status' => 1])
|
||||
->order('sort desc')->select();
|
||||
|
||||
//移动后重新按照排序查找歌曲新排序
|
||||
$sort_up = db::name('vs_room_song')
|
||||
->where(['room_id' => $sort['room_id'],'status' => 1,'times' =>$sort['times'],'times_status' => 1])
|
||||
->field('did,status,song_code,song_name,singer,poster,duration,user_id')->order('sort desc')->select();
|
||||
|
||||
if(!$now_room_song){//没有正在演唱的歌曲
|
||||
$total = db::name('vs_room_song')
|
||||
->where(['room_id' => $sort['room_id'],'status' => 1,'times_status' => 1])
|
||||
->count();
|
||||
$nowInfo = [
|
||||
'did' => $sort_up[0]['did'],
|
||||
'song_code' => $sort_up[0]['song_code'],
|
||||
'song_name' => $sort_up[0]['song_name'],
|
||||
'singer' => $sort_up[0]['singer'],
|
||||
'poster' => $sort_up[0]['poster'],
|
||||
'duration' => $sort_up[0]['duration'],
|
||||
'user_id' => $sort_up[0]['user_id'],
|
||||
'dress' => model('Decorate')->user_decorate_detail($sort_up[0]['user_id'], 1),
|
||||
'nickname' => db::name('user')->where('id',$sort_up[0]['user_id'])->value('nickname'),
|
||||
'avatar' => db::name('user')->where('id',$sort_up[0]['user_id'])->value('avatar'),
|
||||
'charm' => db::name('vs_room_user_charm')->where(['user_id' => $sort_up[0]['user_id'],'room_id' => $sort['room_id']])->value('charm'),
|
||||
];
|
||||
if(count($sort_up) >= 2){
|
||||
$nextInfo = [
|
||||
'did' => $sort_up[1]['did'],
|
||||
'song_code' => $sort_up[1]['song_code'],
|
||||
'song_name' => $sort_up[1]['song_name'],
|
||||
'singer' => $sort_up[1]['singer'],
|
||||
'poster' => $sort_up[1]['poster'],
|
||||
'duration' => $sort_up[1]['duration'],
|
||||
'user_id' => $sort_up[1]['user_id'],
|
||||
'dress' => model('Decorate')->user_decorate_detail($sort_up[1]['user_id'], 1),
|
||||
'nickname' => db::name('user')->where('id',$sort_up[1]['user_id'])->value('nickname'),
|
||||
'avatar' => db::name('user')->where('id',$sort_up[1]['user_id'])->value('avatar'),
|
||||
'charm' => db::name('vs_room_user_charm')->where(['user_id' =>$sort_up[1]['user_id'],'room_id' => $sort['room_id']])->value('charm'),
|
||||
];
|
||||
}else{
|
||||
$nextInfo = null;
|
||||
}
|
||||
|
||||
$text = [
|
||||
'action' => 2,
|
||||
'total' => $total,
|
||||
'songInfo' => $nowInfo,
|
||||
'nextInfo' => $nextInfo
|
||||
];
|
||||
model('Chat')->sendMsg(1013,$sort['room_id'],$text);
|
||||
Cache::set("api:room:song:nextInfo:" . $sort['room_id'],$sort_up[0]['did']);
|
||||
return ['code'=>1,'msg'=>'操作成功','data'=>null];
|
||||
}
|
||||
|
||||
$did = Cache::get("api:room:song:nextInfo:" . $sort['room_id']);
|
||||
//歌曲移动后,下一首播放歌曲信息 发生改变 推送给前端
|
||||
if($data[0]['did'] != $did){
|
||||
if($sort_up[0]['did'] != $did){
|
||||
$total = db::name('vs_room_song')
|
||||
->where(['room_id' => $sort['room_id'],'status' => 1,'times_status' => 1])
|
||||
->count();
|
||||
$info = [
|
||||
'did' => $data[0]['did'],
|
||||
'song_code' => $data[0]['song_code'],
|
||||
'song_name' => $data[0]['song_name'],
|
||||
'singer' => $data[0]['singer'],
|
||||
'poster' => $data[0]['poster'],
|
||||
'duration' => $data[0]['duration'],
|
||||
'user_id' => $data[0]['user_id'],
|
||||
'dress' => model('Decorate')->user_decorate_detail($data[0]['user_id'], 1),
|
||||
'nickname' => db::name('user')->where('id',$data[0]['user_id'])->value('nickname'),
|
||||
'avatar' => db::name('user')->where('id',$data[0]['user_id'])->value('avatar'),
|
||||
'charm' => db::name('vs_room_user_charm')->where(['user_id' => $data[0]['user_id'],'room_id' => $sort['room_id']])->value('charm'),
|
||||
'did' => $sort_up[0]['did'],
|
||||
'song_code' => $sort_up[0]['song_code'],
|
||||
'song_name' => $sort_up[0]['song_name'],
|
||||
'singer' => $sort_up[0]['singer'],
|
||||
'poster' => $sort_up[0]['poster'],
|
||||
'duration' => $sort_up[0]['duration'],
|
||||
'user_id' => $sort_up[0]['user_id'],
|
||||
'dress' => model('Decorate')->user_decorate_detail($sort_up[0]['user_id'], 1),
|
||||
'nickname' => db::name('user')->where('id',$sort_up[0]['user_id'])->value('nickname'),
|
||||
'avatar' => db::name('user')->where('id',$sort_up[0]['user_id'])->value('avatar'),
|
||||
'charm' => db::name('vs_room_user_charm')->where(['user_id' => $sort_up[0]['user_id'],'room_id' => $sort['room_id']])->value('charm'),
|
||||
];
|
||||
$text = [
|
||||
'action' => 3,//下一首播放歌曲信息推送给前端
|
||||
@@ -349,9 +476,9 @@ class RoomSong extends Model
|
||||
'nextInfo' => $info
|
||||
];
|
||||
model('Chat')->sendMsg(1013,$sort['room_id'],$text);
|
||||
Cache::set("api:room:song:nextInfo:" . $sort['room_id'],$data[0]['did']);
|
||||
Cache::set("api:room:song:nextInfo:" . $sort['room_id'],$sort_up[0]['did']);
|
||||
}
|
||||
return ['code'=>1,'msg'=>'操作成功','data'=>$data];
|
||||
return ['code'=>1,'msg'=>'操作成功','data'=>null];
|
||||
}
|
||||
|
||||
//切歌
|
||||
|
||||
1765
application/api/model/SendGift.php
Normal file
1765
application/api/model/SendGift.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -83,7 +83,7 @@ class Sign extends Model
|
||||
*/
|
||||
public function sign_coin($user_id,$room_id,$sign_user_id,$sign_value,$sign_time){
|
||||
//查询用户金币
|
||||
$user_coin = db::name('user_wallet')->where('user_id',$user_id)->value('coin');
|
||||
$user_coin = db::name('user_wallet_coin')->where('user_id',$user_id)->value('coin');
|
||||
if($user_coin < $sign_value){
|
||||
return ['code' => 0, 'msg' => '金币不足','data' => null];
|
||||
}
|
||||
@@ -91,7 +91,7 @@ class Sign extends Model
|
||||
//开启事务
|
||||
db::startTrans();
|
||||
//扣除用户金币并记录日志
|
||||
$wallet_update = model('api/GiveGift') -> change_user_cion_or_earnings_log($user_id,$sign_value,$room_id,1,50,'用户签约关系');
|
||||
$wallet_update = model('api/UserWallet')->change_user_cion_log($user_id,$sign_value,$room_id,50,'用户签约关系');
|
||||
if(!$wallet_update){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '扣除用户金币失败', 'data' => null];
|
||||
@@ -101,7 +101,7 @@ class Sign extends Model
|
||||
$data = [
|
||||
'user_id' => $user_id,
|
||||
'room_id' => $room_id,
|
||||
'sign_time' => $sign_time,
|
||||
'sign_time' => $sign_time,//场次 vs_room_sign 的ID
|
||||
'sign_user_id' => $sign_user_id,
|
||||
'sign_value' => $sign_value,
|
||||
'createtime' => time(),
|
||||
@@ -112,14 +112,6 @@ class Sign extends Model
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试!','data' => null];
|
||||
}
|
||||
|
||||
//记录房间流水及明细
|
||||
//收礼记录行为日志
|
||||
// $give_gift = model('api/GiveGift') -> change_user_give_gift_log($user_id,0,$sign_value,0,$sign_user_id,2,1,$room_id,0,3);
|
||||
// if(!$give_gift){
|
||||
// Db::rollback();
|
||||
// return ['code' => 0, 'msg' => '出价失败', 'data' => null];
|
||||
// }
|
||||
|
||||
//增加房间火热值hot_value
|
||||
$gift_totalaa = $sign_value * get_system_config_value('coin_charm_exp');
|
||||
db::name('vs_room')->where(['id' => $room_id])->inc('hot_value', $gift_totalaa)->inc('today_hot_value', $gift_totalaa)->update();
|
||||
@@ -133,7 +125,7 @@ class Sign extends Model
|
||||
foreach ($refund as $k => $v){
|
||||
if($v['id'] != $sign_user['id']){
|
||||
//给用户退回签约金额记录行为日志
|
||||
$result2[$k] = model('api/GiveGift') -> change_user_cion_or_earnings_log($v['user_id'],$v['sign_value'],$room_id,1,51,'签约失败退款');
|
||||
$result2[$k] = model('api/UserWallet')->change_user_cion_log($v['user_id'],$v['sign_value'],$room_id,51,'签约失败退款');
|
||||
if(!$result2[$k]){
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试,', 'data' => null];
|
||||
@@ -194,7 +186,7 @@ class Sign extends Model
|
||||
}
|
||||
//获取签约出价最高的
|
||||
$max_sign_user = db::name('vs_user_sign_auction')->where(['room_id' => $room_id,'sign_time' => $sign_time,'type' => 0])->order('sign_value desc,id asc')->find();
|
||||
if($max_sign_user){
|
||||
if($max_sign_user && $max_sign_user['sign_value'] > $sign['market_value']){
|
||||
$before_sign_user = null;
|
||||
$is_sign = null;
|
||||
//查询签约用户的身份 是否是第一次被签 是否当前有签
|
||||
@@ -221,7 +213,7 @@ class Sign extends Model
|
||||
|
||||
//记录房间流水及明细
|
||||
//收礼记录行为日志
|
||||
$give_gift = model('api/GiveGift') -> change_user_give_gift_log($max_sign_user['user_id'],0,$max_sign_user['sign_value'],0,$sign_user_id,2,1,$room_id,0,3);
|
||||
$give_gift = model('api/SendGift') -> change_user_give_gift_log($max_sign_user['user_id'],0,$max_sign_user['sign_value'],1,$sign_user_id,2,1,$room_id,'签约用户');
|
||||
if(!$give_gift){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '出价失败', 'data' => null];
|
||||
@@ -273,7 +265,7 @@ class Sign extends Model
|
||||
}
|
||||
|
||||
//签过没过期 给上任签约者
|
||||
$result4 = model('api/GiveGift') -> change_user_cion_or_earnings_log($before_sign_user,$shouyizs,$room_id,2,54,'解约补偿');
|
||||
$result4 = model('api/UserWallet')->change_user_earnings_log($before_sign_user,$shouyizs,$room_id,54,'解约补偿');
|
||||
if(!$result4){
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null];
|
||||
@@ -303,7 +295,7 @@ class Sign extends Model
|
||||
|
||||
if($sign_user_type == 0){
|
||||
//首次签约 给被签约的人
|
||||
$result4 = model('api/GiveGift') -> change_user_cion_or_earnings_log($max_sign_user['sign_user_id'],$shouyizs,$room_id,2,52,'被首次签约成功收入');
|
||||
$result4 = model('api/UserWallet')->change_user_earnings_log($max_sign_user['sign_user_id'],$shouyizs,$room_id,52,'首次签约收入');
|
||||
if(!$result4){
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null];
|
||||
@@ -364,7 +356,7 @@ class Sign extends Model
|
||||
foreach ($refund as $k => $v){
|
||||
if($v['id'] != $max_sign_user['id']){
|
||||
//给用户退回签约金额记录行为日志
|
||||
$result2[$k] = model('api/GiveGift') -> change_user_cion_or_earnings_log($v['user_id'],$v['sign_value'],$room_id,1,51,'签约失败退款');
|
||||
$result2[$k] = model('api/UserWallet')->change_user_cion_log($v['user_id'],$v['sign_value'],$room_id,51,'签约失败退款');
|
||||
if(!$result2[$k]){
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null];
|
||||
@@ -633,7 +625,7 @@ class Sign extends Model
|
||||
];
|
||||
$result = db::name('vs_user_sign_earnings')->insert($data);
|
||||
if($result){
|
||||
$result4 = model('api/GiveGift') -> change_user_cion_or_earnings_log($sign_info['parent_user_id'],$earnings,$room_id,2,55,'签约用户收礼返佣');
|
||||
$result4 = model('api/UserWallet')->change_user_earnings_log($sign_info['parent_user_id'],$earnings,$room_id,55,'签约用户收礼返佣');
|
||||
if(!$result4){
|
||||
return true;
|
||||
}
|
||||
@@ -692,7 +684,7 @@ class Sign extends Model
|
||||
|
||||
|
||||
//获取签约者的金币
|
||||
$coin = db::name('user_wallet')->where('user_id',$user_id)->value('coin');
|
||||
$coin = db::name('user_wallet_coin')->where('user_id',$user_id)->value('coin');
|
||||
if($coin < $change_coin){
|
||||
return ['code' => 0, 'msg' => '您的金币不足', 'data' => null];
|
||||
}
|
||||
@@ -704,7 +696,7 @@ class Sign extends Model
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null];
|
||||
}
|
||||
$res2 = model('api/GiveGift') -> change_user_cion_or_earnings_log($user_id,$change_coin,0,1,56,'续约');
|
||||
$res2 = model('api/UserWallet')->change_user_cion_log($user_id,$change_coin,0,56,'续约');
|
||||
if(!$res2){
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null];
|
||||
|
||||
@@ -75,10 +75,10 @@ class SingerSong extends Model
|
||||
return ['code' => 0, 'msg' => '请先认证歌手', 'data' => null];
|
||||
}
|
||||
//查询是否提交过歌曲
|
||||
$res = db::name('vs_singer_song')->where(['user_id' => $user_id, 'song_name' => $song_name])->find();
|
||||
if ($res) {
|
||||
return ['code' => 0, 'msg' => '请勿重复提交歌曲', 'data' => null];
|
||||
}
|
||||
// $res = db::name('vs_singer_song')->where(['user_id' => $user_id, 'song_name' => $song_name ,'deletetime' => 0])->find();
|
||||
// if ($res) {
|
||||
// return ['code' => 0, 'msg' => '请勿重复提交歌曲', 'data' => null];
|
||||
// }
|
||||
|
||||
//礼物不能是CP礼物
|
||||
$cp_gift_ids = explode(',', get_system_config_value('cp_gift_id'));
|
||||
@@ -157,7 +157,7 @@ class SingerSong extends Model
|
||||
return ['code' => 0, 'msg' => '不能点自己歌曲', 'data' => null];
|
||||
}
|
||||
//查询用户余额
|
||||
$user_money = db::name('user_wallet')->where(['user_id' => $user_id])->value('coin');
|
||||
$user_money = db::name('user_wallet_coin')->where(['user_id' => $user_id])->value('coin');
|
||||
$gift_price = db::name('vs_gift')->where(['gid' => $song['gift_id']])->value('gift_price');
|
||||
if ($user_money < $gift_price * $song['gift_num']) {
|
||||
return ['code' => 0, 'msg' => '余额不足', 'data' => null];
|
||||
@@ -344,7 +344,7 @@ class SingerSong extends Model
|
||||
if ($level) {
|
||||
db::name('vs_singer')->where(['id' => $is_singer['id']])->update(['exp' => $exps,'level' => $level['level']]);
|
||||
//任务:15-每日获得歌星经验
|
||||
model('Tasks')->tasks_complete($user_id,15,$exp_coin);
|
||||
model('api/Tasks')->tasks_complete($user_id,15,$exp_coin);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -56,9 +56,9 @@ class Tasks extends Model
|
||||
public function dailyTasksList($user_id=''){
|
||||
$reslut = [];
|
||||
//用户今日充值金币数量
|
||||
$user_gold = Db::name('vs_user_money_log')->where(['user_id'=>$user_id,'change_type'=>2,'money_type'=>1])
|
||||
$user_gold = Db::name('user_coin_log')->where(['user_id'=>$user_id,'change_type'=>2])
|
||||
->whereTime('createtime', 'today')
|
||||
->sum('change_value');
|
||||
->sum('coin');
|
||||
$reslut['user_gold'] = $user_gold ? $user_gold : 0;
|
||||
//礼盒列表
|
||||
$gift_box = Db::name('vs_gift_bag')->where('status',1)->where('activities_id',2)->select();
|
||||
@@ -106,6 +106,19 @@ class Tasks extends Model
|
||||
$reslut['gift_box_list'][$key]['status_str'] = '已用完('.$reslut['gift_box_list'][$key]['taday_number'].'/'.$ext['num'].')';
|
||||
}
|
||||
}
|
||||
//查询是否实名认证
|
||||
$mobile = db::name('user')->where(['id' => $user_id,'status'=>1])->value('mobile');
|
||||
$is_real = db::name('user_auth')->where('mobile' , $mobile)->field('real_name,card_id,is_real,mobile')->find();
|
||||
if($is_real && $is_real['is_real'] ==1){
|
||||
//查询同一个身份证下的 用户
|
||||
$user_auth_mobile = db::name('user_auth')->where(['card_id'=>$is_real['card_id']])->column('mobile');
|
||||
if(count($user_auth_mobile)>1){
|
||||
$user_ids = db::name('user')->whereIn('mobile',$user_auth_mobile)->column('id');
|
||||
}else{
|
||||
$user_ids = db::name('user')->where('mobile',$is_real['mobile'])->column('id');
|
||||
}
|
||||
}
|
||||
|
||||
//任务列表
|
||||
$data = db::name('vs_tasks')
|
||||
->field('id as task_id,icon,task_name,target_quantity,task_type,jump_type,tasks_bag_id')
|
||||
@@ -141,7 +154,11 @@ class Tasks extends Model
|
||||
->whereTime('createtime', 'today')
|
||||
->find();
|
||||
}else{
|
||||
$user_daily_tasks = Db::name('vs_tasks_user_daily')->where('user_id',$user_id)->where('task_id',$v['task_id'])->find();
|
||||
if(isset($user_ids) && $v['task_type'] == 1 && count($user_ids)>1){
|
||||
$user_daily_tasks = Db::name('vs_tasks_user_daily')->whereIn('user_id',$user_ids)->where('task_id',$v['task_id'])->find();
|
||||
}else{
|
||||
$user_daily_tasks = Db::name('vs_tasks_user_daily')->where('user_id',$user_id)->where('task_id',$v['task_id'])->find();
|
||||
}
|
||||
if($v['jump_type']==4){
|
||||
//跳转的房间路径
|
||||
$v['from_id'] = model('api/Room')->task_jump_room_recommend($v['task_id']);
|
||||
@@ -238,6 +255,10 @@ class Tasks extends Model
|
||||
$v['task_status'] = 1;
|
||||
$v['task_type_str'] = "未完成";
|
||||
}
|
||||
if($user_couple_task['day']<date('Y-m-d') && $user_couple_task['status'] !=2){
|
||||
$v['task_status'] = 1;
|
||||
$v['task_type_str'] = "已过期";
|
||||
}
|
||||
}elseif($v['task_id']==1){//每日签到处理
|
||||
$sign_in_info = Db::name('vs_user_tasks_sign_in')->where(['user_id'=>$user_id,'sign_in_date'=>date('Y-m-d'),'delete_time'=>0])->find();
|
||||
if ($sign_in_info) {
|
||||
@@ -322,7 +343,25 @@ class Tasks extends Model
|
||||
if($task_info['task_type']==2){
|
||||
$user_daily_tasks = Db::name('vs_tasks_user_daily')->where('user_id',$user_id)->where('task_id',$task_id)->whereTime('createtime', 'today')->find();
|
||||
}else{
|
||||
$user_daily_tasks = Db::name('vs_tasks_user_daily')->where('user_id',$user_id)->where('task_id',$task_id)->find();
|
||||
if($task_info['task_type'] == 1){
|
||||
//判断用户是否实名认证,并查询用户手机号下的用户
|
||||
$mobile = db::name('user')->where(['id' => $user_id,'status'=>1])->value('mobile');
|
||||
$is_real = db::name('user_auth')->where('mobile' , $mobile)->field('real_name,card_id,is_real,mobile')->find();
|
||||
if($is_real && $is_real['is_real'] ==1){
|
||||
//查询同一个身份证下的 用户
|
||||
$user_auth_mobile = db::name('user_auth')->where(['card_id'=>$is_real['card_id']])->column('mobile');
|
||||
if(count($user_auth_mobile)>1){
|
||||
$user_ids = db::name('user')->whereIn('mobile',$user_auth_mobile)->column('id');
|
||||
}else{
|
||||
$user_ids = db::name('user')->where('mobile',$is_real['mobile'])->column('id');
|
||||
}
|
||||
$user_daily_tasks = Db::name('vs_tasks_user_daily')->whereIn('user_id',$user_ids)->where('task_id',$task_id)->find();
|
||||
if($user_daily_tasks){
|
||||
return ['code' => 0, 'msg' => '您已完成该任务','data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
$user_daily_tasks = Db::name('vs_tasks_user_daily')->where('user_id', $user_id)->where('task_id', $task_id)->find();
|
||||
}
|
||||
$is_completed = 0;
|
||||
$completion_time = null;
|
||||
@@ -379,23 +418,41 @@ class Tasks extends Model
|
||||
$is_completed = 1;
|
||||
$completion_time = time();
|
||||
}
|
||||
$reslut = Db::name('vs_tasks_user_daily')->insert([
|
||||
'user_id' => $user_id,
|
||||
'task_id' => $task_id,
|
||||
'current_progress' => $current_progress,
|
||||
'tasks_bag_id' => $task_info['tasks_bag_id'],
|
||||
'is_completed' => $is_completed,
|
||||
'ext' => $ext_value,
|
||||
'createtime' => time(),
|
||||
'completion_time' => $completion_time,
|
||||
]);
|
||||
if($task_id == 1){//每日任务,完成即领取
|
||||
$is_claimed = 1;
|
||||
$collection_time = time();
|
||||
$insert_data = [
|
||||
'user_id' => $user_id,
|
||||
'task_id' => $task_id,
|
||||
'current_progress' => $current_progress,
|
||||
'tasks_bag_id' => $task_info['tasks_bag_id'],
|
||||
'is_completed' => $is_completed,
|
||||
'ext' => $ext_value,
|
||||
'createtime' => time(),
|
||||
'completion_time' => $completion_time,
|
||||
'is_claimed' => $is_claimed,
|
||||
'collection_time' => $collection_time,
|
||||
];
|
||||
}else{
|
||||
$insert_data = [
|
||||
'user_id' => $user_id,
|
||||
'task_id' => $task_id,
|
||||
'current_progress' => $current_progress,
|
||||
'tasks_bag_id' => $task_info['tasks_bag_id'],
|
||||
'is_completed' => $is_completed,
|
||||
'ext' => $ext_value,
|
||||
'createtime' => time(),
|
||||
'completion_time' => $completion_time,
|
||||
];
|
||||
}
|
||||
$reslut = Db::name('vs_tasks_user_daily')->insert($insert_data);
|
||||
}
|
||||
}
|
||||
|
||||
if ($reslut) {
|
||||
if($is_completed==1){
|
||||
if(in_array($task_id,[16,13,21,22,23])){
|
||||
model('Tasks')->tasks_complete($user_id,17);
|
||||
model('api/Tasks')->tasks_complete($user_id,17);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '操作成功','data' => ['is_completed'=>1]];
|
||||
}else{
|
||||
@@ -409,12 +466,22 @@ class Tasks extends Model
|
||||
//领取每日任务奖励
|
||||
public function daily_tasks_receive($user_id,$task_id,$student_id = 0){
|
||||
//查询是否实名认证
|
||||
$is_real = model('UserData')->real_name_info($user_id);
|
||||
if($is_real['code']==0){
|
||||
$mobile = db::name('user')->where(['id' => $user_id])->value('mobile');
|
||||
$is_real = db::name('user_auth')->where('mobile' , $mobile)->field('real_name,card_id,is_real,mobile')->find();
|
||||
if(empty($is_real)){
|
||||
return ['code' => 0, 'msg' => '请先实名认证','data' => null];
|
||||
}else{
|
||||
if($is_real['data']['is_real'] !=1){
|
||||
if($is_real['is_real'] !=1){
|
||||
return ['code' => 0, 'msg' => '请先实名认证','data' => null];
|
||||
}else{
|
||||
//查询同一个身份证下的 用户
|
||||
$user_auth_mobile = db::name('user_auth')->where(['card_id'=>$is_real['card_id']])->column('mobile');
|
||||
if(count($user_auth_mobile)>1){
|
||||
$user_ids = db::name('user')->whereIn('mobile',$user_auth_mobile)->column('id');
|
||||
}else{
|
||||
$user_ids = db::name('user')->where('mobile',$is_real['mobile'])->column('id');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
$task_info = Db::name('vs_tasks')->where('id',$task_id)->find();
|
||||
@@ -460,7 +527,11 @@ class Tasks extends Model
|
||||
if($task_info['task_type']==2){
|
||||
$user_daily_tasks = Db::name('vs_tasks_user_daily')->where('user_id',$user_id)->where('task_id',$task_id)->whereTime('createtime', 'today')->find();
|
||||
}else{
|
||||
$user_daily_tasks = Db::name('vs_tasks_user_daily')->where('user_id',$user_id)->where('task_id',$task_id)->find();
|
||||
if(isset($user_ids) && $task_info['task_type'] == 1 && count($user_ids)>1){
|
||||
$user_daily_tasks = Db::name('vs_tasks_user_daily')->whereIn('user_id',$user_ids)->where('task_id',$task_id)->find();
|
||||
}else{
|
||||
$user_daily_tasks = Db::name('vs_tasks_user_daily')->where('user_id',$user_id)->where('task_id',$task_id)->find();
|
||||
}
|
||||
}
|
||||
if (!$user_daily_tasks) {
|
||||
return ['code' => 0, 'msg' => '请完成该任务','data' => null];
|
||||
@@ -471,9 +542,20 @@ class Tasks extends Model
|
||||
if ($user_daily_tasks['is_claimed'] == 1) {
|
||||
return ['code' => 0, 'msg' => '您已领取该奖励','data' => null];
|
||||
}
|
||||
if($user_daily_tasks['user_id'] != $user_id && $task_info['task_type']== 1){
|
||||
return ['code' => 0, 'msg' => '请用您的另一个实名认证账号领取,此账号无权领取','data' => null];
|
||||
}
|
||||
}
|
||||
Db::startTrans();
|
||||
|
||||
// 使用更严格的事务处理,统一加锁顺序
|
||||
$lockKey = 'task_receive_' . $user_id . '_' . $task_id . ($student_id ? '_' . $student_id : '');
|
||||
$lock = cache($lockKey);
|
||||
if ($lock) {
|
||||
return ['code' => 0, 'msg' => '操作过于频繁,请稍后再试','data' => null];
|
||||
}
|
||||
cache($lockKey, 1, 2); // 2秒锁
|
||||
try {
|
||||
Db::startTrans();
|
||||
if($task_id==24){
|
||||
//师徒任务
|
||||
$reslut = Db::name('vs_user_sign_task')->where('id',$user_sign_task['id'])->update([
|
||||
@@ -481,6 +563,7 @@ class Tasks extends Model
|
||||
]);
|
||||
if (!$reslut) {
|
||||
Db::rollback();
|
||||
cache($lockKey, null);
|
||||
return ['code' => 0, 'msg' => '操作失败', 'data' => null];
|
||||
}
|
||||
Db::name('vs_tasks_user_daily')->insert([
|
||||
@@ -529,6 +612,7 @@ class Tasks extends Model
|
||||
]);
|
||||
if (!$reslut) {
|
||||
Db::rollback();
|
||||
cache($lockKey, null);
|
||||
return ['code' => 0, 'msg' => '操作失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
@@ -538,6 +622,7 @@ class Tasks extends Model
|
||||
$op_bag_re = $this->open_tasks_bag($user_id,$task_info['tasks_bag_id']);
|
||||
if ($op_bag_re['code'] != 1) {
|
||||
Db::rollback();
|
||||
cache($lockKey, null);
|
||||
return ['code' => 0, 'msg' => $op_bag_re['msg'], 'data' => null];
|
||||
}
|
||||
}else{
|
||||
@@ -546,15 +631,18 @@ class Tasks extends Model
|
||||
$res = model('common/UserWallet')->change_user_money($user_id, $user_sign_task['value'], model('common/UserWallet')::MONEYTYPEARNINGS, model('common/UserWallet')::SIGN_MASTER_DAILY_RETURN,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::SIGN_MASTER_DAILY_RETURN)." 第".$user_sign_task['times']."天");
|
||||
if ($res['code'] != 1) {
|
||||
Db::rollback();
|
||||
cache($lockKey, null);
|
||||
return ['code' => 0, 'msg' => $res['msg'], 'data' => null];
|
||||
}
|
||||
}
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
cache($lockKey, null);
|
||||
return ['code' => 1, 'msg' => "领取成功", 'data' => null];
|
||||
}catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
cache($lockKey, null);
|
||||
return ['code' => 0, 'msg' => "请重试", 'data' => null];
|
||||
}
|
||||
}
|
||||
@@ -595,11 +683,12 @@ class Tasks extends Model
|
||||
}
|
||||
// 记录日志
|
||||
//添加礼盒记录
|
||||
$reslut = Db::name('vs_gift_bag_receive_log')->insert([
|
||||
$reslut = Db::name('vs_gift_bag_receive_tasks_log')->insert([
|
||||
'user_id' => $user_id,
|
||||
'gift_bag_id' => $gift_box_id,
|
||||
'parent_id' => $v['id'],
|
||||
'gift_id'=> $v['foreign_id'],
|
||||
'type' => $v['type'],
|
||||
'num' => $v['quantity'],
|
||||
'bag_price' => $gift_box_info['money'],
|
||||
'gift_price' => $v['gold'],
|
||||
@@ -768,6 +857,19 @@ class Tasks extends Model
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// 记录日志
|
||||
//添加礼盒记录
|
||||
$reslut = Db::name('vs_gift_bag_receive_tasks_log')->insert([
|
||||
'user_id' => $user_id,
|
||||
'gift_bag_id' => 18,
|
||||
'parent_id' => $v['id'],
|
||||
'gift_id'=> $v['foreign_id'],
|
||||
'type' => $v['type'],
|
||||
'num' => $v['quantity'],
|
||||
'gift_price' => $v['gold'],
|
||||
'createtime' => time(),
|
||||
'updatetime' => time()
|
||||
]);
|
||||
}
|
||||
}
|
||||
// 提交事务
|
||||
@@ -905,7 +1007,7 @@ class Tasks extends Model
|
||||
->where(['user_id'=>$user_id,'is_claimed'=>0,'is_completed'=>1])
|
||||
->where('task_id', 'in', $daily_task_ids)
|
||||
->whereTime('createtime', 'today')
|
||||
->count();
|
||||
->count('id');
|
||||
$task_user_count += $daily_task_count;
|
||||
}
|
||||
|
||||
@@ -926,7 +1028,7 @@ class Tasks extends Model
|
||||
$task_user = Db::name('vs_tasks_user_daily')
|
||||
->where(['user_id'=>$user_id,'is_claimed'=>0,'is_completed'=>1])
|
||||
->where('task_id',$v['task_id'])
|
||||
->count();
|
||||
->count('id');
|
||||
}
|
||||
$task_user_count +=$task_user;
|
||||
}
|
||||
|
||||
@@ -15,9 +15,10 @@ class Tencent extends Model
|
||||
//获取腾讯IM UserSig信息
|
||||
//$uid => 用户id
|
||||
public function tencent_user_sig_info($uid){
|
||||
$config = get_system_config();
|
||||
$tencentyun_im_appid = $config['tencentyun_im_appid'];
|
||||
$tencentyun_im_key = $config['tencentyun_im_key'];
|
||||
|
||||
$tencentyun_im_appid = get_system_config_value('tencentyun_im_appid');
|
||||
$tencentyun_im_key = get_system_config_value('tencentyun_im_key');
|
||||
|
||||
$tencent = new Tencentst($tencentyun_im_appid, $tencentyun_im_key);
|
||||
$user_sig = $tencent->genUserSig($uid);
|
||||
|
||||
@@ -189,8 +190,8 @@ class Tencent extends Model
|
||||
//发送群内系统消息
|
||||
public function send_group_system_notification($rid, $message_data){
|
||||
Log::record("腾讯群内系统消息发送结果".json_encode($rid.$message_data),"info");
|
||||
$config = get_system_config();
|
||||
$tencentyun_im_appid = $config['tencentyun_im_appid'];
|
||||
|
||||
$tencentyun_im_appid = get_system_config_value('tencentyun_im_appid');
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
@@ -1081,4 +1082,42 @@ class Tencent extends Model
|
||||
return true;
|
||||
}
|
||||
|
||||
//禁言
|
||||
public function mute_member($rid, $uida, $time=3600){
|
||||
$config = get_system_config();
|
||||
$tencentyun_im_appid = $config['tencentyun_im_appid'];
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
$postUrl = 'https://console.tim.qq.com/v4/live_engine_http_srv/mute_member?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
$curlPost['GroupId'] = $rid;
|
||||
$curlPost['Members_Account'] = $uida;
|
||||
$curlPost['MuteTime'] = $time;
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => $reslut['ErrorCode'], 'data' => null];
|
||||
}
|
||||
}
|
||||
//禁言用户列表
|
||||
public function get_group_mute_list($rid){
|
||||
$config = get_system_config();
|
||||
$tencentyun_im_appid = $config['tencentyun_im_appid'];
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
$postUrl = 'https://console.tim.qq.com/v4/group_open_http_svc/get_group_muted_account?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
$curlPost['GroupId'] = $rid;
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => $reslut['MutedAccountList']];
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => $reslut['ErrorCode'], 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -60,9 +60,10 @@ class User extends Model
|
||||
}
|
||||
if(empty($field) || in_array('user_wallet',$field)) {
|
||||
//钱包信息
|
||||
$user_wallet = db::name('user_wallet')->where(['user_id' => $uid])->find();
|
||||
$user_info['coin'] = isset($user_wallet['coin']) ? $user_wallet['coin'] : 0;
|
||||
$user_info['earnings'] = isset($user_wallet['earnings']) ? $user_wallet['earnings'] : 0;
|
||||
$user_wallet_coin = db::name('user_wallet_coin')->where(['user_id' => $uid])->find();
|
||||
$user_wallet_earnings = db::name('user_wallet_earnings')->where(['user_id' => $uid])->find();
|
||||
$user_info['coin'] = isset($user_wallet_coin['coin']) ? $user_wallet_coin['coin'] : 0;
|
||||
$user_info['earnings'] = isset($user_wallet_earnings['earnings']) ? $user_wallet_earnings['earnings'] : 0;
|
||||
}
|
||||
if(empty($field) || in_array('user_decorate',$field)) {
|
||||
//装扮
|
||||
@@ -470,60 +471,42 @@ class User extends Model
|
||||
public function get_user_gift_wall_info($uid)
|
||||
{
|
||||
//查询用户礼物墙 以gift_id,send_user_id分组 同一用户送的同一礼物相加
|
||||
$result = db::name('vs_give_gift')->alias('a')
|
||||
$result = db::name('user_gift_wall')->alias('a')
|
||||
->join('vs_gift g', 'a.gift_id = g.gid')
|
||||
->where(['a.gift_user' => $uid,'g.label'=>['<>',2]])
|
||||
->field('a.gift_id,a.user_id,sum(a.number) as total')
|
||||
->group('a.gift_id,a.user_id')
|
||||
->order('total desc')
|
||||
->where(['a.user_id' => $uid, 'g.label' => ['not in', [2, 16]],'a.gift_id' => ['<>', 0]])
|
||||
->field('a.gift_id,a.user_id,a.count,a.give_user_ids,g.gift_name,g.gift_price,g.base_image')
|
||||
->order('count desc')
|
||||
->select();
|
||||
// var_dump($result);exit;
|
||||
// 根据礼物二次分组 获取礼物的总数和送的数量最多的三用户
|
||||
$data = [];
|
||||
// 按 gift_id 聚合数据
|
||||
foreach ($result as $item) {
|
||||
$giftId = $item['gift_id'];
|
||||
$sendUserId = $item['user_id'];
|
||||
$sendUserNickname = db::name('user')->where(['id' => $sendUserId])->value('nickname');
|
||||
$sendUserAvatar = db::name('user')->where(['id' => $sendUserId])->value('avatar');
|
||||
$total = $item['total'];
|
||||
|
||||
if (!isset($data[$giftId])) {
|
||||
$data[$giftId] = [
|
||||
'gift_id' => $giftId,
|
||||
'gift_price' => model('Gift')->where(['gid' => $giftId])->value('gift_price'),
|
||||
'gift_name' => model('Gift')->where(['gid' => $giftId])->value('gift_name'),
|
||||
'base_image' => model('Gift')->where(['gid' => $giftId])->value('base_image'),
|
||||
'total_count' => 0,
|
||||
'top_users' => []
|
||||
$data = [];
|
||||
|
||||
if($result){
|
||||
foreach ($result as $item){
|
||||
$userInfo = [];
|
||||
$users = explode(',', $item['give_user_ids']);
|
||||
foreach ($users as $userId){
|
||||
$user = db::name('user')->where(['id' => $userId])->field('id user_id,nickname,avatar')->find();
|
||||
if($user){
|
||||
$userInfo[] = $user;
|
||||
}
|
||||
}
|
||||
$data[] = [
|
||||
'top_users_count' => count($users),
|
||||
'gift_id' => $item['gift_id'],
|
||||
'gift_name' => $item['gift_name'],
|
||||
'gift_price' => $item['gift_price'],
|
||||
'base_image' => $item['base_image'],
|
||||
'total_count' => $item['count'],
|
||||
'top_users' => $userInfo
|
||||
];
|
||||
}
|
||||
|
||||
// 累加总数量
|
||||
$data[$giftId]['total_count'] += $total;
|
||||
|
||||
// 存储用户赠送记录
|
||||
$data[$giftId]['top_users'][] = [
|
||||
'user_id' => $sendUserId,
|
||||
'nickname' => $sendUserNickname,
|
||||
'avatar' => $sendUserAvatar,
|
||||
'count' => $total
|
||||
];
|
||||
}
|
||||
|
||||
// 对每个礼物的 top_users 排序并取前三名
|
||||
foreach ($data as &$giftData) {
|
||||
// 按 count 降序排序
|
||||
usort($giftData['top_users'], function ($a, $b) {
|
||||
return $b['count'] <=> $a['count'];
|
||||
});
|
||||
$giftData['top_users_count'] = count($giftData['top_users']);
|
||||
// 取前3位
|
||||
$giftData['top_users'] = array_slice($giftData['top_users'], 0, 3);
|
||||
}
|
||||
$data = array_values($data);
|
||||
//查询所有的礼物
|
||||
$gift_list = db::name('vs_gift')->field('gid as gift_id,gift_name,base_image,gift_price')->where(['delete_time' => 0,'label'=>['<>',2]])->select();
|
||||
$gift_list = db::name('vs_gift')
|
||||
->field('gid as gift_id,gift_name,base_image,gift_price')
|
||||
->where(['delete_time' => 0,'label'=>['not in', [2, 16]]])
|
||||
->select();
|
||||
//对比去除$data 里面的礼物
|
||||
$gift_list = array_filter((array)$gift_list, function ($item) use ($data) {
|
||||
return !in_array($item['gift_id'], array_column($data, 'gift_id'));
|
||||
@@ -849,6 +832,7 @@ class User extends Model
|
||||
}
|
||||
}
|
||||
db::commit();
|
||||
Cache::rm('user_base_info_'.$user_id);
|
||||
//推送信息去所在房间
|
||||
//查询当前所在房间
|
||||
$room_id = db::name('vs_room_visitor')->where(['user_id' => $user_id])->order('id' , 'desc')->value('room_id');
|
||||
@@ -868,7 +852,7 @@ class User extends Model
|
||||
$member_name = db::name('user')->where('id' , $user_id)->value('nickname');
|
||||
$member_face_url = db::name('user')->where('id' , $user_id)->value('avatar');
|
||||
model('Tencent')->modify_user_infos($user_id, $member_name, $member_face_url);
|
||||
Cache::rm('user_base_info_'.$user_id);
|
||||
|
||||
return ['code' => 1, 'msg' => '修改成功', 'data' => null];
|
||||
}
|
||||
catch(\Exception $e){
|
||||
|
||||
@@ -288,13 +288,14 @@ class UserCp extends Model
|
||||
* @param $gift_id 礼物ID
|
||||
* @param $room_id 房间ID
|
||||
* @param $cp_zone_id Cp空间ID
|
||||
* @param $gift_price 收礼总金币
|
||||
*/
|
||||
public function addCpLevel($from_user_id, $to_user_id, $room_id, $gift_id, $cp_zone_id, $num,$gift_price)
|
||||
{
|
||||
$jinbi_arr = explode(',', get_system_config_value('cp_exp_rate'));
|
||||
$jinbi = $jinbi_arr[0];
|
||||
$jinyan = $jinbi_arr[1];
|
||||
$exp = round($gift_price * $num / $jinbi * $jinyan, 2);
|
||||
$exp = round($gift_price / $jinbi * $jinyan, 2);
|
||||
$yuan_exp = Db::name('user_cp_zone')->where(['id' => $cp_zone_id])->value('exp');
|
||||
$zone_level = Db::name('user_cp_zone')->where(['id' => $cp_zone_id])->value('level');
|
||||
$toUserNickname =db::name('user')->where(['id' => $to_user_id])->value('nickname')??'未知用户';
|
||||
|
||||
98
application/api/model/UserDailyIncome.php
Normal file
98
application/api/model/UserDailyIncome.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class UserDailyIncome extends Model
|
||||
{
|
||||
// 定义表名(如果表名和模型名一致可省略,这里显式定义更清晰)
|
||||
protected $name = 'user_daily_income';
|
||||
|
||||
// 开启自动时间戳(TP5.1默认用时间戳格式,对应create_time/update_time)
|
||||
protected $autoWriteTimestamp = true;
|
||||
|
||||
// 定义字段类型转换(确保金额为浮点型)
|
||||
protected $type = [
|
||||
'income' => 'float',
|
||||
'user_id' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* 累加用户当日收益(核心方法)
|
||||
* @param int $userId 用户ID
|
||||
* @param float $amount 新增收益金额(正数)
|
||||
* @return bool
|
||||
*/
|
||||
public function addDailyIncome($userId, $amount)
|
||||
{
|
||||
$today = date('Y-m-d'); // 今日日期
|
||||
|
||||
$today_res = $this->where([
|
||||
'user_id' => $userId,
|
||||
'date' => $today
|
||||
])->find();
|
||||
if($today_res){
|
||||
$res = $this->where([
|
||||
'user_id' => $userId,
|
||||
'date' => $today
|
||||
])->update([
|
||||
'income' => $amount,
|
||||
'update_time'=> time(),
|
||||
]);
|
||||
if($res){return true;}
|
||||
}else{
|
||||
$res = $this->insert([
|
||||
'user_id' => $userId,
|
||||
'income' => $amount,
|
||||
'date' => $today,
|
||||
'create_time'=> time(),
|
||||
'update_time'=> time(),
|
||||
]);
|
||||
if($res){return true;}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户今日收益
|
||||
* @param int $userId 用户ID
|
||||
* @param string $today 日期(格式:YYYY-MM-DD)
|
||||
* @return float 今日收益(无收益则返回0)
|
||||
*/
|
||||
public function getTodayIncome($userId, $today = 0)
|
||||
{
|
||||
if (!$today) {
|
||||
$today = date('Y-m-d');
|
||||
}
|
||||
$result = $this->where([
|
||||
'user_id' => $userId,
|
||||
'date' => $today
|
||||
])->value('income');
|
||||
|
||||
return $result ? floatval($result) : 0.00;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户时间段内的收益总和
|
||||
* @param int $userId 用户ID
|
||||
* @param string $startDate 开始日期(格式:YYYY-MM-DD)
|
||||
* @param string $endDate 结束日期(格式:YYYY-MM-DD)
|
||||
* @return float 时间段总收益(无收益则返回0)
|
||||
*/
|
||||
public function getIncomeByPeriod($userId, $startDate, $endDate)
|
||||
{
|
||||
// 校验日期格式(可选,增强健壮性)
|
||||
if (!strtotime($startDate) || !strtotime($endDate)) {
|
||||
return 0.00;
|
||||
}
|
||||
|
||||
$total = $this->where([
|
||||
'user_id' => $userId,
|
||||
'date' => ['between', [$startDate, $endDate]]
|
||||
])->sum('income');
|
||||
|
||||
return $total ? floatval($total) : 0.00;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -91,13 +91,13 @@ class UserData extends Model
|
||||
|
||||
$reslut = model('User')->update($data);
|
||||
if ($reslut) {
|
||||
$cache_key = 'user_base_info_'.$uid;
|
||||
Cache::rm($cache_key);
|
||||
$user_info = model('User')->where('id', $uid)->field('id,nickname,avatar,user_code')->find();
|
||||
//给腾讯同步用户信息
|
||||
$member_name = $user_info['nickname'];
|
||||
$member_face_url = $user_info['avatar'];
|
||||
model('Tencent')->modify_user_infos($uid, $member_name, $member_face_url);
|
||||
$cache_key = 'user_base_info_'.$uid;
|
||||
Cache::rm($cache_key);
|
||||
return ['code' => 1, 'msg' => '修改成功', 'data' => $user_info];
|
||||
} else {
|
||||
return ['code' => 0, 'msg' => '修改失败,','data' =>null];
|
||||
@@ -283,7 +283,10 @@ class UserData extends Model
|
||||
}else{
|
||||
$is_real = false;
|
||||
}
|
||||
|
||||
$mobile_count = db::name('user')->where(['mobile' => $new_mobile,'status'=>1])->count('id');
|
||||
if($mobile_count>=2){
|
||||
return ['code' => 0, 'msg' => '该手机号已存在两个以上的账号!请使用其他手机号!','data' =>null];
|
||||
}
|
||||
if($is_real){
|
||||
//开启事务
|
||||
db::startTrans();
|
||||
@@ -314,9 +317,14 @@ class UserData extends Model
|
||||
return ['code' => 0, 'msg' => '请先绑定手机号','data' =>null];
|
||||
}
|
||||
$card_id_count = db::name('user_auth')->where(['card_id' => $id_card,'is_real' => 1])->count();
|
||||
if($card_id_count >= 3){
|
||||
if($card_id_count >= 2){
|
||||
return ['code' => 0, 'msg' => '该身份证实名已达上限!','data' =>null];
|
||||
}
|
||||
$mobile_count = db::name('user')->where(['mobile' => $user_mobile,'status'=>1])->count('id');
|
||||
$user_auth_count = db::name('user_auth')->where(['mobile' => $user_mobile,'is_real' => 1])->count();
|
||||
if($mobile_count >= 2 && $user_auth_count > 0){
|
||||
return ['code' => 0, 'msg' => '该手机号已绑定多个账号!请勿重复注册!','data' =>null];
|
||||
}
|
||||
//查询是否已经提交过数据了
|
||||
$is_real = db::name('user_auth')->where(['card_id' => $id_card,'mobile' =>$user_mobile])->find();
|
||||
if($is_real){
|
||||
@@ -408,6 +416,7 @@ class UserData extends Model
|
||||
}
|
||||
//任务:3-实名认证
|
||||
model('Tasks')->tasks_complete($user_id,3);
|
||||
Cache::rm('user_base_info_'.$user_id);
|
||||
|
||||
return ['code' => 1, 'msg' => '实名成功','data' =>null];
|
||||
}
|
||||
@@ -415,7 +424,7 @@ class UserData extends Model
|
||||
//实名认证后的信息
|
||||
public function real_name_info($user_id)
|
||||
{
|
||||
$mobile = db::name('user')->where(['id' => $user_id,'status'=>1])->value('mobile');
|
||||
$mobile = db::name('user')->where(['id' => $user_id])->value('mobile');
|
||||
$data = db::name('user_auth')->where('mobile' , $mobile)->field('real_name,card_id,is_real,mobile')->find();
|
||||
if(!$data){
|
||||
return ['code' => 0, 'msg' => '未实名','data' =>null];
|
||||
@@ -583,17 +592,18 @@ class UserData extends Model
|
||||
public function bind_xinxi($user_id,$type,$alipay_account,$bank_card_number,$bank_user_name,$bank_card,$open_bank)
|
||||
{
|
||||
//查询是否实名认证
|
||||
$is_real = model('UserData')->real_name_info($user_id);
|
||||
if($is_real['code']==0){
|
||||
$mobile = db::name('user')->where(['id' => $user_id])->value('mobile');
|
||||
$is_real = db::name('user_auth')->where('mobile' , $mobile)->field('real_name,card_id,is_real,mobile')->find();
|
||||
if(empty($is_real)){
|
||||
return ['code' => 0, 'msg' => '请先实名认证','data' => null];
|
||||
}else{
|
||||
if($is_real['data']['is_real'] !=1){
|
||||
return ['code' => 0, 'msg' => '请先实名认证','data' => null];
|
||||
}else {
|
||||
if ($is_real['is_real'] != 1) {
|
||||
return ['code' => 0, 'msg' => '请先实名认证', 'data' => null];
|
||||
}
|
||||
}
|
||||
if($type == 2){
|
||||
$data = [
|
||||
'alipay_name' => $is_real['data']['real_name'],// 姓名
|
||||
'alipay_name' => $is_real['real_name'],// 姓名
|
||||
'alipay_account' => $alipay_account,// 支付宝账号
|
||||
];
|
||||
$reslut = db::name('user_data')->where('user_id',$user_id)->update($data);
|
||||
@@ -617,7 +627,7 @@ class UserData extends Model
|
||||
}
|
||||
$data = [
|
||||
'bank_card_number' => $bank_card_number,
|
||||
'bank_user_name' => $bank_user_name ? $bank_user_name : $is_real['data']['real_name'],
|
||||
'bank_user_name' => $bank_user_name ? $bank_user_name : $is_real['real_name'],
|
||||
'bank_card' => $bank_card,
|
||||
'open_bank' => $open_bank,
|
||||
];
|
||||
@@ -646,10 +656,10 @@ class UserData extends Model
|
||||
{
|
||||
$data = null;
|
||||
if($type == 2){
|
||||
$data = db::name('user_data')->where('user_id',$user_id)->field('id,alipay_name,alipay_account')->find();
|
||||
$data = db::name('user_data')->where('user_id',$user_id)->field('id,bank_card_number,alipay_name,alipay_account,bank_user_name,bank_card,open_bank')->find();
|
||||
}
|
||||
if($type == 3){
|
||||
$data = db::name('user_data')->where('user_id',$user_id)->field('id,bank_card_number,bank_user_name,bank_card,open_bank')->find();
|
||||
$data = db::name('user_data')->where('user_id',$user_id)->field('id,bank_card_number,alipay_name,alipay_account,bank_user_name,bank_card,open_bank')->find();
|
||||
}
|
||||
if($data['bank_card_number']==0){
|
||||
$data['bank_card_number'] = '';
|
||||
|
||||
@@ -65,6 +65,7 @@ class UserMessage extends Model
|
||||
$system_message1 = db::name('system_message')
|
||||
->field('id')
|
||||
->where($map)
|
||||
->where(['delete_time' => 0])
|
||||
->where('FIND_IN_SET(:user_id, receiving_id)', ['user_id' => $uid])
|
||||
->select();
|
||||
|
||||
@@ -142,6 +143,7 @@ class UserMessage extends Model
|
||||
|
||||
//获取消息
|
||||
$list = db::name('system_message')
|
||||
->field('id,type,title,content,url,admin_id,image,createtime,room_id,user_id,remind_type,status,updatetime')
|
||||
->where($where)
|
||||
->where('FIND_IN_SET(:user_id, receiving_id)', ['user_id' => $uid])
|
||||
->order('id desc')
|
||||
|
||||
@@ -23,17 +23,17 @@ class UserToken extends Model
|
||||
$block1 = db::name('block')->where(['type' => 1,'type_text' => $user_token['user_id']])->find();
|
||||
$userState = db::name('user')->where(['id' => $user_token['user_id']])->value('status');
|
||||
if(isset($block1) || $userState == 2){
|
||||
return ['code' => 204, 'msg'=> '账号已被封禁,请联系管理员','data' => null];
|
||||
return ['code' => 301, 'msg'=> '账号已被封禁,请联系管理员','data' => null];
|
||||
}
|
||||
$login_device = request()->header('deviceId');
|
||||
$block2 = db::name('block')->where(['type' => 2,'type_text' => $login_device])->find();
|
||||
if(isset($block2)){
|
||||
return ['code' => 205, 'msg'=> '设备已被封禁,请联系管理员','data' => null];
|
||||
return ['code' => 301, 'msg'=> '设备已被封禁,请联系管理员','data' => null];
|
||||
}
|
||||
$Ip = request()->ip();
|
||||
$block3 = db::name('block')->where(['type' => 3,'type_text' => $Ip])->find();
|
||||
if(isset($block3)){
|
||||
return ['code' => 206, 'msg'=> 'IP已被封禁,请联系管理员','data' => null];
|
||||
return ['code' => 301, 'msg'=> 'IP已被封禁,请联系管理员','data' => null];
|
||||
}
|
||||
|
||||
return ['code' => 1, 'msg'=> '成功','data' => $user_token['user_id']];
|
||||
@@ -82,6 +82,16 @@ class UserToken extends Model
|
||||
return ['code' => 0, 'msg'=> 'token更新失败'];
|
||||
}
|
||||
}else{
|
||||
//查询有多少个信息
|
||||
$user_token = db::name('user_token')->where('user_id', $user_id)->select();
|
||||
if(count($user_token) > 1){
|
||||
//删除多余的token
|
||||
foreach ($user_token as $key => $value) {
|
||||
if($value['id'] != $data_token['id']){
|
||||
$this->where('id', $value['id'])->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!($this->where('user_id', $user_id)->update(['token' => $tokenString, 'expiretime' => $expiretime]))){
|
||||
return ['code' => 0, 'msg'=> 'token更新失败'];
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Cache;
|
||||
use think\Db;
|
||||
use think\Log;
|
||||
use think\Model;
|
||||
use Yzh\YunPay;
|
||||
|
||||
@@ -11,8 +13,14 @@ class UserWallet extends Model
|
||||
{
|
||||
public function create_data($uid)
|
||||
{
|
||||
$insert_data = ['user_id' => $uid];
|
||||
return Db::name('user_wallet')->insert($insert_data);
|
||||
$insert_data = ['user_id' => $uid, 'createtime' => time()];
|
||||
$coin = Db::name('user_wallet_coin')->insert($insert_data);
|
||||
$earnings = Db::name('user_wallet_earnings')->insert($insert_data);
|
||||
if($coin && $earnings){
|
||||
return true ;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//钱包
|
||||
@@ -21,8 +29,9 @@ class UserWallet extends Model
|
||||
if(!isset($uid)){
|
||||
return ['code' => 301, 'msg' => '登录失效,请重新登录!', 'data' => null];
|
||||
}
|
||||
|
||||
$user_info = db::name('user_wallet')->where('user_id', $uid)->find();
|
||||
// $user_info = db::name('user_wallet')->where('user_id', $uid)->find();
|
||||
$user_info['coin'] = db::name('user_wallet_coin')->where('user_id', $uid)->sum('coin');
|
||||
$user_info['earnings'] = db::name('user_wallet_earnings')->where('user_id', $uid)->sum('earnings');
|
||||
//获取云账号签约协议
|
||||
$yun_pay = new YunPay();
|
||||
$yun_pay_agreement = $yun_pay->getAgreementPreviewUrl();
|
||||
@@ -40,52 +49,64 @@ class UserWallet extends Model
|
||||
}
|
||||
|
||||
//金币/钻石 明细
|
||||
public function log_list($uid, $page, $page_limit,$in_out_type,$start_time,$end_time,$gift_type)
|
||||
//change_type
|
||||
// 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-爵位购买赠送金币(金币),40-后台充值金币,41-后台充值钻石,42-后台扣除金币,43-后台扣除钻石,
|
||||
//50-签约,51-签约失败退回,52-首次被签约收入,53.签约师傅每日返还,54-叛徒补偿,55-徒弟收礼返佣,56-续约,57-签到,58-爆币,59-红包手续费
|
||||
public function log_list($uid, $last_id, $page_limit,$in_out_type,$start_time,$end_time,$gift_type)
|
||||
{
|
||||
$page = intval($page);
|
||||
$page_limit = $page_limit < 30 ? $page_limit : 30;
|
||||
$map = [];
|
||||
$map['money_type'] = $gift_type;//1金币,2收益(钻石)
|
||||
$in_out_types = [];
|
||||
// 1.系统调节 2.充值 3.提现 4.金币转增(送出) 5.每日任务奖励 6.充值返利 7.购买装扮
|
||||
// 8.礼盒奖励 9.房间补贴 10.购买礼物 11.收礼增加收益 12.工会补贴 13.转赠金币(接收) 14.收益兑换
|
||||
// 15.首充 16.天降好礼充值 17.退出工会扣款 18.房主收益 19.主持人收益,20.发布头条扣除余额,21.公会长收益,22.提现驳回或提现失败返还,23.财富等级奖励金币领取,24.删除关系扣金币
|
||||
//27.小时榜获得,28-新人充值好礼,32-发红包(金币),29-发红包(钻石),30-抢红包(金币),31-抢红包(钻石) 33-红包剩余退回(金币),34-红包剩余退回(钻石)
|
||||
//50-签约 51-签约失败退回,52-首次被签约收入 53-师徒签到 54-叛徒补偿,55-徒弟收礼返佣,56-续约,57签到,58爆币
|
||||
if($gift_type == 1){ //1金币,2收益(钻石)
|
||||
if($in_out_type == 1){//1收入
|
||||
$in_out_types = [2,5,6,8,13,14,15,16,22,23,26,27,30,28,33,51,57,58];
|
||||
}elseif($in_out_type == 2){//2支出
|
||||
$in_out_types = [4,7,10,17,20,24,25,32,50,56];
|
||||
}
|
||||
}elseif($gift_type == 2){ //1金币,2收益(钻石)
|
||||
if($in_out_type == 1){//1收入
|
||||
$in_out_types = [6,9,11,12,18,19,21,22,31,28,34,52,53,54,55,57];
|
||||
}elseif($in_out_type == 2){//2支出
|
||||
$in_out_types = [3,14,29];
|
||||
}
|
||||
}
|
||||
|
||||
$map['change_type'] = ['in', $in_out_types];
|
||||
$map['user_id'] =$uid;
|
||||
|
||||
// 时间范围处理
|
||||
if (!empty($start_time) && !empty($end_time)) {
|
||||
$start_time = strtotime($start_time);
|
||||
$end_time = strtotime($end_time.' 23:59:59');
|
||||
$end_time = strtotime($end_time);
|
||||
$map['createtime'] = ['between', [$start_time, $end_time]];
|
||||
}
|
||||
|
||||
$list = Db::name('vs_user_money_log')
|
||||
->where($map)
|
||||
->field('log_id, user_id, change_type, change_value, remarks, createtime')
|
||||
->order('log_id desc')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
foreach ($list as $key => &$value) {
|
||||
$value['change_type_name'] = model('common/UserWallet')->ChangeTypeLable($value['change_type']);
|
||||
if($in_out_type==2){
|
||||
$value['change_value'] = $value['change_value'] * -1;
|
||||
$map['user_id'] =$uid;
|
||||
if ($last_id > 0) {
|
||||
$map['id'] = ['<', $last_id]; // 下一页:只查id小于上一页最后一个id的记录
|
||||
}
|
||||
|
||||
//1-金币
|
||||
if($gift_type == 1){
|
||||
//1-收入
|
||||
if($in_out_type == 1){
|
||||
$in_out_types = [2,5,6,8,13,14,15,16,22,23,26,27,30,28,33,40,44,51,57,58];
|
||||
$map['change_type'] = ['in', $in_out_types];
|
||||
}else{//2-支出
|
||||
$in_out_types = [4,7,10,17,20,24,25,32,42,50,56,59];
|
||||
$map['change_type'] = ['in', $in_out_types];
|
||||
}
|
||||
|
||||
$list = Db::name('user_coin_log')
|
||||
->where($map)
|
||||
->field('id,change_type, coin as change_value, remarks, createtime')
|
||||
->order('id desc')
|
||||
->limit($page_limit) // 只取指定条数,无offset
|
||||
->select();
|
||||
foreach ($list as &$value) {
|
||||
$value['change_type_name'] = model('common/UserWallet')->ChangeTypeLable($value['change_type']);
|
||||
}
|
||||
}else{//-2收益(钻石)
|
||||
//1-收入
|
||||
if($in_out_type == 1){
|
||||
$in_out_types = [9,11,12,18,19,21,22,31,28,34,41,52,53,54,55,57];
|
||||
$map['change_type'] = ['in', $in_out_types];
|
||||
}else{//2-支出
|
||||
$in_out_types = [3,14,29,43];
|
||||
$map['change_type'] = ['in', $in_out_types];
|
||||
}
|
||||
$list = Db::name('user_earnings_log')
|
||||
->where($map)
|
||||
->field('id,change_type, earnings as change_value, remarks, createtime')
|
||||
->order('id desc')
|
||||
->limit($page_limit) // 只取指定条数,无offset
|
||||
->select();
|
||||
foreach ($list as &$value) {
|
||||
$value['change_type_name'] = model('common/UserWallet')->ChangeTypeLable($value['change_type']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,6 +116,13 @@ class UserWallet extends Model
|
||||
//收益(钻石)兑换金币
|
||||
public function exchange_coin($uid, $earnings_num)
|
||||
{
|
||||
//从缓存中获取
|
||||
$exchange_user = Cache::get('exchange_user_' . $uid);
|
||||
if($exchange_user){
|
||||
return ['code' => 0, 'msg' => '手速太快了', 'data' => null];
|
||||
}else{
|
||||
Cache::set('exchange_user_' . $uid, 1, 5);
|
||||
}
|
||||
if(empty($earnings_num)){
|
||||
return ['code' => 0, 'msg' => '请输入需要兑换的钻石数量', 'data' => null];
|
||||
}
|
||||
@@ -103,12 +131,14 @@ class UserWallet extends Model
|
||||
return ['code' => 0, 'msg' => '请输入正确的钻石数量', 'data' => null];
|
||||
}
|
||||
//判断用户的钻石数量是否大于等于兑换数量
|
||||
$user_info = db::name('user_wallet')->where('user_id',$uid)->find();
|
||||
$user_info = db::name('user_wallet_earnings')->where('user_id',$uid)->find();
|
||||
if($user_info['earnings'] < $earnings_num){
|
||||
return ['code' => 0, 'msg' => '钻石数量不足', 'data' => null];
|
||||
}
|
||||
|
||||
$ear_exchange_coin = get_system_config_value('coin_exchange_rate');
|
||||
$coin_num = $earnings_num * $ear_exchange_coin;
|
||||
|
||||
$data = [
|
||||
'user_id' => $uid,
|
||||
'earnings_num' => $earnings_num,
|
||||
@@ -119,30 +149,9 @@ class UserWallet extends Model
|
||||
db::startTrans();
|
||||
try{
|
||||
$give_gift_id = db::name('user_exchange')->insertGetId($data);
|
||||
// 1.系统调节 2.充值 3.提现 4.金币转增(送出) 5.每日任务奖励 6.充值返利 7.购买装扮
|
||||
// 8.礼盒奖励 9.房间补贴 10.购买礼物 11.收礼增加收益 12.工会补贴 13.转赠金币(接收) 14.收益兑换
|
||||
$account_log[] = [
|
||||
'user_id' => $uid,
|
||||
'money_type' => 2,//1金币2钻石
|
||||
'change_value' => $earnings_num,
|
||||
'remarks' => '收益兑换',
|
||||
'change_type' => 14,
|
||||
'createtime' => time(),
|
||||
'from_id' => $give_gift_id,
|
||||
];
|
||||
$account_log[] = [
|
||||
'user_id' => $uid,
|
||||
'money_type' => 1,
|
||||
'change_value' => $earnings_num * $ear_exchange_coin,
|
||||
'remarks' => '收益兑换',
|
||||
'change_type' => 14,
|
||||
'createtime' => time(),
|
||||
'from_id' => $give_gift_id,
|
||||
];
|
||||
$re = db::name('vs_user_money_log')->insertAll($account_log);
|
||||
$re1 = db::name('user_wallet')->where(['user_id' => $uid,'earnings' => ['>=', $earnings_num]])->setDec('earnings',$earnings_num);
|
||||
$re2 = db::name('user_wallet')->where('user_id',$uid)->setInc('coin',$earnings_num * $ear_exchange_coin);
|
||||
if($re && $re1 && $re2){
|
||||
$earn = $this->change_user_earnings_log($uid,$earnings_num,0,14,'收益兑换');
|
||||
$coin = $this->change_user_cion_log($uid,$coin_num,0,14,'收益兑换');
|
||||
if($earn === true && $coin === true){
|
||||
db::commit();
|
||||
return ['code' => 1, 'msg' => '兑换成功', 'data' => null];
|
||||
}else{
|
||||
@@ -153,12 +162,17 @@ class UserWallet extends Model
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '兑换失败', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//转币
|
||||
public function give_coin($uid, $give_uid, $coin){
|
||||
//从缓存中获取
|
||||
$exchange_user = Cache::get('give_coin_user_' . $uid);
|
||||
if($exchange_user){
|
||||
return ['code' => 0, 'msg' => '请5分钟后再试', 'data' => null];
|
||||
}else{
|
||||
Cache::set('give_coin_user_' . $uid, 1, 5 * 60);
|
||||
}
|
||||
if(empty($coin)){
|
||||
return ['code' => 0, 'msg' => '请输入需要转的金币数量', 'data' => null];
|
||||
}
|
||||
@@ -204,4 +218,166 @@ class UserWallet extends Model
|
||||
return ['code' => 0, 'msg' => '转赠失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*操作用户金币并记录日志
|
||||
* @param int $user_id 用户id
|
||||
* @param int $money 金币数量
|
||||
* @param int $change_type 变动类型
|
||||
* @param int $room_id 房间
|
||||
* @param str $remarks 备注
|
||||
*/
|
||||
//change_type
|
||||
// 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-爵位购买赠送金币(金币),,40-后台充值金币,41-后台充值钻石,42-后台扣除金币,43-后台扣除钻石,
|
||||
//50-签约,51-签约失败退回,52-首次被签约收入,53.签约师傅每日返还,54-叛徒补偿,55-徒弟收礼返佣,56-续约,57-签到,58-爆币,59-红包手续费
|
||||
//资金操作
|
||||
public function change_user_cion_log($user_id,$money,$room_id,$change_type,$remarks)
|
||||
{
|
||||
//增加用户金币类型
|
||||
$in_types = [2,5,6,8,13,14,15,16,23,26,27,28,30,33,35,40,51,57,58];
|
||||
//减少用户金币类型
|
||||
$out_types = [4,7,10,17,20,24,25,32,42,50,56,59];
|
||||
|
||||
$user_wallet = Db::name('user_wallet_coin')->where(['user_id' => $user_id])->lock(true)->find();
|
||||
if (!$user_wallet) {
|
||||
return false;
|
||||
}
|
||||
$user_coin = $user_wallet['coin'];
|
||||
$original_coin = $user_coin; // 保存原始值用于日志
|
||||
|
||||
if(in_array($change_type,$in_types)){
|
||||
$update_coin = $user_coin + $money;
|
||||
}elseif(in_array($change_type,$out_types)){
|
||||
if($user_coin < $money){
|
||||
return false;
|
||||
}
|
||||
$update_coin = $user_coin - $money;
|
||||
}else{
|
||||
$update_coin = $user_coin;
|
||||
}
|
||||
$res1 = Db::name('user_wallet_coin')->where(['user_id' => $user_id])->update(['coin' => $update_coin,'updatetime' => time()]);
|
||||
if(!$res1){
|
||||
return false;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'user_id' => $user_id,
|
||||
'room_id' => $room_id,
|
||||
'coin' => $money,
|
||||
'before' => $original_coin,
|
||||
'after' => $update_coin,
|
||||
'change_type' => $change_type,
|
||||
'remarks' => $remarks,
|
||||
'createtime' => time()
|
||||
];
|
||||
|
||||
$res = Db::name('user_coin_log')->insert($data);
|
||||
if(!$res){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*操作用户收益(钻石)并记录日志
|
||||
* @param int $user_id 用户id
|
||||
* @param int $money 数量
|
||||
* @param int $change_type 变动类型
|
||||
* @param int $room_id 房间
|
||||
* @param str $remarks 备注
|
||||
*/
|
||||
//change_type
|
||||
// 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-爵位购买赠送金币(金币),40-后台充值金币,41-后台充值钻石,42-后台扣除金币,43-后台扣除钻石,
|
||||
//50-签约,51-签约失败退回,52-首次被签约收入,53.签约师傅每日返还,54-叛徒补偿,55-徒弟收礼返佣,56-续约,57-签到,58-爆币,59-红包手续费
|
||||
|
||||
//bcadd: 加法运算
|
||||
//bcsub: 减法运算
|
||||
//bcmul: 乘法运算
|
||||
//bcdiv: 除法运算
|
||||
public function change_user_earnings_log($user_id,$money,$room_id,$change_type,$remarks)
|
||||
{
|
||||
//增加用户钻石类型
|
||||
$in_types = [9,11,12,18,19,21,22,31,28,34,41,52,53,54,55,57];
|
||||
|
||||
//减少用户钻石类型
|
||||
$out_types = [3,14,29,43];
|
||||
$user_wallet = Db::name('user_wallet_earnings')->where(['user_id' => $user_id])->lock(true)->find();
|
||||
if(!$user_wallet){
|
||||
return false;
|
||||
}
|
||||
$user_earnings = $user_wallet['earnings'];
|
||||
$original_coin = $user_earnings; // 保存原始值用于日志
|
||||
|
||||
$money = $this ->formatScientificNumber($money);
|
||||
// Log::record("计算收益:".$money,"info");
|
||||
if(in_array($change_type,$in_types)){
|
||||
$update_coin = bcadd($user_earnings , $money,4);
|
||||
}elseif(in_array($change_type,$out_types)){
|
||||
if($user_earnings < $money){
|
||||
return false;
|
||||
}
|
||||
$update_coin = bcsub($user_earnings , $money,4);
|
||||
}else{
|
||||
$update_coin = $user_earnings;
|
||||
}
|
||||
$res1 = Db::name('user_wallet_earnings')->where(['user_id' => $user_id])->update(['earnings' => $update_coin,'updatetime' => time()]);
|
||||
if(!$res1){
|
||||
return false;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'user_id' => $user_id,
|
||||
'room_id' => $room_id,
|
||||
'earnings' => $money,
|
||||
'before' => $original_coin,
|
||||
'after' => $update_coin,
|
||||
'change_type' => $change_type,
|
||||
'remarks' => $remarks,
|
||||
'createtime' => time()
|
||||
];
|
||||
|
||||
$res = Db::name('user_earnings_log')->insert($data);
|
||||
if(!$res){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function formatScientificNumber($num) {
|
||||
// 1. 先将数值转为字符串,方便正则匹配
|
||||
$numStr = (string)$num;
|
||||
|
||||
// 2. 正则匹配科学计数法格式(匹配 E/e 开头的科学计数法,包含正负指数)
|
||||
$scientificPattern = '/^[+-]?\d+(\.\d+)?[Ee][+-]?\d+$/';
|
||||
|
||||
// 3. 判断是否是科学计数法
|
||||
if (preg_match($scientificPattern, $numStr)) {
|
||||
// 是科学计数法,转换为浮点数后保留4位小数
|
||||
$floatNum = (float)$numStr;
|
||||
// 保留4位小数,四舍五入,确保格式正确
|
||||
$result = number_format($floatNum, 4, '.', '');
|
||||
// echo "检测到科学计数法数值,处理后结果:{$result}\n";
|
||||
} else {
|
||||
// 不是科学计数法,直接保留4位小数(兼容普通数值)
|
||||
$floatNum = (float)$numStr;
|
||||
$result = number_format($floatNum, 4, '.', '');
|
||||
// echo "非科学计数法数值,处理后结果:{$result}\n";
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -149,7 +149,7 @@ class UserWithdrawal extends Model
|
||||
return ['code' => 0, 'msg' => "请重试2", 'data' => null];
|
||||
}
|
||||
//修改提现余额
|
||||
$surplus_earnings = Db::name('user_wallet')->where('user_id', $user_id)->value('earnings');
|
||||
$surplus_earnings = Db::name('user_wallet_earnings')->where('user_id', $user_id)->value('earnings');
|
||||
if ($surplus_earnings > 0) {
|
||||
$surplus_earnings = $surplus_earnings / $diamond_to_rmb_ratio; //剩余金额(人民币)
|
||||
}
|
||||
@@ -180,6 +180,12 @@ class UserWithdrawal extends Model
|
||||
*/
|
||||
public function withdrawal_fail($order_id){
|
||||
$withdraw_info = db::name('vs_user_withdrawal')->where('order_sn', $order_id)->find();
|
||||
if (empty($withdraw_info)) {
|
||||
return ['code' => 0, 'msg' => '提现订单不存在'];
|
||||
}
|
||||
if ($withdraw_info['refund_time'] != 0) {
|
||||
return ['code' => 0, 'msg' => '订单已处理过退款'];
|
||||
}
|
||||
//退回提现金额(释放冻结金额)
|
||||
//钻石兑换人民币比例
|
||||
$diamond_to_rmb_ratio = get_system_config_value('diamond_to_rmb_ratio');
|
||||
@@ -193,6 +199,8 @@ class UserWithdrawal extends Model
|
||||
if ($reslut['code'] != 1) {
|
||||
return ['code' => 0, 'msg' => $reslut['msg']];
|
||||
}
|
||||
//修改退款时间
|
||||
db::name('vs_user_withdrawal')->where('wid', $withdraw_info['wid'])->update(['refund_time' => time()]);
|
||||
return ['code' => 1, 'msg' => '成功'];
|
||||
}
|
||||
/*
|
||||
|
||||
@@ -305,7 +305,7 @@ class UserZone extends Model
|
||||
//今天的第一条评论奖励
|
||||
$first_comment = db::name('user_zone_comment')->where(['user_id' => $uid, 'createtime' => ['between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]]])->count();
|
||||
if ($first_comment ==1) {
|
||||
model('DailyTasks')->tasks_complete($uid,5);
|
||||
model('api/DailyTasks')->tasks_complete($uid,5);
|
||||
}
|
||||
// }
|
||||
//增加评论数量
|
||||
|
||||
@@ -21,4 +21,7 @@ return [
|
||||
'gift:migration' => 'app\common\command\GiftMigration',
|
||||
'process:gift_queue' => 'app\common\command\ProcessGiftQueue',
|
||||
'queue:monitor' => 'app\common\command\QueueMonitor',
|
||||
'migrate:money_log' => 'app\common\command\MigrateMoneyLog',
|
||||
'giftwall:migration' => 'app\common\command\GiftWallMigration',
|
||||
|
||||
];
|
||||
|
||||
@@ -1152,27 +1152,31 @@ function handelCharge($where,$data){
|
||||
//充值任务
|
||||
model('api/Tasks')->tasks_complete($orderModel['user_id'],12);
|
||||
model('Nobility')->buyNobility($orderModel['user_id'],$orderModel['nobility_id']);
|
||||
//查询是否首充
|
||||
$is_first_charge = db::name('vs_user_recharge')
|
||||
->where(['user_id' => $orderModel['user_id'],'pay_status' => 2])
|
||||
->count();
|
||||
//首充
|
||||
if($is_first_charge == 1){
|
||||
model('Activities')->first_charge_gift_send($orderModel['user_id'],$orderModel['money']);
|
||||
}
|
||||
return 1;
|
||||
}else{//充值
|
||||
db::startTrans();
|
||||
try{
|
||||
$userModel = db::name('user_wallet')->where('user_id',$orderModel['user_id'])->find();
|
||||
$userModel = db::name('user_wallet_coin')->where('user_id',$orderModel['user_id'])->find();
|
||||
if(!$userModel){
|
||||
return 0;
|
||||
}
|
||||
|
||||
//每天任意充值金额
|
||||
model('DailyTasks')->tasks_complete($orderModel['user_id'],4);
|
||||
|
||||
//增加余额
|
||||
$res = db::name('user_wallet')->where('user_id',$orderModel['user_id'])->update([
|
||||
'coin' => $userModel['coin'] + $orderModel['coin'],
|
||||
'updatetime' => time()
|
||||
]);
|
||||
if(!$res){
|
||||
db::rollback();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//增加余额并记录日志
|
||||
$wallet_update = model('api/UserWallet')->change_user_cion_log($orderModel['user_id'],$orderModel['coin'],0,2,'充值');
|
||||
if(!$wallet_update){
|
||||
Db::rollback();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//修改订单状态
|
||||
$res1 = db::name('vs_user_recharge')->where($where)->update([
|
||||
'pay_status' => 2,
|
||||
@@ -1184,40 +1188,25 @@ function handelCharge($where,$data){
|
||||
db::rollback();
|
||||
return 0;
|
||||
}
|
||||
//查询是否首充
|
||||
$is_first_charge = db::name('vs_user_money_log')->where('user_id',$orderModel['user_id'])->where('change_type',2)->where('money_type',1)->where(['createtime'=>['>=',"1760666400"]])->count();
|
||||
//添加充值记录
|
||||
$res2 = db::name('vs_user_money_log')->insert([
|
||||
'user_id' => $orderModel['user_id'],
|
||||
'change_type' => 2,
|
||||
'money_type' => 1,
|
||||
'change_value' => $orderModel['coin'],
|
||||
'from_id' => $orderModel['rid'],
|
||||
'remarks' => '充值',
|
||||
'createtime' => time()
|
||||
]);
|
||||
if(!$res2){
|
||||
db::rollback();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//给上级返佣
|
||||
//获取上级
|
||||
//给上级返佣 //获取上级
|
||||
$invited_user_id = db::name('vs_user_invited')->where('sub_user_id', $orderModel['user_id'])->value('user_id');
|
||||
if($invited_user_id){
|
||||
$re3 = model('Invited')->invited_reward($orderModel['user_id'],$orderModel['coin']);
|
||||
$re3 = model('api/Invited')->invited_reward($orderModel['user_id'],$orderModel['coin'],$invited_user_id);
|
||||
if($re3['code'] != 1){
|
||||
db::rollback();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
db::commit();
|
||||
//充值任务
|
||||
model('api/Tasks')->tasks_complete($orderModel['user_id'],12);
|
||||
db::commit();
|
||||
|
||||
//活动
|
||||
//查询是否首充
|
||||
$is_first_charge = db::name('vs_user_recharge')
|
||||
->where(['user_id' => $orderModel['user_id'],'pay_status' => 2])
|
||||
->count();
|
||||
//首充
|
||||
if($is_first_charge == 0){
|
||||
if($is_first_charge == 1){
|
||||
model('Activities')->first_charge_gift_send($orderModel['user_id'],$orderModel['money']);
|
||||
}
|
||||
//活动
|
||||
@@ -1235,25 +1224,32 @@ function handelCharge($where,$data){
|
||||
//新人好礼
|
||||
model('Activities')->new_charge_gift_send($orderModel['user_id'],$orderModel['money']);
|
||||
}
|
||||
|
||||
return 1;
|
||||
} catch (\Exception $e){
|
||||
db::rollback();
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//计算收益 10% 因为金币10 = 1元 收益 1钻石 = 1元
|
||||
|
||||
// @param $all_gift_price 礼物总价单位金币
|
||||
// @param $ratio 收益比例
|
||||
// @return int 收益单位钻石
|
||||
// @param $ratio 收益比例
|
||||
// @return float 收益(单位钻石)
|
||||
//bcadd: 加法运算
|
||||
//bcsub: 减法运算
|
||||
//bcmul: 乘法运算
|
||||
//bcdiv: 除法运算
|
||||
function coin_earning($all_gift_price,$ratio){
|
||||
//rmb_coin_ratio 人民币转换金币的比例
|
||||
//金币转换人民币
|
||||
//小数点保留4位
|
||||
$result = $all_gift_price * $ratio / 100 / get_system_config_value('rmb_coin_ratio');
|
||||
return round($result, 4);
|
||||
//百分比转换为小数
|
||||
$ratio = $ratio / 100;
|
||||
//应得金币
|
||||
$coin_earning = bcmul($all_gift_price, $ratio, 3);
|
||||
//金币转为钻石的比例
|
||||
$c_e_ratio = get_system_config_value('rmb_coin_ratio');
|
||||
//转化为钻石(小数点保留4位)
|
||||
return bcdiv($coin_earning, $c_e_ratio, 4);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
287
application/common/command/GiftWallMigration.php
Normal file
287
application/common/command/GiftWallMigration.php
Normal file
@@ -0,0 +1,287 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\command;
|
||||
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\Output;
|
||||
use think\Db;
|
||||
|
||||
class GiftWallMigration extends Command
|
||||
{
|
||||
// 每批处理的数据量
|
||||
protected $batchSize = 10000;
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('giftwall:migration')
|
||||
->setDescription('迁移送礼数据到礼物墙');
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
$output->writeln('开始迁移送礼数据到礼物墙...');
|
||||
|
||||
// 第一步:创建临时表存储汇总数据
|
||||
$this->createTempTable($output);
|
||||
|
||||
// 第二步:分批处理原始数据
|
||||
$this->processInBatches($output);
|
||||
|
||||
// 第三步:合并临时表数据到目标表
|
||||
$this->mergeToTargetTable($output);
|
||||
|
||||
// 第四步:清理临时表
|
||||
$this->cleanupTempTable($output);
|
||||
|
||||
$output->writeln('迁移完成!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建临时汇总表
|
||||
*/
|
||||
protected function createTempTable(Output $output)
|
||||
{
|
||||
$output->writeln('创建临时汇总表...');
|
||||
|
||||
$sql = "CREATE TABLE IF NOT EXISTS `temp_gift_wall_summary` (
|
||||
`user_id` int NOT NULL COMMENT '收礼用户',
|
||||
`gift_id` int NOT NULL COMMENT '礼物ID',
|
||||
`total_count` int NOT NULL DEFAULT '0' COMMENT '收到此礼物的总数',
|
||||
`give_user_ids` text COMMENT '送礼用户ID,逗号分隔',
|
||||
PRIMARY KEY (`user_id`, `gift_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4";
|
||||
|
||||
Db::execute($sql);
|
||||
|
||||
// 清空临时表(如果存在旧数据)
|
||||
Db::execute('TRUNCATE TABLE temp_gift_wall_summary');
|
||||
|
||||
$output->writeln('临时表创建完成');
|
||||
}
|
||||
|
||||
/**
|
||||
* 分批处理原始数据
|
||||
*/
|
||||
protected function processInBatches(Output $output)
|
||||
{
|
||||
$output->writeln('开始分批处理原始数据...');
|
||||
|
||||
// 获取总记录数
|
||||
$total = Db::table('fa_vs_give_gift')->count();
|
||||
$output->writeln("总记录数: {$total}");
|
||||
|
||||
// 计算总批次数
|
||||
$totalBatches = ceil($total / $this->batchSize);
|
||||
|
||||
for ($batch = 0; $batch < $totalBatches; $batch++) {
|
||||
$output->writeln("正在处理第 " . ($batch + 1) . "/{$totalBatches} 批...");
|
||||
|
||||
$offset = $batch * $this->batchSize;
|
||||
|
||||
// 分批查询原始数据
|
||||
$records = Db::table('fa_vs_give_gift')
|
||||
->field('user_id, gift_id, gift_user, number')
|
||||
->limit($offset, $this->batchSize)
|
||||
->select();
|
||||
|
||||
if (empty($records)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 处理这批数据
|
||||
$this->processBatchData($records);
|
||||
|
||||
// 释放内存
|
||||
unset($records);
|
||||
|
||||
// 记录进度
|
||||
$processed = min(($batch + 1) * $this->batchSize, $total);
|
||||
$output->writeln("已处理: {$processed}/{$total}");
|
||||
|
||||
// 小休息一下,避免服务器压力过大
|
||||
usleep(100000); // 0.1秒
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理一批数据
|
||||
*/
|
||||
protected function processBatchData($records)
|
||||
{
|
||||
// 按收礼用户和礼物ID分组
|
||||
$groupedData = [];
|
||||
|
||||
foreach ($records as $record) {
|
||||
$key = $record['gift_user'] . '_' . $record['gift_id'];
|
||||
|
||||
if (!isset($groupedData[$key])) {
|
||||
$groupedData[$key] = [
|
||||
'user_id' => $record['gift_user'],
|
||||
'gift_id' => $record['gift_id'],
|
||||
'total_count' => 0,
|
||||
'give_users' => []
|
||||
];
|
||||
}
|
||||
|
||||
// 累加礼物数量
|
||||
$groupedData[$key]['total_count'] += $record['number'];
|
||||
|
||||
// 记录送礼用户(去重会在最后处理)
|
||||
$groupedData[$key]['give_users'][] = $record['user_id'];
|
||||
}
|
||||
|
||||
// 批量插入或更新到临时表
|
||||
$this->batchUpdateTempTable($groupedData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新临时表
|
||||
*/
|
||||
protected function batchUpdateTempTable($groupedData)
|
||||
{
|
||||
if (empty($groupedData)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 开启事务
|
||||
Db::startTrans();
|
||||
|
||||
try {
|
||||
foreach ($groupedData as $data) {
|
||||
// 去重送礼用户ID
|
||||
$uniqueGiveUsers = array_unique($data['give_users']);
|
||||
$giveUserIdsStr = implode(',', $uniqueGiveUsers);
|
||||
|
||||
// 检查是否已存在该记录
|
||||
$exists = Db::table('temp_gift_wall_summary')
|
||||
->where('user_id', $data['user_id'])
|
||||
->where('gift_id', $data['gift_id'])
|
||||
->find();
|
||||
|
||||
if ($exists) {
|
||||
// 更新现有记录
|
||||
$newCount = $exists['total_count'] + $data['total_count'];
|
||||
|
||||
// 合并送礼用户ID(去重)
|
||||
$existingUsers = explode(',', $exists['give_user_ids']);
|
||||
$allUsers = array_merge($existingUsers, $uniqueGiveUsers);
|
||||
$allUsers = array_unique($allUsers);
|
||||
$mergedGiveUserIds = implode(',', $allUsers);
|
||||
|
||||
Db::table('temp_gift_wall_summary')
|
||||
->where('user_id', $data['user_id'])
|
||||
->where('gift_id', $data['gift_id'])
|
||||
->update([
|
||||
'total_count' => $newCount,
|
||||
'give_user_ids' => $mergedGiveUserIds
|
||||
]);
|
||||
} else {
|
||||
// 插入新记录
|
||||
Db::table('temp_gift_wall_summary')
|
||||
->insert([
|
||||
'user_id' => $data['user_id'],
|
||||
'gift_id' => $data['gift_id'],
|
||||
'total_count' => $data['total_count'],
|
||||
'give_user_ids' => $giveUserIdsStr
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并临时表数据到目标表
|
||||
*/
|
||||
protected function mergeToTargetTable(Output $output)
|
||||
{
|
||||
$output->writeln('开始合并数据到目标表...');
|
||||
|
||||
// 获取临时表总记录数
|
||||
$total = Db::table('temp_gift_wall_summary')->count();
|
||||
$output->writeln("需要合并的记录数: {$total}");
|
||||
|
||||
// 分批合并
|
||||
$batchSize = 5000;
|
||||
$totalBatches = ceil($total / $batchSize);
|
||||
|
||||
for ($batch = 0; $batch < $totalBatches; $batch++) {
|
||||
$output->writeln("正在合并第 " . ($batch + 1) . "/{$totalBatches} 批...");
|
||||
|
||||
$offset = $batch * $batchSize;
|
||||
|
||||
// 分批获取临时表数据
|
||||
$records = Db::table('temp_gift_wall_summary')
|
||||
->limit($offset, $batchSize)
|
||||
->select();
|
||||
|
||||
if (empty($records)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 批量插入或更新到目标表
|
||||
foreach ($records as $record) {
|
||||
// 检查目标表是否已存在该记录
|
||||
$exists = Db::table('fa_user_gift_wall')
|
||||
->where('user_id', $record['user_id'])
|
||||
->where('gift_id', $record['gift_id'])
|
||||
->find();
|
||||
|
||||
if ($exists) {
|
||||
// 更新现有记录
|
||||
$newCount = $exists['count'] + $record['total_count'];
|
||||
|
||||
// 合并送礼用户ID(去重)
|
||||
$existingUsers = explode(',', $exists['give_user_ids']);
|
||||
$newUsers = explode(',', $record['give_user_ids']);
|
||||
$allUsers = array_merge($existingUsers, $newUsers);
|
||||
$allUsers = array_unique($allUsers);
|
||||
$mergedGiveUserIds = implode(',', $allUsers);
|
||||
|
||||
Db::table('fa_user_gift_wall')
|
||||
->where('id', $exists['id'])
|
||||
->update([
|
||||
'count' => $newCount,
|
||||
'give_user_ids' => $mergedGiveUserIds,
|
||||
'updatetime' => time()
|
||||
]);
|
||||
} else {
|
||||
// 插入新记录
|
||||
Db::table('fa_user_gift_wall')
|
||||
->insert([
|
||||
'user_id' => $record['user_id'],
|
||||
'gift_id' => $record['gift_id'],
|
||||
'count' => $record['total_count'],
|
||||
'give_user_ids' => $record['give_user_ids'],
|
||||
'updatetime' => time()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// 释放内存
|
||||
unset($records);
|
||||
|
||||
// 小休息一下
|
||||
usleep(50000); // 0.05秒
|
||||
}
|
||||
|
||||
$output->writeln('数据合并完成');
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理临时表
|
||||
*/
|
||||
protected function cleanupTempTable(Output $output)
|
||||
{
|
||||
$output->writeln('清理临时表...');
|
||||
|
||||
Db::execute('DROP TABLE IF EXISTS temp_gift_wall_summary');
|
||||
|
||||
$output->writeln('临时表已清理');
|
||||
}
|
||||
}
|
||||
131
application/common/command/MigrateMoneyLog.php
Normal file
131
application/common/command/MigrateMoneyLog.php
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\command;
|
||||
/**
|
||||
* 资金日志批量迁移脚本(命令行运行)
|
||||
* 执行命令:php think migrate:money_log
|
||||
*/
|
||||
|
||||
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\Output;
|
||||
use think\Db;
|
||||
|
||||
class MigrateMoneyLog extends Command
|
||||
{
|
||||
|
||||
// 配置命令
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('migrate:money_log')
|
||||
->setDescription('批量迁移fa_vs_user_money_log数据到金币/钻石日志表');
|
||||
}
|
||||
|
||||
// 执行逻辑
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
$output->writeln('========== 开始迁移资金日志数据 ==========');
|
||||
|
||||
// 配置参数(可根据服务器性能调整)
|
||||
$batchSize = 1000; // 每批处理1000条,服务器性能好可调大(如2000)
|
||||
$lastLogId = 0; // 从最小的log_id开始(自增主键,避免重复处理)
|
||||
$total = 0; // 累计处理条数
|
||||
|
||||
// 循环分批处理,直到没有数据
|
||||
while (true) {
|
||||
// 1. 分批查询未处理的数据(exp=0),按log_id递增取,避免重复
|
||||
$list = Db::name('vs_user_money_log')
|
||||
->where('exp', 0)
|
||||
->where('log_id', '>', $lastLogId)
|
||||
->field('log_id,user_id,room_id,change_type,money_type,change_value,from_id,remarks,createtime')
|
||||
->order('log_id ASC')
|
||||
->limit($batchSize)
|
||||
->select();
|
||||
|
||||
// 没有数据则退出循环
|
||||
if (empty($list)) {
|
||||
break;
|
||||
}
|
||||
|
||||
// 2. 收集批量插入的数据
|
||||
$coinData = []; // 金币日志待插入数据
|
||||
$earData = []; // 钻石日志待插入数据
|
||||
$logIds = []; // 本次处理的log_id集合(用于批量更新exp)
|
||||
|
||||
foreach ($list as $v) {
|
||||
$logIds[] = $v['log_id'];
|
||||
$createtime = $v['createtime'] ?: time(); // 处理空创建时间
|
||||
|
||||
// 金币类型(money_type=1)
|
||||
if ($v['money_type'] == 1) {
|
||||
$coinData[] = [
|
||||
'user_id' => $v['user_id'] ?: 0,
|
||||
'room_id' => $v['from_id'] ?: 0, // 按你原有逻辑,room_id对应from_id
|
||||
'coin' => $v['change_value'] ?: 0,
|
||||
'before' => $v['change_value'] ?: 0, // 按你原有逻辑赋值
|
||||
'after' => $v['change_value'] ?: 0, // 按你原有逻辑赋值
|
||||
'change_type' => $v['change_type'] ?: 0,
|
||||
'remarks' => $v['remarks'] ?: '',
|
||||
'createtime' => $createtime
|
||||
];
|
||||
}
|
||||
|
||||
// 钻石类型(money_type=2)
|
||||
if ($v['money_type'] == 2) {
|
||||
$earData[] = [
|
||||
'user_id' => $v['user_id'] ?: 0,
|
||||
'room_id' => $v['from_id'] ?: 0, // 按你原有逻辑,room_id对应from_id
|
||||
'earnings' => $v['change_value'] ?: 0.0000,
|
||||
'before' => $v['change_value'] ?: 0.0000, // 按你原有逻辑赋值
|
||||
'after' => $v['change_value'] ?: 0.0000, // 按你原有逻辑赋值
|
||||
'change_type' => $v['change_type'] ?: 0,
|
||||
'remarks' => $v['remarks'] ?: '',
|
||||
'createtime' => $createtime
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 批量插入数据(开启事务,保证数据一致性)
|
||||
Db::startTrans();
|
||||
try {
|
||||
// 批量插入金币日志(有数据才插入)
|
||||
if (!empty($coinData)) {
|
||||
Db::name('user_coin_log')->insertAll($coinData);
|
||||
}
|
||||
|
||||
// 批量插入钻石日志(有数据才插入)
|
||||
if (!empty($earData)) {
|
||||
Db::name('user_earnings_log')->insertAll($earData);
|
||||
}
|
||||
|
||||
// 4. 批量更新已处理的记录(exp=1)
|
||||
if (!empty($logIds)) {
|
||||
Db::name('vs_user_money_log')
|
||||
->whereIn('log_id', $logIds)
|
||||
->update(['exp' => 1]);
|
||||
}
|
||||
|
||||
Db::commit(); // 提交事务
|
||||
|
||||
// 更新统计和最后处理的log_id
|
||||
$batchCount = count($list);
|
||||
$total += $batchCount;
|
||||
$lastLogId = end($list)['log_id'];
|
||||
|
||||
// 输出进度
|
||||
$output->writeln("成功处理第 {$total} 条数据 | 本次处理 {$batchCount} 条 | 最后处理log_id: {$lastLogId}");
|
||||
|
||||
// 清空数组,释放内存
|
||||
unset($list, $coinData, $earData, $logIds);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback(); // 回滚事务
|
||||
$output->error("处理失败:{$e->getMessage()} | 失败批次log_id范围:{$lastLogId} ~ {($lastLogId + $batchSize)}");
|
||||
break; // 出错则停止,避免数据混乱
|
||||
}
|
||||
}
|
||||
|
||||
$output->writeln("========== 迁移完成!累计处理 {$total} 条数据 ==========");
|
||||
}
|
||||
}
|
||||
@@ -11,101 +11,6 @@ use app\common\library\Token as TokenLib;
|
||||
class BaseCom extends Controller
|
||||
{
|
||||
protected $uid = 0;
|
||||
//初始化
|
||||
protected function _initializes()
|
||||
{
|
||||
//允许跨域
|
||||
header("Access-Control-Allow-Origin: *"); // 允许所有域访问
|
||||
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
|
||||
header("Access-Control-Allow-Headers: Content-Type, Authorization");
|
||||
header("Access-Control-Max-Age: 3600");
|
||||
|
||||
//检测系统是否维护中
|
||||
$is_maintenance = get_system_config_value('is_maintenance');
|
||||
|
||||
//获取内侧账号
|
||||
$inside_uid = get_system_config_value('inside_uid');
|
||||
|
||||
//检测是什么系统
|
||||
$system = input('system','');
|
||||
if(empty($system)){
|
||||
$system = request()->header('system');
|
||||
}
|
||||
//版本号
|
||||
$version = input('App-Version','');
|
||||
if(empty($version)){
|
||||
$version = request()->header('App-Version');
|
||||
}
|
||||
$zhenshi_version = db::name('version')->where('type', 2)->value('apiversion');
|
||||
$result = version_compare($version,$zhenshi_version);
|
||||
//请求的接口
|
||||
$api = request()->controller().'/'.request()->action();
|
||||
if($system == 'iOS' && $result > 0){
|
||||
if($api == 'Index/index_banner' || $api == 'Index/room_type_list' || $api == 'Index/room_list' || $api == 'UserZone/expand_zone' || $api == 'UserZone/zone_list' || $api == 'UserZone/topic_list' || $api == 'UserZone/get_zone_topic'){
|
||||
$this->uid = 0;
|
||||
//定义一个常量
|
||||
define('UID', $this->uid);
|
||||
}else{
|
||||
$token = request()->header('token');
|
||||
if (empty($token)) {
|
||||
$token = input('token', '');
|
||||
if(empty($token)){
|
||||
return V(301, '登录失效');
|
||||
}
|
||||
}
|
||||
|
||||
$reslut = model('UserToken')->check_login_token($token);
|
||||
if($reslut['code'] != 1) {
|
||||
model('UserToken')->where('token', $token)->update(['token' => 1]);
|
||||
return V($reslut['code'], $reslut['msg'],$reslut['data']);
|
||||
} else {
|
||||
$this->uid = $reslut['data'];
|
||||
//定义一个常量
|
||||
define('UID', $this->uid);
|
||||
//检测ID是否在内测中 $inside_uid 是逗号分隔的ID $is_maintenance ==3 是内测
|
||||
if($inside_uid && $is_maintenance == 3){
|
||||
//先转为数组 不是内侧账号 返回301
|
||||
$inside_uid = explode(',',$inside_uid);
|
||||
if(!in_array($this->uid,$inside_uid)){
|
||||
return V(0, '系统维护中');
|
||||
}
|
||||
}elseif($is_maintenance == 2){
|
||||
return V(0, '系统维护中');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
$token = request()->header('token');
|
||||
if (empty($token)) {
|
||||
$token = input('token', '');
|
||||
if(empty($token)){
|
||||
return V(301, '登录失效');
|
||||
}
|
||||
}
|
||||
|
||||
$reslut = model('UserToken')->check_login_token($token);
|
||||
if($reslut['code'] != 1) {
|
||||
model('UserToken')->where('token', $token)->update(['token' => 1]);
|
||||
return V($reslut['code'], $reslut['msg'],$reslut['data']);
|
||||
} else {
|
||||
$this->uid = $reslut['data'];
|
||||
//定义一个常量
|
||||
define('UID', $this->uid);
|
||||
//检测ID是否在内测中 $inside_uid 是逗号分隔的ID $is_maintenance ==3 是内测
|
||||
if($inside_uid && $is_maintenance == 3){
|
||||
//先转为数组 不是内侧账号 返回301
|
||||
$inside_uid = explode(',',$inside_uid);
|
||||
if(!in_array($this->uid,$inside_uid)){
|
||||
return V(0, '系统维护中');
|
||||
}
|
||||
}elseif($is_maintenance == 2){
|
||||
return V(0, '系统维护中');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化方法
|
||||
@@ -124,18 +29,15 @@ class BaseCom extends Controller
|
||||
}
|
||||
|
||||
if($is_maintenance == 2){
|
||||
return V(0, '系统维护中');
|
||||
return V(301, '系统维护中');
|
||||
}
|
||||
|
||||
//检测是什么系统
|
||||
$system = input('system','未知');
|
||||
if(empty($system)){
|
||||
$system = request()->header('system');
|
||||
}
|
||||
$system = request()->header('system');
|
||||
|
||||
if ($system == 'iOS') {
|
||||
//版本号
|
||||
$version = input('App-Version','');
|
||||
$version = input('App-Version');
|
||||
if(empty($version)){
|
||||
$version = request()->header('App-Version');
|
||||
}
|
||||
@@ -153,6 +55,8 @@ class BaseCom extends Controller
|
||||
$this->uid = 0;
|
||||
//定义一个常量
|
||||
define('UID', $this->uid);
|
||||
}else{
|
||||
$this->check_login($is_maintenance) ;
|
||||
}
|
||||
}else{
|
||||
$this->check_login($is_maintenance) ;
|
||||
@@ -169,7 +73,7 @@ class BaseCom extends Controller
|
||||
// 2. 从请求中获取Token(支持多种方式)
|
||||
$token = request()->header('token');
|
||||
if (empty($token)) {
|
||||
$token = input('token', '');
|
||||
$token = input('token');
|
||||
}
|
||||
|
||||
if (empty($token)) {
|
||||
|
||||
@@ -142,7 +142,9 @@ class adminApi extends Controller
|
||||
//通过头部信息获取authorization0
|
||||
$token = $this->request->server('HTTP_AUTHORIZATION', $this->request->request('token', \think\Cookie::get('token')));
|
||||
//检测是否登录
|
||||
if (!$this->auth->isLogin($token)) {
|
||||
// if (!$this->auth->isLogin($token)) {
|
||||
$auth = new Auth ;
|
||||
if (!$auth->isLogin($token)) {
|
||||
Hook::listen('admin_nologin', $this);
|
||||
$url = Session::get('referer');
|
||||
$url = $url ? $url : $this->request->url();
|
||||
|
||||
@@ -25,7 +25,7 @@ class GiftQueue
|
||||
{
|
||||
try {
|
||||
// 验证必要字段
|
||||
if (empty($giftData['user_id']) || empty($giftData['gift_user']) || empty($giftData['from_id'])) {
|
||||
if (empty($giftData['user_id']) || empty($giftData['gift_user'])) {
|
||||
Log::error('送礼队列数据不完整: ' . json_encode($giftData));
|
||||
return false;
|
||||
}
|
||||
@@ -52,6 +52,7 @@ class GiftQueue
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Log::error('送礼队列添加失败:' . $e->getMessage());
|
||||
db::name('redis_error')->insert( ['related_id' => $giftData['id'],'content' => json_encode($giftData),'remark' =>$e->getMessage()]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -186,6 +187,7 @@ class GiftQueue
|
||||
$redis = new Redis(config('cache'));
|
||||
$redis->handler()->lpush(self::QUEUE_FAILED_KEY, $failedData);
|
||||
Log::error("送礼记录重试超过最大次数: {$queueData['uuid']}, 数据: " . json_encode($queueData['data']));
|
||||
db::name('redis_error')->insert( ['related_id' => 0,'content' => json_encode($queueData['data']),'remark' =>'送礼记录重试超过最大次数']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ class GiftTableManager
|
||||
`total_price` decimal(16,2) NOT NULL COMMENT '礼物总价值',
|
||||
`type` int NOT NULL DEFAULT '1' COMMENT '1金币购买 2送背包礼物',
|
||||
`from` int NOT NULL DEFAULT '1' COMMENT '1私聊送礼物 2语聊房送礼 3视频直播房送礼(暂时不用) 4动态打赏 6私密房间送礼',
|
||||
`remarks` varchar(255) NULL COMMENT '备注',
|
||||
`createtime` bigint NOT NULL COMMENT '创建时间(秒时间戳)',
|
||||
`updatetime` bigint DEFAULT NULL COMMENT '更新时间(秒时间戳)',
|
||||
PRIMARY KEY (`id`),
|
||||
|
||||
@@ -5,121 +5,471 @@ namespace app\common\library;
|
||||
|
||||
class Snowflake
|
||||
{
|
||||
// 起始时间戳(2023-01-01)
|
||||
// 起始时间戳(2023-01-01 00:00:00)
|
||||
const EPOCH = 1672502400000;
|
||||
|
||||
// 机器ID位数
|
||||
const WORKER_ID_BITS = 5;
|
||||
const DATACENTER_ID_BITS = 5;
|
||||
const SEQUENCE_BITS = 12;
|
||||
// 位数分配
|
||||
const WORKER_ID_BITS = 5; // 5位工作机器ID
|
||||
const DATACENTER_ID_BITS = 5; // 5位数据中心ID
|
||||
const SEQUENCE_BITS = 12; // 12位序列号
|
||||
|
||||
// 最大值
|
||||
// 最大值计算
|
||||
const MAX_WORKER_ID = -1 ^ (-1 << self::WORKER_ID_BITS);
|
||||
const MAX_DATACENTER_ID = -1 ^ (-1 << self::DATACENTER_ID_BITS);
|
||||
const MAX_SEQUENCE = -1 ^ (-1 << self::SEQUENCE_BITS);
|
||||
|
||||
// 移位
|
||||
// 移位偏移量
|
||||
const WORKER_ID_SHIFT = self::SEQUENCE_BITS;
|
||||
const DATACENTER_ID_SHIFT = self::SEQUENCE_BITS + self::WORKER_ID_BITS;
|
||||
const TIMESTAMP_LEFT_SHIFT = self::SEQUENCE_BITS + self::WORKER_ID_BITS + self::DATACENTER_ID_BITS;
|
||||
|
||||
// 序列号掩码
|
||||
const SEQUENCE_MASK = -1 ^ (-1 << self::SEQUENCE_BITS);
|
||||
|
||||
// 实例存储
|
||||
protected static $instances = [];
|
||||
|
||||
protected $workerId;
|
||||
protected $datacenterId;
|
||||
protected $sequence = 0;
|
||||
protected $lastTimestamp = -1;
|
||||
protected $lastGenerateTime = 0;
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
* @param int $workerId 工作机器ID (0-31)
|
||||
* @param int $datacenterId 数据中心ID (0-31)
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct($workerId = 1, $datacenterId = 1)
|
||||
{
|
||||
// 验证 workerId
|
||||
if ($workerId > self::MAX_WORKER_ID || $workerId < 0) {
|
||||
throw new \Exception("worker Id can't be greater than " . self::MAX_WORKER_ID . " or less than 0");
|
||||
throw new \Exception(sprintf(
|
||||
"Worker ID 必须在 0 到 %d 之间,当前值:%d",
|
||||
self::MAX_WORKER_ID,
|
||||
$workerId
|
||||
));
|
||||
}
|
||||
|
||||
// 验证 datacenterId
|
||||
if ($datacenterId > self::MAX_DATACENTER_ID || $datacenterId < 0) {
|
||||
throw new \Exception("datacenter Id can't be greater than " . self::MAX_DATACENTER_ID . " or less than 0");
|
||||
throw new \Exception(sprintf(
|
||||
"Datacenter ID 必须在 0 到 %d 之间,当前值:%d",
|
||||
self::MAX_DATACENTER_ID,
|
||||
$datacenterId
|
||||
));
|
||||
}
|
||||
|
||||
$this->workerId = $workerId;
|
||||
$this->datacenterId = $datacenterId;
|
||||
|
||||
// 记录日志
|
||||
\think\Log::info(sprintf(
|
||||
"Snowflake 实例初始化完成,WorkerId: %d, DatacenterId: %d",
|
||||
$workerId,
|
||||
$datacenterId
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成下一个ID
|
||||
* @return int
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function nextId()
|
||||
{
|
||||
$timestamp = $this->timeGen();
|
||||
|
||||
// 检查时钟回拨
|
||||
if ($timestamp < $this->lastTimestamp) {
|
||||
$diff = $this->lastTimestamp - $timestamp;
|
||||
throw new \Exception("Clock moved backwards. Refusing to generate id for {$diff} milliseconds");
|
||||
|
||||
// 轻微时钟回拨,等待时钟追上
|
||||
if ($diff < 100) { // 100毫秒内的回拨
|
||||
usleep($diff * 1000); // 微秒休眠
|
||||
$timestamp = $this->timeGen();
|
||||
} else {
|
||||
throw new \Exception(sprintf(
|
||||
"时钟回拨过大,拒绝生成ID。回拨时间:%d 毫秒",
|
||||
$diff
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// 同一毫秒内生成多个ID
|
||||
if ($this->lastTimestamp == $timestamp) {
|
||||
$this->sequence = ($this->sequence + 1) & self::MAX_SEQUENCE;
|
||||
|
||||
// 序列号溢出,等待下一毫秒
|
||||
if ($this->sequence == 0) {
|
||||
$timestamp = $this->tilNextMillis($this->lastTimestamp);
|
||||
}
|
||||
} else {
|
||||
$this->sequence = 0;
|
||||
// 新的毫秒,重置序列号,使用随机初始值避免重复
|
||||
$this->sequence = mt_rand(0, 10) & self::MAX_SEQUENCE;
|
||||
}
|
||||
|
||||
$this->lastTimestamp = $timestamp;
|
||||
|
||||
return (($timestamp - self::EPOCH) << self::TIMESTAMP_LEFT_SHIFT) |
|
||||
($this->datacenterId << self::DATACENTER_ID_SHIFT) |
|
||||
($this->workerId << self::WORKER_ID_SHIFT) |
|
||||
$this->sequence;
|
||||
}
|
||||
// 计算并返回ID
|
||||
$id = ((($timestamp - self::EPOCH) << self::TIMESTAMP_LEFT_SHIFT)
|
||||
| ($this->datacenterId << self::DATACENTER_ID_SHIFT)
|
||||
| ($this->workerId << self::WORKER_ID_SHIFT)
|
||||
| $this->sequence);
|
||||
|
||||
protected function tilNextMillis($lastTimestamp)
|
||||
{
|
||||
$timestamp = $this->timeGen();
|
||||
while ($timestamp <= $lastTimestamp) {
|
||||
$timestamp = $this->timeGen();
|
||||
}
|
||||
return $timestamp;
|
||||
}
|
||||
// 记录生成时间(用于调试)
|
||||
$this->lastGenerateTime = microtime(true);
|
||||
|
||||
protected function timeGen()
|
||||
{
|
||||
return floor(microtime(true) * 1000);
|
||||
return $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析雪花ID
|
||||
* @param int $id
|
||||
* 等待到下一毫秒
|
||||
* @param int $lastTimestamp 最后时间戳
|
||||
* @return int
|
||||
*/
|
||||
protected function tilNextMillis($lastTimestamp)
|
||||
{
|
||||
$timestamp = $this->timeGen();
|
||||
$waitCount = 0;
|
||||
|
||||
while ($timestamp <= $lastTimestamp) {
|
||||
// 等待时间过长记录警告
|
||||
if ($waitCount++ > 100) {
|
||||
\think\Log::warning("Snowflake 等待下一毫秒时间过长,已等待 {$waitCount} 次循环");
|
||||
}
|
||||
|
||||
// 微秒级休眠,避免CPU占用过高
|
||||
usleep(100); // 休眠100微秒
|
||||
$timestamp = $this->timeGen();
|
||||
}
|
||||
|
||||
return $timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前时间戳(毫秒)
|
||||
* @return int
|
||||
*/
|
||||
protected function timeGen()
|
||||
{
|
||||
// 使用微秒时间,提高精度
|
||||
return (int)(microtime(true) * 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析雪花ID为各个组成部分
|
||||
* @param int $id 雪花ID
|
||||
* @return array
|
||||
*/
|
||||
public static function parseId($id)
|
||||
{
|
||||
// 转换为64位二进制字符串
|
||||
$binary = decbin($id);
|
||||
$binary = str_pad($binary, 64, '0', STR_PAD_LEFT);
|
||||
|
||||
$timestamp = bindec(substr($binary, 0, 42));
|
||||
$timestamp = $timestamp + self::EPOCH;
|
||||
// 提取各组成部分
|
||||
$timestampBin = substr($binary, 0, 42);
|
||||
$datacenterIdBin = substr($binary, 42, 5);
|
||||
$workerIdBin = substr($binary, 47, 5);
|
||||
$sequenceBin = substr($binary, 52, 12);
|
||||
|
||||
$datacenterId = bindec(substr($binary, 42, 5));
|
||||
$workerId = bindec(substr($binary, 47, 5));
|
||||
$sequence = bindec(substr($binary, 52, 12));
|
||||
// 转换为十进制
|
||||
$timestamp = bindec($timestampBin) + self::EPOCH;
|
||||
$datacenterId = bindec($datacenterIdBin);
|
||||
$workerId = bindec($workerIdBin);
|
||||
$sequence = bindec($sequenceBin);
|
||||
|
||||
// 转换为可读时间
|
||||
$dateTime = date('Y-m-d H:i:s', (int)($timestamp / 1000));
|
||||
$millisecond = $timestamp % 1000;
|
||||
|
||||
return [
|
||||
'id' => $id,
|
||||
'timestamp' => $timestamp,
|
||||
'datacenterId' => $datacenterId,
|
||||
'workerId' => $workerId,
|
||||
'sequence' => $sequence
|
||||
'datetime' => $dateTime,
|
||||
'millisecond' => $millisecond,
|
||||
'datacenter_id' => $datacenterId,
|
||||
'worker_id' => $workerId,
|
||||
'sequence' => $sequence,
|
||||
'binary' => $binary,
|
||||
'parts' => [
|
||||
'timestamp' => $timestampBin,
|
||||
'datacenter_id' => $datacenterIdBin,
|
||||
'worker_id' => $workerIdBin,
|
||||
'sequence' => $sequenceBin
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成ID(单例模式)
|
||||
* 生成ID(主调用方法)
|
||||
* @param int|null $workerId 工作机器ID
|
||||
* @param int|null $datacenterId 数据中心ID
|
||||
* @return int
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function generate($workerId = null, $datacenterId = null)
|
||||
{
|
||||
// 获取配置
|
||||
if ($workerId === null) {
|
||||
$workerId = self::getWorkerId();
|
||||
}
|
||||
|
||||
if ($datacenterId === null) {
|
||||
$datacenterId = self::getDatacenterId();
|
||||
}
|
||||
|
||||
// 创建实例键
|
||||
$instanceKey = "{$workerId}_{$datacenterId}";
|
||||
|
||||
// 检查是否已有实例
|
||||
if (!isset(self::$instances[$instanceKey])) {
|
||||
self::$instances[$instanceKey] = new self($workerId, $datacenterId);
|
||||
}
|
||||
|
||||
// 生成ID
|
||||
return self::$instances[$instanceKey]->nextId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取工作机器ID
|
||||
* @return int
|
||||
*/
|
||||
public static function generate()
|
||||
protected static function getWorkerId()
|
||||
{
|
||||
static $instance = null;
|
||||
if (!$instance) {
|
||||
// 从配置获取workerId和datacenterId
|
||||
$workerId = config('snowflake.worker_id') ?: 1;
|
||||
$datacenterId = config('snowflake.datacenter_id') ?: 1;
|
||||
$instance = new self($workerId, $datacenterId);
|
||||
// 1. 从配置文件获取(FastAdmin 使用 application/extra/ 目录)
|
||||
$config = config('snowflake');
|
||||
if ($config && isset($config['worker_id'])) {
|
||||
$workerId = (int)$config['worker_id'];
|
||||
if ($workerId >= 0 && $workerId <= self::MAX_WORKER_ID) {
|
||||
return $workerId;
|
||||
}
|
||||
}
|
||||
return $instance->nextId();
|
||||
|
||||
// 2. 从环境变量获取(FastAdmin 使用 .env 文件)
|
||||
if (function_exists('env')) {
|
||||
$envWorkerId = env('SNOWFLAKE_WORKER_ID');
|
||||
if ($envWorkerId !== null && $envWorkerId !== false) {
|
||||
$workerId = (int)$envWorkerId;
|
||||
if ($workerId >= 0 && $workerId <= self::MAX_WORKER_ID) {
|
||||
return $workerId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 自动生成(基于服务器信息和进程ID)
|
||||
// 使用服务器IP的最后一段 + 进程ID
|
||||
$serverIp = self::getServerIp();
|
||||
$ipParts = explode('.', $serverIp);
|
||||
$ipLastPart = end($ipParts);
|
||||
$processId = getmypid() ?: 1;
|
||||
|
||||
// 计算唯一的工作ID
|
||||
$workerId = (($ipLastPart * 1000) + $processId) % (self::MAX_WORKER_ID + 1);
|
||||
|
||||
// 确保在有效范围内
|
||||
$workerId = max(0, min($workerId, self::MAX_WORKER_ID));
|
||||
|
||||
return (int)$workerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据中心ID
|
||||
* @return int
|
||||
*/
|
||||
protected static function getDatacenterId()
|
||||
{
|
||||
// 1. 从配置文件获取
|
||||
$config = config('snowflake');
|
||||
if ($config && isset($config['datacenter_id'])) {
|
||||
$datacenterId = (int)$config['datacenter_id'];
|
||||
if ($datacenterId >= 0 && $datacenterId <= self::MAX_DATACENTER_ID) {
|
||||
return $datacenterId;
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 从环境变量获取
|
||||
if (function_exists('env')) {
|
||||
$envDatacenterId = env('SNOWFLAKE_DATACENTER_ID');
|
||||
if ($envDatacenterId !== null && $envDatacenterId !== false) {
|
||||
$datacenterId = (int)$envDatacenterId;
|
||||
if ($datacenterId >= 0 && $datacenterId <= self::MAX_DATACENTER_ID) {
|
||||
return $datacenterId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 自动生成(基于服务器IP)
|
||||
$serverIp = self::getServerIp();
|
||||
$ipParts = explode('.', $serverIp);
|
||||
|
||||
// 使用IP前两段计算数据中心ID
|
||||
$part1 = isset($ipParts[0]) ? (int)$ipParts[0] : 0;
|
||||
$part2 = isset($ipParts[1]) ? (int)$ipParts[1] : 0;
|
||||
$datacenterId = (($part1 * 10) + $part2) % (self::MAX_DATACENTER_ID + 1);
|
||||
|
||||
// 确保在有效范围内
|
||||
$datacenterId = max(0, min($datacenterId, self::MAX_DATACENTER_ID));
|
||||
|
||||
return (int)$datacenterId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务器IP
|
||||
* @return string
|
||||
*/
|
||||
protected static function getServerIp()
|
||||
{
|
||||
// 多种方式获取服务器IP
|
||||
if (isset($_SERVER['SERVER_ADDR'])) {
|
||||
return $_SERVER['SERVER_ADDR'];
|
||||
}
|
||||
|
||||
if (function_exists('gethostname')) {
|
||||
$hostname = gethostname();
|
||||
if ($hostname) {
|
||||
$ip = gethostbyname($hostname);
|
||||
if ($ip !== $hostname) {
|
||||
return $ip;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 尝试获取本机IP
|
||||
if (function_exists('shell_exec') && strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
|
||||
$ip = shell_exec("hostname -I | awk '{print $1}'");
|
||||
if ($ip) {
|
||||
return trim($ip);
|
||||
}
|
||||
}
|
||||
|
||||
// 默认返回127.0.0.1
|
||||
return '127.0.0.1';
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量生成ID
|
||||
* @param int $count 生成数量
|
||||
* @param int|null $workerId 工作机器ID
|
||||
* @param int|null $datacenterId 数据中心ID
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function batchGenerate($count = 10, $workerId = null, $datacenterId = null)
|
||||
{
|
||||
if ($count <= 0 || $count > 10000) {
|
||||
throw new \Exception("生成数量必须在 1-10000 之间");
|
||||
}
|
||||
|
||||
$ids = [];
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$ids[] = self::generate($workerId, $datacenterId);
|
||||
}
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证ID是否有效
|
||||
* @param int $id 雪花ID
|
||||
* @return bool
|
||||
*/
|
||||
public static function validate($id)
|
||||
{
|
||||
if (!is_numeric($id) || $id <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$parsed = self::parseId($id);
|
||||
|
||||
// 检查时间戳是否合理(不能超过当前时间+10年)
|
||||
$currentTime = (int)(microtime(true) * 1000);
|
||||
$maxTime = $currentTime + (10 * 365 * 24 * 60 * 60 * 1000); // 10年后
|
||||
|
||||
if ($parsed['timestamp'] > $maxTime || $parsed['timestamp'] < self::EPOCH) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查ID组成部分是否在有效范围内
|
||||
if ($parsed['datacenter_id'] > self::MAX_DATACENTER_ID ||
|
||||
$parsed['worker_id'] > self::MAX_WORKER_ID ||
|
||||
$parsed['sequence'] > self::MAX_SEQUENCE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取ID生成统计信息
|
||||
* @return array
|
||||
*/
|
||||
public function getStats()
|
||||
{
|
||||
return [
|
||||
'worker_id' => $this->workerId,
|
||||
'datacenter_id' => $this->datacenterId,
|
||||
'last_timestamp' => $this->lastTimestamp,
|
||||
'last_generate_time' => $this->lastGenerateTime,
|
||||
'max_worker_id' => self::MAX_WORKER_ID,
|
||||
'max_datacenter_id' => self::MAX_DATACENTER_ID,
|
||||
'max_sequence' => self::MAX_SEQUENCE,
|
||||
'epoch' => self::EPOCH,
|
||||
'epoch_datetime' => date('Y-m-d H:i:s', self::EPOCH / 1000)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取ID的详细信息(调试用)
|
||||
* @param int $id
|
||||
* @return array
|
||||
*/
|
||||
public static function getDetail($id)
|
||||
{
|
||||
if (!self::validate($id)) {
|
||||
return ['error' => '无效的雪花ID'];
|
||||
}
|
||||
|
||||
$parsed = self::parseId($id);
|
||||
|
||||
// 添加生成时间估算
|
||||
$generateTime = date('Y-m-d H:i:s', $parsed['timestamp'] / 1000);
|
||||
$now = time();
|
||||
$generateTimestamp = $parsed['timestamp'] / 1000;
|
||||
$timeDiff = $now - $generateTimestamp;
|
||||
|
||||
if ($timeDiff < 60) {
|
||||
$timeAgo = "刚刚";
|
||||
} elseif ($timeDiff < 3600) {
|
||||
$timeAgo = floor($timeDiff / 60) . "分钟前";
|
||||
} elseif ($timeDiff < 86400) {
|
||||
$timeAgo = floor($timeDiff / 3600) . "小时前";
|
||||
} else {
|
||||
$timeAgo = floor($timeDiff / 86400) . "天前";
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $parsed['id'],
|
||||
'timestamp' => $parsed['timestamp'],
|
||||
'datetime' => $parsed['datetime'],
|
||||
'datetime_full' => $generateTime . '.' . str_pad($parsed['millisecond'], 3, '0', STR_PAD_LEFT),
|
||||
'time_ago' => $timeAgo,
|
||||
'datacenter_id' => $parsed['datacenter_id'],
|
||||
'worker_id' => $parsed['worker_id'],
|
||||
'sequence' => $parsed['sequence'],
|
||||
'binary' => chunk_split($parsed['binary'], 8, ' '),
|
||||
'binary_parts' => [
|
||||
'timestamp' => $parsed['parts']['timestamp'],
|
||||
'datacenter' => $parsed['parts']['datacenter_id'],
|
||||
'worker' => $parsed['parts']['worker_id'],
|
||||
'sequence' => $parsed['parts']['sequence']
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// application/common/model/GiveGiftBase.php
|
||||
// application/common/model/GiveGiftBases.php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
@@ -45,7 +45,7 @@ class GiveGiftBase extends Model
|
||||
{
|
||||
try {
|
||||
// 生成雪花ID
|
||||
$data['id'] = Snowflake::generate();
|
||||
// $data['id'] = Snowflake::generate();
|
||||
|
||||
// 设置时间
|
||||
if (empty($data['createtime'])) {
|
||||
@@ -154,12 +154,12 @@ class GiveGiftBase extends Model
|
||||
public function getGiftRecords($where = [], $options = [])
|
||||
{
|
||||
$defaultOptions = [
|
||||
'fields' => '*',
|
||||
'order' => 'createtime desc',
|
||||
'page' => 1,
|
||||
'limit' => 20,
|
||||
'start_time'=> null,
|
||||
'end_time' => null,
|
||||
'fields' => '*',
|
||||
'order' => 'createtime desc',
|
||||
'page' => 1,
|
||||
'limit' => 20,
|
||||
'start_time' => null,
|
||||
'end_time' => null,
|
||||
];
|
||||
|
||||
$options = array_merge($defaultOptions, $options);
|
||||
@@ -191,13 +191,13 @@ class GiveGiftBase extends Model
|
||||
$conditions = [];
|
||||
|
||||
$fieldMap = [
|
||||
'user_id' => 'user_id',
|
||||
'gift_user' => 'gift_user',
|
||||
'from_id' => 'from_id',
|
||||
'gift_id' => 'gift_id',
|
||||
'type' => 'type',
|
||||
'from' => 'from',
|
||||
'gift_type' => 'gift_type',
|
||||
'user_id' => 'user_id',
|
||||
'gift_user' => 'gift_user',
|
||||
'from_id' => 'from_id',
|
||||
'gift_id' => 'gift_id',
|
||||
'type' => 'type',
|
||||
'from' => 'from',
|
||||
'gift_type' => 'gift_type',
|
||||
'createtime' => 'createtime',
|
||||
];
|
||||
|
||||
@@ -288,8 +288,8 @@ class GiveGiftBase extends Model
|
||||
|
||||
return [
|
||||
'total' => $total,
|
||||
'data' => $data,
|
||||
'page' => $options['page'],
|
||||
'data' => $data,
|
||||
'page' => $options['page'],
|
||||
'limit' => $options['limit']
|
||||
];
|
||||
}
|
||||
@@ -303,9 +303,9 @@ class GiveGiftBase extends Model
|
||||
public function getGiftStatistics($where = [], $options = [])
|
||||
{
|
||||
$defaultOptions = [
|
||||
'group_by' => null, // 分组字段
|
||||
'group_by' => null, // 分组字段
|
||||
'start_time' => null,
|
||||
'end_time' => null,
|
||||
'end_time' => null,
|
||||
];
|
||||
|
||||
$options = array_merge($defaultOptions, $options);
|
||||
@@ -459,4 +459,195 @@ class GiveGiftBase extends Model
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 统计送礼数据排行
|
||||
* @param array $where 查询条件
|
||||
* @param array $options 统计选项
|
||||
* @return array
|
||||
*/
|
||||
public function getGiftStatisticsRanking($where = [], $options = [])
|
||||
{
|
||||
$defaultOptions = [
|
||||
'group_by' => null, // 分组字段
|
||||
'start_time' => null,
|
||||
'end_time' => null,
|
||||
];
|
||||
|
||||
$options = array_merge($defaultOptions, $options);
|
||||
|
||||
// 获取需要查询的表
|
||||
$tables = GiftTableManager::getTablesByTimeRange(
|
||||
$options['start_time'],
|
||||
$options['end_time']
|
||||
);
|
||||
|
||||
if (empty($tables)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// 构建查询条件
|
||||
$conditions = $this->buildQueryConditions($where);
|
||||
|
||||
$unionSql = '';
|
||||
$params = [];
|
||||
|
||||
// 构建统计SQL
|
||||
$fields = 'SUM(total_price) as total_price';
|
||||
if ($options['group_by']) {
|
||||
$fields .= ", {$options['group_by']}";
|
||||
}
|
||||
|
||||
foreach ($tables as $table) {
|
||||
$sql = "SELECT {$fields} FROM `{$table}` WHERE 1=1";
|
||||
|
||||
foreach ($conditions as $field => $condition) {
|
||||
if (is_array($condition) && count($condition) == 2) {
|
||||
$operator = $condition[0];
|
||||
$value = $condition[1];
|
||||
$sql .= " AND `{$field}` {$operator} ?";
|
||||
$params[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// 时间范围
|
||||
if ($options['start_time']) {
|
||||
$sql .= " AND createtime >= ?";
|
||||
$params[] = $options['start_time'];
|
||||
}
|
||||
|
||||
if ($options['end_time']) {
|
||||
$sql .= " AND createtime <= ?";
|
||||
$params[] = $options['end_time'];
|
||||
}
|
||||
|
||||
if ($options['group_by']) {
|
||||
$sql .= " GROUP BY {$options['group_by']}";
|
||||
}
|
||||
|
||||
if ($unionSql) {
|
||||
$unionSql .= " UNION ALL ";
|
||||
}
|
||||
$unionSql .= "(" . $sql . ")";
|
||||
}
|
||||
|
||||
// 最终统计
|
||||
if ($options['group_by']) {
|
||||
$finalSql = "SELECT {$options['group_by']},
|
||||
SUM(total_price) * 10 as total
|
||||
FROM ({$unionSql}) as tmp
|
||||
GROUP BY {$options['group_by']}
|
||||
ORDER BY total desc";
|
||||
} else {
|
||||
$finalSql = "SELECT SUM(total_number) as total_number,
|
||||
SUM(total_price) as total,
|
||||
SUM(total_count) as total_count
|
||||
FROM ({$unionSql}) as tmp";
|
||||
}
|
||||
|
||||
try {
|
||||
$result = Db::query($finalSql, $params);
|
||||
return $options['group_by'] ? $result : ($result[0] ?? []);
|
||||
} catch (\Exception $e) {
|
||||
Log::error("统计送礼数据失败: " . $e->getMessage());
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 统计收礼用户 的送礼用户的分组和
|
||||
* @param array $where 查询条件
|
||||
* @param array $options 统计选项
|
||||
* @return array
|
||||
*/
|
||||
public function getToUserStatistics($where = [], $options = [])
|
||||
{
|
||||
$defaultOptions = [
|
||||
'group_by' => null, // 分组字段
|
||||
'start_time' => null,
|
||||
'end_time' => null,
|
||||
];
|
||||
|
||||
$options = array_merge($defaultOptions, $options);
|
||||
|
||||
// 获取需要查询的表
|
||||
$tables = GiftTableManager::getTablesByTimeRange(
|
||||
$options['start_time'],
|
||||
$options['end_time']
|
||||
);
|
||||
|
||||
if (empty($tables)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// 构建查询条件
|
||||
$conditions = $this->buildQueryConditions($where);
|
||||
|
||||
$unionSql = '';
|
||||
$params = [];
|
||||
|
||||
// 构建统计SQL
|
||||
$fields = 'SUM(total_price) as total_price';
|
||||
if ($options['group_by']) {
|
||||
$fields .= ", {$options['group_by']}";
|
||||
}
|
||||
|
||||
foreach ($tables as $table) {
|
||||
$sql = "SELECT {$fields} FROM `{$table}` WHERE 1=1";
|
||||
|
||||
foreach ($conditions as $field => $condition) {
|
||||
if (is_array($condition) && count($condition) == 2) {
|
||||
$operator = $condition[0];
|
||||
$value = $condition[1];
|
||||
$sql .= " AND `{$field}` {$operator} ?";
|
||||
$params[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// 时间范围
|
||||
if ($options['start_time']) {
|
||||
$sql .= " AND createtime >= ?";
|
||||
$params[] = $options['start_time'];
|
||||
}
|
||||
|
||||
if ($options['end_time']) {
|
||||
$sql .= " AND createtime <= ?";
|
||||
$params[] = $options['end_time'];
|
||||
}
|
||||
|
||||
if ($options['group_by']) {
|
||||
$sql .= " GROUP BY {$options['group_by']}";
|
||||
}
|
||||
|
||||
if ($unionSql) {
|
||||
$unionSql .= " UNION ALL ";
|
||||
}
|
||||
$unionSql .= "(" . $sql . ")";
|
||||
}
|
||||
|
||||
// 最终统计
|
||||
if ($options['group_by']) {
|
||||
$finalSql = "SELECT {$options['group_by']},
|
||||
SUM(total_price) * 10 as total
|
||||
FROM ({$unionSql}) as tmp
|
||||
GROUP BY {$options['group_by']}
|
||||
ORDER BY total desc";
|
||||
} else {
|
||||
$finalSql = "SELECT SUM(total_number) as total_number,
|
||||
SUM(total_price) as total,
|
||||
SUM(total_count) as total_count
|
||||
FROM ({$unionSql}) as tmp";
|
||||
}
|
||||
|
||||
try {
|
||||
$result = Db::query($finalSql, $params);
|
||||
return $options['group_by'] ? $result : ($result[0] ?? []);
|
||||
} catch (\Exception $e) {
|
||||
Log::error("统计送礼数据失败: " . $e->getMessage());
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,18 +48,26 @@ class Redpacket extends Model
|
||||
// var_dump($data);exit;
|
||||
Db::startTrans();
|
||||
try {
|
||||
//发红包最小金额
|
||||
$minAmount = get_system_config_value('red_packet_min_amount') ?? 0;
|
||||
//发红包手续费
|
||||
$fee = get_system_config_value('red_packet_fee') ?? 0;
|
||||
|
||||
// 验证用户余额
|
||||
$wallet = Db::name('user_wallet')->where('user_id', $data['user_id'])->find();
|
||||
|
||||
$coinField = $data['coin_type'] == self::COIN_GOLD ? 'coin' : 'earnings';
|
||||
if ($wallet[$coinField] < $data['total_amount']) {
|
||||
if($data['total_amount'] < $minAmount){
|
||||
return ['code' => 0, 'msg' => '红包金额不能小于'.$minAmount, 'data' => null];
|
||||
}
|
||||
if ($wallet[$coinField] < $data['total_amount']+$fee) {
|
||||
return ['code' => 0, 'msg' => '余额不足', 'data' => null];
|
||||
}
|
||||
|
||||
// 扣除余额
|
||||
$delres = Db::name('user_wallet')
|
||||
->where('user_id', $data['user_id'])
|
||||
->dec($coinField, $data['total_amount'])
|
||||
->dec($coinField, $data['total_amount']+$fee)
|
||||
->update();
|
||||
//记录日志 32-发红包(金币),29-发红包(钻石),30-抢红包(金币),31-抢红包(钻石)
|
||||
//记录用户金币日志
|
||||
@@ -73,8 +81,20 @@ class Redpacket extends Model
|
||||
'remarks' => $data['coin_type'] == self::COIN_GOLD ? '金币(发红包)' : '钻石(发红包)',
|
||||
'createtime' => time()
|
||||
];
|
||||
|
||||
$res = Db::name('vs_user_money_log')->insert($data_log);
|
||||
//记录手续费日志
|
||||
$data_log = [
|
||||
'user_id' => $data['user_id'],
|
||||
'change_value' => $fee,
|
||||
'room_id' => $data['room_id'],
|
||||
'money_type' => $data['coin_type'],
|
||||
'change_type' => model('common/UserWallet')::RED_PACKET_FEE ,
|
||||
'from_id' => $data['room_id'],
|
||||
'remarks' => model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::RED_PACKET_FEE),
|
||||
'createtime' => time()
|
||||
];
|
||||
$res = Db::name('vs_user_money_log')->insert($data_log);
|
||||
|
||||
if(!$res || !$delres){
|
||||
Db::rollback();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
@@ -30,7 +31,7 @@ class UserWallet extends Model
|
||||
//金币转增(送出)
|
||||
const OPERATION_CONSUME = 4;
|
||||
//每日任务奖励
|
||||
const DAILY_TASKS_REWARD = 5;
|
||||
const DAILY_TASKS_REWARD = 5;
|
||||
//推广用户充值返利
|
||||
const OPERATION_INVITE_REBATE = 6;
|
||||
//购买装扮
|
||||
@@ -110,35 +111,51 @@ class UserWallet extends Model
|
||||
const DAILY_SIGN = 57;
|
||||
//爆币
|
||||
const BOMB_COIN = 58;
|
||||
|
||||
//红包手续费
|
||||
const RED_PACKET_FEE = 59;
|
||||
//后台充值金币
|
||||
const BACKGROUND_RECHARGE_COIN = 40;
|
||||
//后台充值钻石
|
||||
const BACKGROUND_RECHARGE_DIAMOND = 41;
|
||||
//后台扣除金币
|
||||
const BACKGROUND_DEDUCTION_COIN = 42;
|
||||
//后台扣除钻石
|
||||
const BACKGROUND_DEDUCTION_DIAMOND = 43;
|
||||
//公会会员付费退出会长收入
|
||||
const GUILD_EXIT_DEACON_INCOME = 44;
|
||||
|
||||
|
||||
//金币支出类型数组
|
||||
public $coin_consumption_type_array = [
|
||||
public $coin_consumption_type_array = [
|
||||
self::OPERATION_CONSUME,
|
||||
self::OPERATION_DECORATION,
|
||||
self::OPERATION_GIFT,
|
||||
self::GUILD_EXIT,
|
||||
self::HEADLINE_REWARD,
|
||||
self::DELETE_RELATION_COIN,
|
||||
self::TRANSFER_COIN,
|
||||
self::RED_PACKET_COIN,
|
||||
self::SIGN,
|
||||
self::RENEWAL,
|
||||
self::RED_PACKET_FEE,
|
||||
self::BACKGROUND_DEDUCTION_COIN,
|
||||
|
||||
];
|
||||
//钻石支出类型数组
|
||||
public $diamond_consumption_type_array = [
|
||||
public $diamond_consumption_type_array = [
|
||||
self::OPERATION_WITHDRAW,
|
||||
self::MONEY_CONVERSION,
|
||||
self::RED_PACKET_DIAMOND
|
||||
self::RED_PACKET_DIAMOND,
|
||||
self::BACKGROUND_DEDUCTION_DIAMOND,
|
||||
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->hasOne('User', 'id', 'user_id');
|
||||
}
|
||||
|
||||
//钱包类型
|
||||
public static function getMoneyType($value)
|
||||
{
|
||||
@@ -149,58 +166,64 @@ class UserWallet extends Model
|
||||
return isset($status[$value]) ? $status[$value] : '';
|
||||
|
||||
}
|
||||
public static function ChangeTypeLable($type="")
|
||||
|
||||
public static function ChangeTypeLable($type = "")
|
||||
{
|
||||
$status = [
|
||||
self::OPERATION_SYSTEM => '系统调节',
|
||||
self::OPERATION_RECHARGE => '会员充值',
|
||||
self::OPERATION_WITHDRAW => '会员提现',
|
||||
self::OPERATION_CONSUME => '金币转增(送出)',
|
||||
self::DAILY_TASKS_REWARD => '任务奖励',
|
||||
self::OPERATION_INVITE_REBATE => '邀请用户充值返利',
|
||||
self::OPERATION_DECORATION => '购买装扮',
|
||||
self::GIFT_BOX_REWARD => '礼盒奖励',
|
||||
self::ROOM_SUBSIDY => '房间补贴',
|
||||
self::OPERATION_GIFT => '购买礼物',
|
||||
self::GIVE_GIFT_EARNING => '送礼增加收益',
|
||||
self::GUILD_SUBSIDY => '工会补贴',
|
||||
self::USER_RECEIVE => '会员转赠(接收)',
|
||||
self::MONEY_CONVERSION => '钻石兑换金币',
|
||||
self::FIRST_CHARGE => '首充',
|
||||
self::DROP_GIFT_REWARD => '天降好礼充值',
|
||||
self::GUILD_EXIT => '退出工会扣款',
|
||||
self::ROOM_OWNER_EARNINGS => '房主收益',
|
||||
self::HOST_EARNINGS => '主持人收益',
|
||||
self::HEADLINE_REWARD => '抢头条',
|
||||
self::GUILD_EARNINGS => '公会长收益',
|
||||
self::WITHDRAW_FAILURE => '提现驳回或提现失败返还',
|
||||
self::FINANCE_LEVEL_REWARD => '财富等级奖励金币领取',
|
||||
self::DELETE_RELATION_COIN => '删除关系扣金币',
|
||||
self::TRANSFER_COIN => '赠送好友金币',
|
||||
self::RECEIVE_COIN => '好友转赠所得金币',
|
||||
self::HOUR_RANK_COIN => '小时榜获得金币',
|
||||
self::NEW_USER_CHARGE_GIFT => '新人充值好礼',
|
||||
self::RED_PACKET_COIN => '发红包(金币)',
|
||||
self::RED_PACKET_DIAMOND => '发红包(钻石)',
|
||||
self::RED_PACKET_COIN_RECEIVE => '抢红包(金币)',
|
||||
self::OPERATION_SYSTEM => '系统调节',
|
||||
self::OPERATION_RECHARGE => '会员充值',
|
||||
self::OPERATION_WITHDRAW => '会员提现',
|
||||
self::OPERATION_CONSUME => '金币转增(送出)',
|
||||
self::DAILY_TASKS_REWARD => '任务奖励',
|
||||
self::OPERATION_INVITE_REBATE => '邀请用户充值返利',
|
||||
self::OPERATION_DECORATION => '购买装扮',
|
||||
self::GIFT_BOX_REWARD => '礼盒奖励',
|
||||
self::ROOM_SUBSIDY => '房间补贴',
|
||||
self::OPERATION_GIFT => '购买礼物',
|
||||
self::GIVE_GIFT_EARNING => '送礼增加收益',
|
||||
self::GUILD_SUBSIDY => '工会补贴',
|
||||
self::USER_RECEIVE => '会员转赠(接收)',
|
||||
self::MONEY_CONVERSION => '钻石兑换金币',
|
||||
self::FIRST_CHARGE => '首充',
|
||||
self::DROP_GIFT_REWARD => '天降好礼充值',
|
||||
self::GUILD_EXIT => '退出工会扣款',
|
||||
self::ROOM_OWNER_EARNINGS => '房主收益',
|
||||
self::HOST_EARNINGS => '主持人收益',
|
||||
self::HEADLINE_REWARD => '抢头条',
|
||||
self::GUILD_EARNINGS => '公会长收益',
|
||||
self::WITHDRAW_FAILURE => '提现驳回或提现失败返还',
|
||||
self::FINANCE_LEVEL_REWARD => '财富等级奖励金币领取',
|
||||
self::DELETE_RELATION_COIN => '删除关系扣金币',
|
||||
self::TRANSFER_COIN => '赠送好友金币',
|
||||
self::RECEIVE_COIN => '好友转赠所得金币',
|
||||
self::HOUR_RANK_COIN => '小时榜获得金币',
|
||||
self::NEW_USER_CHARGE_GIFT => '新人充值好礼',
|
||||
self::RED_PACKET_COIN => '发红包(金币)',
|
||||
self::RED_PACKET_DIAMOND => '发红包(钻石)',
|
||||
self::RED_PACKET_COIN_RECEIVE => '抢红包(金币)',
|
||||
self::RED_PACKET_DIAMOND_RECEIVE => '抢红包(钻石)',
|
||||
self::RED_PACKET_LEFT_COIN => '红包剩余退回(金币)',
|
||||
self::RED_PACKET_LEFT_DIAMOND => '红包剩余退回(钻石)',
|
||||
self::NOBILITY_PURCHASE_COIN => '爵位购买赠送(金币)',
|
||||
self::SIGN => '签约支出',
|
||||
self::SIGN_FAILURE => '签约失败退回',
|
||||
self::FIRST_SIGN_INCOME => '首次被签约收入',
|
||||
self::SIGN_MASTER_DAILY_RETURN => '签约师傅每日返还',
|
||||
self::BELIEVER_COMPENSATION => '解约补偿',
|
||||
self::SIGN_BE_SIGNED_INCOME => '被签约者收礼返佣给上级',
|
||||
self::RENEWAL => '续约',
|
||||
self::DAILY_SIGN => '每日签到',
|
||||
self::BOMB_COIN => '参与幸运币活动获得',
|
||||
|
||||
self::RED_PACKET_LEFT_COIN => '红包剩余退回(金币)',
|
||||
self::RED_PACKET_LEFT_DIAMOND => '红包剩余退回(钻石)',
|
||||
self::NOBILITY_PURCHASE_COIN => '爵位购买赠送(金币)',
|
||||
self::SIGN => '签约支出',
|
||||
self::SIGN_FAILURE => '签约失败退回',
|
||||
self::FIRST_SIGN_INCOME => '首次被签约收入',
|
||||
self::SIGN_MASTER_DAILY_RETURN => '签约师傅每日返还',
|
||||
self::BELIEVER_COMPENSATION => '解约补偿',
|
||||
self::SIGN_BE_SIGNED_INCOME => '被签约者收礼返佣给上级',
|
||||
self::RENEWAL => '续约',
|
||||
self::DAILY_SIGN => '每日签到',
|
||||
self::BOMB_COIN => '参与幸运币活动获得',
|
||||
self::RED_PACKET_FEE => '发红包手续费',
|
||||
self::BACKGROUND_RECHARGE_COIN => '后台充值金币',
|
||||
self::BACKGROUND_RECHARGE_DIAMOND => '后台充值钻石',
|
||||
self::BACKGROUND_DEDUCTION_COIN => '后台扣除金币',
|
||||
self::BACKGROUND_DEDUCTION_DIAMOND => '后台扣除钻石',
|
||||
self::GUILD_EXIT_DEACON_INCOME => "公会会员付费退出会长收入"
|
||||
];
|
||||
if($type){
|
||||
if ($type) {
|
||||
return $status[$type] ?? '';
|
||||
}else{
|
||||
} else {
|
||||
return $status;
|
||||
}
|
||||
|
||||
@@ -222,132 +245,128 @@ class UserWallet extends Model
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function change_user_money($user_id, $change_value, $money_type,$change_type, $remarks = "", $room_id=0,$from_uid = 0, $from_id = 0)
|
||||
public function change_user_money($user_id, $change_value, $money_type, $change_type, $remarks = "", $room_id = 0, $from_uid = 0, $from_id = 0)
|
||||
{
|
||||
if (in_array($change_type, $this->coin_consumption_type_array) && $money_type==self::MONEYTYPECOIN) {//金币支出
|
||||
$change_value = $change_value * -1;
|
||||
}
|
||||
if (in_array($change_type, $this->diamond_consumption_type_array) && $money_type==self::MONEYTYPEARNINGS){//钻石支出
|
||||
$change_value = $change_value * -1;
|
||||
// 确定操作的表
|
||||
$table_name = $money_type == self::MONEYTYPECOIN ? 'user_wallet_coin' : 'user_wallet_earnings';
|
||||
|
||||
// 如果是后台操作(change_type == 1),则根据金额正负自动设置具体的变更类型
|
||||
if ($change_type == 1) {
|
||||
if ($money_type == self::MONEYTYPECOIN) {
|
||||
$change_type = $change_value > 0 ? self::BACKGROUND_RECHARGE_COIN : self::BACKGROUND_DEDUCTION_COIN;
|
||||
} else {
|
||||
$change_type = $change_value > 0 ? self::BACKGROUND_RECHARGE_DIAMOND : self::BACKGROUND_DEDUCTION_DIAMOND;
|
||||
}
|
||||
}
|
||||
$change_value = abs($change_value);
|
||||
|
||||
// 验证用户信息
|
||||
$user_info = db::name('user')->find($user_id);
|
||||
if (empty($user_info['id'])) {
|
||||
return ['code' => 0, 'msg' => "用户信息错误", 'data' => null];
|
||||
}
|
||||
$user_wallet = db::name('user_wallet')->where(['user_id' => $user_id])->find();
|
||||
|
||||
// 获取用户钱包信息
|
||||
$user_wallet = db::name($table_name)->where(['user_id' => $user_id])->find();
|
||||
if (empty($user_wallet['id'])) {
|
||||
return ['code' => 0, 'msg' => "用户信息错误", 'data' => null];
|
||||
return ['code' => 0, 'msg' => "用户钱包信息错误", 'data' => null];
|
||||
}
|
||||
|
||||
// 验证资金类型
|
||||
$money_type_str = $this->getMoneyType($money_type);
|
||||
if (empty($money_type_str)) {
|
||||
return ['code' => 0, 'msg' => "非法资金类型", 'data' => null];
|
||||
}
|
||||
$after_coin = $user_wallet['coin'];
|
||||
$after_earnings = $user_wallet['earnings'];
|
||||
if ($money_type == 1) {
|
||||
$change_field = "coin";
|
||||
$after_coin += $change_value;
|
||||
if($after_coin > 99999999){
|
||||
|
||||
// 检查金额是否为数字
|
||||
if (!is_numeric($change_value)) {
|
||||
return ['code' => 0, 'msg' => "变动的数值必须为数字", 'data' => null];
|
||||
}
|
||||
|
||||
// 验证并检查余额上限
|
||||
if ($money_type == self::MONEYTYPECOIN) {
|
||||
$after_coin = $user_wallet['coin'] + $change_value;
|
||||
if ($after_coin > 99999999) {
|
||||
return ['code' => 0, 'msg' => "当前用户金币已达上限", 'data' => null];
|
||||
}
|
||||
} elseif ($money_type == 2) {
|
||||
$change_field = "earnings";
|
||||
$after_earnings += $change_value;
|
||||
if($after_earnings > 99999999){
|
||||
} elseif ($money_type == self::MONEYTYPEARNINGS) {
|
||||
$after_earnings = $user_wallet['earnings'] + $change_value;
|
||||
if ($after_earnings > 99999999) {
|
||||
return ['code' => 0, 'msg' => "当前用户钻石已达上限", 'data' => null];
|
||||
}
|
||||
} else {
|
||||
return ['code' => 0, 'msg' => "非法资金类型", 'data' => null];
|
||||
}
|
||||
|
||||
// 验证变更类型
|
||||
$change_name = $this->ChangeTypeLable($change_type);
|
||||
if(empty($change_name)){
|
||||
if (empty($change_name)) {
|
||||
return ['code' => 0, 'msg' => "非法资金变动类型", 'data' => null];
|
||||
}
|
||||
if (!is_numeric($change_value)) {
|
||||
return ['code' => 0, 'msg' => "变动的数值必须为数字", 'data' => null];
|
||||
|
||||
// 记录资金变动日志
|
||||
if ($money_type == self::MONEYTYPECOIN) {
|
||||
$return = model('api/UserWallet')->change_user_cion_log($user_id, $change_value, $room_id, $change_type, $remarks);
|
||||
} else {
|
||||
$return = model('api/UserWallet')->change_user_earnings_log($user_id, $change_value, $room_id, $change_type, $remarks);
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['user_id'] = $user_id;
|
||||
$data['room_id'] = $room_id;
|
||||
$data['change_type'] = $change_type;
|
||||
$data['money_type'] = $money_type;
|
||||
$data['change_value'] = abs($change_value);
|
||||
$data['after_coin'] = $after_coin;
|
||||
$data['after_earnings'] = $after_earnings;
|
||||
$data['from_id'] = $from_id;
|
||||
$data['from_uid'] = $from_uid;
|
||||
$data['remarks'] = $remarks;
|
||||
$data['createtime'] = time();
|
||||
$data['updatetime'] = time();
|
||||
Db::startTrans();
|
||||
try {
|
||||
if($change_value < 0){
|
||||
$change_value_abs = abs($change_value);
|
||||
$change_value_up = $user_wallet[$change_field] - $change_value_abs;
|
||||
if($change_value_up<0){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => $money_type_str . "不足", 'data' => null];
|
||||
}
|
||||
}
|
||||
Db::name('user_wallet')->where('user_id', $user_id)->inc($change_field, $change_value)->update(['updatetime' => time()]);
|
||||
$reslut = Db::name('vs_user_money_log')->insert($data);
|
||||
if (!$reslut) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => "请重试", 'data' => null];
|
||||
}
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
return ['code' => 1, 'msg' => "操作成功", 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
// 修正返回值逻辑:如果日志记录成功,返回成功;如果日志记录失败,返回失败
|
||||
if (!$return) {
|
||||
return ['code' => 0, 'msg' => "请重试", 'data' => null];
|
||||
} else {
|
||||
return ['code' => 1, 'msg' => "操作成功", 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 用户资金变动日志
|
||||
*/
|
||||
public function money_change_log($user_id,$seach, $money_type=0, $page=0,$page_limit=30){
|
||||
if($money_type){
|
||||
$where['money_type'] =$money_type;
|
||||
public function money_change_log($user_id, $seach, $money_type = 0, $page = 0, $page_limit = 30)
|
||||
{
|
||||
if ($money_type == self::MONEYTYPECOIN) {
|
||||
$table_name_log = 'user_coin_log';
|
||||
} else {
|
||||
$table_name_log = 'user_earnings_log';
|
||||
}
|
||||
if($seach['stime']){
|
||||
$where['createtime'] = ['>=',strtotime($seach['stime'])];
|
||||
$where = [];
|
||||
if ($seach['stime']) {
|
||||
$where['createtime'] = ['>=', strtotime($seach['stime'])];
|
||||
}
|
||||
if($seach['etime']){
|
||||
$where['createtime'] = ['<=',strtotime($seach['etime'])];
|
||||
if ($seach['etime']) {
|
||||
$where['createtime'] = ['<=', strtotime($seach['etime'])];
|
||||
}
|
||||
if($seach['change_type']){
|
||||
$where['change_type'] =$seach['change_type'];
|
||||
if ($seach['change_type']) {
|
||||
$where['change_type'] = $seach['change_type'];
|
||||
}
|
||||
$log['count'] = Db::name('vs_user_money_log')->where($where)->where('user_id',$user_id)->count();
|
||||
$log_select = Db::name('vs_user_money_log')
|
||||
$log['count'] = Db::name($table_name_log)->where($where)->where('user_id', $user_id)->count('id');
|
||||
$log_select = Db::name($table_name_log)
|
||||
->where($where)
|
||||
->where('user_id',$user_id)
|
||||
->order('log_id desc');
|
||||
if($page){
|
||||
$log_select->page($page,$page_limit);
|
||||
->where('user_id', $user_id)
|
||||
->order('createtime desc');
|
||||
if ($page) {
|
||||
$log_select->page($page, $page_limit);
|
||||
}
|
||||
$log['list'] = $log_select->select();
|
||||
foreach ($log['list'] as $key => &$value) {
|
||||
$value['money_type'] = $this->getMoneyType($value['money_type']);
|
||||
$value['money_type'] = $this->getMoneyType($money_type);
|
||||
$change_type = $value['change_type'];
|
||||
$value['change_type'] = $this->ChangeTypeLable($value['change_type']);
|
||||
$value['createtime'] = date('Y-m-d H:i:s',$value['createtime']);
|
||||
if($money_type==1 ){
|
||||
if(in_array($change_type,$this->coin_consumption_type_array)){
|
||||
$value['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
if ($money_type == self::MONEYTYPECOIN) {
|
||||
if (in_array($change_type, $this->coin_consumption_type_array)) {
|
||||
$value['change_in_out'] = "支出";
|
||||
$value['change_value'] = $value['change_value']*-1;
|
||||
}else{
|
||||
$value['change_value'] = $value['coin'] * -1;
|
||||
} else {
|
||||
$value['change_value'] = $value['coin'];
|
||||
$value['change_in_out'] = "收入";
|
||||
}
|
||||
}else{
|
||||
if(in_array($change_type,$this->diamond_consumption_type_array)){
|
||||
} else {
|
||||
if (in_array($change_type, $this->diamond_consumption_type_array)) {
|
||||
$value['change_in_out'] = "支出";
|
||||
$value['change_value'] = $value['change_value']*-1;
|
||||
}else{
|
||||
$value['change_value'] = $value['earnings'] * -1;
|
||||
} else {
|
||||
$value['change_value'] = $value['earnings'];
|
||||
$value['change_in_out'] = "收入";
|
||||
}
|
||||
}
|
||||
@@ -359,7 +378,8 @@ class UserWallet extends Model
|
||||
/*
|
||||
* 获取用户资金类型
|
||||
*/
|
||||
public function getChangeTypeLableList(){
|
||||
public function getChangeTypeLableList()
|
||||
{
|
||||
return $this->ChangeTypeLable();
|
||||
}
|
||||
}
|
||||
88
application/cron/controller/AppTodayStatistical.php
Normal file
88
application/cron/controller/AppTodayStatistical.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace app\cron\controller;
|
||||
|
||||
use app\common\controller\Push;
|
||||
use think\Cache;
|
||||
use think\Db;
|
||||
|
||||
|
||||
/*
|
||||
* 定时任务,每秒执行的方法
|
||||
*/
|
||||
class AppTodayStatistical
|
||||
{
|
||||
/*
|
||||
* 运行函数
|
||||
*/
|
||||
function index()
|
||||
{
|
||||
echo "每日12点统计用户数据:\n";
|
||||
$this->daily_statistics();
|
||||
echo "每日12点统计用户数据结束 \n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 每日12点统计用户数据
|
||||
*/
|
||||
public function daily_statistics(){
|
||||
echo date('Y-m-d')."每日统计开始:\n";
|
||||
$time = strtotime(date('Y-m-d'));
|
||||
$stime = strtotime(date('Y-m-d'));
|
||||
$etime = strtotime(date('Y-m-d 23:59:59'));
|
||||
// $user_list = Db::name('user_wallet')->select();
|
||||
$user_list = db::name('user_wallet_coin')->select();
|
||||
foreach ($user_list as $k=>$v){
|
||||
$gift_pack = Db::name('vs_user_gift_pack')->field('gid,num')->where(['user_id'=>$v['user_id'],'is_tester'=>1])->select();
|
||||
$gift_pack_price = 0;
|
||||
foreach ($gift_pack as $key=>$val){
|
||||
$gift_pack_price += Db::name('vs_gift')->where(['gid'=>$val['gid'],])->value('gift_price')*$val['num'];
|
||||
}
|
||||
//用户房间今日总流水
|
||||
//用户房间id
|
||||
$room_id = db::name('vs_room')->where('user_id', $v['user_id'])->value('id');
|
||||
$transaction = 0;
|
||||
if($room_id){
|
||||
$transaction = db::name('vs_give_gift')
|
||||
->where('from_id',$room_id)
|
||||
->where('from',2)
|
||||
->whereBetween('createtime', [$stime, $etime])
|
||||
->sum('total_price');
|
||||
}
|
||||
//公会流水
|
||||
$guild_flow_price = 0;
|
||||
$guild_id = db::name('vs_guild')->where(['user_id'=>$v['user_id'],'status'=>1,'delete_time'=>0])->value('id');
|
||||
if($guild_id){
|
||||
$guild_flow_price= db::name('vs_guild_flow')->where('guild_id', $guild_id)->where('day', date('Y-m-d',$time))->sum('flow_price');
|
||||
}
|
||||
//充值金额
|
||||
$recharge_price = db::name('vs_user_recharge')
|
||||
->where('user_id', $v['user_id'])
|
||||
->where('pay_status',2)
|
||||
->whereBetween('pay_time', [$stime, $etime])
|
||||
->sum('money');
|
||||
//提现
|
||||
$withdraw_price = db::name('vs_user_withdrawal')
|
||||
->where('user_id', $v['user_id'])
|
||||
->whereIn('status',[2,6])
|
||||
->whereBetween('createtime', [$stime, $etime])
|
||||
->sum('money');
|
||||
$data = [
|
||||
'user_id'=>$v['user_id']??0,
|
||||
'coin'=>$v['coin']??0,
|
||||
'earnings'=> db::name('user_wallet_earnings')->where('user_id', $v['user_id'])->value('earnings')??0,
|
||||
'gift_pack_price'=>$gift_pack_price??0,
|
||||
'room_flow_price'=>$transaction??0,
|
||||
'guild_flow_price'=>$guild_flow_price??0,
|
||||
'recharge_price'=>$recharge_price??0,
|
||||
'withdraw_price'=>$withdraw_price??0,
|
||||
'day'=>date('Y-m-d',$time),
|
||||
'createtime'=>$time,
|
||||
];
|
||||
Db::name('vs_app_today_statistical')->insert($data);
|
||||
}
|
||||
echo date('Y-m-d')."每日统计结束 用户数量".count($user_list)." \n";
|
||||
}
|
||||
}
|
||||
@@ -50,6 +50,13 @@ class FriendEnd
|
||||
public function clear_room_end()
|
||||
{
|
||||
$room_list = db::name('vs_room_cp_movie')->where(['status' => 1,'type'=>1,'time_day' =>['<',time()]])->select();
|
||||
if(!empty($room_list)){
|
||||
foreach ($room_list as $room) {
|
||||
model('api/Friend')->outRoom(1,$room['room_id']);
|
||||
}
|
||||
}
|
||||
//酒吧房私密小屋
|
||||
$room_list = db::name('vs_room_bar_movie')->where(['status' => 1,'end_time' =>['<',time()]])->select();
|
||||
if(!empty($room_list)){
|
||||
foreach ($room_list as $room) {
|
||||
model('api/Friend')->outRoom(0,$room['room_id']);
|
||||
|
||||
@@ -51,6 +51,10 @@ class PerformPerSecond
|
||||
$this->sign_room_time_end();
|
||||
echo "\n";
|
||||
|
||||
echo "酒吧房间时间结束处理:\n";
|
||||
$this->bar_room_time_end();
|
||||
echo "\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -146,7 +150,7 @@ class PerformPerSecond
|
||||
public function withdraw_order_status(){
|
||||
//一个月内的数据
|
||||
$time = time() - 7 * 86400;
|
||||
$withdrawal = db::name('vs_user_withdrawal')->where(['deal_type'=>2,'status'=>['in',[4,5]]])->where(['submit_yun_time'=>['>=',$time]])->select();
|
||||
$withdrawal = db::name('vs_user_withdrawal')->where(['deal_type'=>2,'status'=>['in',[4,5]],'refund_time'=>0])->where(['submit_yun_time'=>['>=',$time]])->select();
|
||||
echo "提现云账号订单状态查询条数(".count($withdrawal)."):\n";
|
||||
foreach ($withdrawal as $key => $value) {
|
||||
if($value['status'] == 5){
|
||||
@@ -154,7 +158,7 @@ class PerformPerSecond
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if(in_array($value['yun_order_status'],[261,5077])){
|
||||
if(in_array($value['yun_order_status'],[261,5077,255])){
|
||||
continue;
|
||||
}
|
||||
echo "提现订单查询:".$value['order_sn']."\n";
|
||||
@@ -162,7 +166,13 @@ class PerformPerSecond
|
||||
$result = $yun_pay->queryOrder($value['type']);
|
||||
if($result['code'] == 1){
|
||||
if($result['data']['code']==0){
|
||||
db::name('vs_user_withdrawal')->where('order_sn',$value['order_sn'])->update([
|
||||
if($value['type']==3){
|
||||
if($result['data']['msg']=="已受理"){
|
||||
print_r($result);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$up_result = db::name('vs_user_withdrawal')->where('order_sn',$value['order_sn'])->update([
|
||||
'status' => 6,
|
||||
'pay_time' => time(),
|
||||
'pay_message' => $result['data']['msg'],
|
||||
@@ -171,6 +181,12 @@ class PerformPerSecond
|
||||
// 'personal_tax_rate' => $result['personal_tax_rate'] ?? 0,
|
||||
'received_tax_amount' => $result['data']['received_tax_amount'] ?? 0,
|
||||
]);
|
||||
// if($up_result){
|
||||
// //扣除冻结金额
|
||||
// $diamond_to_rmb_ratio = get_system_config_value('diamond_to_rmb_ratio');
|
||||
// $money = $value['money'] * $diamond_to_rmb_ratio; //提现金额转换 人民币转为钻石
|
||||
// $result = db::name('user_wallet')->where('user_id', $value['user_id'])->setDec('frozen_earnings', $money);
|
||||
// }
|
||||
}else{
|
||||
db::name('vs_user_withdrawal')->where('order_sn',$value['order_sn'])->update([
|
||||
'status' => 5,
|
||||
@@ -181,7 +197,8 @@ class PerformPerSecond
|
||||
// 'personal_tax_rate' => $result['personal_tax_rate'] ?? 0,
|
||||
'received_tax_amount' => $result['data']['received_tax_amount'] ?? 0,
|
||||
]);
|
||||
if(in_array($result['data']['code'],[5077,261]) && $value['yun_order_status'] == null){
|
||||
// if(in_array($result['data']['code'],[5077,261]) && $value['yun_order_status'] == null){
|
||||
if(in_array($result['data']['code'],[5077,261,255]) && !in_array($value['yun_order_status'],[5077,261,255])){
|
||||
// if($result['data']['code']==5077 && $value['yun_order_status'] == null){
|
||||
//该支付宝账户不存在或未开通手机号转账功能。如有疑问,请收款用户联系支付宝客服咨询。
|
||||
//退还金币
|
||||
@@ -365,4 +382,20 @@ class PerformPerSecond
|
||||
}
|
||||
}
|
||||
|
||||
//酒吧房间时间结束处理
|
||||
public function bar_room_time_end(){
|
||||
$bar_pit_gift = Db::name('vs_room_pit')->where(['end_time'=>['<',time()]])->where(['end_time'=>['<>',0]])->select();
|
||||
if($bar_pit_gift){
|
||||
foreach ($bar_pit_gift as $value){
|
||||
$re = model('api/RoomPit')->DownPit($value['user_id'],$value['room_id'],$value['pit_number']);
|
||||
if($re['code']==1){
|
||||
// db::name('vs_room_bar_pit_gift')->where('id',$value['id'])->update(['delete_time'=>time()]);
|
||||
echo "用户".$value['user_id']."房间".$value['room_id']."已下麦\n";
|
||||
}else{
|
||||
echo $re['msg']."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "酒吧房间时间结束处理完成\n";
|
||||
}
|
||||
}
|
||||
@@ -196,11 +196,10 @@ class RoomPan
|
||||
$roomtype = Db::name('vs_room')->where(['id' => $room_id])->value('type_id');
|
||||
if($roomtype == 6){
|
||||
//推送消息
|
||||
$hot_value = db::name('vs_give_gift')->where('from_id', $room_id)->where('from',6)
|
||||
->sum('total_price');
|
||||
$hot_value = db::name('vs_room')->where('id', $room_id)->value('hot_value');
|
||||
$text1 = [
|
||||
'room_id' => $room_id,
|
||||
'hot_value' => $hot_value * 10,
|
||||
'hot_value' => $hot_value,
|
||||
'text' => '房间心动值变化'
|
||||
];
|
||||
//聊天室推送系统消息
|
||||
|
||||
@@ -31,13 +31,92 @@ class Subsidy
|
||||
* 配置:定时脚本每周一 执行
|
||||
* 配置:/cron/Subsidy/createGuildSubsidyData
|
||||
*/
|
||||
// public function createGuildSubsidyData(){
|
||||
// //获取上周第一天时间
|
||||
// $week_start_time = strtotime('last week Monday');
|
||||
// $week_end_time = strtotime(date('Y-m-d 23:59:59',strtotime('last week Sunday')));
|
||||
//// $week_start_time = strtotime('2025-09-29');
|
||||
//// $week_end_time = strtotime('2025-09-29 23:59:59');
|
||||
//
|
||||
// //获取上周时间
|
||||
// $time_value = date('o-W', $week_start_time);
|
||||
// echo $time_value . "工会周补贴数据生成开始\n";
|
||||
// //查询所有工会
|
||||
// $guild_list = db::name('vs_guild')->where(['delete_time'=>0])->field('id')->select();
|
||||
// $data_count = 0;
|
||||
// foreach ($guild_list as $key => $value) {
|
||||
// //获取所有工会房间ID
|
||||
// $guild_user_data = db::name('vs_guild_user')->where('guild_id', $value['id'])->where(['apply_time'=>['>',0],'status'=>1,'room_id'=>['>',0]])->field('room_id,apply_time,quit_time')->select();
|
||||
// $transaction = 0;
|
||||
// foreach ($guild_user_data as $k => $v) {
|
||||
// $week_start_time_seach = $week_start_time;
|
||||
// $week_end_time_seach = $week_end_time;
|
||||
// if($v['apply_time'] && $week_end_time_seach < $v['apply_time']){
|
||||
// continue;
|
||||
// }
|
||||
// if($v['quit_time'] && $v['quit_time'] < $week_start_time_seach){
|
||||
// continue;
|
||||
// }
|
||||
// if($v['apply_time'] && $week_start_time_seach < $v['apply_time']){
|
||||
// $week_start_time_seach = $v['apply_time'];
|
||||
// }
|
||||
// if($v['quit_time'] && ($week_end_time_seach > $v['quit_time'])){
|
||||
// $week_end_time_seach = $v['quit_time'];
|
||||
// }
|
||||
// $transaction_one = db::name('vs_give_gift')
|
||||
// ->whereIn('from_id',$v['room_id'])
|
||||
// ->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$week_start_time_seach, $week_end_time_seach]]])
|
||||
// ->sum('total_price');
|
||||
// $transaction += $transaction_one;
|
||||
// }
|
||||
//
|
||||
// if($transaction > 0){
|
||||
// //判断是否已经生成过
|
||||
// if (db::name('vs_guild_subsidy')->where(['guild_id'=>$value['id'],'week'=>$time_value])->find()) {
|
||||
// continue;
|
||||
// }
|
||||
// //获取补贴配置
|
||||
// $config = db::name('vs_guild_subsidy_config')->where(['status' => 1])->order('end_amount desc')->select(); //配置查询
|
||||
// if (!$config) {
|
||||
// echo '补贴配置为空\n';
|
||||
// die;
|
||||
// }
|
||||
// $subsidy_ratio = 0;
|
||||
// $subsidy_amount = 0;
|
||||
// foreach ($config as $k => $v) {
|
||||
// if ($transaction >= $v['end_amount']) {
|
||||
// $subsidy_ratio = $v['subsidy_ratio'];
|
||||
// $subsidy_amount = ($transaction * ($subsidy_ratio / 100)) / get_system_config_value('rmb_coin_ratio');//转为钻石
|
||||
// break; // 找到匹配项后提前退出循环
|
||||
// }
|
||||
// }
|
||||
// //生成补贴数据
|
||||
// $data = [
|
||||
// 'guild_id' => $value['id'],
|
||||
// 'week' => $time_value,
|
||||
// 'start_time' => date('Y-m-d H:i:s', $week_start_time),
|
||||
// 'end_time' =>date('Y-m-d H:i:s', $week_end_time),
|
||||
// 'total_transaction' => $transaction,
|
||||
// 'subsidy_amount' => $subsidy_amount,
|
||||
// 'subsidy_ratio' => $subsidy_ratio,
|
||||
// 'status' => 0,
|
||||
// 'createtime' => time(),
|
||||
// ];
|
||||
// // echo "工会".$value['id']."生成数据:流水金额:{$transaction} 补贴比例:{$subsidy_ratio}% 补贴金额:{$subsidy_amount}\n";
|
||||
// $subsidy_id = Db::name('vs_guild_subsidy')->insertGetId($data);
|
||||
// if ($subsidy_id) {
|
||||
// echo "工会".$value['id']."生成成功(补贴ID:".$subsidy_id." 补贴金额:".$subsidy_amount.")\n";
|
||||
// $data_count++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// echo $time_value . "工会周补贴数据生成完成-共" . $data_count . "条数据\n";
|
||||
// }
|
||||
|
||||
public function createGuildSubsidyData(){
|
||||
//获取上周第一天时间
|
||||
$week_start_time = strtotime('last week Monday');
|
||||
$week_end_time = strtotime(date('Y-m-d 23:59:59',strtotime('last week Sunday')));
|
||||
// $week_start_time = strtotime('2025-09-29');
|
||||
// $week_end_time = strtotime('2025-09-29 23:59:59');
|
||||
|
||||
//获取上周时间
|
||||
$time_value = date('o-W', $week_start_time);
|
||||
echo $time_value . "工会周补贴数据生成开始\n";
|
||||
@@ -45,31 +124,10 @@ class Subsidy
|
||||
$guild_list = db::name('vs_guild')->where(['delete_time'=>0])->field('id')->select();
|
||||
$data_count = 0;
|
||||
foreach ($guild_list as $key => $value) {
|
||||
//获取所有工会房间ID
|
||||
$guild_user_data = db::name('vs_guild_user')->where('guild_id', $value['id'])->where(['apply_time'=>['>',0],'status'=>1,'room_id'=>['>',0]])->field('room_id,apply_time,quit_time')->select();
|
||||
$transaction = 0;
|
||||
foreach ($guild_user_data as $k => $v) {
|
||||
$week_start_time_seach = $week_start_time;
|
||||
$week_end_time_seach = $week_end_time;
|
||||
if($v['apply_time'] && $week_end_time_seach < $v['apply_time']){
|
||||
continue;
|
||||
}
|
||||
if($v['quit_time'] && $v['quit_time'] < $week_start_time_seach){
|
||||
continue;
|
||||
}
|
||||
if($v['apply_time'] && $week_start_time_seach < $v['apply_time']){
|
||||
$week_start_time_seach = $v['apply_time'];
|
||||
}
|
||||
if($v['quit_time'] && ($week_end_time_seach > $v['quit_time'])){
|
||||
$week_end_time_seach = $v['quit_time'];
|
||||
}
|
||||
$transaction_one = db::name('vs_give_gift')
|
||||
->whereIn('from_id',$v['room_id'])
|
||||
->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$week_start_time_seach, $week_end_time_seach]]])
|
||||
->sum('total_price');
|
||||
$transaction += $transaction_one;
|
||||
}
|
||||
|
||||
$transaction = Db::name('vs_guild_flow')
|
||||
->where(['guild_id' => $value['id']])
|
||||
->where(['createtime' => ['between', [$week_start_time, $week_end_time]]])
|
||||
->sum('flow_price');
|
||||
if($transaction > 0){
|
||||
//判断是否已经生成过
|
||||
if (db::name('vs_guild_subsidy')->where(['guild_id'=>$value['id'],'week'=>$time_value])->find()) {
|
||||
@@ -102,12 +160,12 @@ class Subsidy
|
||||
'status' => 0,
|
||||
'createtime' => time(),
|
||||
];
|
||||
// echo "工会".$value['id']."生成数据:流水金额:{$transaction} 补贴比例:{$subsidy_ratio}% 补贴金额:{$subsidy_amount}\n";
|
||||
$subsidy_id = Db::name('vs_guild_subsidy')->insertGetId($data);
|
||||
if ($subsidy_id) {
|
||||
echo "工会".$value['id']."生成成功(补贴ID:".$subsidy_id." 补贴金额:".$subsidy_amount.")\n";
|
||||
$data_count++;
|
||||
}
|
||||
// echo "工会".$value['id']."生成数据:流水金额:{$transaction} 补贴比例:{$subsidy_ratio}% 补贴金额:{$subsidy_amount}\n";
|
||||
$subsidy_id = Db::name('vs_guild_subsidy_1')->insertGetId($data);
|
||||
if ($subsidy_id) {
|
||||
echo "工会".$value['id']."生成成功(补贴ID:".$subsidy_id." 补贴金额:".$subsidy_amount.")\n";
|
||||
$data_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo $time_value . "工会周补贴数据生成完成-共" . $data_count . "条数据\n";
|
||||
|
||||
@@ -27,7 +27,11 @@ class Test
|
||||
//
|
||||
// $this->clean_guild_flow();
|
||||
|
||||
$this->createGuildSubsidyData();
|
||||
// $this->giftSend();
|
||||
// $this->createGuildSubsidyDataNewNew();
|
||||
// $this->task_coin_count();
|
||||
$this->createGuildSubsidyDataNew();
|
||||
// $this->repair_guild_room_data();
|
||||
|
||||
}
|
||||
|
||||
@@ -693,4 +697,358 @@ class Test
|
||||
echo $time_value . "工会周补贴数据生成完成-共" . $data_count . "条数据\n";
|
||||
}
|
||||
|
||||
/*
|
||||
* 生成工会补贴数据
|
||||
* 配置:定时脚本每周一 执行
|
||||
* 配置:/cron/Subsidy/createGuildSubsidyData
|
||||
*/
|
||||
public function createGuildSubsidyDataNew(){
|
||||
//获取上周第一天时间
|
||||
$week_start_time = strtotime('last week Monday');
|
||||
$week_end_time = strtotime(date('Y-m-d 23:59:59',strtotime('last week Sunday')));
|
||||
|
||||
// $week_start_time = strtotime('2025-12-08');
|
||||
// $week_end_time = strtotime('2025-12-15');
|
||||
|
||||
// $week_start_time = strtotime('2025-12-15');
|
||||
// $week_end_time = strtotime('2025-12-22');
|
||||
|
||||
//获取上周时间
|
||||
$time_value = date('o-W', $week_start_time);
|
||||
echo $time_value . "工会周补贴数据生成开始\n";
|
||||
//查询所有工会
|
||||
$guild_list = db::name('vs_guild')->where(['delete_time'=>0])->field('id')->select();
|
||||
$data_count = 0;
|
||||
foreach ($guild_list as $key => $value) {
|
||||
//获取所有工会房间ID
|
||||
$guild_user_data = db::name('vs_guild_user')->where('guild_id', $value['id'])->where(['apply_time'=>['>',0],'status'=>1,'room_id'=>['>',0]])->field('room_id,apply_time,quit_time')->select();
|
||||
$transaction = 0;
|
||||
foreach ($guild_user_data as $k => $v) {
|
||||
|
||||
$week_start_time_seach = $week_start_time;
|
||||
$week_end_time_seach = $week_end_time;
|
||||
if($v['apply_time'] && $week_end_time_seach < $v['apply_time']){
|
||||
continue;
|
||||
}
|
||||
if($v['quit_time'] && $v['quit_time'] < $week_start_time_seach){
|
||||
continue;
|
||||
}
|
||||
if($v['apply_time'] && $week_start_time_seach < $v['apply_time']){
|
||||
$week_start_time_seach = $v['apply_time'];
|
||||
}
|
||||
if($v['quit_time'] && ($week_end_time_seach > $v['quit_time'])){
|
||||
$week_end_time_seach = $v['quit_time'];
|
||||
}
|
||||
$transaction_one = db::name('vs_give_gift')
|
||||
->whereIn('from_id',$v['room_id'])
|
||||
->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$week_start_time_seach, $week_end_time_seach]]])
|
||||
->sum('total_price');
|
||||
$transaction += $transaction_one;
|
||||
}
|
||||
|
||||
if($transaction > 0){
|
||||
//判断是否已经生成过
|
||||
// if (db::name('vs_guild_subsidy')->where(['guild_id'=>$value['id'],'week'=>$time_value])->find()) {
|
||||
// continue;
|
||||
// }
|
||||
//获取补贴配置
|
||||
$config = db::name('vs_guild_subsidy_config')->where(['status' => 1])->order('end_amount desc')->select(); //配置查询
|
||||
if (!$config) {
|
||||
echo '补贴配置为空\n';
|
||||
die;
|
||||
}
|
||||
$subsidy_ratio = 0;
|
||||
$subsidy_amount = 0;
|
||||
foreach ($config as $k => $v) {
|
||||
if ($transaction >= $v['end_amount']) {
|
||||
$subsidy_ratio = $v['subsidy_ratio'];
|
||||
$subsidy_amount = ($transaction * ($subsidy_ratio / 100)) / get_system_config_value('rmb_coin_ratio');//转为钻石
|
||||
break; // 找到匹配项后提前退出循环
|
||||
}
|
||||
}
|
||||
//生成补贴数据
|
||||
$data = [
|
||||
'guild_id' => $value['id'],
|
||||
'week' => $time_value,
|
||||
'start_time' => date('Y-m-d H:i:s', $week_start_time),
|
||||
'end_time' =>date('Y-m-d H:i:s', $week_end_time),
|
||||
'total_transaction' => $transaction,
|
||||
'subsidy_amount' => $subsidy_amount,
|
||||
'subsidy_ratio' => $subsidy_ratio,
|
||||
'status' => 0,
|
||||
'createtime' => time(),
|
||||
];
|
||||
echo "工会".$value['id']."生成数据:流水金额:{$transaction} 补贴比例:{$subsidy_ratio}% 补贴金额:{$subsidy_amount}\n";
|
||||
// $subsidy_id = Db::name('vs_guild_subsidy_1')->insertGetId($data);。。。。11
|
||||
// if ($subsidy_id) {
|
||||
// echo "工会".$value['id']."生成成功(补贴ID:".$subsidy_id." 补贴金额:".$subsidy_amount.")\n";
|
||||
// $data_count++;
|
||||
// }
|
||||
}
|
||||
}
|
||||
echo $time_value . "工会周补贴数据生成完成-共" . $data_count . "条数据\n";
|
||||
}
|
||||
|
||||
/*
|
||||
* 生成工会补贴数据
|
||||
* 配置:定时脚本每周一 执行
|
||||
* 配置:/cron/Subsidy/createGuildSubsidyData
|
||||
*/
|
||||
public function createGuildSubsidyDataNewNew(){
|
||||
//获取上周第一天时间
|
||||
$week_start_time = strtotime('last week Monday');
|
||||
$week_end_time = strtotime(date('Y-m-d 23:59:59',strtotime('last week Sunday')));
|
||||
|
||||
// $week_start_time = strtotime('2025-12-08');
|
||||
// $week_end_time = strtotime('2025-12-15');
|
||||
|
||||
// $week_start_time = strtotime('2025-12-22');
|
||||
// $week_end_time = strtotime('2025-12-31');
|
||||
|
||||
//获取上周时间
|
||||
$time_value = date('o-W', $week_start_time);
|
||||
echo $time_value . "工会周补贴数据生成开始\n";
|
||||
//查询所有工会
|
||||
$guild_list = db::name('vs_guild')->where(['delete_time'=>0])->field('id')->select();
|
||||
$data_count = 0;
|
||||
foreach ($guild_list as $key => $value) {
|
||||
$transaction = Db::name('vs_guild_flow')
|
||||
->where(['guild_id' => $value['id']])
|
||||
->where(['createtime' => ['between', [$week_start_time, $week_end_time]]])
|
||||
->sum('flow_price');
|
||||
if($transaction > 0){
|
||||
//判断是否已经生成过
|
||||
// if (db::name('vs_guild_subsidy')->where(['guild_id'=>$value['id'],'week'=>$time_value])->find()) {
|
||||
// continue;
|
||||
// }
|
||||
//获取补贴配置
|
||||
$config = db::name('vs_guild_subsidy_config')->where(['status' => 1])->order('end_amount desc')->select(); //配置查询
|
||||
if (!$config) {
|
||||
echo '补贴配置为空\n';
|
||||
die;
|
||||
}
|
||||
$subsidy_ratio = 0;
|
||||
$subsidy_amount = 0;
|
||||
foreach ($config as $k => $v) {
|
||||
if ($transaction >= $v['end_amount']) {
|
||||
$subsidy_ratio = $v['subsidy_ratio'];
|
||||
$subsidy_amount = ($transaction * ($subsidy_ratio / 100)) / get_system_config_value('rmb_coin_ratio');//转为钻石
|
||||
break; // 找到匹配项后提前退出循环
|
||||
}
|
||||
}
|
||||
//生成补贴数据
|
||||
$data = [
|
||||
'guild_id' => $value['id'],
|
||||
'week' => $time_value,
|
||||
'start_time' => date('Y-m-d H:i:s', $week_start_time),
|
||||
'end_time' =>date('Y-m-d H:i:s', $week_end_time),
|
||||
'total_transaction' => $transaction,
|
||||
'subsidy_amount' => $subsidy_amount,
|
||||
'subsidy_ratio' => $subsidy_ratio,
|
||||
'status' => 0,
|
||||
'createtime' => time(),
|
||||
];
|
||||
echo "工会".$value['id']."生成数据:流水金额:{$transaction} 补贴比例:{$subsidy_ratio}% 补贴金额:{$subsidy_amount}\n";
|
||||
// $subsidy_id = Db::name('vs_guild_subsidy_1')->insertGetId($data);。。。。11
|
||||
// if ($subsidy_id) {
|
||||
// echo "工会".$value['id']."生成成功(补贴ID:".$subsidy_id." 补贴金额:".$subsidy_amount.")\n";
|
||||
// $data_count++;
|
||||
// }
|
||||
}
|
||||
}
|
||||
echo $time_value . "工会周补贴数据生成完成-共" . $data_count . "条数据\n";
|
||||
}
|
||||
|
||||
//礼物发放
|
||||
public function giftSend(){
|
||||
die;
|
||||
// 用户补偿:12963 3个白马王子 (礼物ID:399)
|
||||
// 10012 5个白马王子(礼物ID:399)
|
||||
|
||||
// $user_id = 24224; //拿大锤
|
||||
// $gift_id = 399; //白马王子
|
||||
// $num = 3;
|
||||
echo $user_id."开始执行\n";die;
|
||||
$res = model('api/UserGiftPack')->change_user_gift_pack($user_id,$gift_id,$num,model('api/UserGiftPack')::SYSTEM_ADJUSTMENT,"补偿:巡乐会卡顿赠送");
|
||||
print_r($res);
|
||||
|
||||
|
||||
// $user_id = 21222; //娃哈哈
|
||||
// $gift_id = 399; //白马王子
|
||||
// $num = 5;
|
||||
echo $user_id."开始执行\n";die;
|
||||
$res = model('api/UserGiftPack')->change_user_gift_pack($user_id,$gift_id,$num,model('api/UserGiftPack')::SYSTEM_ADJUSTMENT,"补偿:巡乐会卡顿赠送");
|
||||
print_r($res);die;
|
||||
}
|
||||
|
||||
//禁言
|
||||
public function mute_member(){
|
||||
$guild_id = 77;
|
||||
$guild_user_ids = db::name('vs_guild_user')
|
||||
->where(['delete_time'=>0])
|
||||
->where(['status'=>1])
|
||||
->where(['guild_id'=>$guild_id])
|
||||
->field('user_id')->select();
|
||||
$user_ids =[];
|
||||
foreach ($guild_user_ids as $key => $value) {
|
||||
$user_ids[] = 'u'.$value['user_id'];
|
||||
}
|
||||
model('api/Tencent')->mute_member('g'.$guild_id, $user_ids, 86400*7);
|
||||
}
|
||||
|
||||
public function cesjs(){
|
||||
$user_nobility_info = db::name('vs_user_nobility')
|
||||
->field('id,user_id,lid,end_time')
|
||||
->where('delete_time', 0)
|
||||
->where(['end_time'=>['>',time()]])
|
||||
->select();
|
||||
foreach ($user_nobility_info as $key => $value) {
|
||||
$nobility_info = db::name('vs_nobility')
|
||||
->field('lid,name,image,pay_price,renew_price,day,power_ids')
|
||||
->where('delete_time', 0)
|
||||
->where('lid', $value['lid'])
|
||||
->find();
|
||||
if($value['end_time'] > time() + $nobility_info['day']*86400){
|
||||
echo $value['user_id']. "续费时间:".date('Y-m-d H:i:s',$value['end_time'])."\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
die();
|
||||
|
||||
|
||||
// echo (1772977260-time()) / (3600*24) ;die;
|
||||
//金币:
|
||||
// $surplus_time = 1769664342 - 1767187765;
|
||||
// if($surplus_time > 0){
|
||||
// //小时
|
||||
// $surplus_time_hour = floor($surplus_time / 3600); //向下取整
|
||||
// $pay_coin = 49999.00 - bcmul($surplus_time_hour * ((10990.00 / 30) / 24),1,2); //一小时的价格算
|
||||
//echo floor($pay_coin);die;
|
||||
|
||||
|
||||
|
||||
|
||||
$old_nobility_info = db::name('vs_nobility')
|
||||
->field('lid,name,pay_price,pay_coin')
|
||||
->where('delete_time', 0)
|
||||
->where('lid',7)
|
||||
->find();
|
||||
$nobility_info = db::name('vs_nobility')
|
||||
->field('lid,name,image,pay_price,renew_price,day,power_ids')
|
||||
->where('delete_time', 0)
|
||||
->where('lid', 8)
|
||||
->find();
|
||||
$old_end_time = 1774848342;
|
||||
$pay_time = 1767278104;
|
||||
$surplus_time = $old_end_time - $pay_time;
|
||||
// echo $surplus_time;
|
||||
if($surplus_time > 0){
|
||||
//小时
|
||||
$surplus_time_hour = floor($surplus_time / 3600); //向下取整
|
||||
// echo $surplus_time_hour;die;
|
||||
// echo ($old_nobility_info['pay_price'] / $nobility_info['day']) / 24;die;
|
||||
$price = $nobility_info['pay_price'] - bcmul($surplus_time_hour * (($old_nobility_info['pay_price'] / $nobility_info['day']) / 24),1,2);
|
||||
|
||||
//使用时间
|
||||
$use_time = $old_nobility_info['1767072342'] - time();
|
||||
$price = $nobility_info['pay_price'] - $old_nobility_info['pay_price'] + ((($old_nobility_info['pay_price'] / $nobility_info['day']) / 24) * $use_time);
|
||||
//价格=
|
||||
//一小时的价格算
|
||||
|
||||
}
|
||||
// $end_time = time() + $nobility_info['day'] * 86400;
|
||||
echo $price;
|
||||
|
||||
|
||||
|
||||
// }
|
||||
|
||||
// $re = model('api/Decorate')->pay_decorate(20150,46,30,9);
|
||||
// print_r($re);die;
|
||||
}
|
||||
|
||||
//任务金币统计
|
||||
public function task_coin_count(){
|
||||
// $etime = "2025-12-29 10:30:00";
|
||||
// $stime = "2025-12-29 00:00:00";
|
||||
// $etime = "2025-12-30 04:00:00";
|
||||
// $stime = "2025-12-29 00:00:00";
|
||||
// $etime = "2026-01-05 00:00:00";
|
||||
// $stime = "2025-12-22 00:00:00";
|
||||
// $etime = "2025-12-29 00:00:00";
|
||||
|
||||
// $stime = "2025-12-29 00:00:00";
|
||||
// $etime = "2025-12-31 01:14:09";
|
||||
|
||||
$stime = "2025-12-31 01:14:09";
|
||||
$etime = "2026-01-05 00:00:00";
|
||||
|
||||
//获取所有已领取的任务奖励礼包
|
||||
$where = [];
|
||||
if(!empty($stime)){
|
||||
$where['a.createtime'] = ['>=', strtotime($stime)];
|
||||
}
|
||||
if(!empty($etime)){
|
||||
$where['a.createtime'] = ['<=', strtotime($etime)];
|
||||
}
|
||||
if(!empty($stime) && !empty($etime)){
|
||||
$where['a.createtime'] = ['between', [strtotime($stime), strtotime($etime)]];
|
||||
}
|
||||
// if(!empty($etime) && strtotime($etime)<="1767038400"){//2025-12-30 04:00:00
|
||||
// $tasks_bag_details = db::name('vs_gift_bag_receive_log')
|
||||
// ->alias('a')
|
||||
// ->join('vs_gift_bag_detail b', 'a.parent_id=b.id')
|
||||
// ->field('a.createtime,b.type,b.foreign_id,b.quantity,b.gold')
|
||||
// ->where(['b.type'=>['in', [1,2]]])
|
||||
// ->whereBetween('a.gift_bag_id', [18, 51])
|
||||
// ->where($where)
|
||||
// ->select();
|
||||
// }else{
|
||||
$tasks_bag_details = db::name('vs_gift_bag_receive_tasks_log')
|
||||
->alias('a')
|
||||
->join('vs_gift_bag_detail b', 'a.parent_id=b.id')
|
||||
->field('a.createtime,b.type,b.foreign_id,b.quantity,b.gold')
|
||||
->where(['b.type'=>['in', [1,2]]])
|
||||
->whereBetween('a.gift_bag_id', [18, 51])
|
||||
->where($where)
|
||||
->select();
|
||||
// }
|
||||
$total_reward_price = 0;
|
||||
foreach ($tasks_bag_details as $detail){
|
||||
if($detail['type'] == 1){
|
||||
$total_reward_price += $detail['gold'] * $detail['quantity'];
|
||||
}else{
|
||||
$gift_price = db::name('vs_gift')->where('gid',$detail['foreign_id'])->value('gift_price');
|
||||
$total_reward_price += $gift_price * $detail['quantity'];
|
||||
}
|
||||
}
|
||||
echo $total_reward_price;
|
||||
}
|
||||
|
||||
//修复公会房间数据
|
||||
public function repair_guild_room_data(){
|
||||
$guild_user_data = db::name('vs_guild_user')->where(['apply_time'=>['>',0],'status'=>1,'room_id'=>['>',0]])->field('id,user_id,room_id,guild_id,apply_time,quit_time')->select();
|
||||
$num = 0;
|
||||
foreach ($guild_user_data as $k => $v) {
|
||||
$room_info = db::name('vs_room')->where('id',$v['room_id'])->field('id,type_id')->find();
|
||||
if($room_info['type_id'] == 6){
|
||||
$troom_info = db::name('vs_room')->where(['user_id'=>$v['user_id'],'delete_time'=>0,'type_id'=>['<>',6]])->find();
|
||||
$rid =0;
|
||||
if($troom_info){
|
||||
$rid = $troom_info['id']??0;
|
||||
}
|
||||
$guild_name = db::name('vs_guild')->where('id',$v['guild_id'])->value('guild_name');
|
||||
echo "公会名称:".$guild_name." 公会Id:".$v['guild_id']." 关系Id:".$v['id']."错误房间Id:".$v['room_id']."正确房间Id:".$rid."\n";
|
||||
|
||||
// $re = db::name('vs_guild_user')->where('id',$v['id'])->update(['room_id'=>$rid]);
|
||||
// if($re){
|
||||
// $num++;
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
echo "修改完成 共:".$num;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ return [
|
||||
'host' => '127.0.0.1', // redis 主机ip
|
||||
'port' => 6379, // redis 端口
|
||||
'password' => '', // redis 密码
|
||||
'select' => 15, // 使用哪一个 db,默认为 db0
|
||||
'select' => 14, // 使用哪一个 db,默认为 db0
|
||||
'timeout' => 0, // redis连接的超时时间
|
||||
'persistent' => false,
|
||||
'persistent' => true,
|
||||
];
|
||||
|
||||
@@ -7,6 +7,6 @@ return [
|
||||
'select' => 0,
|
||||
'timeout' => 0,
|
||||
'expire' => 0,
|
||||
'persistent' => false,
|
||||
'persistent' => true,
|
||||
'prefix' => 'fa_redpacket_',
|
||||
];
|
||||
@@ -1,5 +1,27 @@
|
||||
<?php
|
||||
// application/extra/snowflake.php
|
||||
|
||||
return [
|
||||
'worker_id' => 1, // 工作ID(1-31)
|
||||
'datacenter_id' => 1, // 数据中心ID(1-31)
|
||||
// 工作机器ID (0-31)
|
||||
// -1 表示自动生成
|
||||
'worker_id' => -1,
|
||||
|
||||
// 数据中心ID (0-31)
|
||||
// -1 表示自动生成
|
||||
'datacenter_id' => -1,
|
||||
|
||||
// 是否启用日志记录
|
||||
'log_enabled' => false,
|
||||
|
||||
// 时钟回拨处理策略
|
||||
'clock_backwards_strategy' => 'wait',
|
||||
|
||||
// 最大等待时间(毫秒)
|
||||
'max_wait_time' => 100,
|
||||
|
||||
// ID生成模式
|
||||
'mode' => 'auto',
|
||||
|
||||
// 服务器标识
|
||||
'server_identifier' => '',
|
||||
];
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace app\guildadmin\controller;
|
||||
|
||||
use app\admin\command\Menu;
|
||||
use app\common\library\GiftTableManager;
|
||||
use app\guildadmin\model\AuthGroup;
|
||||
use app\guildadmin\model\AuthGroupAccess;
|
||||
use app\guildadmin\model\AuthRule;
|
||||
@@ -323,75 +324,76 @@ class Room extends GuildAdmin
|
||||
//房间流水
|
||||
public function room_flow()
|
||||
{
|
||||
$guild_id = $this->guildId ?? 0;
|
||||
$room_id = input('room_id', '');
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 10);
|
||||
$type = input('type', 1);//1:全部流水 2:日流水 3:周流水 4:月流水
|
||||
$stime = input('stime', '');
|
||||
$etime = input('etime', '');
|
||||
if($room_id == ''){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
if($type == 1){
|
||||
$begin_time = 1748676768;//2025-06-00 15:32:48
|
||||
$end_time = time();
|
||||
$where['a.createtime'] = ['between', [$begin_time, $end_time]];
|
||||
}elseif ($type == 2){
|
||||
//日流水
|
||||
$begin_time = strtotime(date('Y-m-d 00:00:00',time()));
|
||||
$end_time = time();
|
||||
$where['a.createtime'] = ['between', [$begin_time, $end_time]];
|
||||
$begin_time = $stime ? strtotime($stime) : "";
|
||||
$end_time = $etime ? strtotime($etime) : "";
|
||||
if($guild_id){
|
||||
$guild_user_data = db::name('vs_guild_user')->where('guild_id', $guild_id)->where(['apply_time'=>['>',0],'status'=>1,'room_id'=>$room_id])->field('room_id,apply_time,quit_time')->find();
|
||||
if($guild_user_data){
|
||||
if($guild_user_data['apply_time'] && $begin_time < $guild_user_data['apply_time']){
|
||||
$begin_time = $guild_user_data['apply_time'];
|
||||
}
|
||||
if($guild_user_data['quit_time'] && ($end_time > $guild_user_data['quit_time'])){
|
||||
$end_time = $guild_user_data['quit_time'];
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($type == 3){
|
||||
//周流水
|
||||
//本周一
|
||||
$begin_time = strtotime(date('Y-m-d 00:00:00', strtotime('this week')));
|
||||
$end_time = time();
|
||||
$where['a.createtime'] = ['between', [$begin_time, $end_time]];
|
||||
$params['from_id'] = $room_id;
|
||||
$ext_params['start_time'] = $begin_time;
|
||||
$ext_params['end_time'] = $end_time;
|
||||
$params['page'] = $page;
|
||||
$params['limit'] = $page_limit;
|
||||
$res = model('api/GiveGiftBases')->getGiftRecords($params,$ext_params);
|
||||
$list = $res['data'];
|
||||
$count = $res['total'];
|
||||
$list_data = [];
|
||||
foreach ($list as &$value) {
|
||||
$value['time'] = date('Y-m-d', $value['createtime']);
|
||||
$value['sender_nickname'] = db::name('user')->where('id', $value['user_id'])->value('nickname');
|
||||
$value['sender_avatar'] = db::name('user')->where('id', $value['user_id'])->value('avatar');
|
||||
$value['receive_nickname'] = db::name('user')->where('id', $value['gift_user'])->value('nickname');
|
||||
$value['receive_avatar'] = db::name('user')->where('id', $value['gift_user'])->value('avatar');
|
||||
$value['gift_name'] = db::name('vs_gift')->where('gid', $value['gift_id'])->value('gift_name');
|
||||
|
||||
}
|
||||
elseif ($type == 4){
|
||||
$begin_time = strtotime(date('Y-m-01'));
|
||||
$end_time = time();
|
||||
$where['a.createtime'] = ['between', [$begin_time, $end_time]];
|
||||
}
|
||||
$count = db::name('vs_give_gift')->alias('a')
|
||||
->field('a.id')
|
||||
->join('user b', 'a.user_id = b.id', 'left')
|
||||
->join('user c', 'a.gift_user = c.id', 'left')
|
||||
->join('vs_gift d', 'a.gift_id = d.gid', 'left')
|
||||
->where('a.from',2)
|
||||
->where('a.from_id',$room_id)
|
||||
->where($where)
|
||||
->count();
|
||||
$list = db::name('vs_give_gift')->alias('a')
|
||||
->field('a.number,a.createtime,a.total_price,a.type,b.nickname,b.avatar,c.nickname as gift_nickname,c.avatar as gift_avatar,d.gift_name,a.from,a.from_id')
|
||||
->join('user b', 'a.user_id = b.id', 'left')
|
||||
->join('user c', 'a.gift_user = c.id', 'left')
|
||||
->join('vs_gift d', 'a.gift_id = d.gid', 'left')
|
||||
->where('a.from',2)
|
||||
->where('a.from_id',$room_id)
|
||||
->where($where)
|
||||
->order('a.id desc')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
if($list){
|
||||
foreach ($list as &$v){
|
||||
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
|
||||
$v['content'] = $v['nickname'].' 给 '.$v['gift_nickname'].' 送了 '.$v['gift_name'].' x '.$v['number'];
|
||||
$v['content'] = $v['sender_nickname'].' 给 '.$v['receive_nickname'].' 送了 '.$v['gift_name'].' x '.$v['number'];
|
||||
// 来源:1聊天送礼物 2房间语聊送礼 3直播送礼 4动态打赏
|
||||
$v['from_str'] = model('adminapi/Gift')->GiveGiftFromStr[$v['from']];
|
||||
|
||||
}
|
||||
}
|
||||
$where =[];
|
||||
$where_luck = [];
|
||||
$where['room_id'] = $room_id;
|
||||
if($guild_id){
|
||||
$where['guild_id'] = $guild_id;
|
||||
}
|
||||
if($begin_time && $end_time){
|
||||
$where['createtime'] = ['between', [$begin_time, $end_time]];
|
||||
$where_luck['createtime'] = ['between', [$begin_time, $end_time]];
|
||||
}
|
||||
$gift_total_price = db::name('vs_guild_flow')->where($where)->sum('flow_price');
|
||||
$total_lucky_coin = db::name('vs_room_luck_value')->where('room_id',$room_id)->where($where_luck)->sum('luck_value');
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $list,
|
||||
'total' =>[
|
||||
'total_price' => db::name('vs_give_gift')->alias('a')
|
||||
->join('user b', 'a.user_id = b.id', 'left')
|
||||
->where('a.from',2)
|
||||
->where('a.from_id',$room_id)
|
||||
->where($where)->sum('total_price')
|
||||
'total_price' => $gift_total_price,
|
||||
'total_lucky_coin' => $total_lucky_coin
|
||||
]
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user