ExemptReview.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Facade\TableName;
  4. use App\Http\helper\NumConfig;
  5. use App\Models\AccountsInfo;
  6. use App\Models\Cpf;
  7. use App\Models\SystemStatusInfo;
  8. use App\Models\Withdrawal;
  9. use App\Models\WithdrawalChannelPositionConfig;
  10. use App\Services\CashService;
  11. use App\Util;
  12. use Illuminate\Console\Command;
  13. use Illuminate\Support\Facades\DB;
  14. use Illuminate\Support\Facades\Log;
  15. use Illuminate\Support\Facades\Redis;
  16. class ExemptReview extends Command
  17. {
  18. /**
  19. * The name and signature of the console command.
  20. *
  21. * @var string
  22. */
  23. protected $signature = 'exempt_review';
  24. /**
  25. * The console command description.
  26. *
  27. * @var string
  28. */
  29. protected $description = '提现免审--定时扫表订单';
  30. /**
  31. * Create a new command instance.
  32. *
  33. * @return void
  34. */
  35. public function __construct()
  36. {
  37. parent::__construct();
  38. }
  39. /**
  40. * Execute the console command.
  41. *
  42. * @return mixed
  43. */
  44. public function handle()
  45. {
  46. $open=(int)SystemStatusInfo::OnlyGetCacheValue(SystemStatusInfo::$KEY_WithDrawSwitch);
  47. if(!$open)return;
  48. $WithdrawalModel = new Withdrawal();
  49. $OrderWithDraw = DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')->where('State', 1)
  50. ->whereRaw('locking = 0')->orderBy('CreateDate', 'desc')->get();
  51. foreach ($OrderWithDraw as $value) {
  52. if ($value->State != 1) {
  53. continue;
  54. }
  55. // 验证免审条件
  56. $verifyRes = (new \App\Services\Withdrawal())->configVerify($value->UserID, $value->WithDraw,
  57. $value->OrderId);
  58. if (!$verifyRes) {
  59. continue;
  60. }
  61. //防止刷子补充
  62. $AccountsInfoModel = new AccountsInfo();
  63. // $mailNums=DB::table(TableName::QPAccountsDB() . 'OrderWithDraw')
  64. // ->selectRaw('count(distinct (UserID)) as nums')
  65. // ->where("EmailAddress",$value->EmailAddress)
  66. // ->first();
  67. $sameCountCheck = 1;
  68. $sameCountCheckIP = 1;
  69. if ($verifyRes == 4) {
  70. $sameCountCheck = 2;
  71. $sameCountCheckIP = 3;
  72. } elseif ($verifyRes == 5) {
  73. $sameCountCheck = 10;
  74. $sameCountCheckIP = 200;
  75. } elseif ($verifyRes == 2) {
  76. $sameCountCheck = 3;
  77. $sameCountCheckIP = 100;
  78. } elseif ($verifyRes == 3) {
  79. $sameCountCheck = 3;
  80. $sameCountCheckIP = 100;
  81. }
  82. if(($verifyRes==1||$verifyRes==9)&&$value->WithDraw!=1000){
  83. Log::info('首次审核阻拦自动免审:'.$value->OrderId);
  84. continue;
  85. }
  86. if ($AccountsInfoModel->sameWithDrawEmail($value->EmailAddress) > $sameCountCheck && ($value->WithDraw/NumConfig::NUM_VALUE)>20) {
  87. Log::info('EMAIL重复过多阻拦自动免审:'.$value->OrderId.":::".$value->EmailAddress);
  88. continue;
  89. }
  90. // $nameNums=DB::table(TableName::QPAccountsDB() . 'OrderWithDraw')
  91. // ->selectRaw('count(distinct (UserID)) as nums')
  92. // ->where("EmailAddress",$value->BankUserName)
  93. // ->first();
  94. // if($AccountsInfoModel->sameWithDrawBankName($value->BankUserName)>4){
  95. // Log::info('名字重复过多阻拦自动免审:'.$value->OrderId.":::".$value->BankUserName);
  96. // continue;
  97. // }
  98. if ($AccountsInfoModel->sameRegisterIPCountByUserID($value->UserID) > $sameCountCheckIP && ($value->WithDraw/NumConfig::NUM_VALUE)>20) {
  99. Log::info('注册IP重复过多阻拦自动免审:'.$value->OrderId);
  100. continue;
  101. }
  102. if ($AccountsInfoModel->sameLoginIPCount($value->UserID) > $sameCountCheckIP && ($value->WithDraw/NumConfig::NUM_VALUE)>20) {
  103. Log::info('登录IP重复过多阻拦自动免审:'.$value->OrderId);
  104. continue;
  105. }
  106. if ($AccountsInfoModel->sameLoginMacCount($value->UserID) > $sameCountCheck && ($value->WithDraw/NumConfig::NUM_VALUE)>20) {
  107. Log::info('MAC地址码重复阻拦自动免审:'.$value->OrderId);
  108. continue;
  109. }
  110. // 读取免审配置
  111. // $config = DB::table(TableName::agent().'withdrawal_position_config')->where('status', 1)->first();
  112. if (true) {
  113. if($value->PixType == 2){
  114. // $agent = 101;
  115. rand(1,100)>60?$agent = 99:$agent = 101;
  116. }else{
  117. if(($value->WithDraw/NumConfig::NUM_VALUE)<20){
  118. $agent = 99;
  119. }else{
  120. // rand(1,100)>30?$agent = 99:$agent = 101;
  121. $agent = 101;
  122. }
  123. }
  124. // $agent = 99;
  125. $redis = Redis::connection();
  126. $order_sn = $value->OrderId;
  127. if ($redis->exists($order_sn.'key1')) {
  128. continue;
  129. }
  130. $redis->set($order_sn.'key1', $order_sn, 3600 * 24);
  131. $log = ['user_id' => $value->UserID,
  132. // 'config_id' => $config->id,
  133. 'use_quota' => intval($value->WithDraw),
  134. 'order_sn' => $value->OrderId];
  135. DB::connection('write')->table('agent.dbo.withdrawal_position_log')
  136. ->updateOrInsert(['order_sn' => $value->OrderId], $log);
  137. $state = 5;
  138. $RecordData = ['admin_id' => 0,
  139. 'before_state' => 1,
  140. 'after_state' => $state,
  141. 'RecordID' => $value->RecordID,
  142. 'create_at' => date('Y-m-d H:i:s'),
  143. 'update_at' => date('Y-m-d H:i:s')];
  144. !empty($data['remarks']) && $RecordData['remarks'] = $data['remarks'];
  145. // 添加用户提现操作记录
  146. DB::connection('write')->table('QPAccountsDB.dbo.AccountsRecord')
  147. ->updateOrInsert(['RecordID' => $value->RecordID, 'type' => 1], $RecordData);
  148. $RecordID = $value->RecordID;
  149. $amount = $value->WithDraw;
  150. $accountName = $value->BankUserName;
  151. $email = $value->EmailAddress;
  152. $phone = $value->PhoneNumber;
  153. $PixNum = $value->PixNum;
  154. $PixType = $value->PixType;
  155. $OrderId = $value->OrderId;
  156. $IFSCNumber = $value->IFSCNumber;
  157. $BranchBank = $value->BranchBank;
  158. $BankNO = $value->BankNO;
  159. // 改变状态处理中
  160. $agentID = DB::connection('write')->table('agent.dbo.admin_configs')->where('config_value', strval($agent))
  161. ->select('id')->first()->id ?? '';
  162. DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')->where('OrderId', $OrderId)
  163. ->update(['State' => $state, 'agent' => $agentID]);
  164. Log::info('自动免审:'.$OrderId.'--'.$agentID);
  165. $service = CashService::payment($agent);
  166. $result = $service->payment($RecordID, $amount, $accountName, $phone, $email, $OrderId, $PixNum,
  167. $PixType, $IFSCNumber, $BranchBank, $BankNO);
  168. if ($result === 'fail') {
  169. Log::info('免审提现失败:'.$value->OrderId);
  170. }
  171. }
  172. }
  173. }
  174. }