goCheck(); //获取传递参数 $orderInfo = input('post.'); $orderInfo['subType'] = input('post.subType',0); $orderInfo['mySub'] = input('post.mySub',0); $uid = $this->verifyToken(); //解密手机号 $orderInfo['telnum'] = $this->rsaDecipher($telnum = input('telnum')); //手机号正则验证 $check = '/^(1(([35789][0-9])|(47)))\d{8}$/'; if (!preg_match($check, $orderInfo['telnum'])){ throw new ParamException([ 'code' => 400, 'msg' => '手机号格式不正确', 'errorCode' => 10000 ]); } $order = new OrderService(); $result['status'] = $order->place($uid,$orderInfo); return api_return('下单成功',$result); } //未登录处理 private function checkNoLogin($orderInfo){ //检查参数并创建用户 $this->checkUserParam($orderInfo); //解密手机号 $orderInfo['phone'] = $this->rsaDecipher($telnum = input('telnum')); //手机号正则验证 $check = '/^(1(([35789][0-9])|(47)))\d{8}$/'; if (!preg_match($check, $orderInfo['phone'])){ throw new ParamException([ 'code' => 400, 'msg' => '手机号格式不正确', 'errorCode' => 10000 ]); } //检测手机号是否已注册,注册则登录,否则添加新数据 $userCount = User::checkUserByTelnum( $orderInfo['phone']); if($userCount){ throw new ParamException([ 'msg' => '手机号已注册!请登录', 'errorCode' => 10000, 'code' => 400, 'status' => 1 ]); }else{ $resUser = User::addUserInfo($orderInfo); return $resUser; } } /* * 查询顶订单是否支付成功 * */ public function checkOrderPay(){ $user_id = $this->verifyToken(); $orderID = input('order_id'); //参数验证 if(!intval($orderID)){ throw new ParamException([ 'msg' => '订单id参数错误', 'errorCode' => 10000, 'code' => 400 ]); } $result = Db::table("orders")->field('status')->where([['user_id','=',$user_id],['id','=',$orderID]])->find(); if(empty($result)){ throw new ParamException([ 'msg' => '订单不存在', 'errorCode' => 10004, 'code' => 404 ]); } return api_return('ok',$result); } }