NewCustomCommand.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace app\command;
  3. use app\model\Member;
  4. use app\model\MemberAccount;
  5. use app\model\Order;
  6. use app\model\PayDetail;
  7. use support\Db;
  8. use Symfony\Component\Console\Command\Command;
  9. use Symfony\Component\Console\Input\InputArgument;
  10. use Symfony\Component\Console\Input\InputInterface;
  11. use Symfony\Component\Console\Output\OutputInterface;
  12. class NewCustomCommand extends Command
  13. {
  14. protected static $defaultName = 'NewCustomCommand';
  15. protected static $defaultDescription = 'NewCustomCommand';
  16. /**
  17. * @return void
  18. */
  19. protected function configure()
  20. {
  21. // $this->addArgument('name', InputArgument::OPTIONAL, '余额账户转福利账户');
  22. $this->addArgument('name', InputArgument::OPTIONAL, '新客专享回填订单号');
  23. }
  24. protected function execute(InputInterface $input, OutputInterface $output): int
  25. {
  26. $payDetails = PayDetail::where('pay_category', 'COMBINE')->get()->toArray();
  27. try {
  28. foreach ($payDetails as $payDetail) {
  29. if (!empty($payDetail['join_pay_object_json'])) {
  30. $payObjectJson = json_decode($payDetail['join_pay_object_json'], true);
  31. }
  32. // 查订单号
  33. $payDetailOrder = PayDetail::where('join_pay_order_id', 'COMBINE')
  34. ->where('join_pay_member_id', $payDetail['join_pay_member_id'])
  35. ->first();
  36. if (!empty($payDetailOrder->join_pay_object_json)) {
  37. $payObjectJson2 = json_decode($payDetailOrder->join_pay_object_json, true);
  38. if (isset($payObjectJson2['recharge_order_id'])) {
  39. continue;
  40. }
  41. if (isset($payObjectJson['order_id'])) {
  42. $payObjectJson2['recharge_order_id'] = $payObjectJson['order_id'];
  43. PayDetail::where('pay_id', $payDetailOrder->pay_id)->update([
  44. 'join_pay_object_json' => json_encode($payObjectJson2)
  45. ]);
  46. }
  47. }
  48. echo "支付记录【" . $payDetail['pay_id'] . "】已处理完成\n";
  49. }
  50. Db::commit();
  51. return self::SUCCESS;
  52. } catch (\Exception $e) {
  53. dump($e->getMessage());
  54. Db::rollBack();
  55. return self::SUCCESS;
  56. }
  57. }
  58. }