# 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;
use Beike\Models\Customer;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Auth\Middleware\Authenticate as 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.
*

View File

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

View File

@ -18,7 +18,7 @@ class Brand extends Base
{
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
{

View File

@ -31,7 +31,14 @@ class BrandRepo
*/
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) {
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;
}

View File

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

View File

@ -104,6 +104,6 @@ class OrderController extends Controller
throw new \Exception('无效的订单');
}
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)
{
$product = ProductRepo::getProductDetail($product);
if ($product->active == 0) {
return redirect(shop_route('home.index'));
}
$data = [
'product' => (new ProductDetail($product))->jsonSerialize(),
];
@ -31,7 +34,7 @@ class ProductController extends Controller
* 通过关键字搜索产品
*
* @param Request $request
* @return AnonymousResourceCollection
* @return mixed
*/
public function search(Request $request)
{

View File

@ -5,7 +5,7 @@
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"php": "^7.4|^8.0",
"php": "^8.0.2",
"ext-json": "*",
"ext-zip": "*",
"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>@{{ brand.sort_order }}</td>
<td>@{{ brand.first }}</td>
<td>@{{ brand.status }}</td>
<td>
<span :class="brand.status ? 'text-success' : 'text-secondary'">@{{ brand.status ? '启用' : '禁用' }}</span>
</td>
<td>
<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>

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>
</tr>
</thead>
@ -28,10 +29,11 @@
<td>@{{ group.description?.name || '' }}</td>
<td>@{{ group.description?.description || '' }}</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.reward_point_factor }}</td>
<td>@{{ group.use_point_factor }}</td>
<td>@{{ group.use_point_factor }}</td> --}}
<td>
<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>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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