From 0e395eb9869011258df892e2e20ad72c1a380418 Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Tue, 17 May 2022 17:50:30 +0800 Subject: [PATCH] pay --- .../{UserEditVip.php => UserEditAgent.php} | 6 +- app/Admin/Controllers/AgentController.php | 107 ++++++++++++++++ app/Admin/Controllers/UserController.php | 14 +-- app/Admin/Controllers/UserVipController.php | 78 ++++++++++++ app/Admin/Controllers/VipController.php | 43 +++---- .../{UserEditVip.php => UserEditAgent.php} | 33 ++--- app/Admin/Renderable/UserFansSimpleTable.php | 8 +- .../Renderable/UserInviterSimpleTable.php | 8 +- app/Admin/routes.php | 7 +- app/Console/Commands/ModelFillable.php | 4 + app/Models/Agent.php | 27 ++++ app/Models/User.php | 16 ++- app/Models/UserVip.php | 14 ++- app/Models/Vip.php | 28 ++++- app/Services/DistributeService.php | 34 ++--- app/Services/VipService.php | 56 +++++++++ .../2021_12_03_135905_create_vips_table.php | 21 +++- ...21_12_03_135913_create_user_vips_table.php | 34 ----- .../2021_12_07_143655_create_orders_table.php | 14 +++ ...6_140921_add_coupon_id_to_orders_table.php | 32 ----- ...113_add_shipping_state_to_orders_table.php | 32 ----- ...115137_add_sales_value_to_orders_table.php | 32 ----- ...5_094822_add_is_change_to_orders_table.php | 34 ----- ...11510_add_trade_out_no_to_orders_table.php | 32 ----- ...7_add_auto_complete_at_to_orders_table.php | 32 ----- ..._06_112225_add_bargain_to_orders_table.php | 35 ------ ...22_05_06_133819_add_role_to_user_infos.php | 9 +- ..._05_06_160615_add_invitor_id_to_orders.php | 36 ------ ...2022_05_17_145958_create_agents_table.php} | 12 +- database/seeders/AdminMenuSeeder.php | 15 ++- database/seeders/AdminPermissionSeeder.php | 2 +- .../{VipSeeder.php => AgentSeeder.php} | 6 +- database/seeders/DatabaseSeeder.php | 3 +- database/seeders/UserSeeder.php | 8 +- database/seeders/VipsTableSeeder.php | 27 ++++ dcat_admin_ide_helper.php | 116 +++++++++++++----- resources/lang/zh_CN/agent.php | 19 +++ resources/lang/zh_CN/user-vip.php | 21 ++++ resources/lang/zh_CN/user.php | 6 +- resources/lang/zh_CN/vip.php | 14 ++- 40 files changed, 614 insertions(+), 461 deletions(-) rename app/Admin/Actions/Show/{UserEditVip.php => UserEditAgent.php} (78%) create mode 100644 app/Admin/Controllers/AgentController.php create mode 100644 app/Admin/Controllers/UserVipController.php rename app/Admin/Forms/{UserEditVip.php => UserEditAgent.php} (57%) create mode 100644 app/Models/Agent.php create mode 100644 app/Services/VipService.php delete mode 100644 database/migrations/2021_12_03_135913_create_user_vips_table.php delete mode 100644 database/migrations/2021_12_16_140921_add_coupon_id_to_orders_table.php delete mode 100644 database/migrations/2021_12_16_194113_add_shipping_state_to_orders_table.php delete mode 100644 database/migrations/2021_12_23_115137_add_sales_value_to_orders_table.php delete mode 100644 database/migrations/2021_12_25_094822_add_is_change_to_orders_table.php delete mode 100644 database/migrations/2021_12_27_111510_add_trade_out_no_to_orders_table.php delete mode 100644 database/migrations/2021_12_28_140737_add_auto_complete_at_to_orders_table.php delete mode 100644 database/migrations/2022_04_06_112225_add_bargain_to_orders_table.php delete mode 100644 database/migrations/2022_05_06_160615_add_invitor_id_to_orders.php rename database/migrations/{2022_05_07_174547_add_slug_to_vips.php => 2022_05_17_145958_create_agents_table.php} (60%) rename database/seeders/{VipSeeder.php => AgentSeeder.php} (93%) create mode 100644 database/seeders/VipsTableSeeder.php create mode 100644 resources/lang/zh_CN/agent.php create mode 100644 resources/lang/zh_CN/user-vip.php diff --git a/app/Admin/Actions/Show/UserEditVip.php b/app/Admin/Actions/Show/UserEditAgent.php similarity index 78% rename from app/Admin/Actions/Show/UserEditVip.php rename to app/Admin/Actions/Show/UserEditAgent.php index 6bc6f4b2..0f0272cb 100644 --- a/app/Admin/Actions/Show/UserEditVip.php +++ b/app/Admin/Actions/Show/UserEditAgent.php @@ -2,11 +2,11 @@ namespace App\Admin\Actions\Show; -use App\Admin\Forms\UserEditVip as UserEditVipForm; +use App\Admin\Forms\UserEditAgent as UserEditAgentForm; use Dcat\Admin\Show\AbstractTool; use Dcat\Admin\Widgets\Modal; -class UserEditVip extends AbstractTool +class UserEditAgent extends AbstractTool { /** * @return string @@ -22,7 +22,7 @@ class UserEditVip extends AbstractTool public function render() { - $form = UserEditVipForm::make()->payload(['id'=>$this->getKey()]); + $form = UserEditAgentForm::make()->payload(['id'=>$this->getKey()]); return Modal::make() ->lg() ->title($this->title) diff --git a/app/Admin/Controllers/AgentController.php b/app/Admin/Controllers/AgentController.php new file mode 100644 index 00000000..9c8fa148 --- /dev/null +++ b/app/Admin/Controllers/AgentController.php @@ -0,0 +1,107 @@ +column('sort'); + $grid->column('name'); + $grid->column('ratio')->display(function ($value) { + return $value . '%'; + }); + $grid->column('growth_value'); + + $grid->model()->orderBy('sort', 'asc'); + + /** 操作 **/ + //新增 + if (Admin::user()->can('dcat.admin.vips.create')) { + $grid->disableCreateButton(false); + $grid->enableDialogCreate(); + } + //修改 + $grid->showQuickEditButton(Admin::user()->can('dcat.admin.vips.edit')); + //删除以及自定义操作 + $grid->actions(function (Grid\Displayers\Actions $actions) { + $actions->disableDelete(Admin::user()->cannot('dcat.admin.vips.destroy')); + }); + + $grid->filter(function (Grid\Filter $filter) { + $filter->panel(false); + $filter->like('name')->width(3); + }); + }); + } + + /** + * Make a show builder. + * + * @param mixed $id + * + * @return Show + */ + protected function detail($id) + { + return Show::make($id, new Agent(), function (Show $show) { + $show->field('id'); + $show->field('name'); + $show->field('sort'); + $show->filed('slug'); + $show->column('ratio')->as(function ($value) { + return $value . '%'; + }); + $show->field('growth_value'); + $show->field('created_at'); + $show->field('updated_at'); + }); + } + + /** + * Make a form builder. + * + * @return Form + */ + protected function form() + { + return Form::make(new Agent(), function (Form $form) { + $form->display('id'); + $form->number('sort')->min(1)->required()->help('不可重复')->rules(function (Form $form) { + $rule = Rule::unique('vips'); + if ($id = $form->model()->id) { + $rule->ignore($id); + } + return $rule; + }); + $form->text('name')->required(); + $form->radio('slug')->options(Agent::$typeMap)->default(Agent::TYPE_FAVOITE); + $form->number('ratio')->min(0)->max(100)->help('例如: 60%, 填写 60 即可'); + $form->number('growth_value')->min(0)->default(0)->help('升级到此等级所需的成长值'); + }); + } + + public function destroy($id) + { + $vip = Agent::findOrFail($id); + if ($vip->hasUser()) { + throw new BizException(__('vip.options.deny_message')); + } + return parent::destroy($id); + } +} diff --git a/app/Admin/Controllers/UserController.php b/app/Admin/Controllers/UserController.php index 6ed4d2ed..0dc7a045 100644 --- a/app/Admin/Controllers/UserController.php +++ b/app/Admin/Controllers/UserController.php @@ -9,7 +9,7 @@ use App\Admin\Actions\Grid\UserResetAccountPassword; use App\Admin\Actions\Grid\UserResetPassword; use App\Admin\Actions\Show\UserEditBank; use App\Admin\Actions\Show\UserEditPhone; -use App\Admin\Actions\Show\UserEditVip; +use App\Admin\Actions\Show\UserEditAgent; use App\Admin\Renderable\Grid\Filter\PriceBetween; use App\Admin\Renderable\UserBalanceLogSimpleTable; use App\Admin\Renderable\UserFansSimpleTable; @@ -42,7 +42,7 @@ class UserController extends AdminController */ protected function grid() { - $builder = User::with(['userInfo', 'wallet', 'balance', 'userInfo.inviterInfo.user', 'userVip.vip']); + $builder = User::with(['userInfo', 'wallet', 'balance', 'userInfo.inviterInfo.user', 'agent']); return Grid::make($builder, function (Grid $grid) { $grid->model()->whereNotNull('phone'); $grid->column('id')->sortable()->if(function () { @@ -62,7 +62,7 @@ class UserController extends AdminController $modal->title('成长值'); return UserSalesValueLogSimpleTable::make(['id'=>$this->id]); })->setHeaderAttributes(['style' => 'color:#5b69bc']); - $grid->column('userVip.vip.name'); + $grid->column('agent.name', '代理'); // $grid->column('wallet.balance')->display(function ($value) { // $value = bcdiv($value, 100, 2); // if ($this->wallet?->is_frozen) { @@ -154,8 +154,8 @@ class UserController extends AdminController $column->row(Show::make($id, $builder, function (Show $show) { $show->row(function (Show\Row $show) { $show->width(6)->field('id'); - $show->width(6)->field('vip', '代理')->as(function () { - return $this->userVip ? $this->userVip->vip->name . '(' .$this->userVip->vip->ratio. '%)' : ''; + $show->width(6)->field('agent', '代理')->as(function () { + return $this->agent ? $this->agent->name . '(' .$this->agent->ratio. '%)' : ''; })->badge(); $show->width(6)->field('phone'); $show->field('user_info.inviter_info.user.phone'); @@ -199,8 +199,8 @@ class UserController extends AdminController // $tools->append(new UserEditBank()); // } // 设置代理等级 - if (Admin::user()->can('dcat.admin.users.edit_vip')) { - $tools->append(new UserEditVip()); + if (Admin::user()->can('dcat.admin.users.agent')) { + $tools->append(new UserEditAgent()); } }); })); diff --git a/app/Admin/Controllers/UserVipController.php b/app/Admin/Controllers/UserVipController.php new file mode 100644 index 00000000..e8598d8e --- /dev/null +++ b/app/Admin/Controllers/UserVipController.php @@ -0,0 +1,78 @@ +column('user.phone'); + $grid->column('vip.name'); + $grid->column('times')->display(function ($v) { + return data_get($v, 'text'); + }); + $grid->column('success_time'); + $grid->column('created_at'); + + $grid->disableViewButton(false); + + $grid->filter(function (Grid\Filter $filter) { + $filter->panel(false); + $filter->like('name')->width(3); + }); + }); + } + + /** + * Make a show builder. + * + * @param mixed $id + * + * @return Show + */ + protected function detail($id) + { + return Show::make($id, UserVip::with(['user', 'vip']), function (Show $show) { + $show->field('id'); + $show->field('user_id'); + $show->field('vip_id'); + $show->field('times')->as(function ($v) { + return data_get($v, 'text'); + });; + $show->field('success_time'); + $show->field('created_at'); + $show->field('updated_at'); + }); + } + + /** + * Make a form builder. + * + * @return Form + */ + protected function form() + { + return Form::make(new UserVip(), function (Form $form) { + $form->display('id'); + $form->text('user_id'); + $form->text('vip_id'); + $form->text('times'); + $form->text('success_time'); + + $form->display('created_at'); + $form->display('updated_at'); + }); + } +} diff --git a/app/Admin/Controllers/VipController.php b/app/Admin/Controllers/VipController.php index a11b8963..c45148dc 100644 --- a/app/Admin/Controllers/VipController.php +++ b/app/Admin/Controllers/VipController.php @@ -9,7 +9,6 @@ use Dcat\Admin\Form; use Dcat\Admin\Grid; use Dcat\Admin\Http\Controllers\AdminController; use Dcat\Admin\Show; -use Illuminate\Validation\Rule; class VipController extends AdminController { @@ -21,16 +20,16 @@ class VipController extends AdminController protected function grid() { return Grid::make(new Vip(), function (Grid $grid) { - $grid->column('sort'); + + $grid->column('id'); $grid->column('name'); - $grid->column('ratio')->display(function ($value) { - return $value . '%'; + $grid->column('times')->display(function ($v) { + return data_get($v, 'text'); }); - $grid->column('growth_value'); + $grid->column('price'); + $grid->column('sort')->editable(); + $grid->column('status')->switch(); - $grid->model()->orderBy('sort', 'asc'); - - /** 操作 **/ //新增 if (Admin::user()->can('dcat.admin.vips.create')) { $grid->disableCreateButton(false); @@ -62,12 +61,12 @@ class VipController extends AdminController return Show::make($id, new Vip(), function (Show $show) { $show->field('id'); $show->field('name'); - $show->field('sort'); - $show->filed('slug'); - $show->column('ratio')->as(function ($value) { - return $value . '%'; + $show->field('times')->as(function ($v) { + return data_get($v, 'text'); }); - $show->field('growth_value'); + $show->filed('price'); + $show->filed('sort'); + $show->field('status'); $show->field('created_at'); $show->field('updated_at'); }); @@ -82,17 +81,15 @@ class VipController extends AdminController { return Form::make(new Vip(), function (Form $form) { $form->display('id'); - $form->number('sort')->min(1)->required()->help('不可重复')->rules(function (Form $form) { - $rule = Rule::unique('vips'); - if ($id = $form->model()->id) { - $rule->ignore($id); - } - return $rule; - }); $form->text('name')->required(); - $form->radio('slug')->options(Vip::$typeMap)->default(Vip::TYPE_FAVOITE); - $form->number('ratio')->min(0)->max(100)->help('例如: 60%, 填写 60 即可'); - $form->number('growth_value')->min(0)->default(0)->help('升级到此等级所需的成长值'); + $form->embeds('times', function ($form) { + $form->number('num', '数量')->min(0)->required(); + $form->select('unit', '单位')->options(Vip::$timeMap)->required(); + $form->text('text', '描述')->required(); + }); + $form->number('price')->min(0); + $form->number('sort')->min(0); + $form->switch('status')->default(1); }); } diff --git a/app/Admin/Forms/UserEditVip.php b/app/Admin/Forms/UserEditAgent.php similarity index 57% rename from app/Admin/Forms/UserEditVip.php rename to app/Admin/Forms/UserEditAgent.php index 2dda8cc6..0b880c46 100644 --- a/app/Admin/Forms/UserEditVip.php +++ b/app/Admin/Forms/UserEditAgent.php @@ -2,14 +2,14 @@ namespace App\Admin\Forms; -use App\Models\{User, Vip}; +use App\Models\{User, Agent}; use Dcat\Admin\Contracts\LazyRenderable; use Dcat\Admin\Traits\LazyWidget; use Dcat\Admin\Widgets\Form; use Illuminate\Support\Facades\DB; use Throwable; -class UserEditVip extends Form implements LazyRenderable +class UserEditAgent extends Form implements LazyRenderable { use LazyWidget; @@ -34,24 +34,12 @@ class UserEditVip extends Form implements LazyRenderable { $id = $this->payload['id'] ?? 0; $user = User::findOrFail($id); - $vip_id = $input['vip']; + $agent_id = $input['agent']; try { DB::beginTransaction(); - if ($user->userVip) { - if ($vip_id) { - $user->userVip->update([ - 'vip_id' => $vip_id - ]); - } else { - $user->userVip->delete(); - } - } else { - if ($vip_id) { - $user->userVip()->create([ - 'vip_id' => $vip_id - ]); - } - } + $user->update([ + 'agent_id' => $agent_id + ]); DB::commit(); } catch (Throwable $th) { DB::rollBack(); @@ -68,11 +56,10 @@ class UserEditVip extends Form implements LazyRenderable public function form() { $id = $this->payload['id'] ?? 0; - $user = User::findOrFail($id); - $vips = Vip::orderBy('sort')->get(); + $user = User::with(['agent'])->findOrFail($id); + $agents = Agent::orderBy('sort')->get(); - $this->text('user_vip', '当前代理')->value(data_get($user, 'userVip.vip.name', '无'))->disable(); - - $this->select('vip')->options($vips->pluck('name', 'id')); + $this->text('user_agent', '当前代理')->value(data_get($user, 'agent.name', '无'))->disable(); + $this->select('agent')->options($agents->pluck('name', 'id')); } } diff --git a/app/Admin/Renderable/UserFansSimpleTable.php b/app/Admin/Renderable/UserFansSimpleTable.php index b3fbd30b..d1699b93 100644 --- a/app/Admin/Renderable/UserFansSimpleTable.php +++ b/app/Admin/Renderable/UserFansSimpleTable.php @@ -12,15 +12,15 @@ class UserFansSimpleTable extends LazyRenderable { $userId = $this->payload['id'] ?? 0; $builder = UserInfo::query(); - $builder->with(['user.userVip.vip'])->where('inviter_id', $userId); + $builder->with(['user.agent'])->where('inviter_id', $userId); return Grid::make($builder, function (Grid $grid) { $grid->column('user_id', 'ID'); $grid->column('user.phone', '手机号')->link(function ($value) { return admin_url('users/'.$this->user_id); }); - $grid->column('user.userVip.vip.name', '代理'); - $grid->column('user.userVip.vip.ratio', '提成比例')->display(function ($v) { - return $v.'%'; + $grid->column('user.agent.name', '代理'); + $grid->column('user.agent.ratio', '提成比例')->display(function ($v) { + return $v ? $v.'%' : ''; }); $grid->column('growth_value', '成长值'); $grid->column('created_at', '注册时间'); diff --git a/app/Admin/Renderable/UserInviterSimpleTable.php b/app/Admin/Renderable/UserInviterSimpleTable.php index bd74379d..a6628de3 100644 --- a/app/Admin/Renderable/UserInviterSimpleTable.php +++ b/app/Admin/Renderable/UserInviterSimpleTable.php @@ -13,16 +13,16 @@ class UserInviterSimpleTable extends LazyRenderable $userId = $this->payload['id'] ?? 0; $userInfo = UserInfo::where('user_id', $userId)->first(); $builder = UserInfo::query(); - $builder->with(['user.userVip.vip'])->whereIn('user_id', $userInfo->parent_ids)->latest('depth'); + $builder->with(['user.agent'])->whereIn('user_id', $userInfo->parent_ids)->latest('depth'); return Grid::make($builder, function (Grid $grid) { $grid->column('user_id', 'ID'); $grid->column('user.phone', '手机号')->link(function ($value) { return admin_url('users/'.$this->user_id); }); - $grid->column('user.userVip.vip.name', '代理'); - $grid->column('user.userVip.vip.ratio', '提成比例')->display(function ($v) { - return $v.'%'; + $grid->column('user.agent.name', '代理'); + $grid->column('user.agent.ratio', '提成比例')->display(function ($v) { + return $v ? $v.'%' : ''; }); $grid->column('growth_value', '成长值'); $grid->column('created_at', '注册时间'); diff --git a/app/Admin/routes.php b/app/Admin/routes.php index 905b4ca4..c7669529 100644 --- a/app/Admin/routes.php +++ b/app/Admin/routes.php @@ -88,8 +88,6 @@ Route::group([ $router->resource('users', 'UserController'); - $router->resource('vips', 'VipController'); - $router->resource('messages', 'MessageController')->only([ 'index', 'create', 'store', 'edit', 'update', 'destroy', ]); @@ -182,4 +180,9 @@ Route::group([ $router->resource('store', 'Store\StoreController'); $router->resource('profit', 'OrderProfitController'); + + $router->resource('agent', 'AgentController'); + + $router->resource('user-vip', 'UserVipController')->only(['index', 'show']); + $router->resource('vip', 'VipController'); }); diff --git a/app/Console/Commands/ModelFillable.php b/app/Console/Commands/ModelFillable.php index 3cf72ee8..796cb4dd 100644 --- a/app/Console/Commands/ModelFillable.php +++ b/app/Console/Commands/ModelFillable.php @@ -38,9 +38,13 @@ class ModelFillable extends Command public function handle() { $table = $this->argument('table'); + $ignore = ['id', 'created_at', 'updated_at', 'deleted_at']; if (Schema::hasTable($table)) { $list = Schema::getColumnListing($table); + $list = array_filter($list, function ($value) use ($ignore) { + return !in_array($value, $ignore); + }); $this->info("protected \$fillable = ['".implode('\', \'', $list)."'];"); } } diff --git a/app/Models/Agent.php b/app/Models/Agent.php new file mode 100644 index 00000000..8d4be55b --- /dev/null +++ b/app/Models/Agent.php @@ -0,0 +1,27 @@ + '爱好者', + self::TYPE_AGENT => '代理' + ]; + + public function users() + { + return $this->hasMany(User::class, 'agent_id'); + } +} diff --git a/app/Models/User.php b/app/Models/User.php index 6b83b599..5d6db0a9 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -49,6 +49,8 @@ class User extends Model implements AuthorizableContract, AuthenticatableContrac 'register_ip', 'status', 'status_remark', + 'agent_id', + 'vip_expired' ]; /** @@ -58,6 +60,7 @@ class User extends Model implements AuthorizableContract, AuthenticatableContrac 'phone_verified_at' => 'datetime', 'email_verified_at' => 'datetime', 'last_login_at' => 'datetime', + 'vip_expired' => 'datetime', 'status' => 'int', ]; @@ -85,11 +88,11 @@ class User extends Model implements AuthorizableContract, AuthenticatableContrac } /** - * 用户的VIP信息 + * 用户的VIP购买记录 */ - public function userVip() + public function vips() { - return $this->hasOne(UserVip::class, 'user_id'); + return $this->hasMany(UserVip::class, 'user_id'); } /** @@ -152,7 +155,7 @@ class User extends Model implements AuthorizableContract, AuthenticatableContrac */ public function isVip(): bool { - return $this->userInfo?->growth_value >= 650; + return $this->vip_expired && $this->vip_expired->gt(now()) ? true : false; } /** @@ -263,6 +266,11 @@ class User extends Model implements AuthorizableContract, AuthenticatableContrac return $this->hasMany(BargainOrder::class); } + public function agent() + { + return $this->belongsTo(Agent::class, 'agent_id'); + } + /** * 获取我的粉丝总数 * diff --git a/app/Models/UserVip.php b/app/Models/UserVip.php index 70a368dd..a66599df 100644 --- a/app/Models/UserVip.php +++ b/app/Models/UserVip.php @@ -9,14 +9,20 @@ class UserVip extends Model { use HasFactory; - protected $fillable = ['vip_id', 'growth_value']; + protected $fillable = ['user_id', 'vip_id', 'name', 'price', 'times', 'gift', 'status', 'success_time']; - protected $attributes = [ - 'growth_value' => 0 - ]; + public function user() + { + return $this->belongsTo(User::class, 'user_id'); + } public function vip() { return $this->belongsTo(Vip::class, 'vip_id'); } + + public function pay() + { + return $this->morphOne(PayLog::class, 'payable'); + } } diff --git a/app/Models/Vip.php b/app/Models/Vip.php index 7c740ab6..f021002b 100644 --- a/app/Models/Vip.php +++ b/app/Models/Vip.php @@ -5,21 +5,37 @@ namespace App\Models; use Dcat\Admin\Traits\HasDateTimeFormatter; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use App\Casts\JsonArray; +use Illuminate\Database\Eloquent\Builder; class Vip extends Model { use HasFactory, HasDateTimeFormatter; - const TYPE_FAVOITE = 'favoite'; - const TYPE_AGENT = 'agent'; + const TIME_YEAR = 'year'; + const TIME_MONTH = 'month'; + const TIME_DAY = 'day'; - protected $fillable = ['growth_value', 'name', 'ratio', 'slug', 'sort']; + protected $fillable = ['name', 'times', 'sort', 'status', 'gift', 'price']; - public static $typeMap = [ - self::TYPE_FAVOITE => '爱好者', - self::TYPE_AGENT => '代理' + protected $casts = [ + 'times' => 'json', + 'gift' => 'json' ]; + public static $timeMap = [ + self::TIME_YEAR => '年', + self::TIME_MONTH => '月', + self::TIME_DAY => '天', + ]; + + protected static function booted() + { + static::addGlobalScope('sort', function (Builder $builder) { + $builder->orderBy('sort', 'asc'); + }); + } + public function users() { return $this->belongsToMany(User::class, 'user_vips', 'vip_id', 'user_id'); diff --git a/app/Services/DistributeService.php b/app/Services/DistributeService.php index 596e36ac..bc5adf20 100644 --- a/app/Services/DistributeService.php +++ b/app/Services/DistributeService.php @@ -2,7 +2,7 @@ namespace App\Services; -use App\Models\{User, Order, SalesValueLog, Vip, OrderProfit}; +use App\Models\{User, Order, SalesValueLog, Agent, OrderProfit}; use App\Services\Payment\WxpayService; use App\Enums\SocialiteType; use App\Exceptions\BizException; @@ -42,7 +42,7 @@ class DistributeService ]); $user->userInfo()->increment('growth_value', $sales_value); // 自动升级代理 - $levels = Vip::orderBy('sort')->get(); + $levels = Agent::orderBy('sort')->get(); $level_up = ''; foreach($levels->reverse() as $item) { if ($user->userInfo->growth_value >= $item->growth_value) { @@ -50,47 +50,47 @@ class DistributeService } } if ($level_up && $level_up->slug === 'favoite') { - $user->userVip()->updateOrCreate([], [ - 'vip_id' => $level_up->id, - 'growth_value' => $level_up->growth_value + $user->update([ + 'agent_id' => $level_up->id, ]); } - // 上级返现 + // 上级返利 $parent_ids = array_reverse($user->userInfo->parent_ids); - $parents = User::with(['userInfo', 'userVip.vip'])->whereIn('id', $parent_ids)->get(); + $parents = User::with(['userInfo', 'agent'])->whereIn('id', $parent_ids)->get(); // 过滤掉不是代理身份的用户 // 过滤掉当前等级 大于 下一级的等级的用户 $filtered = $parents->filter(function ($item, $key) use ($parents) { - if (!$item->userVip) { + if (!$item->agent) { return false; } $next = $parents->get($key + 1); - if ($next && $next->userVip) { - return $item->userVip->vip->sort < $next->userVip->vip->sort; + if ($next && $next->agent) { + return $item->agent->sort < $next->agent->sort; } return true; }); - // 生成返现记录 + // 生成返利记录 $profit_list = []; $money_sum = 0; foreach($filtered->reverse() as $item) { - $vip = $item->userVip->vip??''; - if (!$vip) { + $agent = $item->agent??''; + if (!$agent) { continue; } - $money = floor($sales_value * $vip->ratio) / 100 - $money_sum; + $money = floor($sales_value * $agent->ratio) / 100 - $money_sum; array_unshift($profit_list, [ 'from_user_id' => $user->id, 'user_id' => $item->id, - 'role' => $vip->slug . '-' . $vip->sort, - 'role_name' => $vip->name, - 'ratio' => $vip->ratio, + 'role' => $agent->slug . '-' . $agent->sort, + 'role_name' => $agent->name, + 'ratio' => $agent->ratio, 'growth_value' => $sales_value, 'money' => $money ]); $money_sum += $money; } + // 订单保存返利金额 $order->update([ 'profit' => $money_sum ]); diff --git a/app/Services/VipService.php b/app/Services/VipService.php new file mode 100644 index 00000000..a007563c --- /dev/null +++ b/app/Services/VipService.php @@ -0,0 +1,56 @@ +status) { + throw new BizException('该会员卡已关闭'); + } + $user_vip = $user->vips()->create([ + 'vip_id' => $vip->id, + 'name' => $vip->name, + 'price' => $vip->price, + 'times' => $vip->times, + 'gift' => $vip->gift, + ]); + + return $user_vip; + } + + public function pay(UserVip $userVip, $pay_way) + { + if ($userVip->status == 2) { + throw new BizException('支付处理中,请勿重复操作'); + } + $userVip->update([ + 'status' => 2 + ]); + $pay_log = $user_vip->pay()->create([ + 'pay_sn' => serial_number(), + 'pay_way' => $pay_way + ]); + // 微信小程序支付 + if ($pay_log->pay_way === PayWay::WxpayMiniProgram->value) { + $openid = $user->socialites()->where('socialite_type', SocialiteType::WechatMiniProgram)->value('socialite_id'); + if (!$openid) { + throw new BizException('未找到用户的微信授权信息, 无法使用微信支付'); + } + $params = [ + 'body' => app_settings('app.app_name').'-会员-' . $userVip->name, + 'out_trade_no' => $pay_log->pay_sn, + 'total_fee' => $userVip->price, + 'trade_type' => 'JSAPI', + 'openid' => $openid, + ]; + } + throw new BizException('未知的支付方式'); + } +} diff --git a/database/migrations/2021_12_03_135905_create_vips_table.php b/database/migrations/2021_12_03_135905_create_vips_table.php index a59aaae6..e79d689c 100644 --- a/database/migrations/2021_12_03_135905_create_vips_table.php +++ b/database/migrations/2021_12_03_135905_create_vips_table.php @@ -15,8 +15,24 @@ class CreateVipsTable extends Migration { Schema::create('vips', function (Blueprint $table) { $table->id(); - $table->string('name')->comment('等级名称'); - $table->unsignedBigInteger('growth_value')->default(0)->comment('等级成长值'); + $table->string('name')->comment('名称'); + $table->text('times')->comment('时效{num,unit,text}'); + $table->decimal('price', 12, 2)->default(0)->comment('价格'); + $table->unsignedInteger('sort')->default(1)->comment('排序(asc)'); + $table->tinyInteger('status')->default(1)->comment('状态'); + $table->text('gift')->nullable()->comment('赠品'); + $table->timestamps(); + }); + Schema::create('user_vips', function (Blueprint $table) { + $table->id(); + $table->unsignedBigInteger('user_id')->unique()->comment('用户ID'); + $table->unsignedBigInteger('vip_id')->comment('会员ID'); + $table->string('name')->comment('名称'); + $table->decimal('price', 12, 2)->default(0)->comment('价格'); + $table->text('times')->comment('时效{num,unit,text}'); + $table->text('gift')->nullable()->comment('赠品'); + $table->tinyInteger('status')->default(0)->comment('状态(0: 待支付, 1: 支付成功)'); + $table->timestamp('success_time')->nullable()->comment('购买时间'); $table->timestamps(); }); } @@ -29,5 +45,6 @@ class CreateVipsTable extends Migration public function down() { Schema::dropIfExists('vips'); + Schema::dropIfExists('user_vips'); } } diff --git a/database/migrations/2021_12_03_135913_create_user_vips_table.php b/database/migrations/2021_12_03_135913_create_user_vips_table.php deleted file mode 100644 index 41a88a8a..00000000 --- a/database/migrations/2021_12_03_135913_create_user_vips_table.php +++ /dev/null @@ -1,34 +0,0 @@ -id(); - $table->unsignedBigInteger('user_id')->unique()->comment('用户ID'); - $table->unsignedBigInteger('vip_id')->comment('会员等级ID'); - $table->unsignedBigInteger('growth_value')->comment('当前会员成长值'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('user_vips'); - } -} diff --git a/database/migrations/2021_12_07_143655_create_orders_table.php b/database/migrations/2021_12_07_143655_create_orders_table.php index 06631fcb..40d33f13 100644 --- a/database/migrations/2021_12_07_143655_create_orders_table.php +++ b/database/migrations/2021_12_07_143655_create_orders_table.php @@ -22,6 +22,7 @@ class CreateOrdersTable extends Migration $table->unsignedBigInteger('reduced_amount')->default(0)->comment('减免金额'); $table->unsignedBigInteger('shipping_fee')->default(0)->comment('运费'); $table->unsignedBigInteger('products_total_amount')->comment('商品总额'); + $table->unsignedBigInteger('user_coupon_id')->nullable()->comment('用户优惠券ID'); $table->unsignedBigInteger('total_amount')->comment('订单总额(支付金额)=商品总额+运费-优惠券金额-会员优惠-减免金额'); $table->string('note')->nullable()->comment('客户备注'); $table->string('remark')->nullable()->comment('订单备注'); @@ -35,9 +36,22 @@ class CreateOrdersTable extends Migration $table->string('consignee_zone')->nullable()->comment('收货人所在地区'); $table->string('consignee_address')->nullable()->comment('收货人详细地址'); $table->tinyInteger('status')->default(0)->comment('订单状态: 0 待付款, 1 已付款, 9 已完成, 10 已取消'); + $table->tinyInteger('shipping_state')->index()->default(0)->comment('发货状态'); $table->timestamp('completed_at')->nullable()->comment('订单完成时间'); $table->timestamps(); + $table->unsignedDecimal('sales_value', 18, 2)->default(0.00)->comment('总销售值'); + $table->decimal('profit')->default(0)->comment('产生的提成'); + $table->unsignedBigInteger('store_id')->nullable()->comment('关联门店'); + $table->unsignedBigInteger('inviter_id')->nullable()->comment('关联员工'); + $table->string('source_type')->nullable()->comment('来源'); + $table->unsignedBigInteger('source_id')->nullable()->comment('来源'); + + $table->unsignedTinyInteger('is_change')->default(0)->comment('是否是换货后生成的新订单'); + $table->string('out_trade_no')->nullable()->comment('外部交易单号'); + $table->timestamp('auto_complete_at')->nullable()->comment('订单自动完成时间'); + $table->unsignedBigInteger('bargain_amount')->nullable()->default(0)->comment('砍价金额'); + $table->unique('sn'); $table->index(['user_id', 'status']); $table->index('status'); diff --git a/database/migrations/2021_12_16_140921_add_coupon_id_to_orders_table.php b/database/migrations/2021_12_16_140921_add_coupon_id_to_orders_table.php deleted file mode 100644 index 4531051b..00000000 --- a/database/migrations/2021_12_16_140921_add_coupon_id_to_orders_table.php +++ /dev/null @@ -1,32 +0,0 @@ -unsignedBigInteger('user_coupon_id')->nullable()->comment('用户优惠券ID'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('orders', function (Blueprint $table) { - $table->dropColumn(['user_coupon_id']); - }); - } -} diff --git a/database/migrations/2021_12_16_194113_add_shipping_state_to_orders_table.php b/database/migrations/2021_12_16_194113_add_shipping_state_to_orders_table.php deleted file mode 100644 index 5295b11e..00000000 --- a/database/migrations/2021_12_16_194113_add_shipping_state_to_orders_table.php +++ /dev/null @@ -1,32 +0,0 @@ -tinyInteger('shipping_state')->index()->default(0)->comment('发货状态'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('orders', function (Blueprint $table) { - $table->dropColumn(['shipping_state']); - }); - } -} diff --git a/database/migrations/2021_12_23_115137_add_sales_value_to_orders_table.php b/database/migrations/2021_12_23_115137_add_sales_value_to_orders_table.php deleted file mode 100644 index e376f99f..00000000 --- a/database/migrations/2021_12_23_115137_add_sales_value_to_orders_table.php +++ /dev/null @@ -1,32 +0,0 @@ -unsignedDecimal('sales_value', 18, 2)->default(0.00)->comment('总销售值'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('orders', function (Blueprint $table) { - $table->dropColumn(['sales_value']); - }); - } -} diff --git a/database/migrations/2021_12_25_094822_add_is_change_to_orders_table.php b/database/migrations/2021_12_25_094822_add_is_change_to_orders_table.php deleted file mode 100644 index 18c6e487..00000000 --- a/database/migrations/2021_12_25_094822_add_is_change_to_orders_table.php +++ /dev/null @@ -1,34 +0,0 @@ -unsignedTinyInteger('is_change')->default(0)->comment('是否是换货后生成的新订单'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('orders', function (Blueprint $table) { - // - $table->dropColumn('is_change'); - }); - } -} diff --git a/database/migrations/2021_12_27_111510_add_trade_out_no_to_orders_table.php b/database/migrations/2021_12_27_111510_add_trade_out_no_to_orders_table.php deleted file mode 100644 index a820daa7..00000000 --- a/database/migrations/2021_12_27_111510_add_trade_out_no_to_orders_table.php +++ /dev/null @@ -1,32 +0,0 @@ -string('out_trade_no')->nullable()->comment('外部交易单号'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('orders', function (Blueprint $table) { - $table->dropColumn(['out_trade_no']); - }); - } -} diff --git a/database/migrations/2021_12_28_140737_add_auto_complete_at_to_orders_table.php b/database/migrations/2021_12_28_140737_add_auto_complete_at_to_orders_table.php deleted file mode 100644 index fc4d9628..00000000 --- a/database/migrations/2021_12_28_140737_add_auto_complete_at_to_orders_table.php +++ /dev/null @@ -1,32 +0,0 @@ -timestamp('auto_complete_at')->nullable()->comment('订单自动完成时间'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('orders', function (Blueprint $table) { - $table->dropColumn(['auto_complete_at']); - }); - } -} diff --git a/database/migrations/2022_04_06_112225_add_bargain_to_orders_table.php b/database/migrations/2022_04_06_112225_add_bargain_to_orders_table.php deleted file mode 100644 index 47135845..00000000 --- a/database/migrations/2022_04_06_112225_add_bargain_to_orders_table.php +++ /dev/null @@ -1,35 +0,0 @@ -unsignedBigInteger('bargain_amount')->nullable()->default(0)->comment('砍价金额'); - // $table->unsignedBigInteger('bargain_order_id')->nullable()->comment('关联砍价单ID'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('orders', function (Blueprint $table) { - // - $table->dropColumn(['bargain_amount']); - }); - } -} diff --git a/database/migrations/2022_05_06_133819_add_role_to_user_infos.php b/database/migrations/2022_05_06_133819_add_role_to_user_infos.php index 203a3712..131aa904 100644 --- a/database/migrations/2022_05_06_133819_add_role_to_user_infos.php +++ b/database/migrations/2022_05_06_133819_add_role_to_user_infos.php @@ -18,6 +18,10 @@ class AddRoleToUserInfos extends Migration $table->tinyInteger('is_company')->default(0)->comment('是否员工'); $table->string('invite_qrcode')->nullable()->comment('小程序邀请码'); }); + Schema::table('users', function (Blueprint $table) { + $table->unsignedBigInteger('agent_id')->nullable()->comment('代理身份'); + $table->timestamp('vip_expired')->nullable()->comment('会员有效期'); + }); } /** @@ -28,7 +32,10 @@ class AddRoleToUserInfos extends Migration public function down() { Schema::table('user_infos', function (Blueprint $table) { - $table->dropColumn(['profit', 'is_company']); + $table->dropColumn(['profit', 'is_company', 'invite_qrcode', 'agent_id']); + }); + Schema::table('users', function (Blueprint $table) { + $table->dropColumn(['agent_id']); }); } } diff --git a/database/migrations/2022_05_06_160615_add_invitor_id_to_orders.php b/database/migrations/2022_05_06_160615_add_invitor_id_to_orders.php deleted file mode 100644 index 9885a6d5..00000000 --- a/database/migrations/2022_05_06_160615_add_invitor_id_to_orders.php +++ /dev/null @@ -1,36 +0,0 @@ -decimal('profit')->default(0)->comment('产生的提成'); - $table->unsignedBigInteger('store_id')->nullable()->comment('关联门店'); - $table->unsignedBigInteger('inviter_id')->nullable()->comment('关联员工'); - $table->string('source_type')->nullable()->comment('来源'); - $table->unsignedBigInteger('source_id')->nullable()->comment('来源'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('orders', function (Blueprint $table) { - $table->dropColumn(['store_id', 'inviter_id']); - }); - } -} diff --git a/database/migrations/2022_05_07_174547_add_slug_to_vips.php b/database/migrations/2022_05_17_145958_create_agents_table.php similarity index 60% rename from database/migrations/2022_05_07_174547_add_slug_to_vips.php rename to database/migrations/2022_05_17_145958_create_agents_table.php index 560fc5fb..f8ec32e1 100644 --- a/database/migrations/2022_05_07_174547_add_slug_to_vips.php +++ b/database/migrations/2022_05_17_145958_create_agents_table.php @@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class AddSlugToVips extends Migration +class CreateAgentsTable extends Migration { /** * Run the migrations. @@ -13,10 +13,14 @@ class AddSlugToVips extends Migration */ public function up() { - Schema::table('vips', function (Blueprint $table) { + Schema::create('agents', function (Blueprint $table) { + $table->id(); + $table->string('name')->comment('等级名称'); $table->string('slug')->comment('标识'); + $table->unsignedBigInteger('growth_value')->default(0)->comment('等级成长值'); $table->unsignedInteger('sort')->comment('等级'); $table->integer('ratio')->comment('返佣比例, 10 => 10%'); + $table->timestamps(); }); } @@ -27,8 +31,6 @@ class AddSlugToVips extends Migration */ public function down() { - Schema::table('vips', function (Blueprint $table) { - $table->dropColumn(['slug', 'ratio', 'sort']); - }); + Schema::dropIfExists('agents'); } } diff --git a/database/seeders/AdminMenuSeeder.php b/database/seeders/AdminMenuSeeder.php index 0dedbb0e..c9645a12 100644 --- a/database/seeders/AdminMenuSeeder.php +++ b/database/seeders/AdminMenuSeeder.php @@ -24,18 +24,27 @@ class AdminMenuSeeder extends Seeder 'uri' => '/', ], [ - 'title' => '会员管理', + 'title' => '用户管理', 'icon' => 'fa fa-users', 'uri' => '', 'children' => [ [ - 'title' => '会员列表', + 'title' => '用户列表', 'icon' => '', 'uri' => 'users', ], - ['title' => '代理等级', 'icon' => '', 'uri' => 'vips'] + ['title' => '代理等级', 'icon' => '', 'uri' => 'agent'] ], ], + [ + 'title' => '会员卡管理', + 'icon' => 'fa fa-credit-card-alt', + 'uri' => '', + 'children' => [ + ['title' => '会员卡', 'icon' => '', 'uri' => 'vip'], + ['title' => '购买记录', 'icon' => '', 'uri' => 'user-vip'], + ] + ], [ 'title' => '商城管理', 'icon' => 'fa fa-shopping-bag', diff --git a/database/seeders/AdminPermissionSeeder.php b/database/seeders/AdminPermissionSeeder.php index d673da93..78bbd0e8 100644 --- a/database/seeders/AdminPermissionSeeder.php +++ b/database/seeders/AdminPermissionSeeder.php @@ -84,7 +84,7 @@ class AdminPermissionSeeder extends Seeder 'reset_account_password'=>['name' =>'修改安全密码'], 'edit_phone'=>['name' =>'修改手机号'], 'edit_bank'=>['name'=>'修改银行卡'], - 'edit_vip'=>['name'=>'设置代理'], + 'agent'=>['name'=>'设置代理'], ], ], 'article_categories' =>[ diff --git a/database/seeders/VipSeeder.php b/database/seeders/AgentSeeder.php similarity index 93% rename from database/seeders/VipSeeder.php rename to database/seeders/AgentSeeder.php index 96aaaf53..12f857bd 100644 --- a/database/seeders/VipSeeder.php +++ b/database/seeders/AgentSeeder.php @@ -3,9 +3,9 @@ namespace Database\Seeders; use Illuminate\Database\Seeder; -use App\Models\Vip; +use App\Models\Agent; -class VipSeeder extends Seeder +class AgentSeeder extends Seeder { /** * Run the database seeds. @@ -23,6 +23,6 @@ class VipSeeder extends Seeder ['name' => '银级爱好者', 'slug' => 'favoite', 'growth_value' => 50000, 'ratio' => 20, 'sort' => 5, 'created_at' => $time, 'updated_at' => $time], ['name' => '铜级爱好者', 'slug' => 'favoite', 'growth_value' => 5000, 'ratio' => 10, 'sort' => 6, 'created_at' => $time, 'updated_at' => $time], ]; - Vip::insert($list); + Agent::insert($list); } } diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index cd89ae51..b336c11f 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -18,7 +18,8 @@ class DatabaseSeeder extends Seeder AdminMenuSeeder::class, AdminPermissionSeeder::class, AppSettingSeeder::class, - VipSeeder::class, + AgentSeeder::class, + VipsTableSeeder::class, AdminUserSeeder::class, ]); diff --git a/database/seeders/UserSeeder.php b/database/seeders/UserSeeder.php index 96ea80c1..ee969aa9 100644 --- a/database/seeders/UserSeeder.php +++ b/database/seeders/UserSeeder.php @@ -58,13 +58,9 @@ class UserSeeder extends Seeder 'email' => $email, 'email_verified_at' => $time, 'register_ip' => $faker->ipv4, - 'status' => 1 + 'status' => 1, + 'agent_id' => ($vip && $vip <= 6) ? $vip : null ], $inviter); - if ($vip && $vip <= 6) { - $user->userVip()->create([ - 'vip_id' => $vip - ]); - } return $user; } diff --git a/database/seeders/VipsTableSeeder.php b/database/seeders/VipsTableSeeder.php new file mode 100644 index 00000000..baf21167 --- /dev/null +++ b/database/seeders/VipsTableSeeder.php @@ -0,0 +1,27 @@ + '年卡', 'times' => json_encode(['text' => '1年', 'num' => 1, 'unit' => 'year']), 'price' => 100, 'created_at' => $time, 'updated_at' => $time], + ['name' => '季卡', 'times' => json_encode(['text' => '3月', 'num' => 3, 'unit' => 'month']), 'price' => 25, 'created_at' => $time, 'updated_at' => $time], + ['name' => '月卡', 'times' => json_encode(['text' => '1月', 'num' => 1, 'unit' => 'month']), 'price' => 10, 'created_at' => $time, 'updated_at' => $time], + ]; + Vip::insert($list); + } +} diff --git a/dcat_admin_ide_helper.php b/dcat_admin_ide_helper.php index bea5cfbe..8f1305f1 100644 --- a/dcat_admin_ide_helper.php +++ b/dcat_admin_ide_helper.php @@ -12,6 +12,7 @@ namespace Dcat\Admin { /** * @property Grid\Column|Collection width + * @property Grid\Column|Collection filed * @property Grid\Column|Collection id * @property Grid\Column|Collection cover * @property Grid\Column|Collection content @@ -69,6 +70,8 @@ namespace Dcat\Admin { * @property Grid\Column|Collection state * @property Grid\Column|Collection tracking_number * @property Grid\Column|Collection sales_value + * @property Grid\Column|Collection growth_value + * @property Grid\Column|Collection ratio * @property Grid\Column|Collection v * @property Grid\Column|Collection cate * @property Grid\Column|Collection is_force @@ -150,6 +153,9 @@ namespace Dcat\Admin { * @property Grid\Column|Collection is_failed * @property Grid\Column|Collection checked_at * @property Grid\Column|Collection last_news + * @property Grid\Column|Collection store_id + * @property Grid\Column|Collection products + * @property Grid\Column|Collection others * @property Grid\Column|Collection spu_id * @property Grid\Column|Collection specs * @property Grid\Column|Collection weight @@ -167,28 +173,28 @@ namespace Dcat\Admin { * @property Grid\Column|Collection from_user_id * @property Grid\Column|Collection role * @property Grid\Column|Collection role_name - * @property Grid\Column|Collection growth_value - * @property Grid\Column|Collection ratio * @property Grid\Column|Collection money * @property Grid\Column|Collection paid_at + * @property Grid\Column|Collection pay_way + * @property Grid\Column|Collection pay_no * @property Grid\Column|Collection pay_data * @property Grid\Column|Collection max * @property Grid\Column|Collection failed_reason * @property Grid\Column|Collection shipping_fee * @property Grid\Column|Collection products_total_amount + * @property Grid\Column|Collection user_coupon_id * @property Grid\Column|Collection note * @property Grid\Column|Collection pay_sn - * @property Grid\Column|Collection pay_way * @property Grid\Column|Collection pay_at - * @property Grid\Column|Collection completed_at - * @property Grid\Column|Collection user_coupon_id * @property Grid\Column|Collection shipping_state + * @property Grid\Column|Collection completed_at + * @property Grid\Column|Collection profit + * @property Grid\Column|Collection inviter_id + * @property Grid\Column|Collection source_type + * @property Grid\Column|Collection source_id * @property Grid\Column|Collection is_change * @property Grid\Column|Collection out_trade_no * @property Grid\Column|Collection auto_complete_at - * @property Grid\Column|Collection store_id - * @property Grid\Column|Collection profit - * @property Grid\Column|Collection inviter_id * @property Grid\Column|Collection payable_type * @property Grid\Column|Collection payable_id * @property Grid\Column|Collection tokenable_type @@ -233,6 +239,7 @@ namespace Dcat\Admin { * @property Grid\Column|Collection expires_at * @property Grid\Column|Collection socialite_type * @property Grid\Column|Collection socialite_id + * @property Grid\Column|Collection product_sku_id * @property Grid\Column|Collection tag_id * @property Grid\Column|Collection taggable_id * @property Grid\Column|Collection taggable_type @@ -255,7 +262,10 @@ namespace Dcat\Admin { * @property Grid\Column|Collection path * @property Grid\Column|Collection real_inviter_id * @property Grid\Column|Collection is_company + * @property Grid\Column|Collection invite_qrcode * @property Grid\Column|Collection vip_id + * @property Grid\Column|Collection gift + * @property Grid\Column|Collection success_time * @property Grid\Column|Collection phone_verified_at * @property Grid\Column|Collection email * @property Grid\Column|Collection email_verified_at @@ -264,12 +274,16 @@ namespace Dcat\Admin { * @property Grid\Column|Collection register_ip * @property Grid\Column|Collection status_remark * @property Grid\Column|Collection old_password + * @property Grid\Column|Collection agent_id + * @property Grid\Column|Collection vip_expired + * @property Grid\Column|Collection price * @property Grid\Column|Collection rate * @property Grid\Column|Collection service_amount * @property Grid\Column|Collection account_amount * @property Grid\Column|Collection withdrawable * * @method Grid\Column|Collection width(string $label = null) + * @method Grid\Column|Collection filed(string $label = null) * @method Grid\Column|Collection id(string $label = null) * @method Grid\Column|Collection cover(string $label = null) * @method Grid\Column|Collection content(string $label = null) @@ -327,6 +341,8 @@ namespace Dcat\Admin { * @method Grid\Column|Collection state(string $label = null) * @method Grid\Column|Collection tracking_number(string $label = null) * @method Grid\Column|Collection sales_value(string $label = null) + * @method Grid\Column|Collection growth_value(string $label = null) + * @method Grid\Column|Collection ratio(string $label = null) * @method Grid\Column|Collection v(string $label = null) * @method Grid\Column|Collection cate(string $label = null) * @method Grid\Column|Collection is_force(string $label = null) @@ -408,6 +424,9 @@ namespace Dcat\Admin { * @method Grid\Column|Collection is_failed(string $label = null) * @method Grid\Column|Collection checked_at(string $label = null) * @method Grid\Column|Collection last_news(string $label = null) + * @method Grid\Column|Collection store_id(string $label = null) + * @method Grid\Column|Collection products(string $label = null) + * @method Grid\Column|Collection others(string $label = null) * @method Grid\Column|Collection spu_id(string $label = null) * @method Grid\Column|Collection specs(string $label = null) * @method Grid\Column|Collection weight(string $label = null) @@ -425,28 +444,28 @@ namespace Dcat\Admin { * @method Grid\Column|Collection from_user_id(string $label = null) * @method Grid\Column|Collection role(string $label = null) * @method Grid\Column|Collection role_name(string $label = null) - * @method Grid\Column|Collection growth_value(string $label = null) - * @method Grid\Column|Collection ratio(string $label = null) * @method Grid\Column|Collection money(string $label = null) * @method Grid\Column|Collection paid_at(string $label = null) + * @method Grid\Column|Collection pay_way(string $label = null) + * @method Grid\Column|Collection pay_no(string $label = null) * @method Grid\Column|Collection pay_data(string $label = null) * @method Grid\Column|Collection max(string $label = null) * @method Grid\Column|Collection failed_reason(string $label = null) * @method Grid\Column|Collection shipping_fee(string $label = null) * @method Grid\Column|Collection products_total_amount(string $label = null) + * @method Grid\Column|Collection user_coupon_id(string $label = null) * @method Grid\Column|Collection note(string $label = null) * @method Grid\Column|Collection pay_sn(string $label = null) - * @method Grid\Column|Collection pay_way(string $label = null) * @method Grid\Column|Collection pay_at(string $label = null) - * @method Grid\Column|Collection completed_at(string $label = null) - * @method Grid\Column|Collection user_coupon_id(string $label = null) * @method Grid\Column|Collection shipping_state(string $label = null) + * @method Grid\Column|Collection completed_at(string $label = null) + * @method Grid\Column|Collection profit(string $label = null) + * @method Grid\Column|Collection inviter_id(string $label = null) + * @method Grid\Column|Collection source_type(string $label = null) + * @method Grid\Column|Collection source_id(string $label = null) * @method Grid\Column|Collection is_change(string $label = null) * @method Grid\Column|Collection out_trade_no(string $label = null) * @method Grid\Column|Collection auto_complete_at(string $label = null) - * @method Grid\Column|Collection store_id(string $label = null) - * @method Grid\Column|Collection profit(string $label = null) - * @method Grid\Column|Collection inviter_id(string $label = null) * @method Grid\Column|Collection payable_type(string $label = null) * @method Grid\Column|Collection payable_id(string $label = null) * @method Grid\Column|Collection tokenable_type(string $label = null) @@ -491,6 +510,7 @@ namespace Dcat\Admin { * @method Grid\Column|Collection expires_at(string $label = null) * @method Grid\Column|Collection socialite_type(string $label = null) * @method Grid\Column|Collection socialite_id(string $label = null) + * @method Grid\Column|Collection product_sku_id(string $label = null) * @method Grid\Column|Collection tag_id(string $label = null) * @method Grid\Column|Collection taggable_id(string $label = null) * @method Grid\Column|Collection taggable_type(string $label = null) @@ -513,7 +533,10 @@ namespace Dcat\Admin { * @method Grid\Column|Collection path(string $label = null) * @method Grid\Column|Collection real_inviter_id(string $label = null) * @method Grid\Column|Collection is_company(string $label = null) + * @method Grid\Column|Collection invite_qrcode(string $label = null) * @method Grid\Column|Collection vip_id(string $label = null) + * @method Grid\Column|Collection gift(string $label = null) + * @method Grid\Column|Collection success_time(string $label = null) * @method Grid\Column|Collection phone_verified_at(string $label = null) * @method Grid\Column|Collection email(string $label = null) * @method Grid\Column|Collection email_verified_at(string $label = null) @@ -522,6 +545,9 @@ namespace Dcat\Admin { * @method Grid\Column|Collection register_ip(string $label = null) * @method Grid\Column|Collection status_remark(string $label = null) * @method Grid\Column|Collection old_password(string $label = null) + * @method Grid\Column|Collection agent_id(string $label = null) + * @method Grid\Column|Collection vip_expired(string $label = null) + * @method Grid\Column|Collection price(string $label = null) * @method Grid\Column|Collection rate(string $label = null) * @method Grid\Column|Collection service_amount(string $label = null) * @method Grid\Column|Collection account_amount(string $label = null) @@ -533,6 +559,7 @@ namespace Dcat\Admin { /** * @property Show\Field|Collection width + * @property Show\Field|Collection filed * @property Show\Field|Collection id * @property Show\Field|Collection cover * @property Show\Field|Collection content @@ -590,6 +617,8 @@ namespace Dcat\Admin { * @property Show\Field|Collection state * @property Show\Field|Collection tracking_number * @property Show\Field|Collection sales_value + * @property Show\Field|Collection growth_value + * @property Show\Field|Collection ratio * @property Show\Field|Collection v * @property Show\Field|Collection cate * @property Show\Field|Collection is_force @@ -671,6 +700,9 @@ namespace Dcat\Admin { * @property Show\Field|Collection is_failed * @property Show\Field|Collection checked_at * @property Show\Field|Collection last_news + * @property Show\Field|Collection store_id + * @property Show\Field|Collection products + * @property Show\Field|Collection others * @property Show\Field|Collection spu_id * @property Show\Field|Collection specs * @property Show\Field|Collection weight @@ -688,28 +720,28 @@ namespace Dcat\Admin { * @property Show\Field|Collection from_user_id * @property Show\Field|Collection role * @property Show\Field|Collection role_name - * @property Show\Field|Collection growth_value - * @property Show\Field|Collection ratio * @property Show\Field|Collection money * @property Show\Field|Collection paid_at + * @property Show\Field|Collection pay_way + * @property Show\Field|Collection pay_no * @property Show\Field|Collection pay_data * @property Show\Field|Collection max * @property Show\Field|Collection failed_reason * @property Show\Field|Collection shipping_fee * @property Show\Field|Collection products_total_amount + * @property Show\Field|Collection user_coupon_id * @property Show\Field|Collection note * @property Show\Field|Collection pay_sn - * @property Show\Field|Collection pay_way * @property Show\Field|Collection pay_at - * @property Show\Field|Collection completed_at - * @property Show\Field|Collection user_coupon_id * @property Show\Field|Collection shipping_state + * @property Show\Field|Collection completed_at + * @property Show\Field|Collection profit + * @property Show\Field|Collection inviter_id + * @property Show\Field|Collection source_type + * @property Show\Field|Collection source_id * @property Show\Field|Collection is_change * @property Show\Field|Collection out_trade_no * @property Show\Field|Collection auto_complete_at - * @property Show\Field|Collection store_id - * @property Show\Field|Collection profit - * @property Show\Field|Collection inviter_id * @property Show\Field|Collection payable_type * @property Show\Field|Collection payable_id * @property Show\Field|Collection tokenable_type @@ -754,6 +786,7 @@ namespace Dcat\Admin { * @property Show\Field|Collection expires_at * @property Show\Field|Collection socialite_type * @property Show\Field|Collection socialite_id + * @property Show\Field|Collection product_sku_id * @property Show\Field|Collection tag_id * @property Show\Field|Collection taggable_id * @property Show\Field|Collection taggable_type @@ -776,7 +809,10 @@ namespace Dcat\Admin { * @property Show\Field|Collection path * @property Show\Field|Collection real_inviter_id * @property Show\Field|Collection is_company + * @property Show\Field|Collection invite_qrcode * @property Show\Field|Collection vip_id + * @property Show\Field|Collection gift + * @property Show\Field|Collection success_time * @property Show\Field|Collection phone_verified_at * @property Show\Field|Collection email * @property Show\Field|Collection email_verified_at @@ -785,12 +821,16 @@ namespace Dcat\Admin { * @property Show\Field|Collection register_ip * @property Show\Field|Collection status_remark * @property Show\Field|Collection old_password + * @property Show\Field|Collection agent_id + * @property Show\Field|Collection vip_expired + * @property Show\Field|Collection price * @property Show\Field|Collection rate * @property Show\Field|Collection service_amount * @property Show\Field|Collection account_amount * @property Show\Field|Collection withdrawable * * @method Show\Field|Collection width(string $label = null) + * @method Show\Field|Collection filed(string $label = null) * @method Show\Field|Collection id(string $label = null) * @method Show\Field|Collection cover(string $label = null) * @method Show\Field|Collection content(string $label = null) @@ -848,6 +888,8 @@ namespace Dcat\Admin { * @method Show\Field|Collection state(string $label = null) * @method Show\Field|Collection tracking_number(string $label = null) * @method Show\Field|Collection sales_value(string $label = null) + * @method Show\Field|Collection growth_value(string $label = null) + * @method Show\Field|Collection ratio(string $label = null) * @method Show\Field|Collection v(string $label = null) * @method Show\Field|Collection cate(string $label = null) * @method Show\Field|Collection is_force(string $label = null) @@ -929,6 +971,9 @@ namespace Dcat\Admin { * @method Show\Field|Collection is_failed(string $label = null) * @method Show\Field|Collection checked_at(string $label = null) * @method Show\Field|Collection last_news(string $label = null) + * @method Show\Field|Collection store_id(string $label = null) + * @method Show\Field|Collection products(string $label = null) + * @method Show\Field|Collection others(string $label = null) * @method Show\Field|Collection spu_id(string $label = null) * @method Show\Field|Collection specs(string $label = null) * @method Show\Field|Collection weight(string $label = null) @@ -946,28 +991,28 @@ namespace Dcat\Admin { * @method Show\Field|Collection from_user_id(string $label = null) * @method Show\Field|Collection role(string $label = null) * @method Show\Field|Collection role_name(string $label = null) - * @method Show\Field|Collection growth_value(string $label = null) - * @method Show\Field|Collection ratio(string $label = null) * @method Show\Field|Collection money(string $label = null) * @method Show\Field|Collection paid_at(string $label = null) + * @method Show\Field|Collection pay_way(string $label = null) + * @method Show\Field|Collection pay_no(string $label = null) * @method Show\Field|Collection pay_data(string $label = null) * @method Show\Field|Collection max(string $label = null) * @method Show\Field|Collection failed_reason(string $label = null) * @method Show\Field|Collection shipping_fee(string $label = null) * @method Show\Field|Collection products_total_amount(string $label = null) + * @method Show\Field|Collection user_coupon_id(string $label = null) * @method Show\Field|Collection note(string $label = null) * @method Show\Field|Collection pay_sn(string $label = null) - * @method Show\Field|Collection pay_way(string $label = null) * @method Show\Field|Collection pay_at(string $label = null) - * @method Show\Field|Collection completed_at(string $label = null) - * @method Show\Field|Collection user_coupon_id(string $label = null) * @method Show\Field|Collection shipping_state(string $label = null) + * @method Show\Field|Collection completed_at(string $label = null) + * @method Show\Field|Collection profit(string $label = null) + * @method Show\Field|Collection inviter_id(string $label = null) + * @method Show\Field|Collection source_type(string $label = null) + * @method Show\Field|Collection source_id(string $label = null) * @method Show\Field|Collection is_change(string $label = null) * @method Show\Field|Collection out_trade_no(string $label = null) * @method Show\Field|Collection auto_complete_at(string $label = null) - * @method Show\Field|Collection store_id(string $label = null) - * @method Show\Field|Collection profit(string $label = null) - * @method Show\Field|Collection inviter_id(string $label = null) * @method Show\Field|Collection payable_type(string $label = null) * @method Show\Field|Collection payable_id(string $label = null) * @method Show\Field|Collection tokenable_type(string $label = null) @@ -1012,6 +1057,7 @@ namespace Dcat\Admin { * @method Show\Field|Collection expires_at(string $label = null) * @method Show\Field|Collection socialite_type(string $label = null) * @method Show\Field|Collection socialite_id(string $label = null) + * @method Show\Field|Collection product_sku_id(string $label = null) * @method Show\Field|Collection tag_id(string $label = null) * @method Show\Field|Collection taggable_id(string $label = null) * @method Show\Field|Collection taggable_type(string $label = null) @@ -1034,7 +1080,10 @@ namespace Dcat\Admin { * @method Show\Field|Collection path(string $label = null) * @method Show\Field|Collection real_inviter_id(string $label = null) * @method Show\Field|Collection is_company(string $label = null) + * @method Show\Field|Collection invite_qrcode(string $label = null) * @method Show\Field|Collection vip_id(string $label = null) + * @method Show\Field|Collection gift(string $label = null) + * @method Show\Field|Collection success_time(string $label = null) * @method Show\Field|Collection phone_verified_at(string $label = null) * @method Show\Field|Collection email(string $label = null) * @method Show\Field|Collection email_verified_at(string $label = null) @@ -1043,6 +1092,9 @@ namespace Dcat\Admin { * @method Show\Field|Collection register_ip(string $label = null) * @method Show\Field|Collection status_remark(string $label = null) * @method Show\Field|Collection old_password(string $label = null) + * @method Show\Field|Collection agent_id(string $label = null) + * @method Show\Field|Collection vip_expired(string $label = null) + * @method Show\Field|Collection price(string $label = null) * @method Show\Field|Collection rate(string $label = null) * @method Show\Field|Collection service_amount(string $label = null) * @method Show\Field|Collection account_amount(string $label = null) diff --git a/resources/lang/zh_CN/agent.php b/resources/lang/zh_CN/agent.php new file mode 100644 index 00000000..d7bd1f49 --- /dev/null +++ b/resources/lang/zh_CN/agent.php @@ -0,0 +1,19 @@ + [ + 'Agent' => '代理等级', + 'agents' => '代理等级', + ], + 'fields' => [ + 'name' => '等级名称', + 'growth_value' => '升级', + 'sort' => '等级', + 'ratio' => '比例', + 'slug' => '类别' + ], + 'options' => [ + 'deny' => '删除失败', + 'deny_message'=> '该等级下还有用户, 无法删除', + ], +]; diff --git a/resources/lang/zh_CN/user-vip.php b/resources/lang/zh_CN/user-vip.php new file mode 100644 index 00000000..f8d95616 --- /dev/null +++ b/resources/lang/zh_CN/user-vip.php @@ -0,0 +1,21 @@ + [ + 'UserVip' => '购买记录', + 'user-vip' => '购买记录', + ], + 'fields' => [ + 'user_id' => '用户', + 'vip_id' => '会员卡', + 'times' => '时效', + 'success_time' => '购买时间', + 'user' => [ + 'phone' => '用户', + ], + 'vip' => [ + 'name' => '会员卡' + ] + ], + 'options' => [ + ], +]; diff --git a/resources/lang/zh_CN/user.php b/resources/lang/zh_CN/user.php index 4270096b..f1022a57 100644 --- a/resources/lang/zh_CN/user.php +++ b/resources/lang/zh_CN/user.php @@ -16,11 +16,7 @@ return [ 'last_login_at' => '最近登录时间', 'register_ip' => '注册IP', 'created_at' => '注册时间', - 'userVip'=>[ - 'vip' => [ - 'name' => '代理', - ], - ], + 'agent' => '代理', 'userInfo'=>[ 'avatar' => '头像', 'nickname' => '昵称', diff --git a/resources/lang/zh_CN/vip.php b/resources/lang/zh_CN/vip.php index 28b4bcce..5a4cc56a 100644 --- a/resources/lang/zh_CN/vip.php +++ b/resources/lang/zh_CN/vip.php @@ -2,15 +2,17 @@ return [ 'labels' => [ - 'Vip' => '会员等级', - 'vips' => '会员等级', + 'Vip' => '会员卡', + 'vips' => '会员卡', ], 'fields' => [ - 'name' => '等级名称', - 'growth_value' => '升级', - 'sort' => '等级', + 'name' => '名称', + 'sort' => '排序', 'ratio' => '比例', - 'slug' => '类别' + 'times' => '时效', + 'gift' => '赠品', + 'price' => '价格', + 'status' => '状态' ], 'options' => [ 'deny' => '删除失败',