AccCallbackController.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Facade\TableName;
  4. use App\Http\helper\NumConfig;
  5. use App\Models\PrivateMail;
  6. use Illuminate\Http\Request;
  7. use Illuminate\Support\Facades\DB;
  8. use Illuminate\Support\Facades\Redis;
  9. class AccCallbackController
  10. {
  11. /*
  12. select '55'+cast(PhoneNum as varchar) as Phone,(CASE
  13. WHEN CHARINDEX(' ', aw.BankUserName) > 0 THEN SUBSTRING(aw.BankUserName, 1, CHARINDEX(' ', aw.BankUserName) - 1)
  14. ELSE case when aw.BankUserName is null then 'Jogador' else aw.BankUserName end
  15. END)
  16. from QPTreasureDB.dbo.GameScoreInfo gi
  17. left join QPAccountsDB.dbo.AccountsInfo af on gi.UserID = af.UserID
  18. left join QPAccountsDB.dbo.AccountPhone ap on ap.UserID = gi.UserID
  19. left join QPRecordDB.dbo.RecordUserTotalStatistics rt on rt.UserID = gi.UserID
  20. left join QPAccountsDB.dbo.AccountWithDrawInfo as aw on aw.UserID=gi.UserID
  21. where af.Channel = 125
  22. and gi.LastLogonDate < '2023-10-15'
  23. and (rt.Recharge > 40)
  24. -- or rt.Withdraw>0 or gi.Score>2000)
  25. and ap.PhoneNum is not null
  26. -- and gi.Score>5000
  27. order by rt.Recharge desc;
  28. insert into QPRecordDB.dbo.AccountsChangeApk (UserID, FromPackage, ToPackage, ClickTimes, State, Channel) (
  29. select af.UserID as UserID,'com.tiger.ourotiger' as FromPackage,'com.tiger.ourotiger2' as ToPackage,1 as ClickTimes,1 as State,125 as Channel
  30. from QPTreasureDB.dbo.GameScoreInfo gi
  31. left join QPAccountsDB.dbo.AccountsInfo af on gi.UserID = af.UserID
  32. left join QPAccountsDB.dbo.AccountPhone ap on ap.UserID = gi.UserID
  33. left join QPRecordDB.dbo.RecordUserTotalStatistics rt on rt.UserID = gi.UserID
  34. left join QPAccountsDB.dbo.AccountWithDrawInfo as aw on aw.UserID=gi.UserID
  35. where af.Channel = 125
  36. and gi.LastLogonDate < '2023-10-15')
  37. */
  38. public function sendBonusToAll(){
  39. $key="temptask_0930";
  40. if(Redis::exists($key)){
  41. echo "runover:".$key;
  42. return;
  43. }
  44. $bonus=5;
  45. $list=DB::table('QPRecordDB.dbo.RecordUserTotalStatistics as rs')
  46. ->leftJoin("QPAccountsDB.dbo.AccountsInfo as ai", "ai.UserID", "rs.UserID")
  47. ->whereRaw('rs.Recharge>=10 and ai.Channel = 125')
  48. ->selectRaw("ai.UserID")
  49. ->get();
  50. foreach ($list as $item){
  51. $this->bonusSendMail($item->UserID,$bonus);
  52. }
  53. }
  54. // 验证码查询
  55. public function make()
  56. {
  57. // echo $this->convertAccentsAndSpecialToNormal( 'Você acabou de receber R$8 bônus,entre no SlotsOuro para reivindicá-lo,se não conseguir entrar,exclua-o e baixe-o novamente,tudo bem.');
  58. // die;
  59. $key="taskCallback_013";
  60. $startid=0;
  61. if(Redis::exists($key)){
  62. $startid=Redis::get($key);
  63. }
  64. // $list = DB::table("QPTreasureDB.dbo.GameScoreInfo as gi")
  65. // ->leftJoin("QPAccountsDB.dbo.AccountsInfo as ai", "ai.UserID", "gi.UserID")
  66. // ->leftJoin("QPAccountsDB.dbo.AccountPhone as ap", "ai.UserID", "ap.UserID")
  67. // ->leftJoin("QPAccountsDB.dbo.AccountWithDrawInfo as aw", "ai.UserID", "aw.UserID")
  68. // ->leftJoin("QPRecordDB.dbo.RecordUserTotalStatistics as rs", "ai.UserID", "rs.UserID")
  69. // ->whereRaw("ai.UserID>$startid and rs.Recharge =0 and gi.Score > 500 and gi.WinCount > 0 and ai.LastLogonDate < '2023-06-21' and ap.PhoneNum<>'' and ai.LastLogonDate > '2023-06-14'")
  70. // ->selectRaw("ai.UserID,ai.Channel,ap.PhoneNum,rs.Recharge,rs.Withdraw,ai.Channel,gi.Score,aw.BankUserName,ai.NickName")
  71. // ->orderBy('ai.UserID')
  72. // ->limit(2000)
  73. // ->get();
  74. $list = DB::table("QPTreasureDB.dbo.GameScoreInfo as gi")
  75. ->leftJoin("QPAccountsDB.dbo.AccountsInfo as ai", "ai.UserID", "gi.UserID")
  76. ->leftJoin("QPAccountsDB.dbo.AccountPhone as ap", "ai.UserID", "ap.UserID")
  77. ->leftJoin("QPAccountsDB.dbo.AccountWithDrawInfo as aw", "ai.UserID", "aw.UserID")
  78. ->leftJoin("QPRecordDB.dbo.RecordUserTotalStatistics as rs", "ai.UserID", "rs.UserID")
  79. ->whereRaw("ai.UserID>$startid and rs.Recharge > 20 and ai.LastLogonDate < '2023-10-27' and ap.PhoneNum<>'' and ai.LastLogonDate>'2023-10-20' and ai.Channel in (106) and ai.UserID not in (select UserID from QPRecordDB.dbo.AccountsChangeApk where AccountsChangeApk.State=2 and AccountsChangeApk.Channel=106)")
  80. ->selectRaw("ai.UserID,ai.Channel,ap.PhoneNum,rs.Recharge,rs.Withdraw,ai.Channel,gi.Score,aw.BankUserName,ai.NickName")
  81. ->orderBy('ai.UserID')
  82. ->limit(2000)
  83. ->get();
  84. echo "<PRE>";
  85. $reason = "更新失败召回";
  86. $lastid=DB::table("QPRecordDB.dbo.AccountsCallbackRecords")->selectRaw("max(ID) ID")->first()->ID;
  87. $lastid=$lastid??0;
  88. $lastid+=100000;
  89. $gameNames=[
  90. '100'=>'Slots Ouro',
  91. '101'=>'Slots Ouro',
  92. '110'=>'Slots Ouro',
  93. '103'=>'Slots Vencedor',
  94. '113'=>'Slots Vencedor',
  95. '104'=>'777 Moedas',
  96. '106'=>'RIO',
  97. ];
  98. $storeNames=[
  99. '100'=>'Play Store',
  100. '101'=>'Play Store',
  101. '110'=>'AppStore',
  102. '103'=>'Play Store',
  103. '113'=>'AppStore',
  104. '104'=>'Play Store',
  105. '106'=>'Play Store',
  106. ];
  107. foreach ($list as $item) {
  108. // print_r($item);
  109. $lastid++;
  110. // $bonus
  111. if($item->UserID>$startid)$startid=$item->UserID;
  112. $bonus=3;
  113. $pay=intval($item->Recharge);
  114. if($pay>=50000) {
  115. $bonus = 50;
  116. }elseif($pay>=10000){
  117. $bonus = 30;
  118. }elseif($pay>=5000){
  119. $bonus = 20;
  120. }elseif($pay>=1000){
  121. $bonus = 10;
  122. }elseif($pay>=100){
  123. $bonus = 8;
  124. }elseif($pay>=30){
  125. $bonus = 5;
  126. }
  127. $name=$item->BankUserName;
  128. if(isset($name)&&$name!=""){
  129. $name='Querida '.explode(" ",$name)[0].",";
  130. }else if(substr($item->NickName,0,1)!='U'){
  131. $name='Querida '.$item->NickName.',';
  132. }else{
  133. $name='';
  134. }
  135. // Você acabou de receber R$5 bônus, entre imediatamente em Ouro777 para reivindicá-lo, se você não conseguir entrar, exclua-o e baixe-o novamente, tudo bem.
  136. $gamename=$gameNames[$item->Channel];
  137. $store=$storeNames[$item->Channel];
  138. // $msg=" {$gamename}:{$name} entre no jogo para receber seu bônus de {$bonus} moedas. Se você tiver algum problema, basta excluir o jogo e baixá-lo novamente.";
  139. $code=substr($item->PhoneNum,strlen($item->PhoneNum)-6,4);
  140. // $msg = "Olá, o '$gamename' foi atualizado e você pode resgatar seu bônus de $bonus reais abrindo a atualização da $store";
  141. // $msg="Olá, o '$gamename' foi atualizado automaticamente, abra o jogo para resgatar seu bônus exclusivo de $bonus reais!";
  142. $msg="{".$code."} (OTP) ganhe R$10 bônus. Caso haja algum problema com o jogo, acesse https://rio.ouro777.com para atualizações.";
  143. $msg=$this->convertAccentsAndSpecialToNormal($msg);
  144. $bonus=$bonus*100;
  145. $cashout= $item->Withdraw??0;
  146. $record = [
  147. 'UserID' => $item->UserID,
  148. 'Channel' => $item->Channel,
  149. 'Msg' => $msg,
  150. 'PhoneNum' => $item->PhoneNum,
  151. 'Reason' => $reason,
  152. 'Recharge' => $pay,
  153. 'Profit' =>$pay -$cashout / 100,
  154. 'State' => 1,
  155. 'LeftCoin' => $item->Score,
  156. 'Bonus'=>$bonus,
  157. 'TrackToken' => $this->from10_to62($lastid),
  158. //'SendDate'=>$item->,
  159. //'Result'=>$item->,
  160. ];
  161. DB::connection("write")->table("QPRecordDB.dbo.AccountsCallbackRecords")->insert($record);
  162. // $this->bonusSendMail($item->UserID,$bonus);
  163. print_r($record);
  164. }
  165. Redis::set($key,$startid);
  166. Redis::expire($key,3600);
  167. return apiReturnSuc();
  168. }
  169. /**
  170. * Replaces special characters in a string with their "non-special" counterpart.
  171. *
  172. * Useful for friendly URLs.
  173. *
  174. * @access public
  175. * @param string
  176. * @return string
  177. */
  178. function convertAccentsAndSpecialToNormal($string)
  179. {
  180. $table = array(
  181. 'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A', 'Å' => 'A', 'Ă' => 'A', 'Ā' => 'A', 'Ą' => 'A', 'Æ' => 'A', 'Ǽ' => 'A',
  182. 'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ä' => 'a', 'å' => 'a', 'ă' => 'a', 'ā' => 'a', 'ą' => 'a', 'æ' => 'a', 'ǽ' => 'a',
  183. 'Þ' => 'B', 'þ' => 'b', 'ß' => 'Ss',
  184. 'Ç' => 'C', 'Č' => 'C', 'Ć' => 'C', 'Ĉ' => 'C', 'Ċ' => 'C',
  185. 'ç' => 'c', 'č' => 'c', 'ć' => 'c', 'ĉ' => 'c', 'ċ' => 'c',
  186. 'Đ' => 'Dj', 'Ď' => 'D',
  187. 'đ' => 'dj', 'ď' => 'd',
  188. 'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ĕ' => 'E', 'Ē' => 'E', 'Ę' => 'E', 'Ė' => 'E',
  189. 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e', 'ĕ' => 'e', 'ē' => 'e', 'ę' => 'e', 'ė' => 'e',
  190. 'Ĝ' => 'G', 'Ğ' => 'G', 'Ġ' => 'G', 'Ģ' => 'G',
  191. 'ĝ' => 'g', 'ğ' => 'g', 'ġ' => 'g', 'ģ' => 'g',
  192. 'Ĥ' => 'H', 'Ħ' => 'H',
  193. 'ĥ' => 'h', 'ħ' => 'h',
  194. 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I', 'İ' => 'I', 'Ĩ' => 'I', 'Ī' => 'I', 'Ĭ' => 'I', 'Į' => 'I',
  195. 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'į' => 'i', 'ĩ' => 'i', 'ī' => 'i', 'ĭ' => 'i', 'ı' => 'i',
  196. 'Ĵ' => 'J',
  197. 'ĵ' => 'j',
  198. 'Ķ' => 'K',
  199. 'ķ' => 'k', 'ĸ' => 'k',
  200. 'Ĺ' => 'L', 'Ļ' => 'L', 'Ľ' => 'L', 'Ŀ' => 'L', 'Ł' => 'L',
  201. 'ĺ' => 'l', 'ļ' => 'l', 'ľ' => 'l', 'ŀ' => 'l', 'ł' => 'l',
  202. 'Ñ' => 'N', 'Ń' => 'N', 'Ň' => 'N', 'Ņ' => 'N', 'Ŋ' => 'N',
  203. 'ñ' => 'n', 'ń' => 'n', 'ň' => 'n', 'ņ' => 'n', 'ŋ' => 'n', 'ʼn' => 'n',
  204. 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ö' => 'O', 'Ø' => 'O', 'Ō' => 'O', 'Ŏ' => 'O', 'Ő' => 'O', 'Œ' => 'O',
  205. 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'ø' => 'o', 'ō' => 'o', 'ŏ' => 'o', 'ő' => 'o', 'œ' => 'o', 'ð' => 'o',
  206. 'Ŕ' => 'R', 'Ř' => 'R',
  207. 'ŕ' => 'r', 'ř' => 'r', 'ŗ' => 'r',
  208. 'Š' => 'S', 'Ŝ' => 'S', 'Ś' => 'S', 'Ş' => 'S',
  209. 'š' => 's', 'ŝ' => 's', 'ś' => 's', 'ş' => 's',
  210. 'Ŧ' => 'T', 'Ţ' => 'T', 'Ť' => 'T',
  211. 'ŧ' => 't', 'ţ' => 't', 'ť' => 't',
  212. 'Ù' => 'U', 'Ú' => 'U', 'Û' => 'U', 'Ü' => 'U', 'Ũ' => 'U', 'Ū' => 'U', 'Ŭ' => 'U', 'Ů' => 'U', 'Ű' => 'U', 'Ų' => 'U',
  213. 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ü' => 'u', 'ũ' => 'u', 'ū' => 'u', 'ŭ' => 'u', 'ů' => 'u', 'ű' => 'u', 'ų' => 'u',
  214. 'Ŵ' => 'W', 'Ẁ' => 'W', 'Ẃ' => 'W', 'Ẅ' => 'W',
  215. 'ŵ' => 'w', 'ẁ' => 'w', 'ẃ' => 'w', 'ẅ' => 'w',
  216. 'Ý' => 'Y', 'Ÿ' => 'Y', 'Ŷ' => 'Y',
  217. 'ý' => 'y', 'ÿ' => 'y', 'ŷ' => 'y',
  218. 'Ž' => 'Z', 'Ź' => 'Z', 'Ż' => 'Z',
  219. 'ž' => 'z', 'ź' => 'z', 'ż' => 'z',
  220. '“' => '"', '”' => '"', '‘' => "'", '’' => "'", '•' => '-', '…' => '...', '—' => '-', '–' => '-', '¿' => '?', '¡' => '!', '°' => ' degrees ',
  221. '¼' => ' 1/4 ', '½' => ' 1/2 ', '¾' => ' 3/4 ', '⅓' => ' 1/3 ', '⅔' => ' 2/3 ', '⅛' => ' 1/8 ', '⅜' => ' 3/8 ', '⅝' => ' 5/8 ', '⅞' => ' 7/8 ',
  222. '÷' => ' divided by ', '×' => ' times ', '±' => ' plus-minus ', '√' => ' square root ', '∞' => ' infinity ',
  223. '≈' => ' almost equal to ', '≠' => ' not equal to ', '≡' => ' identical to ', '≤' => ' less than or equal to ', '≥' => ' greater than or equal to ',
  224. '←' => ' left ', '→' => ' right ', '↑' => ' up ', '↓' => ' down ', '↔' => ' left and right ', '↕' => ' up and down ',
  225. '℅' => ' care of ', '℮' => ' estimated ',
  226. 'Ω' => ' ohm ',
  227. '♀' => ' female ', '♂' => ' male ',
  228. '©' => ' Copyright ', '®' => ' Registered ', '™' => ' Trademark ',
  229. );
  230. $string = strtr($string, $table);
  231. // Currency symbols: £¤¥€ - we dont bother with them for now
  232. $string = preg_replace("/[^\x9\xA\xD\x20-\x7F]/u", "", $string);
  233. return $string;
  234. }
  235. public static function bonusSendMail($UserID, $bonus)
  236. {
  237. $amount = $bonus;
  238. $TitleString = 'Por favor, reivindique seu bônus';
  239. $TextString = "Desejo-lhe sempre boa sorte e ganhe altos multiplicadores!";
  240. PrivateMail::sendMail(2, $UserID, $TitleString, $TextString, '30000,'.$amount, '', $amount, 3);
  241. }
  242. /**
  243. * 获取该条记录的自增ID
  244. * 将自增转换为62进制,并拼接网址 如:http://qetee.com/w7e
  245. * 用户访问到 http://qetee.com/w7e 时,提取短网址后缀 w7e
  246. * 将短网址后缀转换为10进制,得到自增ID号 如:123456
  247. * 使用查询该记录,进行业务逻辑处理(比如跳转)
  248. */
  249. /**
  250. * 十进制数转换成62进制
  251. *
  252. * @param integer $num
  253. * @return string
  254. */
  255. function from10_to62($num) {
  256. $to = 62;
  257. $dict = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  258. $ret = '';
  259. do {
  260. $ret = $dict[bcmod($num, $to)] . $ret;
  261. $num = bcdiv($num, $to);
  262. } while ($num > 0);
  263. return $ret;
  264. }
  265. /**
  266. * 62进制数转换成十进制数
  267. *
  268. * @param string $num
  269. * @return string
  270. */
  271. function from62_to10($num) {
  272. $from = 62;
  273. $num = strval($num);
  274. $dict = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  275. $len = strlen($num);
  276. $dec = 0;
  277. for($i = 0; $i < $len; $i++) {
  278. $pos = strpos($dict, $num[$i]);
  279. $dec = bcadd(bcmul(bcpow($from, $len - $i - 1), $pos), $dec);
  280. }
  281. return $dec;
  282. }
  283. // 绑定手机号 -- 手动
  284. public function bind_phone(Request $request, $UserID)
  285. {
  286. if ($request->isMethod('post')) {
  287. $post = $request->post();
  288. $Channel = DB::connection('write')->table(TableName::QPAccountsDB() . 'AccountsInfo')
  289. ->where('UserID', $UserID)->select('Channel')->first()->Channel;
  290. $IsUserBindPhone = DB::table(TableName::QPAccountsDB() . 'AccountPhone')
  291. ->where('UserID', $UserID)
  292. ->first();
  293. if ($IsUserBindPhone) {
  294. return apiReturnFail('用户已绑定');
  295. }
  296. DB::table(TableName::QPAccountsDB() . 'AccountPhone')
  297. ->insert([
  298. 'PhoneNum' => (int)$post['PhoneNum'],
  299. 'BindDate' => now(),
  300. 'LogonPass' => $post['LogonPass'],
  301. 'UserID' => $UserID,
  302. 'Channel' => $Channel,
  303. ]);
  304. return apiReturnSuc();
  305. } else {
  306. return view('admin.code.bind_phone', compact('UserID'));
  307. }
  308. }
  309. }