public function index() { $mobile = empty($_REQUEST['mobile']) ? '' : $_REQUEST['mobile']; $keywords = empty($_REQUEST['keywords']) ? '' : $_REQUEST['keywords']; $page = empty($_REQUEST[C('VAR_PAGE')]) ? 1 : $_REQUEST[C('VAR_PAGE')]; $num = empty($_REQUEST['numPerPage']) ? C('PAGE_LISTROWS') : $_REQUEST['numPerPage']; if ($mobile) { $map['mobile'] = $mobile; $mapPage['mobile'] = $mobile; $this->assign('mobile', $mobile); } $mapPage = $map; if ($keywords) { $map['nick_name'] = array('like', "%{$keywords}%"); $mapPage['keywords'] = $keywords; $this->assign('keywords', $keywords); } $db = M('Member'); $count = $db->where($map)->count(); $data = $db->where($map)->order('id desc')->limit($num)->page($page)->select(); foreach ($data as $key => $row) { $data[$key]['header'] = imgUrl($row['header']); } $this->_page($count, $mapPage, $page, $num); $this->assign('list', $data); $this->display(); }
protected function fileCache($content, $id, $size = '') { $file = imgUrl($this->type, $id, $size, false); $dir = dirname($file); if (!is_dir($dir)) { std_mkdirr($dir, 0755); } file_put_contents($file, $content); return $file; }
function edit() { $db = M('Auth'); $data = $db->where(array('id' => $_GET['id']))->find(); $data['check_data'] = json_decode($data['check_data'], true); $data['check_data']['header'] = imgUrl($data['check_data']['header']); $url = "http://121.40.92.53/ycbb/index.php/App/City/city_list"; $province = CurlController::curl($url, array()); $city = CurlController::curl($url, array('pid' => $data['check_data']['province_id'])); $area = CurlController::curl($url, array('pid' => $data['check_data']['city_id'])); $this->assign('vo', $data); $this->assign('province', $province['data']['list']); $this->assign('city', $city['data']['list']); $this->assign('area', $area['data']['list']); $this->display(); }
/** * 查询pid下的子id * @return json */ public function brand_list() { $pid = isset($_POST['pid']) ? (int) htmlspecialchars($_POST['pid']) : '0'; $arr = $this->dao->field("id ,name,pid,icon")->where(array('pid' => $pid, 'status' => 1))->select(); foreach ($arr as $key => $row) { $arr[$key]['icon'] = imgUrl($row['icon']); } if ($arr) { $data['list'] = $arr; $this->jsonUtils->echo_json_data(0, 'ok', $data); exit; } else { $this->jsonUtils->echo_json_msg(1, '暂无城市数据...'); exit; } }
public function banner() { $position = isset($_POST['position']) ? htmlspecialchars($_POST['position']) : ''; $db = M('Banner'); $data = $db->where(array('position' => $position))->field('url,title')->order('ord asc')->select(); if ($data) { foreach ($data as $key => $row) { $data[$key]['url'] = imgUrl($row['url']); } } else { $data = array(); } $arr['list'] = $data; $this->jsonUtils->echo_json_data(0, 'ok', $arr); }
/** * 商家服务项目列表 * * @return [type] [description] * 不传classid 获取该商户所有下的所有项目 */ public function service_list() { $mer_session_id = isset($_POST['mer_session_id']) ? htmlspecialchars(trim($_POST['mer_session_id'])) : ''; $pagenum = isset($_POST['page']) ? htmlspecialchars($_POST['page']) : '1'; $num = isset($_POST['num']) ? htmlspecialchars($_POST['num']) : '6'; $classid = isset($_POST['classid']) ? htmlspecialchars($_POST['classid']) : ''; $pagenum = ($pagenum - 1) * $num; $merchant_id = $this->session_handle->getsession_userid($mer_session_id); $map = "merchant_id={$merchant_id} "; $sql = "select se.name as service_name,se.id as service_id,ca.icon,\r\n \tse.pcat_id as classid,se.cat_id as sub_id ,se.price,se.sell_num,se.effect, se.timeout \r\n \tfrom " . C('DB_PREFIX') . "service as se \r\n \tjoin " . C('DB_PREFIX') . "category as ca on se.cat_id = ca.id where merchant_id={$merchant_id} "; if (!empty($classid)) { $sql = $sql . " and pcat_id={$classid}"; $map = $map . " and pcat_id ={$classid} "; } $sql = $sql . " group by cat_id order by se.addtime desc limit {$pagenum},{$num} "; $arr = $this->dao->query($sql); $count = $this->dao->where($map)->count(); if ($arr) { foreach ($arr as $key => $row) { $arr[$key]['icon'] = imgUrl($row['icon']); } } else { $arr = array(); } $data['list'] = $arr; $data['count'] = $count; $this->jsonUtils->echo_json_data(0, 'ok', $data); }
/** * 获取某人动态 * 公共查看 */ public function getSomeoneRecentV2() { $session_id = isset($_POST['session_id']) ? htmlspecialchars($_POST['session_id']) : ''; if (!empty($session_id)) { $member_id = $this->session_handle->getsession_userid($session_id, 1); $systemid = CommonController::getSystemUserid($member_id['id'], $member_id['type']); } $system_user_id = isset($_POST['system_user_id']) ? (int) htmlspecialchars($_POST['system_user_id']) : ''; $longitude = isset($_POST['longitude']) ? htmlspecialchars($_POST['longitude']) : ''; $latitude = isset($_POST['latitude']) ? htmlspecialchars($_POST['latitude']) : ''; $page = isset($_POST['page']) ? htmlspecialchars($_POST['page']) : '1'; $num = isset($_POST['num']) ? htmlspecialchars($_POST['num']) : '6'; if (empty($system_user_id) && empty($systemid)) { $this->jsonUtils->echo_json_msg(4, '参数不全'); exit; } if (empty($system_user_id) && !empty($systemid)) { $system_user_id = $systemid; } if (!empty($longitude) && !empty($latitude)) { $disable = true; } else { $disable = false; } $time = time(); $db = M('AnswerUserRecent'); $count = $db->where(array('system_user_id' => $system_user_id, 'status' => 0))->count(); $data = $db->table(C('DB_PREFIX') . "answer_user_recent as a")->join(C('DB_PREFIX') . "system_user as b on b.id = a.system_user_id")->join(C('DB_PREFIX') . "member as c on (c.id = b.sub_id and b.type = 0)")->where(array('a.system_user_id' => $system_user_id, 'a.status' => 0))->field('a.id,a.system_user_id,a.content,a.pics,a.addtime,a.laud_count,a.comment_count,a.longitude,a.latitude,b.name,b.header,b.brand_icon,c.gender')->page($page)->order('addtime desc')->limit($num)->select(); if ($data) { if ($disable) { foreach ($data as $key => $row) { $data[$key]['addtime'] = dealtime($row['addtime']); $data[$key]['header'] = imgUrl($row['header']); $data[$key]['gender'] = !empty($row['gender']) ? $row['gender'] : '0'; $data[$key]['brand_icon'] = imgUrl($row['brand_icon']); $data[$key]['pics'] = imgUrl(json_decode($row['pics'], true)); $data[$key]['distance'] = getDistance($longitude, $latitude, $row['longitude'], $row['latitude']); unset($data[$key]['longitude']); unset($data[$key]['latitude']); } } else { foreach ($data as $key => $row) { $data[$key]['addtime'] = date('Y-m-d H:i:s', $row['addtime']); $data[$key]['header'] = imgUrl($row['header']); $data[$key]['gender'] = !empty($row['gender']) ? $row['gender'] : '0'; $data[$key]['brand_icon'] = imgUrl($row['brand_icon']); $data[$key]['pics'] = imgUrl(json_decode($row['pics'], true)); } } } else { $data = array(); } $arr['count'] = empty($count) ? 0 : $count; $arr['list'] = $data; $this->jsonUtils->echo_json_data(0, 'ok', $arr); exit; }
public function detail() { // dump($_GET); $id = isset($_GET['id']) ? htmlspecialchars($_GET['id']) : ''; $furlen = isset($_GET['furl']) ? $_GET['furl'] : ''; $furl = urldecode(base64_decode($furlen)); // dump($furl); $currentUser = $this->getCurrentUser(); $db = M('AnswerUserRecent'); $recent = $db->table(C('DB_PREFIX') . "answer_user_recent as a ")->field('a.id,a.system_user_id,a.content,a.pics,a.addtime,b.header,b.name,a.latitude,a.longitude')->join(C('DB_PREFIX') . "system_user as b on b.id = a.system_user_id", 'LEFT')->where(array('a.id' => $id))->find(); $ulr = "http://api.map.baidu.com/geocoder/v2/?ak=4TGAqmofi6LcGeNYVFlOTOQG&output=json&pois=0&location=" . $recent['latitude'] . ',' . $recent['longitude']; $adrressJson = file_get_contents($ulr); $adrress = json_decode($adrressJson, true); // dump($adrress); $recent['baidumap'] = $adrress['result']['formatted_address']; if (empty($recent)) { $this->jsonUtils->echo_json_msg(4, '动态不存在'); exit; } $recent['header'] = imgUrl($recent['header']); $recent['addtime'] = date('Y-m-d H:i:s', $recent['addtime']); $recent['pics'] = imgUrl(json_decode($recent['pics'], true)); $this->data = array(); $data = $db->table(C('DB_PREFIX') . "answer_user_recent_reply as a")->field('a.id,b.name as reply_name,a.reply_id as system_userid,ifnull(c.name,"") as pidname,a.reply_content,a.addtime,a.pid')->join(C('DB_PREFIX') . "system_user as b on b.id = a.reply_id", 'LEFT')->join(C('DB_PREFIX') . "system_user as c on c.id = a.pid_id", 'LEFT')->where(array('a.recent_id' => $recent['id'], 'a.status' => 0))->order('a.addtime asc')->select(); if (!empty($data)) { foreach ($data as $key => $row) { $data[$key]['addtime'] = date('Y-m-d H:i:s', $row['addtime']); } $recent['count'] = count($data); $this->data = $data; $data = $this->dealRecentArray(); } else { $data = array(); $recent['count'] = 0; } // dump($recent); $recent['child'] = $data; $this->assign('furlen', $furlen); $this->assign('furl', $furl); $this->assign('data', $recent); // dump($recent); $this->display(); }
/** * 获取所有的回答 并进行排序重置 * @param int $issueId * @param int $num * @param int $page */ protected function getQuestionAnswer($issueId) { $ansDb = M(''); $data = $ansDb->table(C('DB_PREFIX') . "answer_reply as a")->field("a.laud_count,a.collect_count,a.issue_id,a.id,a.reply_id as system_user_id,b.name,b.header,a.reply_content,a.addtime,a.pid,c.name as pidname")->join(C('DB_PREFIX') . "system_user as b on a.reply_id = b.id")->join(C('DB_PREFIX') . "system_user as c on c.id =a.pid_id", 'left')->where(array('a.issue_id' => $issueId, 'a.status' => array(array('eq', 0), array('eq', 1), 'or')))->order('a.id asc')->select(); if ($data) { foreach ($data as $key => $row) { $data[$key]['addtime'] = $this->dealAlltime($row['addtime']); $data[$key]['pidname'] = empty($row['pidname']) ? '' : $row['pidname']; $data[$key]['header'] = imgUrl($row['header']); } $this->data = $data; $data = $this->dealAnswerArray(); //排序 // dump($data); rsort($data); } else { $data = array(); } return $data; }
public function edit() { $model = M("Merchant"); $id = $_REQUEST[$model->getPk()]; $vo = $model->getById($id); $vo['header'] = imgUrl($vo['header']); $model = M('city'); $cityArr = $model->where('pid=' . $vo['province_id'])->getField('id,name'); $areaArr = $model->where('pid=' . $vo['city_id'])->getField('id,name'); $city = "<option>请选择城市</option>"; $area = "<option>请选择地区</option>"; foreach ($cityArr as $key => $val) { if ($key == $vo['city_id']) { $city .= "<option selected value='{$key}'>{$val}</option>"; } else { $city .= "<option value='{$key}'>{$val}</option>"; } } foreach ($areaArr as $k => $v) { if ($k == $vo['area_id']) { $area .= "<option selected value='{$k}'>{$v}</option>"; } else { $area .= "<option value='{$k}'>{$v}</option>"; } } $model = M('Category'); $cate = $model->where('pid=0')->getField('id,name'); $pcatIdArr = json_decode($vo['pcat_id'], true); $category = ''; foreach ($cate as $key1 => $val1) { if (in_array($key1, $pcatIdArr)) { $category .= "<input checked type='checkbox' name='pcat_id[]' value='' />{$val1} "; } else { $category .= "<input type='checkbox' name='pcat_id[]' value='' />{$val1} "; } } $this->assign("category", $category); $this->assign('city', $city); $this->assign('area', $area); $this->assign('vo', $vo); $this->display(); }
public function uploadPic() { if ($_FILES) { $f_arr = mul_upload('/ChatPic/', 3); if ($f_arr) { $f_arr[0] = imgUrl($f_arr[0]); $this->jsonUtils->echo_json_data(0, 'ok', $f_arr[0]); exit; } } else { $this->jsonUtils->echo_json_msg(404, '未上传图片'); exit; } }
function metaTwitterTags($data = null, $loadDefaults = true) { $allData = array(); if ($loadDefaults) { $allData = array('card' => 'summary', 'title' => ENV_META_TITLE, 'description' => ENV_META_DESCRIPTION, 'image' => imgUrl(ENV_META_IMAGE, true)); } if (!is_null($data)) { $allData = array_merge($allData, $data); } foreach ($allData as $key => $val) { echo '<meta name="twitter:' . $key . '" content="' . $val . '" />'; } }
public function get_order() { $order_no = isset($_POST['order_no']) ? htmlspecialchars($_POST['order_no']) : ''; $member_session_id = $_POST['member_session_id']; $member_id = $this->session_handle->getsession_userid($member_session_id); if (empty($order_no)) { $this->jsonUtils->echo_json_msg(4, '订单号为空...'); exit; } $arr = $this->dao->table(C('DB_PREFIX') . "order as a")->field("a.order_no,a.addtime,b.id as merchant_id,b.header,b.merchant_name,a.reach_time,a.cart_data,a.member_remark,a.merchant_remark,a.total_price,a.total_time,a.type,a.sub_data,a.member_comment,a.merchant_comment,a.fail_content,a.status,b.tel")->join(C('DB_PREFIX') . 'merchant as b on a.merchant_id = b.id')->where("a.order_no={$order_no} and a.member_id = {$member_id} ")->find(); if ($arr) { $cart = json_decode($arr['cart_data'], true); unset($arr['cart_data']); $arr['system_user_id'] = CommonController::getSystemUserid($arr['merchant_id'], 2); $arr['header'] = imgUrl($arr['header']); $arr['cart_model'] = $cart['cart_model']; $arr['reach_time'] = date('Y-m-d H:i:s', $arr['reach_time']); $arr['addtime'] = date('Y-m-d H:i:s', $arr['addtime']); // $arr ['header'] = imgUrl ( $arr ['header'] ); $model = new Model(); $sub_data = json_decode($arr['sub_data'], true); switch ($arr['type']) { // 0 预约 1需求 2活动 case '0': $arr['pics'] = imgUrl($sub_data['pics']); // $arr ['distance'] = ''; $arr['list'] = $sub_data['list']; break; case '1' or '3': // 需求 $arr['pics'] = imgUrl($sub_data['pics']); // $arr ['distance'] = $sub_data ['distance']; $arr['list'] = $sub_data['list']; break; case '2': // 活动 // $arr ['distance'] = ''; $arr['list'] = array(); break; default: $this->jsonUtils->echo_json_msg(4, '数据异常'); exit; break; } unset($arr['sub_data']); if ($arr['status'] != 0) { if ($arr['member_comment'] > 0) { $sql = "select a.desc,c.header,c.nick_name,a.pics,from_unixtime(a.addtime,'%Y-%m-%d %H:%i:%s') as addtime,\r\n\t\t\t\t\ta.service_attitude,a.service_quality,a.merchant_setting\r\n\t\t\t\t\tfrom " . C('DB_PREFIX') . "comment as a left join\r\n\t\t\t\t\t" . C('DB_PREFIX') . "member as c on a.member_id=c.id\r\n\t\t\t\t\twhere a.order_no={$arr['order_no']} and type=0 limit 1"; $arro = $this->dao->query($sql); $arro[0]['header'] = imgUrl($arro[0]['header']); $arro[0]['pics'] = imgUrl(json_decode($arro[0]['pics'], true)); $arr['member_comment'] = '1'; $arr['member_comment_info'] = empty($arro[0]) ? '' : $arro[0]; } else { $arr['member_comment'] = '0'; $arr['member_comment_info'] = ''; } if ($arr['merchant_comment'] > 0) { $sql = "select a.desc,c.header,a.pics,c.merchant_name as nick_name,a.service_attitude,from_unixtime(a.addtime,'%Y-%m-%d %H:%i:%s') as addtime \r\n\t\t\t\t\tfrom " . C('DB_PREFIX') . "comment as a left join " . C('DB_PREFIX') . "merchant as c \r\n\t\t\t\t\ton a.merchant_id=c.id where a.order_no={$arr['order_no']} and type=2 limit 1"; $arro = $this->dao->query($sql); $arro[0]['header'] = imgUrl($arro[0]['header']); $arro[0]['pics'] = imgUrl(json_decode($arro[0]['pics'], true)); $arr['merchant_comment'] = '1'; $arr['merchant_comment_info'] = empty($arro[0]) ? '' : $arro[0]; } else { $arr['merchant_comment'] = '0'; $arr['merchant_comment_info'] = ''; } } else { $arr['merchant_comment_info'] = ''; $arr['member_comment_info'] = ''; } $this->jsonUtils->echo_json_data(0, 'ok', $arr); exit; } else { $this->jsonUtils->echo_json_msg(1, '该订单不存在..'); exit; } }
/** * 根据jid 获取用户信息 */ public function getChatUserData() { //跨域解决方法: 指定域名 header('Access-Control-Allow-Origin:http://www.caryu.net'); header('Access-Control-Allow-Credentials:true'); $jid = isset($_POST['jid']) ? htmlspecialchars($_POST['jid']) : ''; $db = M('SystemUser'); $data = $db->where(array('id' => $jid))->field('name,header')->find(); if ($data === false) { $this->jsonUtils->echo_json_msg(4, '查询失败'); exit; } else { $data['header'] = imgUrl($data['header']); $this->jsonUtils->echo_json_data(0, 'ok', $data); exit; } }
public function detail() { // dump($_GET); $id = isset($_GET['id']) ? htmlspecialchars($_GET['id']) : ''; if (empty($id)) { $this->error('id为空'); } $furlen = isset($_GET['furl']) ? $_GET['furl'] : ''; $furl = urldecode(base64_decode($furlen)); //已报价商家 $dis = M('')->table(C('DB_PREFIX') . "member_demand as a")->field('a.*,b.nick_name,b.mobile,b.header')->join(C('DB_PREFIX') . "member as b on a.member_id = b.id")->where("a.id={$id}")->find(); $dis['header'] = imgUrl($dis['header']); $dis['pics'] = imgUrl(json_decode($dis['pics'], true)); $db = M(''); //分开显示报价情况 // $bidding = $db ->table(C('DB_PREFIX')."merchant_bidding as a ")->field('b.name,a.price,a.out_time,c.merchant_name,c.header,c.mobile,c.tel,a.merchant_id') // ->join(C('DB_PREFIX')."category as b on a.sub_id = b.id",'LEFT') // ->join(C('DB_PREFIX')."merchant as c on a.merchant_id = c.id",'LEFT') // ->where(array('a.demand_id'=>$id))->order('a.addtime asc')->select(); // $biddingMerchant = array(); // foreach($bidding as $k =>$r){ // $bidding_data [$r['merchant_id']]['child'][] = $r; // $bidding_data [$r['merchant_id']]['total_price'] += $r['price']; // $bidding_data [$r['merchant_id']]['out_time'] += $r['price']; // if(!array($r['merchant_id'],$biddingMerchant)){ // $biddingMerchant[] = $r['merchant_id']; // } // } // dump($bidding_data);dump($biddingMerchant);die(); $bidding = $db->query("select sum(a.price) as total_price,sum(a.out_time) as total_time,b.merchant_name,b.header,b.mobile,b.tel ,b.id as merchant_id,b.latitude,b.longitude from " . C('DB_PREFIX') . "merchant_bidding as a left join " . C('DB_PREFIX') . "merchant as b on a.merchant_id = b.id where demand_id = " . $id . " group by merchant_id order by a.addtime asc"); $count = count($bidding); foreach ($bidding as $ke => $ro) { $bidding[$ke]['header'] = imgUrl($ro['header']); $distance = getDistance($dis['latitude'], $dis['longitude'], $ro['latitude'], $ro['longitude']); $bidding[$ke]['distance'] = $distance; $bidding[$ke]['remark'] = $this->getMerRemark($id, $ro['merchant_id']); unset($bidding[$ke]['latitude']); unset($bidding[$ke]['longitude']); $biddingMerchant[] = $ro['merchant_id']; } $db = M('DemandMerchantEnable'); $enable = $db->table(C('DB_PREFIX') . "demand_merchant_enable as f ")->join(C('DB_PREFIX') . "merchant as a on f.merchant_id = a.id", 'LEFT')->field('a.merchant_name,a.tel,a.id,a.mobile,a.header,a.longitude,a.latitude,a.address,b.name as province,c.name as city,d.name as area')->join(C('DB_PREFIX') . "city as b on a.province_id = b.id", 'LEFT')->join(C('DB_PREFIX') . "city as c on a.city_id = c.id", 'LEFT')->join(C('DB_PREFIX') . "city as d on a.area_id = d.id", 'LEFT')->where(array('f.demand_id' => $id))->select(); if ($enable === false) { $this->error('商户未收到需求'); } else { if (count($biddingMerchant) > 0) { foreach ($enable as $key => $row) { if (in_array($row['id'], $biddingMerchant)) { unset($enable[$key]); } } sort($enable); } } foreach ($enable as $key => $row) { $enable[$key]['header'] = imgUrl($row['header']); $enable[$key]['distance'] = getDistance($dis['latitude'], $dis['longitude'], $row['latitude'], $row['longitude']); } $enable = sort_asc($enable); $this->assign('merchant', $enable); $this->assign('furlen', $furlen); $this->assign('furl', $furl); $this->assign('data', $dis); $this->assign('bidding', $bidding); $this->display(); }
/** * 收藏列表 */ public function collect_listV2() { $member_session_id = $_POST['session_id']; $page = isset($_POST['page']) ? htmlspecialchars($_POST['page']) : '1'; $num = isset($_POST['num']) ? htmlspecialchars($_POST['num']) : '6'; // 1 收藏商家 3用户收藏问答 4 商家收藏问答 $type = isset($_POST['type']) ? htmlspecialchars($_POST['type']) : '1'; $limit = ($page - 1) * $num . ',' . $num; if ($type == 1) { $member_id = $this->session_handle->getsession_userid($member_session_id); $model = new Model(); $sql = "select b.id as merchant_id ,b.header,b.merchant_name,d.name as city_name,c.name as area_name,b.address\r\n\t\t\tfrom " . C('DB_PREFIX') . "collect as a left join\r\n\t\t\t" . C('DB_PREFIX') . "merchant as b on a.obj_id=b.id\r\n\t\t\tleft join " . C('DB_PREFIX') . "city as c on c.id=b.area_id\r\n\t\t\tleft join " . C('DB_PREFIX') . "city as d on d.id=b.city_id\r\n\t\t\twhere a.member_id={$member_id} and a.type = 1 limit {$limit}"; $arr = $model->query($sql); if ($arr) { foreach ($arr as $key => $value) { $arr[$key]['header'] = imgUrl($value['header']); } $data['list'] = $arr; $this->jsonUtils->echo_json_data(0, 'ok', $data); exit; } else { $data['list'] = array(); $this->jsonUtils->echo_json_msg(0, 'ok', $data); exit; } } elseif ($type == 3 || $type == 4) { $member_id = $this->session_handle->getsession_userid($member_session_id, 1); $systemid = CommonController::getSystemUserid($member_id['id'], $member_id['type']); $model = new Model(); $sql = "select c.title,c.id as problem_id,d.name as category_name,e.header,b.id as reply_id,b.reply_content,b.laud_count,b.collect_count\r\n\t\t\tfrom " . C('DB_PREFIX') . "collect as a left join\r\n\t\t\t" . C('DB_PREFIX') . "answer_reply as b on a.obj_id=b.id\r\n\t\t\tleft join " . C('DB_PREFIX') . "system_user as e on e.id=b.reply_id\r\n\t\t\tleft join " . C('DB_PREFIX') . "answer_problem as c on c.id=b.issue_id\r\n\t\t\tleft join " . C('DB_PREFIX') . "answer_category as d on d.id=c.pid\r\n\t\t\twhere a.member_id={$systemid} and a.type = {$type} order by a.addtime desc limit {$limit}"; $arr = $model->query($sql); if (!$arr) { $arr = array(); } else { foreach ($arr as $key => $row) { $arr[$key]['header'] = imgUrl($row['header']); } } $data['list'] = $arr; $this->jsonUtils->echo_json_data(0, 'ok', $data); exit; } }
/** * 需求列表 */ public function demand_list() { $member_session_id = $_POST['member_session_id']; $member_id = $this->session_handle->getsession_userid($member_session_id); $page = isset($_POST['page']) ? htmlspecialchars($_POST['page']) : '1'; $num = isset($_POST['num']) ? htmlspecialchars($_POST['num']) : '6'; // if ($type == 1) { // 已报价 $longitude = $_POST['longitude']; $latitude = $_POST['latitude']; if (empty($longitude) || empty($latitude)) { $this->jsonUtils->echo_json_msg(4, '经度或者纬度为空...'); exit; } // 查询已报价的需求 $db = M('MemberDemand'); $data = $db->table(C('DB_PREFIX') . "member_demand as a ")->field('a.addtime,a.title,a.id,a.expire_time,a.status as demand_status,a.is_bidding')->join(C('DB_PREFIX') . "member_demand_subitems as b on a.id =b.demand_id")->where("a.merchant_id =0 and a.member_id = {$member_id} and a.member_del = 0")->group('a.id')->page($page)->limit($num)->order('a.addtime desc')->select(); $db2 = M('MerchantBidding'); if ($data) { foreach ($data as $key => $row) { $bidding = $db2->query("select sum(a.price) as total_price,sum(a.out_time) as total_time,b.merchant_name,b.header ,b.id as merchant_id,b.latitude,b.longitude from " . C('DB_PREFIX') . "merchant_bidding as a left join " . C('DB_PREFIX') . "merchant as b on a.merchant_id = b.id where demand_id = " . $row['id'] . " group by merchant_id order by a.addtime asc"); $data[$key]['child_count'] = count($bidding); if ($data[$key]['child_count'] > 0) { foreach ($bidding as $ke => $ro) { $bidding[$ke]['header'] = imgUrl($ro['header']); $distance = getDistance($latitude, $longitude, $ro['latitude'], $ro['longitude']); $bidding[$ke]['distance'] = $distance; unset($bidding[$ke]['latitude']); unset($bidding[$ke]['longitude']); } } $data[$key]['addtime'] = date('Y-m-d H:i:s', $row['addtime']); // 1 已过期 0 未过期 $is_expire = time() - $row['expire_time'] > 0 ? '1' : '0'; if ($is_expire) { if ($row['demand_status'] == 0) { $data[$key]['demand_status'] = '3'; //过期 } } $data[$key]['child'] = $bidding; } $arr['list'] = $data; $this->jsonUtils->echo_json_data(0, "ok", $arr); exit; } else { $arr['list'] = array(); $this->jsonUtils->echo_json_data(0, "ok", $arr); exit; } // } // elseif ($type == 2) { // 未报价 // $limit = ($page-1)*$num.','.$num; // $arr = $this->dao->query ( "select id,title,reach_time,status as demand_status,from_unixtime(addtime,'%Y-%m-%d') as addtime,a.description,a.expire_time from " . C ( 'DB_PREFIX' ) . "member_demand as a where a.is_bidding = 0 and a.member_id = $member_id and a.member_del = 0 order by a.addtime desc limit $limit" ); // if ($arr) { // $data ['list'] = $arr; // foreach ( $arr as $key => $value ) { // $arr [$key] ['type'] = 2; // // 1 已过期 0 未过期 // $is_expire= time()-$value['expire_time'] > 0 ? '1':'0'; // if($is_expire){ // if($value['demand_status'] == 0){ // $arr[$key]['demand_status'] = '3';//过期 // } // } // } // } else { // $data ['list'] = array(); // } // $this->jsonUtils->echo_json_data ( 0, 'ok', $data ); // exit (); // }else{ // $this->jsonUtils->echo_json_msg ( 1, 'type 为空...' ); // exit (); // } }
/** * 获取商家编辑信息 */ function getMerchantInfo() { $id = isset($_POST['id']) ? htmlspecialchars($_POST['id']) : ''; // 商家id $salesman_session_id = isset($_POST['salesman_session_id']) ? htmlspecialchars($_POST['salesman_session_id']) : ''; $salesman_id = $this->session_handle->getsession_userid($salesman_session_id); if (empty($salesman_id)) { $this->jsonUtils->echo_json_msg(4, '会话id不能为空'); exit; } $db = M('Auth'); $auth = $db->where(array('mark_id' => $id, 'status' => 0))->find(); if ($auth == false) { $data = $this->merchant->where(array('id' => $id))->field('province_id,city_id,area_id,business_time,merchant_name,address,manager,tel,longitude,latitude,header')->find(); $data['status'] = '0'; } else { $data = json_decode($auth['check_data'], true); $data['status'] = '1'; } if ($data) { $data['header'] = imgUrl($data['header']); $data['province_name'] = CityController::getName($data['province_id']); $data['city_name'] = CityController::getName($data['city_id']); $data['area_name'] = CityController::getName($data['area_id']); $this->jsonUtils->echo_json_data(0, 'ok', $data); exit; } else { $this->jsonUtils->echo_json_msg(4, '该商家不存在'); exit; } }
/** * 商家头像上传 * * @return [type] [description] */ public function merchantHeader() { $mer_session_id = isset($_POST['mer_session_id']) ? htmlspecialchars(trim($_POST['mer_session_id'])) : ''; $merchant_id = $this->session_handle->getsession_userid($mer_session_id, 1); if ($_FILES) { $result = mul_upload('/Header/', 3); // Log::write(json_encode($result),'ERR'); if ($result) { $data['header'] = $result[0]; $id = $merchant_id['id']; $this->dao->where(array('id' => $merchant_id['id']))->save($data); CommonController::saveHeader($merchant_id['id'], $merchant_id['type'], $result[0]); $header = imgUrl($result[0]); $this->jsonUtils->echo_json_data(0, '上传成功!', array('header' => $header)); exit; } else { $this->jsonUtils->echo_json_msg(1, '上传失败!'); exit; } } else { $this->jsonUtils->echo_json_msg(1, '无文件上传!'); exit; } }
public function get_activity() { $id = isset($_POST['id']) ? htmlspecialchars($_POST['id']) : ''; if (empty($id)) { $this->jsonUtils->echo_json_msg(4, '活动ID为空'); exit; } $arr = $this->dao->query("select a.id,a.category_ids,a.name,a.merchant_id,b.merchant_name,b.address,a.second_price,a.market_price,a.start_time,a.end_time,a.cart_model,a.detail,a.pics,a.remain, a.order_time,a.business_hours,a.other from " . C('DB_PREFIX') . "activity as a left join ." . C('DB_PREFIX') . "merchant as b on a.merchant_id=b.id where a.effect =1 and a.id={$id}"); // echo $this->dao->getLastSql();exit(); if ($arr) { $merchant_id = $arr[0]['merchant_id']; $start_time = date('Y-m-d', $arr[0]['start_time']); $end_time = date('Y-m-d', $arr[0]['end_time']); $valid_time = $start_time . "到" . $end_time; //有效时间\ $cur_time = date('Y-m-d', time()); if (time() < $arr[0]['start_time']) { $remain_days = 0; $remain_time = 0; } else { $remain_days = $this->diff_days($start_time, $cur_time); //获取两日期相差天数 $remain_time = $arr[0]['end_time'] - time(); } $name = M('category')->where(array('id' => array('in', $arr[0]['category_ids'])))->field('name')->select(); $cate = ''; foreach ($name as $row) { $cate[] = $row['name']; } $arr[0]['category_name'] = empty($cate) ? '' : implode('、', $cate); //商家平均服务态度星级,服务质量星级,设备星级 $m_arr = $this->dao->query("select avg(service_attitude) as service_attitude ,avg(service_quality) as service_quality,avg(merchant_setting) as merchant_setting from " . C('DB_PREFIX') . "comment where merchant_id={$merchant_id} "); $arr[0]['valid_time'] = $valid_time; //有效时间 $arr[0]['remain_days'] = $remain_days; //剩余天数 $arr[0]['remain_time'] = $remain_time; //剩余miaoshu // $arr[0]['remain_time']=''; unset($arr[0]['start_time']); unset($arr[0]['end_time']); $arr[0]['service_attitude'] = $m_arr[0]['service_attitude'] == null ? '' : $m_arr[0]['service_attitude']; $arr[0]['service_quality'] = $m_arr[0]['service_attitude'] == null ? '' : $m_arr[0]['service_attitude']; $arr[0]['merchant_setting'] = $m_arr[0]['service_attitude'] == null ? '' : $m_arr[0]['service_attitude']; if ($arr[0]['pics']) { $json_obj = json_decode($arr[0]['pics'], true); $arr[0]['pics'] = imgUrl($json_obj); } $this->jsonUtils->echo_json_data(0, 'ok', $arr[0]); } else { $this->jsonUtils->echo_json_msg(1, '获取失败!'); exit; } }
/** * 用户查看商家评论列表 */ public function comment_list() { $merchant_id = isset($_POST['merchant_id']) ? htmlspecialchars($_POST['merchant_id']) : ''; $page = isset($_POST['page']) ? htmlspecialchars($_POST['page']) : '1'; $num = isset($_POST['num']) ? htmlspecialchars($_POST['num']) : '6'; $limit = ($page - 1) * $num . ',' . $num; $sql = "select a.id,a.desc,from_unixtime(a.addtime,'%Y-%m-%d') as comment_time,b.header,b.nick_name,a.pics as member_name from " . C('DB_PREFIX') . "comment as a left join " . C('DB_PREFIX') . "member as b on a.member_id=b.id where a.merchant_id={$merchant_id} limit {$limit}"; $arr = $this->dao->query($sql); if ($arr === false) { $this->jsonUtils->echo_json_msg(1, '暂无评论记录...'); exit; } else { foreach ($arr as $key => $value) { if ($arr[$key]['pics']) { $pics_arr = json_decode($arr[$key]['pics']); $arr[$key]['pics'] = imgUrl($pics_arr); } else { $arr[$key]['pics'] = ""; } } $count = $this->dao->where("merchant_id={$merchant_id} and parent_id=0")->count(); $data["count"] = $count; $data["list"] = $arr; $this->jsonUtils->echo_json_data(0, 'ok', $data); exit; } }
/** * 用户需求详情 type=1 未报价 type=2已报价 */ public function get_member_demand() { //跨域解决方法: 指定域名 header('Access-Control-Allow-Origin:http://www.caryu.net'); header('Access-Control-Allow-Credentials:true'); $mer_session_id = $_POST['mer_session_id']; $merchant_id = $this->session_handle->getsession_userid($mer_session_id); $id = (int) $_POST['id']; $bidd = M('MerchantBidding')->where(array('demand_id' => $id, 'merchant_id' => $merchant_id))->find(); if ($bidd) { $type = 2; } else { $type = 1; } if (empty($id)) { $this->jsonUtils->echo_json_msg(4, '车主需求ID为空...'); exit; } $arr = $this->dao->query("select a.id,a.status as demand_status ,from_unixtime(a.reach_time,'%Y-%m-%d %H:%i') as reach_time ,a.description,a.pics,a.member_id,a.longitude,a.latitude,a.cart_data,b.nick_name,b.header,a.publish,a.expire_time from " . C('DB_PREFIX') . "member_demand as a left join " . C('DB_PREFIX') . "member as b on a.member_id = b.id where a.id={$id}"); if ($arr) { $arr[0]['header'] = imgUrl($arr[0]['header']); $cart = json_decode($arr[0]['cart_data'], true); $arr[0]['cart_model'] = $cart['cart_model']; $model = new Model(); $merchant = M('Merchant'); $mer_arr = $merchant->field("longitude,latitude")->where("id={$merchant_id}")->select(); $longitude = $arr[0]['longitude']; // 用户发布需求的经纬度 $latitude = $arr[0]['latitude']; $demand_id = $arr[0]['id']; // 计算商家店铺和用户需求距离 $arr[0]['distance'] = getDistance($latitude, $longitude, $mer_arr[0]['latitude'], $mer_arr[0]['longitude']); $is_expire = time() - $arr[0]['expire_time'] > 0 ? '1' : '0'; if ($is_expire) { if ($arr[0]['demand_status'] == 0) { $arr[0]['demand_status'] = '3'; //过期 } } // 服务项目信息 if ($arr[0]['publish'] == 0) { $category = "category"; } elseif ($arr[0]['publish'] == 1) { $category = "car_maintain_category"; } else { $this->jsonUtils->echo_json_msg(4, '订单有误'); exit; } // $s_arr = $model->query("select b.name,b.id from " . C('DB_PREFIX') . "member_demand_subitems as a left join " . C('DB_PREFIX') . "{$category} as b on a.category_id=b.id where a.demand_id={$demand_id} "); $perlist = array(); if ($s_arr) { if ($type == 1) { // 未报价 $arr[0]['merchant_remark'] = ''; } elseif ($type == 2) { // 已报价 bidding $merchant_remark = M('MerchantBiddingRemark')->where(array('demand_id' => $id, 'merchant_id' => $merchant_id))->getField('remark'); $arr[0]['merchant_remark'] = !empty($merchant_remark) ? $merchant_remark : ''; $map['demand_id'] = $id; $map['merchant_id'] = $merchant_id; $alert_price = M('MerchantBidding')->where($map)->field('id as bidding_id,price,sub_id as cat_id,out_time as time')->select(); foreach ($alert_price as $tem) { $price[$tem['cat_id']] = $tem; } } else { $this->jsonUtils->echo_json_msg(4, '参数不全.'); exit; } // 区分是报价为0 还是未报价,-1标识未报价 foreach ($s_arr as $key => $row) { $perlist[$key]['category_id'] = $row['id']; $perlist[$key]['server_name'] = $row['name']; $perlist[$key]['is_server'] = 1; $perlist[$key]['price'] = !isset($price[$row['id']]['price']) ? '-1' : $price[$row['id']]['price']; $perlist[$key]['bidding_id'] = !isset($price[$row['id']]['bidding_id']) ? '-1' : $price[$row['id']]['bidding_id']; $perlist[$key]['time'] = !isset($price[$row['id']]['time']) ? '-1' : $price[$row['id']]['time']; } } $arr[0]['list'] = $perlist; if ($arr[0]['pics']) { $json_obj = json_decode($arr[0]['pics'], true); $arr[0]['pics'] = imgUrl($json_obj); } else { $arr[0]['pics'] = ''; } $arr[0]['cart_model'] == null ? '' : $arr[0]['cart_model']; $this->jsonUtils->echo_json_data(0, 'ok', $arr[0]); exit; } else { $this->jsonUtils->echo_json_msg(1, '没有该用户需求...'); exit; } }
/** * 上传图片,仅供图片修改删除 新增 使用,(未存储session,由js确定最终数据) */ public function uploadPicByEdit() { $type = $_REQUEST['type']; $config = array('1' => array('/Answer/', 'pics_answer', 1), '2' => array('/Recent/', 'pics_recent', 2)); if (empty($type) || empty($config[$type])) { die(json_encode(array("code" => 4, 'msg' => '请联系管理员'))); exit; } if (!empty($_FILES)) { $arr = mul_upload($config[$type][0], $config[$type][2]); if ($arr) { $arr = imgUrl($arr); //$pic = $config[$type][1]; //$_SESSION[$pic][]=$arr[0]; die(json_encode(array("code" => 0, 'msg' => 'ok', 'data' => $arr[0]))); exit; } } else { die(json_encode(array("code" => 4, 'msg' => '请选择上传图片'))); exit; } }
/** * 获取会员简短详情 */ public function get_short_memberV2() { $member_session_id = $_POST['member_session_id']; $member_id = $this->session_handle->getsession_userid($member_session_id); $arr = $this->dao->table(C('DB_PREFIX') . "member as a")->field("a.id,a.nick_name,a.header,e.brand_icon,b.name as brand_name")->join(C('DB_PREFIX') . "cart as c on (c.member_id = a.id and c.default_cart = 1)", 'LEFT')->join(C('DB_PREFIX') . "car_brand as b on b.id = c.brand_id", 'LEFT')->join(C('DB_PREFIX') . "system_user as e on (e.sub_id = a.id and e.type = 0)", 'LEFT')->where("a.id={$member_id}")->find(); $arr['header'] = imgUrl($arr['header']); $arr['brand_name'] = !empty($arr['brand_name']) ? $arr['brand_name'] : ''; $arr['brand_icon'] = imgUrl($arr['brand_icon']); if ($arr) { $this->jsonUtils->echo_json_data(0, 'ok', $arr); exit; } else { $this->jsonUtils->echo_json_msg(1, '获取个人信息失败...'); exit; } }
/** * 获取活动详情 1未开始 2进行中 3已下架 */ public function get_activity() { $id = (int) $_POST['id']; $sessionid = isset($_POST['mer_session_id']) ? htmlspecialchars($_POST['mer_session_id']) : ''; $merchant_id = isset($_POST['merchant_id']) ? htmlspecialchars($_POST['merchant_id']) : ''; if (empty($merchant_id)) { if (!empty($sessionid)) { $merchant_id = $this->session_handle->getsession_userid($sessionid); } else { $this->jsonUtils->echo_json_msg(6, '商家id为空'); } } $arr = $this->activity_dao->where("id={$id} ")->find(); if ($arr) { if ($arr['pics']) { $json_obj = json_decode($arr['pics'], true); $arr['pics'] = imgUrl($json_obj); } $arr['start_time'] = date('Y-m-d H:i', $arr['start_time']); $arr['end_time'] = date('Y-m-d H:i', $arr['end_time']); $arr['valid_start_time'] = date('Y-m-d H:i', $arr['valid_start_time']); $arr['valid_end_time'] = date('Y-m-d H:i', $arr['valid_end_time']); $arr['category_name'] = CategoryController::getCategoryNames($arr['category_ids']); $arr['resttime'] = $arr['end_time'] - time() > 0 ? $arr['end_time'] - time() : 0; if ($arr['effect'] == 0) { // 审核中 只能下架 $arr['instock'] = 0; // 0下架 } else { if ($arr['end_time'] < time()) { // 已过期的活动 $arr['instock'] = 1; // 1上架 } else { $arr['instock'] = 0; // 0下架 } } $arr['merchant_name'] = MerchantController::getMerName($merchant_id); $star = MerchantController::getMerCommentStar($merchant_id); $arr['service_quality'] = $star['service_quality']; $arr['service_attitude'] = $star['service_attitude']; $arr['merchant_setting'] = $star['merchant_setting']; $this->jsonUtils->echo_json_data(0, 'ok', $arr); exit; } else { $this->jsonUtils->echo_json_msg(1, '获取失败!'); exit; } }
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> </head> <body> <div class="container"> <div class="row"> <div class="col-xs-12 col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3"> <article> <div class="main"> <header> <h1><img src="<?php imgUrl('lightwork.png'); ?> " alt="<?php metaTitle(); ?> "/></h1> <h2>Well, this is 404 page...</h2> </header> <section> <?php include templatePath('messages.php'); ?> <div> <p> It means that the server wasn't able to find the resource you're looking for <?php if (isset($_REQUEST['action'])) {
/** * 获取指定用户的默认车型 */ public function getDefaultCarV2() { $member_session_id = $_POST['member_session_id']; $member_id = $this->session_handle->getsession_userid($member_session_id); $db = M('Cart'); $data = $db->table(C('DB_PREFIX') . "cart as a")->field('a.id ,b.icon,a.cart_model,a.car_number,a.frame_number,a.default_cart')->join(C('DB_PREFIX') . "car_brand as b on a.brand_id = b.id", 'LEFT')->where(array('a.member_id' => $member_id, 'a.default_cart' => 1))->find(); // echo $db->getLastSql(); if ($data === false) { $data = array(); } else { $brand = explode(',', $data['cart_model']); $data['brand_name'] = $brand[0]; $data['view_name'] = $brand[1]; $data['icon'] = imgUrl($data['icon']); $data['addtime'] = date('Y-m-d H:i:s', $data['addtime']); $data['carttime'] = !empty($data['carttime']) ? date('Y-m-d', $data['carttime']) : ''; } $this->jsonUtils->echo_json_data(0, 'ok', $data); exit; }