public function getVCode() { if (!IS_POST) { return 1; // err } $token = $_POST['token']; $wecha_id = $_POST['wecha_id']; $telno = $_POST['telno']; $func = $_POST['func']; // 获得公司名字, 作为短信落款 $merchant = M('wxuser')->where(array('token' => $token, 'status' => 1))->field('company')->find(); if (empty($merchant['company'])) { $company = "领众科技"; } else { $company = $merchant['company']; } $result['errcode'] = 0; $result['msg'] = ''; $Cache = Cache::getInstance('File', array('expire' => '610')); $code = $Cache->get('vcode_' . $token . $telno); if (empty($code)) { $code = sprintf("%0" . strlen($max) . "d", mt_rand(100000, 999999)); $Cache->set('vcode_' . $token . $telno, $code); //$truth_code = $Cache->get('vcode_'.$token.$telno); } Log::record('truthcode:' . 'vcode_' . $token . $telno . ':' . $code); Log::save(); include LIB_PATH . 'Action/SmsSender.class.php'; $smsSender = new SmsSender(); $vcode_tmpl = C('vcode'); if (isset($vcode_tmpl)) { $smsContent = str_replace("#merchant#", $company, $vcode_tmpl); $smsContent = str_replace("#code#", $code, $smsContent); $res = $smsSender->notify($token, $func, $smsContent, $telno); if ($res !== 0) { $result['errcode'] = 1; } } else { $result['errcode'] = 1; } $this->ajaxReturn($result, 'json'); }
public function getcode() { $token = $this->_get('token'); $wecha_id = $this->_get('wecha_id'); $tel = $this->_post('tel'); $cardnum = $this->_post('cardnum'); $where = array('token' => $token, 'tel' => $tel, 'cardnum' => $cardnum); //根据电话号码验证会员是否被导入 $userinfo = M("physical_member")->where($where)->find(); if (!$userinfo) { echo '{"success":0,"msg":"没有找到您的会员卡信息,请联系商家导入。"}'; exit; } elseif ($userinfo['binded']) { echo '{"success":0,"msg":"此手机号已被绑定."}'; exit; } elseif ($userinfo['cardnum'] != $cardnum) { echo '{"success":0,"msg":"您输入的手机号与卡号不匹配,请重新输入。"}'; exit; } $Cache = Cache::getInstance('File', array('expire' => '310')); $scode = $Cache->get($token . $tel); if (!empty($scode)) { // 避免多次发送 echo '{"success":0,"msg":"验证码已发送,请稍侯。"}'; exit; } $code = $this->rand_number(100000, 999999); $Cache->set($token . $tel, $code); Log::record("Send code : " . $code . " at " . date("Y-m-d H:i:s") . "\r\n", Log::DEBUG); include LIB_PATH . 'Action/SmsSender.class.php'; $smsSender = new SmsSender(); $binding_tmpl = C('card_binding'); $smsContent = ''; if (isset($binding_tmpl)) { $smsContent = str_replace("#merchant#", '领众科技', $binding_tmpl); $smsContent = str_replace("#code#", $code, $smsContent); } if ($smsContent != '') { $re = $smsSender->notify($this->_get('token'), "huiyuan", $smsContent, $tel); if ($re == 0) { $Cache->set($token . $tel, $code); echo '{"success":1,"msg":"验证码已发送,请输入收到的短信验证码!"}'; } else { echo '{"success":0,"msg":"验证码发送失败,请稍侯再试。"}'; } } else { echo '{"success":0,"msg":"验证码发送失败,请稍侯再试。"}'; } }
public function getcode() { $code = $this->rand_number(100000, 999999); //普通提交方式 include_once 'HttpClient.class.php'; //目标主机的地址,我这里填上测试的地址 $Client = new HttpClient("mssms.cn:8000"); $url = "http://222.185.228.25:8000/msm/sdk/http/sendsmsutf8.jsp"; //请求的页面地址 //POST的参数 $mobile = $this->_post('mobile'); $params = array('username' => "JSMB260705", 'scode' => "095169", 'mobile' => $mobile, 'content' => "@1@={$code}", 'tempid' => "MB-2013102300"); $pageContents = HttpClient::quickPost($url, $params); echo "提交返回=" . $pageContents; exit; $token = '540e6acfz71'; $wecha_id = $this->_get('wecha_id'); $tel = '15678456321'; $cardnum = 'LZ948820080012'; $where = array('token' => $token, 'tel' => $tel, 'cardnum' => $cardnum); //根据电话号码验证会员是否被导入 $userinfo = M("physical_member")->where($where)->find(); if (!$userinfo) { echo '{"success":0,"msg":"没有找到您的会员卡信息,请联系商家导入。"}'; exit; } elseif ($userinfo['binded']) { echo '{"success":0,"msg":"此手机号已被绑定."}'; exit; } elseif ($userinfo['cardnum'] != $cardnum) { echo '{"success":0,"msg":"您输入的手机号与卡号不匹配,请重新输入。"}'; exit; } $Cache = Cache::getInstance('File', array('expire' => '310')); $scode = $Cache->get($token . $tel); if (!empty($scode)) { // 避免多次发送 echo '{"success":0,"msg":"验证码已发送,请稍侯。"}'; exit; } $code = $this->rand_number(100000, 999999); $Cache->set($token . $tel, $code); Log::record("Send code : " . $code . " at " . date("Y-m-d H:i:s") . "\r\n", Log::DEBUG); include LIB_PATH . 'Action/SmsSender.class.php'; $smsSender = new SmsSender(); $binding_tmpl = C('card_binding'); $smsContent = ''; if (isset($binding_tmpl)) { $smsContent = str_replace("#merchant#", '领众科技', $binding_tmpl); $smsContent = str_replace("#code#", $code, $smsContent); } if ($smsContent != '') { $re = $smsSender->notify($this->_get('token'), "huiyuan", $smsContent, $tel); if ($re == 0) { $Cache->set($token . $tel, $code); echo '{"success":1,"msg":"验证码已发送,请输入收到的短信验证码!"}'; } else { echo '{"success":0,"msg":"验证码发送失败,请稍侯再试。"}'; } } else { echo '{"success":0,"msg":"验证码发送失败,请稍侯再试。"}'; } }
public function book() { // 检查是否需要短信验证码 $token = $this->token; $enable_vcode = 0; $smsset = M('sms_set')->where(array('token' => $token))->find(); if (!empty($smsset)) { if (strpos($smsset['function'], 'vccanyin') !== FALSE) { $enable_vcode = 1; } } $tel = $this->_post('tel'); $smsvcode = $this->_post('smsvcode'); if ($enable_vcode) { if (!SmsvcodeAction::verifyVCode($token, $tel, $smsvcode)) { // 验证码不匹配 Log::save(); $this->ajaxReturn("请输入正确的短信验证码!", "ERROR", 0); } } $menus = $this->_post('menus'); $cart_id = $this->_post('cart_id'); $username = $this->_post('username'); $guestnum = $this->_post('guestnum'); $note = $this->_post('note'); $dinetime = $this->_post('dinetime'); $where['id'] = $cart_id; //获取token以便发送短信提醒 $order_info = M('dine_order')->join('tp_dine_rest on tp_dine_order.rest_id = tp_dine_rest.id')->where(array('tp_dine_order.id' => $cart_id))->field('tp_dine_rest.token,tp_dine_order.sn')->order('createtime desc')->find(); $menus = htmlspecialchars_decode($menus); $menus = htmlspecialchars_decode($menus); $jmenus = json_decode($menus, true); $price = 0; $dishnum = count($jmenus); $dishname = ''; for ($j = 0; $j < count($jmenus); $j++) { $price += (double) $jmenus[$j]['price'] * (int) $jmenus[$j]['nums']; $dishname .= $jmenus[$j]['name'] . ' '; } $data['price'] = $price; $data['tel'] = $tel; $data['username'] = $username; $data['menus'] = $menus; $data['status'] = 2; $data['submittime'] = time(); $data['guestnum'] = $guestnum; $data['note'] = $note; $data['dinetime'] = $dinetime; $data['dishnum'] = $dishnum; $data['table'] = $this->_post('table'); $order = M('dine_order')->where($where)->save($data); if ($order) { include LIB_PATH . 'Action/SmsSender.class.php'; // 获得公司名字, 作为短信落款 $company = ''; $merchant = M('wxuser')->where(array('token' => $this->token, 'status' => 1))->field('company')->find(); if (empty($merchant['company'])) { $company = "领众科技"; } else { $company = $merchant['company']; } $smsSender = new SmsSender(); $notify_tmpl = C('dine_notify'); if (isset($notify_tmpl)) { $smsContent = str_replace("#merchant#", $company, $notify_tmpl); $smsContent = str_replace("#username#", $data['username'], $smsContent); $smsContent = str_replace("#tel#", $data['tel'], $smsContent); $smsContent = str_replace("#dinetime#", $data['dinetime'], $smsContent); $smsContent = str_replace("#guestnum#", $data['guestnum'], $smsContent); $smsContent = str_replace("#dishnum#", $data['dishnum'], $smsContent); $smsContent = str_replace("#sn#", $order_info['sn'], $smsContent); $smsContent = str_replace("#menus#", $dishname, $smsContent); if ($data['table']) { $table_info = $data['table'] . "号桌"; $smsContent = str_replace("#table#", $table_info, $smsContent); } else { $smsContent = str_replace("#table#", '桌号无', $smsContent); } $res = $smsSender->notify($order_info['token'], "canyin_order", $smsContent); $this->ajaxReturn($order, "OK", 1); } } else { $this->ajaxReturn("服务器繁忙,订单生成失败,请稍后再试!", "ERROR", 0); } }
public function book() { if ($_POST) { $token = $this->_get('token'); // 检查是否需要短信验证码 $enable_vcode = 0; $smsset = M('sms_set')->where(array('token' => $token))->find(); if (!empty($smsset)) { if (strpos($smsset['function'], 'vchotel') !== FALSE) { $enable_vcode = 1; } } $tel = $this->_post('tel'); $smsvcode = $this->_post('smsvcode'); if ($enable_vcode) { if (!SmsvcodeAction::verifyVCode($token, $tel, $smsvcode)) { // 验证码不匹配 echo '{"success":0,"msg":"请输入正确的短信验证码。"}'; exit; } } $data['wecha_id'] = $this->_post('wecha_id'); $data['book_people'] = $this->_post('truename'); $data['remarks'] = $this->_post('remarks'); $data['tel'] = $this->_post('tel'); $data['book_num'] = $this->_post('nums'); $data['book_time'] = strtotime($this->_post('dateline')); $data['book_lefttime'] = strtotime($this->_post('leftdateline')); $id = $this->_post('id'); $data['room_type'] = $this->_post('roomtype'); $data['order_status'] = 3; $data['hid'] = $this->_get('hid'); $data['token'] = $this->_get('token'); $data['submit_time'] = time(); $data['sn'] = $this->get_order_sn(); $data['room_id'] = $_POST['room_id']; // $data['payment'] = $_POST['payment']; $price = M('Hotel_room')->where(array('id' => $id, 'token' => $data['token'], 'hid' => $data['hid'], 'status' => 1))->find(); //判断库存 if ($price['open_inventory'] == 1 && $price['inventory'] < $data['book_num']) { echo '{"success":0,"msg":"库存不足,请联系商家!"}'; exit; } $day = round(($data['leftbook_time'] - $data['book_time']) / 3600 / 24); if ($day <= 0) { $day = 1; } $data['price'] = $day * $price['yhprice'] * $data['book_num']; // $data['prepayment'] = $day* $price['sale_price'] * $data['book_num']; $data['text_cols'] = serialize($this->_post('text_cols')); $data['select_cols'] = serialize($this->_post('select_cols')); $order = M('Hotel_order')->data($data)->add(); //若下单成功则减库存 if ($order) { $booking['inventory'] = $price['inventory'] - $data['book_num']; M('Hotel_room')->where(array('id' => $id, 'token' => $data['token']))->data($booking)->save(); } if ($order) { include LIB_PATH . 'Action/SmsSender.class.php'; $smsSender = new SmsSender(); $re = $smsSender->notify($this->_get('token'), "dingdan", "您有一个新的微预订:来自" . $data['book_people'] . ",预订商品:" . $data['room_type'] . ",预订时间:" . $this->_post('dateline')); echo '{"success":1,"msg":"恭喜,预定成功。"}'; } else { echo '{"success":0,"msg":"请从新预定。"}'; } exit; } }
public function book() { if ($_POST['action'] == 'book') { $token = $this->_get('token'); // 检查是否需要短信验证码 $enable_vcode = 0; $smsset = M('sms_set')->where(array('token' => $token))->find(); if (!empty($smsset)) { if (strpos($smsset['function'], 'vcdindan') !== FALSE) { $enable_vcode = 1; } } $tel = $this->_post('tel'); $smsvcode = $this->_post('smsvcode'); if ($enable_vcode) { if (!SmsvcodeAction::verifyVCode($token, $tel, $smsvcode)) { // 验证码不匹配 echo '{"success":0,"msg":"请输入正确的短信验证码。"}'; exit; } } $data['wecha_id'] = $this->_post('wecha_id'); $data['book_people'] = $this->_post('truename'); $data['remarks'] = $this->_post('remarks'); $data['tel'] = $this->_post('tel'); $data['book_num'] = $this->_post('nums'); $data['book_time'] = strtotime($this->_post('dateline')); $id = $this->_post('id'); $data['room_type'] = $this->_post('roomtype'); $data['order_status'] = 3; $data['hid'] = $this->_get('hid'); $data['booking_id'] = $this->_post('id'); $data['token'] = $this->_get('token'); $data['submit_time'] = time(); $data['sn'] = $this->get_order_sn(); $price = M('Host_list_add')->where(array('id' => $id, 'token' => $data['token'], 'hid' => $data['hid'], 'status' => 1))->find(); //判断库存 if ($price['open_inventory'] == 1 && $price['inventory'] < $data['book_num']) { echo '{"success":0,"msg":"库存不足,请联系商家!"}'; exit; } $data['price'] = $price['yhprice'] * $data['book_num']; $data['text_cols'] = serialize($this->_post('text_cols')); $data['select_cols'] = serialize($this->_post('select_cols')); $order = M('Host_order')->data($data)->add(); //若下单成功则减库存 if ($price['open_inventory'] == 1 && $order) { $booking['inventory'] = $price['inventory'] - $data['book_num']; M('host_list_add')->where(array('id' => $id, 'token' => $data['token']))->data($booking)->save(); } if ($order) { include LIB_PATH . 'Action/SmsSender.class.php'; $smsSender = new SmsSender(); $notify_tmpl = C('host_notify'); $smsContent = ''; if (isset($notify_tmpl)) { $smsContent = str_replace("#merchant#", '领众科技', $notify_tmpl); $smsContent = str_replace("#book_people#", $data['book_people'], $smsContent); $smsContent = str_replace("#tel#", $data['tel'], $smsContent); $smsContent = str_replace("#room_type#", $data['room_type'], $smsContent); $smsContent = str_replace("#book_num#", $data['book_num'], $smsContent); $smsContent = str_replace("#dateline#", $this->_post('dateline'), $smsContent); $smsContent = str_replace("#price#", $data['price'], $smsContent); $smsContent = str_replace("#sn#", $data['sn'], $smsContent); } if ($smsContent != '') { $re = $smsSender->notify($this->_get('token'), "dingdan", $smsContent); } echo '{"success":1,"msg":"恭喜,预定成功。"}'; } else { echo '{"success":0,"msg":"系统忙,请稍后预定。"}'; } exit; } }