sosuke.iwabuchi 1 год назад
Родитель
Сommit
0b74edfcf6
7 измененных файлов: 62 добавлений и 4 удалений
  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 Просмотреть файл

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

namespace App\Codes;

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

+ 2
- 1
app/Logics/QRService/CertificateLogic.php Просмотреть файл

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

namespace App\Logics\QRService;

use App\Codes\DepositTransferReason;
use App\Exceptions\AppCommonException;
use App\Models\HtpmsCustomer\Mst\ShopNoRelation;
use App\Models\HtpmsCustomer\QRService\CertificationAvailableSetting;
@@ -105,7 +106,7 @@ class CertificateLogic
$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->discount_amount = $discountAmount;
$qr->discount_ticket_code = $discountTicketCode;


+ 3
- 1
app/Logics/QRService/ChargeLogic.php Просмотреть файл

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

namespace App\Logics\QRService;

use App\Codes\DepositTransferReason;

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

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

$deposit->deposit += $amount;

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

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


+ 2
- 1
app/Logics/QRService/CreateLogic.php Просмотреть файл

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

namespace App\Logics\QRService;

use App\Codes\DepositTransferReason;
use App\Exceptions\AppCommonException;
use App\Models\ColumnName;
use App\Models\HtpmsCustomer\QRService\AcquisitionAvailableSetting;
@@ -119,7 +120,7 @@ class CreateLogic
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;

// 利用情報


+ 4
- 1
app/Logics/QRService/DepositCheck.php Просмотреть файл

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

namespace App\Logics\QRService;

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

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

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


+ 3
- 0
app/Models/HtpmsCustomer/Deposit/DepositTransfer.php Просмотреть файл

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

namespace App\Models\HtpmsCustomer\Deposit;

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

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

public function getHistory(): ?HistoryModel


+ 37
- 0
database/migrations/2024_04_01_140500_add_column_tbl3_dep_deposit_transfers.php Просмотреть файл

@@ -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");
}
});
}
};

Загрузка…
Отмена
Сохранить