public function detail() { //所有分类 包含2级分类 $all_category_list = D('Group_category')->get_category(); $this->assign('all_category_list', $all_category_list); $database_extension_activity_list = D('Extension_activity_list'); $condition_extension_activity_list['pigcms_id'] = $_GET['id']; $now_activity = $database_extension_activity_list->field(true)->where($condition_extension_activity_list)->find(); if (empty($now_activity)) { $this->assign('jumpUrl', $this->config['site_url']); $this->error('该活动不存在'); } $extension_image_class = new extension_image(); $now_activity['all_pic'] = $extension_image_class->get_allImage_by_path($now_activity['pic']); $now_activity['info'] = str_replace('<img src="/upload/activity/content/', '<img src="' . $this->config['site_url'] . '/upload/activity/content/', $now_activity['info']); $activity_id = $now_activity['pigcms_id']; if ($now_activity['part_count']) { $tmp_part_list = D('')->field('`ear`.`pigcms_id`,`ear`.`time`,`ear`.`msec`,`ear`.`ip`,`ear`.`part_count`,`u`.`nickname`,`u`.`avatar`')->table(array(C('DB_PREFIX') . 'extension_activity_record' => 'ear', C('DB_PREFIX') . 'user' => 'u'))->where("`ear`.`activity_list_id`='{$activity_id}' AND `ear`.`uid`=`u`.`uid`")->order('`ear`.`pigcms_id` DESC')->select(); $part_list = $this->convertPartList($tmp_part_list); $this->assign('part_list', $part_list); // dump($part_list); if ($this->user_session && D('Extension_activity_record')->where(array('activity_list_id' => $activity_id, 'uid' => $this->user_session['uid']))) { $uid = $this->user_session['uid']; $tmp_user_part_list = D('')->field('`ear`.`pigcms_id`,`ear`.`time`,`ear`.`msec`,`ear`.`ip`,`ear`.`part_count`,`u`.`nickname`,`u`.`avatar`')->table(array(C('DB_PREFIX') . 'extension_activity_record' => 'ear', C('DB_PREFIX') . 'user' => 'u'))->where("`ear`.`activity_list_id`='{$activity_id}' AND `ear`.`uid`='{$uid}' AND `ear`.`uid`=`u`.`uid`")->order('`ear`.`pigcms_id` DESC')->select(); $user_part_list = $this->convertPartList($tmp_user_part_list); $this->assign('user_part_list', $user_part_list); } } $now_activity['money'] = floatval($now_activity['money']); $now_activity['lottery_number'] += 10000000; $this->assign('now_activity', $now_activity); // dump($now_activity); //找到该商品所属的活动 $parent_activity = D('Extension_activity')->field(true)->where(array('activity_id' => $now_activity['activity_term']))->find(); $this->assign('parent_activity', $parent_activity); //推荐两个活动 $tui_activityList = $database_extension_activity_list->field(true)->where(array('activity_term' => $now_activity['activity_term'], 'status' => '1', 'is_finish' => '0'))->order('RAND()')->limit(2)->select(); $extension_image_class = new extension_image(); foreach ($tui_activityList as &$value) { $value['list_pic'] = $extension_image_class->get_image_by_path(array_shift(explode(';', $value['pic'])), 's'); $value['url'] = $this->config['site_url'] . '/activity/' . $value['pigcms_id'] . '.html'; } $this->assign('tui_activityList', $tui_activityList); $tpl_name = ''; // dump($now_activity); switch ($now_activity['type']) { case '1': if ($now_activity['is_finish']) { $activity_id = $now_activity['pigcms_id']; import('ORG.Net.IpLocation'); $IpLocation = new IpLocation(); //中奖数值 $lottery_number_arr = array(); for ($i = 0; $i < 8; $i++) { array_push($lottery_number_arr, substr($now_activity['lottery_number'], $i, 1)); } $this->assign('lottery_number_arr', $lottery_number_arr); //获奖人信息 $lottery_user = D('User')->field('`uid`,`nickname`,`avatar`,`last_ip`')->where(array('uid' => $now_activity['lottery_uid']))->find(); $last_location = $IpLocation->getlocation(long2ip($lottery_user['last_ip'])); $lottery_user['last_ip_txt'] = iconv('GBK', 'UTF-8', $last_location['country']); $this->assign('lottery_user', $lottery_user); //获奖人员所有购买记录 $uid = $now_activity['lottery_uid']; $lottery_part_list = D('')->field('`eyr`.`record_id`,`ear`.`time`,`ear`.`msec`,`eyr`.`number`')->table(array(C('DB_PREFIX') . 'extension_activity_record' => 'ear', C('DB_PREFIX') . 'extension_yiyuanduobao_record' => 'eyr'))->where("`ear`.`activity_list_id`='{$activity_id}' AND `ear`.`uid`='{$uid}' AND `eyr`.`record_id`=`ear`.`pigcms_id`")->order('`eyr`.`pigcms_id` DESC')->select(); shuffle($lottery_part_list); $lottery_part_listArr = array(); foreach ($lottery_part_list as &$value) { $value['number'] += 10000000; if (empty($lottery_part_listArr[$value['record_id']])) { $lottery_part_listArr[$value['record_id']] = array('time' => $value['time'], 'msec' => $value['msec']); } $lottery_part_listArr[$value['record_id']]['list'][] = $value; } $this->assign('lottery_part_list', $lottery_part_list); $this->assign('lottery_part_listArr', $lottery_part_listArr); //当前用户所有购买记录 if ($this->user_session && $user_part_list) { $uid = $this->user_session['uid']; $lottery_user_list = D('')->field('`eyr`.`record_id`,`ear`.`time`,`ear`.`msec`,`eyr`.`number`')->table(array(C('DB_PREFIX') . 'extension_activity_record' => 'ear', C('DB_PREFIX') . 'extension_yiyuanduobao_record' => 'eyr'))->where("`ear`.`activity_list_id`='{$activity_id}' AND `ear`.`uid`='{$uid}' AND `eyr`.`record_id`=`ear`.`pigcms_id`")->order('`eyr`.`pigcms_id` DESC')->select(); shuffle($lottery_user_list); $lottery_user_listArr = array(); foreach ($lottery_user_list as &$value) { $value['number'] += 10000000; if (empty($lottery_user_listArr[$value['record_id']])) { $lottery_user_listArr[$value['record_id']] = array('time' => $value['time'], 'msec' => $value['msec']); } $lottery_user_listArr[$value['record_id']]['list'][] = $value; } } $this->assign('lottery_user_list', $lottery_user_list); $this->assign('lottery_user_listArr', $lottery_user_listArr); //购买记录 $activity_record_list = D('')->field('`ear`.*,`u`.`uid`,`u`.`nickname`')->table(array(C('DB_PREFIX') . 'extension_activity_record' => 'ear', C('DB_PREFIX') . 'user' => 'u'))->where("`ear`.`activity_list_id`='{$activity_id}' AND `ear`.`uid`=`u`.`uid`")->order('`ear`.`pigcms_id` DESC')->limit(50)->select(); $allCount = 0; foreach ($activity_record_list as &$value) { $tmp_time = date('His', $value['time']) . $value['msec']; $allCount += $tmp_time; $last_location = $IpLocation->getlocation(long2ip($value['ip'])); $value['ip_txt'] = iconv('GBK', 'UTF-8', $last_location['country']); } $this->assign('activity_record_list', $activity_record_list); $this->assign('allCount', $allCount); $tpl_name = '1yuan_finish'; } else { $tpl_name = '1yuan'; } break; default: $tpl_name = 'coupon'; } $this->display($tpl_name); }
public function ajax_upload_pic() { if ($_FILES['imgFile']['error'] != 4) { $img_mer_id = sprintf("%09d", $this->merchant_session['mer_id']); $rand_num = mt_rand(10, 99) . '/' . substr($img_mer_id, 0, 3) . '/' . substr($img_mer_id, 3, 3) . '/' . substr($img_mer_id, 6, 3); $upload_dir = './upload/extension/' . $rand_num . '/'; if (!is_dir($upload_dir)) { mkdir($upload_dir, 0777, true); } import('ORG.Net.UploadFile'); $upload = new UploadFile(); $upload->maxSize = $this->config['activity_pic_size'] * 1024 * 1024; $upload->allowExts = array('jpg', 'jpeg', 'png', 'gif'); $upload->allowTypes = array('image/png', 'image/jpg', 'image/jpeg', 'image/gif'); $upload->savePath = $upload_dir; $upload->thumb = true; $upload->imageClassPath = 'ORG.Util.Image'; $upload->thumbPrefix = 'm_,s_'; $upload->thumbMaxWidth = $this->config['activity_pic_width']; $upload->thumbMaxHeight = $this->config['activity_pic_height']; $upload->thumbRemoveOrigin = false; $upload->saveRule = 'uniqid'; if ($upload->upload()) { $uploadList = $upload->getUploadFileInfo(); $title = $rand_num . ',' . $uploadList[0]['savename']; $extension_image_class = new extension_image(); $url = $extension_image_class->get_image_by_path($title, 's'); exit(json_encode(array('error' => 0, 'url' => $url, 'title' => $title))); } else { exit(json_encode(array('error' => 1, 'message' => $upload->getErrorMsg()))); } } else { exit(json_encode(array('error' => 1, 'message' => '没有选择图片'))); } }