| @@ -0,0 +1,43 @@ | |||
| <?php | |||
| namespace App\Http\Controllers\Web\Custom\HelloTechno; | |||
| use App\Codes\UserRole; | |||
| use App\Http\Controllers\Web\IParam; | |||
| use App\Util\Custom\HelloTechno\API; | |||
| use Illuminate\Http\JsonResponse; | |||
| use Illuminate\Http\Request; | |||
| class AdjustDataController extends HelloTechnoController | |||
| { | |||
| public function name(): string | |||
| { | |||
| return "[HelloTechno専用]精算履歴取得"; | |||
| } | |||
| public function description(): string | |||
| { | |||
| return "[HelloTechno専用]精算履歴を取得する"; | |||
| } | |||
| public function __construct( | |||
| protected AdjustDataParam $param, | |||
| ) { | |||
| parent::__construct(); | |||
| $this->roleAllow(UserRole::NORMAL_ADMIN); | |||
| } | |||
| protected function getParam(): IParam | |||
| { | |||
| return $this->param; | |||
| } | |||
| protected function run(Request $request): JsonResponse | |||
| { | |||
| $param = $this->param; | |||
| $adjustData = API::getAdjustData($param->customerCode, $param->parkingManagementCode, $param->adjustSeqNo); | |||
| return $this->successResponse($adjustData); | |||
| } | |||
| } | |||
| @@ -0,0 +1,22 @@ | |||
| <?php | |||
| namespace App\Http\Controllers\Web\Custom\HelloTechno; | |||
| use App\Http\Controllers\Web\BaseParam; | |||
| /** | |||
| * @property string $customerCode | |||
| * @property string $parkingManagementCode | |||
| * @property int $adjustSeqNo | |||
| */ | |||
| class AdjustDataParam extends BaseParam | |||
| { | |||
| public function rules(): array | |||
| { | |||
| return [ | |||
| 'customer_code' => $this->str(), | |||
| 'parking_management_code' => $this->str(), | |||
| 'adjust_seq_no' => $this->numeric(), | |||
| ]; | |||
| } | |||
| } | |||
| @@ -65,7 +65,7 @@ class CreateReceiptIssuingOrderController extends HelloTechnoController | |||
| 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_INVOICE_NO => $customer['invoice_no'], | |||
| Order::COL_NAME_RECEIPT_PURPOSE => "駐車料金", | |||
| Order::COL_NAME_RECEIPT_ISSUER => $customer['name'], | |||
| Order::COL_NAME_RECEIPT_SHOP_NAME => $parking['name'], | |||
| @@ -38,7 +38,7 @@ class ConfirmController extends WebController | |||
| $param = $this->param; | |||
| $this->manager->initById($param->id) | |||
| $this->manager->initByToken($param->accessToken) | |||
| ->checkTimestamp($param->timestamp) | |||
| ->fill( | |||
| [ | |||
| @@ -7,7 +7,7 @@ use App\Http\Controllers\Web\TimestampParam; | |||
| use App\Models\ReceiptIssuingOrder; | |||
| /** | |||
| * @property string $id | |||
| * @property string $accessToken | |||
| * @property string $receiptName | |||
| */ | |||
| @@ -17,7 +17,7 @@ class ConfirmParam extends BaseParam implements TimestampParam | |||
| { | |||
| return array_merge( | |||
| [ | |||
| ReceiptIssuingOrder::COL_NAME_ID => $this->str(), | |||
| ReceiptIssuingOrder::COL_NAME_ACCESS_TOKEN => $this->str(), | |||
| ReceiptIssuingOrder::COL_NAME_RECEIPT_NAME => $this->str(), | |||
| ], | |||
| $this->timestamp(), | |||
| @@ -47,6 +47,7 @@ class ReceiptIssuingOrder extends AppModel | |||
| const COL_NAME_MEMO = "memo"; | |||
| protected $casts = [ | |||
| self::COL_NAME_ORDER_DATETIME => 'datetime', | |||
| self::COL_NAME_ACCESS_TOKEN_EXPIRES_AT => 'datetime', | |||
| self::COL_NAME_STATUS_SMS_SEND_DATETIME => 'datetime', | |||
| self::COL_NAME_STATUS_FIRST_ACCESS_DATETIME => 'datetime', | |||
| @@ -35,6 +35,7 @@ class ReceiptIssuingOrderRepository extends BaseRepository | |||
| const CONDITION_ORDER_DATE_FROM = 'order_date_from'; | |||
| const CONDITION_ORDER_DATE_TO = 'order_date_to'; | |||
| const CONDITION_RECEIPT_NO = 'receipt_no'; | |||
| const TABLE_ORDER = "order"; | |||
| const TABLE_CUSTOM_ORDER = "custom_order"; | |||
| @@ -125,6 +126,10 @@ class ReceiptIssuingOrderRepository extends BaseRepository | |||
| $table->where($this->makeColumnName([static::TABLE_HANDLER, User::COL_NAME_NAME]), 'like', "%{$handlerName}%"); | |||
| } | |||
| // 領収証番号 | |||
| $this->where($table, $condition, static::CONDITION_RECEIPT_NO, $this->makeColumnName([static::TABLE_ORDER, ReceiptIssuingOrder::COL_NAME_RECEIPT_NO])); | |||
| $table->select($this->columns()); | |||
| $main = DB::table($table, "main"); | |||
| @@ -182,10 +187,11 @@ class ReceiptIssuingOrderRepository extends BaseRepository | |||
| $this->makeColumnNameForSelect([$order, ReceiptIssuingOrder::COL_NAME_MAIL_NAME]), | |||
| $this->makeColumnNameForSelect([$order, ReceiptIssuingOrder::COL_NAME_MEMO]), | |||
| $this->makeColumnNameForSelect([$order, ReceiptIssuingOrder::COL_NAME_UPDATED_AT]), | |||
| $this->makeColumnNameForSelect([$custom, CustomOrder::COL_NAME_CUSTOMER_CODE], 'customer_code'), | |||
| $this->makeColumnNameForSelect([$custom, CustomOrder::COL_NAME_PARKING_MANAGEMENT_CODE], 'parking_management_code'), | |||
| $this->makeColumnNameForSelect([$custom, CustomOrder::COL_NAME_CUSTOMER_NAME], 'customer_name'), | |||
| $this->makeColumnNameForSelect([$custom, CustomOrder::COL_NAME_PARKING_NAME], 'parking_name'), | |||
| $this->makeColumnNameForSelect([$custom, CustomOrder::COL_NAME_CUSTOMER_CODE]), | |||
| $this->makeColumnNameForSelect([$custom, CustomOrder::COL_NAME_PARKING_MANAGEMENT_CODE]), | |||
| $this->makeColumnNameForSelect([$custom, CustomOrder::COL_NAME_CUSTOMER_NAME]), | |||
| $this->makeColumnNameForSelect([$custom, CustomOrder::COL_NAME_PARKING_NAME]), | |||
| $this->makeColumnNameForSelect([$custom, CustomOrder::COL_NAME_ADJUST_SEQ_NO]), | |||
| $this->makeColumnNameForSelect([$handler, User::COL_NAME_ID], 'handler_id'), | |||
| $this->makeColumnNameForSelect([$handler, User::COL_NAME_NAME], 'handler_name'), | |||
| @@ -3,8 +3,10 @@ | |||
| namespace App\Util\Custom\HelloTechno; | |||
| use App\Exceptions\AppCommonException; | |||
| use App\Models\ReceiptIssuingHTParkingCustomOrder; | |||
| use App\Models\ReceiptIssuingOrder; | |||
| use Exception; | |||
| use Illuminate\Http\Client\Response; | |||
| use Illuminate\Support\Carbon; | |||
| use Illuminate\Support\Facades\Http; | |||
| use Illuminate\Support\Facades\Log; | |||
| @@ -19,6 +21,7 @@ class API | |||
| private const URL_CUSTOMERS = 'customers'; | |||
| private const URL_PARKINGS = 'parkings'; | |||
| private const URL_ADJUST_DATA = 'adjust-data'; | |||
| private const URL_RECEIPT_ISSUING_ORDER = 'receipt-issuing'; | |||
| private const CONFIG_KEY_API_HOST = "logic.custom.hellotechno.host"; | |||
| @@ -50,6 +53,12 @@ class API | |||
| return static::get(static::getAdjustDataUrl(), $query); | |||
| } | |||
| public static function sendReceiptIssuingOrder(ReceiptIssuingOrder $order, ReceiptIssuingHTParkingCustomOrder $customOrder) | |||
| { | |||
| $param = static::makeReceiptIssuingOrderParams($order, $customOrder); | |||
| return static::post(static::getReceiptIssuingOrderUrl(), $param); | |||
| } | |||
| private static function getHost(): string | |||
| { | |||
| return config(static::CONFIG_KEY_API_HOST, "http://localhost"); | |||
| @@ -73,6 +82,63 @@ class API | |||
| $condition = [static::getHost(), static::URL_ADJUST_DATA]; | |||
| return implode('/', $condition); | |||
| } | |||
| private static function getReceiptIssuingOrderUrl() | |||
| { | |||
| $condition = [static::getHost(), static::URL_RECEIPT_ISSUING_ORDER]; | |||
| return implode('/', $condition); | |||
| } | |||
| public static function makeReceiptIssuingOrderParams(ReceiptIssuingOrder $order, ReceiptIssuingHTParkingCustomOrder $customOrder): array | |||
| { | |||
| $param = []; | |||
| $param['id'] = $order->id; | |||
| $param['customer_code'] = $customOrder->customer_code; | |||
| $param['parking_management_code'] = $customOrder->parking_management_code; | |||
| $param['adjust_seq_no'] = $customOrder->adjust_seq_no; | |||
| $param['order_datetime'] = static::formatDateTimeStr($order->order_datetime); | |||
| $param['status_done'] = $order->status_done; | |||
| $param['status_sms_send_datetime'] = static::formatDateTimeStr($order->status_sms_send_datetime); | |||
| $param['status_first_access_datetime'] = static::formatDateTimeStr($order->status_first_access_datetime); | |||
| $param['status_receipt_confirm_datetime'] = static::formatDateTimeStr($order->status_receipt_confirm_datetime); | |||
| $param['status_order_mail_datetime'] = static::formatDateTimeStr($order->status_order_mail_datetime); | |||
| $param['status_mail_download_datetime'] = static::formatDateTimeStr($order->status_mail_download_datetime); | |||
| $param['status_mail_post_date'] = static::formatDateStr($order->status_mail_post_date); | |||
| $param['status_receipt_download_datetime'] = static::formatDateTimeStr($order->status_receipt_download_datetime); | |||
| $param['status_receipt_email_send_order_datetime'] = static::formatDateTimeStr($order->status_receipt_email_send_order_datetime); | |||
| $param['status_receipt_email_send_datetime'] = static::formatDateTimeStr($order->status_receipt_email_send_datetime); | |||
| $param['sms_phone_number'] = $order->sms_phone_number; | |||
| $param['sms_send_success'] = $order->sms_send_success; | |||
| $param['receipt_no'] = $order->receipt_no; | |||
| $param['receipt_use_date'] = $order->receipt_use_date; | |||
| $param['receipt_shop_name'] = $order->receipt_shop_name; | |||
| $param['receipt_issuer'] = $order->receipt_issuer; | |||
| $param['receipt_purpose'] = $order->receipt_purpose; | |||
| $param['receipt_name'] = $order->receipt_name; | |||
| $param['receipt_invoice_no'] = $order->receipt_invoice_no; | |||
| $param['receipt_amount'] = $order->receipt_amount; | |||
| $param['email'] = $order->email; | |||
| $param['mail_pref_code'] = $order->mail_pref_code; | |||
| $param['mail_zip_code'] = $order->mail_zip_code; | |||
| $param['mail_address1'] = $order->mail_address1; | |||
| $param['mail_address2'] = $order->mail_address2; | |||
| $param['mail_address3'] = $order->mail_address3; | |||
| $param['mail_name'] = $order->mail_name; | |||
| $param['updated_at'] = $order->updated_at; | |||
| return $param; | |||
| } | |||
| private static function formatDateStr(?Carbon $date): ?string | |||
| { | |||
| if ($date === null) return null; | |||
| return $date->format('Y-m-d'); | |||
| } | |||
| private static function formatDateTimeStr(?Carbon $date): ?string | |||
| { | |||
| if ($date === null) return null; | |||
| return $date->format('Y-m-d H:i:s'); | |||
| } | |||
| private static function get(string $url, array $query = []) | |||
| { | |||
| @@ -94,4 +160,25 @@ class API | |||
| throw $e; | |||
| } | |||
| } | |||
| private static function post(string $url, array $param = []) | |||
| { | |||
| try { | |||
| $res = Http::post($url, $param); | |||
| 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; | |||
| } | |||
| } | |||
| } | |||
| @@ -40,6 +40,7 @@ RouteHelper::post('/user/change-password', App\Http\Controllers\Web\LoginUser\Ch | |||
| // 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\AdjustDataController::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); | |||