Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

117 lines
3.2KB

  1. <?php
  2. namespace App\Console\Commands\Test;
  3. use App\Console\Commands\BaseCommand;
  4. use App\Logics\QRService\CreateLogic;
  5. use App\Models\HtpmsCustomer\Deposit\Deposit;
  6. use App\Models\HtpmsCustomer\Mst\Shop;
  7. use App\Models\HtpmsCustomer\QRService\AcquisitionAvailableSetting;
  8. use App\Models\HtpmsCustomer\QRService\ServiceParkingGroup;
  9. use App\Models\HtpmsCustomer\QRService\ServiceParkingGroupRelation;
  10. use App\Util\DBUtil;
  11. use Exception;
  12. use Illuminate\Support\Facades\DB;
  13. class 方式3疎通データ作成 extends BaseCommand
  14. {
  15. const COMMAND = "test:make-pattern3-simple-data";
  16. /**
  17. * The name and signature of the console command.
  18. *
  19. * @var string
  20. */
  21. protected $signature = self::COMMAND;
  22. /**
  23. * The console command description.
  24. *
  25. * @var string
  26. */
  27. protected $description = '方式3の疎通確認用データを作成する';
  28. static public function getCommand()
  29. {
  30. return self::COMMAND;
  31. }
  32. /**
  33. * Create a new command instance.
  34. *
  35. * @return void
  36. */
  37. public function __construct()
  38. {
  39. parent::__construct();
  40. }
  41. /**
  42. * Execute the console command.
  43. *
  44. * @return int
  45. */
  46. public function service(): int
  47. {
  48. $db = new DBUtil();
  49. try {
  50. $db->beginTransaction();
  51. // 店舗作成
  52. $shop = new Shop();
  53. $shop->name = "方式3疎通確認用店舗";
  54. $shop->under_amount_when_auth = 0;
  55. $shop->qr_service_expire_min = 0;
  56. $shop->save();
  57. // デポジット作成
  58. $deposit = new Deposit();
  59. $deposit->shop_id = $shop->id;
  60. $deposit->deposit = 10000;
  61. $deposit->save();
  62. // QRサービス券駐車場グループ作成
  63. $group = new ServiceParkingGroup();
  64. $group->name = "方式3疎通確認用QRサービス券駐車場グループ";
  65. $group->save();
  66. // QRサービス券駐車場グループ紐づけ作成
  67. $groupRelation = new ServiceParkingGroupRelation();
  68. $groupRelation->qr_service_parking_group_id = $group->id;
  69. $groupRelation->parking_management_code = "90002";
  70. $groupRelation->save();
  71. $groupRelation = new ServiceParkingGroupRelation();
  72. $groupRelation->qr_service_parking_group_id = $group->id;
  73. $groupRelation->parking_management_code = "90005";
  74. $groupRelation->save();
  75. // 設定作成
  76. $setting = new AcquisitionAvailableSetting();
  77. $setting->shop_id = $shop->id;
  78. $setting->shop_no = 30;
  79. $setting->qr_service_parking_group_id = $group->id;
  80. $setting->discount_ticket_code = 31;
  81. $setting->save();
  82. // サービス券取得用トークン作成
  83. $token = CreateLogic::getToken($shop->id);
  84. $this->info(sprintf("トークン %s", $token->token));
  85. $this->info(sprintf("%s/qr-service/acquitision/%s", config('app.url'), $token->token));
  86. $db->commit();
  87. } catch (Exception $e) {
  88. $db->rollBack();
  89. throw $e;
  90. }
  91. return self::RESULTCODE_SUCCESS;
  92. }
  93. }