| @@ -7,11 +7,13 @@ use App\Http\Controllers\Web\IParam; | |||
| use App\Http\Controllers\Web\WebController; | |||
| use App\Logic\ReceiptIssuingOrder\Custom\HelloTechno\CreateManager; | |||
| use App\Models\ReceiptIssuingOrder as Order; | |||
| use App\Models\ReceiptIssuingHTParkingCustomOrder as HT; | |||
| use App\Util\Custom\HelloTechno\API; | |||
| use Illuminate\Http\JsonResponse; | |||
| use Illuminate\Http\Request; | |||
| use Illuminate\Support\Facades\Auth; | |||
| class CreateReceiptIssuingOrderController extends WebController | |||
| class CreateReceiptIssuingOrderController extends HelloTechnoController | |||
| { | |||
| public function name(): string | |||
| { | |||
| @@ -27,7 +29,7 @@ class CreateReceiptIssuingOrderController extends WebController | |||
| protected CreateReceiptIssuingOrderParam $param, | |||
| private CreateManager $manager | |||
| ) { | |||
| $this->middleware('auth:sanctum'); | |||
| parent::__construct(); | |||
| $this->roleAllow(UserRole::NORMAL_ADMIN); | |||
| } | |||
| @@ -40,11 +42,21 @@ class CreateReceiptIssuingOrderController extends WebController | |||
| { | |||
| $param = $this->param; | |||
| // TODO 顧客情報取得 | |||
| // TODO 駐車場情報取得 | |||
| // 顧客情報取得 | |||
| // $customer = collect(API::getCustomers($param->customerCode)) | |||
| // ->where('customer_code', $param->customerCode) | |||
| // ->firstOrFail(); | |||
| // 駐車場情報取得 | |||
| // $parking = collect(API::getParkings($param->customerCode, $param->parkingManagementCode)) | |||
| // ->where('parking_management_code', $param->parkingManagementCode) | |||
| // ->firstOrFail(); | |||
| $orderData = [ | |||
| ...$param->toArray(), | |||
| // HT::COL_NAME_CUSTOMER_NAME => $customer['name'], | |||
| // HT::COL_NAME_PARKING_NAME => $parking['name'], | |||
| HT::COL_NAME_CUSTOMER_NAME => "TODOテスト運営会社", | |||
| HT::COL_NAME_PARKING_NAME => "TODOテスト駐車場", | |||
| Order::COL_NAME_HANDLER_ID => Auth::id(), | |||
| Order::COL_NAME_SUMMARY_KEY1 => $param->customerCode, | |||
| Order::COL_NAME_SUMMARY_KEY2 => $param->parkingManagementCode, | |||
| @@ -2,15 +2,13 @@ | |||
| namespace App\Http\Controllers\Web\Custom\HelloTechno; | |||
| use App\Codes\Custom; | |||
| use App\Codes\UserRole; | |||
| use App\Http\Controllers\Web\IParam; | |||
| use App\Http\Controllers\Web\WebController; | |||
| use App\Util\Custom\HelloTechno\API; | |||
| use Illuminate\Http\JsonResponse; | |||
| use Illuminate\Http\Request; | |||
| class CustomersController extends WebController | |||
| class CustomersController extends HelloTechnoController | |||
| { | |||
| public function name(): string | |||
| { | |||
| @@ -25,9 +23,8 @@ class CustomersController extends WebController | |||
| public function __construct( | |||
| protected CustomersParam $param, | |||
| ) { | |||
| $this->middleware('auth:sanctum'); | |||
| parent::__construct(); | |||
| $this->roleAllow(UserRole::NORMAL_ADMIN); | |||
| $this->customAllow = [Custom::HELLO_TECHNO]; | |||
| } | |||
| protected function getParam(): IParam | |||
| @@ -0,0 +1,17 @@ | |||
| <?php | |||
| namespace App\Http\Controllers\Web\Custom\HelloTechno; | |||
| use App\Codes\Custom; | |||
| use App\Http\Controllers\Web\WebController; | |||
| abstract class HelloTechnoController extends WebController | |||
| { | |||
| public function __construct() | |||
| { | |||
| parent::__construct(); | |||
| $this->middleware('auth:sanctum'); | |||
| $this->customAllow = [Custom::HELLO_TECHNO]; | |||
| } | |||
| } | |||
| @@ -2,18 +2,13 @@ | |||
| namespace App\Http\Controllers\Web\Custom\HelloTechno; | |||
| use App\Codes\Custom; | |||
| use App\Codes\UserRole; | |||
| use App\Http\Controllers\Web\IParam; | |||
| use App\Http\Controllers\Web\WebController; | |||
| use App\Logic\ReceiptIssuingOrder\CreateManager; | |||
| use App\Util\Custom\HelloTechno\API; | |||
| use Illuminate\Http\JsonResponse; | |||
| use Illuminate\Http\Request; | |||
| use Illuminate\Support\Facades\Http; | |||
| use Illuminate\Support\Facades\Log; | |||
| class ParkingsController extends WebController | |||
| class ParkingsController extends HelloTechnoController | |||
| { | |||
| public function name(): string | |||
| { | |||
| @@ -28,9 +23,8 @@ class ParkingsController extends WebController | |||
| public function __construct( | |||
| protected ParkingsParam $param, | |||
| ) { | |||
| $this->middleware('auth:sanctum'); | |||
| parent::__construct(); | |||
| $this->roleAllow(UserRole::NORMAL_ADMIN); | |||
| $this->customAllow = [Custom::HELLO_TECHNO]; | |||
| } | |||
| protected function getParam(): IParam | |||
| @@ -0,0 +1,49 @@ | |||
| <?php | |||
| namespace App\Http\Controllers\Web\Custom\HelloTechno; | |||
| use App\Codes\UserRole; | |||
| use App\Http\Controllers\Web\IParam; | |||
| use App\Models\ReceiptIssuingOrder as Order; | |||
| use App\Repositories\Custom\HelloTechno\ReceiptIssuingOrderRepository; | |||
| use Illuminate\Http\JsonResponse; | |||
| use Illuminate\Http\Request; | |||
| use Illuminate\Support\Facades\Auth; | |||
| class ReceiptIssuingOrdersController extends HelloTechnoController | |||
| { | |||
| public function name(): string | |||
| { | |||
| return "[HelloTechno専用]領収証発行依頼作成"; | |||
| } | |||
| public function description(): string | |||
| { | |||
| return "[HelloTechno専用]領収証発行依頼を作成する"; | |||
| } | |||
| public function __construct( | |||
| protected ReceiptIssuingsOrdersParam $param, | |||
| private ReceiptIssuingOrderRepository $repository | |||
| ) { | |||
| parent::__construct(); | |||
| $this->roleAllow(UserRole::NORMAL_ADMIN); | |||
| } | |||
| protected function getParam(): IParam | |||
| { | |||
| return $this->param; | |||
| } | |||
| protected function run(Request $request): JsonResponse | |||
| { | |||
| $param = $this->param; | |||
| $list = $this->repository->get($param->toArray()); | |||
| return $this->successResponse([ | |||
| 'records' => $list | |||
| ]); | |||
| } | |||
| } | |||
| @@ -0,0 +1,32 @@ | |||
| <?php | |||
| namespace App\Http\Controllers\Web\Custom\HelloTechno; | |||
| use App\Http\Controllers\Web\BaseParam; | |||
| use App\Models\ReceiptIssuingHTParkingCustomOrder as HT; | |||
| /** | |||
| * @property ?string $customerCode | |||
| * @property ?string $customerName | |||
| * @property ?string $parkingManagementCode | |||
| * @property ?string $parkingName | |||
| * @property ?int $adjustSeqNo | |||
| */ | |||
| class ReceiptIssuingsOrdersParam extends BaseParam | |||
| { | |||
| public function rules(): array | |||
| { | |||
| return | |||
| array_merge( | |||
| [ | |||
| HT::COL_NAME_CUSTOMER_CODE => $this->str(true), | |||
| HT::COL_NAME_CUSTOMER_NAME => $this->str(true), | |||
| HT::COL_NAME_PARKING_MANAGEMENT_CODE => $this->str(true), | |||
| HT::COL_NAME_PARKING_NAME => $this->str(true), | |||
| HT::COL_NAME_ADJUST_SEQ_NO => $this->numeric(true), | |||
| ], | |||
| $this->sortableRules(), | |||
| ); | |||
| } | |||
| } | |||
| @@ -0,0 +1,41 @@ | |||
| <?php | |||
| namespace App\Http\Controllers\Web\ReceiptIssuingOrder; | |||
| use App\Http\Controllers\Web\IParam; | |||
| use App\Http\Controllers\Web\WebController; | |||
| use App\Logic\ReceiptIssuingOrder\PDFDownLoadManager; | |||
| use Illuminate\Http\Request; | |||
| use Illuminate\Http\Response; | |||
| class DownloadController extends WebController | |||
| { | |||
| public function name(): string | |||
| { | |||
| return "領収証PDFダウンロード"; | |||
| } | |||
| public function description(): string | |||
| { | |||
| return "領収証PDFダウンロードする"; | |||
| } | |||
| public function __construct( | |||
| protected DownloadParam $param, | |||
| private PDFDownLoadManager $manager | |||
| ) { | |||
| parent::__construct(); | |||
| } | |||
| protected function getParam(): IParam | |||
| { | |||
| return $this->param; | |||
| } | |||
| protected function run(Request $request): Response | |||
| { | |||
| $param = $this->param; | |||
| return $this->manager->initByToken($param->accessToken)->service(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,21 @@ | |||
| <?php | |||
| namespace App\Http\Controllers\Web\ReceiptIssuingOrder; | |||
| use App\Http\Controllers\Web\BaseParam; | |||
| use App\Models\ReceiptIssuingOrder; | |||
| /** | |||
| * @property string $accessToken | |||
| */ | |||
| class DownloadParam extends BaseParam | |||
| { | |||
| public function rules(): array | |||
| { | |||
| return [ | |||
| ReceiptIssuingOrder::COL_NAME_ACCESS_TOKEN => $this->str(), | |||
| ]; | |||
| } | |||
| } | |||
| @@ -0,0 +1,45 @@ | |||
| <?php | |||
| namespace App\Http\Controllers\Web\ReceiptIssuingOrder; | |||
| use App\Codes\UserRole; | |||
| use App\Http\Controllers\Web\IParam; | |||
| use App\Http\Controllers\Web\WebController; | |||
| use App\Logic\ReceiptIssuingOrder\TokenCheckManager; | |||
| use Illuminate\Http\JsonResponse; | |||
| use Illuminate\Http\Request; | |||
| class TokenCheckController extends WebController | |||
| { | |||
| public function name(): string | |||
| { | |||
| return "トークンチェック"; | |||
| } | |||
| public function description(): string | |||
| { | |||
| return "トークンの有効性をチェックする"; | |||
| } | |||
| public function __construct( | |||
| protected TokenCheckParam $param, | |||
| private TokenCheckManager $manager | |||
| ) { | |||
| parent::__construct(); | |||
| } | |||
| protected function getParam(): IParam | |||
| { | |||
| return $this->param; | |||
| } | |||
| protected function run(Request $request): JsonResponse | |||
| { | |||
| $param = $this->param; | |||
| if (!$this->manager->check($param->accessToken)) { | |||
| return $this->failedResponse(); | |||
| } | |||
| return $this->successResponse(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,21 @@ | |||
| <?php | |||
| namespace App\Http\Controllers\Web\ReceiptIssuingOrder; | |||
| use App\Http\Controllers\Web\BaseParam; | |||
| use App\Models\ReceiptIssuingOrder; | |||
| /** | |||
| * @property string $accessToken | |||
| */ | |||
| class TokenCheckParam extends BaseParam | |||
| { | |||
| public function rules(): array | |||
| { | |||
| return [ | |||
| ReceiptIssuingOrder::COL_NAME_ACCESS_TOKEN => $this->str(), | |||
| ]; | |||
| } | |||
| } | |||
| @@ -80,6 +80,10 @@ abstract class WebController extends BaseController | |||
| */ | |||
| private ResultCode|null $resultCode = ResultCode::SECCESS; | |||
| public function __construct() | |||
| { | |||
| } | |||
| /** | |||
| * パラメータオブジェクト | |||
| @@ -335,11 +339,7 @@ abstract class WebController extends BaseController | |||
| $myCustoms = Auth::user()->contract->custom(); | |||
| foreach ($this->customAllow as $targetCustom) { | |||
| logger(['myCustoms' => $myCustoms, 'target' => $targetCustom]); | |||
| if (in_array($targetCustom, $myCustoms, true)) { | |||
| return true; | |||
| } | |||
| @@ -6,6 +6,7 @@ use App\Codes\ReceiptIssuingOrderStatus; | |||
| use App\Codes\SMSSendPurpose; | |||
| use App\Logic\SMS\SMSManager; | |||
| use App\Models\ReceiptIssuingOrder; | |||
| use App\Util\DateUtil; | |||
| use Illuminate\Support\Facades\View; | |||
| use LogicException; | |||
| @@ -16,6 +17,7 @@ class CreateManager extends ReceiptIssuingOrderManager | |||
| protected ReceiptIssuingOrder $order, | |||
| protected SMSManager $smsManager | |||
| ) { | |||
| parent::__construct($order); | |||
| } | |||
| public function init() | |||
| @@ -50,6 +52,7 @@ class CreateManager extends ReceiptIssuingOrderManager | |||
| // モデル更新 | |||
| $order->status = ReceiptIssuingOrderStatus::CREATED; | |||
| $order->order_datetime = DateUtil::now(); | |||
| $this->refreshToken(); | |||
| $contractId = $this->loginUser()->getContractId(); | |||
| @@ -4,17 +4,16 @@ namespace App\Logic\ReceiptIssuingOrder; | |||
| use App\Codes\ReceiptIssuingOrderStatus; | |||
| use App\Exceptions\AppCommonException; | |||
| use App\Logic\SMS\SMSManager; | |||
| use App\Models\ReceiptIssuingOrder; | |||
| use PDF; | |||
| class UpdateManager extends ReceiptIssuingOrderManager | |||
| class PDFDownLoadManager extends ReceiptIssuingOrderManager | |||
| { | |||
| public function __construct( | |||
| protected ReceiptIssuingOrder $order, | |||
| protected SMSManager $smsManager | |||
| ) { | |||
| parent::__construct($order); | |||
| } | |||
| public function initByToken(string $token) | |||
| @@ -36,7 +35,7 @@ class UpdateManager extends ReceiptIssuingOrderManager | |||
| return $this; | |||
| } | |||
| protected function service() | |||
| public function service() | |||
| { | |||
| $order = $this->order; | |||
| @@ -48,6 +47,7 @@ class UpdateManager extends ReceiptIssuingOrderManager | |||
| ->inline(); | |||
| $order->status = ReceiptIssuingOrderStatus::DOWNLOAD_DONE; | |||
| $order->save(); | |||
| return $ret; | |||
| } | |||
| @@ -15,8 +15,9 @@ abstract class ReceiptIssuingOrderManager | |||
| protected bool $initialized = false; | |||
| protected function __construct(protected ReceiptIssuingOrder $order) | |||
| { | |||
| public function __construct( | |||
| protected ReceiptIssuingOrder $order, | |||
| ) { | |||
| } | |||
| protected function fetch(string $receiptIssuingOrderId) | |||
| @@ -39,10 +40,6 @@ abstract class ReceiptIssuingOrderManager | |||
| protected function checkToken(string $token): bool | |||
| { | |||
| if ($this->order->isNotSavedModel()) { | |||
| throw new LogicException("初期化不良"); | |||
| } | |||
| $order = ReceiptIssuingOrder::whereAccessToken($token) | |||
| ->first(); | |||
| @@ -0,0 +1,20 @@ | |||
| <?php | |||
| namespace App\Logic\ReceiptIssuingOrder; | |||
| use App\Models\ReceiptIssuingOrder; | |||
| class TokenCheckManager extends ReceiptIssuingOrderManager | |||
| { | |||
| public function __construct( | |||
| protected ReceiptIssuingOrder $order, | |||
| ) { | |||
| parent::__construct($order); | |||
| } | |||
| public function check(string $token): bool | |||
| { | |||
| return $this->checkToken($token); | |||
| } | |||
| } | |||
| @@ -13,6 +13,7 @@ class UpdateManager extends ReceiptIssuingOrderManager | |||
| protected ReceiptIssuingOrder $order, | |||
| protected SMSManager $smsManager | |||
| ) { | |||
| parent::__construct($order); | |||
| } | |||
| public function initByToken(string $token) | |||
| @@ -11,6 +11,9 @@ class ReceiptIssuingHTParkingCustomOrder extends AppModel | |||
| const COL_NAME_CUSTOMER_CODE = "customer_code"; | |||
| const COL_NAME_PARKING_MANAGEMENT_CODE = "parking_management_code"; | |||
| const COL_NAME_ADJUST_SEQ_NO = "adjust_seq_no"; | |||
| const COL_NAME_CUSTOMER_NAME = "customer_name"; | |||
| const COL_NAME_PARKING_NAME = "parking_name"; | |||
| public function getModelName(): string | |||
| { | |||
| @@ -13,6 +13,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; | |||
| use Illuminate\Database\Query\Builder; | |||
| use Illuminate\Foundation\Auth\User as Authenticatable; | |||
| use Illuminate\Notifications\Notifiable; | |||
| use Illuminate\Support\Facades\DB; | |||
| use Laravel\Sanctum\HasApiTokens; | |||
| class User extends Authenticatable implements IModelFeature | |||
| @@ -22,6 +23,7 @@ class User extends Authenticatable implements IModelFeature | |||
| const COL_NAME_ID = 'id'; | |||
| const COL_NAME_ROLE = 'role'; | |||
| const COL_NAME_EMAIL = 'email'; | |||
| const COL_NAME_NAME = 'name'; | |||
| /** | |||
| * The attributes that should be hidden for serialization. | |||
| @@ -17,7 +17,7 @@ abstract class BaseRepository | |||
| const MAX_LIMIT = 500; | |||
| protected static function sort(Builder $query, array $condition) | |||
| protected function sort(Builder $query, array $condition) | |||
| { | |||
| $target = data_get($condition, self::CONDITION_SORT_TARGET); | |||
| $order = data_get($condition, self::CONDITION_SORT_ORDER); | |||
| @@ -25,24 +25,26 @@ abstract class BaseRepository | |||
| return; | |||
| } | |||
| if ($order === self::ORDER_ASC) { | |||
| if ($order === static::ORDER_ASC) { | |||
| $query->orderBy($target); | |||
| } | |||
| if ($order === self::ORDER_DESC) { | |||
| if ($order === static::ORDER_DESC) { | |||
| $query->orderByDesc($target); | |||
| } | |||
| } | |||
| protected static function limit(Builder $query, array $condition, int $default = self::MAX_LIMIT) | |||
| protected function limit(Builder $query, array $condition, ?int $default = null) | |||
| { | |||
| $limit = data_get($condition, self::CONDITION_LIMIT, $default) ?? $default; | |||
| $limit = data_get($condition, self::CONDITION_LIMIT, $default) ?? $default ?? static::MAX_LIMIT; | |||
| $limit = min($limit, self::MAX_LIMIT); | |||
| $query->limit($limit); | |||
| } | |||
| protected static function where(Builder $query, array $condition, string $conditionKey, string|null $columnName = null): bool | |||
| protected function where(Builder $query, array $condition, string $conditionKey, string|null $columnName = null): bool | |||
| { | |||
| $ret = data_get($condition, $conditionKey); | |||
| @@ -53,7 +55,7 @@ abstract class BaseRepository | |||
| return false; | |||
| } | |||
| } | |||
| protected static function whereIn(Builder $query, array $condition, string $conditionKey, string|null $columnName = null): bool | |||
| protected function whereIn(Builder $query, array $condition, string $conditionKey, string|null $columnName = null): bool | |||
| { | |||
| $ret = data_get($condition, $conditionKey); | |||
| @@ -64,4 +66,10 @@ abstract class BaseRepository | |||
| return false; | |||
| } | |||
| } | |||
| protected function makeColumnName(array $targets, ?string $as = null): string | |||
| { | |||
| $as = $as ? " as {$as}" : ""; | |||
| return implode('.', $targets) . $as; | |||
| } | |||
| } | |||
| @@ -0,0 +1,113 @@ | |||
| <?php | |||
| namespace App\Repositories\Custom\HelloTechno; | |||
| use App\Models\ReceiptIssuingHTParkingCustomOrder as CustomOrder; | |||
| use App\Models\ReceiptIssuingOrder; | |||
| use App\Models\User; | |||
| use App\Repositories\BaseRepository; | |||
| use Illuminate\Database\Query\JoinClause; | |||
| use Illuminate\Support\Collection; | |||
| use Illuminate\Support\Facades\DB; | |||
| class ReceiptIssuingOrderRepository extends BaseRepository | |||
| { | |||
| const CONDITION_ID = 'id'; | |||
| const CONDITION_STATUS = 'status'; | |||
| const CONDITION_CUSTOMER_CODE = 'customer_code'; | |||
| const CONDITION_PARKING_MANAGEMENT_CODE = 'parking_management_code'; | |||
| const CONDITION_CUSTOMER_NAME = 'customer_name'; | |||
| const CONDITION_PARKING_MANAGEMENT_NAME = 'parking_name'; | |||
| const TABLE_ORDER = "order"; | |||
| const TABLE_CUSTOM_ORDER = "custom_order"; | |||
| const TABLE_HANDLER = "handler"; | |||
| /** | |||
| * コレクションを取得する | |||
| * | |||
| * @param array $condition | |||
| * @return Collection<ParkingRepositoryData> | |||
| */ | |||
| public function get(array $condition): Collection | |||
| { | |||
| $order = ReceiptIssuingOrder::getBuilder(static::TABLE_ORDER); | |||
| $table = $order | |||
| ->joinSub(CustomOrder::getBuilder(), static::TABLE_CUSTOM_ORDER, function (JoinClause $join) { | |||
| $join->on( | |||
| $this->makeColumnName([static::TABLE_ORDER, ReceiptIssuingOrder::COL_NAME_ID]), | |||
| $this->makeColumnName([static::TABLE_CUSTOM_ORDER, CustomOrder::COL_NAME_RECEIPT_ISSUING_ORDER_ID]) | |||
| ); | |||
| }) | |||
| ->leftJoinSub(User::getBuilder(), static::TABLE_HANDLER, function (JoinClause $join) { | |||
| $join->on( | |||
| $this->makeColumnName([static::TABLE_ORDER, ReceiptIssuingOrder::COL_NAME_HANDLER_ID]), | |||
| $this->makeColumnName([static::TABLE_HANDLER, CustomOrder::COL_NAME_ID]) | |||
| ); | |||
| }); | |||
| // -----検索条件 | |||
| // 運営会社 | |||
| $this->where($table, $condition, $this->makeColumnName([static::TABLE_CUSTOM_ORDER, CustomOrder::COL_NAME_CUSTOMER_CODE])); | |||
| $customerName = data_get($condition, static::CONDITION_CUSTOMER_NAME); | |||
| if ($customerName) { | |||
| $table->where($this->makeColumnName([static::TABLE_CUSTOM_ORDER, CustomOrder::COL_NAME_CUSTOMER_NAME]), 'like', "%{$customerName}%"); | |||
| } | |||
| // 駐車場 | |||
| $this->where($table, $condition, $this->makeColumnName([static::TABLE_CUSTOM_ORDER, CustomOrder::COL_NAME_PARKING_MANAGEMENT_CODE])); | |||
| $parkihngName = data_get($condition, static::CONDITION_PARKING_MANAGEMENT_NAME); | |||
| if ($parkihngName) { | |||
| $table->where($this->makeColumnName([static::TABLE_CUSTOM_ORDER, CustomOrder::COL_NAME_PARKING_NAME]), 'like', "%{$parkihngName}%"); | |||
| } | |||
| // ステータス | |||
| $this->where($table, $condition, $this->makeColumnName([static::TABLE_ORDER, ReceiptIssuingOrder::COL_NAME_STATUS])); | |||
| $table->select($this->columns()); | |||
| $main = DB::table($table, "main"); | |||
| // ソート | |||
| $this->sort($main, $condition); | |||
| $main->orderBy(static::CONDITION_ID); | |||
| // リミット | |||
| $this->limit($main, $condition); | |||
| return ReceiptIssuingOrderRepositoryData::makeList($main->get()); | |||
| } | |||
| private function columns() | |||
| { | |||
| $order = static::TABLE_ORDER; | |||
| $custom = static::TABLE_CUSTOM_ORDER; | |||
| $handler = static::TABLE_HANDLER; | |||
| $columns = [ | |||
| $this->makeColumnName([$order, ReceiptIssuingOrder::COL_NAME_ID], 'id'), | |||
| $this->makeColumnName([$order, ReceiptIssuingOrder::COL_NAME_STATUS], 'status'), | |||
| $this->makeColumnName([$order, ReceiptIssuingOrder::COL_NAME_ORDER_DATETIME], 'order_datetime'), | |||
| $this->makeColumnName([$custom, CustomOrder::COL_NAME_CUSTOMER_CODE], 'customer_code'), | |||
| $this->makeColumnName([$custom, CustomOrder::COL_NAME_PARKING_MANAGEMENT_CODE], 'parking_management_code'), | |||
| $this->makeColumnName([$custom, CustomOrder::COL_NAME_CUSTOMER_NAME], 'customer_name'), | |||
| $this->makeColumnName([$custom, CustomOrder::COL_NAME_PARKING_NAME], 'parking_name'), | |||
| $this->makeColumnName([$handler, User::COL_NAME_ID], 'handler_id'), | |||
| $this->makeColumnName([$handler, User::COL_NAME_NAME], 'handler_name'), | |||
| ]; | |||
| return $columns; | |||
| } | |||
| } | |||
| @@ -0,0 +1,11 @@ | |||
| <?php | |||
| namespace App\Repositories\Custom\HelloTechno; | |||
| use App\Repositories\BaseRepositoryData; | |||
| /** | |||
| */ | |||
| class ReceiptIssuingOrderRepositoryData extends BaseRepositoryData | |||
| { | |||
| } | |||
| @@ -3,6 +3,7 @@ | |||
| namespace App\Util\Custom\HelloTechno; | |||
| use App\Exceptions\AppCommonException; | |||
| use Exception; | |||
| use Illuminate\Http\Client\Response; | |||
| use Illuminate\Support\Facades\Http; | |||
| use Illuminate\Support\Facades\Log; | |||
| @@ -23,20 +24,30 @@ class API | |||
| public static function getCustomers(?string $customerCde = null) | |||
| { | |||
| $res = Http::get(static::getCustomersUrl($customerCde)); | |||
| return static::handleResponse($res); | |||
| $query = []; | |||
| if ($customerCde) { | |||
| $query['customer_code'] = $customerCde; | |||
| } | |||
| return static::get(static::getCustomersUrl(), $query); | |||
| } | |||
| public static function getParkings(string $customerCode, ?string $parkingManagementCode = null) | |||
| { | |||
| $res = Http::get(static::getParkingsUrl($customerCode, $parkingManagementCode)); | |||
| return static::handleResponse($res); | |||
| $query['customer_code'] = $customerCode; | |||
| if ($parkingManagementCode) { | |||
| $query['parking_management_code'] = $parkingManagementCode; | |||
| } | |||
| return static::get(static::getParkingsUrl(), $query); | |||
| } | |||
| public static function getAdjustData(string $customerCode, string $parkingManagementCode, int $adjustSeqNo) | |||
| { | |||
| $res = Http::get(static::getAdjustDataUrl($customerCode, $parkingManagementCode, $adjustSeqNo)); | |||
| return static::handleResponse($res); | |||
| $query['customer_code'] = $customerCode; | |||
| $query['parking_management_code'] = $parkingManagementCode; | |||
| $query['adjust_seq_no'] = $adjustSeqNo; | |||
| return static::get(static::getAdjustDataUrl(), $query); | |||
| } | |||
| private static function getHost(): string | |||
| @@ -44,43 +55,43 @@ class API | |||
| return config(static::CONFIG_KEY_API_HOST, "http://localhost"); | |||
| } | |||
| private static function getCustomersUrl(?string $customerCode) | |||
| private static function getCustomersUrl() | |||
| { | |||
| $condition = [static::getHost(), static::URL_CUSTOMERS]; | |||
| if ($customerCode) { | |||
| $condition[] = $customerCode; | |||
| } | |||
| return implode('/', $condition); | |||
| } | |||
| private static function getParkingsUrl(string $customerCode, ?string $parkingManagementCode) | |||
| private static function getParkingsUrl() | |||
| { | |||
| $condition = [static::getHost(), static::URL_PARKINGS, $customerCode]; | |||
| if ($parkingManagementCode) { | |||
| $condition[] = $parkingManagementCode; | |||
| } | |||
| // $condition = [static::getHost(), static::URL_PARKINGS]; | |||
| $condition = [static::getHost(), static::URL_PARKINGS, "9990"]; | |||
| return implode('/', $condition); | |||
| } | |||
| private static function getAdjustDataUrl(string $customerCode, string $parkingManagementCode, int $adjustSeqNo) | |||
| private static function getAdjustDataUrl() | |||
| { | |||
| $condition = [static::getHost(), static::URL_ADJUST_DATA, $customerCode, $parkingManagementCode, $adjustSeqNo]; | |||
| $condition = [static::getHost(), static::URL_ADJUST_DATA]; | |||
| return implode('/', $condition); | |||
| } | |||
| private static function handleResponse(Response $res): array | |||
| private static function get(string $url, array $query = []) | |||
| { | |||
| if ($res->failed()) { | |||
| throw $res->throw(); | |||
| try { | |||
| $res = Http::get($url, $query); | |||
| if ($res->failed()) { | |||
| throw $res->throw(); | |||
| } | |||
| $data = $res->json(); | |||
| if (data_get($data, static::RESULT_CODE) !== static::RESULT_CODE_SUCCESS) { | |||
| Log::error("HT RESPONSE ERROR"); | |||
| Log::error($data); | |||
| throw new AppCommonException('HT API 失敗'); | |||
| } | |||
| return data_get($data, static::FIELD_DATA, []); | |||
| } catch (Exception $e) { | |||
| Log::error("HelloTechno API エラー URL:${url}]"); | |||
| throw $e; | |||
| } | |||
| $data = $res->json(); | |||
| if (data_get($data, static::RESULT_CODE) !== static::RESULT_CODE_SUCCESS) { | |||
| Log::error("HT RESPONSE ERROR"); | |||
| Log::error($data); | |||
| throw new AppCommonException('HT API 失敗'); | |||
| } | |||
| return data_get($data, static::FIELD_DATA, []); | |||
| } | |||
| } | |||
| @@ -127,10 +127,13 @@ class MigrationHelper | |||
| return $this; | |||
| } | |||
| public function userId(bool $nullable = false) | |||
| public function userId(bool $nullable = false, ?string $columnName = null, ?string $comment = null) | |||
| { | |||
| $this->table->uuid(ColumnName::USER_ID)->comment("ユーザーID")->nullable($nullable); | |||
| $this->table->foreign(ColumnName::USER_ID)->references(ColumnName::ID)->on(User::getTableName()); | |||
| $columnName = $columnName ?? ColumnName::USER_ID; | |||
| $comment = $comment ?? "ユーザーID"; | |||
| $this->table->uuid($columnName)->comment($comment)->nullable($nullable); | |||
| $this->table->foreign($columnName)->references(ColumnName::ID)->on(User::getTableName()); | |||
| return $this; | |||
| } | |||
| @@ -16,6 +16,7 @@ | |||
| "require-dev": { | |||
| "barryvdh/laravel-ide-helper": "^2.13", | |||
| "fakerphp/faker": "^1.9.1", | |||
| "itsgoingd/clockwork": "^5.1", | |||
| "laravel/pint": "^1.0", | |||
| "laravel/sail": "^1.18", | |||
| "mockery/mockery": "^1.4.4", | |||
| @@ -4,7 +4,7 @@ | |||
| "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", | |||
| "This file is @generated automatically" | |||
| ], | |||
| "content-hash": "830b2086d431430c84cff2228ec2809a", | |||
| "content-hash": "edf71dac141191fd318aa91cb311db2a", | |||
| "packages": [ | |||
| { | |||
| "name": "barryvdh/laravel-snappy", | |||
| @@ -6425,6 +6425,74 @@ | |||
| }, | |||
| "time": "2020-07-09T08:09:16+00:00" | |||
| }, | |||
| { | |||
| "name": "itsgoingd/clockwork", | |||
| "version": "v5.1.12", | |||
| "source": { | |||
| "type": "git", | |||
| "url": "https://github.com/itsgoingd/clockwork.git", | |||
| "reference": "c9dbdbb1f0efd19bb80f1080ef63f1b9b1bc3b1b" | |||
| }, | |||
| "dist": { | |||
| "type": "zip", | |||
| "url": "https://api.github.com/repos/itsgoingd/clockwork/zipball/c9dbdbb1f0efd19bb80f1080ef63f1b9b1bc3b1b", | |||
| "reference": "c9dbdbb1f0efd19bb80f1080ef63f1b9b1bc3b1b", | |||
| "shasum": "" | |||
| }, | |||
| "require": { | |||
| "ext-json": "*", | |||
| "php": ">=5.6" | |||
| }, | |||
| "type": "library", | |||
| "extra": { | |||
| "laravel": { | |||
| "providers": [ | |||
| "Clockwork\\Support\\Laravel\\ClockworkServiceProvider" | |||
| ], | |||
| "aliases": { | |||
| "Clockwork": "Clockwork\\Support\\Laravel\\Facade" | |||
| } | |||
| } | |||
| }, | |||
| "autoload": { | |||
| "psr-4": { | |||
| "Clockwork\\": "Clockwork/" | |||
| } | |||
| }, | |||
| "notification-url": "https://packagist.org/downloads/", | |||
| "license": [ | |||
| "MIT" | |||
| ], | |||
| "authors": [ | |||
| { | |||
| "name": "itsgoingd", | |||
| "email": "itsgoingd@luzer.sk", | |||
| "homepage": "https://twitter.com/itsgoingd" | |||
| } | |||
| ], | |||
| "description": "php dev tools in your browser", | |||
| "homepage": "https://underground.works/clockwork", | |||
| "keywords": [ | |||
| "Devtools", | |||
| "debugging", | |||
| "laravel", | |||
| "logging", | |||
| "lumen", | |||
| "profiling", | |||
| "slim" | |||
| ], | |||
| "support": { | |||
| "issues": "https://github.com/itsgoingd/clockwork/issues", | |||
| "source": "https://github.com/itsgoingd/clockwork/tree/v5.1.12" | |||
| }, | |||
| "funding": [ | |||
| { | |||
| "url": "https://github.com/itsgoingd", | |||
| "type": "github" | |||
| } | |||
| ], | |||
| "time": "2022-12-13T00:04:12+00:00" | |||
| }, | |||
| { | |||
| "name": "laravel/pint", | |||
| "version": "v1.8.0", | |||
| @@ -37,6 +37,7 @@ return new class extends Migration | |||
| $table->string('email')->comment("Email")->nullable(); | |||
| $table->string('password')->comment("ログインパスワード")->nullable(); | |||
| $table->unsignedTinyInteger("role")->comment("認可")->nullable(); | |||
| $table->string('name')->comment("氏名")->nullable(); | |||
| $helper->index(1, [ColumnName::CONTRACT_ID]); | |||
| @@ -32,9 +32,9 @@ return new class extends Migration | |||
| return function (Blueprint $table, MigrationHelper $helper) { | |||
| $helper->baseColumn() | |||
| ->contractId(); | |||
| ->contractId() | |||
| ->userId(true, "handler_id", "担当者ID"); | |||
| $table->string("handler_id")->comment("担当者ID")->nullable(); | |||
| $table->datetime("order_datetime")->comment("依頼日時")->nullable(); | |||
| $table->string("status")->comment("ステータス")->nullable(); | |||
| $table->string("summary_key1")->comment("集計キー1")->nullable(); | |||
| @@ -37,6 +37,8 @@ return new class extends Migration | |||
| $table->string("customer_code")->comment("顧客コード")->nullable(); | |||
| $table->string("parking_management_code")->comment("駐車場管理コード")->nullable(); | |||
| $table->unsignedInteger("adjust_seq_no")->comment("精算連番")->nullable(); | |||
| $table->string("customer_name")->comment("顧客名")->nullable(); | |||
| $table->string("parking_name")->comment("駐車場名")->nullable(); | |||
| $helper->index(1, [ColumnName::RECEIPT_ISSUING_ORDER_ID]); | |||
| }; | |||
| @@ -34,6 +34,7 @@ class TestUserSeeder extends Seeder | |||
| User::factory()->for($contract)->create([ | |||
| User::COL_NAME_EMAIL => $email, | |||
| User::COL_NAME_ROLE => $role, | |||
| User::COL_NAME_NAME => $email . "太郎", | |||
| ]); | |||
| } | |||
| } | |||
| @@ -48,6 +49,7 @@ class TestUserSeeder extends Seeder | |||
| User::factory()->for($contract)->create([ | |||
| User::COL_NAME_EMAIL => $email, | |||
| User::COL_NAME_ROLE => UserRole::NORMAL_ADMIN, | |||
| User::COL_NAME_NAME => $email . "太郎", | |||
| ]); | |||
| } | |||
| } | |||
| @@ -17,8 +17,15 @@ RouteHelper::get('/me', App\Http\Controllers\Web\Auth\MeController::class); | |||
| RouteHelper::post('/login', App\Http\Controllers\Web\Auth\LoginController::class); | |||
| RouteHelper::get('/logout', App\Http\Controllers\Web\Auth\LogoutController::class); | |||
| RouteHelper::get('/app-token-check', App\Http\Controllers\Web\ReceiptIssuingOrder\TokenCheckController::class); | |||
| RouteHelper::get('/receip/download', App\Http\Controllers\Web\ReceiptIssuingOrder\TokenCheckController::class); | |||
| // Custom for HelloTechno | |||
| RouteHelper::get('/custom/hello-techno/customers', App\Http\Controllers\Web\Custom\HelloTechno\CustomersController::class); | |||
| RouteHelper::get('/custom/hello-techno/parkings', App\Http\Controllers\Web\Custom\HelloTechno\ParkingsController::class); | |||
| // RouteHelper::get('/custom/hello-techno/adjust-data', App\Http\Controllers\Web\Custom\HelloTechno\CustomersController::class); | |||
| RouteHelper::get('/custom/hello-techno/receipt-issuing-orders', App\Http\Controllers\Web\Custom\HelloTechno\ReceiptIssuingOrdersController::class); | |||
| RouteHelper::post('/custom/hello-techno/receipt-issuing-order/create', App\Http\Controllers\Web\Custom\HelloTechno\CreateReceiptIssuingOrderController::class); | |||
| @@ -19,6 +19,8 @@ Route::get('pdf', 'App\Http\Controllers\PDFController@index'); | |||
| RouteHelper::post('/receiptIssuingOrder/create', App\Http\Controllers\Web\ReceiptIssuingOrder\CreateController::class); | |||
| // 領収証ダウンロード | |||
| RouteHelper::get('/receipt/download', App\Http\Controllers\Web\ReceiptIssuingOrder\DownloadController::class); | |||
| // ルーティングで適合しない場合はフロント側のRoutingにゆだねる | |||
| RouteHelper::get('/{any?}', App\Http\Controllers\Web\IndexController::class)->where('any', '.*'); | |||