记录今日写的接口【laravel框架】

模型

	// 修改密码接口
		public static function Uppassword($rel){
			if(empty($rel['password'])){
				$array['status']=1;
				$array['msg']="密码不能为空";
				return $array;
			}
			if(strlen($rel['password'])<6){
				$array['status']=2;
				$array['msg']="密码不得小于6位";
				return $array;
			}
			$sql = DB::table('jy_user')->where('password',md5($rel['password']))->first();
			if(!$sql){
				$array['status']=3;
				$array['msg']="原始密码不正确";
				return $array;
			}
            if($rel['pwd']!=$rel['passworda']){
            	$array['status']=4;
            	$array['msg']="两次密码不一致";
            	return $array;
            }else{
            	$id = $_GET['id'];
            	$password=array(
                    'password'=>md5($rel['passworda'])
            		);
            	$data = DB::table('jy_user')->where('id',$id)->update($password);
            	$array['status']=5;
            	$array['msg']="修改密码成功";
            	return $array;
            }
		}

控制器

 // 修改密码接口
	    public function uppwd(Request $request){
	    	$data = $request->all();
	    	$info = Api::Uppassword($data);
	    	return json_encode($info);
	    }
	    // 未支付的状态接口
	    public function noorder(){
	   	$uid = $_GET['uid'];
	   	$sql = DB::select("select jy_id.order,jy_goodsclass.stateof,jy_goodsclass.gc_name from jy_goodsclass,jy_id where jy_goodsclass.id=jy_id.pid and uid={$uid} and stateof=1");
	   	if($sql){
	   		$array["list"]=$sql;
	   		$array['status']=100;
	   		$array['msg']="成功";
	   	}
	   	return json_encode($array);
	    }

	    //已支付的状态接口
	    public function yesorder(){
	    	$uid = $_GET['uid'];
	    	$sql = DB::select("select jy_id.order,jy_goodsclass.stateof,jy_goodsclass.gc_name,jy_goodsclass.gc_price,jy_goodsclass.gc_endprice from jy_goodsclass,jy_id where jy_goodsclass.id=jy_id.pid and uid={$uid} and stateof=2");
	    	if($sql){
	    		$array['list']=$sql;
	    		$array['status']=100;
	    		$array['msg']="成功";
	    	}
	    	return json_encode($array);
	    }
	    // 已取消的状态接口
	    public function escorder(){
	    	$uid = $_GET['uid'];
	    	$sql = DB::select("select jy_id.order,jy_goodsclass.stateof,jy_goodsclass.gc_name from jy_goodsclass,jy_id where jy_goodsclass.id=jy_id.pid and uid={$uid} and stateof=3");
	    	if($sql){
	    		$array['list']=$sql;
	    		$array['status']=100;
	    		$array['msg']="成功";
	    	}
	    	return json_encode($array);
	    }

 

  • 35
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值