ExemptReview.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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) {
  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) {
  99. Log::info('注册IP重复过多阻拦自动免审:'.$value->OrderId);
  100. continue;
  101. }
  102. if ($AccountsInfoModel->sameLoginIPCount($value->UserID) > $sameCountCheckIP) {
  103. Log::info('登录IP重复过多阻拦自动免审:'.$value->OrderId);
  104. continue;
  105. }
  106. if ($AccountsInfoModel->sameLoginMacCount($value->UserID) > $sameCountCheck) {
  107. Log::info('MAC地址码重复阻拦自动免审:'.$value->OrderId);
  108. continue;
  109. }
  110. if(Cpf::getCpfCount($value->UserID)>$sameCountCheck){
  111. Log::info("CPF重复阻拦自动免审:".$value->OrderId);
  112. continue;
  113. }
  114. // 读取免审配置
  115. // $config = DB::table(TableName::agent().'withdrawal_position_config')->where('status', 1)->first();
  116. if (true) {
  117. if($value->PixType == 2){
  118. $agent = 101;
  119. }else{
  120. if(($value->WithDraw/NumConfig::NUM_VALUE)<20){
  121. $agent = 99;
  122. }else{
  123. $agent = 101;
  124. }
  125. }
  126. $redis = Redis::connection();
  127. $order_sn = $value->OrderId;
  128. if ($redis->exists($order_sn.'key1')) {
  129. continue;
  130. }
  131. $redis->set($order_sn.'key1', $order_sn, 3600 * 24);
  132. $log = ['user_id' => $value->UserID,
  133. // 'config_id' => $config->id,
  134. 'use_quota' => intval($value->WithDraw),
  135. 'order_sn' => $value->OrderId];
  136. DB::connection('write')->table('agent.dbo.withdrawal_position_log')
  137. ->updateOrInsert(['order_sn' => $value->OrderId], $log);
  138. $state = 5;
  139. $RecordData = ['admin_id' => 0,
  140. 'before_state' => 1,
  141. 'after_state' => $state,
  142. 'RecordID' => $value->RecordID,
  143. 'create_at' => date('Y-m-d H:i:s'),
  144. 'update_at' => date('Y-m-d H:i:s')];
  145. !empty($data['remarks']) && $RecordData['remarks'] = $data['remarks'];
  146. // 添加用户提现操作记录
  147. DB::connection('write')->table('QPAccountsDB.dbo.AccountsRecord')
  148. ->updateOrInsert(['RecordID' => $value->RecordID, 'type' => 1], $RecordData);
  149. $RecordID = $value->RecordID;
  150. $amount = $value->WithDraw;
  151. $accountName = $value->BankUserName;
  152. $email = $value->EmailAddress;
  153. $phone = $value->PhoneNumber;
  154. $PixNum = $value->PixNum;
  155. $PixType = $value->PixType;
  156. $OrderId = $value->OrderId;
  157. $IFSCNumber = $value->IFSCNumber;
  158. $BranchBank = $value->BranchBank;
  159. $BankNO = $value->BankNO;
  160. // 改变状态处理中
  161. $agentID = DB::connection('write')->table('agent.dbo.admin_configs')->where('config_value', strval($agent))
  162. ->select('id')->first()->id ?? '';
  163. DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')->where('OrderId', $OrderId)
  164. ->update(['State' => $state, 'agent' => $agentID]);
  165. Log::info('自动免审:'.$OrderId.'--'.$agentID);
  166. $service = CashService::payment($agent);
  167. $result = $service->payment($RecordID, $amount, $accountName, $phone, $email, $OrderId, $PixNum,
  168. $PixType, $IFSCNumber, $BranchBank, $BankNO);
  169. if ($result === 'fail') {
  170. Log::info('免审提现失败:'.$value->OrderId);
  171. }
  172. }
  173. }
  174. }
  175. }