public function __construct() { parent::__construct(); $this->model = getModelByName($_REQUEST['_controller']); $this->model || $this->error('模型不存在!'); $this->assign('model', $this->model); $this->option = getModelByName('guess_option'); $this->assign('option', $this->option); }
public function __construct() { if (_ACTION == 'show') { $GLOBALS['is_wap'] = true; } parent::__construct(); $this->model = getModelByName($_REQUEST['_controller']); $this->model || $this->error('模型不存在!'); $this->assign('model', $this->model); $this->option = getModelByName('vote_option'); $this->assign('option', $this->option); $this->vlog = getModelByName('vote_log'); $this->assign('vlog', $this->vlog); }
public function __construct() { parent::__construct(); $this->model = getModelByName($_REQUEST['_controller']); $this->model || $this->error('模型不存在!'); $this->assign('model', $this->model); $this->option = getModelByName('xydzp_option'); $this->assign('option', $this->option); $this->jplist = getModelByName('xydzp_jplist'); $this->assign('jplist', $this->jplist); $arr = array('lists', 'add', 'edit'); $action = strtolower(_ACTION); $res['title'] = '幸运大转盘'; $res['url'] = addons_url('Xydzp://Xydzp/lists'); $res['class'] = in_array($action, $arr) ? 'current' : ''; $nav[] = $res; $arr = array('jpoplists', 'jpopadd', 'jpopedit'); $res['title'] = '奖品库管理'; $res['url'] = addons_url('Xydzp://Xydzp/jpoplists'); $res['class'] = in_array($action, $arr) ? 'current' : ''; $nav[] = $res; $res['title'] = '功能设置'; $res['url'] = addons_url('Xydzp://Xydzp/config'); $res['class'] = $action == 'config' ? 'current' : ''; $nav[] = $res; $arr = array('zjloglists', 'zjlogadd', 'zjlogedit'); if (in_array($action, $arr)) { $res['title'] = '中奖记录'; $res['url'] = addons_url('Xydzp://Xydzp/zjloglists'); $res['class'] = 'current'; $nav[] = $res; } $arr = array('jplists', 'jpadd', 'jpedit'); if (in_array($action, $arr)) { $res['title'] = '奖品设置'; $res['url'] = addons_url('Xydzp://Xydzp/jplists'); $res['class'] = 'current'; $nav[] = $res; } $this->assign('nav', $nav); }
function getInfo($id, $update = false, $data = array()) { $key = 'Award_getInfo_' . $id; $info = S($key); if ($info === false || $update) { $info = (array) (empty($data) ? $this->find($id) : $data); if (count($info) != 0) { $model = getModelByName($this->tableName); $info['img_url'] = get_cover_url($info['img'], 100, 100); $info['type_name'] = get_name_by_status($info['award_type'], 'award_type', $model['id']); if ($info['award_type'] == 0) { // $info['price']=$info['score'].'积分'; $info['award_title'] = $info['score'] . '积分'; } else { if ($info['award_type'] == 1) { // $info['price'] = $info['price']==0?'未报价':$info['price']; $info['award_title'] = $info['price'] == 0 ? '' : '价值 ' . intval($info['price']) . '元'; } else { if ($info['award_type'] == 2) { $coupon = D('Addons://Coupon/Coupon')->getInfo($info['coupon_id']); $info['award_title'] = $coupon['title']; $info['coupon_num'] = $coupon['num']; } else { if ($info['award_type'] == 3) { $coupon = D('Addons://ShopCoupon/Coupon')->getInfo($info['coupon_id']); $info['coupon_num'] = $coupon['num']; $info['award_title'] = $coupon['title']; } else { if ($info['award_type'] == 4) { $info['award_title'] = '返现金额 ' . $info['money'] . '元'; } } } } } } S($key, $info, 86400); } return $info; }
public function getModel($model = null) { $model || ($model = $_REQUEST['_addons']); $model || ($model = $_REQUEST['model']); $model || $this->error('模型名标识必须!'); if (is_numeric($model)) { $model = M('model')->find($model); } else { $model = getModelByName($model); } $this->assign('model', $model); return $model; }
public function lzwg_add($lzwgid) { // $lzwgid = I ( 'lzwg_id', 0, 'intval' ); $uid = $map1['uid'] = $this->mid; $award = M('sport_award')->where($map1)->select(); $model = getModelByName('lottery_prize_list'); $fafangjp = D('LuckyFollow')->getLzwgAwardNum($lzwgid); $dao = D('LotteryPrizeList'); $lotteryPrizedata = $dao->getList($lzwgid); foreach ($lotteryPrizedata as $l) { $lp[$l['award_id']] = intval($l['award_num']); } foreach ($award as $v) { $v['has_pay'] = intval($fafangjp[$v['id']]); $v['set_num'] = intval($lp[$v['id']]); $awardArr[$v['id']] = $v; } if (IS_POST) { $awardNumArr = I('post.award_num'); // $prizeNum=0; foreach ($awardNumArr as $id => $num) { if ($num < 0) { $this->error('奖品数量不能小于0'); } // if ($num>0){ // $prizeNum++; // } if ($lp[$id] + $awardArr[$id]['count'] < $num) { $this->error($awardArr[$id]['name'] . '数量不能超过奖品库剩余的数量!'); } else { $awardArr[$id]['count'] = $awardArr[$id]['count'] + $lp[$id] - $num; } } // if ($prizeNum>9){ // $this->error('一场活动只能设置 9 种奖品'); // } foreach ($awardNumArr as $id => $num) { if (isset($lp[$id])) { // 更新数据 $map['sports_id'] = $lzwgid; $map['award_id'] = $id; $data['award_num'] = $num; $res = M('lottery_prize_list')->where($map)->save($data); $dao->getInfo($id, true); } else { // 增加数据 $data['sports_id'] = $lzwgid; $data['award_id'] = $id; $data['award_num'] = $num; $data['uid'] = $this->mid; $res = M('lottery_prize_list')->add($data); } } $awardDao = D('Award'); foreach ($awardArr as $id => $vo) { $res = $awardDao->update($id, $vo); } $prizelist = $dao->getList($lzwgid, true); foreach ($prizelist as &$v) { if ($fafangjp[$v['award_id']]) { $v['award_num'] = $v['award_num'] - $fafangjp[$v['award_id']]; } if ($v['award_num'] > 0) { $d[] = $v; } } foreach ($d as $v) { $prizeArr[] = array('prize_id' => $v['award_id'], 'prize_num' => $v['award_num']); } $lzwg_activities = D('Addons://Draw/Draw')->getInfo($lzwgid); $start_time = $lzwg_activities['start_time']; $end_time = $lzwg_activities['end_time']; // if ($end_time < NOW_TIME) { // $prizeid = - 1; // } else { get_lottery($prizeArr, $start_time, $end_time, $uid, $lzwgid, true); $this->success('添加' . $model['title'] . '成功!'); } $this->assign('sports_id', $lzwgid); // $this->assign ( 'prizes', $prizes ); $this->assign('awards', $awardArr); $this->display(); }