diff --git a/app/Admin/Controllers/v3/SystemConfigController.php b/app/Admin/Controllers/v3/SystemConfigController.php index 3d472d7..4ee820b 100644 --- a/app/Admin/Controllers/v3/SystemConfigController.php +++ b/app/Admin/Controllers/v3/SystemConfigController.php @@ -8,9 +8,12 @@ use Dcat\Admin\Grid; use Dcat\Admin\Show; use Dcat\Admin\Controllers\AdminController; use App\Models\v3\SystemConfig as SystemConfigModel; +use App\Libs\SsdbClient; +use App\Constants\v3\SsdbKeys; class SystemConfigController extends AdminController { + /** * Make a grid builder. * @@ -47,10 +50,15 @@ class SystemConfigController extends AdminController protected function detail($id) { return Show::make($id, new SystemConfig(), function (Show $show) { + $menuName = $show->model()->menu_name; $show->field('id'); $show->field('menu_name'); $show->field('category_text'); - $show->field('value'); + $show->field('value')->width(6); + if($menuName == 'initial_delivery_amount'){ + $delivery = SsdbClient::client()->get(SsdbKeys::INTIAL_DELIVERY_AMOUNT); + $show->field('value_text','已存ssdb的值:')->width(6)->value($delivery); + } $show->field('info'); $show->field('desc'); $show->field('sort'); @@ -68,20 +76,32 @@ class SystemConfigController extends AdminController protected function form() { return Form::make(new SystemConfig(), function (Form $form) { + $menuName = $form->model()->menu_name; $form->hidden('id'); $form->text('menu_name')->width(4)->required()->rules('regex:/^[0-9a-z_]{1,}$/',['regex'=>'只能输入数字、小写字母和下划线'])->help('本字段在添加成功后不能编辑!'); $form->select('category')->width(4)->options(SystemConfigModel::$_CATEGORY); - $form->text('value')->required()->width(6)->maxLength(100); + $deliveryForm = $form->text('value')->required()->width(6)->maxLength(100); + + if($menuName == 'initial_delivery_amount'){ + $delivery = SsdbClient::client()->get(SsdbKeys::INTIAL_DELIVERY_AMOUNT); + $deliveryForm->help('已存ssdb的值:'.$delivery); + } + $form->text('info')->maxLength(255); $form->text('desc')->maxLength(500); $form->number('sort')->width(2)->default(0); $form->saving(function(Form $form){ $id = $form->input('id'); - if($id && $form->input('menu_name') ){ + $menuName = $form->input('menu_name'); + if($id && $menuName ){ $form->deleteInput('menu_name'); } + if($id && $menuName == 'initial_delivery_amount'){ + $delivery = $form->input('value'); + SsdbClient::client()->set(SsdbKeys::INTIAL_DELIVERY_AMOUNT,$delivery); + } }); $form->switch('status') ->customFormat(function ($v) { diff --git a/app/Admin/Forms/CategoryTieForm.php b/app/Admin/Forms/CategoryTieForm.php index cd8f37f..9db8732 100644 --- a/app/Admin/Forms/CategoryTieForm.php +++ b/app/Admin/Forms/CategoryTieForm.php @@ -10,9 +10,6 @@ use Illuminate\Support\Facades\DB; class CategoryTieForm extends Form { - - protected $ssdb; - /** * Handle the form request. * @@ -37,9 +34,9 @@ class CategoryTieForm extends Form if(count($data) > 0){ - $this->ssdb->client()->hclear('applet_index_category'); + SsdbClient::client()->hclear('applet_index_category'); - $category = $this->ssdb->client()->multi_hset('applet_index_category',$data); + $category = SsdbClient::client()->multi_hset('applet_index_category',$data); if($category === false){ return $this->error('绑定失败'); @@ -55,8 +52,7 @@ class CategoryTieForm extends Form */ public function form() { - $this->ssdb = new SsdbClient(); - $category = $this->ssdb->client()->hgetall('applet_index_category'); + $category = SsdbClient::client()->hgetall('applet_index_category'); $select = array_keys($category); // 只查一级 diff --git a/app/Admin/Forms/CouponTieForm.php b/app/Admin/Forms/CouponTieForm.php index 7d27d13..7ce64ec 100644 --- a/app/Admin/Forms/CouponTieForm.php +++ b/app/Admin/Forms/CouponTieForm.php @@ -8,11 +8,6 @@ use App\Libs\SsdbClient; class CouponTieForm extends Form { - /** - * - */ - protected $ssdb; - /** * Handle the form request. * @@ -29,7 +24,7 @@ class CouponTieForm extends Form 'repay' => $input['repay'], ]; - $coupon = $this->ssdb->client()->multi_hset('coupon_rebate_activity',$data); + $coupon = SsdbClient::client()->multi_hset('coupon_rebate_activity',$data); if($coupon === false){ return $this->error('修改失败'); } @@ -42,8 +37,7 @@ class CouponTieForm extends Form */ public function form() { - $this->ssdb = new SsdbClient(); - $coupon = $this->ssdb->client()->hgetall('coupon_rebate_activity'); + $coupon = SsdbClient::client()->hgetall('coupon_rebate_activity'); if(empty($coupon)){ $coupon = [ 'activity'=> 0, diff --git a/app/Constants/v3/SsdbKeys.php b/app/Constants/v3/SsdbKeys.php new file mode 100644 index 0000000..cd38925 --- /dev/null +++ b/app/Constants/v3/SsdbKeys.php @@ -0,0 +1,74 @@ +