From 302b6dd70224e196cefc030bfde2281c76a932c8 Mon Sep 17 00:00:00 2001 From: Jing Li Date: Wed, 24 Apr 2024 09:29:50 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=A8=E5=BA=97=E4=BD=A3=E9=87=91=E6=AF=94?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Store/StoreController.php | 58 +++++++++++-------- app/Http/Controllers/Api/LedgerController.php | 2 +- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/app/Admin/Controllers/Store/StoreController.php b/app/Admin/Controllers/Store/StoreController.php index 917ebfa..0ef91bf 100644 --- a/app/Admin/Controllers/Store/StoreController.php +++ b/app/Admin/Controllers/Store/StoreController.php @@ -30,42 +30,43 @@ class StoreController extends AdminController ->bulkActions([]) ->filter($this->baseFilter()->body([ amis()->GroupControl()->mode('horizontal')->body([ - amisMake()->TextControl()->name('title')->label(__('store.title'))->columnRatio(3)->clearable(), - amisMake()->TreeSelectControl()->name('category_id')->label(__('store.category_id'))->columnRatio(3) + amis()->TextControl()->name('title')->label(__('store.title'))->columnRatio(3)->clearable(), + amis()->TreeSelectControl()->name('category_id')->label(__('store.category_id'))->columnRatio(3) ->source(admin_url('api/keywords/tree-list?parent_key=store_category')) ->labelField('name') ->valueField('key') ->onlyLeaf(true) ->clearable(), - amisMake()->SelectControl()->name('business_id')->label(__('store.business_id'))->columnRatio(3) + amis()->SelectControl()->name('business_id')->label(__('store.business_id'))->columnRatio(3) ->source(admin_url('api/keywords/tree-list?parent_key=store_business')) ->labelField('name') ->valueField('key') ->clearable(), ]), - amisMake()->GroupControl()->mode('horizontal')->body([ - amisMake()->SelectControl()->name('level_id')->label(__('store.level_id'))->columnRatio(3) + amis()->GroupControl()->mode('horizontal')->body([ + amis()->SelectControl()->name('level_id')->label(__('store.level_id'))->columnRatio(3) ->source(admin_url('api/keywords/tree-list?parent_key=store_level')) ->labelField('name') ->valueField('key') ->clearable(), - // amisMake()->InputCityControl()->name('region')->label(__('store.region'))->columnRatio(3) + // amis()->InputCityControl()->name('region')->label(__('store.region'))->columnRatio(3) // ->allowDistrict(false) // ->extractValue(false) // ->clearable(), - amisMake()->SelectControl()->name('business_status')->label(__('store.business_status'))->options(BusinessStatus::options())->columnRatio(3)->clearable(), + amis()->SelectControl()->name('business_status')->label(__('store.business_status'))->options(BusinessStatus::options())->columnRatio(3)->clearable(), ]), ])) ->columns([ - amisMake()->TableColumn()->name('id')->label(__('store.id')), - amisMake()->TableColumn()->name('title')->label(__('store.title')), - amisMake()->TableColumn()->name('master.name')->label(__('store.master_id')), - amisMake()->TableColumn()->name('category.name')->label(__('store.category_id')), - amisMake()->TableColumn()->name('business.name')->label(__('store.business_id')), - amisMake()->TableColumn()->name('level.name')->label(__('store.level_id')), - amisMake()->TableColumn()->name('region')->label(__('store.region'))->set('type', 'tpl')->set('tpl', '${region.province}-${region.city}'), - amisMake()->TableColumn()->name('business_status')->label(__('store.business_status'))->type('switch')->trueValue(BusinessStatus::Open)->falseValue(BusinessStatus::Close), - amisMake()->TableColumn()->name('created_at')->label(__('store.created_at')), + amis()->TableColumn()->name('id')->label(__('store.id')), + amis()->TableColumn()->name('title')->label(__('store.title')), + amis()->TableColumn()->name('master.name')->label(__('store.master_id')), + amis()->TableColumn()->name('category.name')->label(__('store.category_id')), + amis()->TableColumn()->name('business.name')->label(__('store.business_id')), + amis()->TableColumn()->name('level.name')->label(__('store.level_id')), + amis()->TableColumn()->name('profit_ratio')->label(__('store.profit_ratio'))->type('tpl')->set('tpl', '${profit_ratio}%'), + amis()->TableColumn()->name('region')->label(__('store.region'))->set('type', 'tpl')->set('tpl', '${region.province}-${region.city}'), + amis()->TableColumn()->name('business_status')->label(__('store.business_status'))->type('switch')->trueValue(BusinessStatus::Open)->falseValue(BusinessStatus::Close), + amis()->TableColumn()->name('created_at')->label(__('store.created_at')), $this->rowActions([ $this->rowShowButton()->visible($user->can('admin.store.stores.view')), $this->rowEditTypeButton('drawer', 'lg')->visible($user->can('admin.store.stores.update')), @@ -79,40 +80,47 @@ class StoreController extends AdminController public function form($edit): Form { return $this->baseForm()->title('')->body([ - amisMake()->TextControl()->name('title')->label(__('store.title'))->required(), - amisMake()->SelectControl()->name('master_id')->label(__('store.master_id')) + amis()->TextControl()->name('title')->label(__('store.title'))->required(), + amis()->SelectControl()->name('master_id')->label(__('store.master_id')) ->source($edit ? admin_url('api/employees?_all=1&employee_status='.EmployeeStatus::Online->value) : admin_url('api/employees?_all=1&store_id=0&employee_status='.EmployeeStatus::Online->value)) ->labelField('name') ->valueField('id') ->searchable() ->required(), - amisMake()->TreeSelectControl()->name('category_id')->label(__('store.category_id')) + amis()->TreeSelectControl()->name('category_id')->label(__('store.category_id')) ->source(admin_url('api/keywords/tree-list?parent_key=store_category')) ->labelField('name') ->valueField('key') ->onlyLeaf(true) ->required(), - amisMake()->SelectControl()->name('business_id')->label(__('store.business_id')) + amis()->SelectControl()->name('business_id')->label(__('store.business_id')) ->source(admin_url('api/keywords/tree-list?parent_key=store_business')) ->labelField('name') ->valueField('key') ->required(), - amisMake()->SelectControl()->name('level_id')->label(__('store.level_id')) + amis()->SelectControl()->name('level_id')->label(__('store.level_id')) ->source(admin_url('api/keywords/tree-list?parent_key=store_level')) ->labelField('name') ->valueField('key') ->required(), - amisMake()->InputCityControl()->name('region')->label(__('store.region'))->allowDistrict(false)->extractValue(false)->required(), - amisMake()->LocationControl()->name('location')->label(__('store.location'))->ak(config('baidu.js_secret'))->autoSelectCurrentLoc(), + amis()->NumberControl() + ->name('profit_ratio') + ->label(__('store.profit_ratio')) + ->placeholder(__('store.profit_ratio')) + ->precision(2) + ->showSteps(false) + ->required(), + amis()->InputCityControl()->name('region')->label(__('store.region'))->allowDistrict(false)->extractValue(false)->required(), + amis()->LocationControl()->name('location')->label(__('store.location'))->ak(config('baidu.js_secret'))->autoSelectCurrentLoc(), ]); } public function detail(): Form { - $detail = amisMake()->Property()->items([ + $detail = amis()->Property()->items([ ['label' => __('store.title'), 'content' => '${title}'], ['label' => __('store.master_id'), 'content' => '${master.name}'], - ['label' => __('store.business_status'), 'content' => amisMake()->Tag()->label('${business_status_text}')->color('${business_status_color}')], + ['label' => __('store.business_status'), 'content' => amis()->Tag()->label('${business_status_text}')->color('${business_status_color}')], ['label' => __('store.category_id'), 'content' => '${category.name}'], ['label' => __('store.business_id'), 'content' => '${business.name}'], ['label' => __('store.level_id'), 'content' => '${level.name}'], diff --git a/app/Http/Controllers/Api/LedgerController.php b/app/Http/Controllers/Api/LedgerController.php index aba1220..fad939c 100644 --- a/app/Http/Controllers/Api/LedgerController.php +++ b/app/Http/Controllers/Api/LedgerController.php @@ -98,7 +98,7 @@ class LedgerController extends Controller throw new RuntimeException('上报数据已更新,不可重新上传'); } - $ratio = bcdiv($user->store->profit_ratio, 100, 2); + $ratio = bcdiv($user->store->profit_ratio, 100, 4); // 计算预期佣金 $validated['expected_commission'] = bcmul($validated['sales'], $ratio, 2);