assign('count', Card::count()); return $this->fetch(); } public function save_excel() { $where = Util::getMore([ ['status', ''], ['name', ''] ]); Card::SaveExcel($where); } /** * 异步获取砍价数据 */ public function get_list() { $where = Util::getMore([ ['page', 1], ['limit', 20], ['status', ''], ['name', ''] ]); $seckillList = Card::systemPage($where); if (is_object($seckillList['list'])) $seckillList['list'] = $seckillList['list']->toArray(); $data = $seckillList['list']['data']; return Json::successlayui(['count' => $seckillList['list']['total'], 'data' => $data]); } /** * 添加秒杀商品 * @return form-builder */ public function create() { $f = array(); $f[] = Form::input('name', '标题')->required('请输入礼品卡标题'); $f[] = Form::number('price', '价格')->step(0.01)->required(); $f[] = Form::number('store_award', '奖金')->step(0.01)->required(); $f[] = Form::number('num', '数量')->step(1)->required()->min(1); $form = Form::make_post_form('添加礼品卡', $f, Url::buildUrl('save_cards')); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } /** * 保存秒杀商品 * @param int $id */ public function save_cards() { $data = Util::postMore([ 'name', 'price', 'store_award', 'num', ]); for ($i = 0; $i < $data['num']; $i++) { $item = [ 'add_time' => time(), 'name' => $data['name'], 'code' => Card::createCode(), 'password' => Card::createPassword(), 'price' => $data['price'], 'store_award' => $data['store_award'], ]; Card::create($item); } return Json::successful('添加成功!'); } }