|
- <?php
-
- namespace Tests\Feature\Http;
-
- use App\Codes\HTTPResultCode;
- 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\AcquisitionTicket;
- use App\Models\HtpmsCustomer\QRService\AcquisitionTicketToken;
- use App\Models\HtpmsCustomer\QRService\ServiceParkingGroup;
- use App\Models\HtpmsCustomer\QRService\ServiceParkingGroupRelation;
- use App\Util\DateUtil;
- use Tests\TestCase;
-
- /**
- * @group IF24-02
- */
- class IF24_02Test extends TestCase
- {
-
- protected function tearDown(): void
- {
- parent::tearDown();
- }
- protected function setUp(): void
- {
- parent::setUp();
-
- Shop::truncate();
- Deposit::truncate();
- AcquisitionAvailableSetting::truncate();
- AcquisitionTicket::truncate();
- ServiceParkingGroup::truncate();
- ServiceParkingGroupRelation::truncate();
- AcquisitionTicketToken::truncate();
- }
-
- /**
- * A basic feature test example.
- */
- public function test_IF21_01(): void
- {
- // 店舗作成
- $shop = new Shop();
- $shop->name = "test shop";
- $shop->under_amount_when_auth = 0;
- $shop->qr_service_expire_min = 100;
- $shop->save();
-
- // デポジット作成
- $deposit = new Deposit();
- $deposit->shop_id = $shop->id;
- $deposit->deposit = 1000;
- $deposit->save();
-
-
- // QRサービス券駐車場グループ作成
- $group = new ServiceParkingGroup();
- $group->name = "GROUP";
- $group->save();
-
- // QRサービス券駐車場グループ紐づけ作成
- $groupRelation = new ServiceParkingGroupRelation();
- $groupRelation->qr_service_parking_group_id = $group->id;
- $groupRelation->parking_management_code = "58993";
- $groupRelation->save();
-
- // 設定作成
- $setting = new AcquisitionAvailableSetting();
- $setting->shop_id = $shop->id;
- $setting->shop_no = 55;
- $setting->qr_service_parking_group_id = $group->id;
- $setting->discount_ticket_code = 10;
- $setting->save();
-
- // サービス券取得用トークン作成
- $token = CreateLogic::getToken($shop->id);
-
-
-
- // サービス券作成
- $res = $this->post('/api/qr-service/get-ticket', [
- 'token' => $token->token
- ]);
-
- $this->assertEquals(HTTPResultCode::SECCESS->value, $res->json("result"));
- // print_r($res->json());
-
-
- // 作成済みのサービス券取得
- $ticketId = $res->json("data.ticket_id");
- $qr = $res->json("data.data");
- $res = $this->post('/api/qr-service/get-ticket', [
- 'token' => $token->token,
- 'ticket_id' => $ticketId,
- ]);
-
- $this->assertEquals(HTTPResultCode::SECCESS->value, $res->json("result"));
- $this->assertEquals($ticketId, $res->json("data.ticket_id"));
- $this->assertEquals($qr, $res->json("data.data"));
-
- $data = AcquisitionTicket::firstOrFail();
-
- $res = $this->post('/Adjust/CheckQRDiscountTicket', [
- "Header" => [
- "CustomerCode" => "9990",
- "ParkingManagementCode" => "58993",
- "AdjusterSerialNo" => 1,
- "SendDatetime" => DateUtil::now()->format('YmdHis'),
- "ResultCode" => "100",
- "InterfaceID" => "IF24-01",
- ],
- "Body" => [
- "QRCodeType" => 4,
- "PublishingTerminalCode" => "01",
- "PublishingDate" => DateUtil::now()->format('Ymd'),
- "PublishingNo" => $data->publishing_no,
- "ShopNo" => $setting->shop_no,
- "DiscountTicketCode" => $setting->discount_ticket_code,
- "AdjustDatetime" => DateUtil::now()->format('YmdHi'),
- "DiscountAmount" => 100,
- ]
- ]);
-
- // print_r($res->json());
- // print_r(AcquisitionTicket::all()->toArray());
-
- $this->assertEquals("100", $res->json("Header.ResultCode"));
- }
- }
|