public function checktime() { $car_db = M('Car'); $order_db = M('Order'); $cid = $_POST['cid']; $bgtime = $_POST['bgtime']; $endtime = $_POST['endtime']; $num = diffBetweenTwoDays($bgtime, $endtime); $kznum = getDayWeek($bgtime, $num); $sharearr = explode(',', $kznum); $where = "cid = {$cid}"; $where .= " and ("; foreach ($sharearr as $k => $v) { if ($v) { $where .= "sharetime like '%" . $v . "%'"; if ($sharearr[$k + 1]) { $where .= " or "; } } } $where .= " or ( sharetime like '%1%' and sharetime like '%3%' )"; $where .= ")"; $cinfo = $car_db->where($where)->find(); if ($cinfo) { $omap['cid'] = $cid; $omap['bgtime'] = array('elt', $endtime); $omap['endtime'] = array('egt', $bgtime); $omap['status'] = array('not in', '2,6,7'); //$omap['status'] = array('not in',''); $olist = $order_db->field('oid')->where($omap)->select(); if ($olist) { echo '0'; } else { echo '1'; } } else { echo '0'; } }
function _login($forward = '') { global $_GPC, $_W; load()->model('user'); $member = array(); $username = trim($_GPC['username']); pdo_query('DELETE FROM' . tablename('users_failed_login') . ' WHERE lastupdate < :timestamp', array(':timestamp' => TIMESTAMP - 300)); $failed = pdo_get('users_failed_login', array('username' => $username, 'ip' => CLIENT_IP)); if ($failed['count'] >= 5) { message('输入密码错误次数超过5次,请在5分钟后再登录', referer(), 'info'); } if (!empty($_W['setting']['copyright']['verifycode'])) { $verify = trim($_GPC['verify']); if (empty($verify)) { message('请输入验证码'); } $result = checkcaptcha($verify); if (empty($result)) { message('输入验证码错误'); } } if (empty($username)) { message('请输入要登录的用户名'); } $member['username'] = $username; $member['password'] = $_GPC['password']; if (empty($member['password'])) { message('请输入密码'); } $record = user_single($member); $now = time(); $now = date("Y-m-d", $now); //计算天数 $day1 = $now; $day2 = date("Y-m-d", $record['endtime']); $diff = diffBetweenTwoDays($day1, $day2); $oldday = 16 - $diff; if (0 >= $oldday) { $oldday = 0; } if (!empty($record)) { if ($record['status'] == 1) { message('您的账号正在审核或是已经被系统禁止,请联系网站管理员解决!'); } if ($record['status'] != 0) { if ($day1 >= $day2) { if ($oldday == 0) { message('您的账号已经过期15天了,不幸的是:您属于体验会员,已经自动了删除账号!'); } else { message('您的账号已经到期,不幸的是:您属于体验会员,' . $oldday . '天后将自动删除账号!'); } } } $founders = explode(',', $_W['config']['setting']['founder']); $_W['isfounder'] = in_array($record['uid'], $founders); if (!empty($_W['siteclose']) && empty($_W['isfounder'])) { message('站点已关闭,关闭原因:' . $_W['setting']['copyright']['reason']); } $cookie = array(); $cookie['uid'] = $record['uid']; $cookie['lastvisit'] = $record['lastvisit']; $cookie['lastip'] = $record['lastip']; $cookie['hash'] = md5($record['password'] . $record['salt']); $session = base64_encode(json_encode($cookie)); isetcookie('__session', $session, !empty($_GPC['rember']) ? 7 * 86400 : 0); $status = array(); $status['uid'] = $record['uid']; $status['lastvisit'] = TIMESTAMP; $status['lastip'] = CLIENT_IP; user_update($status); if (empty($forward)) { $forward = $_GPC['forward']; } if (empty($forward)) { $forward = './index.php?c=account&a=display'; } if ($record['uid'] != $_GPC['__uid']) { isetcookie('__uniacid', '', -7 * 86400); isetcookie('__uid', '', -7 * 86400); } pdo_delete('users_failed_login', array('id' => $failed['id'])); message("欢迎回来,{$record['username']},您还可以使用{$diff}天。", $forward); } else { if (empty($failed)) { pdo_insert('users_failed_login', array('ip' => CLIENT_IP, 'username' => $username, 'count' => '1', 'lastupdate' => TIMESTAMP)); } else { pdo_update('users_failed_login', array('count' => $failed['count'] + 1, 'lastupdate' => TIMESTAMP), array('id' => $failed['id'])); } message('登录失败,请检查您输入的用户名和密码!'); } }
public function hjcinfoRecommend($id, $page = 1, $rows = 10, $search = array(), $sort = 'cid', $order = 'desc') { if (IS_POST) { $car_db = M('Car'); $city_db = M('City'); $hjcinfo_db = M('Hjcinfo'); $info = $hjcinfo_db->where('id=' . $id)->find(); // $where = array("1 = 1"); if (empty($search)) { $where[] = "`ctype` = '{$info[ctype]}'"; $where[] = "`cbrand` = '{$info[cbrand]}'"; $where[] = "`cmodel` = '{$info[cmodel]}'"; $where[] = "`canby` = '{$info[canby]}'"; $where[] = "`bsbox` = '{$info[bsbox]}'"; $where[] = "`output` = '{$info[output]}'"; $where[] = "`is_swap` = '{$info[is_swap]}'"; $where[] = "`userid` != '{$info[userid]}'"; } else { $num = diffBetweenTwoDays($search['bgtime'], $search['endtime']); //单位:天数 $kznum = getDayWeek($search['bgtime'], $num); $sharearr = explode(',', $kznum); $sql = "("; foreach ($sharearr as $k => $v) { if ($v) { $sql .= "sharetime like '%" . $v . "%'"; if ($sharearr[$k + 1]) { $sql .= " or "; } } } $sql .= " or ( sharetime like '%1%' and sharetime like '%3%' )"; $sql .= ")"; $where[] = $sql; } foreach ($search as $k => $v) { if (!$v) { continue; } switch ($k) { case 'output': if ($v != 0) { $where[] = "`{$k}` = '{$v}'"; } break; case 'city': //$ctmap['code'] = $v; //$ctinfo = $city_db->where($ctmap)->find(); $where[] = "C.{$k} = '{$v}'"; break; case 'ctype': $where[] = "`{$k}` = '{$v}'"; break; case 'cbrand': if ($v != 0) { $where[] = "`{$k}` = '{$v}'"; } break; case 'cmodel': if ($v != 0) { $where[] = "`{$k}` = '{$v}'"; } break; case 'bsbox': if ($v != 0) { $where[] = "`{$k}` = '{$v}'"; } break; case 'canby': if ($v != 0) { $where[] = "`{$k}` = '{$v}'"; } break; } } $where = implode(' and ', $where); $total = $car_db->where($where)->count(); $order = $sort . ' ' . $order; $limit = ($page - 1) * $rows . "," . $rows; $list = $car_db->table(C('DB_PREFIX') . 'Car C')->join(C('DB_PREFIX') . 'cartype CT on CT.tpid = C.ctype')->join(C('DB_PREFIX') . 'users U on U.userid = C.userid')->join(C('DB_PREFIX') . 'carbrand CB on CB.brandid = C.cbrand')->join(C('DB_PREFIX') . 'carmodel CM on CM.modelid = C.cmodel')->join(C('DB_PREFIX') . 'city Ci on C.city = Ci.code')->field("U.userid,U.name,U.ctel,C.cid,CT.tpname,C.cppro,C.cpzm, Ci.name as cityname,C.cpnum,C.output,C.bsbox,C.colour,C.canby,CB.brandname, CM.name as modelname, C.is_rz,C.is_recommend,C.cid as operateid")->where($where)->order($order)->limit($limit)->select(); //$a = $car_db->getlastsql(); $data = array('total' => $total, 'rows' => $list); $this->ajaxReturn($kznum); } else { $hjcinfo_db = M('Hjcinfo'); $car_db = M('Car'); $info = $hjcinfo_db->table(C('DB_PREFIX') . 'hjcinfo H')->join(C('DB_PREFIX') . 'cartype CT on CT.tpid = H.ctype')->join(C('DB_PREFIX') . 'city C on C.code = H.citycode')->join(C('DB_PREFIX') . 'users U on U.userid = H.userid')->field("H.*,U.name as uname, C.name as cityname, CT.tpname, FROM_UNIXTIME(H.ctime, '%Y-%m-%d %H:%i') as ctime")->where('H.id = ' . $id)->find(); $prov_db = M('Province'); $city_db = M('City'); $brand_db = M('Carbrand'); $model_db = M('Carmodel'); $colour_db = M('Carcolour'); $type_db = M('Cartype'); $regyear_db = M('Carregyear'); $map['code'] = array('neq', '0'); $plist = $prov_db->where($map)->select(); $ctlist = $city_db->where($map)->select(); $tylist = $type_db->select(); $blist = $brand_db->select(); $mlist = $model_db->select(); $rylist = $regyear_db->select(); //$menu_db = D('Menu'); $currentpos = '推荐座驾'; //栏目位置 $datagrid = array('options' => array('title' => $currentpos, 'url' => U('Hjcinfo/hjcinfoRecommend', array('grid' => 'datagrid', 'id' => $id)), 'toolbar' => 'Hjcinfo_hjcinforecommend_datagrid_toolbar', 'singleSelect' => false), 'fields' => array('选中' => array('field' => 'ck', 'width' => 5, 'checkbox' => true), '车主姓名' => array('field' => 'name', 'width' => 10), '车牌号码' => array('field' => 'cpnum', 'width' => 10, 'formatter' => 'hjcinfoHjcinfoRecommendCpnumFormatter'), '车辆类型' => array('field' => 'tpname', 'width' => 10), '品牌型号' => array('field' => 'modelname', 'width' => 10, 'formatter' => 'hjcinfoHjcinfoRecommendBrandFormatter'), '车辆排量' => array('field' => 'output', 'width' => 10, 'formatter' => 'hjcinfoHjcinfoRecommendoutputFormatter'), '变速箱' => array('field' => 'bsbox', 'width' => 10, 'formatter' => 'hjcinfoHjcinfoRecommendbsboxFormatter'), '可载人数' => array('field' => 'canby', 'width' => 10, 'formatter' => 'hjcinfoHjcinfoRecommendCanbyFormatter'), '颜色' => array('field' => 'colour', 'width' => 10), '所在城市' => array('field' => 'cityname', 'width' => 10), '管理操作' => array('field' => 'operateid', 'width' => 10, 'formatter' => 'hjcinfoHjcinfoRecommendOperateFormatter'))); $this->assign('plist', $plist); $this->assign('ctlist', $ctlist); $this->assign('tylist', $tylist); $this->assign('blist', $blist); $this->assign('mlist', $mlist); $this->assign('rylist', $rylist); $this->assign('info', $info); $this->assign('datagrid', $datagrid); /*echo "<pre>"; var_dump($info);die();*/ $this->display('hjc_rmlist'); } }
public function myorder() { if (session('userid')) { $order_db = M('Order'); $user_db = M('Users'); $car_db = M('Car'); $brand_db = M('Carbrand'); $model_db = M('Carmodel'); $uid = session('userid'); $gmap['cuserid'] = $uid; $gcount = $order_db->where($gmap)->count(); $Page = new \Think\Page($gcount, 10); $gxlist = $order_db->where($gmap)->limit($Page->firstRow . ',' . $Page->listRows)->order('ctime desc')->select(); $show = $Page->show(); foreach ($gxlist as $k => $v) { $num = diffBetweenTwoDays($v['bgtime'], $v['endtime']); $jymap['userid'] = $v['userid']; $jyinfo = $user_db->where($jymap)->field('nickname,name,photo,regtime')->find(); $gxlist[$k]['jyname'] = $jyinfo['name']; $gxlist[$k]['nickname'] = $jyinfo['nickname']; $gxlist[$k]['jyphoto'] = $jyinfo['photo']; $gxlist[$k]['numday'] = $num; } $hmap['userid'] = $uid; $hcount = $order_db->where($hmap)->count(); $hpage = new \Think\Page($hcount, 10); $hjlist = $order_db->where($hmap)->limit($hpage->firstRow . ',' . $hpage->listRows)->order('ctime desc')->select(); $hshow = $hpage->show(); foreach ($hjlist as $key => $val) { $hjcmap['cid'] = $val['cid']; $hjcinfo = $car_db->where($hjcmap)->find(); $cbmap['brandid'] = $hjcinfo['cbrand']; $cbinfo = $brand_db->field('brandname')->where($cbmap)->find(); $cmmap['modelid'] = $hjcinfo['cmodel']; $cminfo = $model_db->field('name')->where($cmmap)->find(); $hjlist[$key]['hjcphoto'] = $hjcinfo['cphoto1']; $hjlist[$key]['hjbm'] = $cbinfo['brandname'] . $cminfo['name']; $hjlist[$key]['hjcp'] = $hjcinfo['cppro'] . $hjcinfo['cpzm'] . substr_replace($hjcinfo['cpnum'], '****', 0, 4); } //dump($gxlist); $this->assign('gxlist', $gxlist); $this->assign('page', $show); $this->assign('hjlist', $hjlist); $this->assign('hpage', $hshow); $this->display(); } else { $this->redirect('User/login'); } }
public function clearedit($id, $paytype) { $appeal_db = M('Appeal'); $order_db = M('Order'); $appeallist = $appeal_db->where('oid=' . $id)->find(); $orderlist = $order_db->where('oid=' . $id)->find(); $info['id'] = $id; $info['paytype'] = $paytype; if ($orderlist['is_delay'] == '3') { $addrisk_db = M('Addrisk'); $num = diffBetweenTwoDays($orderlist['bgtime'], $orderlist['endtime']); $delays = $orderlist['s_price'] / $num; $admap['id'] = array('in', $orderlist['ot_safe']); $arlist = $addrisk_db->where($admap)->select(); foreach ($arlist as $k => $v) { $delays += $v['price']; } $dsprice = $orderlist['o_price'] / $num; $this->assign('delays', $delays); $this->assign('desprice', $dsprice); $deposit = $orderlist['deposit'] - ($delays + $dsprice); } else { $deposit = $orderlist['deposit']; } $this->assign('deposit', $deposit); $this->assign('orderlist', $orderlist); $this->assign('appeallist', $appeallist); $this->assign('info', $info); $this->display(); }
$spirituality = isset($spirituality) ? $spirituality : ""; $prayer_for_group = isset($prayer_for_group) ? $prayer_for_group : ""; $prayer_for_urgent = isset($prayer_for_urgent) ? $prayer_for_urgent : ""; $group_userHead_src = isset($group_userHead_src) ? $group_userHead_src : ""; $userHead_src = isset($group_userHead_src->userHead_src) ? $group_userHead_src->userHead_src : ""; $spiri_total_count = !empty($spiri_total_count) ? $spiri_total_count : "0"; $spiri_week_count = !empty($spiri_week_count) ? $spiri_week_count : "0"; $prayer_group_week_count = !empty($prayer_group_week_count) ? $prayer_group_week_count : "0"; $urgent_group_week_count = !empty($urgent_group_week_count) ? $urgent_group_week_count : "0"; $prayer_group_total_count = !empty($prayer_group_total_count) ? $prayer_group_total_count : "0"; $urgent_group_total_count = !empty($urgent_group_total_count) ? $urgent_group_total_count : "0"; $group_user_info = isset($group_user_info) ? $group_user_info : ""; // var_dump($group_user_info);exit; $user_created_at = isset($group_user_info->user_created_at) ? $group_user_info->user_created_at : ""; // var_dump($user_created_at);exit; $reg_days = diffBetweenTwoDays(date("Y-m-d", strtotime($user_created_at)), date("Y-m-d", time())) + 1; function diffBetweenTwoDays($day1, $day2) { $second1 = strtotime($day1); $second2 = strtotime($day2); if ($second1 < $second2) { $tmp = $second2; $second2 = $second1; $second1 = $tmp; } return ($second1 - $second2) / 86400; } //两个数相除得百分比 function get_percentage($val1, $val2, $decimal = 2) { if ($val2 == 0) {
public function ordersub() { if (IS_POST) { $order_db = M('Order'); $car_db = M('Car'); $user_db = M('Users'); $setting_db = M('Setting'); $addrisk_db = M('Addrisk'); $bgtime = $_POST['bgtime']; $endtime = $_POST['endtime']; $num = diffBetweenTwoDays($bgtime, $endtime); $cid = $_POST['cid']; $cuserid = $_POST['cuserid']; $cmap['cid'] = $cid; $cinfo = $car_db->where($cmap)->find(); $oprice = $cinfo['shareprice'] * $num; $setmap['key'] = 'SAFE_SET'; $setinfo = $setting_db->where($setmap)->find(); if ($setinfo['value']) { $safexs = $setinfo['value'] / 100; } else { $safexs = 20 / 100; } $setminmap['key'] = 'SAFE_MIN'; $setmininfo = $setting_db->where($setminmap)->find(); if ($setmininfo['value']) { $safemin = $setmininfo['value']; } else { $safemin = 20; } $setmaxmap['key'] = 'SAFE_MAX'; $setmaxinfo = $setting_db->where($setmaxmap)->find(); if ($setmaxinfo['value']) { $safemax = $setmaxinfo['value']; } else { $safemax = 60; } $sprice = floor($cinfo['shareprice'] * $safexs); if ($sprice < $safemin) { $sprice = $safemin; } if ($sprice > $safemax) { $sprice = $safemax; } $ot_safe = $_POST['ot_safe']; $adriskprice = 0; $ots = ""; if ($ot_safe) { foreach ($ot_safe as $k => $v) { $armap['id'] = $v; $arinfo = $addrisk_db->where($armap)->find(); if ($arinfo['ptype'] == '0') { $adriskprice += $arinfo['price'] * $num; } else { $adriskprice += $arinfo['price']; } $ots .= $v; if ($ot_safe[$k + 1]) { $ots .= ","; } } } $depsetmap['key'] = 'DEPOSIT_SET'; $depsetinfo = $setting_db->where($depsetmap)->find(); if ($depsetinfo['value']) { $depset = $depsetinfo['value']; } else { $depset = 5; } $sprice = $sprice * $num; $deposit = $cinfo['shareprice'] * ($num + $depset) + $sprice; $cprice = $oprice + $sprice + $adriskprice; if ($_POST['is_swap'] == '1') { $data['swapcid'] = $_POST['swapcid']; } if ($_POST['is_swap']) { $data['is_swap'] = $_POST['is_swap']; } else { $data['is_swap'] = '0'; } $data['order_sn'] = build_order_no(); $data['o_price'] = $oprice; $data['s_price'] = $sprice; $data['ot_safe'] = $ots; $data['c_price'] = $cprice; $data['cid'] = $cid; $data['cuserid'] = $cuserid; $data['userid'] = session('userid'); $data['bgtime'] = $bgtime; $data['endtime'] = $endtime; $data['getaddress'] = $_POST['getaddress']; $data['gethour'] = $_POST['gethour']; $data['ctime'] = time(); $data['status'] = '0'; $data['deposit'] = $deposit; $res = $order_db->add($data); if ($res) { //发送车主消息 $comap['userid'] = $cuserid; $cotel = M('Users')->field('tel,name,sex,openid')->where($comap)->find(); $uomap['userid'] = session('userid'); $uoinfo = $user_db->table(C('DB_PREFIX') . 'Users U')->join(C('DB_PREFIX') . 'City C on U.city = C.code')->join(C('DB_PREFIX') . 'Province P on U.province = P.code')->field('U.userid, U.name, U.sex, U.tel, C.name as city, P.name as province')->where($uomap)->find(); $uoinfo['name'] = namereplace($uoinfo['name'], $uoinfo['sex']); $content = "订单消息,来自" . $uoinfo['province'] . $uoinfo['city'] . "的" . $uoinfo['name'] . "计划在" . $bgtime . "至" . $endtime . "换驾您的车辆," . $_POST['gethour'] . ":00取车,对方电话" . $uoinfo['tel'] . ";请在微信公众号“我爱换驾”查询订单并确认回复;若1小时内没回复,默认为拒绝。您也可致电400-00000寻求帮助。"; sendmsg($cotel['tel'], $content); //发送订单消息 $sysmsg_db = D('Sysmsg'); $sysmsg_db->sendmsg($cuserid, "您有一个新订单需要处理,请查看处理。", '2', '0', $res); //驾友短信 $cotel['name'] = namereplace($cotel['name'], $cotel['sex']); $brandmap['brandid'] = $cinfo['cbrand']; $modelmap['modelid'] = $cinfo['cmodel']; $brandinfo = M('Carbrand')->where($brandmap)->find(); $modelinfo = M('Carmodel')->where($modelmap)->find(); $cinfo['cpnum'] = substr_replace($cinfo['cpnum'], '****', 0, 4); $jycontent = "您已经成功提交换驾" . $cotel['name'] . $brandinfo['brandname'] . $modelinfo['name'] . "(" . $cinfo['cppro'] . $cinfo['cpzm'] . $cinfo['cpnum'] . ")订单,车主将在1小时内处理您的换驾单,请耐心等待。若车主接受订单,您需要在2小时内使用共享豆或银行卡支付押金,否则订单会自动取消。"; sendmsg($uoinfo['tel'], $jycontent); //微信模板消息通知 if ($cotel['openid']) { @import("Wxapi.Wxpuch", APP_PATH, '.class.php'); $pushwx = new \Wxpuch(); $openid = $cotel['openid']; $template_id = "alI51h9F3yYcJ9FQ6_z_-HTVcvKgjmmJi3ozFcGFRSY"; $url = "http://www.52huanjia.com/clyy/weixin/index/morder/oid/" . $res; $data = array('first' => array('value' => urlencode("您好,你有一个新订单需要处理,请查看处理。"), 'color' => "#000000"), 'orderNo' => array('value' => urlencode($data['order_sn']), 'color' => '#000000'), 'orderStatus' => array('value' => urlencode('订单已生成,车主待处理。'), 'color' => '#000000'), 'takeCarAt' => array('value' => urlencode($bgtime), 'color' => '#000000'), 'returnCarAt' => array('value' => urlencode($endtime), 'color' => '#000000'), 'carType' => array('value' => urlencode($brandinfo['brandname'] . $modelinfo['name'] . "(" . $cinfo['cppro'] . $cinfo['cpzm'] . $cinfo['cpnum'] . ")"), 'color' => '#000000'), 'remark' => array('value' => urlencode('请在1小时内处理订单,否则订单将会自动取消。'), 'color' => '#000000')); $pushwx->doSend($openid, $template_id, $url, $data); } $this->redirect('Index/vieworder', array('oid' => $res)); } } }