基于微信小程序的疫苗预约系统让疫苗信息,疫苗预约信息等相关信息集中在后台让管理员管理,让用户在小程序端预约疫苗,查看疫苗预约信息,该系统让信息管理变得高效,也让用户预约疫苗,查看疫苗预约等信息变得越来越方便。
一、项目简述
本系统功能包括:
1、疫苗添加、修改、删除等管理
2、接种点管理(接种点、工作人员)
3、预约跟进(预约、签到、预检、接种、留观、留观历史)
4、用户管理
1、小程序预约的界面展示
2、医生管理控制器
<?php
namespace app\store\controller;
use app\store\model\Doctors as DoctorsModel;
/**
* 医生管理控制器
* Class Doctors
* @package app\store\controller
*/
class Doctors extends Controller
{
/**
* 医生列表
* @return mixed
* @throws \think\exception\DbException
*/
public function index()
{
$model = new DoctorsModel;
$list = $model->getList();
// return json($list);
return $this->fetch('index', compact('list'));
}
3、添加医生
/**
* 添加医生
* @return array|mixed
*/
public function add()
{
if (!$this->request->isAjax()) {
return $this->fetch('add');
}
$model = new DoctorsModel;
if ($model->add($this->postData('doctors'))) {
return $this->renderSuccess('添加成功', url('doctors/index'));
}
$error = $model->getError() ?: '添加失败';
return $this->renderError($error);
}
/**
* 删除医生
* @param $doctors_id
* @return array
* @throws \think\exception\DbException
*/
public function delete($doctors_id)
{
$model = DoctorsModel::get($doctors_id);
if (!$model->remove()) {
return $this->renderError('删除失败');
}
return $this->renderSuccess('删除成功');
}
4、医生编辑
/**
* 医生编辑
* @param $doctors_id
* @return array|mixed
* @throws \think\exception\DbException
*/
public function edit($doctors_id)
{
// 商品详情
$model = DoctorsModel::detail($doctors_id);
if (!$this->request->isAjax()) {
return $this->fetch('edit', compact('model'));
}
// 更新记录
if ($model->edit($this->postData('doctors'))) {
return $this->renderSuccess('更新成功', url('doctors/index'));
}
$error = $model->getError() ?: '更新失败';
return $this->renderError($error);
}
}
5、订单管理
<?php
namespace app\store\controller;
use app\store\model\Order as OrderModel;
/**
* 订单管理
* Class Order
* @package app\store\controller
*/
class Order extends Controller
{
/**
* 待发货订单列表
* @return mixed
* @throws \think\exception\DbException
*/
public function delivery_list()
{
return $this->getList('待发货订单列表', [
'pay_status' => 20,
'delivery_status' => 10
]);
}
/**
* 已付款订单列表
* @return mixed
* @throws \think\exception\DbException
*/
public function receipt_list()
{
return $this->getList('已付款订单列表', ['status' => 1]);
}
/**
* 待付款订单列表
* @return mixed
* @throws \think\exception\DbException
*/
public function pay_list()
{
return $this->getList('待付款订单列表', ['status' => 0]);
}
/**
* 已完成订单列表
* @return mixed
* @throws \think\exception\DbException
*/
public function complete_list()
{
return $this->getList('已完成订单列表', ['status' => 2]);
}
/**
* 已取消订单列表
* @return mixed
* @throws \think\exception\DbException
*/
public function cancel_list()
{
return $this->getList('已取消订单列表', ['status' => -1]);
}
/**
* 全部订单列表
* @return mixed
* @throws \think\exception\DbException
*/
public function all_list()
{
return $this->getList('全部订单列表');
}
6、订单列表、订单详情控制器
/**
* 订单列表
* @param $title
* @param $filter
* @return mixed
* @throws \think\exception\DbException
*/
private function getList($title, $filter = [])
{
$model = new OrderModel;
$list = $model->getList($filter);
return $this->fetch('index', compact('title','list'));
}
/**
* 订单详情
* @param $order_id
* @return mixed
* @throws \think\exception\DbException
*/
public function detail($order_id)
{
$detail = OrderModel::detail($order_id);
return $this->fetch('detail', compact('detail'));
}
7、确认发货
/**
* 确认发货
* @param $order_id
* @return array
* @throws \think\exception\DbException
*/
public function delivery($order_id)
{
$model = OrderModel::detail($order_id);
if ($model->delivery($this->postData('order'))) {
return $this->renderSuccess('发货成功');
}
$error = $model->getError() ?: '发货失败';
return $this->renderError($error);
}
}
8、在后台设置可以进行预约接种疫苗的时间段
9、疫苗上架的功能界面图:
10、订阅的用户信息管理
11、预约的用户信息管理
12、预约的用户信息管理详情页,后台管理员也可以手动为客户修改预约日期
13、导出订阅用户
<?php
namespace app\store\controller;
use think\Db;
use think\Log;
Class Output extends Controller
{
/**
* 导出订阅用户
*/
public function outExcel(){
vendor("PHPExcel.PHPExcel");
//实例化phpexcel对象
$objPHPExcel = new \PHPExcel();
$orders = session('output_orders');
// 给表格添加数据
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', '名字')
->setCellValue('B1', '排号')
->setCellValue('C1', '电话')
->setCellValue('D1', '疫苗种类')
->setCellValue('E1', '年龄')
->setCellValue('F1', '出生日期')
->setCellValue('G1', '身份证号')
->setCellValue('H1', '发货状态')
->setCellValue('I1', '订阅时间')
->setCellValue('J1', '发货时间')
->setCellValue('K1', '渠道来源')
->setCellValue('L1', '分销员');
$arr = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L'];
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(15);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(15);
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(15);
$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(15);
$objPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('J')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('K')->setWidth(15);
$objPHPExcel->getActiveSheet()->getColumnDimension('K')->setWidth(15);
for($i = 0; $i < count($arr); $i++){
$objPHPExcel->getActiveSheet()->getStyle($arr[$i].'1')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle($arr[$i].'1')->getFont()->setSize(12);
$objPHPExcel->getActiveSheet()->getStyle($arr[$i].'1')->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle($arr[$i].'1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
}
$objPHPExcel->getActiveSheet()->getRowDimension(1)->setRowHeight(30);
for($i = 2; $i <= count($orders) + 1; $i++){
$objPHPExcel->getActiveSheet()->getStyle('A'.$i)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A'.$i)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('B'.$i)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('B'.$i)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('C'.$i)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('C'.$i)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('D'.$i)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('D'.$i)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('E'.$i)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('E'.$i)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('F'.$i)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('F'.$i)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('G'.$i)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('G'.$i)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('H'.$i)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('H'.$i)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('I'.$i)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('I'.$i)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('J'.$i)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('J'.$i)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('K'.$i)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('K'.$i)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('L'.$i)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('L'.$i)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
if($orders[$i-2]['deliver_status'] == '1'){
$deliver_status = "已发货";
}elseif($orders[$i-2]['deliver_status'] == '-1'){
$deliver_status = "已过期";
}else{
$deliver_status = "未发货";
}
$minus_time = time() - strtotime($orders[$i-2]['birthday']);
$age = floor($minus_time/3600/24/365);
$objPHPExcel->getActiveSheet()->setCellValue('A' . $i, $orders[$i-2]['user_name']);
$objPHPExcel->getActiveSheet()->setCellValue('B' . $i, $orders[$i-2]['subscribe_id']);
$objPHPExcel->getActiveSheet()->setCellValue('C' . $i, $orders[$i-2]['telephone']);
$objPHPExcel->getActiveSheet()->setCellValue('D' . $i, $orders[$i-2]['vaccines']);
$objPHPExcel->getActiveSheet()->setCellValue('E' . $i, $age);
$objPHPExcel->getActiveSheet()->setCellValue('F' . $i, $orders[$i-2]['birthday']);
$objPHPExcel->getActiveSheet()->setCellValue('G' . $i, $orders[$i-2]['idcard']."\t");
$objPHPExcel->getActiveSheet()->setCellValue('H' . $i, $deliver_status);
$objPHPExcel->getActiveSheet()->setCellValue('I' . $i, $orders[$i-2]['create_time']);
$objPHPExcel->getActiveSheet()->setCellValue('J' . $i, $orders[$i-2]['deliver_time']);
$objPHPExcel->getActiveSheet()->setCellValue('K' . $i, $orders[$i-2]['channel']);
$objPHPExcel->getActiveSheet()->setCellValue('l' . $i, $orders[$i-2]['name']);
}
$objPHPExcel->getActiveSheet()->setTitle('订阅用户');
//激活当前表
$objPHPExcel->setActiveSheetIndex(0);
ob_end_clean();//清除缓冲区,避免乱码
$name = '订阅用户_'.date('YmdHis').'.xlsx';
//弹出提示下载文件
header('pragma:public');
header("Content-Disposition:attachment;filename=".$name);
header('Cache-Control: max-age=0');
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');
}
14、导出预约用户Excel表单
/**
* 导出预约用户
*/
public function outExcel2(){
vendor("PHPExcel.PHPExcel");
//实例化phpexcel对象
$objPHPExcel = new \PHPExcel();
$orders = session('output_orders2');
// 给表格添加数据
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', '名字')
->setCellValue('B1', '针次')
->setCellValue('C1', '电话')
->setCellValue('D1', '疫苗种类')
->setCellValue('E1', '年龄')
->setCellValue('F1', '出生日期')
->setCellValue('G1', '身份证号')
->setCellValue('H1', '接种状态')
->setCellValue('I1', '下单时间')
->setCellValue('J1', '预约日期')
->setCellValue('K1', '预约时段')
->setCellValue('L1', '渠道来源')
->setCellValue('M1', '分销员');
$arr = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M'];
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(15);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(15);
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(15);
$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(15);
$objPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('J')->setWidth(15);
$objPHPExcel->getActiveSheet()->getColumnDimension('K')->setWidth(15);
$objPHPExcel->getActiveSheet()->getColumnDimension('L')->setWidth(15);
$objPHPExcel->getActiveSheet()->getColumnDimension('M')->setWidth(15);
for($i = 0; $i < count($arr); $i++){
$objPHPExcel->getActiveSheet()->getStyle($arr[$i].'1')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle($arr[$i].'1')->getFont()->setSize(12);
$objPHPExcel->getActiveSheet()->getStyle($arr[$i].'1')->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle($arr[$i].'1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
}
$objPHPExcel->getActiveSheet()->getRowDimension(1)->setRowHeight(30);
for($i = 2; $i <= count($orders) + 1; $i++){
$objPHPExcel->getActiveSheet()->getStyle('A'.$i)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A'.$i)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('B'.$i)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('B'.$i)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('C'.$i)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('C'.$i)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('D'.$i)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('D'.$i)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('E'.$i)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('E'.$i)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('F'.$i)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('F'.$i)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('G'.$i)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('G'.$i)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('H'.$i)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('H'.$i)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('I'.$i)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('I'.$i)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('J'.$i)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('J'.$i)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('K'.$i)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('K'.$i)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('L'.$i)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('L'.$i)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('M'.$i)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('M'.$i)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
if($orders[$i-2]['number'] == '1'){
$number = "第一针";
}elseif($orders[$i-2]['number'] == '2'){
$number = "第二针";
}elseif($orders[$i-2]['number'] == '3'){
$number = "第三针";
}
if($orders[$i-2]['status'] == '1'){
$status = "已完成";
}elseif($orders[$i-2]['status'] == '2'){
$status = "已过期";
}elseif($orders[$i-2]['status'] == '-1'){
$status = "已取消";
}else{
$status = "待接种";
}
$minus_time = time() - strtotime($orders[$i-2]['birthday']);
$age = floor($minus_time/3600/24/365);
$objPHPExcel->getActiveSheet()->setCellValue('A' . $i, $orders[$i-2]['user_name']);
$objPHPExcel->getActiveSheet()->setCellValue('B' . $i, $number);
$objPHPExcel->getActiveSheet()->setCellValue('C' . $i, $orders[$i-2]['telephone']);
$objPHPExcel->getActiveSheet()->setCellValue('D' . $i, $orders[$i-2]['vaccines']);
$objPHPExcel->getActiveSheet()->setCellValue('E' . $i, $age);
$objPHPExcel->getActiveSheet()->setCellValue('F' . $i, $orders[$i-2]['birthday']);
$objPHPExcel->getActiveSheet()->setCellValue('G' . $i, $orders[$i-2]['idcard']."\t");
$objPHPExcel->getActiveSheet()->setCellValue('H' . $i, $status);
$objPHPExcel->getActiveSheet()->setCellValue('I' . $i, $orders[$i-2]['order_time']);
$objPHPExcel->getActiveSheet()->setCellValue('J' . $i, $orders[$i-2]['appoint_date']);
$objPHPExcel->getActiveSheet()->setCellValue('K' . $i, $orders[$i-2]['appoint_time']);
$objPHPExcel->getActiveSheet()->setCellValue('L' . $i, $orders[$i-2]['channel']);
$objPHPExcel->getActiveSheet()->setCellValue('M' . $i, $orders[$i-2]['name']);
}
$objPHPExcel->getActiveSheet()->setTitle('预约用户');
//激活当前表
$objPHPExcel->setActiveSheetIndex(0);
ob_end_clean();//清除缓冲区,避免乱码
$name = '预约用户_'.date('YmdHis').'.xlsx';
//弹出提示下载文件
header('pragma:public');
header("Content-Disposition:attachment;filename=".$name);
header('Cache-Control: max-age=0');
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');
}
}