| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- <?php
- namespace App\Game\Services;
- use App\Facade\TableName;
- use App\Game\Config\GameBasicConfig;
- use App\Game\GlobalUserInfo;
- use App\Http\helper\HttpCurl;
- use App\Http\helper\NumConfig;
- use App\Models\RecordScoreInfo;
- use App\Notification\TelegramBot;
- use App\Util;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Redis;
- use Yansongda\Pay\Log;
- class OuroGameService
- {
- const REASON_updateAccount=83;
- const REASON_PwaBonus=82;
- const REASON_RedEnvelope=12;
- const REASON_BindPhone=21;
- const REASON_AgentBonus=2;
- const REASON_AgentWithDraw=81;
- public static function notifyWebHall($UserID,$GlobalUID="",$cmd='pay_finish',$data=["Golds"=>0,"PayNum"=>0]){
- try {
- $url = str_replace("wss:","https:",GameBasicConfig::$HallServer).'/phpapi';
- // aaa=111&password=wojiushimima&cmd=pay_finish&UserID=1
- if(empty($GlobalUID)){
- if(GlobalUserInfo::$me&&GlobalUserInfo::$me->UserID==$UserID){
- $user=GlobalUserInfo::$me;
- }else{
- $user=GlobalUserInfo::getGameUserInfo('UserID',$UserID);
- }
- if(!$user)return;
- $GlobalUID=$user->GlobalUID;
- }
- $query = ['aaa' => 111, 'password' => 'wojiushimima', 'cmd' => $cmd, 'UserID' => $UserID, 'GlobalUID' => $GlobalUID,'data' => json_encode($data)];
- $build_query = $url . '?' . http_build_query($query);
- Util::WriteLog("hallnoti",$build_query);
- return (new HttpCurl())->curl_get($build_query);
- // dd($build_query);
- }catch (\Exception $exception){
- $telegram = new TelegramBot();
- $env = env('APP_ENV');
- $telegram->sendMsg($env."24680 hallnotify error:".$exception->getMessage());
- }
- return false;
- }
- public static function notifyMail($user_id,$GlobalUID="")
- {
- self::notifyWebHall($user_id,$GlobalUID,'call_client',["type"=>"refresh_mail"]);
- }
- public static function getUserInGame($UserID,$GlobalUID="")
- {
- $key='ingame_state_'.$UserID;
- $ingame_state=Redis::get($key)??-1;
- return intval($ingame_state);
- }
- public static function AddScore($UserID,$GiftScore,$reason=null,$notify=true)
- {
- // 增加用户金币
- $OrgScore = DB::table('QPTreasureDB.dbo.GameScoreInfo')->where('UserID', $UserID)->value('Score');
- Log::info('OuroService变化金币' . $GiftScore);
- DB::table('QPTreasureDB.dbo.GameScoreInfo')->where('UserID', $UserID)->increment('Score',$GiftScore);
- $NowScore=$OrgScore+$GiftScore;
- RecordScoreInfo::addScore($UserID, $GiftScore, $reason, $OrgScore); #赠送彩金
- // if($reason){
- // DB::connection('sqlsrv')->unprepared("
- // SET NOCOUNT ON;
- // use QPRecordDB;
- // exec QPRecordDB.dbo.GSP_YN_GR_RecordGameScore $UserID,$GiftScore,$reason,0,'',0,0");
- // }
- if(!$notify){
- return [$OrgScore,$NowScore];
- }
- self::notifyWebHall($UserID,"",'pay_finish',["Golds"=>$NowScore,"PayNum"=>$GiftScore]);
- return [$OrgScore,$NowScore];
- }
- public static function AddDrawBase($UserID, $draw_base, $act_no=2)
- {
- // 增加可提额度
- if (DB::table(TableName::QPRecordDB() . 'RecordUserTotalStatistics')->where('UserID', $UserID)->first()) {
- DB::table(TableName::QPRecordDB() . 'RecordUserTotalStatistics')->where('UserID', $UserID)->increment('DrawBase', $draw_base);
- } else {
- DB::table(TableName::QPRecordDB() . 'RecordUserTotalStatistics')->insert(['UserID' => $UserID, 'DrawBase' => $draw_base]);
- }
- // 增加记录
- DB::table(TableName::agent() . 'add_draw_base')
- ->insert([
- 'user_id' => $UserID,
- 'draw_base' => $draw_base,
- 'create_time' => now(),
- 'admin_id' => '24680'.$act_no
- ]);
- }
- public static function AddFreeScore($UserID,$GiftScore,$reason=null,$notify=true)
- {
- $vip = DB::table(TableName::QPAccountsDB() . 'YN_VIPAccount')
- ->where('UserID', $UserID)
- ->value('Recharge') ?: 0;
- if($vip){
- // 增加用户金币
- $OrgScore = DB::table('QPTreasureDB.dbo.GameScoreInfo')->where('UserID', $UserID)->value('InsureScore');
- DB::table('QPTreasureDB.dbo.GameScoreInfo')->where('UserID', $UserID)->increment('InsureScore',$GiftScore);
- $NowScore=$OrgScore+$GiftScore;
- }else{
- // 增加用户金币
- $OrgScore = DB::table('QPTreasureDB.dbo.GameScoreInfo')->where('UserID', $UserID)->value('Score');
- DB::table('QPTreasureDB.dbo.GameScoreInfo')->where('UserID', $UserID)->increment('Score',$GiftScore);
- $NowScore=$OrgScore+$GiftScore;
- }
- return [$OrgScore,$NowScore];
- }
- }
|