|
@@ -5,6 +5,7 @@ namespace Longyi\Gift\Http\Controllers\Admin;
|
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
use Illuminate\View\View;
|
|
use Illuminate\View\View;
|
|
|
use Longyi\Gift\Models\GiftCards;
|
|
use Longyi\Gift\Models\GiftCards;
|
|
|
|
|
+use Longyi\Gift\Models\GiftCardUsageLog;
|
|
|
use Webkul\Admin\Http\Controllers\Controller;
|
|
use Webkul\Admin\Http\Controllers\Controller;
|
|
|
use Longyi\Gift\DataGrids\GiftCards\GiftCardsDataGrid;
|
|
use Longyi\Gift\DataGrids\GiftCards\GiftCardsDataGrid;
|
|
|
use Longyi\Gift\Repositories\GiftCardsRepository;
|
|
use Longyi\Gift\Repositories\GiftCardsRepository;
|
|
@@ -62,7 +63,17 @@ class GiftController extends Controller
|
|
|
$data['remaining_giftcard_amount'] = $data['giftcard_amount'] ?? 0;
|
|
$data['remaining_giftcard_amount'] = $data['giftcard_amount'] ?? 0;
|
|
|
|
|
|
|
|
$this->giftCardsRepository->create($data);
|
|
$this->giftCardsRepository->create($data);
|
|
|
-
|
|
|
|
|
|
|
+ // 记录使用日志
|
|
|
|
|
+ GiftCardUsageLog::create([
|
|
|
|
|
+ 'giftcard_number' => $data['giftcard_number'],
|
|
|
|
|
+ 'customer_id' => $data['customer_id'],
|
|
|
|
|
+ 'used_amount' => 0,
|
|
|
|
|
+ 'balance_before' => $data['giftcard_amount'],
|
|
|
|
|
+ 'balance_after' => $data['giftcard_amount'],
|
|
|
|
|
+ 'action_type' => GiftCardUsageLog::ACTION_ADD,
|
|
|
|
|
+ 'status' => 'completed',
|
|
|
|
|
+ 'notes' => "Administrator addition",
|
|
|
|
|
+ ]);
|
|
|
if (request()->expectsJson()) {
|
|
if (request()->expectsJson()) {
|
|
|
return new JsonResponse([
|
|
return new JsonResponse([
|
|
|
'message' => '礼品卡创建成功',
|
|
'message' => '礼品卡创建成功',
|