|
|
|
@@ -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; |
|
|
|
|