예제 #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
파일: user.php 프로젝트: jin123456bat/home
 /**
  * 验证账号密码
  */
 function authpwd($id, $oldpwd, $newpwd)
 {
     $result = $this->where('id=?', array($id))->select('password,salt');
     if (isset($result[0]['salt']) && isset($result[0]['password'])) {
         if (md5($oldpwd . $result[0]['salt']) == $result[0]['password']) {
             $salt = random::number(6);
             $newpwd = md5($newpwd . $salt);
             return $this->where('id=?', array($id))->update(array('password' => $newpwd, 'salt' => $salt));
         }
         return false;
     }
     return false;
 }
예제 #5
0
파일: order.php 프로젝트: jin123456bat/home
 /**
  * 随机生成一个流水号
  */
 function swift($uid, $length = 3)
 {
     return date('mdHis') . $uid . random::number($length);
 }