|
|
@ -0,0 +1,68 @@ |
|
|
|
|
|
<?php |
|
|
|
|
|
|
|
|
|
|
|
namespace App\Admin\Forms\v3; |
|
|
|
|
|
|
|
|
|
|
|
use Dcat\Admin\Widgets\Form; |
|
|
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
|
|
|
|
use Illuminate\Support\Facades\Redis; |
|
|
|
|
|
use App\Libs\Redis\RedisKey; |
|
|
|
|
|
|
|
|
|
|
|
class GoodsActivityLimitForm extends Form |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Handle the form request. |
|
|
|
|
|
* |
|
|
|
|
|
* @param array $input |
|
|
|
|
|
* |
|
|
|
|
|
* @return Response |
|
|
|
|
|
*/ |
|
|
|
|
|
public function handle(array $input) |
|
|
|
|
|
{ |
|
|
|
|
|
// 获取外部传递参数
|
|
|
|
|
|
$flashSale = $input['flash_sale']; |
|
|
|
|
|
$groupBuy= $input['group_buy']; |
|
|
|
|
|
$newProduct= $input['new_product']; |
|
|
|
|
|
|
|
|
|
|
|
$data = [ |
|
|
|
|
|
'flash_sale' => $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(RedisKey::ACTIVITY_TYPE_LIMIT_NUMS); |
|
|
|
|
|
|
|
|
|
|
|
$flashSale = isset($data['flash_sale'])?$data['flash_sale']:0; |
|
|
|
|
|
$groupBuy= isset($data['group_buy'])?$data['group_buy']:0; |
|
|
|
|
|
$newProduct= isset($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 []; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |