PayOrder.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Http\AppFlyerEvent\AppflyerEvent;
  4. use App\Http\helper\Helper;
  5. use App\Http\helper\HttpCurl;
  6. use App\Services\StoredProcedure;
  7. use Illuminate\Console\Command;
  8. use Illuminate\Support\Facades\Log;
  9. use Illuminate\Support\Facades\Redis;
  10. class PayOrder extends Command
  11. {
  12. /**
  13. * The name and signature of the console command.
  14. *
  15. * @var string
  16. */
  17. protected $signature = 'order_list';
  18. /**
  19. * The console command description.
  20. *
  21. * @var string
  22. */
  23. protected $description = '订单队列';
  24. /**
  25. * Create a new command instance.
  26. *
  27. * @return void
  28. */
  29. public function __construct()
  30. {
  31. parent::__construct();
  32. }
  33. /**
  34. * Execute the console command.
  35. *
  36. * @return mixed
  37. */
  38. public function handle()
  39. {
  40. // $redis = new \Redis();
  41. //
  42. // $redis->connect('127.0.0.1', '6379');
  43. // $redis->auth('uKliY6dhGYhWAwCW');
  44. // $redis->connect('127.0.0.1', '6379');
  45. while (true) {
  46. $res = Redis::rPop('payService');
  47. if ($res) {
  48. $jsonToData = \GuzzleHttp\json_decode($res, true);
  49. $userID = $jsonToData['userID'];
  50. $payMoney = $jsonToData['payAmt'];
  51. $favorable_price = $jsonToData['favorable_price'];
  52. $Score = $jsonToData['Score'];
  53. $GiftsID = $jsonToData['GiftsID'];
  54. // 开始执行时间
  55. $startTime = Helper::millisecond();
  56. // 执行存储过程 -- 防刷机制
  57. StoredProcedure::SetUserTabType($userID);
  58. //DB::connection('write')->select("SET NOCOUNT ON use QPAccountsDB exec GSP_GP_SetUserTabType12 $userID");
  59. Log::info('GSP_GP_SetUserTabType12 执行时间:' . ((Helper::millisecond() - $startTime) / 1000));
  60. # 单控标签 -- 执行存储过程
  61. StoredProcedure::user_label($userID, 1, $payMoney);
  62. Log::info('CheckAccountsLabel 执行时间:' . ((Helper::millisecond() - $startTime) / 1000));
  63. // 服务器通知
  64. $url = config('transfer.stock')['url'] . 'notifyPay';
  65. $data = [
  66. 'userid' => $userID,
  67. 'getScore' => $favorable_price,
  68. 'score' => $Score,
  69. 'giftsid' => empty($GiftsID) ? 0 : $GiftsID
  70. ];
  71. (new HttpCurl())->service($url, $data);
  72. Log::info('中转服 执行时间:' . ((Helper::millisecond() - $startTime) / 1000));
  73. // AF 事件
  74. $bool = (new AppflyerEvent())->event($userID, '', 'af_purchase_new', $payMoney);
  75. Log::info('AF 执行时间:' . ((Helper::millisecond() - $startTime) / 1000));
  76. echo '李雪峰';
  77. }
  78. sleep(3);
  79. }
  80. }
  81. }