后台顾客管理

This commit is contained in:
TL 2022-06-30 10:08:24 +08:00
parent 524e316d1e
commit eca27b0966
7 changed files with 31 additions and 11 deletions

View File

@ -14,7 +14,7 @@ class Customer extends Authenticatable
const AUTH_GUARD = 'web_shop';
protected $fillable = ['name', 'email', 'password', 'status', 'avatar', 'customer_group_id', 'language_id', 'status', 'from'];
protected $fillable = ['name', 'email', 'password', 'status', 'avatar', 'customer_group_id', 'locale', 'status', 'from'];
public function addresses(): HasMany
{

View File

@ -13,4 +13,16 @@ class CustomerGroup extends Model
use HasFactory;
protected $fillable = ['total', 'reward_point_factor', 'use_point_factor', 'discount_factor', 'level'];
public function description()
{
return $this->hasOne(CustomerGroupDescription::class)->where('locale', locale());
}
public function descriptions()
{
return $this->hasMany(CustomerGroupDescription::class);
}
}

View File

@ -0,0 +1,13 @@
<?php
namespace Beike\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class CustomerGroupDescription extends Model
{
use HasFactory;
protected $fillable = ['locale', 'name', 'description'];
}

View File

@ -64,12 +64,7 @@ class CustomerGroupRepo
public static function list()
{
$builder = CustomerGroup::query()
->leftJoin('customer_group_descriptions AS cgd', function ($join) {
$join->on('cgd.customer_group_id', 'customer_groups.id')
->where('cgd.language_id', current_language_id());
})
->select(['customer_groups.*', 'cgd.name', 'cgd.description']);
$builder = CustomerGroup::query();
$groups = $builder->get();
return $groups;

View File

@ -68,7 +68,7 @@ class CustomerRepo
->leftJoin('customer_groups AS cg', 'customers.customer_group_id', 'cg.id')
->leftJoin('customer_group_descriptions AS cgd', function ($join) {
$join->on('cgd.customer_group_id', 'cg.id')
->where('cgd.language_id', current_language_id());
->where('cgd.locale', locale());
})
->select(['customers.id', 'customers.email', 'customers.name', 'customers.avatar', 'customers.status', 'customers.from', 'cgd.name AS customer_group_name']);

View File

@ -28,7 +28,7 @@ class AccountService
$data['customer_group_id'] = setting('default_customer_group_id', 1); // default_customer_group_id为默认客户组名称
$data['status'] = !setting('approve_customer'); // approve_customer为是否需要审核客户
$data['from'] = $data['from'] ?? 'pc';
$data['language_id'] = current_language_id();
$data['locale'] = locale();
$data['name'] = '';
$data['avatar'] = '';

View File

@ -20,7 +20,7 @@ class CreateCustomerTable extends Migration
$table->string('name');
$table->string('avatar')->default('');
$table->unsignedInteger('customer_group_id');
$table->unsignedInteger('language_id');
$table->string('locale', 10);
$table->text('cart')->nullable();
$table->tinyInteger('status')->default(0);
$table->string('code', 40)->default('');
@ -42,7 +42,7 @@ class CreateCustomerTable extends Migration
Schema::create('customer_group_descriptions', function (Blueprint $table) {
$table->id();
$table->unsignedInteger('customer_group_id');
$table->unsignedInteger('language_id');
$table->string('locale', 10);
$table->string('name', 256);
$table->text('description');
$table->timestamps();