链街Dcat后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.8 KiB

  1. <?php
  2. namespace App\Admin\Forms\v3;
  3. use Dcat\Admin\Widgets\Form;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Illuminate\Support\Facades\Redis;
  6. use App\Libs\Redis\RedisKey;
  7. class GoodsActivitySettingForm extends Form
  8. {
  9. /**
  10. * Handle the form request.
  11. *
  12. * @param array $input
  13. *
  14. * @return Response
  15. */
  16. public function handle(array $input)
  17. {
  18. // 获取外部传递参数
  19. $flashSale = $input['flash_sale'];
  20. $groupBuy= $input['group_buy'];
  21. $newProduct= $input['new_product'];
  22. $data = [
  23. 'flash_sale' => $flashSale,
  24. 'group_buy' => $groupBuy,
  25. 'new_product' => $newProduct,
  26. ];
  27. $res = Redis::hmset(RedisKey::ACTIVITY_TYPE_LIMIT_NUMS , $data);
  28. if($res){
  29. return $this->success('修改成功','/goods_activity');
  30. }else{
  31. return $this->error('修改失败');
  32. }
  33. }
  34. /**
  35. * Build a form here.
  36. */
  37. public function form()
  38. {
  39. $data = Redis::hgetall('activity_type_limit_nums');
  40. $flashSale = isset($data['flash_sale'])?$data['flash_sale']:0;
  41. $groupBuy= isset($data['group_buy'])?$data['group_buy']:0;
  42. $newProduct= isset($data['new_product'])?$data['new_product']:0;
  43. $this->display(RedisKey::ACTIVITY_TYPE_LIMIT_NUMS , '设置')->value('同一活动类型的商品,单笔订单可购买商品种数');
  44. $this->number('flash_sale','秒杀')->attribute('min', 0)->default(1)->value($flashSale);
  45. $this->number('group_buy','团购')->attribute('min', 0)->default(1)->value($groupBuy);
  46. $this->number('new_product','新品')->attribute('min', 0)->default(1)->value($newProduct);
  47. }
  48. /**
  49. * The data of the form.
  50. *
  51. * @return array
  52. */
  53. public function default()
  54. {
  55. return [];
  56. }
  57. }