Initial commit
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
namespace Home\Controller;
|
||||
use Think\Controller;
|
||||
|
||||
class BaseController extends Controller
|
||||
{
|
||||
private $loginStatus=1;//1为登录正常,0为登录异常
|
||||
public $user_id;
|
||||
public $openid;
|
||||
function _initialize() {
|
||||
//api接口相关设置
|
||||
C("SHOW_PAGE_TRACE",false);//强制关闭调试器
|
||||
header("Access-Control-Allow-Origin:*");//允许ajax远程跨域
|
||||
header('Access-Control-Allow-Headers:x-requested-with,content-type,user_id,openid');
|
||||
}
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
//校验用户登录信息
|
||||
$this->checkLogin();
|
||||
}
|
||||
function checkLogin(){
|
||||
$this->user_id=$_SERVER['HTTP_USER_ID'];
|
||||
if(!$this->user_id){
|
||||
$loginStatus = 0;
|
||||
}
|
||||
$this->openid = $_SERVER['HTTP_OPENID'];
|
||||
if(!$this->openid){
|
||||
$loginStatus = 0;
|
||||
}
|
||||
header('loginStatus:'.$this->loginStatus);
|
||||
//error方法一定要放到header下而,否则客户端无法收到header中的loginStatus,newToken字段
|
||||
if(!$this->loginStatus ){
|
||||
$this->error('未登录');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
namespace Home\Controller;
|
||||
use Think\Controller;
|
||||
class PublicController extends Controller {
|
||||
|
||||
public function login(){
|
||||
$user_name = I('user_name');
|
||||
$user_password = I('user_password');
|
||||
$user_info = D('user')->where(array('user_name'=>$user_name, 'user_password'=>md6($user_password)))->find();
|
||||
if($user_info){
|
||||
$role_info = D('role_user')->where(array('user_id'=>$user_info['user_id']))->find();
|
||||
$res['role_id'] = $role_info['role_id'];
|
||||
$res['user_id'] = $user_info['user_id'];
|
||||
$res['can_check'] = $user_info['can_check'];
|
||||
$this->success($res);
|
||||
}
|
||||
else{
|
||||
$this->error('用户名或密码错误');
|
||||
// $this->error($user_password);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function notify()
|
||||
{
|
||||
$fileContent = file_get_contents("php://input");
|
||||
|
||||
$notify_post = json_decode(json_encode(simplexml_load_string($fileContent, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
|
||||
D('notify')->add(array('res'=>json_encode($notify_post)));
|
||||
// if ($notify_post["result_code"] == "SUCCESS") {
|
||||
// $transaction_id = $notify_post['transaction_id'];
|
||||
// $order_num = $notify_post['attach'];
|
||||
// $real_pay = $notify_post["cash_fee"] * 0.01;
|
||||
// $order_data = D('order')->where(array('order_num'=>$order_num))->find();
|
||||
// if($order_data['status_code'] == 101 || $order_data['status_code'] == 301){
|
||||
// $save = array();
|
||||
// $save['transaction_id'] = $transaction_id;
|
||||
// $save['real_pay'] = $real_pay;
|
||||
// $save['paytime'] = time();
|
||||
// $save['status_code'] = 110;
|
||||
// if($order_data['status_code'] == 301){
|
||||
// $save['status_code'] = 310;
|
||||
// }
|
||||
// $order_data = D('order')->where(array('order_num'=>$order_num))->save($save);
|
||||
// $log_data = array();
|
||||
// $log_data['order_id'] = $order_data['order_id'];
|
||||
// $log_data['time'] = time();
|
||||
// $log_data['status_code'] = $save['status_code'];
|
||||
// $log_data['status_name'] = '检测中';
|
||||
// $log_data['desc'] = '已付款(待邮寄切片)';
|
||||
// $log_data['is_qiantai'] = 1;
|
||||
// $log_data['user_id'] = $this->user_id;
|
||||
// D('order_log')->add($log_data);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// }
|
||||
echo "success";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
Reference in New Issue
Block a user