| @@ -0,0 +1,41 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\Parking; | |||||
| use App\Http\Controllers\Web\WebController; | |||||
| use App\Models\ColumnName; | |||||
| use App\Models\HtpmsCustomer\Existing\Parking; | |||||
| use Illuminate\Http\JsonResponse; | |||||
| use Illuminate\Http\Request; | |||||
| class ParkingListController extends WebController | |||||
| { | |||||
| public function name(): string | |||||
| { | |||||
| return "駐車場一覧取得"; | |||||
| } | |||||
| public function description(): string | |||||
| { | |||||
| return "駐車場一覧を取得する"; | |||||
| } | |||||
| public function __construct(protected ParkingListParam $param) | |||||
| { | |||||
| parent::__construct(); | |||||
| } | |||||
| protected function run(Request $request): JsonResponse | |||||
| { | |||||
| $res = [ | |||||
| "list" => Parking::getBuilder()->select([ | |||||
| sprintf("%s as %s", Parking::COL_NAME_PARKING_MANAGEMENT_CODE, ColumnName::PARKING_MANAGEMENT_CODE), | |||||
| sprintf("%s as %s", Parking::COL_NAME_PARKING_NAME, "parking_name"), | |||||
| ])->get() | |||||
| ]; | |||||
| return $this->successResponse($res); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,9 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\Parking; | |||||
| use App\Http\Controllers\Web\NoneParams; | |||||
| class ParkingListParam extends NoneParams | |||||
| { | |||||
| } | |||||
| @@ -0,0 +1,43 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\QRService\Group; | |||||
| use App\Http\Controllers\Web\WebController; | |||||
| use App\Logics\QRService\QRServiceParkingGroupLogic; | |||||
| use App\Models\HtpmsCustomer\Existing\Parking; | |||||
| use App\Models\HtpmsCustomer\QRService\ServiceParkingGroup; | |||||
| use Illuminate\Http\JsonResponse; | |||||
| use Illuminate\Http\Request; | |||||
| class QRServiceGroupAddController extends WebController | |||||
| { | |||||
| public function name(): string | |||||
| { | |||||
| return "QRサービス券駐車場グループ駐車場追加"; | |||||
| } | |||||
| public function description(): string | |||||
| { | |||||
| return "QRサービス券駐車場グループへ駐車場を追加する"; | |||||
| } | |||||
| public function __construct(protected QRServiceGroupAddParam $param) | |||||
| { | |||||
| parent::__construct(); | |||||
| } | |||||
| protected function run(Request $request): JsonResponse | |||||
| { | |||||
| $param = $this->param; | |||||
| $group = ServiceParkingGroup::findOrFail($param->id); | |||||
| $parking = Parking::whereParkCode($param->parkingManagementCode) | |||||
| ->firstOrFail(); | |||||
| QRServiceParkingGroupLogic::add($group, $parking); | |||||
| return $this->successResponse(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,22 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\QRService\Group; | |||||
| use App\Http\Controllers\Web\BaseParam; | |||||
| use App\Models\HtpmsCustomer\QRService\ServiceParkingGroup; | |||||
| use App\Models\HtpmsCustomer\QRService\ServiceParkingGroupRelation; | |||||
| /** | |||||
| * @property string id | |||||
| * @property string parkingManagementCode | |||||
| */ | |||||
| class QRServiceGroupAddParam extends BaseParam | |||||
| { | |||||
| public function rules(): array | |||||
| { | |||||
| return [ | |||||
| ServiceParkingGroup::COL_NAME_ID => $this->str(), | |||||
| ServiceParkingGroupRelation::COL_NAME_PARKING_MANAGEMENT_CODE => $this->str(), | |||||
| ]; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,84 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\QRService\Group; | |||||
| use App\Http\Controllers\Web\WebController; | |||||
| use App\Repositories\QRServiceParkingGroupRepository; | |||||
| use App\Repositories\QRServiceParkingGroupRepositoryData; | |||||
| use Illuminate\Http\JsonResponse; | |||||
| use Illuminate\Http\Request; | |||||
| class QRServiceGroupListController extends WebController | |||||
| { | |||||
| public function name(): string | |||||
| { | |||||
| return "QRサービス券駐車場グループ取得"; | |||||
| } | |||||
| public function description(): string | |||||
| { | |||||
| return "QRサービス券駐車場グループを取得する"; | |||||
| } | |||||
| public function __construct(protected QRServiceGroupListParam $param, private QRServiceParkingGroupRepository $repository) | |||||
| { | |||||
| parent::__construct(); | |||||
| } | |||||
| protected function run(Request $request): JsonResponse | |||||
| { | |||||
| $param = $this->param; | |||||
| $list = $this->repository->get([ | |||||
| ...$param->toArray(), | |||||
| ]); | |||||
| // データ整形 | |||||
| $container = new データ整形(); | |||||
| foreach ($list as $data) { | |||||
| $container->add($data); | |||||
| } | |||||
| $res = [ | |||||
| 'list' => $container->output(), | |||||
| ]; | |||||
| return $this->successResponse($res); | |||||
| } | |||||
| } | |||||
| class データ整形 | |||||
| { | |||||
| private array $name = []; | |||||
| private array $parking = []; | |||||
| public function add(QRServiceParkingGroupRepositoryData $data) | |||||
| { | |||||
| $this->name[$data->id] = $data->name; | |||||
| if ($data->parking_management_code === null) return; | |||||
| $this->parking[$data->id][] = [ | |||||
| "parking_management_code" => $data->parking_management_code, | |||||
| "parking_name" => $data->parking_name, | |||||
| ]; | |||||
| } | |||||
| public function output(): array | |||||
| { | |||||
| $ret = []; | |||||
| foreach ($this->name as $id => $name) { | |||||
| $data = []; | |||||
| $data['id'] = $id; | |||||
| $data['name'] = $name; | |||||
| $data['parkings'] = data_get($this->parking, $id, []); | |||||
| $ret[] = $data; | |||||
| } | |||||
| return $ret; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,25 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\QRService\Group; | |||||
| use App\Http\Controllers\Web\BaseParam; | |||||
| use App\Http\Controllers\Web\SortableParam; | |||||
| use App\Repositories\QRServiceParkingGroupRepository; | |||||
| /** | |||||
| * @property ?string qrServiceParkingGroupId | |||||
| * @property ?string name | |||||
| * @property ?string parkingManagementCode | |||||
| */ | |||||
| class QRServiceGroupListParam extends BaseParam implements SortableParam | |||||
| { | |||||
| public function rules(): array | |||||
| { | |||||
| return [ | |||||
| QRServiceParkingGroupRepository::CONDITION_QR_SERVICE_PARKING_GROUP_ID => $this->str(true), | |||||
| QRServiceParkingGroupRepository::CONDITION_NAME => $this->str(true), | |||||
| QRServiceParkingGroupRepository::CONDITION_PARKING_MANAGEMENT_CODE => $this->str(true), | |||||
| ...$this->sortableRules(), | |||||
| ]; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,46 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\QRService\Group; | |||||
| use App\Http\Controllers\Web\WebController; | |||||
| use App\Logics\QRService\QRServiceParkingGroupLogic; | |||||
| use App\Models\HtpmsCustomer\QRService\ServiceParkingGroup; | |||||
| use App\Repositories\QRServiceParkingGroupRepository; | |||||
| use Illuminate\Http\JsonResponse; | |||||
| use Illuminate\Http\Request; | |||||
| class QRServiceGroupRegisterController extends WebController | |||||
| { | |||||
| public function name(): string | |||||
| { | |||||
| return "QRサービス券駐車場グループ新規登録"; | |||||
| } | |||||
| public function description(): string | |||||
| { | |||||
| return "QRサービス券駐車場グループを新規登録する"; | |||||
| } | |||||
| public function __construct(protected QRServiceGroupRegisterParam $param, private QRServiceParkingGroupRepository $repository) | |||||
| { | |||||
| parent::__construct(); | |||||
| } | |||||
| protected function run(Request $request): JsonResponse | |||||
| { | |||||
| $param = $this->param; | |||||
| $group = new ServiceParkingGroup(); | |||||
| $group->name = $param->name; | |||||
| QRServiceParkingGroupLogic::register($group); | |||||
| $res = [ | |||||
| 'id' => $group->id, | |||||
| ]; | |||||
| return $this->successResponse($res); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,19 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\QRService\Group; | |||||
| use App\Http\Controllers\Web\BaseParam; | |||||
| use App\Models\HtpmsCustomer\QRService\ServiceParkingGroup; | |||||
| /** | |||||
| * @property string name | |||||
| */ | |||||
| class QRServiceGroupRegisterParam extends BaseParam | |||||
| { | |||||
| public function rules(): array | |||||
| { | |||||
| return [ | |||||
| ServiceParkingGroup::COL_NAME_NAME => $this->str(["between:5,100"]) | |||||
| ]; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,43 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\QRService\Group; | |||||
| use App\Http\Controllers\Web\WebController; | |||||
| use App\Logics\QRService\QRServiceParkingGroupLogic; | |||||
| use App\Models\HtpmsCustomer\Existing\Parking; | |||||
| use App\Models\HtpmsCustomer\QRService\ServiceParkingGroup; | |||||
| use Illuminate\Http\JsonResponse; | |||||
| use Illuminate\Http\Request; | |||||
| class QRServiceGroupRemoveController extends WebController | |||||
| { | |||||
| public function name(): string | |||||
| { | |||||
| return "QRサービス券駐車場グループ駐車場削除"; | |||||
| } | |||||
| public function description(): string | |||||
| { | |||||
| return "QRサービス券駐車場グループへ駐車場を削除する"; | |||||
| } | |||||
| public function __construct(protected QRServiceGroupRemoveParam $param) | |||||
| { | |||||
| parent::__construct(); | |||||
| } | |||||
| protected function run(Request $request): JsonResponse | |||||
| { | |||||
| $param = $this->param; | |||||
| $group = ServiceParkingGroup::findOrFail($param->id); | |||||
| $parking = Parking::whereParkCode($param->parkingManagementCode) | |||||
| ->firstOrFail(); | |||||
| QRServiceParkingGroupLogic::remove($group, $parking); | |||||
| return $this->successResponse(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,22 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\QRService\Group; | |||||
| use App\Http\Controllers\Web\BaseParam; | |||||
| use App\Models\HtpmsCustomer\QRService\ServiceParkingGroup; | |||||
| use App\Models\HtpmsCustomer\QRService\ServiceParkingGroupRelation; | |||||
| /** | |||||
| * @property string id | |||||
| * @property string parkingManagementCode | |||||
| */ | |||||
| class QRServiceGroupRemoveParam extends BaseParam | |||||
| { | |||||
| public function rules(): array | |||||
| { | |||||
| return [ | |||||
| ServiceParkingGroup::COL_NAME_ID => $this->str(), | |||||
| ServiceParkingGroupRelation::COL_NAME_PARKING_MANAGEMENT_CODE => $this->str(), | |||||
| ]; | |||||
| } | |||||
| } | |||||
| @@ -1,6 +1,6 @@ | |||||
| <?php | <?php | ||||
| namespace App\Http\Controllers\Web\Shop; | |||||
| namespace App\Http\Controllers\Web\Shop\Config; | |||||
| use App\Http\Controllers\Web\WebController; | use App\Http\Controllers\Web\WebController; | ||||
| use App\Logics\QRService\ChargeLogic; | use App\Logics\QRService\ChargeLogic; | ||||
| @@ -1,6 +1,6 @@ | |||||
| <?php | <?php | ||||
| namespace App\Http\Controllers\Web\Shop; | |||||
| namespace App\Http\Controllers\Web\Shop\Config; | |||||
| use App\Http\Controllers\Web\BaseParam; | use App\Http\Controllers\Web\BaseParam; | ||||
| use App\Models\ColumnName; | use App\Models\ColumnName; | ||||
| @@ -0,0 +1,50 @@ | |||||
| <?php | |||||
| namespace App\Logics\QRService; | |||||
| use App\Exceptions\ParamException; | |||||
| use App\Models\HtpmsCustomer\Existing\Parking; | |||||
| use App\Models\HtpmsCustomer\QRService\ServiceParkingGroup; | |||||
| use App\Models\HtpmsCustomer\QRService\ServiceParkingGroupRelation; | |||||
| class QRServiceParkingGroupLogic | |||||
| { | |||||
| public static function register(ServiceParkingGroup $group) | |||||
| { | |||||
| // 重複チェック | |||||
| if (ServiceParkingGroup::whereName($group->name)->exists()) { | |||||
| ParamException::throw(ServiceParkingGroup::COL_NAME_NAME, trans('validate.exists')); | |||||
| } | |||||
| $group->save(); | |||||
| } | |||||
| public static function add(ServiceParkingGroup $group, Parking $parking) | |||||
| { | |||||
| // 重複チェック | |||||
| if (ServiceParkingGroupRelation::whereQrServiceParkingGroupId($group->id) | |||||
| ->whereParkingManagementCode($parking->park_code) | |||||
| ->exists() | |||||
| ) { | |||||
| ParamException::throw(ServiceParkingGroupRelation::COL_NAME_PARKING_MANAGEMENT_CODE, trans('validate.exists')); | |||||
| } | |||||
| $relation = new ServiceParkingGroupRelation(); | |||||
| $relation->qr_service_parking_group_id = $group->id; | |||||
| $relation->parking_management_code = $parking->park_code; | |||||
| $relation->save(); | |||||
| return $relation; | |||||
| } | |||||
| public static function remove(ServiceParkingGroup $group, Parking $parking) | |||||
| { | |||||
| $relation = ServiceParkingGroupRelation::whereQrServiceParkingGroupId($group->id) | |||||
| ->whereParkingManagementCode($parking->park_code) | |||||
| ->firstOrFail(); | |||||
| $relation->delete(); | |||||
| } | |||||
| } | |||||
| @@ -3,6 +3,8 @@ | |||||
| namespace App\Models\HtpmsCustomer\Existing; | namespace App\Models\HtpmsCustomer\Existing; | ||||
| use Illuminate\Database\Eloquent\Model; | use Illuminate\Database\Eloquent\Model; | ||||
| use Illuminate\Database\Query\Builder; | |||||
| use Illuminate\Support\Facades\DB; | |||||
| class Parking extends Model | class Parking extends Model | ||||
| { | { | ||||
| @@ -13,4 +15,20 @@ class Parking extends Model | |||||
| protected $table = 'tbl_park'; | protected $table = 'tbl_park'; | ||||
| protected $fillable = []; // 参照専用 | protected $fillable = []; // 参照専用 | ||||
| protected $visible = [ | |||||
| self::COL_NAME_PARKING_MANAGEMENT_CODE, | |||||
| self::COL_NAME_PARKING_NAME, | |||||
| ]; | |||||
| public static function getBuilder(string $name = 'main'): Builder | |||||
| { | |||||
| $instance = new static(); | |||||
| return DB::connection($instance->getConnectionName())->table(static::getTableName(), $name); | |||||
| } | |||||
| public static function getTableName(): string | |||||
| { | |||||
| return (new static)->getTable(); | |||||
| } | |||||
| } | } | ||||
| @@ -5,7 +5,7 @@ namespace App\Models\HtpmsCustomer\QRService; | |||||
| use App\Models\HtpmsCustomer\HtpmsCustomerHistoryModel; | use App\Models\HtpmsCustomer\HtpmsCustomerHistoryModel; | ||||
| /** | /** | ||||
| * QRサービス券駐車場グループ | |||||
| * QRサービス券駐車場グループ履歴 | |||||
| */ | */ | ||||
| class ServiceParkingGroupHistory extends HtpmsCustomerHistoryModel | class ServiceParkingGroupHistory extends HtpmsCustomerHistoryModel | ||||
| { | { | ||||
| @@ -0,0 +1,95 @@ | |||||
| <?php | |||||
| namespace App\Repositories; | |||||
| use App\Models\ColumnName; | |||||
| use App\Models\HtpmsCustomer\Existing\Parking; | |||||
| use App\Models\HtpmsCustomer\QRService\ServiceParkingGroup; | |||||
| use App\Models\HtpmsCustomer\QRService\ServiceParkingGroupRelation; | |||||
| use App\Repositories\BaseRepository; | |||||
| use Illuminate\Database\Query\JoinClause; | |||||
| use Illuminate\Support\Collection; | |||||
| use Illuminate\Support\Facades\DB; | |||||
| class QRServiceParkingGroupRepository extends BaseRepository | |||||
| { | |||||
| const CONDITION_QR_SERVICE_PARKING_GROUP_ID = ColumnName::QR_SERVICE_PARKING_GROUP_ID; | |||||
| const CONDITION_NAME = 'name'; | |||||
| const CONDITION_PARKING_MANAGEMENT_CODE = ColumnName::PARKING_MANAGEMENT_CODE; | |||||
| const TABLE_GROUP = "group"; | |||||
| const TABLE_RELATION = "relation"; | |||||
| const TABLE_PARKING = "parking"; | |||||
| /** | |||||
| * コレクションを取得する | |||||
| * | |||||
| * @param array $condition | |||||
| * @return Collection<int, QRServiceParkingGroupRepositoryData> | |||||
| */ | |||||
| public function get(array $condition): Collection | |||||
| { | |||||
| $table = ServiceParkingGroup::getBuilder(static::TABLE_GROUP); | |||||
| $table->leftJoinSub(ServiceParkingGroupRelation::getBuilder(), static::TABLE_RELATION, function (JoinClause $join) { | |||||
| $join->on( | |||||
| $this->makeColumnName([static::TABLE_GROUP, ServiceParkingGroup::COL_NAME_ID]), | |||||
| $this->makeColumnName([static::TABLE_RELATION, ServiceParkingGroupRelation::COL_NAME_QR_SERVICE_PARKING_GROUP_ID]) | |||||
| ); | |||||
| }); | |||||
| $table->leftJoinSub(Parking::getBuilder(), static::TABLE_PARKING, function (JoinClause $join) { | |||||
| $join->on( | |||||
| $this->makeColumnName([static::TABLE_RELATION, ServiceParkingGroupRelation::COL_NAME_PARKING_MANAGEMENT_CODE]), | |||||
| $this->makeColumnName([static::TABLE_PARKING, Parking::COL_NAME_PARKING_MANAGEMENT_CODE]) | |||||
| ); | |||||
| }); | |||||
| // -----検索条件 | |||||
| // GROUP_ID | |||||
| $this->where($table, $condition, static::CONDITION_QR_SERVICE_PARKING_GROUP_ID, $this->makeColumnName([static::TABLE_GROUP, ServiceParkingGroup::COL_NAME_ID])); | |||||
| // 名前 | |||||
| $name = data_get($condition, static::CONDITION_NAME); | |||||
| if ($name) { | |||||
| $table->where($this->makeColumnName([static::TABLE_GROUP, ServiceParkingGroup::COL_NAME_NAME]), 'like', "%{$name}%"); | |||||
| } | |||||
| // 駐車場管理コード | |||||
| $this->where($table, $condition, static::CONDITION_PARKING_MANAGEMENT_CODE, $this->makeColumnName([ | |||||
| static::TABLE_RELATION, | |||||
| ServiceParkingGroupRelation::COL_NAME_PARKING_MANAGEMENT_CODE | |||||
| ])); | |||||
| $table->select($this->columns()); | |||||
| $main = DB::connection("htpms_customer")->table($table, "main"); | |||||
| // ソート | |||||
| $this->sort($main, $condition); | |||||
| // リミット | |||||
| $this->limit($main, $condition); | |||||
| return QRServiceParkingGroupRepositoryData::makeList($main->get()); | |||||
| } | |||||
| private function columns() | |||||
| { | |||||
| $group = static::TABLE_GROUP; | |||||
| $relation = static::TABLE_RELATION; | |||||
| $parking = static::TABLE_PARKING; | |||||
| $columns = [ | |||||
| $this->makeColumnNameForSelect([$group, ServiceParkingGroup::COL_NAME_ID]), | |||||
| $this->makeColumnNameForSelect([$group, ServiceParkingGroup::COL_NAME_NAME]), | |||||
| $this->makeColumnNameForSelect([$parking, Parking::COL_NAME_PARKING_MANAGEMENT_CODE], ColumnName::PARKING_MANAGEMENT_CODE), | |||||
| $this->makeColumnNameForSelect([$parking, Parking::COL_NAME_PARKING_NAME], "parking_name"), | |||||
| ]; | |||||
| return $columns; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,14 @@ | |||||
| <?php | |||||
| namespace App\Repositories; | |||||
| /** | |||||
| * @property string id | |||||
| * @property string name | |||||
| * @property ?string parking_management_code | |||||
| * @property ?string parking_name | |||||
| */ | |||||
| class QRServiceParkingGroupRepositoryData extends BaseRepositoryData | |||||
| { | |||||
| } | |||||
| @@ -36,12 +36,17 @@ Route::middleware('auth:sanctum')->group(function () { | |||||
| // 運営会社ルート | // 運営会社ルート | ||||
| Route::middleware(RouteHelper::role([UserRole::CUSTOMER]))->group(function () { | Route::middleware(RouteHelper::role([UserRole::CUSTOMER]))->group(function () { | ||||
| RouteHelper::post('/role/switch/shop', App\Http\Controllers\Web\Auth\SwitcShophController::class); | |||||
| RouteHelper::get('/parking/list', App\Http\Controllers\Web\Parking\ParkingListController::class); | |||||
| RouteHelper::post('/role/switch/shop', App\Http\Controllers\Web\Auth\SwitchShopController::class); | |||||
| RouteHelper::post('/login-user/shop/register', App\Http\Controllers\Web\LoginUser\ShopRegisterController::class); | RouteHelper::post('/login-user/shop/register', App\Http\Controllers\Web\LoginUser\ShopRegisterController::class); | ||||
| RouteHelper::post('/shop/register', App\Http\Controllers\Web\Shop\ShopRegisterController::class); | RouteHelper::post('/shop/register', App\Http\Controllers\Web\Shop\ShopRegisterController::class); | ||||
| RouteHelper::get('/shop/list', App\Http\Controllers\Web\Shop\ShopListController::class); | RouteHelper::get('/shop/list', App\Http\Controllers\Web\Shop\ShopListController::class); | ||||
| RouteHelper::post('/shop/deposit/charge', App\Http\Controllers\Web\Shop\DepositChargeController::class); | RouteHelper::post('/shop/deposit/charge', App\Http\Controllers\Web\Shop\DepositChargeController::class); | ||||
| RouteHelper::post('/shop/config', App\Http\Controllers\Web\Shop\ShopConfigController::class); | |||||
| RouteHelper::post('/shop/config', App\Http\Controllers\Web\Shop\Config\ShopConfigController::class); | |||||
| RouteHelper::get('/qr-service/parking-group/list', App\Http\Controllers\Web\QRService\Group\QRServiceGroupListController::class); | |||||
| RouteHelper::post('/qr-service/parking-group/register', App\Http\Controllers\Web\QRService\Group\QRServiceGroupRegisterController::class); | |||||
| RouteHelper::post('/qr-service/parking-group/parking/add', App\Http\Controllers\Web\QRService\Group\QRServiceGroupAddController::class); | |||||
| RouteHelper::post('/qr-service/parking-group/parking/remove', App\Http\Controllers\Web\QRService\Group\QRServiceGroupRemoveController::class); | |||||
| }); | }); | ||||
| // 店舗ルート | // 店舗ルート | ||||