| @@ -0,0 +1,116 @@ | |||||
| <?php | |||||
| namespace App\Console\Commands\Test; | |||||
| use App\Console\Commands\BaseCommand; | |||||
| use App\Logics\QRService\CreateLogic; | |||||
| use App\Models\HtpmsCustomer\Deposit\Deposit; | |||||
| use App\Models\HtpmsCustomer\Mst\Shop; | |||||
| use App\Models\HtpmsCustomer\QRService\AcquisitionAvailableSetting; | |||||
| use App\Models\HtpmsCustomer\QRService\ServiceParkingGroup; | |||||
| use App\Models\HtpmsCustomer\QRService\ServiceParkingGroupRelation; | |||||
| use App\Util\DBUtil; | |||||
| use Exception; | |||||
| use Illuminate\Support\Facades\DB; | |||||
| class 方式3疎通データ作成 extends BaseCommand | |||||
| { | |||||
| const COMMAND = "test:make-pattern3-simple-data"; | |||||
| /** | |||||
| * The name and signature of the console command. | |||||
| * | |||||
| * @var string | |||||
| */ | |||||
| protected $signature = self::COMMAND; | |||||
| /** | |||||
| * The console command description. | |||||
| * | |||||
| * @var string | |||||
| */ | |||||
| protected $description = '方式3の疎通確認用データを作成する'; | |||||
| static public function getCommand() | |||||
| { | |||||
| return self::COMMAND; | |||||
| } | |||||
| /** | |||||
| * Create a new command instance. | |||||
| * | |||||
| * @return void | |||||
| */ | |||||
| public function __construct() | |||||
| { | |||||
| parent::__construct(); | |||||
| } | |||||
| /** | |||||
| * Execute the console command. | |||||
| * | |||||
| * @return int | |||||
| */ | |||||
| public function service(): int | |||||
| { | |||||
| $db = new DBUtil(); | |||||
| try { | |||||
| $db->beginTransaction(); | |||||
| // 店舗作成 | |||||
| $shop = new Shop(); | |||||
| $shop->name = "方式3疎通確認用店舗"; | |||||
| $shop->under_amount_when_auth = 0; | |||||
| $shop->qr_service_expire_min = 0; | |||||
| $shop->save(); | |||||
| // デポジット作成 | |||||
| $deposit = new Deposit(); | |||||
| $deposit->shop_id = $shop->id; | |||||
| $deposit->deposit = 10000; | |||||
| $deposit->save(); | |||||
| // QRサービス券駐車場グループ作成 | |||||
| $group = new ServiceParkingGroup(); | |||||
| $group->name = "方式3疎通確認用QRサービス券駐車場グループ"; | |||||
| $group->save(); | |||||
| // QRサービス券駐車場グループ紐づけ作成 | |||||
| $groupRelation = new ServiceParkingGroupRelation(); | |||||
| $groupRelation->qr_service_parking_group_id = $group->id; | |||||
| $groupRelation->parking_management_code = "90002"; | |||||
| $groupRelation->save(); | |||||
| $groupRelation = new ServiceParkingGroupRelation(); | |||||
| $groupRelation->qr_service_parking_group_id = $group->id; | |||||
| $groupRelation->parking_management_code = "90005"; | |||||
| $groupRelation->save(); | |||||
| // 設定作成 | |||||
| $setting = new AcquisitionAvailableSetting(); | |||||
| $setting->shop_id = $shop->id; | |||||
| $setting->shop_no = 30; | |||||
| $setting->qr_service_parking_group_id = $group->id; | |||||
| $setting->discount_ticket_code = 31; | |||||
| $setting->save(); | |||||
| // サービス券取得用トークン作成 | |||||
| $token = CreateLogic::getToken($shop->id); | |||||
| $this->info(sprintf("トークン %s", $token->token)); | |||||
| $this->info(sprintf("%s/qr-service/acquitision/%s", config('app.url'), $token->token)); | |||||
| $db->commit(); | |||||
| } catch (Exception $e) { | |||||
| $db->rollBack(); | |||||
| throw $e; | |||||
| } | |||||
| return self::RESULTCODE_SUCCESS; | |||||
| } | |||||
| } | |||||