From 8ba83f4d6f2b6e85686204e030aa436ed4710803 Mon Sep 17 00:00:00 2001 From: "sosuke.iwabuchi" Date: Mon, 22 May 2023 09:06:54 +0900 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E5=82=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 4 +- app/Codes/Custom.php | 9 ++ app/Codes/ReceiptIssuingOrderType.php | 15 ++++ .../Controllers/Web/Auth/LoginController.php | 31 +++---- app/Http/Controllers/Web/Auth/LoginParam.php | 2 +- .../Controllers/Web/Auth/LogoutController.php | 32 +++++++ app/Http/Controllers/Web/Auth/LogoutParam.php | 13 +++ app/Http/Controllers/Web/Auth/Me.php | 24 ++++++ .../Controllers/Web/Auth/MeController.php | 50 +++++++++++ app/Http/Controllers/Web/Auth/MeParam.php | 13 +++ .../CreateReceiptIssuingOrderController.php | 73 ++++++++++++++++ .../CreateReceiptIssuingOrderParam.php | 38 ++++++++ .../HelloTechno/CustomersController.php | 46 ++++++++++ .../Web/Custom/HelloTechno/CustomersParam.php | 19 ++++ .../Custom/HelloTechno/ParkingsController.php | 49 +++++++++++ .../Web/Custom/HelloTechno/ParkingsParam.php | 20 +++++ app/Http/Controllers/Web/WebController.php | 34 +++++++- .../ReceiptIssuingOrder/CreateManager.php | 5 ++ .../Custom/HelloTechno/CreateManager.php | 50 +++++++++++ app/Logic/SMS/FourSMessageManager.php | 4 +- app/Logic/SMS/LogManager.php | 4 +- app/Models/BaseModel.php | 24 ++++++ app/Models/Contract.php | 16 +++- .../ReceiptIssuingHTParkingCustomOrder.php | 4 + app/Models/ReceiptIssuingOrder.php | 5 +- app/Models/User.php | 17 +--- app/Util/Custom/HelloTechno/API.php | 86 +++++++++++++++++++ config/logic.php | 9 +- ...00_create_receipt_issuing_orders_table.php | 5 +- ...18_131700_create_sms_send_orders_table.php | 6 +- database/seeders/TestUserSeeder.php | 54 ++++++++++++ docker/8.2/php.ini | 3 + routes/api.php | 12 +++ tests/Feature/SMSTest.php | 4 +- 34 files changed, 727 insertions(+), 53 deletions(-) create mode 100644 app/Codes/Custom.php create mode 100644 app/Codes/ReceiptIssuingOrderType.php create mode 100644 app/Http/Controllers/Web/Auth/LogoutController.php create mode 100644 app/Http/Controllers/Web/Auth/LogoutParam.php create mode 100644 app/Http/Controllers/Web/Auth/Me.php create mode 100644 app/Http/Controllers/Web/Auth/MeController.php create mode 100644 app/Http/Controllers/Web/Auth/MeParam.php create mode 100644 app/Http/Controllers/Web/Custom/HelloTechno/CreateReceiptIssuingOrderController.php create mode 100644 app/Http/Controllers/Web/Custom/HelloTechno/CreateReceiptIssuingOrderParam.php create mode 100644 app/Http/Controllers/Web/Custom/HelloTechno/CustomersController.php create mode 100644 app/Http/Controllers/Web/Custom/HelloTechno/CustomersParam.php create mode 100644 app/Http/Controllers/Web/Custom/HelloTechno/ParkingsController.php create mode 100644 app/Http/Controllers/Web/Custom/HelloTechno/ParkingsParam.php create mode 100644 app/Logic/ReceiptIssuingOrder/Custom/HelloTechno/CreateManager.php create mode 100644 app/Util/Custom/HelloTechno/API.php create mode 100644 database/seeders/TestUserSeeder.php diff --git a/.env.example b/.env.example index dee8d4a..3fdd3bb 100644 --- a/.env.example +++ b/.env.example @@ -61,4 +61,6 @@ SAIL_XDEBUG_MODE=debug,develop SMS_PROVIDER=log SMS_FOURS_MESSAGE_USER=null -SMS_FOURS_MESSAGE_PASSWORD=null \ No newline at end of file +SMS_FOURS_MESSAGE_PASSWORD=null + +CUSTOM_HELLOTECHNO_API_HOST="http://localhost" \ No newline at end of file diff --git a/app/Codes/Custom.php b/app/Codes/Custom.php new file mode 100644 index 0000000..3f4901e --- /dev/null +++ b/app/Codes/Custom.php @@ -0,0 +1,9 @@ +param = $param; - } - public function param(): LoginParam + public function __construct(protected LoginParam $param) { - return $this->param; } protected function run(Request $request): JsonResponse { // 取得したユーザ情報を登録しログインを行う - $param = $this->param(); - + $param = $this->param; $user = User::whereEmail($param->email)->first(); if ($user === null) { @@ -47,15 +38,17 @@ class LoginController extends WebController } if (Auth::attempt([ - $this->username() => $param->email, + 'email' => $param->email, 'password' => $param->password, ])) { - $user = Auth::user(); + $me = $this->me(); - return $this->successResponse(); - } else { - return $this->failedResponse([], '認証失敗'); + if ($me !== null) { + return $this->successResponse($me); + } } + + return $this->failedResponse([], '認証失敗'); } } diff --git a/app/Http/Controllers/Web/Auth/LoginParam.php b/app/Http/Controllers/Web/Auth/LoginParam.php index 47814c5..d7b071c 100644 --- a/app/Http/Controllers/Web/Auth/LoginParam.php +++ b/app/Http/Controllers/Web/Auth/LoginParam.php @@ -1,6 +1,6 @@ successResponse(); + } +} diff --git a/app/Http/Controllers/Web/Auth/LogoutParam.php b/app/Http/Controllers/Web/Auth/LogoutParam.php new file mode 100644 index 0000000..a7a0ae3 --- /dev/null +++ b/app/Http/Controllers/Web/Auth/LogoutParam.php @@ -0,0 +1,13 @@ +toArray(); + + return array_intersect_key($user, array_flip([ + User::COL_NAME_ID, + User::COL_NAME_CONTRACT_ID, + User::COL_NAME_ROLE, + ])); + } + return null; + } +} diff --git a/app/Http/Controllers/Web/Auth/MeController.php b/app/Http/Controllers/Web/Auth/MeController.php new file mode 100644 index 0000000..680cff7 --- /dev/null +++ b/app/Http/Controllers/Web/Auth/MeController.php @@ -0,0 +1,50 @@ +me(); + if ($me !== null) { + return $this->successResponse($me); + } + return $this->failedResponse(); + // if (Auth::check()) { + // $user = Auth::user(); + // $ret = $user->get([ + // User::COL_NAME_CONTRACT_ID, + // User::COL_NAME_ROLE, + // ]); + + // } else { + // } + } +} diff --git a/app/Http/Controllers/Web/Auth/MeParam.php b/app/Http/Controllers/Web/Auth/MeParam.php new file mode 100644 index 0000000..73fd307 --- /dev/null +++ b/app/Http/Controllers/Web/Auth/MeParam.php @@ -0,0 +1,13 @@ +middleware('auth:sanctum'); + $this->roleAllow(UserRole::NORMAL_ADMIN); + } + + protected function getParam(): IParam + { + return $this->param; + } + + protected function run(Request $request): JsonResponse + { + $param = $this->param; + + // TODO 顧客情報取得 + // TODO 駐車場情報取得 + + $orderData = [ + ...$param->toArray(), + Order::COL_NAME_HANDLER_ID => Auth::id(), + Order::COL_NAME_SUMMARY_KEY1 => $param->customerCode, + Order::COL_NAME_SUMMARY_KEY2 => $param->parkingManagementCode, + Order::COL_NAME_RECEIPT_PURPOSE => "駐車領収証", + Order::COL_NAME_RECEIPT_INVOICE_NO => "##TODO インボイス登録番号##", + Order::COL_NAME_RECEIPT_PURPOSE => "駐車料金", + Order::COL_NAME_RECEIPT_ISSUER => "##TODO 発行者名##", + Order::COL_NAME_RECEIPT_SHOP_NAME => "##TODO 駐車場名##", + Order::COL_NAME_RECEIPT_PURPOSE => "駐車料金", + Order::COL_NAME_MEMO => "駐車料金", + ]; + + logger($orderData); + + $messages = $this->manager->init() + ->fill($orderData) + ->create(); + + if (count($messages) !== 0) { + return $this->failedResponse([], $messages); + } + + + return $this->successResponse(); + } +} diff --git a/app/Http/Controllers/Web/Custom/HelloTechno/CreateReceiptIssuingOrderParam.php b/app/Http/Controllers/Web/Custom/HelloTechno/CreateReceiptIssuingOrderParam.php new file mode 100644 index 0000000..fd8f669 --- /dev/null +++ b/app/Http/Controllers/Web/Custom/HelloTechno/CreateReceiptIssuingOrderParam.php @@ -0,0 +1,38 @@ + $this->str(), + HT::COL_NAME_PARKING_MANAGEMENT_CODE => $this->str(), + HT::COL_NAME_ADJUST_SEQ_NO => $this->numeric(true), + ReceiptIssuingOrder::COL_NAME_RECEIPT_USE_DATETIME => $this->date(), + ReceiptIssuingOrder::COL_NAME_RECEIPT_NAME => $this->str(), + ReceiptIssuingOrder::COL_NAME_RECEIPT_AMOUNT => $this->numeric(['min:0', 'max:999999']), + ReceiptIssuingOrder::COL_NAME_MEMO => $this->text(true), + ReceiptIssuingOrder::COL_NAME_SMS_PHONE_NUMBER => $this->str([new PhoneNumber()]), + + ]; + } +} diff --git a/app/Http/Controllers/Web/Custom/HelloTechno/CustomersController.php b/app/Http/Controllers/Web/Custom/HelloTechno/CustomersController.php new file mode 100644 index 0000000..d0c2696 --- /dev/null +++ b/app/Http/Controllers/Web/Custom/HelloTechno/CustomersController.php @@ -0,0 +1,46 @@ +middleware('auth:sanctum'); + $this->roleAllow(UserRole::NORMAL_ADMIN); + $this->customAllow = [Custom::HELLO_TECHNO]; + } + + protected function getParam(): IParam + { + return $this->param; + } + + protected function run(Request $request): JsonResponse + { + $param = $this->param; + + $list = API::getCustomers($param->customerCode); + + return $this->successResponse(['records' => $list]); + } +} diff --git a/app/Http/Controllers/Web/Custom/HelloTechno/CustomersParam.php b/app/Http/Controllers/Web/Custom/HelloTechno/CustomersParam.php new file mode 100644 index 0000000..4c5c640 --- /dev/null +++ b/app/Http/Controllers/Web/Custom/HelloTechno/CustomersParam.php @@ -0,0 +1,19 @@ + $this->str(true), + ]; + } +} diff --git a/app/Http/Controllers/Web/Custom/HelloTechno/ParkingsController.php b/app/Http/Controllers/Web/Custom/HelloTechno/ParkingsController.php new file mode 100644 index 0000000..228b4c4 --- /dev/null +++ b/app/Http/Controllers/Web/Custom/HelloTechno/ParkingsController.php @@ -0,0 +1,49 @@ +middleware('auth:sanctum'); + $this->roleAllow(UserRole::NORMAL_ADMIN); + $this->customAllow = [Custom::HELLO_TECHNO]; + } + + protected function getParam(): IParam + { + return $this->param; + } + + protected function run(Request $request): JsonResponse + { + $param = $this->param; + + $list = API::getParkings($param->customerCode, $param->parkingManagementCode); + + return $this->successResponse(['records' => $list]); + } +} diff --git a/app/Http/Controllers/Web/Custom/HelloTechno/ParkingsParam.php b/app/Http/Controllers/Web/Custom/HelloTechno/ParkingsParam.php new file mode 100644 index 0000000..4caf1c8 --- /dev/null +++ b/app/Http/Controllers/Web/Custom/HelloTechno/ParkingsParam.php @@ -0,0 +1,20 @@ + $this->str(), + 'parking_management_code' => $this->str(true) + ]; + } +} diff --git a/app/Http/Controllers/Web/WebController.php b/app/Http/Controllers/Web/WebController.php index 23e5e85..fa6877e 100644 --- a/app/Http/Controllers/Web/WebController.php +++ b/app/Http/Controllers/Web/WebController.php @@ -84,7 +84,10 @@ abstract class WebController extends BaseController /** * パラメータオブジェクト */ - abstract protected function getParam(): IParam; + protected function getParam(): IParam + { + return $this->param; + } /** @@ -281,6 +284,7 @@ abstract class WebController extends BaseController // 以下 認可関係 protected array|null $roleAllow = null; protected array|null $roleDisallow = null; + protected array|null $customAllow = null; protected function roleAllow(UserRole $role) { @@ -314,7 +318,33 @@ abstract class WebController extends BaseController if (is_array($this->roleDisallow) && in_array($role, $this->roleDisallow)) { return false; } - return true; + + return $this->canCustomAccess(); + } + + public function canCustomAccess(): bool + { + + if (Auth::user()->role === UserRole::SUPER_ADMIN) { + return true; + } + + if ($this->customAllow === null) { + return true; + } + + $myCustoms = Auth::user()->contract->custom(); + + + + + foreach ($this->customAllow as $targetCustom) { + logger(['myCustoms' => $myCustoms, 'target' => $targetCustom]); + if (in_array($targetCustom, $myCustoms, true)) { + return true; + } + } + return false; } // 返却用データの登録 diff --git a/app/Logic/ReceiptIssuingOrder/CreateManager.php b/app/Logic/ReceiptIssuingOrder/CreateManager.php index 633e215..38ec74c 100644 --- a/app/Logic/ReceiptIssuingOrder/CreateManager.php +++ b/app/Logic/ReceiptIssuingOrder/CreateManager.php @@ -27,6 +27,11 @@ class CreateManager extends ReceiptIssuingOrderManager return $this; } + public function id(): string + { + return $this->order->id ?? ""; + } + public function fill(array $attr) { $this->order->fill($attr); diff --git a/app/Logic/ReceiptIssuingOrder/Custom/HelloTechno/CreateManager.php b/app/Logic/ReceiptIssuingOrder/Custom/HelloTechno/CreateManager.php new file mode 100644 index 0000000..0d55c62 --- /dev/null +++ b/app/Logic/ReceiptIssuingOrder/Custom/HelloTechno/CreateManager.php @@ -0,0 +1,50 @@ +manager->init(); + return $this; + } + + public function fill(array $attr): static + { + $this->manager->fill($attr); + $this->customOrder->fill($attr); + + return $this; + } + + public function create(): array + { + $messages = $this->manager->create(); + + if (count($messages) !== 0) { + return $messages; + } + + $this->customOrder->setReceiptIssuingOrder($this->manager->id()); + $this->customOrder->save(); + + return []; + } +} diff --git a/app/Logic/SMS/FourSMessageManager.php b/app/Logic/SMS/FourSMessageManager.php index 582bdc5..d447b49 100644 --- a/app/Logic/SMS/FourSMessageManager.php +++ b/app/Logic/SMS/FourSMessageManager.php @@ -48,8 +48,8 @@ class FourSMessageManager implements SMSManager $order->receipt_issuing_order_id = $receiptIssuingOrder->id; $order->contract_id = $receiptIssuingOrder->contract_id; $order->phone_number = $receiptIssuingOrder->sms_phone_number; - $order->sumamry_key1 = $receiptIssuingOrder->sumamry_key1; - $order->sumamry_key2 = $receiptIssuingOrder->sumamry_key2; + $order->summary_key1 = $receiptIssuingOrder->summary_key1; + $order->summary_key2 = $receiptIssuingOrder->summary_key2; $order->purpose = $purpose; $order->content = $contents; diff --git a/app/Logic/SMS/LogManager.php b/app/Logic/SMS/LogManager.php index 5572741..53445d7 100644 --- a/app/Logic/SMS/LogManager.php +++ b/app/Logic/SMS/LogManager.php @@ -21,8 +21,8 @@ class LogManager implements SMSManager $order->receipt_issuing_order_id = $receiptIssuingOrder->id; $order->contract_id = $receiptIssuingOrder->contract_id; $order->phone_number = $receiptIssuingOrder->sms_phone_number; - $order->sumamry_key1 = $receiptIssuingOrder->sumamry_key1; - $order->sumamry_key2 = $receiptIssuingOrder->sumamry_key2; + $order->summary_key1 = $receiptIssuingOrder->summary_key1; + $order->summary_key2 = $receiptIssuingOrder->summary_key2; $order->purpose = $purpose; $order->content = $contents; diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index 7fc4ef4..a774ff0 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -9,7 +9,9 @@ use App\Models\Feature\IModelFeature; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Query\Builder; +use Illuminate\Support\Arr; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Str; abstract class BaseModel extends Model implements IModelFeature { @@ -41,6 +43,17 @@ abstract class BaseModel extends Model implements IModelFeature return (new static)->getTable(); } + public static function hasColumn(string $columnName): bool + { + $target = sprintf("%s::COL_NAME_%s", static::class, Str::upper($columnName)); + $ret = defined($target); + if (!$ret) { + logger(sprintf("does not have column [%s] on [%s] [%s]", Str::upper($columnName), static::getTableName(), $target)); + } + return $ret; + } + + public function copy(IModelFeature $from): static { $data = $from->getAttributeKeys(); @@ -66,4 +79,15 @@ abstract class BaseModel extends Model implements IModelFeature 'updating' => UpdatingEvent::class, 'deleted' => DeletedEvent::class, ]; + + + // カラムが存在する項目のみfillするようオーバーライド + public function fill(array $atr) + { + $filterd = array_filter($atr, function ($value, $key) { + return static::hasColumn($key); + }, ARRAY_FILTER_USE_BOTH); + + return parent::fill($filterd); + } } diff --git a/app/Models/Contract.php b/app/Models/Contract.php index 08affa5..6ee9597 100644 --- a/app/Models/Contract.php +++ b/app/Models/Contract.php @@ -3,6 +3,7 @@ namespace App\Models; use Illuminate\Support\Str; +use App\Codes\Custom; class Contract extends AppModel { @@ -20,11 +21,24 @@ class Contract extends AppModel return in_array($target, $this->custom(), true); } + /** + * @return Custom[] + */ public function custom(): array { $custom = data_get($this, self::COL_NAME_CUSTOM); if ($custom) { - return explode(',', $custom); + + + $strList = explode(',', $custom); + $ret = []; + foreach ($strList as $str) { + $c = Custom::tryFrom($str); + if ($c !== null) { + $ret[] = $c; + } + } + return $ret; } else { return []; } diff --git a/app/Models/ReceiptIssuingHTParkingCustomOrder.php b/app/Models/ReceiptIssuingHTParkingCustomOrder.php index 9b4c6f0..6c1e7ea 100644 --- a/app/Models/ReceiptIssuingHTParkingCustomOrder.php +++ b/app/Models/ReceiptIssuingHTParkingCustomOrder.php @@ -8,6 +8,10 @@ class ReceiptIssuingHTParkingCustomOrder extends AppModel { use ReceiptIssuingOrderFeature; + 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"; + public function getModelName(): string { return "領収証発行依頼(HT駐車場カスタム)"; diff --git a/app/Models/ReceiptIssuingOrder.php b/app/Models/ReceiptIssuingOrder.php index 5dae456..3a42d5f 100644 --- a/app/Models/ReceiptIssuingOrder.php +++ b/app/Models/ReceiptIssuingOrder.php @@ -12,8 +12,8 @@ class ReceiptIssuingOrder extends AppModel const COL_NAME_HANDLER_ID = "handler_id"; const COL_NAME_ORDER_DATETIME = "order_datetime"; const COL_NAME_STATUS = "status"; - const COL_NAME_SUMMARY_KEY1 = "sumamry_key1"; - const COL_NAME_SUMMARY_KEY2 = "sumamry_key2"; + const COL_NAME_SUMMARY_KEY1 = "summary_key1"; + const COL_NAME_SUMMARY_KEY2 = "summary_key2"; const COL_NAME_ACCESS_TOKEN = "access_token"; const COL_NAME_ACCESS_TOKEN_EXPIRES_AT = "access_token_expires_at"; const COL_NAME_SMS_PHONE_NUMBER = "sms_phone_number"; @@ -22,6 +22,7 @@ class ReceiptIssuingOrder extends AppModel const COL_NAME_RECEIPT_USE_DATETIME = "receipt_use_datetime"; const COL_NAME_RECEIPT_SHOP_NAME = "receipt_shop_name"; const COL_NAME_RECEIPT_ISSUER = "receipt_issuer"; + const COL_NAME_RECEIPT_NAME = "receipt_name"; const COL_NAME_RECEIPT_PURPOSE = "receipt_purpose"; const COL_NAME_RECEIPT_INVOICE_NO = "receipt_invoice_no"; const COL_NAME_RECEIPT_AMOUNT = "receipt_amount"; diff --git a/app/Models/User.php b/app/Models/User.php index 8f4ecc2..632f0ca 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -19,22 +19,9 @@ class User extends Authenticatable implements IModelFeature { use HasApiTokens, HasFactory, Notifiable, HasUuids, ContractFeature; + const COL_NAME_ID = 'id'; const COL_NAME_ROLE = 'role'; - - // public function __construct(...$params) - // { - // $this->dispatchesEvents = [ - // 'created' => CreatedListener::class, - // 'updating' => UpdatingListener::class, - // 'deleting' => DeletingListener::class, - // ]; - // protected $dispatchesEvents = [ - // 'created' => CreatedEvent::class, - // 'updating' => UpdatingEvent::class, - // 'deleted' => DeletedEvent::class, - // ]; - // parent::__construct(...$params); - // } + const COL_NAME_EMAIL = 'email'; /** * The attributes that should be hidden for serialization. diff --git a/app/Util/Custom/HelloTechno/API.php b/app/Util/Custom/HelloTechno/API.php new file mode 100644 index 0000000..719a211 --- /dev/null +++ b/app/Util/Custom/HelloTechno/API.php @@ -0,0 +1,86 @@ +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, []); + } +} diff --git a/config/logic.php b/config/logic.php index 361a4c4..3aacfb3 100644 --- a/config/logic.php +++ b/config/logic.php @@ -18,5 +18,12 @@ return [ 'userId' => env("SMS_FOURS_MESSAGE_USER"), 'password' => env("SMS_FOURS_MESSAGE_PASSWORD"), ] - ] + ], + + + 'custom' => [ + 'hellotechno' => [ + 'host' => env('CUSTOM_HELLOTECHNO_API_HOST', 'http://localhost') + ], + ], ]; diff --git a/database/migrations/2023_04_15_152400_create_receipt_issuing_orders_table.php b/database/migrations/2023_04_15_152400_create_receipt_issuing_orders_table.php index b95c3e2..1b6d069 100644 --- a/database/migrations/2023_04_15_152400_create_receipt_issuing_orders_table.php +++ b/database/migrations/2023_04_15_152400_create_receipt_issuing_orders_table.php @@ -37,8 +37,8 @@ return new class extends Migration $table->string("handler_id")->comment("担当者ID")->nullable(); $table->datetime("order_datetime")->comment("依頼日時")->nullable(); $table->string("status")->comment("ステータス")->nullable(); - $table->string("sumamry_key1")->comment("集計キー1")->nullable(); - $table->string("sumamry_key2")->comment("集計キー2")->nullable(); + $table->string("summary_key1")->comment("集計キー1")->nullable(); + $table->string("summary_key2")->comment("集計キー2")->nullable(); $table->string("access_token")->comment("アクセストークン")->nullable(); $table->datetime("access_token_expires_at")->comment("アクセストークン有効期限日時")->nullable(); @@ -53,6 +53,7 @@ return new class extends Migration $table->string("receipt_shop_name")->comment("領収証_発行店名")->nullable(); $table->string("receipt_issuer")->comment("領収証_発行者名")->nullable(); $table->string("receipt_purpose")->comment("領収証_但書き")->nullable(); + $table->string("receipt_name")->comment("領収証_宛名")->nullable(); $table->string("receipt_invoice_no")->comment("領収証_インボイス登録番号")->nullable(); $table->string("receipt_amount")->comment("領収証_金額")->nullable(); $table->string("receipt_how_to_receive")->comment("領収証_取得希望方法")->nullable(); diff --git a/database/migrations/2023_04_18_131700_create_sms_send_orders_table.php b/database/migrations/2023_04_18_131700_create_sms_send_orders_table.php index 5f61ecc..de35c39 100644 --- a/database/migrations/2023_04_18_131700_create_sms_send_orders_table.php +++ b/database/migrations/2023_04_18_131700_create_sms_send_orders_table.php @@ -47,13 +47,13 @@ return new class extends Migration $table->text('content')->comment("本文")->nullable(); $table->text('phone_number')->comment("送信先電話番号")->nullable(); - $table->string("sumamry_key1")->comment("集計キー1")->nullable(); - $table->string("sumamry_key2")->comment("集計キー2")->nullable(); + $table->string("summary_key1")->comment("集計キー1")->nullable(); + $table->string("summary_key2")->comment("集計キー2")->nullable(); $helper->index(1, [ColumnName::CONTRACT_ID, 'send_datetime']); $helper->index(2, [ColumnName::CONTRACT_ID, 'done']); - $helper->index(3, [ColumnName::CONTRACT_ID, 'sumamry_key1', 'sumamry_key2']); + $helper->index(3, [ColumnName::CONTRACT_ID, 'summary_key1', 'summary_key2']); $helper->index(4, [ColumnName::CONTRACT_ID, 'done']); }; diff --git a/database/seeders/TestUserSeeder.php b/database/seeders/TestUserSeeder.php new file mode 100644 index 0000000..a44bb39 --- /dev/null +++ b/database/seeders/TestUserSeeder.php @@ -0,0 +1,54 @@ +create([ + Contract::COL_NAME_NAME => 'テスト用契約' + ]); + + $emails = [ + ['normal@aa.com', UserRole::NORMAL_ADMIN], + ['contract@aa.com', UserRole::CONTRACT_ADMIN], + ['admin@aa.com', UserRole::SUPER_ADMIN], + ]; + + foreach ($emails as [$email, $role]) { + if (!User::whereEmail($email)->exists()) { + User::factory()->for($contract)->create([ + User::COL_NAME_EMAIL => $email, + User::COL_NAME_ROLE => $role, + ]); + } + } + + $contract = Contract::factory()->create([ + Contract::COL_NAME_NAME => 'テスト用契約 HT', + Contract::COL_NAME_CUSTOM => Custom::HELLO_TECHNO, + ]); + + $email = 'hello@aa.com'; + if (!User::whereEmail($email)->exists()) { + User::factory()->for($contract)->create([ + User::COL_NAME_EMAIL => $email, + User::COL_NAME_ROLE => UserRole::NORMAL_ADMIN, + ]); + } + } +} diff --git a/docker/8.2/php.ini b/docker/8.2/php.ini index 39dcbca..2a6d903 100644 --- a/docker/8.2/php.ini +++ b/docker/8.2/php.ini @@ -5,3 +5,6 @@ variables_order = EGPCS [opcache] opcache.enable_cli=1 + +[xdebug] +xdebug.start_with_request=yes \ No newline at end of file diff --git a/routes/api.php b/routes/api.php index a2a44f1..a7f32eb 100644 --- a/routes/api.php +++ b/routes/api.php @@ -10,3 +10,15 @@ | be assigned to the "api" middleware group. Make something great! | */ + +use App\Util\RouteHelper; + +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); + +// 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::post('/custom/hello-techno/receipt-issuing-order/create', App\Http\Controllers\Web\Custom\HelloTechno\CreateReceiptIssuingOrderController::class); diff --git a/tests/Feature/SMSTest.php b/tests/Feature/SMSTest.php index d1f8526..fb30cc3 100644 --- a/tests/Feature/SMSTest.php +++ b/tests/Feature/SMSTest.php @@ -33,8 +33,8 @@ class SMSTest extends TestCase $receiptIssuingOurder->contract_id = $contract->id; $receiptIssuingOurder->status = "NEW"; - $receiptIssuingOurder->sumamry_key1 = "京都"; - $receiptIssuingOurder->sumamry_key2 = "駅前駐車場"; + $receiptIssuingOurder->summary_key1 = "京都"; + $receiptIssuingOurder->summary_key2 = "駅前駐車場"; $receiptIssuingOurder->sms_phone_number = "09093604589"; $receiptIssuingOurder->save();