博主介绍:
国内互联网知名博主 · 8年软件架构师
🎯 方向:软件开发
主要内容:
✔ 选题 | 功能设计| 任务书
✔ 项目指导 | 答辩PPT | 代码实现 | 源码定制 | 代码讲解
Java(SpringBoot / SSM) · Python · Vue · 微信小程序 · Android
大数据 · 机器学习/深度学习 · React · Go · PHP · Node.js
源码获取:
如需完整源码及数据库脚本,可关注并私信获取,或在评论区留言交流技术问题
一、基于 PHP 的校园二手交易平台功能介绍
本项目是基于 PHP 开发的校园二手交易平台,采用前后台分离的架构设计,支持 ** 用户(前台)、管理员(后台)、卖家(后台)** 三类角色,覆盖校园二手交易全流程,为师生提供安全、便捷的二手物品交易服务。
1、用户(前台)功能模块
用户作为平台的核心使用角色,可通过前台完成从注册到交易的全流程操作:
- 登录注册:支持账号注册与登录,保障账号安全与身份识别。
- 系统首页:展示平台核心入口、热门商品及最新资讯,提供直观的导航体验。
- 二手商品:浏览、搜索、筛选各类二手商品,支持查看商品详情与收藏。
- 校园资讯:发布校园活动、交易须知等信息,提升平台活跃度与信息透明度。
- 后台管理:为具备卖家资质的用户提供后台入口,实现商品与订单管理。
- 购物车:支持商品添加、结算与批量操作,优化交易流程。
- 个人中心:管理个人信息、订单记录、收藏商品及收货地址,提升用户体验。
2、管理员(后台)功能模块
管理员负责平台的整体运营与管控,核心功能包括:
- 系统首页:展示平台运营数据、待办事项,提供全局概览。
- 用户管理:管理用户账号信息、权限分配及违规处理,保障平台秩序。
- 卖家管理:审核卖家资质、管理卖家账号,规范交易主体行为。
- 商品分类管理:维护商品分类体系,支持分类新增、编辑与排序,优化商品检索效率。
- 二手商品管理:审核商品信息、处理违规商品,保障商品质量与交易安全。
- 校园资讯管理:发布、编辑、删除校园资讯,维护平台信息生态。
- 信息反馈管理:处理用户与卖家的反馈、投诉,及时响应问题并优化服务。
- 个人中心:管理个人账号信息、修改密码,保障账号安全。
- 系统管理:配置系统参数、管理权限角色、维护系统日志,保障平台稳定运行。
3、卖家(后台)功能模块
卖家作为交易主体,可通过后台高效管理自身业务:
- 登录 / 注册:完成卖家身份认证与账号管理,保障交易主体真实性。
- 系统首页:展示个人交易数据、待处理订单及商品统计,提供业务概览。
- 二手商品管理:发布、编辑、下架二手商品,管理商品库存与状态。
- 信息反馈管理:查看并回复用户咨询、投诉,提升交易沟通效率。
- 个人中心:管理个人信息、收款账户及店铺设置,优化店铺运营。
- 订单管理:处理订单发货、确认收货、退款申请,保障交易闭环。
4、功能模块/系统架构图:

技术:PHP、Vue 框架、MySQL 数据库、前端三件套(html、css、js)等
5、系统核心优势或亮点:
- 角色权限精准管控:清晰划分用户、卖家、管理员三类角色,实现功能权限精准隔离,保障交易安全与平台秩序。
- 交易流程高效闭环:从商品浏览、购物车结算到订单管理全流程线上化,配合关键词搜索功能,大幅提升交易效率与用户体验。
- 前后台分离架构:前台负责用户交互,后台专注业务管理,界面友好易用,系统稳定可靠,同时支持校园资讯发布,贴合校园场景需求。
二、部分功能运行截图
1、前台用户功能模块:


核心代码:
php
public function login(){
$username = isset($_REQUEST['username'])?$_REQUEST['username']:"";
$password = isset($_REQUEST['password'])?$_REQUEST['password']:"";
$sql = "select * from `yonghu` where `yonghuzhanghao` = '".$username."' and `mima` = '".$password."'";
$result = table_sql($sql);
if ($result->num_rows > 0) {
// 输出数据
while($row = $result->fetch_assoc()) {
$token_array = [
"iat" => time(), //签发时间
"exp" => time()+7200, //token 过期时间
'tablename'=> 'yonghu',//表名
'columData' => $this->columData,
'id' => $row['id'],
'isAdmin' => 0,
"success" => $row,//记录的uid的信息,如果有其它信息,可以再添加数组的键值对
'username' => $row['yonghuzhanghao'],
];
$tokens = base64_encode(json_encode($token_array));
$_SESSION[$tokens] = $row["id"];
$colum = "yonghuzhanghao";
$md5 = md5($row["id"]."+10086");
$_SESSION[$md5] = $row[$colum];
$data = ['code' => 0, 'token' => $tokens];
exit(json_encode($data));
}
} else {
exit(json_encode(['code'=>500,'msg'=>"账号或密码错误"]));
}
}
/**
* 退出
* post
*/
public function logout(){
$token = $this->token();
unset($token);
exit(json_encode(['code'=>0,'msg'=>'退出成功']));
}
/**
* 注册
* post
*/
public function register(){
$tmpData = strval(file_get_contents("php://input"));
$postData = json_decode($tmpData,true);
$colum = "yonghuzhanghao";
$trues = "select * from `yonghu` where `yonghuzhanghao` = '".$postData[$colum]."'";
$result = table_sql($trues);
if($result->num_rows<1){
$keyArr = $valArr = array();
foreach ($postData as $key => $value){
if (in_array($key, $this->columData) && $value != ''){
array_push($keyArr,"`".$key."`");
array_push($valArr,"'".$value."'");
}
}
$key = implode(',',$keyArr);
$v = implode(',',$valArr);
$sql = "INSERT INTO `yonghu` (`id`,".$key.") VALUES (".time().",".$v.")";
$result = table_sql($sql);
if (!$result) exit(json_encode(['code'=>500,'msg'=>'注册失败。']));
exit(json_encode(['code'=>0]));
}
exit(json_encode(['code'=>500,'msg'=>"用户名已存在。"]));
}



2、后台管理员功能模块

3、后台卖家功能模块


三、部分核心代码
php
public function page(){
$token = $this->token();
$tokens = json_decode(base64_decode($token),true);
if (!isset($tokens['id']) || empty($tokens['id'])) exit(json_encode(['code'=>401,'msg'=>"你还没有登录。"]));
$userid = $tokens['id'];
$where = " where 1 ";//查询条件
$orwhere = '';
$page = isset($_REQUEST['page'])?$_REQUEST['page']:"1";
$limt = isset($_REQUEST['limit'])?$_REQUEST['limit']:"10";
$sort = isset($_REQUEST['sort'])?$_REQUEST['sort']:"id";
$order = isset($_REQUEST['order'])?$_REQUEST['order']:"asc";
foreach ($_REQUEST as $k => $val){
if(in_array($k, $this->columData)){
if ($val != ''){
$where.= " and ".$k." like '".$val."'";
}
}
}
if ($tokens['isAdmin']!=1 && !empty($userid)){
$where .= " and `userid` = ".$userid;
}
$data = json_decode(base64_decode($token),true);
if ($data['isAdmin']!=1){
$where .= " and `userid` = ".$data['id'];
}
$sql = "select * from `storeup` ".$where;
$count = table_sql($sql);
if ($count->num_rows < 1){
$numberCount = 0;
}else{
$numberCount = $count->num_rows;
}
$page_count = ceil($numberCount/$limt);//页数
$startCount = ($page-1)*$limt;
$where .= empty($orwhere) ? '' : "and (".$orwhere.")";
$lists = "select * from `storeup` ".$where." order by ".$sort." ".$order." limit ".$startCount.",".$limt;
$result = table_sql($lists);
$arrayData = array();
if ($result->num_rows > 0) {
while ($datas = $result->fetch_assoc()){
array_push($arrayData,$datas);
}
}
exit(json_encode([
'code'=>0,
'data' => [
"total" => $numberCount,
"pageSize" => $limt,
"totalPage" => $page_count,
"currPage" => $page,
"list" => $arrayData
]
]));
}
/**
* 分页,列表list
* get
*/
public function lists(){
$page = isset($_REQUEST['page'])?$_REQUEST['page']:"1";
$limt = isset($_REQUEST['limit'])?$_REQUEST['limit']:"10";
$sort = isset($_REQUEST['sort'])?$_REQUEST['sort']:"id";
$order = isset($_REQUEST['order'])?$_REQUEST['order']:"asc";
$refid = isset($_REQUEST['refid']) ? $_REQUEST['refid'] : "0";
$where = " where 1 ";//查询条件
$orwhere = '';
if(isset($_REQUEST['goodid'])) {
$where .= " and goodid = ".$_REQUEST['goodid']." ";
}
foreach ($_REQUEST as $k => $val){
if(in_array($k, $this->columData)){
$where.= " and ".$k." like '".$val."'";
}
}
$token = $this->token();
$data = json_decode(base64_decode($token),true);
if ($data['isAdmin']!=1){
$where .= " and `userid` = ".$data['id'];
}
$sql = "select * from `storeup`".$where;
$count = table_sql($sql);
if ($count->num_rows < 1){
$numberCount = 0;
}else{
$numberCount = $count->num_rows;
}
$page_count = ceil($numberCount/$limt);//页数
$startCount = ($page-1)*$limt;
$lists = "select * from `storeup` ".$where." order by ".$sort." ".$order." limit ".$startCount.",".$limt;
$result = table_sql($lists);
$arrayData = array();
if ($result->num_rows > 0) {
while ($datas = $result->fetch_assoc()){
array_push($arrayData,$datas);
}
}
exit(json_encode([
'code'=>0,
'data' => [
"total" => $numberCount,
"pageSize" => $limt,
"totalPage" => $page_count,
"currPage" => $page,
"list" => $arrayData
]
]));
}
php
class OrdersController extends CommonController {
public function __construct()
{
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");
header('Access-Control-Allow-Headers:Origin,Content-Type,Accept,token,X-Requested-With,device');
}
public $columData = [
'id','addtime'
,'orderid'
,'tablename'
,'userid'
,'goodid'
,'goodname'
,'picture'
,'buynumber'
,'price'
,'discountprice'
,'total'
,'discounttotal'
,'type'
,'status'
,'address'
,'tel'
,'consignee'
,'remark'
,'logistics'
,'maijiazhanghao'
,'goodtype'
];
/**
* 分页,列表
* get
*/
public function page(){
$token = $this->token();
$tokens = json_decode(base64_decode($token),true);
if (!isset($tokens['id']) || empty($tokens['id'])) exit(json_encode(['code'=>401,'msg'=>"你还没有登录。"]));
$userid = $tokens['id'];
$where = " where 1 ";//查询条件
$orwhere = '';
if($tokens['isAdmin'] != 1 && $tokens['tablename'] == 'maijia') {
$where .= " and `maijiazhanghao` = '".$tokens['username']."' ";
}
$page = isset($_REQUEST['page'])?$_REQUEST['page']:"1";
$limt = isset($_REQUEST['limit'])?$_REQUEST['limit']:"10";
$sort = isset($_REQUEST['sort'])?$_REQUEST['sort']:"id";
$order = isset($_REQUEST['order'])?$_REQUEST['order']:"asc";
foreach ($_REQUEST as $k => $val){
if(in_array($k, $this->columData)){
if ($val != ''){
$where.= " and ".$k." like '".$val."'";
}
}
}
$base = json_decode(base64_decode($token),true);
if ($base['isAdmin']!=1 || ($base['isAdmin']==1 && $base['tablename'] != "users")){
$md5 = md5($userid."+10086");
$colum = "maijiazhanghao";
$columData = $base['columData'];
if (isset($_SESSION[$md5]) && in_array($colum, $columData)){
if($base['tablename'] == 'maijia'){
$orsign = false;
if(!$orsign) {
$where .= " and `maijiazhanghao` = '".$_SESSION[$md5]."'";
}
}
}
}
$token = $this->token();
$data = json_decode(base64_decode($token),true);
$type = isset($_REQUEST['type'])? '('.$_REQUEST['type'].')':'(1, 2, 3)';
$where .= isset($_REQUEST['status']) ? " and `status`='".$_REQUEST['status']."'" : "";
$where .= " and `type` in ".$type;
$sql = "select * from `orders` ".$where;
$count = table_sql($sql);
if ($count->num_rows < 1){
$numberCount = 0;
}else{
$numberCount = $count->num_rows;
}
$page_count = ceil($numberCount/$limt);//页数
$startCount = ($page-1)*$limt;
$where .= empty($orwhere) ? '' : "and (".$orwhere.")";
$lists = "select * from `orders` ".$where." order by ".$sort." ".$order." limit ".$startCount.",".$limt;
$result = table_sql($lists);
$arrayData = array();
if ($result->num_rows > 0) {
while ($datas = $result->fetch_assoc()){
array_push($arrayData,$datas);
}
}
exit(json_encode([
'code'=>0,
'data' => [
"total" => $numberCount,
"pageSize" => $limt,
"totalPage" => $page_count,
"currPage" => $page,
"list" => $arrayData
]
]));
}
四、文档部分参考


五、源码获取
如需完整源码及数据库脚本,可关注并私信获取,或在评论区留言交流技术问题