function suggest() { $config = getAddonConfig('Suggestions'); $this->assign($config); // dump ( $config ); $map['id'] = $data['uid'] = $this->mid; $user = get_followinfo($this->mid); $this->assign('user', $user); if (IS_POST) { // 保存用户信息 $nickname = I('nickname'); if ($config['need_nickname'] && !empty($nickname)) { $data['nickname'] = $nickname; } $mobile = I('mobile'); if ($config['need_mobile'] && !empty($mobile)) { $data['mobile'] = $mobile; } // 保存内容 $data['cTime'] = time(); $data['content'] = I('content'); $data['token'] = get_token(); $res = M('suggestions')->add($data); if ($res) { // 增加积分 add_credit('suggestions'); $this->success('增加成功,谢谢您的反馈'); } else { $this->error('增加失败,请稍后再试'); } } else { $this->display(); } }
function export() { set_time_limit(0); // 获取模型信息 $model = $this->model; // 解析列表规则 $list_data = $this->_list_grid($model); $grids = $list_data['list_grids']; $fields = $list_data['fields']; foreach ($grids as $v) { if ($v['title'] == '操作') { array_pop($grids); } else { $arr = explode('|', $v['field'][0]); if (count($arr) > 1) { $fun[$arr[0]] = $arr[1]; } $ht[$arr[0]] = $v['title']; } } $dataArr[0] = $ht; // 搜索条件 $map = $this->_search_map($model, $fields); $map['ask_id'] = $this->ask_id; $name = parse_name(get_table_name($model['id']), true); $data = M($name)->field(empty($fields) ? true : $fields)->where($map)->order($order)->select(); if ($data) { $qdao = D('AskQuestion'); foreach ($data as &$vv) { $user = get_followinfo($vv['uid']); $vv['nickname'] = $user['nickname']; $vv['times'] += 1; $vv['question_id'] = $qdao->getQuestionTitle($vv['question_id'], $this->ask_id); $vv['answer'] = implode(', ', unserialize($vv['answer'])); $vv['is_correct'] = $vv['is_correct'] == 1 ? '是' : '否'; } foreach ($data as &$vo) { foreach ($vo as $name => &$vv) { if (isset($fun[$name])) { if ($fun[$name] == 'get_name_by_status') { $vv = get_name_by_status($vv, $name, $model['id']); } else { $vv = call_user_func($fun[$name], $vv); } } } foreach ($ht as $key => $val) { $newArr[$key] = empty($vo[$key]) ? ' ' : $vo[$key]; } $vo = $newArr; } $dataArr = array_merge($dataArr, $data); } if ($return) { return $dataArr; } else { outExcel($dataArr, $map['module']); } }
public function lists() { D('Addons://Shop/Order')->autoSetFinish(); $this->assign('add_button', false); $this->assign('del_button', false); $this->assign('check_all', false); $map['token'] = get_token(); $map['shop_id'] = $this->shop_id; $search = $_REQUEST['order_number']; if ($search) { $this->assign('search', $search); $map1['nickname'] = array('like', '%' . htmlspecialchars($search) . '%'); $nickname_follow_ids = D('Common/User')->where($map1)->getFields('uid'); $nickname_follow_ids = implode(',', $nickname_follow_ids); if (!empty($nickname_follow_ids)) { $map['uid'] = array('exp', ' in (' . $nickname_follow_ids . ') '); } else { $map['order_number'] = array('like', '%' . htmlspecialchars($search) . '%'); } unset($_REQUEST['order_number']); } session('common_condition', $map); $list_data = $this->_get_model_list($this->model); // 分类数据 $map['is_show'] = 1; $list = M('weisite_category')->where($map)->field('id,title')->select(); $cate[0] = ''; foreach ($list as $vo) { $cate[$vo['id']] = $vo['title']; } $orderDao = D('Addons://Shop/Order'); // dump($list_data ['list_data']); foreach ($list_data['list_data'] as &$vo) { $param['id'] = $vo['id']; $order = $orderDao->getInfo($vo['id']); // dump($order); $vo = array_merge($vo, $order); $follow = get_followinfo($vo['uid']); $param2['uid'] = $follow['uid']; $vo['uid'] = '<a target="_blank" href="' . addons_url('UserCenter://UserCenter/detail', $param2) . '">' . $follow['nickname'] . '</a>'; $vo['cate_id'] = intval($vo['cate_id']); $vo['cate_id'] = $cate[$vo['cate_id']]; $goods = json_decode($order['goods_datas'], true); foreach ($goods as $vv) { $vo['goods'] .= '<img width="50" style="vertical-align:middle;margin:0 10px 0 0" src="' . get_cover_url($vv['cover']) . '"/>' . $vv['title'] . '<br><br>'; } $vo['goods'] = rtrim($vo['goods'], '<br><br>'); $vo['order_number'] = '<a href="' . addons_url('Shop://Order/detail', $param) . '">' . $vo['order_number'] . '</a>'; $vo['action'] = '<a href="' . addons_url('Shop://Order/detail', $param) . '">详情</a>'; if ($vo['status_code'] == 1) { $vo['action'] .= '<br><br><a href="' . addons_url('Shop://Order/set_confirm', $param) . '">商家确认</a>'; } } // dump($list_data ['list_data'] ); $this->assign($list_data); // dump ( $list_data ); $templateFile = $this->model['template_list'] ? $this->model['template_list'] : ''; $this->display($templateFile); }
function getCommentByPage($aim_id, $aim_table, $limit = 20, $order = 'id desc') { $map['aim_id'] = $aim_id; $map['aim_table'] = $aim_table; //$map['is_audit']=1; $list = $this->where($map)->order($order)->selectPage(); foreach ($list['list_data'] as &$v) { $follow = get_followinfo($v['follow_id']); if ($follow) { $v = array_merge($follow, $v); } } return $list; }
function getInfo($id, $update = false, $data = array()) { $key = 'DrawFollowLog_getInfo_' . $id; $info = S($key); if ($info === false || $update) { $info = (array) (empty($data) ? $this->find($id) : $data); $sports = D('Addons://Sports/Sports')->getInfo($info['sports_id']); $info['sportsarr'] = $sports; $follow = get_followinfo($info['follow_id']); $info['followarr'] = $follow; } S($key, $info, 86400); return $info; }
function detail($temp = '', $is_perview = false) { if (!isset($_GET['uid'])) { redirect(U('detail', array('uid' => $this->mid))); } $info = $this->_getInfo($this->uid); // dump($info); // exit; if ($this->mid != $this->uid) { $map_collect['from_uid'] = $this->mid; $map_collect['to_uid'] = $this->uid; $isExchange = M('business_card_collect')->where($map_collect)->getField('id'); // 是否交换了名片 if ($isExchange) { $isExchange = 1; } $this->assign('isExchange', $isExchange); } if ($isExchange == 0 && $this->uid != $this->mid) { $this->assign('isShowBtn', 1); } if ($isExchange == 1 && $this->uid != $this->mid) { $this->assign('needDeleteBtn', 1); } if ($this->uid == $this->mid) { $this->assign('isself', 1); $map['uid'] = $this->uid; $map['aim_id'] = $info['id']; $map['aim_table'] = 'business_card'; $comments = D('Addons://Comment/Comment')->where($map)->select(); foreach ($comments as &$c) { $userInfo = get_followinfo($c['follow_id']); $c['truename'] = $userInfo['truename']; $c['mobile'] = $userInfo['mobile']; $c['headimgurl'] = $userInfo['headimgurl']; } $this->assign('comments', $comments); } //名片栏目 $colunm = $this->_getBusinessCardColunm($this->uid); $this->assign('card_colunm', $colunm); $this->assign('is_perview', $is_perview); $this->display(ONETHINK_ADDON_PATH . 'BusinessCard/View/default/TemplateDetail/' . $info['temp'] . '/detail.html'); }
function card_show() { $model = $this->getModel('wish_card'); $Model = D(parse_name(get_table_name($model['id']), 1)); if (IS_POST) { //保存贺卡 $write_info = session('write_info'); $post_data = array_merge($write_info, $_POST); $post_data['mid'] = get_mid(); $post_data['token'] = get_token(); $post_data['create_time'] = time(); if ($id = $Model->add($post_data)) { $data = $post_data; $isMake = 1; } } else { $id = I('id'); $data = $Model->find($id); $Model->where('id=' . $id)->setInc('read_count', 1); //统计浏览数加1 $isMake = 0; } if ($data) { $sendUser = get_followinfo($data['mid']); $this->assign('sendUser', $sendUser); $this->assign('data', $data); $shareUrl = addons_url('WishCard://Wap/card_show', array('id' => $id)); $makeUrl = addons_url('WishCard://Wap/card_type'); $this->assign('shareUrl', $shareUrl); $this->assign('makeUrl', $makeUrl); $this->assign('isMake', $isMake); //是否制作的 //dump($shareUrl); $template = ONETHINK_ADDON_PATH . 'WishCard/View/default/Template/' . $data['template_cate'] . '/' . $data['template'] . '/index.html'; $this->assign("assetsPath", SITE_URL . '/Addons/WishCard/View/default/Template/' . $data['template_cate'] . '/' . $data['template']); $this->display($template); } else { $this->error("没有该模板或模板保存不成功!"); } }
function addCredit($data) { if (empty($data) || empty($data['credit_name'])) { return false; } $credit = $this->getCreditByName($data['credit_name']); // if (! $credit) // return false; empty($data['uid']) && ($data['uid'] = session('follow_id')); empty($data['cTime']) && ($data['cTime'] = time()); $data['token'] = get_token(); isset($data['experience']) || ($data['experience'] = $credit['experience']); isset($data['score']) || ($data['score'] = $credit['score']); $res = $this->add($data); if ($res) { $info = get_followinfo($data['uid']); $save['score'] = $info['score'] + $data['score']; $save['experience'] = $info['experience'] + $data['experience']; D('Common/Follow')->update($data['uid'], $save); // $this->updateFollowTotalCredit ( $data ['uid'] ); } return $res; }
public function lists() { $this->assign('add_button', false); $this->assign('search_button', false); $this->assign('del_button', false); $this->assign('check_all', false); // 解析列表规则 $data = $this->_list_grid($this->model); $this->assign($data); // 搜索条件 $map = $this->_search_map($this->model, $data['fields']); $name = parse_name(get_table_name($this->model['id']), true); $list = M($name)->where($map)->order('id DESC')->group('uid')->selectPage(); foreach ($list['list_data'] as &$vo) { $member = get_memberinfo($vo['uid']); if (empty($member)) { $member = get_followinfo($vo['uid']); } $vo['truename'] = $member['truename']; $vo['mobile'] = $member['mobile']; } $this->assign($list); $this->display(); }
function getPackageData($id) { $return['public_info'] = $public_info = get_token_appinfo(); $id = $map['target_id'] = I('id'); $return['data'] = $data = M('scratch')->find($id); // dump($data); // 奖项 $map['addon'] = 'Scratch'; $return['prizes'] = $prizes = M('prize')->where($map)->select(); // 抽奖记录 $all_prizes = M('sn_code')->where($map)->order('id desc')->select(); // dump ( $all_prizes ); foreach ($all_prizes as $all) { if ($all['prize_id'] > 0) { $has[$all['prize_id']] += 1; // 每个奖项已经中过的次数 $new_prizes[] = $all; // 最新中奖记录 $all['uid'] == $GLOBALS['mid'] && ($my_prizes[] = $all); // 我的中奖记录 } else { $no_count += 1; // 没有中奖的次数 } // 记录我已抽奖的次数 $all['uid'] == $GLOBALS['mid'] && ($my_count += 1); } $return['new_prizes'] = $new_prizes; $return['my_prizes'] = $my_prizes; // dump ( $new_prizes ); // dump ( $my_prizes ); // 权限判断 unset($map); $follow = get_followinfo($GLOBALS['mid']); $is_admin = is_login(); $error = ''; if ($data['end_time'] <= time()) { $error = '活动已结束'; } else { if ($data['max_num'] > 0 && $data['max_num'] <= $my_count) { $error = '您的刮卡机会已用完啦'; } else { if ($data['follower_condtion'] > intval($follow['status']) && !$is_admin) { switch ($data['follower_condtion']) { case 1: $error = '关注后才能参与'; break; case 2: $error = '用户绑定后才能参与'; break; case 3: $error = '领取会员卡后才能参与'; break; } } else { if ($data['credit_conditon'] > intval($follow['score']) && !$is_admin) { $error = '您的金币值不足'; } else { if ($data['credit_bug'] > intval($follow['score']) && !$is_admin) { $error = '您的金币值不够扣除'; } else { if (!empty($data['addon_condition'])) { addon_condition_check($data['addon_condition']) || ($error = '您没权限参与'); } } } } } } $return['error'] = $error; // 抽奖算法 if (empty($error)) { $return['prize'] = $this->_lottery($data, $prizes, $new_prizes, $my_count, $has, $no_count); } // 添加模板目录 $return['template'] = $data['template'] == "" ? "default" : $data['template']; return $return; }
private function getFollow($fids) { if (!empty($fids)) { foreach ($fids as $v) { $follow[] = get_followinfo($v); } foreach ($follow as $v) { $followinfo[$v['id']] = $v; } } return $followinfo; }
function set_sn_code() { $id = $param['id'] = I('id', 0, 'intval'); $lock = S('set_sn_code_lock'); if ($lock == 1 || isset($_GET['format'])) { $param['publicid'] = I('publicid'); $param['rand'] = NOW_TIME . rand(10, 99); $this->error('排队领取中', U('set_sn_code', $param)); } else { S('set_sn_code_lock', 1, 30); } $follow = get_followinfo($this->mid); $config = getAddonConfig('UserCenter'); // dump ( $config ); // S ( 'set_sn_code_lock', 0 ); // exit (); if ($config['need_bind'] && !(defined('IN_WEIXIN') && IN_WEIXIN) && !isset($_GET['is_stree']) && $this->mid != 1 && (empty($follow['mobile']) || empty($follow['truename']))) { Cookie('__forward__', $_SERVER['REQUEST_URI']); S('set_sn_code_lock', 0); // 解锁 redirect(addons_url('UserCenter://Wap/bind_prize_info')); } $info = D('Coupon')->getInfo($id); $member = explode(',', $info['member']); if (!in_array(0, $member)) { //判断是否为会员 $card_map['token'] = get_token(); $card_map['uid'] = $this->mid; $card = M('card_member')->where($card_map)->find(); if (!$card['member'] || !in_array(-1, $member) || !in_array($card['level'], $member)) { $msg = '您的等级未满足,还不能领取该优惠券!'; $this->show_error($msg, $info); } } if ($info['collect_count'] >= $info['num']) { $msg = empty($info['empty_prize_tips']) ? '您来晚了,优惠券已经领取完' : $info['empty_prize_tips']; $this->show_error($msg, $info); } if (!empty($info['start_time']) && $info['start_time'] > NOW_TIME) { $msg = empty($info['start_tips']) ? '活动在' . time_format($info['start_time']) . '开始,请到时再来' : $info['start_tips']; $this->show_error($msg, $info); } if (!empty($info['end_time']) && $info['end_time'] < NOW_TIME) { $msg = empty($info['end_tips']) ? '您来晚了,活动已经结束' : $info['end_tips']; $this->show_error($msg, $info); } $list = D('Common/SnCode')->getMyList($this->mid, $id); $this->assign('my_sn_list', $list); $my_count = count($list); $error = $this->_get_error($info, $my_count); if (!empty($error)) { S('set_sn_code_lock', 0); // 解锁 $this->display('over'); exit; } $data['target_id'] = $id; $data['uid'] = $this->mid; $data['addon'] = 'Coupon'; $data['sn'] = uniqid(); $data['cTime'] = NOW_TIME; $data['token'] = $info['token']; $res = D('Common/SnCode')->delayAdd($data); S('set_sn_code_lock', 0); // 解锁 // 扣除积分 if (!empty($info['credit_bug'])) { $credit['score'] = $info['credit_bug']; $credit['experience'] = 0; add_credit('coupon_credit_bug', 5, $credit); } if (isset($_GET['is_stree'])) { return false; } redirect(U('show', $param)); }
/** * 显示微信用户列表数据 */ function userCenter() { // dump ( $this->mid ); if ($this->mid < 0) { Cookie('__forward__', $_SERVER['REQUEST_URI']); redirect(U('bind')); } // 商城版的直接在商城个人中心里 redirect(addons_url('Shop://Wap/user_center')); $info = get_followinfo($this->mid); $this->assign('info', $info); // dump ( $info ); // 插件扩展 $dirs = array_map('basename', glob(ONETHINK_ADDON_PATH . '*', GLOB_ONLYDIR)); if ($dirs === FALSE || !file_exists(ONETHINK_ADDON_PATH)) { $this->error('插件目录不可读或者不存在'); } $arr = array(); $_REQUEST['doNotInit'] = 1; foreach ($dirs as $d) { require_once ONETHINK_ADDON_PATH . $d . '/Model/WeixinAddonModel.class.php'; $model = D('Addons://' . $d . '/WeixinAddon'); if (!method_exists($model, 'personal')) { continue; } $lists = $model->personal($data, $keywordArr); if (empty($lists) || !is_array($lists)) { continue; } if (isset($lists['url'])) { $arr[] = $lists; } else { $arr = array_merge($arr, $lists); } } foreach ($arr as $vo) { if (empty($vo['group'])) { $default_link[] = $vo; } else { $list_data[$vo['group']][] = $vo; } } $this->assign('default_link', $default_link); $this->assign('list_data', $list_data); // 会员页 $this->display(); }
function lists() { $this->assign('add_button', false); $model = $this->getModel('comment'); $page = I('p', 1, 'intval'); // 默认显示第一页数据 // 解析列表规则 $list_data = $this->_list_grid($model); $fields = $list_data['fields']; // 搜索条件 // $nickname = I ( 'nickname' ); // $map ['token'] = $fmap ['token'] = get_token (); $map = $this->_search_map($model, $fields); // if (! empty ( $nickname )) { // $fmap ['nickname'] = array ( // 'like', // "%$nickname%" // ); // $follow_ids = D ( 'Comment/Follow' )->where ( $fmap )->getFields ( 'id' ); // if (empty ( $follow_ids )) { // $map ['follow_id'] = 0; // } else { // $map ['follow_id'] = array ( // 'in', // $follow_ids // ); // } // } if (I('sports_id')) { $map['aim_table'] = 'sports'; $map['aim_id'] = I('sports_id'); } if (I('lzwg_id')) { $map['aim_table'] = 'lzwg'; $map['aim_id'] = I('lzwg_id'); } // empty ( $map ) || session ( 'common_condition', $map ); $row = empty($model['list_row']) ? 20 : $model['list_row']; $map['uid'] = $this->mid; // dump($map); $list_data['list_data'] = D('Comment')->where($map)->order('id desc')->page($page, $row)->select(); // lastsql(); /* 查询记录总数 */ $count = D('Comment')->where($map)->count(); // 分页 if ($count > $row) { $page = new \Think\Page($count, $row); $page->setConfig('theme', '%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%'); $list_data['_page'] = $page->show(); } $sportsDao = D('Addons://Sports/Sports'); foreach ($list_data['list_data'] as &$v) { if ($v['aim_table'] == 'sports') { $sports = $sportsDao->getInfo($v['aim_id']); $v['sports'] = $sports['vs_team']; $param['id'] = $v['id']; $param['is_audit'] = $v['is_audit']; } $url = addons_url('Comment://Comment/change_audit', $param); $v['is_audit'] = $v['is_audit'] == 0 ? '<a href="' . $url . '">未审核</a>' : '审核通过'; $v['content'] = parseComment($v['content']); $follow = get_followinfo($v['follow_id']); $v = array_merge($follow, $v); $v['content'] = '<span class="selectRange" data-url=' . addons_url('Comment://Comment/addBlack') . '>' . $v['content'] . '</span>'; } $this->assign($list_data); //dump($list_data); $this->display(); }
public function lists() { //D ( 'Addons://Shop/Order' )->autoSetFinish (); $orderDao = D('Addons://Shop/Order'); if (IS_POST) { $searchDate = I('search_date') ? I('search_date') : date('Y-n-d'); $searchKeyword = I('search_keyword') ? '&search_keyword=' . I('search_keyword') : ''; redirect('index.php/addon/Shop/Order/lists.html?' . 'search_date=' . $searchDate . $searchKeyword); } else { $searchDate = I('search_date') ? I('search_date') : date('Y-n-d'); $searchKeyword = I('search_keyword'); $user_ids_arrary = ''; if (!empty($searchKeyword)) { $fileter['true_name'] = array('like', '%' . htmlspecialchars($searchKeyword) . '%'); $fileter['mobile'] = array('like', '%' . htmlspecialchars($searchKeyword) . '%'); $fileter['_logic'] = 'OR'; $user_ids_arrary = D('Common/shop_address')->where($fileter)->getFields('id'); $this->assign('search_keyword', $searchKeyword); } if (!empty($user_ids_arrary)) { $filter_order['uid'] = array('IN', $user_ids_arrary); } if (!empty($searchDate)) { $search_date_timestamp = strtotime($searchDate); $search_date_add_day_timestamp = strtotime('+1 day', $search_date_timestamp); $filter_order['cTime'] = array('between', array($search_date_timestamp, $search_date_add_day_timestamp)); $this->assign('search_date', $searchDate); } if (!empty($searchKeyword) && empty($user_ids_arrary)) { // 按关键字查询无结果 } else { $order_lists = $orderDao->where($filter_order)->select(); } } foreach ($order_lists as &$vo) { $param['id'] = $vo['id']; $order = $orderDao->getInfo($vo['id']); // dump($order); $vo = array_merge($vo, $order); $follow = get_followinfo($vo['uid']); $param2['uid'] = $follow['uid']; //$vo ['cate_id'] = intval ( $vo ['cate_id'] ); //$vo ['cate_id'] = $cate [$vo ['cate_id']]; $goods = json_decode($order['goods_datas'], true); foreach ($goods as $vv) { //$vo ['goods'] .= '<img width="50" style="vertical-align:middle;margin:0 10px 0 0" src="' . get_cover_url ( $vv ['cover'] ) . '"/>' . $vv ['title'] . '<br><br>'; $vo['goods'] .= $vv['title'] . ':' . $vv['num'] . '份*¥' . $vv['price'] . '<br/>'; } $vo['goods'] = rtrim($vo['goods'], '<br><br>'); $vo['order_number'] = '<a href="' . addons_url('Shop://Order/detail', $param) . '">' . $vo['order_number'] . '</a>'; $vo['action'] = '<a href="' . addons_url('Shop://Order/detail', $param) . '">详情</a>'; if ($vo['status_code'] == 1) { $vo['action'] .= '<br><br><a href="' . addons_url('Shop://Order/set_confirm', $param) . '">商家确认</a>'; } $addressInfo = D('Addons://Shop/Address')->getInfo($order['uid']); //$vo ['uid'] = '<a target="_blank" href="' . addons_url ( 'UserCenter://UserCenter/detail', $param2 ) . '">' . $follow ['nickname'] . '</a>'; $vo['uid'] = $addressInfo['truename'] . '<br/>' . $addressInfo['mobile']; } // dump($list_data ['list_data'] ); $title_list = array('订单编号', '下单商品', '下单人', '总价', '下单时间', '支付类型', '订单跟踪'); $this->assign('title_lists', $title_list); $this->assign('order_lists', $order_lists); //$templateFile = $this->model ['template_list'] ? $this->model ['template_list'] : ''; $this->display(); }
function user_center() { $follow_id = $this->mid; $follow = get_followinfo($follow_id); $this->assign('follow', $follow); // dump($follow); // 全部订单 $orderUrl = addons_url('Shop://Wap/myOrder', array('shop_id' => $this->shop_id)); $this->assign('ordersUrl', $orderUrl); // 获取待付款 $unPayUrl = addons_url('Shop://Wap/unPayOrder', array('shop_id' => $this->shop_id)); $this->assign('unPayUrl', $unPayUrl); // 我的购物车 $cartUrl = addons_url('Shop://Wap/cart', array('shop_id' => $this->shop_id)); $this->assign('cartUrl', $cartUrl); // 我的收藏 $collectUrl = addons_url('Shop://Wap/myCollect', array('shop_id' => $this->shop_id)); $this->assign('collectUrl', $collectUrl); // 我的收获地址 $addressUrl = addons_url('Shop://Wap/myAddress', array('shop_id' => $this->shop_id)); $this->assign('addressUrl', $addressUrl); $this->display(); }
function get_mult_userinfo($uid) { $info = get_followinfo($uid); if (!$info) { $info = get_memberinfo($uid); } return $info; }
function _getFollowArr($openids, $field = 'openid') { if (empty($openids)) { return array(); } $omap['openid'] = array('in', $openids); $uids = M('public_follow')->where($omap)->field('uid,openid')->select(); foreach ($uids as $v) { $uidArr[$v['openid']] = $v['uid']; $userList[] = get_followinfo($v['uid']); } foreach ($userList as $v) { $userArr[$v[$field]]['truename'] = empty($v['truename']) ? $v['nickname'] : $v['truename']; $userArr[$v[$field]]['mobile'] = $v['mobile']; } return $userArr; }
function ajax_data() { $public_info = get_token_appinfo(); $this->assign('public_info', $public_info); $id = I('id'); $data = D('Scratch')->getScratchInfo($id); $this->assign('data', $data); // dump($data); // 奖项 $addon = 'Scratch'; $prizes = D('Prize')->getPrizes($id, $addon); $this->assign('prizes', $prizes); // 抽奖记录 // $all_prizes = M ( 'sn_code' )->where ( $map )->order ( 'id desc' )->select (); $all_prizes = D('SnCode')->getSnCodes($id, $addon); // dump ( $all_prizes ); foreach ($all_prizes as $all) { if ($all['prize_id'] > 0) { $has[$all['prize_id']] += 1; // 每个奖项已经中过的次数 $new_prizes[] = $all; // 最新中奖记录 $all['uid'] == $this->mid && ($my_prizes[] = $all); // 我的中奖记录 } else { $no_count += 1; // 没有中奖的次数 } // 记录我已抽奖的次数 $all['uid'] == $this->mid && ($my_count += 1); } $this->assign('new_prizes', $new_prizes); $this->assign('my_prizes', $my_prizes); // dump ( $new_prizes ); // dump ( $my_prizes ); // 权限判断 $follow = get_followinfo($this->mid); $is_admin = is_login(); $error = ''; if ($data['start_time'] > time()) { $error = '活动还没开始'; } if ($data['end_time'] <= time()) { $error = '活动已结束'; } else { if ($data['max_num'] > 0 && $data['max_num'] <= $my_count) { $error = '您的刮卡机会已用完啦'; } else { if ($data['follower_condtion'] > intval($follow['status']) && !$is_admin) { switch ($data['follower_condtion']) { case 1: $error = '关注后才能参与'; break; case 2: $error = '用户绑定后才能参与'; break; case 3: $error = '领取会员卡后才能参与'; break; } } else { if ($data['credit_conditon'] > intval($follow['score']) && !$is_admin) { $error = '您的金币值不足'; } else { if ($data['credit_bug'] > intval($follow['score']) && !$is_admin) { $error = '您的金币值不够扣除'; } else { if (!empty($data['addon_condition'])) { addon_condition_check($data['addon_condition']) || ($error = '您没权限参与'); } } } } } } $this->assign('error', $error); // 抽奖算法 if (empty($error)) { $prize = D('Scratch')->_lottery($data, $prizes, $new_prizes, $my_count, $has, $no_count); $prizes = D('Prize')->getPrizes($id, $addon); $prize['img'] = get_cover_url($prize['img']); $this->assign('prize', $prize); } $content = $this->fetch(ONETHINK_ADDON_PATH . 'Scratch/View/default/Scratch/data.html'); $returnData = I('callback') . '({"html":"' . rawurlencode($content) . '","prizeJson":"' . rawurlencode(json_encode($prize)) . '"})'; echo $returnData; exit; }
function getLzwgLuckyFollowInfo($id, $update = false, $data = array()) { $key = 'LuckyFollow_getLzwgLuckyFollowInfo_' . $id; $info = S($key); if ($info === false || $update) { $info = (array) (empty($data) ? $this->find($id) : $data); $award = D('Addons://Draw/Award')->getInfo($info['award_id']); $info['prizeid'] = $info['award_id']; $info['award_id'] = $award['name']; // $info ['sportsid'] = $info ['sport_id']; // $sport=M('sports')->find($info['sport_id']); // $sportsdao = D ( 'Addons://Sports/Sports' ); // $home_team = $dao->getInfo ( $info ['home_team'] ); // $visit_team = $dao->getInfo ( $info ['visit_team'] ); // $sport = D ( 'Addons://Sports/Sports' )->getInfo ( $info ['sport_id'] ); // $sport ['home_team'] = $home_team ['title']; // $sport ['visit_team'] = $visit_team ['title']; // $info['sport_id'] = $sport ['home_team'] . ' <br/><center>VS</center>' . $sport ['visit_team']; $lzwg = D('Addons://Draw/Draw')->getInfo($info['draw_id']); $info['sport_id'] = $lzwg['title']; $follow = get_followinfo($info['follow_id']); // $info['nick_name']=$follow['nickname']; // $info['headimgurl']=url_img_html($follow['headimgurl']); $info['nickname'] = url_img_html($follow['headimgurl']) . '<br/>' . $follow['nickname']; $info['nickname2'] = $follow['nickname']; $info['headimgurl'] = $follow['headimgurl']; $info['truename'] = $follow['truename']; $info['mobile'] = $follow['mobile']; $info['area'] = $follow['province'] . $follow['city']; $info['address'] = $info['area']; $info['score'] = $follow['score']; // 擂鼓数 // $drumData = $this->getDrumCount ( $info ['follow_id'] ); // $info ['drum_count'] = intval ( $drumData [$info ['sportsid']] ); $param['state'] = $info['state']; $param['id'] = $id; $url = addons_url("Draw://LuckyFollow/lzwgChangeState", $param); $info['state'] = $info['state'] == 0 ? "<a href='{$url}'>未兑换</a>" : '已兑换'; } S($key, $info, 86400); return $info; }