فهرست منبع

首页后台更改

bianjunhui 3 هفته پیش
والد
کامیت
1bb9675b23

+ 2 - 0
packages/Webkul/Admin/src/Http/Controllers/Settings/ThemeController.php

@@ -95,6 +95,7 @@ class ThemeController extends Controller
             'type'       => 'required|in:product_carousel,category_carousel,static_content,image_carousel,footer_links,services_content',
             'channel_id' => 'required|in:'.implode(',', (core()->getAllChannels()->pluck('id')->toArray())),
             'theme_code' => 'required',
+            'showstyle'  => 'nullable|string|max:50',
         ]);
 
         $locale = request('locale');
@@ -106,6 +107,7 @@ class ThemeController extends Controller
             'sort_order',
             'channel_id',
             'theme_code',
+            'showstyle',
             'status',
             $locale
         );

+ 1 - 0
packages/Webkul/Admin/src/Resources/lang/en/app.php

@@ -3635,6 +3635,7 @@ return [
                 'static-content'                => 'Static Content',
                 'static-content-description'    => 'Improve engagement with concise, informative static content for your audience.',
                 'status'                        => 'Status',
+                'showstyle'                     => 'Show Style',
                 'themes'                        => 'Themes',
                 'title'                         => 'Edit Theme',
                 'update-slider'                 => 'Update Slider',

+ 1 - 0
packages/Webkul/Admin/src/Resources/lang/zh_CN/app.php

@@ -3515,6 +3515,7 @@ return [
                 'static-content'                => '静态内容',
                 'static-content-description'    => '为您的受众提供简洁、信息丰富的静态内容,提高参与度。',
                 'status'                        => '状态',
+                'showstyle'                     => '展示样式',
                 'title'                         => '编辑主题',
                 'update-slider'                 => '更新滑块',
                 'url'                           => '网址',

+ 18 - 0
packages/Webkul/Admin/src/Resources/views/settings/themes/edit.blade.php

@@ -213,6 +213,24 @@
                                 <x-admin::form.control-group.error control-name="theme" />
                             </x-admin::form.control-group>
         
+                            <!-- Show Style -->
+                            <x-admin::form.control-group>
+                                <x-admin::form.control-group.label class="required">
+                                    @lang('admin::app.settings.themes.edit.showstyle')
+                                </x-admin::form.control-group.label>
+
+                                <x-admin::form.control-group.control
+                                    type="text"
+                                    name="showstyle"
+                                    rules="required"
+                                    :value="$theme->showstyle ?? 'style-1'"
+                                    :label="trans('admin::app.settings.themes.edit.showstyle')"
+                                    :placeholder="trans('admin::app.settings.themes.edit.showstyle')"
+                                />
+
+                                <x-admin::form.control-group.error control-name="showstyle" />
+                            </x-admin::form.control-group>
+
                             <!-- Status -->
                             <x-admin::form.control-group class="!mb-0">
                                 <x-admin::form.control-group.label class="required">

+ 73 - 0
packages/Webkul/Shop/src/Http/Controllers/API/CustomerController.php

@@ -6,13 +6,86 @@ use Illuminate\Http\JsonResponse;
 use Illuminate\Http\Request;
 use Illuminate\Http\Response;
 use Illuminate\Support\Facades\Cookie;
+use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Event;
 use Longyi\RewardPoints\Helpers\ApiResponse;
+use Longyi\RewardPoints\Repositories\RewardPointRepository;
+use Longyi\RewardPoints\Services\GrowthValueService;
 use Webkul\Customer\Models\Customer;
 use Webkul\Shop\Http\Requests\Customer\LoginRequest;
 
 class CustomerController extends APIController
 {
+    public function __construct(
+        protected RewardPointRepository $rewardPointRepository,
+        protected GrowthValueService $growthValueService
+    ) {}
+
+    /**
+     * 个人中心数据聚合接口(需登录)
+     *
+     * GET /api/customer/profile
+     *
+     * 返回:用户基础信息、成长值(VIP)、积分、优惠券数量、订单总数。
+     *
+     * @return JsonResponse
+     */
+    public function profile(): JsonResponse
+    {
+        $customer = auth()->guard('customer')->user();
+        if (! $customer) {
+            return ApiResponse::unauthorized();
+        }
+
+        // 1. 成长值 / VIP 信息
+        $growth = $this->growthValueService->getCustomerGrowthValue($customer->id);
+
+        // 2. 积分余额
+        $points = (int) $this->rewardPointRepository->getCustomerPoints($customer->id);
+
+        // 3. 优惠券数量(用户专属券,未过期)
+        $couponCount = (int) DB::table('cart_rule_coupons')
+            ->where('customer_id', $customer->id)
+            ->where(function ($query) {
+                $query->whereNull('expired_at')
+                    ->orWhere('expired_at', '>=', now());
+            })
+            ->count();
+
+        // 4. 订单总数
+        $orderCount = (int) DB::table('orders')
+            ->where('customer_id', $customer->id)
+            ->count();
+
+        return ApiResponse::success([
+            'user' => [
+                'id'         => $customer->id,
+                'name'       => $customer->name,
+                'first_name' => $customer->first_name,
+                'last_name'  => $customer->last_name,
+                'email'      => $customer->email,
+                'phone'      => $customer->phone,
+                'image_url'  => $customer->image_url,
+            ],
+            'growth' => [
+                'growth_value'          => (int) $growth['growth_value'],
+                'level_name'            => $growth['growth_level_name'] ?? null,
+                'discount_rate'         => $growth['growth_discount_rate'] ?? 0,
+                'level_icon'            => $growth['growth_level_icon'] ?? null,
+                'benefits'              => is_string($growth['growth_benefits'] ?? null)
+                    ? json_decode($growth['growth_benefits'], true)
+                    : ($growth['growth_benefits'] ?? []),
+                'next_level'            => $growth['next_level'] ?? null,
+                'growth_to_next_level'  => $growth['points_to_next_level'] ?? null,
+                'expires_at'            => $growth['expires_at'] ?? null,
+                'first_order_completed' => (bool) ($growth['first_order_completed'] ?? false),
+            ],
+            'points'       => $points,
+            'coupon_count' => $couponCount,
+            'order_count'  => $orderCount,
+        ]);
+    }
+
     /**
      * 验证邮箱是否已注册(无需登录)
      *

+ 8 - 0
packages/Webkul/Shop/src/Routes/api-token.php

@@ -32,6 +32,14 @@ Route::group(['prefix' => 'api'], function () {
             Route::get('check-email', 'checkEmail')->name('shop.api.customer.check-email');
         });
 
+    /** 个人中心数据(Bearer Token 认证,需登录) */
+    Route::controller(CustomerController::class)
+        ->middleware('bearer.token')
+        ->prefix('customer')
+        ->group(function () {
+            Route::get('profile', 'profile')->name('shop.api.token.customer.profile');
+        });
+
     /** 客户地址管理(Bearer Token 认证) */
     Route::controller(BearerAddressController::class)
         ->middleware('bearer.token')

+ 32 - 0
packages/Webkul/Theme/src/Database/Migrations/2026_09_23_000001_add_showstyle_to_theme_customizations_table.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     */
+    public function up(): void
+    {
+        Schema::table('theme_customizations', function (Blueprint $table) {
+            if (! Schema::hasColumn('theme_customizations', 'showstyle')) {
+                $table->string('showstyle', 50)->default('style-1')->after('status')->comment('展示样式');
+            }
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Schema::table('theme_customizations', function (Blueprint $table) {
+            if (Schema::hasColumn('theme_customizations', 'showstyle')) {
+                $table->dropColumn('showstyle');
+            }
+        });
+    }
+};

+ 1 - 0
packages/Webkul/Theme/src/Models/ThemeCustomization.php

@@ -92,6 +92,7 @@ class ThemeCustomization extends TranslatableModel implements ThemeCustomization
         'options',
         'sort_order',
         'status',
+        'showstyle',
         'channel_id',
         'theme_code',
     ];