Browse Source

異動履歴修正

develop
sosuke.iwabuchi 1 year ago
parent
commit
0b74edfcf6
7 changed files with 62 additions and 4 deletions
  1. +11
    -0
      app/Codes/DepositTransferReason.php
  2. +2
    -1
      app/Logics/QRService/CertificateLogic.php
  3. +3
    -1
      app/Logics/QRService/ChargeLogic.php
  4. +2
    -1
      app/Logics/QRService/CreateLogic.php
  5. +4
    -1
      app/Logics/QRService/DepositCheck.php
  6. +3
    -0
      app/Models/HtpmsCustomer/Deposit/DepositTransfer.php
  7. +37
    -0
      database/migrations/2024_04_01_140500_add_column_tbl3_dep_deposit_transfers.php

+ 11
- 0
app/Codes/DepositTransferReason.php View File

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

namespace App\Codes;

enum DepositTransferReason: string
{
case チャージ = "駐車料金割引(認証)";
case 駐車料金割引_認証 = "駐車料金割引_認証";
case 駐車料金割引_印字 = "駐車料金割引_印字";
case 駐車料金割引_取得 = "駐車料金割引_取得";
}

+ 2
- 1
app/Logics/QRService/CertificateLogic.php View File

@@ -2,6 +2,7 @@


namespace App\Logics\QRService; namespace App\Logics\QRService;


use App\Codes\DepositTransferReason;
use App\Exceptions\AppCommonException; use App\Exceptions\AppCommonException;
use App\Models\HtpmsCustomer\Mst\ShopNoRelation; use App\Models\HtpmsCustomer\Mst\ShopNoRelation;
use App\Models\HtpmsCustomer\QRService\CertificationAvailableSetting; use App\Models\HtpmsCustomer\QRService\CertificationAvailableSetting;
@@ -105,7 +106,7 @@ class CertificateLogic
$qr = self::getUsable($parkingManagementCode, $adjusterTerminalCode, $publishingDate, $seqNo); $qr = self::getUsable($parkingManagementCode, $adjusterTerminalCode, $publishingDate, $seqNo);


// デポジット処理 // デポジット処理
self::useDeposit($qr->shop_id, $discountAmount);
self::useDeposit($qr->shop_id, $discountAmount, DepositTransferReason::駐車料金割引_認証);
$qr->used_at = $adjustDatetime; $qr->used_at = $adjustDatetime;
$qr->discount_amount = $discountAmount; $qr->discount_amount = $discountAmount;
$qr->discount_ticket_code = $discountTicketCode; $qr->discount_ticket_code = $discountTicketCode;


+ 3
- 1
app/Logics/QRService/ChargeLogic.php View File

@@ -2,6 +2,7 @@


namespace App\Logics\QRService; namespace App\Logics\QRService;


use App\Codes\DepositTransferReason;


class ChargeLogic class ChargeLogic
{ {
@@ -18,9 +19,10 @@ class ChargeLogic


[$shop, $deposit] = self::getData($shopId); [$shop, $deposit] = self::getData($shopId);


$deposit->deposit += $amount;


$history = self::makeTransferHistory($shopId, $amount); $history = self::makeTransferHistory($shopId, $amount);
$deposit->deposit += $amount;
$history->transfer_reason = DepositTransferReason::チャージ;


$deposit->save(); $deposit->save();
$history->save(); $history->save();


+ 2
- 1
app/Logics/QRService/CreateLogic.php View File

@@ -2,6 +2,7 @@


namespace App\Logics\QRService; namespace App\Logics\QRService;


use App\Codes\DepositTransferReason;
use App\Exceptions\AppCommonException; use App\Exceptions\AppCommonException;
use App\Models\ColumnName; use App\Models\ColumnName;
use App\Models\HtpmsCustomer\QRService\AcquisitionAvailableSetting; use App\Models\HtpmsCustomer\QRService\AcquisitionAvailableSetting;
@@ -119,7 +120,7 @@ class CreateLogic
self::checkQrParkingGroup($qr->qr_service_parking_group_id, $parkingManagementCode); self::checkQrParkingGroup($qr->qr_service_parking_group_id, $parkingManagementCode);


// デポジット処理 // デポジット処理
self::useDeposit($qr->shop_id, $discountAmount);
self::useDeposit($qr->shop_id, $discountAmount, DepositTransferReason::駐車料金割引_取得);
$qr->discount_amount = $discountAmount; $qr->discount_amount = $discountAmount;


// 利用情報 // 利用情報


+ 4
- 1
app/Logics/QRService/DepositCheck.php View File

@@ -2,6 +2,7 @@


namespace App\Logics\QRService; namespace App\Logics\QRService;


use App\Codes\DepositTransferReason;
use App\Contexts\Model\Deposit as ContextDeposit; use App\Contexts\Model\Deposit as ContextDeposit;
use App\Contexts\Model\Shop as ContextShop; use App\Contexts\Model\Shop as ContextShop;
use App\Exceptions\AppCommonException; use App\Exceptions\AppCommonException;
@@ -32,6 +33,7 @@ trait DepositCheck
protected static function useDeposit( protected static function useDeposit(
string $shopId, string $shopId,
int $amount, int $amount,
DepositTransferReason $reason,
) { ) {
// データ取得 // データ取得
[$shop, $deposit] = self::getData($shopId); [$shop, $deposit] = self::getData($shopId);
@@ -42,6 +44,7 @@ trait DepositCheck


// 異動履歴作成 // 異動履歴作成
$history = self::makeTransferHistory($shopId, -1 * $amount); $history = self::makeTransferHistory($shopId, -1 * $amount);
$history->transfer_reason = $reason;


// デポジット減算 // デポジット減算
$deposit->deposit -= $amount; $deposit->deposit -= $amount;
@@ -60,7 +63,7 @@ trait DepositCheck
$transfer = new DepositTransfer(); $transfer = new DepositTransfer();
$transfer->shop_id = $shopId; $transfer->shop_id = $shopId;
$transfer->transfer_datetime = DateUtil::now(); $transfer->transfer_datetime = DateUtil::now();
$transfer->transfer_amount = -1 * $amount;
$transfer->transfer_amount = $amount;
$transfer->before_amount = $deposit->deposit; $transfer->before_amount = $deposit->deposit;
$transfer->after_amount = $deposit->deposit + $amount; $transfer->after_amount = $deposit->deposit + $amount;
return $transfer; return $transfer;


+ 3
- 0
app/Models/HtpmsCustomer/Deposit/DepositTransfer.php View File

@@ -2,6 +2,7 @@


namespace App\Models\HtpmsCustomer\Deposit; namespace App\Models\HtpmsCustomer\Deposit;


use App\Codes\DepositTransferReason;
use App\Models\Cast; use App\Models\Cast;
use App\Models\ColumnName; use App\Models\ColumnName;
use App\Models\HistoryModel; use App\Models\HistoryModel;
@@ -14,6 +15,7 @@ class DepositTransfer extends HtpmsCustomerAppModel
{ {
const COL_NAME_SHOP_ID = ColumnName::SHOP_ID; // 店舗ID const COL_NAME_SHOP_ID = ColumnName::SHOP_ID; // 店舗ID
const COL_NAME_TRANSFER_DATETIME = "transfer_datetime"; // 異動日時 const COL_NAME_TRANSFER_DATETIME = "transfer_datetime"; // 異動日時
const COL_NAME_TRANSFER_REASON = "transfer_reason"; // 異動理由
const COL_NAME_TRANSFER_AMOUNT = "transfer_amount"; // デポジット残高 const COL_NAME_TRANSFER_AMOUNT = "transfer_amount"; // デポジット残高
const COL_NAME_BEFORE_AMOUNT = "before_amount"; // 異動前デポジット const COL_NAME_BEFORE_AMOUNT = "before_amount"; // 異動前デポジット
const COL_NAME_AFTER_AMOUNT = "after_amount"; // 異動後デポジット const COL_NAME_AFTER_AMOUNT = "after_amount"; // 異動後デポジット
@@ -22,6 +24,7 @@ class DepositTransfer extends HtpmsCustomerAppModel


protected $casts = [ protected $casts = [
self::COL_NAME_TRANSFER_DATETIME => Cast::DATETIME, self::COL_NAME_TRANSFER_DATETIME => Cast::DATETIME,
self::COL_NAME_TRANSFER_REASON => DepositTransferReason::class,
]; ];


public function getHistory(): ?HistoryModel public function getHistory(): ?HistoryModel


+ 37
- 0
database/migrations/2024_04_01_140500_add_column_tbl3_dep_deposit_transfers.php View File

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

use App\Models\ColumnName;
use App\Util\MigrationHelper;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{

protected $connection = "htpms_customer";
/**
* Run the migrations.
*/
public function up(): void
{
$schema = function (Blueprint $table, MigrationHelper $helper) {

$table->string("transfer_reason")->nullable()->comment("異動理由");
};

MigrationHelper::alterTable("tbl3_dep_deposit_transfers", $schema);
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('tbl3_dep_deposit_transfers', function (Blueprint $table) {
if (Schema::hasColumn($table->getTable(), "transfer_reason")) {
$table->dropColumn("transfer_reason");
}
});
}
};

Loading…
Cancel
Save