UpdateYzHistoryData.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. declare (strict_types=1);
  3. namespace app\command;
  4. use think\console\Command;
  5. use think\console\Input;
  6. use think\console\input\Argument;
  7. use think\console\input\Option;
  8. use think\console\Output;
  9. use think\Exception;
  10. use think\facade\Db;
  11. class UpdateYzHistoryData extends Command
  12. {
  13. protected function configure()
  14. {
  15. // 指令配置
  16. $this->setName('UpdateYzHistoryData')
  17. ->setDescription('更新有赞的历史数据');
  18. }
  19. protected function execute(Input $input, Output $output)
  20. {
  21. $data = Db::name('order_out')
  22. ->alias('a')
  23. ->field('a.orderCode,a.outCode,a.post_name,a.post_code')
  24. ->leftJoin('sale b', 'b.orderCode=a.orderCode')
  25. ->where('a.addtime', '>=', date('Y-m-d H:i:s', time() - 72 * 3600))
  26. ->where([
  27. 'a.is_del' => 0,
  28. 'a.status' => 2,
  29. 'b.order_source' => 5
  30. ])
  31. ->limit(1)->select()->toArray();
  32. // ->cursor();
  33. $url = config('app.yz_domain') . 'api/yz_out_send';
  34. foreach ($data as $value) {
  35. $res = curl_request($url, [
  36. 'orderCode' => $value['orderCode'],
  37. 'out_stype' => $value['post_name'],
  38. 'post_code' => $value['post_code'],
  39. 'uid' => 96,
  40. 'uname' => '武锋(历史数据处理)',
  41. 'order_out' => $value['outCode'],
  42. ]);
  43. $res = json_decode($res, true);
  44. if ($res['code'] != 0) $output->writeln('handle fail,' . json_encode($value, JSON_UNESCAPED_UNICODE) . ':' . $res['message']);
  45. }
  46. }
  47. }