# Conflicts:
#	resources/lang/zh_cn/shop/account.php
This commit is contained in:
sl 2022-08-18 19:17:42 +08:00
commit 173af2594f
16 changed files with 79 additions and 23 deletions

View File

@ -2,12 +2,38 @@
namespace App\Http\Middleware; namespace App\Http\Middleware;
use Beike\Models\Customer;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Auth\AuthenticationException; use Illuminate\Auth\AuthenticationException;
use Illuminate\Auth\Middleware\Authenticate as Middleware; use Illuminate\Auth\Middleware\Authenticate as Middleware;
class ShopAuthenticate extends Middleware class ShopAuthenticate extends Middleware
{ {
/**
* Handle an incoming request.
*
* @param Request $request
* @param \Closure $next
* @param string[] ...$guards
* @return mixed
*
* @throws AuthenticationException
*/
public function handle($request, \Closure $next, ...$guards)
{
$this->authenticate($request, $guards);
$customer = current_customer();
if ($customer->status != 1) {
Auth::guard(Customer::AUTH_GUARD)->logout();
return redirect(shop_route('account.login'));
}
return $next($request);
}
/** /**
* Get the path the user should be redirected to when they are not authenticated. * Get the path the user should be redirected to when they are not authenticated.
* *

View File

@ -43,9 +43,9 @@ return [
| |
*/ */
'permissions' => [ 'permissions' => [
'storage/framework/' => '775', 'storage/framework/' => '755',
'storage/logs/' => '775', 'storage/logs/' => '755',
'bootstrap/cache/' => '775', 'bootstrap/cache/' => '755',
], ],
/* /*

View File

@ -18,7 +18,7 @@ class Brand extends Base
{ {
use HasFactory; use HasFactory;
protected $fillable = ['name', 'country_id', 'first', 'logo', 'code', 'sort_order', 'status']; protected $fillable = ['name', 'first', 'logo', 'sort_order', 'status'];
public function products() :HasMany public function products() :HasMany
{ {

View File

@ -31,7 +31,14 @@ class BrandRepo
*/ */
public static function create($data) public static function create($data)
{ {
return Brand::query()->create($data); $brandData = [
'name' => $data['name'] ?? '',
'first' => $data['first'] ?? '',
'logo' => $data['logo'] ?? '',
'sort_order' => (int)($data['sort_order'] ?? 0),
'status' => (bool)($data['status'] ?? 1),
];
return Brand::query()->create($brandData);
} }
/** /**
@ -48,7 +55,15 @@ class BrandRepo
if (!$brand) { if (!$brand) {
throw new Exception("品牌id $brand 不存在"); throw new Exception("品牌id $brand 不存在");
} }
$brand->update($data);
$brandData = [
'name' => $data['name'] ?? '',
'first' => $data['first'] ?? '',
'logo' => $data['logo'] ?? '',
'sort_order' => (int)($data['sort_order'] ?? 0),
'status' => (bool)($data['status'] ?? 1),
];
$brand->update($brandData);
return $brand; return $brand;
} }

View File

@ -14,11 +14,7 @@ namespace Beike\Shop\Http\Controllers\Account;
use Beike\Models\Customer; use Beike\Models\Customer;
use Beike\Shop\Http\Controllers\Controller; use Beike\Shop\Http\Controllers\Controller;
use Beike\Shop\Http\Requests\LoginRequest; use Beike\Shop\Http\Requests\LoginRequest;
use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth;
use function auth;
use function back;
use function redirect;
use function view;
class LoginController extends Controller class LoginController extends Controller
{ {
@ -36,6 +32,11 @@ class LoginController extends Controller
throw new \Exception("账号密码错误!"); throw new \Exception("账号密码错误!");
} }
$customer = current_customer();
if ($customer && $customer->status != 1) {
Auth::guard(Customer::AUTH_GUARD)->logout();
throw new \Exception("用户已被禁用!");
}
return json_success("登录成功!"); return json_success("登录成功!");
} }
} }

View File

@ -104,6 +104,6 @@ class OrderController extends Controller
throw new \Exception('无效的订单'); throw new \Exception('无效的订单');
} }
StateMachineService::getInstance($order)->changeStatus(StateMachineService::COMPLETED); StateMachineService::getInstance($order)->changeStatus(StateMachineService::COMPLETED);
return json_success(trans('shop/account.order_completed')); return json_success(trans('shop/account.order.completed'));
} }
} }

View File

@ -20,6 +20,9 @@ class ProductController extends Controller
public function show(Request $request, Product $product) public function show(Request $request, Product $product)
{ {
$product = ProductRepo::getProductDetail($product); $product = ProductRepo::getProductDetail($product);
if ($product->active == 0) {
return redirect(shop_route('home.index'));
}
$data = [ $data = [
'product' => (new ProductDetail($product))->jsonSerialize(), 'product' => (new ProductDetail($product))->jsonSerialize(),
]; ];
@ -31,7 +34,7 @@ class ProductController extends Controller
* 通过关键字搜索产品 * 通过关键字搜索产品
* *
* @param Request $request * @param Request $request
* @return AnonymousResourceCollection * @return mixed
*/ */
public function search(Request $request) public function search(Request $request)
{ {

View File

@ -5,7 +5,7 @@
"keywords": ["framework", "laravel"], "keywords": ["framework", "laravel"],
"license": "MIT", "license": "MIT",
"require": { "require": {
"php": "^7.4|^8.0", "php": "^8.0.2",
"ext-json": "*", "ext-json": "*",
"ext-zip": "*", "ext-zip": "*",
"doctrine/dbal": "^3.3", "doctrine/dbal": "^3.3",

View File

@ -27,7 +27,9 @@
<td><div class="wh-50"><img :src="thumbnail(brand.logo)" class="img-fluid"></div></td> <td><div class="wh-50"><img :src="thumbnail(brand.logo)" class="img-fluid"></div></td>
<td>@{{ brand.sort_order }}</td> <td>@{{ brand.sort_order }}</td>
<td>@{{ brand.first }}</td> <td>@{{ brand.first }}</td>
<td>@{{ brand.status }}</td> <td>
<span :class="brand.status ? 'text-success' : 'text-secondary'">@{{ brand.status ? '启用' : '禁用' }}</span>
</td>
<td> <td>
<button class="btn btn-outline-secondary btn-sm" @click="checkedCreate('edit', index)">编辑</button> <button class="btn btn-outline-secondary btn-sm" @click="checkedCreate('edit', index)">编辑</button>
<button class="btn btn-outline-danger btn-sm ml-1" type="button" @click="deleteItem(brand.id, index)">删除</button> <button class="btn btn-outline-danger btn-sm ml-1" type="button" @click="deleteItem(brand.id, index)">删除</button>

View File

@ -15,10 +15,11 @@
<th>名称</th> <th>名称</th>
<th>描述</th> <th>描述</th>
<th>等级</th> <th>等级</th>
<th>消费额度</th> <th>创建时间</th>
{{-- <th>消费额度</th>
<th>折扣率</th> <th>折扣率</th>
<th>奖励积分系数</th> <th>奖励积分系数</th>
<th>使用积分系数</th> <th>使用积分系数</th> --}}
<th>操作</th> <th>操作</th>
</tr> </tr>
</thead> </thead>
@ -28,10 +29,11 @@
<td>@{{ group.description?.name || '' }}</td> <td>@{{ group.description?.name || '' }}</td>
<td>@{{ group.description?.description || '' }}</td> <td>@{{ group.description?.description || '' }}</td>
<td>@{{ group.level }}</td> <td>@{{ group.level }}</td>
<td>@{{ group.total }}</td> <td>@{{ group.created_at }}</td>
{{-- <td>@{{ group.total }}</td>
<td>@{{ group.discount_factor }}</td> <td>@{{ group.discount_factor }}</td>
<td>@{{ group.reward_point_factor }}</td> <td>@{{ group.reward_point_factor }}</td>
<td>@{{ group.use_point_factor }}</td> <td>@{{ group.use_point_factor }}</td> --}}
<td> <td>
<button class="btn btn-outline-secondary btn-sm" @click="checkedCustomersCreate('edit', index)">编辑</button> <button class="btn btn-outline-secondary btn-sm" @click="checkedCustomersCreate('edit', index)">编辑</button>
<button class="btn btn-outline-danger btn-sm ml-1" type="button" @click="deleteCustomer(group.id, index)">删除</button> <button class="btn btn-outline-danger btn-sm ml-1" type="button" @click="deleteCustomer(group.id, index)">删除</button>

View File

@ -159,6 +159,7 @@
zipcode: '', zipcode: '',
zone_id: '', zone_id: '',
city: '', city: '',
city_id: '',
address_1: '', address_1: '',
address_2: '', address_2: '',
} }

View File

@ -52,7 +52,7 @@
const id = $(this).data('id'); const id = $(this).data('id');
const self = $(this); const self = $(this);
layer.confirm('确定要删除角色吗?', { layer.confirm('确定要删除页面吗?', {
title: "提示", title: "提示",
btn: ['取消', '确定'], btn: ['取消', '确定'],
area: ['400px'], area: ['400px'],

View File

@ -12,7 +12,11 @@
return [ return [
'list' => 'Order List', 'list' => 'Order List',
'orders_index' => 'Index', 'orders_index' => 'Index',
'unpaid' => 'Unpaid', 'unpaid' => 'Unpaid',
'shipped' => 'Shipped',
'completed' => 'Completed',
'orders_create' => 'Create', 'orders_create' => 'Create',
'orders_show' => 'Detail', 'orders_show' => 'Detail',
'orders_update' => 'Update', 'orders_update' => 'Update',

View File

@ -20,7 +20,7 @@ return [
'order' => [ 'order' => [
'index' => 'Order List', 'index' => 'Order List',
'order_completed' => 'Completed Order', 'completed' => 'Completed Order',
], ],
'addresses' => [ 'addresses' => [

View File

@ -12,7 +12,11 @@
return [ return [
'list' => '订单列表', 'list' => '订单列表',
'orders_index' => '订单列表', 'orders_index' => '订单列表',
'unpaid' => '待支付', 'unpaid' => '待支付',
'shipped' => '已发货',
'completed' => '已完成',
'orders_create' => '创建订单', 'orders_create' => '创建订单',
'orders_show' => '订单详情', 'orders_show' => '订单详情',
'orders_update' => '更新订单', 'orders_update' => '更新订单',

View File

@ -46,8 +46,6 @@ return [
'order' => [ 'order' => [
'index' => '订单列表', 'index' => '订单列表',
'show' => '订单详情',
'order_completed' => '已确认收货',
'order_details' => '订单详情', 'order_details' => '订单详情',
'amount' => '金额', 'amount' => '金额',
'state' => '状态', 'state' => '状态',