diff --git a/app/Admin/Actions/Grid/v3/GoodsActivitySetting.php b/app/Admin/Actions/Grid/v3/GoodsActivitySetting.php new file mode 100644 index 0000000..068b7af --- /dev/null +++ b/app/Admin/Actions/Grid/v3/GoodsActivitySetting.php @@ -0,0 +1,74 @@ +response() + ->success('跳转到设置页面' ) + ->redirect('/activity_setting'); + } + + /** + * @return string|void + */ + // public function href() + // { + // return admin_url('category/tie'); + // } + + /** + * @return string|array|void + */ + public function confirm() + { + // return ['Confirm?', 'contents']; + } + +// protected function actionScript() +// { + +// return <<paginate(10); + + $grid->tools([new GoodsActivitySetting()]); }); } @@ -281,4 +287,12 @@ class GoodsActivityController extends AdminController }); }); } + + + public function SettingForm(Content $content) + { + return $content + ->title('活动设置') + ->body(new Card(new GoodsActivitySettingForm())); + } } diff --git a/app/Admin/Forms/v3/GoodsActivitySetting.php b/app/Admin/Forms/v3/GoodsActivitySetting.php deleted file mode 100644 index 38895a7..0000000 --- a/app/Admin/Forms/v3/GoodsActivitySetting.php +++ /dev/null @@ -1,52 +0,0 @@ -error('修改成功'); - } - - /** - * Build a form here. - */ - public function form() - { - $id = $this->getKey(); - - $this->display('activity_type_limit_nums','同一活动类型商品单笔订单可购买商品种数'); - $this->number('flash_sale','秒杀')->value()->default(); - $this->image('group_buy','团购')->value()->default(); - $this->image('new_product','新品')->value()->default(); - } - - /** - * The data of the form. - * - * @return array - */ - public function default() - { - return []; - } - -} diff --git a/app/Admin/Forms/v3/GoodsActivitySettingForm.php b/app/Admin/Forms/v3/GoodsActivitySettingForm.php new file mode 100644 index 0000000..a1d1648 --- /dev/null +++ b/app/Admin/Forms/v3/GoodsActivitySettingForm.php @@ -0,0 +1,68 @@ + $flashSale, + 'group_buy' => $groupBuy, + 'new_product' => $newProduct, + ]; + + $res = Redis::hmset(RedisKey::ACTIVITY_TYPE_LIMIT_NUMS , $data); + if($res){ + return $this->success('修改成功','/goods_activity'); + }else{ + return $this->error('修改失败'); + } + } + + /** + * Build a form here. + */ + public function form() + { + $data = Redis::hgetall('activity_type_limit_nums'); + + $flashSale = $data['flash_sale']?$data['flash_sale']:0; + $groupBuy= $data['group_buy']?$data['group_buy']:0; + $newProduct= $data['new_product']?$data['new_product']:0; + + $this->display(RedisKey::ACTIVITY_TYPE_LIMIT_NUMS , '设置')->value('同一活动类型的商品,单笔订单可购买商品种数'); + $this->number('flash_sale','秒杀')->attribute('min', 0)->default(1)->value($flashSale); + $this->number('group_buy','团购')->attribute('min', 0)->default(1)->value($groupBuy); + $this->number('new_product','新品')->attribute('min', 0)->default(1)->value($newProduct); + } + + /** + * The data of the form. + * + * @return array + */ + public function default() + { + return []; + } + +} diff --git a/app/Admin/routes.php b/app/Admin/routes.php index aa9ac7c..a729727 100644 --- a/app/Admin/routes.php +++ b/app/Admin/routes.php @@ -59,6 +59,7 @@ Route::group([ $router->resource('/goods', 'v3\GoodsController'); $router->resource('/goods_activity', 'v3\GoodsActivityController'); $router->resource('/goods_new', 'v3\GoodsNewController'); + $router->get('/activity_setting', 'v3\GoodsActivityController@SettingForm'); // 平台管理 $router->resource('/banners', 'v3\BannersController'); diff --git a/app/Libs/Redis/RedisKey.php b/app/Libs/Redis/RedisKey.php new file mode 100644 index 0000000..1ce5a70 --- /dev/null +++ b/app/Libs/Redis/RedisKey.php @@ -0,0 +1,12 @@ +