first commit

This commit is contained in:
编码猿
2024-09-27 01:32:49 +08:00
commit 28ebe05a64
7399 changed files with 1174529 additions and 0 deletions

View File

@@ -0,0 +1 @@
4bd183af-4f0c-4a12-9e0b-6a6be05cb63e

View File

@@ -0,0 +1,11 @@
<?php
/*
* 文章模型
* */
namespace app\admin\model;
class Article {
}

View File

@@ -0,0 +1,124 @@
<?php
/**
* 权限组模型
* Class Auth
* @package app\admin\model
*/
namespace app\admin\model;
use app\admin\service\ModelService;
class Auth extends ModelService {
/**
* 绑定的数据表
* @var string
*/
protected $table = 'system_auth';
/**
* 获取权限组
* @return array|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getList() {
$where_auth = [
['status', '=', 1],
];
$order_auth = [
'id' => 'asc',
];
$auth = $this->where($where_auth)->field('id, title, status')->order($order_auth)->select();
return $auth;
}
/**
* 权限角色列表
* @param int $page
* @param int $limit
* @param array $search
* @param array $where
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function authList($page = 1, $limit = 10, $search = [], $where = []) {
//搜索条件
foreach ($search as $key => $value) {
if ($key == 'status' && $value != '') {
$where[] = [$key, '=', $value];
} elseif ($key == 'create_at' && $value != '') {
$value_list = explode(" - ", $value);
$where[] = [$key, 'BETWEEN', ["{$value_list[0]} 00:00:00", "{$value_list[1]} 23:59:59"]];
} else {
!empty($value) && $where[] = [$key, 'LIKE', '%' . $value . '%'];
}
}
$field = 'id, title , remark, status, sort, create_at';
$count = $this->where($where)->count();
$data = $this->where($where)->field($field)->page($page, $limit)->order(['sort asc'])->select();
empty($data) ? $msg = '暂无数据!' : $msg = '查询成功!';
$info = [
'limit' => $limit,
'page_current' => $page,
'page_sum' => ceil($count / $limit),
];
$list = [
'code' => 0,
'msg' => $msg,
'count' => $count,
'info' => $info,
'data' => $data,
];
return $list;
}
/**
* 保存节点
* @param $insert
* @return \think\response\Json
*/
public function add($insert) {
$save = $this->save($insert);
if ($save == 1) {
return __success('保存成功!');
} else {
return __error('保存失败!');
}
}
/**
* 更新节点
* @param $update
* @return \think\response\Json
*/
public function edit($update) {
$data = $this->where('id', $update['id'])->update($update);
if ($data == 1) {
return __success('更新成功!');
} else {
return __error('数据没有修改!');
}
}
/**
* 修改系统节点字段值
* @param $update
* @return \think\response\Json
*/
public function edit_field($update) {
$data = $this->where('id', $update['id'])->update([$update['field'] => $update['value']]);
if ($data == 1) {
return __success('修改成功!');
} else {
return __error('数据没有修改!');
}
}
}

View File

@@ -0,0 +1,30 @@
<?php
/*
*权限节点模型
* */
namespace app\admin\model;
use app\admin\service\ModelService;
class AuthNode extends ModelService {
/**
* 绑定的数据表
* @var string
*/
protected $table = 'system_auth_node';
/**
* 保存授权信息
* @param $insertAll
* @return \think\response\Json
* @throws \Exception
*/
public function authorize($insertAll) {
$save = $this->saveAll($insertAll);
if (!empty($save)) return __success('保存成功!');
return __error('保存失败');
}
}

View File

@@ -0,0 +1,87 @@
<?php
/**
* 系统配置模板
*/
namespace app\admin\model;
use app\admin\service\ModelService;
/**
* 系统配置信息
* Class Config
* @package app\admin\model
*/
class Config extends ModelService {
/**
* 绑定数据表
* @var string
*/
protected $table = 'system_config';
/**
* 获取系统基础配置信息
* @return array|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getBasicConfig() {
$basic = $this->where('group', 'basic')->column('name,value');
return $basic;
}
/**
* 获取系统配置列表
* @param int $page
* @param int $limit
* @param array $search
* @param array $where
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function configList($page = 1, $limit = 500, $search = [], $where = []) {
//搜索条件
foreach ($search as $key => $value) {
!empty($value) && $where[] = [$key, 'LIKE', '%' . $value . '%'];
}
$field = 'id, group , name, value, remark, sort, create_at';
$count = $this->where($where)->count();
$data = $this->where($where)->field($field)->order(['sort asc'])->select();
empty($data) ? $msg = '暂无数据!' : $msg = '查询成功!';
$info = [
'limit' => $limit,
'page_current' => $page,
'page_sum' => ceil($count / $limit),
];
$list = [
'code' => 0,
'msg' => $msg,
'count' => $count,
'info' => $info,
'data' => $data,
];
return $list;
}
/**
* 修改字段值
* @param $update
* @return \think\response\Json
*/
public function edit_field($update) {
$data = $this->where('id', $update['id'])->update([$update['field'] => $update['value']]);
if ($data == 1) {
return __success('修改成功!');
} else {
return __error('数据没有修改!');
}
}
}

View File

@@ -0,0 +1,301 @@
<?php
/*
* 菜单模型
* */
namespace app\admin\model;
use app\admin\service\ModelService;
class Menu extends ModelService {
/**
* 绑定数据表
* @var string
*/
protected $table = 'system_menu';
/**
* 新增菜单数据
* @param $insert
* @return \think\response\Json
* @throws \think\exception\PDOException
*/
public function add($insert) {
//使用事物保存数据
$this->startTrans();
$save = $this->save($insert);
if (!$save) {
$this->rollback();
return __error('数据有误,请稍后再试!');
}
$this->commit();
return __success('菜单添加成功!');
}
/**
* 修改菜单数据
* @param $update
* @return \think\response\Json
*/
public function edit($update) {
$data = $this->where('id', $update['id'])->update($update);
if ($data == 1) {
return __success('菜单更新成功!');
} else {
return __error('数据没有修改!');
}
}
/**
* 获取首页信息
* @return array|null|\PDOStatement|string|\think\Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getHome() {
$where_home = [
['id', '=', 1],
['status', '=', 1],
];
$home = $this->field('id, title, icon, href')->where($where_home)->find();
!empty($home) && $home['href'] = url($home['href']);
return $home;
}
/**
* 获取菜单栏头部
* @return array|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function getNav() {
$where_nav = [
['id', '<>', 1],
['pid', '=', 0],
['status', '=', 1],
];
$order_nav = [
'sort' => 'asc',
'create_at' => 'asc',
];
//查询顶级菜单栏数据
$nav = self::field('id, title, icon')->where($where_nav)->order($order_nav)->select();
//去除空菜单
foreach ($nav as $k => $val) {
$menu = self::where(['pid' => $nav[$k]['id'], 'status' => 1])->select()->toArray();
if (empty($menu)) unset($nav[$k]);
}
//判断图标类型
foreach ($nav as $key => $val) (strpos($nav[$key]['icon'], 'fa-') !== false) ? $nav[$key]['icon_type'] = true : $nav[$key]['icon_type'] = false;
return $nav;
}
/**
* 获取菜单栏数据
* @param array $search 搜索条件
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function menuList($search = [], $where = []) {
if (empty($search)) {
$menu_list = $this->getMenu();
empty($menu_list) ? $msg = '暂无数据!' : $msg = '查询成功!';
return [
'code' => 0,
'msg' => $msg,
'count' => count($menu_list),
'data' => $menu_list,
];
} else {
//搜索条件
foreach ($search as $key => $value) {
if ($key == 'status' && $value != '') {
$where[] = [$key, '=', $value];
} elseif ($key == 'create_at' && $value != '') {
$value_list = explode(" - ", $value);
$where[] = [$key, 'BETWEEN', ["{$value_list[0]} 00:00:00", "{$value_list[1]} 23:59:59"]];
} else {
!empty($value) && $where[] = [$key, 'LIKE', '%' . $value . '%'];
}
}
$menu_list = $this->where($where)->order(['pid' => 'asc', 'sort' => 'asc', 'create_at' => 'desc'])->select();
empty($menu_list) ? $msg = '暂无数据!' : $msg = '查询成功!';
//修改菜单栏数据格式
$this->__buildMenu($menu_list);
return [
'code' => 0,
'msg' => $msg,
'count' => count($menu_list),
'data' => $menu_list,
];
}
}
/**
* 修改搜索菜单栏数据格式
* @param $list
* @param int $i
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function __buildMenu(&$list) {
foreach ($list as &$vo) {
$i = 1;
if ($vo['pid'] != 0) {
$i++;
$nav = $this->where('id', $vo['pid'])->find();
!empty($nav) && ($nav['pid'] != 0 && $i++);
}
$vo['title'] = replace_menu_title($vo['title'], $i);
($vo['id'] == 1 || $i >= 3) ? $vo['is_add'] = false : $vo['is_add'] = true;
}
}
/**
* 使用回调获取菜单栏数据
* @param int $pid 上级id
* @param array $menu 菜单数据
* @param int $i 序号
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getMenu($pid = 0, &$menu = [], $i = 0) {
$i++;
$field = 'id, pid, title, icon, href, target, sort, status, create_at, create_by';
$where_nav = [
['pid', '=', $pid],
];
$order = [
'sort' => 'asc',
'create_at' => 'desc',
];
$nav = $this->field($field)->where($where_nav)->order($order)->select();
foreach ($nav as $vo) {
($vo['id'] == 1 || $i >= 3) ? $vo['is_add'] = false : $vo['is_add'] = true;
$vo['title'] = replace_menu_title($vo['title'], $i);
$menu[] = $vo;
$this->getMenu($vo['id'], $menu, $i);
}
return $menu;
}
/**
* 创建菜单时获取上级的菜单
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getUpMenu() {
$field = 'id, pid, title';
$where_nav = [
['id', '<>', 1],
['pid', '=', 0],
];
$order = [
'sort' => 'asc',
'create_at' => 'desc',
];
//最顶级
$first_list = $this->where($where_nav)->field($field)->order($order)->select();
//组合菜单数据
$menu_list[] = [
'id' => 0,
'pid' => 0,
'title' => '顶级菜单',
];
foreach ($first_list as &$vo) {
$vo['title'] = replace_menu_title($vo['title'], 1);
$menu_list[] = $vo;
$where_second = [['pid', '=', $vo['id']]];
$second_list = $this->where($where_second)->field($field)->order($order)->select();
foreach ($second_list as &$vl) {
$vl['title'] = replace_menu_title($vl['title'], 2);
$menu_list[] = $vl;
}
}
return $menu_list;
}
/**
* 获取系统导航菜单
* @param array $menu_list
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function getMenuApi($menu_list = []) {
$field = 'id, pid, title, icon, href, spread, target';
$order = ['sort' => 'asc', 'create_at' => 'desc'];
$nav = self::getNav()->toArray();
foreach ($nav as $vo) {
$i = 0;
$where_first_menu = [['pid', '=', $vo['id']], ['status', '=', 1]];
$first_menu = self::field($field)->where($where_first_menu)->order($order)->select()->toArray();
foreach ($first_menu as $vo_1) {
if (auth($vo_1['href'])) {
if (!empty($vo_1['href']) && $vo_1['href'] != "#") {
$vo_1['href'] = url($vo_1['href']);
}
$vo_1['spread'] = (bool)$vo_1['spread'];
$menu_list['66ysx_' . $vo['id']][$i] = $vo_1;
$where_second_menu = [['pid', '=', $vo_1['id']], ['status', '=', 1]];
$second_menu = self::field($field)->where($where_second_menu)->order($order)->select()->toArray();
foreach ($second_menu as $vo_2) {
if (auth($vo_2['href'])) {
if (!empty($vo_2['href']) && $vo_2['href'] != "#") {
$vo_2['href'] = url($vo_2['href']);
}
$vo_2['spread'] = (bool)$vo_2['spread'];
$menu_list['66ysx_' . $vo['id']][$i]['children'][] = $vo_2;
}
}
//去除空菜单
if (!isset($menu_list['66ysx_' . $vo['id']][$i]['children'])) {
if ($menu_list['66ysx_' . $vo['id']][$i]['href'] == '#' || $menu_list['66ysx_' . $vo['id']][$i]['href'] == '') {
unset($menu_list['66ysx_' . $vo['id']][$i]);
} else {
$i++;
}
} else {
$i++;
}
}
}
}
return array_filter($menu_list);
}
/**
* 更新字段值
* @param $update
* @return \think\response\Json
*/
public function edit_field($update) {
$data = $this->where('id', $update['id'])->update([$update['field'] => $update['value']]);
if ($data == 1) {
return __success('修改成功!');
} else {
return __error('数据没有修改!');
}
}
}

View File

@@ -0,0 +1,35 @@
<?php
/*
* 导航模型
* */
namespace app\admin\model;
use app\admin\service\ModelService;
class Nav extends ModelService {
/**
* 绑定数据表
* @var string
*/
protected $table = 'system_nav';
/**
* 获取快捷导航
* @param int $limit
* @return array|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function getQuickNav($limit = 6) {
$list = self::where(['status' => 1])->order(['sort' => 'desc', 'create_at' => 'desc'])
->limit($limit)->select()->each(function ($item, $key) {
$item['href'] = url($item['href']);
});
return $list;
}
}

View File

@@ -0,0 +1,142 @@
<?php
/*
* 节点模型
* */
namespace app\admin\model;
use app\admin\service\ModelService;
class Node extends ModelService {
/**
* 绑定的数据表
* @var string
*/
protected $table = 'system_node';
/**
* 节点列表
* @param int $page 当前页
* @param int $limit 每页显示数量
* @param array $search 搜索条件 array
* @param array $where 组成的条件
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function nodeList($page = 1, $limit = 10, $search = [], $where = []) {
//搜索条件
foreach ($search as $key => $value) {
if ($key == 'is_auth' && $value != '') {
$where[] = [$key, '=', $value];
} elseif ($key == 'create_at' && $value != '') {
$value_list = explode(" - ", $value);
$where[] = [$key, 'BETWEEN', ["{$value_list[0]} 00:00:00", "{$value_list[1]} 23:59:59"]];
} else {
!empty($value) && $where[] = [$key, 'LIKE', '%' . $value . '%'];
}
}
$field = 'id, node, title , is_auth, create_at';
$count = $this->where($where)->count();
$data = $this->where($where)->field($field)->page($page, $limit)->order(['node asc'])->select();
empty($data) ? $msg = '暂无数据!' : $msg = '查询成功!';
$info = [
'limit' => $limit,
'page_current' => $page,
'page_sum' => ceil($count / $limit),
];
$list = [
'code' => 0,
'msg' => $msg,
'count' => $count,
'info' => $info,
'data' => $data,
];
return $list;
}
/**
* 保存节点
* @param $insert
* @return \think\response\Json
*/
public function add($insert) {
$save = $this->save($insert);
if ($save == 1) {
return __success('保存成功!');
} else {
return __error('保存失败!');
}
}
/**
* 更新节点
* @param $update
* @return \think\response\Json
*/
public function edit($update) {
$data = $this->where('id', $update['id'])->update($update);
if ($data == 1) {
return __success('更新成功!');
} else {
return __error('数据没有修改!');
}
}
/**
* 修改系统节点字段值
* @param $update
* @return \think\response\Json
*/
public function edit_field($update) {
$data = $this->where('id', $update['id'])->update([$update['field'] => $update['value']]);
if ($data == 1) {
return __success('修改成功!');
} else {
return __error('数据没有修改!');
}
}
/**
* 根据模块名称获取节点
* @param $module
* @param array $node_list
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function nodeModuleList($module, $node_list = []) {
$modules = $this->where(['type' => 1, 'node' => $module])->order(['node'=>'asc'])->select()->toArray();
foreach ($modules as &$vo_m) {
$i = 1;
$vo_module = $vo_m;
$vo_module['node'] = replace_menu_title($vo_module['node'], $i);
$node_list[] = $vo_module;
$controller = $this->where([['type', '=', 2], ['node', 'LIKE', "{$vo_m['node']}/%"]])->order(['node'=>'asc'])->select()->toArray();
foreach ($controller as &$vo_c) {
$i = 2;
$vo_controller = $vo_c;
$vo_controller['node'] = replace_menu_title($vo_controller['node'], $i);
$node_list[] = $vo_controller;
$action = $this->where([['type', '=', 3], ['node', 'LIKE', "{$vo_c['node']}/%"]])->order(['node'=>'asc'])->select()->toArray();
foreach ($action as &$vo_a) {
$i = 3;
$vo_action = $vo_a;
$vo_action['node'] = replace_menu_title($vo_action['node'], $i);
$node_list[] = $vo_action;
}
}
}
return [
'code' => 0,
'msg' => '查询成功',
'count' => count($node_list),
'data' => $node_list,
];
}
}

View File

@@ -0,0 +1,193 @@
<?php
/**
* 系统管理员模型
* Class User
* @package app\admin\model
*/
namespace app\admin\model;
use app\admin\service\ModelService;
class User extends ModelService {
/**
* 绑定数据表
* @var string
*/
protected $table = 'system_user';
/**
* 关联角色表数据
* @return \think\model\relation\HasOne
*/
public function auth() {
return $this->hasOne("Auth", "id", "auth_id")->joinType('left')->field('title');
}
/**
* 启用或者禁用管理员账户
* @param $id
* @return User|bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function operate($id) {
$where_operate = [
['id', '=', $id],
['is_deleted', '=', 0],
['status', 'In', [0, 1]],
];
$operate = $this->where($where_operate)->find();
if (!empty($operate)) {
$operate['status'] == 0 ? $status = 1 : $status = 0;
$status == 0 ? $msg = '账户停用成功!' : $msg = '账户启用成功';
$update = $this->where($where_operate)->update(['status' => $status]);
if ($update >= 1) return ['code' => 0, 'msg' => $msg];
return ['code' => 1, 'msg' => '账户状态更改失败,请检查!'];
}
return false;
}
/**
* 登录验证
* @param $username 管理员账户
* @param $password 管理员密码
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function login($username, $password) {
$where_login = [
['username', '=', $username],
['is_deleted', 'In', [0, 1]],
['status', 'In', [0, 1]],
];
$login = $this->where($where_login)->find();
if (empty($login)) return ['code' => 1, 'msg' => '账户不存在,请重新输入!', 'user' => $login];
if ($login['password'] != password($password)) return ['code' => 1, 'msg' => '密码不正确,请重新输入!', 'user' => $login];
if ($login['is_deleted'] == 1) return ['code' => 1, 'msg' => '该账户已被删除,请联系超级管理员!', 'user' => $login];
if ($login['status'] == 0) return ['code' => 1, 'msg' => '该账户已被停用,请联系超级管理员!', 'user' => $login];
unset($login['password']);
return ['code' => 0, 'msg' => '登录成功,正在进入后台系统!', 'user' => $login];
}
/**
* 添加管理员
* @param $insert 需要插入的数据
* @return \think\response\Json
* @throws \think\exception\PDOException
*/
public function add($insert) {
//使用事物保存数据
$this->startTrans();
$save = $this->save($insert);
if (!$save) {
$this->rollback();
return __error('数据有误,请稍后再试!');
}
$this->commit();
return __success('管理员账户添加成功!');
}
/**
* 修改管理员信息
* @param $update 需要修改的数据
* @return \think\response\Json
*/
public function edit($update) {
$update = $this->where('id', $update['id'])->update($update);
if ($update >= 1) return __success('信息修改成功');
return __error('数据没有修改!');
}
/**
* 修改管理员自己的信息
* @param $update
* @return \think\response\Json
*/
public function editSelf($data) {
$this->where('id', $data['id'])->update($data);
//重新刷新session
$user = $this->where('id', $data['id'])->find();
unset($user['password']);
$user['login_at'] = time();
session('user', $user);
return __success('信息修改成功');
}
/**
* 修改管理员密码
* @param $update 需要修改的数据
* @return \think\response\Json
*/
public function editPassword($update) {
$this->startTrans();
try {
$this->where('id', $update['id'])->update(['password' => password($update['password'])]);
$this->commit();
} catch (\Exception $e) {
$this->rollback();
return __error($e->getMessage());
}
return __success('密码修改成功');
}
/**
* 获取用户列表信息
* @param int $page 当前页
* @param int $limit 每页显示数量
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function userList($page = 1, $limit = 10, $search = []) {
$where = [['is_deleted', '=', 0]];
//搜索条件
foreach ($search as $key => $value) {
if ($key == 'status' && $value != '') {
$where[] = [$key, '=', $value];
} elseif ($key == 'create_at' && $value != '') {
$value_list = explode(" - ", $value);
$where[] = [$key, 'BETWEEN', ["{$value_list[0]} 00:00:00", "{$value_list[1]} 23:59:59"]];
} else {
!empty($value) && $where[] = [$key, 'LIKE', '%' . $value . '%'];
}
}
$field = 'id, auth_id, username, head_img, qq, mail, phone, remark, status, create_by, create_at';
$count = $this->where($where)->count();
$data = $this->where($where)->field($field)->page($page, $limit)->select()
->each(function ($item, $key) {
list($auth_id_list, $auth_title) = [json_decode($item['auth_id'], true), ''];
foreach ($auth_id_list as $auth_id) {
$title = model('auth')->where(['id' => $auth_id, 'status' => 1])->value('title');
$auth_title = empty($auth_title) ? $title : "{$auth_title}{$title}";
}
$create_by_username = $this->where(['id' => $item['create_by'], 'status' => 1, 'is_deleted' => 0])->value('username');
empty($auth_title) ? $item['auth_title'] = '暂无权限信息' : $item['auth_title'] = $auth_title;
empty($create_by_username) ? $item['create_by_username'] = '暂未创建者信息' : $item['create_by_username'] = $create_by_username;
});
empty($data) ? $msg = '暂无数据!' : $msg = '查询成功!';
$info = [
'limit' => $limit,
'page_current' => $page,
'page_sum' => ceil($count / $limit),
];
$list = [
'code' => 0,
'msg' => $msg,
'count' => $count,
'info' => $info,
'data' => $data,
];
return $list;
}
}

View File

@@ -0,0 +1 @@
a1519cd4-363d-4c2a-87f6-0e9a0023bd99

View File

@@ -0,0 +1,107 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2020/4/24
* Time: 15:06
*/
namespace app\admin\model\costom;
use think\Model;
class Message extends Model
{
protected $table = 'user_message';
/**
* 获取留言建议列表信息
* @param int $page 当前页
* @param int $limit 每页显示数量
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function messageList($page = 1, $limit = 10, $search = []){
$where = [];
//搜索条件
foreach ($search as $key => $value) {
if (!empty($value)) {
switch ($key) {
case 'add_time':
$value_list = explode(" - ", $value);
$value_list[0] = strtotime($value_list[0]);
$value_list[1] = strtotime($value_list[1]);
$where[] = [$key, 'BETWEEN', ["$value_list[0]", "$value_list[1]"]];
break;
case 'status':
$where[] = [$key, '=', $value];
break;
case 'telnum':
$where[] = [$key, '=', $value];
break;
case 'type':
$where[] = [$key, '=', $value-1];
break;
default:
!empty($value) && $where[] = [$key, 'LIKE', '%' . $value . '%'];
}
}
}
$count = self::where($where)->count();
$data = self::where($where)->page($page, $limit)->order([ 'add_time' => 'desc'])->select();
empty($data) ? $msg = '暂无数据!' : $msg = '查询成功!';
foreach ($data as $key => $val){
$val['add_time'] = date('Y-m-d H:i:s',$val['add_time']);
if($val['reply_time']){
$val['reply_time'] = date('Y-m-d H:i:s',$val['reply_time']);
}
$val['img1'] = config('secure.mpic_url'). $val['img1'];
$val['img2'] = config('secure.mpic_url'). $val['img2'];
if($val['type']){
$val['type'] = config('setmes.mesName')[$val['type']];
}else{
$val['type'] = '考生建议';
}
}
$info = [
'limit' => $limit,
'page_current' => $page,
'page_sum' => ceil($count / $limit),
];
$list = [
'code' => 0,
'msg' => $msg,
'count' => $count,
'info' => $info,
'data' => $data,
];
return $list;
}
/*
* 回复问题
* */
public function reply($post){
$post['reply'] = $post['replyCon'];
$post['status'] = 2;
unset($post['replyCon']);
try {
self::where('id', $post['id'])->update($post);
} catch (\Exception $e) {
return __error($e->getMessage());
}
return __success('回复成功');
}
}

View File

@@ -0,0 +1,188 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2020/4/23
* Time: 19:02
*/
namespace app\admin\model\costom;
use think\Exception;
use think\facade\Log;
use think\Model;
require '../extend/WxPay/WxPay.Api.php';
class Order extends Model
{
protected $table = 'orders';
public static function orderRefund($post){
$resOrder = self::field('ord_no,status,money')->where([['id','=',$post['id']],['status','=',1],['pay_way','=',$post['payWay']]])->find();
//订单状态是否已支付
if(!$resOrder){
return 2;
}
if($post['payWay'] == 1){
//退款参数赋值
$data['order_no'] = $resOrder['ord_no'];
$data['total_price'] = $resOrder['money'];
$data['reason'] = $post['reason'];
$data['op_user_id'] = config('wxpay.mch_id');
$result = self::refund($data);
if($result['result_code'] == 'SUCCESS'){
self::where([['id','=',$post['id']],['status','=',1]])->update(['status' => 2,'refund_time'=>time()]);
return true;
}
return false;
}else{
$data['order_no'] = $resOrder['ord_no'];
$data['total_price'] = $resOrder['money'];
$data['reason'] = $post['reason'];
$result = self::aliRefund($data);
if($result->code == 10000 && $result->msg == 'Success'){
self::where([['id','=',$post['id']],['status','=',1],['pay_way','=',$post['payWay']]])->update(['status' => 2,'refund_time'=>time()]);
return true;
}
}
}
/**
* 微信支付退款
* @param $orderInfo
* @throws \WxPayException
*/
private static function refund($orderInfo)
{
$inputObj = new \WxPayUnifiedOrder();
$out_refund_no = date('Ymd') . str_pad(mt_rand(1, 99999), 5, '0', STR_PAD_LEFT);
$inputObj->SetOut_trade_no($orderInfo['order_no']);
$inputObj->SetOut_refund_no($out_refund_no);
$inputObj->SetTotal_fee(intval($orderInfo['total_price']*100));
$inputObj->SetRefund_fee(intval($orderInfo['total_price']*100));
$inputObj->SetRefund_desc($orderInfo['reason']);
$inputObj->SetOp_user_id( $orderInfo['op_user_id']);
$wxOrder = \WxPayApi::refund($inputObj);
return $wxOrder;
}
/**
* 支付寶退款
* @param $orderInfo
*/
private static function aliRefund($orderInfo)
{
require '../extend/alipay/wappay/buildermodel/AlipayTradeRefundContentBuilder.php';// 加载交易服务
require '../extend/alipay/wappay/service/AlipayTradeService.php';// 加载交易服务
$out_trade_no = trim($orderInfo['order_no']);
//退款金额,不能大于订单总金额
$refund_amount=trim($orderInfo['total_price']);
//退款的原因说明
$refund_reason=trim($orderInfo['reason']);
$config = config('alipay.');
$RequestBuilder = new \AlipayTradeRefundContentBuilder();
$RequestBuilder->setOutTradeNo($out_trade_no);
$RequestBuilder->setRefundAmount($refund_amount);
$RequestBuilder->setRefundReason($refund_reason);
$Response = new \AlipayTradeService($config);
$result=$Response->Refund($RequestBuilder);
return $result;
}
/**
* 获取订单列表信息
* @param int $page 当前页
* @param int $limit 每页显示数量
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function orderList($page = 1, $limit = 10, $search = []) {
$where = [];
//搜索条件
foreach ($search as $key => $value) {
if (!empty($value)) {
switch ($key) {
case 'add_time':
$value_list = explode(" - ", $value);
$value_list[0] = strtotime($value_list[0]);
$value_list[1] = strtotime($value_list[1]);
$where[] = [$key, 'BETWEEN', ["$value_list[0]", "$value_list[1]"]];
break;
case 'stu_yzy_province':
$where[] = [$key, '=', $value];
break;
case 'telnum':
$where[] = [$key, '=', $value];
break;
case 'ord_no':
$where[] = [$key, '=', $value];
break;
case 'pay_way':
$where[] = [$key, '=', $value];
break;
case 'status':
if($value > 0){
$where[] = [$key, '=', $value-1];
}
break;
default:
!empty($value) && $where[] = [$key, 'LIKE', '%' . $value . '%'];
}
}
}
$count = self::where($where)->count();
$data = self::field('id,score,add_time,pay_time,vip,wenli,mykemustr,wenli,province_title,telnum,money,ord_no,refund_time,status,user_id,pay_way')->where($where)->page($page, $limit)->order([ 'add_time' => 'desc'])->select();
empty($data) ? $msg = '暂无数据!' : $msg = '查询成功!';
//获取配置权限名称
$vipNameArr = config('product.vipName');
foreach ($data as $key => $val){
$data[$key]['order_time'] = '';
$data[$key]['vipName'] = $vipNameArr[$val['vip']];
$data[$key]['order_time'] .= "下单:".date('Y-m-d H:i:s',$val['add_time']);
if($val['pay_time']){
$data[$key]['order_time'] .="_支付:". date('Y-m-d H:i:s',$val['pay_time']);
}
if($val['refund_time']){
$data[$key]['order_time'] .="_退款:". date('Y-m-d H:i:s',$val['refund_time']);
}
$val['wenli'] = $val['wenli'] = config('setSub.subTypeName')[$val['wenli']];
//拼接用户信息
$data[$key]['userInfo'] = $val['province_title']."_".$val['score']."_".$val['wenli']."_".$val['mykemustr'];
}
$info = [
'limit' => $limit,
'page_current' => $page,
'page_sum' => ceil($count / $limit),
];
$list = [
'code' => 0,
'msg' => $msg,
'count' => $count,
'info' => $info,
'data' => $data,
];
return $list;
}
}

View File

@@ -0,0 +1,64 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2020/4/25
* Time: 15:11
*/
namespace app\admin\model\costom;
use app\admin\service\ModelService;
class Proscore extends ModelService
{
/**
* 绑定数据表
* @var string
*/
protected $table = 'yzy_province_lines2020';
/**
* 获取省控分数列表
* @param int $page
* @param int $limit
* @param array $search
* @return array
*/
public static function getList($page = 1, $limit = 10, $search = []) {
$where = [];
//搜索条件
foreach ($search as $key => $value) {
if (!empty($value)) {
switch ($key) {
case 'province_id':
$where[] = [$key, '=', $value];
break;
default:
!empty($value) && $where[] = [$key, 'LIKE', '%' . $value . '%'];
}
}
}
$count = self::where($where)->count();
$data = self::where($where)->page($page, $limit)->select();
empty($data) ? $msg = '暂无数据!' : $msg = '查询成功!';
$info = [
'limit' => $limit,
'page_current' => $page,
'page_sum' => ceil($count / $limit),
];
$list = [
'code' => 0,
'msg' => $msg,
'count' => $count,
'info' => $info,
'data' => $data,
];
return $list;
}
}

View File

@@ -0,0 +1,82 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2020/4/23
* Time: 8:57
*/
namespace app\admin\model\costom;
use app\admin\service\ModelService;
class User extends ModelService
{
protected $table = 'users';
/**
* 获取用户列表信息
* @param int $page 当前页
* @param int $limit 每页显示数量
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function userList($page = 1, $limit = 10, $search = []) {
$where = [];
//搜索条件
foreach ($search as $key => $value) {
if (!empty($value)) {
switch ($key) {
case 'add_time':
$value_list = explode(" - ", $value);
$value_list[0] = strtotime($value_list[0]);
$value_list[1] = strtotime($value_list[1]);
$where[] = [$key, 'BETWEEN', ["$value_list[0]", "$value_list[1]"]];
break;
case 'phone':
$where[] = [$key, '=', $value];
break;
case 'province':
$where[] = [$key, '=', $value];
break;
default:
!empty($value) && $where[] = [$key, 'LIKE', '%' . $value . '%'];
}
}
}
$count = self::where($where)->count();
$data = self::field('id,score,add_time,province,phone,wenli,mykemu')->where($where)->page($page, $limit)->order([ 'add_time' => 'desc'])->select();
empty($data) ? $msg = '暂无数据!' : $msg = '查询成功!';
//获取省份数组
$provinceArr = config('province.province');
foreach ($data as $key => $val){
$val['province'] = $provinceArr[$val['province']]['title'];
$val['add_time'] = date('Y-m-d H:i:s',$val['add_time']);
$val['wenli'] = config('setSub.subTypeName')[$val['wenli']];
if($val['mykemu']){
$val['mykemu'] = changeSubString($val['mykemu']);
}
$data[$key]['userInfo'] = $val['province']."_".$val['score']."_".$val['wenli']."_".$val['mykemu'];
}
$info = [
'limit' => $limit,
'page_current' => $page,
'page_sum' => ceil($count / $limit),
];
$list = [
'code' => 0,
'msg' => $msg,
'count' => $count,
'info' => $info,
'data' => $data,
];
return $list;
}
}