Browse Source

IC定期連携対応

master
sosuke.iwabuchi 1 year ago
parent
commit
c51741ba3f
39 changed files with 1169 additions and 3 deletions
  1. +44
    -0
      app/Http/Controllers/Web/Customer/BeforeDeleteController.php
  2. +18
    -0
      app/Http/Controllers/Web/Customer/BeforeDeleteParam.php
  3. +43
    -0
      app/Http/Controllers/Web/Customer/BeforeUpdateController.php
  4. +27
    -0
      app/Http/Controllers/Web/Customer/BeforeUpdateParam.php
  5. +13
    -2
      app/Http/Controllers/Web/FromKintoneController.php
  6. +76
    -0
      app/Http/Controllers/Web/HTICWeb/AdjustDataController.php
  7. +25
    -0
      app/Http/Controllers/Web/HTICWeb/AdjustDataParam.php
  8. +77
    -0
      app/Http/Controllers/Web/HTICWeb/SeasonTicketContractController.php
  9. +41
    -0
      app/Http/Controllers/Web/HTICWeb/SeasonTicketContractParam.php
  10. +37
    -0
      app/Http/Controllers/Web/HTICWeb/UserController.php
  11. +17
    -0
      app/Http/Controllers/Web/HTICWeb/UserParam.php
  12. +39
    -0
      app/Http/Controllers/Web/HTICWeb/UserRegisterController.php
  13. +29
    -0
      app/Http/Controllers/Web/HTICWeb/UserRegisterParam.php
  14. +77
    -0
      app/Http/Controllers/Web/SeasonTicketContract/BeforeCreateController.php
  15. +30
    -0
      app/Http/Controllers/Web/SeasonTicketContract/BeforeCreateParam.php
  16. +39
    -0
      app/Http/Controllers/Web/SeasonTicketContract/BeforeDeleteController.php
  17. +19
    -0
      app/Http/Controllers/Web/SeasonTicketContract/BeforeDeleteParam.php
  18. +76
    -0
      app/Http/Controllers/Web/SeasonTicketContract/BeforeUpdateController.php
  19. +30
    -0
      app/Http/Controllers/Web/SeasonTicketContract/BeforeUpdateParam.php
  20. +38
    -0
      app/Http/Controllers/Web/SeasonTicketContract/FetchController.php
  21. +18
    -0
      app/Http/Controllers/Web/SeasonTicketContract/FetchParam.php
  22. +58
    -0
      app/Http/Controllers/Web/SeasonTicketContract/ParkingUseTypeChangeOrderController.php
  23. +24
    -0
      app/Http/Controllers/Web/SeasonTicketContract/ParkingUseTypeChangeOrderParam.php
  24. +13
    -0
      app/Http/Controllers/Web/WebController.php
  25. +1
    -0
      app/Http/Kernel.php
  26. +33
    -0
      app/Http/Middleware/FromHTICWeb.php
  27. +2
    -0
      app/Kintone/Models/Customer.php
  28. +13
    -0
      app/Kintone/Models/DropDown/PaymentPlan/PaymentMethod.php
  29. +28
    -0
      app/Kintone/Models/ParkingUseTypeChangeOrderApplication.php
  30. +8
    -1
      app/Kintone/Models/PaymentPlan.php
  31. +36
    -0
      app/Kintone/Models/SeasonTicketContract.php
  32. +5
    -0
      app/Logic/GeneralApplicationManager.php
  33. +5
    -0
      app/Providers/RouteServiceProvider.php
  34. +87
    -0
      app/Transmissions/HTICWeb/Sender.php
  35. +8
    -0
      config/custom.php
  36. +2
    -0
      routes/api.php
  37. +19
    -0
      routes/apiFromHTICWeb.php
  38. +8
    -0
      routes/apiFromKintone.php
  39. +6
    -0
      routes/web.php

+ 44
- 0
app/Http/Controllers/Web/Customer/BeforeDeleteController.php View File

@@ -0,0 +1,44 @@
<?php

namespace App\Http\Controllers\Web\Customer;

use App\Http\Controllers\Web\FromKintoneController;
use App\Transmissions\HTICWeb\Sender;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class BeforeDeleteController extends FromKintoneController
{

public function name(): string
{
return "IC定期用 顧客情報削除";
}

public function description(): string
{
return "IC定期用 顧客情報削除";
}

use Sender;


public function __construct(protected BeforeDeleteParam $param)
{
parent::__construct();
}

protected function run(Request $request): JsonResponse
{
$param = $this->param;

$this->sendUserDelete(
[
...$param->toArray(),
'id' => $param->userId,
]
);

return $this->successResponse();
}
}

+ 18
- 0
app/Http/Controllers/Web/Customer/BeforeDeleteParam.php View File

@@ -0,0 +1,18 @@
<?php

namespace App\Http\Controllers\Web\Customer;

use App\Http\Controllers\Web\BaseParam;

/**
* @property int userId
*/
class BeforeDeleteParam extends BaseParam
{
public function rules(): array
{
return [
'user_id' => $this->numeric(),
];
}
}

+ 43
- 0
app/Http/Controllers/Web/Customer/BeforeUpdateController.php View File

@@ -0,0 +1,43 @@
<?php

namespace App\Http\Controllers\Web\Customer;

use App\Http\Controllers\Web\FromKintoneController;
use App\Transmissions\HTICWeb\Sender;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class BeforeUpdateController extends FromKintoneController
{

public function name(): string
{
return "IC定期用 顧客情報更新";
}

public function description(): string
{
return "IC定期用 顧客情報更新";
}

use Sender;


public function __construct(protected BeforeUpdateParam $param)
{
parent::__construct();
}

protected function run(Request $request): JsonResponse
{
$param = $this->param;

$res = $this->sendUserUpdate(
[
...$param->toArray(),
]
);

return $this->successResponse($res->json("data"));
}
}

+ 27
- 0
app/Http/Controllers/Web/Customer/BeforeUpdateParam.php View File

@@ -0,0 +1,27 @@
<?php

namespace App\Http\Controllers\Web\Customer;

use App\Http\Controllers\Web\BaseParam;
use App\Http\Controllers\Web\Rule;

class BeforeUpdateParam extends BaseParam
{
public function rules(): array
{
return [
'user_id' => $this->numeric(),
'email' => $this->str([...Rule::email()]),
'first_name' => $this->str(true),
'last_name' => $this->str(true),
'first_name_kana' => $this->str(true),
'last_name_kana' => $this->str(true),
'zip_code' => $this->str(true),
'pref_code' => $this->str(true),
'address1' => $this->str(true),
'address2' => $this->str(true),
'address3' => $this->str(true),
'phone_number' => $this->str(true),
];
}
}

+ 13
- 2
app/Http/Controllers/Web/FromKintoneController.php View File

@@ -16,11 +16,22 @@ abstract class FromKintoneController extends WebController
{
if ($this->resultCode === ResultCode::SECCESS) {
return response()->json([
'result' => 'SUCCESS'
'result' => 'SUCCESS',
'data' => $this->getData(),
]);
}

$message = $this->getGeneralMessage() ?? "";
if (!$message) {
$messages = $this->getMessages();
if (is_array($message) && 0 < count($messages)) {
$message = $messages[array_key_first($message)];
}
}

return response()->json([
'result' => 'FAILED'
'result' => 'FAILED',
'message' => $message,
]);
}
}

+ 76
- 0
app/Http/Controllers/Web/HTICWeb/AdjustDataController.php View File

@@ -0,0 +1,76 @@
<?php

namespace App\Http\Controllers\Web\HTICWeb;

use App\Http\Controllers\Web\WebController;
use App\Kintone\Models\DropDown\PaymentPlan\PaymentMethod;
use App\Kintone\Models\DropDown\PaymentPlan\PaymentType;
use App\Kintone\Models\PaymentPlan;
use App\Kintone\Models\SeasonTicketContract;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class AdjustDataController extends WebController
{

public function name(): string
{
return "[IC定期連携]精算データ連携";
}

public function description(): string
{
return "[IC定期連携]精算データ連携";
}


public function __construct(protected AdjustDataParam $param)
{
parent::__construct();
}

protected function run(Request $request): JsonResponse
{
$param = $this->param;

// 契約の特定
$query = SeasonTicketContract::getQuery()
->where(SeasonTicketContract::FIELD_IC_SEASON_TICEKT_PARKING_MANAGEMENT_CODE, $param->parkingManagementCode)
->where(SeasonTicketContract::FIELD_IC_SEASON_TICEKT_SEASON_TICKET_SEQ_NO, $param->seasonTicketSeqNo);
$list = SeasonTicketContract::getAccess()->all($query);
if ($list->count() !== 1) {
// 対象不正のためスキップ
info("対象不正のためスキップ");
return $this->successResponse();
}
$seasonTicketContract = $list[0];

// 重複チェック
$query = PaymentPlan::getQuery()
->where(PaymentPlan::FIELD_IC_SEASON_TICKET_CONTRACT_ID, $seasonTicketContract->icSeasonTicektContractId)
->where(PaymentPlan::FIELD_CUSTOMER_CODE, $seasonTicketContract->customerCode)
->whereDate(PaymentPlan::FIELD_APPROPRIATION_DATE, $param->adjustDatetime)
->where(PaymentPlan::FIELD_APPROPRIATION_AMOUNT, $param->parkingCharge);
if (PaymentPlan::getAccess()->all($query)->isNotEmpty()) {
// 登録済みのためスキップ
info("登録済みのためスキップ");
return $this->successResponse();
}

// データ保存
$plan = new PaymentPlan();
$plan->seasonTicketContractRecordNo = $seasonTicketContract->getRecordId();
$plan->icSeasonTicketContractId = $seasonTicketContract->icSeasonTicektContractId;
$plan->paymentType = PaymentType::SEASON_TICKET;
$plan->paymentMethod = PaymentMethod::定期更新機;
$plan->paymentPlanDate = $param->adjustDatetime;
$plan->paymentPlanAmount = $param->parkingCharge;
$plan->appropriationDate = $param->adjustDatetime;
$plan->appropriationAmount = $param->parkingCharge;
$plan->remainingAmount = 0;

$plan->save();

return $this->successResponse();
}
}

+ 25
- 0
app/Http/Controllers/Web/HTICWeb/AdjustDataParam.php View File

@@ -0,0 +1,25 @@
<?php

namespace App\Http\Controllers\Web\HTICWeb;

use App\Http\Controllers\Web\BaseParam;
use Illuminate\Support\Carbon;

/**
* @property string parkingManagementCode
* @property int seasonTicketSeqNo
* @property int parkingCharge
* @property Carbon adjustDatetime
*/
class AdjustDataParam extends BaseParam
{
public function rules(): array
{
return [
'parking_management_code' => $this->str(),
'season_ticket_seq_no' => $this->numeric(),
'parking_charge' => $this->numeric(),
'adjust_datetime' => $this->date(),
];
}
}

+ 77
- 0
app/Http/Controllers/Web/HTICWeb/SeasonTicketContractController.php View File

@@ -0,0 +1,77 @@
<?php

namespace App\Http\Controllers\Web\HTICWeb;

use App\Http\Controllers\Web\WebController;
use App\Kintone\Models\Customer;
use App\Kintone\Models\SeasonTicketContract;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;

class SeasonTicketContractController extends WebController
{

public function name(): string
{
return "[IC定期連携]定期契約情報連携";
}

public function description(): string
{
return "[IC定期連携]定期契約情報連携";
}


public function __construct(protected SeasonTicketContractParam $param)
{
parent::__construct();
}

protected function run(Request $request): JsonResponse
{
$param = $this->param;

// 顧客マスタの特定
$query = Customer::getQuery()->where(Customer::FIELD_IC_SEASON_TICEKT_USER_ID, $param->userId);
$customerList = Customer::getAccess()->all($query);

if ($customerList->count() !== 1) {
// 対象不正のためスキップ
Log::warning("顧客不正のためスキップ");
return $this->successResponse();
}

// 契約の特定
$customer = $customerList[0];

$query = SeasonTicketContract::getQuery()
->where(SeasonTicketContract::FIELD_CUSTOMER_CODE, $customer->customerCode)
->where(SeasonTicketContract::FIELD_IC_SEASON_TICEKT_CONTRACT_ID, $param->seasonTicketContractId)
->where(SeasonTicketContract::FIELD_IC_SEASON_TICEKT_PARKING_MANAGEMENT_CODE, $param->parkingManagementCode);

$seasonTicketContractList = SeasonTicketContract::getAccess()->all($query);

if ($seasonTicketContractList->count() !== 1) {
// 対象不正のためスキップ
Log::warning("契約不正のためスキップ");
return $this->successResponse();
}

// 更新
$seasonTicketContract = $seasonTicketContractList[0];

$seasonTicketContract->icSeasonTicektSeasonTicketSeqNo = $param->seasonTicketSeqNo;
$seasonTicketContract->icSeasonTicektVehicleTypeName = $param->vehicleTypeName;
$seasonTicketContract->icSeasonTicektParkingUseTypeName = $param->parkingUseTypeName;
$seasonTicketContract->icSeasonTicektContractorTypeName = $param->contractorTypeLineNoName;
$seasonTicketContract->icSeasonTicektStartDate = $param->expirationStartDate;
$seasonTicketContract->icSeasonTicektEndDate = $param->expirationEndDate;
$seasonTicketContract->icSeasonTicektPositionMemo = $param->positionMemo;
$seasonTicketContract->icSeasonTicektMemo = $param->memo;

$seasonTicketContract->save();

return $this->successResponse();
}
}

+ 41
- 0
app/Http/Controllers/Web/HTICWeb/SeasonTicketContractParam.php View File

@@ -0,0 +1,41 @@
<?php

namespace App\Http\Controllers\Web\HTICWeb;

use App\Http\Controllers\Web\BaseParam;
use Illuminate\Support\Carbon;

/**
* @property int userId
* @property int seasonTicketContractId
* @property int seasonTicketSeqNo
* @property string parkingManagementCode
* @property ?Carbon expirationStartDate
* @property ?Carbon expirationEndDate
* @property string vehicleTypeName
* @property string parkingUseTypeName
* @property string contractorTypeLineNoName
* @property ?string positionMemo
* @property ?string memo
* @property bool invalidFlg
*/
class SeasonTicketContractParam extends BaseParam
{
public function rules(): array
{
return [
'user_id' => $this->numeric(),
'season_ticket_contract_id' => $this->numeric(),
'parking_management_code' => $this->str(),
'season_ticket_seq_no' => $this->numeric(),
'expiration_start_date' => $this->date(true),
'expiration_end_date' => $this->date(true),
'vehicle_type_name' => $this->str(),
'parking_use_type_name' => $this->str(),
'contractor_type_line_no_name' => $this->str(),
'position_memo' => $this->str(),
'memo' => $this->str(),
'invalid_flg' => $this->boolean(),
];
}
}

+ 37
- 0
app/Http/Controllers/Web/HTICWeb/UserController.php View File

@@ -0,0 +1,37 @@
<?php

namespace App\Http\Controllers\Web\HTICWeb;

use App\Http\Controllers\Web\WebController;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class UserController extends WebController
{

public function name(): string
{
return "[IC定期連携]利用者情報連携";
}

public function description(): string
{
return "[IC定期連携]利用者情報連携";
}


public function __construct(protected UserParam $param)
{
parent::__construct();
}

protected function run(Request $request): JsonResponse
{
$param = $this->param;




return $this->successResponse();
}
}

+ 17
- 0
app/Http/Controllers/Web/HTICWeb/UserParam.php View File

@@ -0,0 +1,17 @@
<?php

namespace App\Http\Controllers\Web\HTICWeb;

use App\Http\Controllers\Web\BaseParam;
use Illuminate\Support\Carbon;

/**

*/
class UserParam extends BaseParam
{
public function rules(): array
{
return [];
}
}

+ 39
- 0
app/Http/Controllers/Web/HTICWeb/UserRegisterController.php View File

@@ -0,0 +1,39 @@
<?php

namespace App\Http\Controllers\Web\HTICWeb;

use App\Http\Controllers\Web\FromKintoneController;
use App\Transmissions\HTICWeb\Sender;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class UserRegisterController extends FromKintoneController
{

use Sender;

public function name(): string
{
return "[IC定期連携]利用者情報新規登録";
}

public function description(): string
{
return "[IC定期連携]利用者情報新規登録";
}


public function __construct(protected UserRegisterParam $param)
{
parent::__construct();
}

protected function run(Request $request): JsonResponse
{
$param = $this->param;

$res = $this->sendUserCreate($param->toArray());

return $this->successResponse($res->json('data'));
}
}

+ 29
- 0
app/Http/Controllers/Web/HTICWeb/UserRegisterParam.php View File

@@ -0,0 +1,29 @@
<?php

namespace App\Http\Controllers\Web\HTICWeb;

use App\Http\Controllers\Web\BaseParam;
use App\Http\Controllers\Web\Rule;

/**

*/
class UserRegisterParam extends BaseParam
{
public function rules(): array
{
return [
'email' => $this->str([...Rule::email()]),
'first_name' => $this->str(true),
'last_name' => $this->str(true),
'first_name_kana' => $this->str(true),
'last_name_kana' => $this->str(true),
'zip_code' => $this->str(true),
'pref_code' => $this->str(true),
'address1' => $this->str(true),
'address2' => $this->str(true),
'address3' => $this->str(true),
'phone_number' => $this->str(true),
];
}
}

+ 77
- 0
app/Http/Controllers/Web/SeasonTicketContract/BeforeCreateController.php View File

@@ -0,0 +1,77 @@
<?php

namespace App\Http\Controllers\Web\SeasonTicketContract;

use App\Exceptions\GeneralErrorMessageException;
use App\Http\Controllers\Web\FromKintoneController;
use App\Transmissions\HTICWeb\Sender;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class BeforeCreateController extends FromKintoneController
{

public function name(): string
{
return "IC定期用 契約新規作成";
}

public function description(): string
{
return "IC定期用 契約新規作成";
}

use Sender;


public function __construct(protected BeforeCreateParam $param)
{
parent::__construct();
}

protected function run(Request $request): JsonResponse
{
$param = $this->param;


// 名称からコード値へ変換
$res = $this->getSeasonTicketContractParams($param->toArray());

$contractorType = $this->getKey($res->json("data.contractor_type"), $param->contractorTypeName);
$parkingUseType = $this->getKey($res->json("data.parking_use_type"), $param->parkingUseTypeName);
$vehicleType = $this->getKey($res->json("data.vehicle_type"), $param->vehicleTypeName);

if ($contractorType === null) {
throw new GeneralErrorMessageException("契約者タイプ不正");
}
if ($parkingUseType === null) {
throw new GeneralErrorMessageException("駐車場利用方法不正");
}
if ($vehicleType === null) {
throw new GeneralErrorMessageException("車両タイプ不正");
}

$res = $this->sendSeasonTicketContractCreate(
[
...$param->toArray(),
'contractor_type_line_no' => $contractorType,
'vehicle_type' => $vehicleType,
'parking_use_type' => $parkingUseType,
]
);

return $this->successResponse($res->json("data"));
}

private function getKey(array $list, string $targetName)
{
foreach ($list as $ele) {
$key = array_key_first($ele);
$val = $ele[$key];
if ($val === $targetName) {
return $key;
}
}
return null;
}
}

+ 30
- 0
app/Http/Controllers/Web/SeasonTicketContract/BeforeCreateParam.php View File

@@ -0,0 +1,30 @@
<?php

namespace App\Http\Controllers\Web\SeasonTicketContract;

use App\Http\Controllers\Web\BaseParam;

/**
* @property string seasonTicketContractRecordNo
* @property string vehicleTypeName
* @property string parkingUseTypeName
* @property string contractorTypeName
*/
class BeforeCreateParam extends BaseParam
{
public function rules(): array
{
return [
'user_id' => $this->numeric(),
'parking_management_code' => $this->str(),
'season_ticket_seq_no' => $this->numeric(true),
'vehicle_type_name' => $this->str(),
'parking_use_type_name' => $this->str(),
'contractor_type_name' => $this->str(),
'expiration_start_date' => $this->date(true),
'expiration_end_date' => $this->date(true),
'position_memo' => $this->str(true),
'memo' => $this->str(true),
];
}
}

+ 39
- 0
app/Http/Controllers/Web/SeasonTicketContract/BeforeDeleteController.php View File

@@ -0,0 +1,39 @@
<?php

namespace App\Http\Controllers\Web\SeasonTicketContract;

use App\Http\Controllers\Web\FromKintoneController;
use App\Transmissions\HTICWeb\Sender;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class BeforeDeleteController extends FromKintoneController
{

public function name(): string
{
return "IC定期用 契約更新確認";
}

public function description(): string
{
return "IC定期用 契約更新確認";
}

use Sender;


public function __construct(protected BeforeDeleteParam $param)
{
parent::__construct();
}

protected function run(Request $request): JsonResponse
{
$param = $this->param;

$res = $this->sendSeasonTicketContractDelete($param->toArray());

return $this->successResponse($res->json());
}
}

+ 19
- 0
app/Http/Controllers/Web/SeasonTicketContract/BeforeDeleteParam.php View File

@@ -0,0 +1,19 @@
<?php

namespace App\Http\Controllers\Web\SeasonTicketContract;

use App\Http\Controllers\Web\BaseParam;

/**
* @property string $seasonTicketContractRecordNo
*/
class BeforeDeleteParam extends BaseParam
{
public function rules(): array
{
return [
'user_id' => $this->numeric(),
'parking_management_code' => $this->str(),
];
}
}

+ 76
- 0
app/Http/Controllers/Web/SeasonTicketContract/BeforeUpdateController.php View File

@@ -0,0 +1,76 @@
<?php

namespace App\Http\Controllers\Web\SeasonTicketContract;

use App\Exceptions\GeneralErrorMessageException;
use App\Http\Controllers\Web\FromKintoneController;
use App\Transmissions\HTICWeb\Sender;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class BeforeUpdateController extends FromKintoneController
{

public function name(): string
{
return "IC定期用 契約更新確認";
}

public function description(): string
{
return "IC定期用 契約更新確認";
}

use Sender;


public function __construct(protected BeforeUpdateParam $param)
{
parent::__construct();
}

protected function run(Request $request): JsonResponse
{
$param = $this->param;


// 名称からコード値へ変換
$res = $this->getSeasonTicketContractParams($param->toArray());

$contractorType = $this->getKey($res->json("data.contractor_type"), $param->contractorTypeName);
$parkingUseType = $this->getKey($res->json("data.parking_use_type"), $param->parkingUseTypeName);
$vehicleType = $this->getKey($res->json("data.vehicle_type"), $param->vehicleTypeName);

if ($contractorType === null) {
throw new GeneralErrorMessageException("契約者タイプ不正");
}
if ($parkingUseType === null) {
throw new GeneralErrorMessageException("駐車場利用方法不正");
}
if ($vehicleType === null) {
throw new GeneralErrorMessageException("車両タイプ不正");
}

$res = $this->sendSeasonTicketContractUpdate(
[
...$param->toArray(),
'contractor_type_line_no' => $contractorType,
'vehicle_type' => $vehicleType,
'parking_use_type' => $parkingUseType,
]
);
return $this->successResponse($res->json("data"));
}

private function getKey(array $list, string $targetName)
{
foreach ($list as $ele) {
$key = array_key_first($ele);
$val = $ele[$key];
if ($val === $targetName) {
return $key;
}
}
return null;
}
}

+ 30
- 0
app/Http/Controllers/Web/SeasonTicketContract/BeforeUpdateParam.php View File

@@ -0,0 +1,30 @@
<?php

namespace App\Http\Controllers\Web\SeasonTicketContract;

use App\Http\Controllers\Web\BaseParam;

/**
* @property string seasonTicketContractRecordNo
* @property string vehicleTypeName
* @property string parkingUseTypeName
* @property string contractorTypeName
*/
class BeforeUpdateParam extends BaseParam
{
public function rules(): array
{
return [
'user_id' => $this->numeric(),
'parking_management_code' => $this->str(),
'season_ticket_seq_no' => $this->numeric(true),
'vehicle_type_name' => $this->str(),
'parking_use_type_name' => $this->str(),
'contractor_type_name' => $this->str(),
'expiration_start_date' => $this->date(true),
'expiration_end_date' => $this->date(true),
'position_memo' => $this->str(true),
'memo' => $this->str(true),
];
}
}

+ 38
- 0
app/Http/Controllers/Web/SeasonTicketContract/FetchController.php View File

@@ -0,0 +1,38 @@
<?php

namespace App\Http\Controllers\Web\SeasonTicketContract;

use App\Http\Controllers\Web\FromKintoneController;
use App\Transmissions\HTICWeb\Sender;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class FetchController extends FromKintoneController
{

public function name(): string
{
return "IC定期用 契約フェッチ";
}

public function description(): string
{
return "IC定期用 契約フェッチ";
}

use Sender;


public function __construct(protected FetchParam $param)
{
parent::__construct();
}

protected function run(Request $request): JsonResponse
{
$param = $this->param;

$res = $this->getSeasonTicketContractFetch($param->toArray());
return $this->successResponse($res->json("data"));
}
}

+ 18
- 0
app/Http/Controllers/Web/SeasonTicketContract/FetchParam.php View File

@@ -0,0 +1,18 @@
<?php

namespace App\Http\Controllers\Web\SeasonTicketContract;

use App\Http\Controllers\Web\BaseParam;

/**
* @property string seasonTicketContractId
*/
class FetchParam extends BaseParam
{
public function rules(): array
{
return [
'season_ticket_contract_id' => $this->numeric(),
];
}
}

+ 58
- 0
app/Http/Controllers/Web/SeasonTicketContract/ParkingUseTypeChangeOrderController.php View File

@@ -0,0 +1,58 @@
<?php

namespace App\Http\Controllers\Web\SeasonTicketContract;

use App\Http\Controllers\Web\WebController;
use App\Kintone\Models\Customer;
use App\Kintone\Models\Parking;
use App\Kintone\Models\ParkingUseTypeChangeOrderApplication;
use App\Kintone\Models\SeasonTicketContract;
use App\Logic\GeneralApplicationManager;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class ParkingUseTypeChangeOrderController extends WebController
{

public function name(): string
{
return "駐車場利用方法変更依頼";
}

public function description(): string
{
return "駐車場利用方法変更依頼を登録する";
}


public function __construct(protected ParkingUseTypeChangeOrderParam $param)
{
parent::__construct();
$this->middleware('auth:sanctum');
}

protected function run(Request $request): JsonResponse
{
$param = $this->param;

$parking = Parking::findByParkingName($param->parkingName);
$customer = Customer::getSelf();
$seasonTicketContract = SeasonTicketContract::find($param->seasonTicketContractRecordNo);

$application = new ParkingUseTypeChangeOrderApplication();
$manager = new GeneralApplicationManager($application);
$manager
->setCustomer($customer)
->setSeasonTicketContract($seasonTicketContract)
->setParking($parking)
->makeApplication();

$application->parkingUseTypeBefore = $seasonTicketContract->icSeasonTicektParkingUseTypeName;
$application->parkingUseTypeAfter = $param->parkingUseType;
$application->memo = $param->memo;

$application->save();

return $this->successResponse();
}
}

+ 24
- 0
app/Http/Controllers/Web/SeasonTicketContract/ParkingUseTypeChangeOrderParam.php View File

@@ -0,0 +1,24 @@
<?php

namespace App\Http\Controllers\Web\SeasonTicketContract;

use App\Http\Controllers\Web\BaseParam;

/**
* @property string seasonTicketContractRecordNo
* @property string parkingName
* @property string parkingUseType
* @property string memo
*/
class ParkingUseTypeChangeOrderParam extends BaseParam
{
public function rules(): array
{
return [
'season_ticket_contract_record_no' => $this->str(),
'parking_name' => $this->str(),
'parking_use_type' => $this->str(),
'memo' => $this->str(true),
];
}
}

+ 13
- 0
app/Http/Controllers/Web/WebController.php View File

@@ -377,6 +377,19 @@ abstract class WebController extends BaseController
return $this;
}

protected function getData()
{
return $this->data;
}
protected function getGeneralMessage()
{
return $this->generalMessage;
}
protected function getMessages()
{
return $this->messages;
}

protected function setResultCode(ResultCode $resultCode)
{
$this->resultCode = $resultCode;


+ 1
- 0
app/Http/Kernel.php View File

@@ -65,5 +65,6 @@ class Kernel extends HttpKernel
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,

'fromKintone' => \App\Http\Middleware\FromKintoneMiddleware::class,
'fromHTICWeb' => \App\Http\Middleware\FromHTICWeb::class,
];
}

+ 33
- 0
app/Http/Middleware/FromHTICWeb.php View File

@@ -0,0 +1,33 @@
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;

class FromHTICWeb
{
private const API_KEY_NAME = "kyoto-public-api-key";

/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next)
{


if ($request->has(self::API_KEY_NAME) === false) {
abort(403);
}

if ($request->get(self::API_KEY_NAME) !== config("custom.ht-ic-web.apiKey")) {
abort(403);
}

return $next($request);
}
}

+ 2
- 0
app/Kintone/Models/Customer.php View File

@@ -29,6 +29,7 @@ class Customer extends KintoneModel
const FIELD_ADDRESS = "住所";
const FIELD_BANK_BRANCH_ID = "ChargedBankBranchCode";
const FIELD_BANK_ACCOUNT_REGISTER_REMAIND_DATETIME = "口座登録催促予定日時";
const FIELD_IC_SEASON_TICEKT_USER_ID = "IC定期関連情報_ユーザーID";

protected const FIELDS = [
...parent::FIELDS,
@@ -41,6 +42,7 @@ class Customer extends KintoneModel
self::FIELD_ADDRESS => FieldType::SINGLE_LINE_TEXT,
self::FIELD_BANK_BRANCH_ID => FieldType::SINGLE_LINE_TEXT,
self::FIELD_BANK_ACCOUNT_REGISTER_REMAIND_DATETIME => FieldType::DATETIME,
self::FIELD_IC_SEASON_TICEKT_USER_ID => FieldType::NUMBER,
];

protected const FIELD_NAMES = [


+ 13
- 0
app/Kintone/Models/DropDown/PaymentPlan/PaymentMethod.php View File

@@ -0,0 +1,13 @@
<?php

namespace App\Kintone\Models\DropDown\PaymentPlan;

abstract class PaymentMethod
{
const SMBC口座振替 = "SMBC口座振替";
const 振込 = "振込";
const コンビニ = "コンビニ";
const 現金 = "現金";
const クレジットカード = "クレジットカード";
const 定期更新機 = "定期更新機";
}

+ 28
- 0
app/Kintone/Models/ParkingUseTypeChangeOrderApplication.php View File

@@ -0,0 +1,28 @@
<?php

namespace App\Kintone\Models;

/**
* アプリ名 各種申請 [駐車場利用方法変更申請]
*
* @property string parkingUseTypeBefore
* @property string parkingUseTypeAfter
* @property string memo
*/
class ParkingUseTypeChangeOrderApplication extends GeneralApplication
{
const FIELD_PARKING_USE_TYPE_BEFORE = "IC定期_駐車場利用方法変更申請_変更前";
const FIELD_PARKING_USE_TYPE_AFTER = "IC定期_駐車場利用方法変更申請_変更後";
const FIELD_MEMO = "IC定期_駐車場利用方法変更申請_備考";

protected const FIELDS = [
...parent::FIELDS,
self::FIELD_PARKING_USE_TYPE_BEFORE => FieldType::SINGLE_LINE_TEXT,
self::FIELD_PARKING_USE_TYPE_AFTER => FieldType::SINGLE_LINE_TEXT,
self::FIELD_MEMO => FieldType::MULTI_LINE_TEXT,
];

protected const FIELD_NAMES = [
...parent::FIELD_NAMES,
];
}

+ 8
- 1
app/Kintone/Models/PaymentPlan.php View File

@@ -9,7 +9,7 @@ use Illuminate\Support\Collection;

/**
* アプリ名 入金予定・結果
* @property int SEASON_TICKET_CONTRACT_RECORD_NO
* @property int seasonTicketContractRecordNo
* @property string parkingName
* @property int parkingName
* @property int customerCode
@@ -26,6 +26,7 @@ use Illuminate\Support\Collection;
* @property int firstPaymentEntryRecordNo
* @property Collection<int ,Deposit> depositList
* @property string[] partialFee
* @property int icSeasonTicketContractId
*/
class PaymentPlan extends KintoneModel
{
@@ -49,6 +50,7 @@ class PaymentPlan extends KintoneModel
const FIELD_DEPOSIT_LIST_NAME = "保証金明細_名称";
const FIELD_DEPOSIT_LIST_AMOUNT = "保証金明細_金額";
const FIELD_PARTIAL_FEE = "定期料金日割り分";
const FIELD_IC_SEASON_TICKET_CONTRACT_ID = "IC定期_契約ID";

protected const FIELDS = [
...parent::FIELDS,
@@ -68,6 +70,7 @@ class PaymentPlan extends KintoneModel
self::FIELD_FIRST_PAYMENT_ENTRY_RECORD_NO => FieldType::NUMBER,
self::FIELD_DEPOSIT_LIST => FieldType::SUBTABLE,
self::FIELD_PARTIAL_FEE => FieldType::CHECK_BOX,
self::FIELD_IC_SEASON_TICKET_CONTRACT_ID => FieldType::NUMBER,
];

protected const SUB_TABLES = [
@@ -85,6 +88,10 @@ class PaymentPlan extends KintoneModel
self::FIELD_TARGET_MONTH => 'target_month',
];

protected const RELATIONS = [
SeasonTicketContract::class,
];

protected function toArrayCustom(): array
{
return [


+ 36
- 0
app/Kintone/Models/SeasonTicketContract.php View File

@@ -17,6 +17,16 @@ use Illuminate\Support\Carbon;
* @property string registerNo
* @property ?Carbon contractStartDate
* @property ?Carbon contractEndDate
* @property ?int icSeasonTicektContractId
* @property ?string icSeasonTicektParkingManagementCode
* @property ?int icSeasonTicektSeasonTicketSeqNo
* @property ?string icSeasonTicektVehicleTypeName
* @property ?string icSeasonTicektParkingUseTypeName
* @property ?string icSeasonTicektContractorTypeName
* @property ?Carbon icSeasonTicektStartDate
* @property ?Carbon icSeasonTicektEndDate
* @property ?string icSeasonTicektPositionMemo
* @property ?string icSeasonTicektMemo
*/
class SeasonTicketContract extends KintoneModel
{
@@ -40,6 +50,17 @@ class SeasonTicketContract extends KintoneModel
const FIELD_STUDENT_LICENSE_EXPIRES_DATE = "学生証有効期限";
const FIELD_OTHER_LICENSE_EXPIRES_DATE = "障がい者手帳有効期限";

const FIELD_IC_SEASON_TICEKT_CONTRACT_ID = "IC定期関連情報_契約ID";
const FIELD_IC_SEASON_TICEKT_PARKING_MANAGEMENT_CODE = "IC定期関連情報_駐車場管理コード";
const FIELD_IC_SEASON_TICEKT_SEASON_TICKET_SEQ_NO = "IC定期関連情報_定期券番号";
const FIELD_IC_SEASON_TICEKT_VEHICLE_TYPE_NAME = "IC定期関連情報_車種";
const FIELD_IC_SEASON_TICEKT_PARKING_USE_TYPE_NAME = "IC定期関連情報_駐車場利用方法";
const FIELD_IC_SEASON_TICEKT_CONTRACTOR_TYPE_NAME = "IC定期関連情報_契約者種類";
const FIELD_IC_SEASON_TICEKT_START_DATE = "IC定期関連情報_有効期限開始";
const FIELD_IC_SEASON_TICEKT_END_DATE = "IC定期関連情報_有効期限終了";
const FIELD_IC_SEASON_TICEKT_POSITION_MEMO = "IC定期関連情報_駐車位置情報";
const FIELD_IC_SEASON_TICEKT_MEMO = "IC定期関連情報_備考";

protected const FIELDS = [
...parent::FIELDS,
self::FIELD_CUSTOMER_CODE => FieldType::NUMBER,
@@ -58,6 +79,16 @@ class SeasonTicketContract extends KintoneModel
self::FIELD_OTHER_LICENSE_IMAGES_UPLOAD_DATETIME => FieldType::DATETIME,
self::FIELD_STUDENT_LICENSE_EXPIRES_DATE => FieldType::DATE,
self::FIELD_OTHER_LICENSE_EXPIRES_DATE => FieldType::DATE,
self::FIELD_IC_SEASON_TICEKT_PARKING_MANAGEMENT_CODE => FieldType::SINGLE_LINE_TEXT,
self::FIELD_IC_SEASON_TICEKT_CONTRACT_ID => FieldType::NUMBER,
self::FIELD_IC_SEASON_TICEKT_SEASON_TICKET_SEQ_NO => FieldType::NUMBER,
self::FIELD_IC_SEASON_TICEKT_VEHICLE_TYPE_NAME => FieldType::SINGLE_LINE_TEXT,
self::FIELD_IC_SEASON_TICEKT_PARKING_USE_TYPE_NAME => FieldType::SINGLE_LINE_TEXT,
self::FIELD_IC_SEASON_TICEKT_CONTRACTOR_TYPE_NAME => FieldType::SINGLE_LINE_TEXT,
self::FIELD_IC_SEASON_TICEKT_START_DATE => FieldType::DATE,
self::FIELD_IC_SEASON_TICEKT_END_DATE => FieldType::DATE,
self::FIELD_IC_SEASON_TICEKT_POSITION_MEMO => FieldType::SINGLE_LINE_TEXT,
self::FIELD_IC_SEASON_TICEKT_MEMO => FieldType::MULTI_LINE_TEXT,
];

protected const FIELD_NAMES = [
@@ -85,6 +116,7 @@ class SeasonTicketContract extends KintoneModel
'can_parking_certificate_apply' => $this->canParkingCertificateApply(),
'can_change_plan_apply' => $this->canChangePlanApply(),
'is_terminated' => $this->isTerminated(),
'is_ic_season_ticket' => $this->isIcSeasonTicket(),
];
}

@@ -126,6 +158,10 @@ class SeasonTicketContract extends KintoneModel
{
return $this->contractEndDate instanceof Carbon ? $this->contractEndDate <= DateUtil::now() : false;
}
public function isIcSeasonTicket(): bool
{
return !!$this->icSeasonTicektContractId;
}

public function canParkingCertificateApply(): bool
{


+ 5
- 0
app/Logic/GeneralApplicationManager.php View File

@@ -9,6 +9,7 @@ use App\Kintone\Models\Customer;
use App\Kintone\Models\GeneralApplication;
use App\Kintone\Models\Parking;
use App\Kintone\Models\ParkingCertificateApplication;
use App\Kintone\Models\ParkingUseTypeChangeOrderApplication;
use App\Kintone\Models\SeasonTicketContract;
use App\Kintone\Models\SeasonTicketReOrderApplication;
use App\Kintone\Models\StickerReOrderApplication;
@@ -47,6 +48,10 @@ class GeneralApplicationManager
$this->setType("シール再発行申請");
return;
}
if ($model instanceof ParkingUseTypeChangeOrderApplication) {
$this->setType("IC定期_駐車場利用方法変更申請");
return;
}
if ($model instanceof SeasonTicketReOrderApplication) {
$this->setType("定期券再発行申請");
return;


+ 5
- 0
app/Providers/RouteServiceProvider.php View File

@@ -30,10 +30,15 @@ class RouteServiceProvider extends ServiceProvider
Route::middleware('web')
->prefix('api')
->group(base_path('routes/api.php'));

Route::middleware('api')
->prefix('api-from-kintone')
->group(base_path('routes/apiFromKintone.php'));

Route::middleware(['api', "fromHTICWeb"])
->prefix('api/ht-ic-web')
->group(base_path('routes/apiFromHTICWeb.php'));

Route::middleware('web')
->group(base_path('routes/web.php'));
});


+ 87
- 0
app/Transmissions/HTICWeb/Sender.php View File

@@ -0,0 +1,87 @@
<?php

namespace App\Transmissions\HTICWeb;

use App\Codes\EnvironmentName;
use App\Exceptions\AppCommonException;
use App\Exceptions\GeneralErrorMessageException;
use Illuminate\Support\Facades\Http;

trait Sender
{
protected function sendSeasonTicketContractCreate(array $contents)
{
return $this->sendToHTICWeb("seasonticketcontract/create", $contents);
}
protected function sendSeasonTicketContractUpdate(array $contents)
{
return $this->sendToHTICWeb("seasonticketcontract/update", $contents);
}
protected function sendSeasonTicketContractDelete(array $contents)
{
return $this->sendToHTICWeb("seasonticketcontract/delete", $contents);
}
protected function getSeasonTicketContractParams(array $contents)
{
return $this->sendToHTICWeb("seasonticketcontract/params", $contents);
}
protected function getSeasonTicketContractFetch(array $contents)
{
return $this->sendToHTICWeb("seasonticketcontract/fetch", $contents);
}
protected function sendUserCreate(array $contents)
{
return $this->sendToHTICWeb("user/create", $contents);
}
protected function sendUserUpdate(array $contents)
{
return $this->sendToHTICWeb("user/update", $contents);
}
protected function sendUserDelete(array $contents)
{
return $this->sendToHTICWeb("user/delete", $contents);
}

private function sendToHTICWeb(string $url, array $contents)
{
$fullUrl = sprintf("%s/api/kyoto-public/%s", config("custom.ht-ic-web.url", ""), $url);
$customerCode = app()->environment([EnvironmentName::PRODUCTOIN->value]) ? "1163" : "9990";
$sendContents = [
...$contents,
'customer_code' => $customerCode,
'ht-ic-web-api-key' => config("custom.ht-ic-web.apiKey", ""),

];
logger([
"senddata",
'url' => $fullUrl,
"contents" => $sendContents
]);
$res = Http::post($fullUrl, $sendContents);

if ($res->failed()) {
throw $res->toException();
}

if ($res->json('result') !== 0) {
logger($res->json());


$generalErrorMessage = $res->json('messages.general', "");
if (!!$generalErrorMessage) {
throw new GeneralErrorMessageException($generalErrorMessage);
}
$messages = $res->json('messages.errors', []);
logger(['messages' => $messages]);
if (0 < count($messages)) {
$key = array_key_first($messages);
$message = $messages[$key];
throw new GeneralErrorMessageException(sprintf("%s: %s", $key, $message));
}

throw new AppCommonException("HTICWeb連携失敗");
}

return $res;
}
}

+ 8
- 0
config/custom.php View File

@@ -0,0 +1,8 @@
<?php

return [
"ht-ic-web" => [
'apiKey' => env("HT_IC_WEB_API_KEY", ""),
'url' => env("HT_IC_WEB_URL", ""),
]
];

+ 2
- 0
routes/api.php View File

@@ -1,6 +1,7 @@
<?php

use App\Util\RouteHelper;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
@@ -28,6 +29,7 @@ RouteHelper::post('/season-ticket-contract/parking-certificate-order', App\Http\
RouteHelper::post('/season-ticket-contract/termination-order', App\Http\Controllers\Web\SeasonTicketContract\TerminationOrderController::class);
RouteHelper::get('/season-ticket-contract/termination-order/options', App\Http\Controllers\Web\SeasonTicketContract\TerminationOrderOptionsController::class);
RouteHelper::post('/season-ticket-contract/update-vehicle-info-order', App\Http\Controllers\Web\SeasonTicketContract\UpdateVehicleInfoOrderController::class);
RouteHelper::post('/season-ticket-contract/parking-use-type-change-order', App\Http\Controllers\Web\SeasonTicketContract\ParkingUseTypeChangeOrderController::class);
RouteHelper::post('/upload/student-license-images', App\Http\Controllers\Web\SeasonTicketContract\UploadStudentLicenseImagesController::class);
RouteHelper::post('/upload/other-license-images', App\Http\Controllers\Web\SeasonTicketContract\UploadOtherLicenseImagesController::class);



+ 19
- 0
routes/apiFromHTICWeb.php View File

@@ -0,0 +1,19 @@
<?php

use App\Util\RouteHelper;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "api" middleware group. Make something great!
|
*/

// IC定期連携用ルート定義
RouteHelper::post('/season-ticket-contract', App\Http\Controllers\Web\HTICWeb\SeasonTicketContractController::class);
RouteHelper::post('/user', App\Http\Controllers\Web\HTICWeb\UserController::class);
RouteHelper::post('/adjust-data', App\Http\Controllers\Web\HTICWeb\AdjustDataController::class);

+ 8
- 0
routes/apiFromKintone.php View File

@@ -19,6 +19,14 @@ RouteHelper::post('/season-ticket-contract-selection/fill-candidates', App\Http\
RouteHelper::post('/receipt/create', App\Http\Controllers\Web\Receipt\ReceiptCreateController::class);
RouteHelper::post('/receipt/save', App\Http\Controllers\Web\Receipt\ReceiptSaveController::class);

RouteHelper::post('/season-ticket-contract/ht-ic-web/before/create', App\Http\Controllers\Web\SeasonTicketContract\BeforeCreateController::class);
RouteHelper::post('/season-ticket-contract/ht-ic-web/before/update', App\Http\Controllers\Web\SeasonTicketContract\BeforeUpdateController::class);
RouteHelper::post('/season-ticket-contract/ht-ic-web/before/delete', App\Http\Controllers\Web\SeasonTicketContract\BeforeDeleteController::class);
RouteHelper::post('/season-ticket-contract/ht-ic-web/before/fetch', App\Http\Controllers\Web\SeasonTicketContract\FetchController::class);
RouteHelper::post('/user/ht-ic-web/before/create', App\Http\Controllers\Web\HTICWeb\UserRegisterController::class);
RouteHelper::post('/user/ht-ic-web/before/update', App\Http\Controllers\Web\Customer\BeforeUpdateController::class);
RouteHelper::post('/user/ht-ic-web/before/delete', App\Http\Controllers\Web\Customer\BeforeDeleteController::class);


// ------FOR WEBHOOK-------------------
RouteHelper::get('/webhook/season-ticket-contract-selection', App\Http\Controllers\Web\KintoneWebHook\SeasonTicketContractSelectionController::class);

+ 6
- 0
routes/web.php View File

@@ -1,6 +1,7 @@
<?php

use App\Util\RouteHelper;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
@@ -18,6 +19,11 @@ RouteHelper::get('/pdf', App\Http\Controllers\PDFController::class);

// 画像取得
RouteHelper::get('/image/season-ticket-contract/{id}', App\Http\Controllers\Web\Image\SeasonTicketContractImageController::class);
RouteHelper::get('/test/bank', App\Http\Controllers\Web\Image\SeasonTicketContractImageController::class);

Route::get("/test/bank", function () {
return view('bank-test');
});

// ルーティングで適合しない場合はフロント側のRoutingにゆだねる
RouteHelper::get('/{any?}', App\Http\Controllers\Web\IndexController::class)->where('any', '.*');

Loading…
Cancel
Save