yafhandler 添加展示 修改

xiaoxiao2021-02-28  77

<?php /** * Created by PhpStorm. * Date: 2017/5/17 * Time: 下午2:52 */ use Handler\Handler as Y; use Respect\Validation\Validator as V; class LotteryController extends _BaseController { /** *添加活动展示页面 */ public function 1addAction() { } /** *添加活动 */ public function 2addAction() { Y::disableView(); $this->rule['name'] = V::stringVal()->setTemplate('名称错误'); $this->rule['desc'] = V::stringVal()->setTemplate('活动简介错误'); $this->rule['content'] = V::stringVal()->setTemplate('活动详情错误'); $this->rule['start_time'] = V::date('Y-m-d H:i:s');//活动开始时间 $this->rule['end_time'] = V::date('Y-m-d H:i:s');//活动结束时间 $this->rule['pname'] = V::arrayType(); $this->rule['description'] = V::arrayType(); $this->rule['possibility'] = V::arrayType(); $this->rule['sort'] = V::arrayType(); $name= $this->post('name'); $desc= $this->post('desc'); $content= $this->post('content'); $start_time= $this->post('start_time'); $s_time=strtotime($start_time); $end_time= $this->post('end_time'); $e_time=strtotime($end_time); $pname= $this->post('pname'); $description= $this->post('description'); $possibility= $this->post('possibility'); $sort= $this->post('sort'); $awards=[]; foreach ($pname as $k=>$v){ $awards[$k]['name']=$v; $awards[$k]['description']=$description[$k]; $awards[$k]['possibility']=$possibility[$k]; $awards[$k]['sort']=$sort[$k]; } if($this->errorMsg){ return $this->error(100000004,$this->errorMsg); }else{ //获取用户ID $uid=$_SESSION['userId']; //获取发布人角色 ID $roleId=$_SESSION['user_relation']['role_type']; } $data = $this->KClient('apply', 'Lottery')->add($name, $desc, $content, $s_time, $e_time, $uid, $roleId, $awards); if ( $data['code'] == 0 ) { return $this->success($data); } else { return $this->error($data['code']); } } //活动列表 public function 3listAction(){ $pageSize=5; $order='id desc'; $this->rule['page'] = V::intVal()->min(0)->setTemplate('页码错误'); $page = $this->get('page',1); $offset=($page-1)*$pageSize; $data = $this->kClient("apply", "Lottery")->list($offset, $pageSize,$order); $pager = new Tools\AdminPager('lotterylist', $page, $data['data']['count'],$pageSize,1); $this->assign("itemList", $data['data']['list']); $this->assign("page", $pager->show()); } //活动奖项详情 public function 4descAction(){ $this->rule['rid'] = V::intVal()->setTemplate('活动不存在'); $rid = $this->get('rid'); $data = $this->kClient("apply", "LotteryAward")->getListByLotteryId($rid); $this->assign("lotteryList", $data['data']); } //展示单个活动详情 public function 5updescAction(){ $this->rule['rid'] = V::intVal()->setTemplate('活动不存在'); $rid = $this->get('rid',1); $data = $this->kClient("apply", "Lottery")->detail($rid); $this->assign("descList", $data['data']); } //修改活动详情 public function 6updateAction() { Y::disableView(); $this->rule['name'] = V::stringVal()->setTemplate('名称错误'); $this->rule['desc'] = V::stringVal()->setTemplate('活动简介错误'); $this->rule['content'] = V::stringVal()->setTemplate('活动详情错误'); $this->rule['start_time'] = V::intVal();//活动开始时间 $this->rule['end_time'] = V::intVal();//活动结束时间 $this->rule['id'] = V::intVal()->setTemplate('活动不存在');//活动ID $this->rule['rid'] = V::intVal()->setTemplate('用户ID不存在');//用户ID $this->rule['roleid'] = V::intVal()->setTemplate('角色ID不存在');//角色ID if($this->errorMsg){ return $this->error(100000004, $this->errorMsg); } $name= $this->post('name'); $desc= $this->post('desc'); $content= $this->post('content'); $s_time= $this->post('start_time'); $e_time= $this->post('end_time'); $uid= $this->post('rid'); $id= $this->post('id'); $roleid= $this->post('roleid'); $data = $this->kClient("apply", "Lottery")->update($id, $name, $s_time, $e_time, $desc, $content, $uid, $roleid); if ( $data['code'] == 0 ) { return $this->success($data); } else { return $this->error($data['code']); } } //渲染添加奖品页面 public function 7addAction(){ // lottery活动id id 奖项id $this->rule['id'] = V::intVal()->setTemplate('奖项ID有误'); $this->rule['lottery'] = V::intVal()->setTemplate('活动ID有误'); if($this->errorMsg){ return $this->error(100000004, $this->errorMsg); } $awardId= $this->get('id'); $lotteryId= $this->get('lottery'); $this->assign("id", $awardId); $this->assign("lotteryid", $lotteryId); } /*添加奖品*/ public function 8addAction(){ $this->rule['name'] = V::stringVal()->setTemplate('奖品名称错误'); $this->rule['desc'] = V::stringVal()->setTemplate('奖项描述错误'); $this->rule['num'] = V::intVal()->setTemplate('奖品数量错误'); $this->rule['lotteryid'] = V::intVal()->setTemplate('活动ID有误'); $this->rule['id'] = V::intVal()->setTemplate('奖项ID有误'); if($this->errorMsg){ return $this->error(100000004, $this->errorMsg); } $name= $this->post('name'); $description= $this->post('desc'); $num= $this->post('num'); $lotteryId= $this->post('lotteryid'); $awardId= $this->post('id'); $data = $this->kClient("apply", "LotteryPrize")->add($lotteryId, $awardId, $name, $description, $num, $status=1); if ( $data['code'] == 0 ) { return $this->success($data); } else { return $this->error($data['code']); } } }
转载请注明原文地址: https://www.6miu.com/read-57639.html

最新回复(0)