예제 #1
0
파일: index.php 프로젝트: jin123456bat/home
 /**
  * 发送手机验证码
  */
 function code()
 {
     $system = $this->model('system')->fetch('sms');
     $system = $this->model('system')->toArray($system, 'sms');
     $sms = new sms($system['uid'], $system['key'], $system['sign']);
     $telephone = $this->post->telephone;
     if ($telephone === NULL) {
         return $sms->getNum();
     } else {
         if (validate::telephone($telephone)) {
             $smslogModel = $this->model('smslog');
             if ($smslogModel->check($telephone)) {
                 $code = random::number(6);
                 $template = $system['template'];
                 $template = sprintf($template, $code);
                 $result = $sms->send($telephone, $template);
                 if ($result > 0) {
                     $smslogModel->create($telephone, $code);
                     return json_encode(array('code' => 1, 'result' => 'ok', 'body' => $code));
                 }
             }
             return json_encode(array('code' => 2, 'result' => '短信发送失败'));
         } else {
             return json_encode(array('code' => 0, 'result' => '手机号码不合法'));
         }
     }
 }
예제 #2
0
 /**
  * 物流接口查询
  * @param unknown $com 快递方代码  SF EMS
  * @param unknown $waybills 快递单号
  * @param string $order 排序方式 desc asc
  */
 function query($com, $waybills, $order = 'desc')
 {
     $url = 'http://m.kuaidi100.com/query?type=' . $com . '&postid=' . $waybills . '&id=1&valicode=&temp=' . random::number(10);
     $curl = curl_init();
     curl_setopt($curl, CURLOPT_URL, $url);
     curl_setopt($curl, CURLOPT_HEADER, 0);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
     curl_setopt($curl, CURLOPT_TIMEOUT, 5);
     $get_content = curl_exec($curl);
     if ($get_content === false) {
         echo curl_error($curl);
     }
     curl_close($curl);
     return $get_content;
 }
예제 #3
0
 /**
  * 创建退货申请
  */
 function create($uid, $oid, $type, $reason, $money, $description, $imgs)
 {
     $orderModel = $this->model('orderlist');
     $order = $orderModel->where('id=?', array($oid))->limit(1)->select('ordertotalamount,status,money');
     if (empty($order)) {
         return new json(json::PARAMETER_ERROR, '订单不存在');
     }
     $money = $order[0]['money'] + $order[0]['ordertotalamount'] >= $money ? $money : $order[0]['ordertotalamount'] + $order[0]['money'];
     $refundno = date("YmdHis") . $uid . $oid . random::number(4);
     $data = array('id' => NULL, 'refundno' => $refundno, 'uid' => $uid, 'oid' => $oid, 'type' => $type, 'time' => $_SERVER['REQUEST_TIME'], 'reason' => $reason, 'money' => $money, 'description' => $description, 'o_status' => $order[0]['status'], 'handle' => self::REFUND_HANDLE_NO);
     $rid = $this->insert($data);
     if ($rid) {
         foreach ($imgs as $img) {
             $refundimg = $this->model('refundimg');
             $refundimg->insert(array(NULL, $rid, $img));
         }
     }
     return $rid;
 }
예제 #4
0
 /**
  * 微信分享和卡劵使用的签名包
  * @param unknown $jsApiTicket
  * @return multitype:string NULL number unknown Ambigous <boolean, string> 
  */
 public function getSignPackage($jsApiTicket)
 {
     // 注意 URL 一定要动态获取,不能 hardcode.
     $protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://";
     $url = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $timestamp = time();
     $nonceStr = random::word(16);
     // 这里参数的顺序要按照 key 值 ASCII 码升序排序
     $string = 'jsapi_ticket=%s&noncestr=%s&timestamp=%s&url=%s';
     $string = sprintf($string, $jsApiTicket, $nonceStr, $timestamp, $url);
     $signature = sha1($string);
     $signPackage = array("appId" => $this->_appid, "nonceStr" => $nonceStr, "timestamp" => $timestamp, "url" => $url, "signature" => $signature, "rawString" => $string);
     return $signPackage;
 }
예제 #5
0
 /**
  * 随机生成一个优惠代码
  */
 function randomcode()
 {
     $couponModel = $this->model('coupon');
     $code = strtoupper(date('ymdHis', $_SERVER['REQUEST_TIME']) . random::word(6, '', random::RANDOM_WORD_NUMBER));
     while ($couponModel->exist($code)) {
         $code = strtoupper(date('ymdHis', $_SERVER['REQUEST_TIME']) . random::word(6, '', random::RANDOM_WORD_NUMBER));
     }
     return new json(json::OK, NULL, $code);
 }
예제 #6
0
파일: user.php 프로젝트: jin123456bat/home
 /**
  * 微信用户注册数据模型
  * @auth felixchen
  */
 function registerWeiXin($openid, $oid = NULL, $client = 'weixin', $usernam = '', $img = '')
 {
     $salt = random::word(6);
     $password = md5($openid . $salt);
     $regtime = $_SERVER['REQUEST_TIME'];
     $logtime = $regtime;
     $email = '';
     $money = 0;
     $score = 0;
     $close = 0;
     $ordernum = 0;
     $cost = 0;
     $gravatar = $img;
     $username = $usernam;
     $telephone = NULL;
     $array = array(NULL, $gravatar, $username, $telephone, $email, $password, $openid, $regtime, $logtime, $money, $score, $ordernum, $cost, $salt, $close, $oid, $client);
     if ($this->insert($array)) {
         return $this->lastInsertId();
     }
     return false;
 }
예제 #7
0
 /**
  * 输出微信浏览器中的支付验证器
  */
 function output($prepay_id)
 {
     $data = array('appId' => $this->_system->get('appid', 'weixin'), 'timeStamp' => $_SERVER['REQUEST_TIME'], 'nonceStr' => random::word(32), 'package' => 'prepay_id=' . $prepay_id, 'signType' => 'MD5');
     $data['paySign'] = $this->sign($data);
     return $data;
 }
예제 #8
0
파일: order.php 프로젝트: jin123456bat/home
 /**
  * 随机生成一个流水号
  */
 function swift($uid, $length = 3)
 {
     return date('mdHis') . $uid . random::number($length);
 }