Commit f00549db authored by wangtao's avatar wangtao

业务板块api接口

parent 7e1a11d2
...@@ -7,11 +7,13 @@ ...@@ -7,11 +7,13 @@
* Licensed: 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行 * Licensed: 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
* --------------------------------------------------------------------------- * ---------------------------------------------------------------------------
*/ */
namespace app\admin\controller; namespace app\admin\controller;
use app\BaseController; use app\BaseController;
use app\model\system\SystemRoles as Roles; use app\model\system\SystemRoles as Roles;
use app\model\system\SystemManager as Manager; use app\model\system\SystemManager as Manager;
use think\facade\Db;
/** /**
*【后台控制器抽象基类】 *【后台控制器抽象基类】
...@@ -45,7 +47,9 @@ abstract class AdminBase extends BaseController ...@@ -45,7 +47,9 @@ abstract class AdminBase extends BaseController
/** /**
* 覆盖无需业务 * 覆盖无需业务
*/ */
protected function __home(){} protected function __home()
{
}
/** /**
* 后台控制器验证初始化 * 后台控制器验证初始化
...@@ -59,7 +63,7 @@ abstract class AdminBase extends BaseController ...@@ -59,7 +63,7 @@ abstract class AdminBase extends BaseController
//载入权限菜单 //载入权限菜单
$this->loadMenusRoles(); $this->loadMenusRoles();
//构组路由: 控制器 + 方法 + (参数action的传值) //构组路由: 控制器 + 方法 + (参数action的传值)
$this->routeUri = strtolower($this->request->ADDON_APP.$this->request->controller()."/".$this->request->action().(($action = $this->request->get('action')) ? '/'.$action : '')); $this->routeUri = strtolower($this->request->ADDON_APP . $this->request->controller() . "/" . $this->request->action() . (($action = $this->request->get('action')) ? '/' . $action : ''));
//验证权限 //验证权限
$this->isPower(); $this->isPower();
} }
...@@ -69,11 +73,11 @@ abstract class AdminBase extends BaseController ...@@ -69,11 +73,11 @@ abstract class AdminBase extends BaseController
*/ */
private function isLogin() private function isLogin()
{ {
if(is_null($this->manUser = session(VT_MANAGER))){ if (is_null($this->manUser = session(VT_MANAGER))) {
$url = $this->appMap.'/login/index'; $url = $this->appMap . '/login/index';
if($this->request->isAjax()){ if ($this->request->isAjax()) {
$this->exitMsg('您还未登录或已过期,请先登录!',401,['url'=>$url]); $this->exitMsg('您还未登录或已过期,请先登录!', 401, ['url' => $url]);
}else{ } else {
$this->redirect($url); $this->redirect($url);
} }
} }
...@@ -85,23 +89,23 @@ abstract class AdminBase extends BaseController ...@@ -85,23 +89,23 @@ abstract class AdminBase extends BaseController
private function loadMenusRoles() private function loadMenusRoles()
{ {
$us = Manager::one("username = '{$this->manUser['username']}' AND state > 0"); $us = Manager::one("username = '{$this->manUser['username']}' AND state > 0");
if($us && $this->manUser['password'] == $us['password'] && $this->manUser['passsalt'] == $us['passsalt']){ if ($us && $this->manUser['password'] == $us['password'] && $this->manUser['passsalt'] == $us['passsalt']) {
//禁止同帐号同时异地登录处理 //禁止同帐号同时异地登录处理
if(in_array(vconfig('ip_login',0),[2,3]) && $us['loginip'] != $this->request->ip()){ if (in_array(vconfig('ip_login', 0), [2, 3]) && $us['loginip'] != $this->request->ip()) {
session(null); session(null);
$url = $this->appMap.'/login/index'; $url = $this->appMap . '/login/index';
$this->exitMsg('您的帐号已在其他终端登录!',$this->request->isAjax() ? 401 : 303,['url'=>$url]); $this->exitMsg('您的帐号已在其他终端登录!', $this->request->isAjax() ? 401 : 303, ['url' => $url]);
} }
$us = $us->toArray(); $us = $us->toArray();
$us['role_menuid'] = ''; $us['role_menuid'] = '';
$us['role_name'] = '超级管理员'; $us['role_name'] = '超级管理员';
$us['uid'] = $this->manUser['uid']; $us['uid'] = $this->manUser['uid'];
//非超级管理员载入角色权限['roleid'=>角色ID,'role_name'=>+角色名,'role_menuid'=>+拥有的菜单ID串'actions'=>+权限记录集] //非超级管理员载入角色权限['roleid'=>角色ID,'role_name'=>+角色名,'role_menuid'=>+拥有的菜单ID串'actions'=>+权限记录集]
$this->manUser = $us['userid']>1 ? array_merge($us, Roles::cache($us['roleid'])) : $us; $this->manUser = $us['userid'] > 1 ? array_merge($us, Roles::cache($us['roleid'])) : $us;
}else{ } else {
session(null); session(null);
$url = $this->appMap.'/login/index'; $url = $this->appMap . '/login/index';
$this->exitMsg('您还未登录或已过期,请先登录!',$this->request->isAjax() ? 401 : 303,['url'=>$url]); $this->exitMsg('您还未登录或已过期,请先登录!', $this->request->isAjax() ? 401 : 303, ['url' => $url]);
} }
} }
...@@ -110,24 +114,24 @@ abstract class AdminBase extends BaseController ...@@ -110,24 +114,24 @@ abstract class AdminBase extends BaseController
*/ */
private function isPower() private function isPower()
{ {
if($this->manUser['userid']>1 && !in_array($this->routeUri,$this->manUser['actions'])){ if ($this->manUser['userid'] > 1 && !in_array($this->routeUri, $this->manUser['actions'])) {
$this->exitMsg('抱歉,您没有该项权限请联系管理员!',$this->request->isAjax() ? 401 : 400); $this->exitMsg('抱歉,您没有该项权限请联系管理员!', $this->request->isAjax() ? 401 : 400);
} }
} }
/** /**
* 日志/在线处理 * 日志/在线处理
* @access protected * @access protected
* @param sting $tip 提示 * @param sting $tip 提示
*/ */
protected function logon(string $tip = '') protected function logon(string $tip = '')
{ {
//操作日志 //操作日志
if(vconfig('admin_log',0)){ if (vconfig('admin_log', 0)) {
\app\model\system\SystemManagerLog::add(['url'=>$this->routeUri.($tip ? ' '.$tip : ''),'username'=>$this->manUser['username'],'ip'=>$this->request->ip()]); \app\model\system\SystemManagerLog::add(['url' => $this->routeUri . ($tip ? ' ' . $tip : ''), 'username' => $this->manUser['username'], 'ip' => $this->request->ip()]);
} }
//在线统计 【online_on = 0:关闭全部 1:开启后台 2:开启会员 3:开启全部】 //在线统计 【online_on = 0:关闭全部 1:开启后台 2:开启会员 3:开启全部】
if(in_array(vconfig('online_on',0),[1,3])){ if (in_array(vconfig('online_on', 0), [1, 3])) {
\app\model\system\SystemOnline::recod($this->manUser, $this->routeUri, 0); \app\model\system\SystemOnline::recod($this->manUser, $this->routeUri, 0);
} }
} }
...@@ -140,24 +144,29 @@ abstract class AdminBase extends BaseController ...@@ -140,24 +144,29 @@ abstract class AdminBase extends BaseController
*/ */
protected function getRoleExt() protected function getRoleExt()
{ {
if($this->manUser['userid'] == 1) return 0; if ($this->manUser['userid'] == 1) return 0;
$d = explode('/', $this->routeUri); $d = explode('/', $this->routeUri);
if(isset($this->manUser['role_ext'][$d[0].'/*'])){ if (isset($this->manUser['role_ext'][$d[0] . '/*'])) {
return $this->manUser['role_ext'][$d[0].'/*']; return $this->manUser['role_ext'][$d[0] . '/*'];
}elseif(isset($d[1]) && isset($this->manUser['role_ext'][$d[0].'/'.$d[1].'/*'])){ } elseif (isset($d[1]) && isset($this->manUser['role_ext'][$d[0] . '/' . $d[1] . '/*'])) {
return $this->manUser['role_ext'][$d[0].'/'.$d[1].'/*']; return $this->manUser['role_ext'][$d[0] . '/' . $d[1] . '/*'];
}elseif(isset($d[1]) && isset($d[2]) && isset($this->manUser['role_ext'][$d[0].'/'.$d[1].'/'.$d[2].'/*'])){ } elseif (isset($d[1]) && isset($d[2]) && isset($this->manUser['role_ext'][$d[0] . '/' . $d[1] . '/' . $d[2] . '/*'])) {
return $this->manUser['role_ext'][$d[0].'/'.$d[1].'/'.$d[2].'/*']; return $this->manUser['role_ext'][$d[0] . '/' . $d[1] . '/' . $d[2] . '/*'];
}else{ } else {
return $this->manUser['role_ext'][$this->routeUri] ?? 0; return $this->manUser['role_ext'][$this->routeUri] ?? 0;
} }
} }
public function downloadfile($fileid) public function downloadfile($fileid, $excel = 0)
{ {
$fileinfo = get_upload_file($fileid,'info');
return download('.'.$fileinfo['fileurl'], $fileinfo['filename'],true); if ($excel == 1) {
$fileinfo = Db::name('excel_down')->where(['id' => $fileid])->find();
} else {
$fileinfo = get_upload_file($fileid, 'info');
}
$fileurl = strstr($fileinfo['fileurl'],'/static');
return download('.' . $fileurl, $fileinfo['filename'])->force(true);
} }
} }
\ No newline at end of file
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
namespace app\admin\controller\caiwu; namespace app\admin\controller\caiwu;
use app\admin\controller\AdminBase; use app\admin\controller\AdminBase;
use app\event\PhpOffice;
use think\App; use think\App;
use think\facade\Db; use think\facade\Db;
use app\model\project\UserWithdrawal; use app\model\project\UserWithdrawal;
...@@ -163,6 +164,58 @@ class Withdrawal extends AdminBase ...@@ -163,6 +164,58 @@ class Withdrawal extends AdminBase
return $this->returnMsg($e->getMessage()); return $this->returnMsg($e->getMessage());
} }
}
//导出excel
public function excelwithdrawal()
{
$post = input();
$map = [];
$hasmap = [];
if (isset($post['kw']) && !empty($post['kw'])) {
$map[] = ['sn', 'like', '%' . $post['kw'] . '%'];
}
if (isset($post['sh_status']) && $post['sh_status'] > -1) {
$map[] = ['sh_status', '=', $post['sh_status']];
}
if (isset($post['dk_status']) && $post['dk_status'] > -1) {
$map[] = ['dk_status', '=', $post['dk_status']];
}
if (isset($post['user']) && !empty($post['user'])) {
$hasmap[] = ['username|mobile', 'like', '%' . $post['user'] . '%'];
}
if (isset($post['ids']) && $post['ids']) {
$map[] = ['user_withdrawal.id', 'in', $post['ids']];
}
try {
$list = $this->withdrawal->where($map)->hasWhere('getuserdata', $hasmap)->with(['getuserdata'])->append(['sh_status_text', 'dk_status_text'])->order('createtime desc')->select()->toArray();
if (empty($list)) {
throw new \Exception('没有数据');
}
$exceldata[] = ['提现单号', '用户名', '用户手机', '提现金额', '提现手续费', '实际到账金额', '提现账号', '审核状态', '打款状态', '提现时间', '打款时间'];
foreach ($list as $k => $v) {
$exceldata[] = [
$v['sn'],
$v['getuserdata']['username'],
$v['getuserdata']['mobile'],
$v['tx_money'],
$v['tx_commission'],
$v['tx_sj_money'],
$v['account'],
$v['sh_status_text'],
$v['dk_status_text'],
$v['createtime'],
$v['dk_time'] ? date('Y-m-d H:i:s', $v['dk_time']) : '',
];
}
$excelid = PhpOffice::exportexcel($exceldata, '提现导出');
$data['url'] = '/admin/caiwu.withdrawal/downloadfile?excel=1&fileid=' . $excelid;
return $this->returnMsg('success', 1, $data);
} catch (\Exception $e) {
return $this->returnMsg($e->getMessage());
}
} }
} }
\ No newline at end of file
...@@ -69,7 +69,7 @@ class Cert extends AdminBase ...@@ -69,7 +69,7 @@ class Cert extends AdminBase
if($result){ if($result){
return $this->returnMsg('修改成功',1); return $this->returnMsg('修改成功',1);
}else{ }else{
return $this->returnMsg('修改成功'); return $this->returnMsg('修改失败');
} }
} }
......
...@@ -51,6 +51,10 @@ class Course extends AdminBase ...@@ -51,6 +51,10 @@ class Course extends AdminBase
if (isset($post['cate_id']) && !empty($post['cate_id'])) { if (isset($post['cate_id']) && !empty($post['cate_id'])) {
$map[] = ['cate_id', '=', $post['cate_id']]; $map[] = ['cate_id', '=', $post['cate_id']];
} }
if (isset($post['status']) && $post['status'] > -1) {
$map[] = ['status', '=', $post['status']];
}
$list = $this->course->where($map)->append(['thumbpath', 'cate_name', 'teacher_name', 'status_text', 'tag_title', 'user_info', 'is_sell_text'])->order('createtime desc')->paginate($post['limit']); $list = $this->course->where($map)->append(['thumbpath', 'cate_name', 'teacher_name', 'status_text', 'tag_title', 'user_info', 'is_sell_text'])->order('createtime desc')->paginate($post['limit']);
return $this->returnMsg($list); return $this->returnMsg($list);
...@@ -66,8 +70,16 @@ class Course extends AdminBase ...@@ -66,8 +70,16 @@ class Course extends AdminBase
{ {
$post = input(); $post = input();
$this->course->update([$post['af'] => $post['av']], [['id', '=', $post['id']]]); $result = $this->course->update([$post['af'] => $post['av']], [['id', '=', $post['id']]]);
return $this->returnMsg('修改成功'); if($post['av'] == 'is_sell'){
$course_id = $post['id'];
event('Course', ['course_id' => $course_id, 'tasktype' => 'course', 'action' => 'shcourseupdate']);
}
if($result){
return $this->returnMsg('修改成功',1);
}else{
return $this->returnMsg('修改失败');
}
} }
...@@ -76,8 +88,10 @@ class Course extends AdminBase ...@@ -76,8 +88,10 @@ class Course extends AdminBase
$post = input(); $post = input();
$ids = is_array($post['id']) ? implode(',', $post['id']) : $post['id']; $ids = is_array($post['id']) ? implode(',', $post['id']) : $post['id'];
if ($this->course->where("id IN(" . $ids . ")")->update(['is_del' => 1])) { if ($this->course->where("id IN(" . $ids . ")")->update(['is_del' => 1])) {
$course_id_arr = $this->course->where("id IN(" . $ids . ")")->column('id'); // $course_id_arr = $this->course->where("id IN(" . $ids . ")")->column('id');
$course_id_arr = array_unique($course_id_arr); // $course_id_arr = array_unique($course_id_arr);
$course_id_arr = explode(',', $ids);
foreach ($course_id_arr as $course_id) { foreach ($course_id_arr as $course_id) {
event('Course', ['course_id' => $course_id, 'tasktype' => 'course', 'action' => 'shcourseupdate']); event('Course', ['course_id' => $course_id, 'tasktype' => 'course', 'action' => 'shcourseupdate']);
} }
......
<?php
/**
* ===========================================================================
* Veitool 快捷开发框架系统
* Author: Niaho 26843818@qq.com
* Copyright (c)2019-2025 www.veitool.com All rights reserved.
* Licensed: 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
* ---------------------------------------------------------------------------
*/
namespace app\admin\controller\order;
use app\admin\controller\AdminBase;
use think\App;
use think\facade\Db;
use app\model\Payment as PaymentModel;
/**
* 后台主控制器
*/
class Payment extends AdminBase
{
protected $payment;
public function __construct(App $app)
{
parent::__construct($app);
$this->payment = new PaymentModel();
}
// 列表
public function index(string $do = '')
{
$limit = 10;
if ($do == 'json') {
$post = input();
$post['limit'] = isset($post['limit']) ? $post['limit'] : $limit;
$map = [];
$hasmap = [];
if (isset($post['kw']) && !empty($post['kw'])) {
$map[] = ['order_no', 'like', '%' . $post['kw'] . '%'];
}
if (isset($post['user']) && !empty($post['user'])) {
$hasmap[] = ['username|mobile', 'like', '%' . $post['user'] . '%'];
}
if (isset($post['pay_status']) && $post['pay_status'] > -1) {
$map[] = ['pay_status', '=', $post['pay_status']];
}
$list = $this->payment->where($map)->hasWhere('getuserdata', $hasmap)->with(['getuserdata'])->append(['pay_status_text', 'pay_method_text', 'pay_time_text', 'order_name'])->order('createtime desc')->paginate($post['limit']);
return $this->returnMsg($list);
}
$this->assign('limit', $limit);
return $this->fetch('', '', false);
}
//快速编辑
public function editup()
{
$post = input();
$result = $this->payment->update([$post['af'] => $post['av']], [['id', '=', $post['id']]]);
if ($result) {
return $this->returnMsg('修改成功', 1);
} else {
return $this->returnMsg('修改失败');
}
}
public function del()
{
$post = input();
$ids = is_array($post['id']) ? implode(',', $post['id']) : $post['id'];
if ($this->payment->where("id IN(" . $ids . ")")->update(['is_del' => 1])) {
return $this->returnMsg("删除成功", 1);
} else {
return $this->returnMsg("删除失败");
}
}
}
\ No newline at end of file
{extend name="base/header" /} {extend name="base/header" /}
{block name="body"} {block name="body"}
<div style="margin: 0px 10px"> <div style="margin: 0px 30px 0px 0px">
<form class="layui-form " style="margin-top: 20px;" id="fjfrom"> <form class="layui-form " style="margin-top: 20px;" id="fjfrom">
<div class="layui-form-item"> <div class="layui-form-item">
......
...@@ -132,10 +132,10 @@ ...@@ -132,10 +132,10 @@
} }
layer.open({ layer.open({
type: 2, type: 2,
area: ['900px', '900px'], area: ['900px', '90%'],
title: title, title: title,
btn: ['确定', '关闭'], btn: ['确定', '关闭'],
fixed: false, //不固定 // fixed: false, //不固定
content: '/admin/advert/edit?id='+id+'&type='+type, content: '/admin/advert/edit?id='+id+'&type='+type,
yes: function(index, layero){ yes: function(index, layero){
var data = window["layui-layer-iframe" + index].callbackdata(); var data = window["layui-layer-iframe" + index].callbackdata();
......
{extend name="base/header" /} {extend name="base/header" /}
{block name="body"} {block name="body"}
<div style="margin: 0px 10px"> <div style="margin: 0px 30px 0px 0px;">
<form class="layui-form " style="margin-top: 20px;" id="fjfrom"> <form class="layui-form " style="margin-top: 20px;" id="fjfrom">
......
...@@ -118,10 +118,10 @@ ...@@ -118,10 +118,10 @@
} }
layer.open({ layer.open({
type: 2, type: 2,
area: ['900px', '900px'], area: ['600px', '70%'],
title: title, title: title,
btn: ['确定', '关闭'], btn: ['确定', '关闭'],
fixed: false, //不固定 // fixed: false, //不固定
content: '/admin/advert_cate/edit?id='+id+'&type='+type, content: '/admin/advert_cate/edit?id='+id+'&type='+type,
yes: function(index, layero){ yes: function(index, layero){
var data = window["layui-layer-iframe" + index].callbackdata(); var data = window["layui-layer-iframe" + index].callbackdata();
......
...@@ -164,10 +164,10 @@ ...@@ -164,10 +164,10 @@
} }
layer.open({ layer.open({
type: 2, type: 2,
area: ['900px', '900px'], area: ['900px', '90%'],
title: title, title: title,
btn: ['确定', '关闭'], btn: ['确定', '关闭'],
fixed: false, //不固定 // fixed: false, //不固定
content: '/admin/article/edit?id='+id+'&type='+type, content: '/admin/article/edit?id='+id+'&type='+type,
yes: function(index, layero){ yes: function(index, layero){
var data = window["layui-layer-iframe" + index].callbackdata(); var data = window["layui-layer-iframe" + index].callbackdata();
......
...@@ -104,10 +104,10 @@ ...@@ -104,10 +104,10 @@
} }
layer.open({ layer.open({
type: 2, type: 2,
area: ['900px', '900px'], area: ['700px', '90%'],
title: title, title: title,
btn: ['确定', '关闭'], btn: ['确定', '关闭'],
fixed: false, //不固定 // fixed: false, //不固定
content: app_root+'edit?id='+id, content: app_root+'edit?id='+id,
yes: function(index, layero){ yes: function(index, layero){
var data = window["layui-layer-iframe" + index].callbackdata(); var data = window["layui-layer-iframe" + index].callbackdata();
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
<div class="layui-inline"> <div class="layui-inline">
<div class="layui-btn-group"> <div class="layui-btn-group">
<button class="layui-btn" lay-submit lay-filter="search-withdrawal"><i class="layui-icon layui-icon-search"></i> 搜索</button> <button class="layui-btn" lay-submit lay-filter="search-withdrawal"><i class="layui-icon layui-icon-search"></i> 搜索</button>
<button class="layui-btn" lay-submit lay-filter="excel-withdrawal"><i class="layui-icon layui-icon-download-circle"></i> 导出</button>
<a class="layui-btn" lay-submit lay-filter="search-withdrawal-all" onclick="$('#withdrawal-groupid').val('')"><i class="layui-icon layui-icon-light"></i>全部</a> <a class="layui-btn" lay-submit lay-filter="search-withdrawal-all" onclick="$('#withdrawal-groupid').val('')"><i class="layui-icon layui-icon-light"></i>全部</a>
...@@ -106,6 +107,7 @@ ...@@ -106,6 +107,7 @@
page: true, page: true,
limit:{$limit}, limit:{$limit},
height: 'full-341', height: 'full-341',
// toolbar: 'default', //开启工具栏,此处显示默认图标,可以自定义模板,详见文档
url: app_root+"index?&do=json", url: app_root+"index?&do=json",
// css: 'td .layui-table-cell{height:80px;line-height:80px;padding:0 5px;}', // css: 'td .layui-table-cell{height:80px;line-height:80px;padding:0 5px;}',
cols: [[ cols: [[
...@@ -138,6 +140,34 @@ ...@@ -138,6 +140,34 @@
},'post',{headersToken:true}); },'post',{headersToken:true});
}); });
form.on('submit(excel-withdrawal)', function(data){
var checkStatus = table.checkStatus('withdrawal');
var checkRows = checkStatus.data;
var ids = checkRows.map(function(d){return d.id;});
var field = data.field; // 获得表单字段
field.ids = ids;
layer.load();
$.ajax({
method: "post",
url: app_root+'/excelwithdrawal',
data: field,
dataType: "json",
success: function (res){
layer.closeAll();
if(res.code===1) {
window.location.href = res.data.url;
}else{
layer.msg(res.msg,{icon:2,shade:[0.4,'#000'],time:1500},function (){
});
}
}
});
return false; // 阻止默认 form 跳转
});
/*快编监听*/ /*快编监听*/
table.on('edit(withdrawal)',function(obj){ table.on('edit(withdrawal)',function(obj){
admin.req(app_root+"editup",{id:obj.data.id,av:obj.value,af:obj.field},function(res){ admin.req(app_root+"editup",{id:obj.data.id,av:obj.value,af:obj.field},function(res){
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<link rel="stylesheet" href="/static/admin/element/index.css?v=1"> <link rel="stylesheet" href="/static/admin/element/index.css?v=1">
<!-- 引入组件库 --> <!-- 引入组件库 -->
<script src="/static/admin/element/index.js"></script> <script src="/static/admin/element/index.js"></script>
<div style="margin: 0px 10px"> <div style="margin: 0px 20px 0px 0px">
<form class="layui-form " style="margin-top: 20px;" id="fjfrom"> <form class="layui-form " style="margin-top: 20px;" id="fjfrom">
<div class="layui-form-item"> <div class="layui-form-item">
......
...@@ -192,10 +192,9 @@ ...@@ -192,10 +192,9 @@
} }
layer.open({ layer.open({
type: 2, type: 2,
area: ['900px', '850px'], area: ['900px', '90%'],
title: title, title: title,
btn: ['确定', '关闭'], btn: ['确定', '关闭'],
fixed: false, //不固定
content: app_root+'/edit?id='+id+'&type='+type, content: app_root+'/edit?id='+id+'&type='+type,
yes: function(index, layero){ yes: function(index, layero){
var data = window["layui-layer-iframe" + index].callbackdata(); var data = window["layui-layer-iframe" + index].callbackdata();
......
{extend name="base/header" /} {extend name="base/header" /}
{block name="body"} {block name="body"}
<div style="margin: 0px 10px"> <div style="margin: 0px 20px 0px 0px;">
<form class="layui-form " style="margin-top: 20px;" id="fjfrom"> <form class="layui-form " style="margin-top: 20px;" id="fjfrom">
<div class="layui-form-item"> <div class="layui-form-item">
......
...@@ -117,10 +117,9 @@ ...@@ -117,10 +117,9 @@
} }
layer.open({ layer.open({
type: 2, type: 2,
area: ['900px', '900px'], area: ['900px', '90%'],
title: title, title: title,
btn: ['确定', '关闭'], btn: ['确定', '关闭'],
fixed: false, //不固定
content: app_root+'edit?id='+id, content: app_root+'edit?id='+id,
yes: function(index, layero){ yes: function(index, layero){
var data = window["layui-layer-iframe" + index].callbackdata(); var data = window["layui-layer-iframe" + index].callbackdata();
......
...@@ -170,7 +170,7 @@ ...@@ -170,7 +170,7 @@
function certorderOpen(id='',type=''){ function certorderOpen(id='',type=''){
layer.open({ layer.open({
type: 2, type: 2,
area: ['900px', '900px'], area: ['900px', '90%'],
title: '资料详情', title: '资料详情',
btn: ['确定', '关闭'], btn: ['确定', '关闭'],
fixed: false, //不固定 fixed: false, //不固定
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<link rel="stylesheet" href="/static/admin/element/index.css?v=1"> <link rel="stylesheet" href="/static/admin/element/index.css?v=1">
<!-- 引入组件库 --> <!-- 引入组件库 -->
<script src="/static/admin/element/index.js"></script> <script src="/static/admin/element/index.js"></script>
<div style="margin: 0px 10px"> <div style="margin: 0px 20px 0px 0px;">
<form class="layui-form " style="margin-top: 20px;" id="fjfrom"> <form class="layui-form " style="margin-top: 20px;" id="fjfrom">
......
...@@ -150,10 +150,10 @@ ...@@ -150,10 +150,10 @@
} }
layer.open({ layer.open({
type: 2, type: 2,
area: ['900px', '850px'], area: ['600px', '600px'],
title: title, title: title,
btn: ['确定', '关闭'], btn: ['确定', '关闭'],
fixed: false, //不固定
content: app_root+'/edit?id='+id+'&type='+type, content: app_root+'/edit?id='+id+'&type='+type,
yes: function(index, layero){ yes: function(index, layero){
var data = window["layui-layer-iframe" + index].callbackdata(); var data = window["layui-layer-iframe" + index].callbackdata();
......
...@@ -85,14 +85,14 @@ ...@@ -85,14 +85,14 @@
<div class="layui-tab-item"> <div class="layui-tab-item">
<div class="layui-card-body" style=" padding: 0px 10px !important; "> <div class="layui-card-body" style=" padding: 0px 10px !important; ">
<div class="layui-card-box" style="width: 950px;"> <div class="layui-card-box" style="width: 850px;">
<table lay-filter="courseclasscategory" id="courseclasscategory"></table> <table lay-filter="courseclasscategory" id="courseclasscategory"></table>
</div> </div>
</div> </div>
</div> </div>
<div class="layui-tab-item"> <div class="layui-tab-item">
<div class="layui-card-body" style=" padding: 0px 10px !important; "> <div class="layui-card-body" style=" padding: 0px 10px !important; ">
<div class="layui-card-box" style="width: 950px;"> <div class="layui-card-box" style="width: 850px;">
<table lay-filter="coursework" id="coursework"></table> <table lay-filter="coursework" id="coursework"></table>
</div> </div>
</div> </div>
......
...@@ -28,6 +28,15 @@ ...@@ -28,6 +28,15 @@
<div class="layui-form-item"> <div class="layui-form-item">
<div class="layui-inline" style="width:250px;"><input type="text" name="kw" placeholder="课程关键词" autocomplete="off" class="layui-input" lay-affix="clear"/></div> <div class="layui-inline" style="width:250px;"><input type="text" name="kw" placeholder="课程关键词" autocomplete="off" class="layui-input" lay-affix="clear"/></div>
<div class="layui-inline" style="width:150px;">
<select name="status">
<option value="-1">审核状态</option>
<option value="0">待提交</option>
<option value="1">待审核</option>
<option value="2">审核失败</option>
<option value="3">审核成功</option>
</select>
</div>
<div class="layui-inline"> <div class="layui-inline">
<div class="layui-btn-group"> <div class="layui-btn-group">
<button class="layui-btn" lay-submit lay-filter="search-course"><i class="layui-icon layui-icon-search"></i> 搜索</button> <button class="layui-btn" lay-submit lay-filter="search-course"><i class="layui-icon layui-icon-search"></i> 搜索</button>
...@@ -121,7 +130,8 @@ ...@@ -121,7 +130,8 @@
{field:'price',width:120,align:'center',title:'价格'}, {field:'price',width:120,align:'center',title:'价格'},
{field:'createtime',width:120,align:'center',title:'发布时间'}, {field:'createtime',width:120,align:'center',title:'发布时间'},
{field:"status_text",width:80,align:'center',title:"状态",templet:'#status-demo'}, {field:"status_text",width:80,align:'center',title:"状态",templet:'#status-demo'},
{field:"is_sell_text",width:80,align:'center',title:"上架状态"}, // {field:"is_sell_text",width:80,align:'center',title:"上架状态"},
{field:"is_sell",width:80,align:'center',title:"是否上架",templet:function(d){return '<input type="checkbox" name="is_sell" lay-skin="switch" lay-text="是|否" lay-filter="is_sell-chang" value="'+d.is_sell+'" data-json="'+encodeURIComponent(JSON.stringify(d))+'"'+(d.is_sell==1 ? ' checked' : '')+'>';},unresize:true,},
{field:"teacher_name",width:100,align:'center',title:"讲师"}, {field:"teacher_name",width:100,align:'center',title:"讲师"},
{field:'tag_title',width:100,align:'center',title:'标签'}, {field:'tag_title',width:100,align:'center',title:'标签'},
...@@ -132,6 +142,16 @@ ...@@ -132,6 +142,16 @@
} }
}); });
// 状态 - 开关操作
form.on('switch(is_sell-chang)', function(obj){
var json = JSON.parse(decodeURIComponent($(this).data('json')));
var av = obj.elem.checked ? 1 : 0;
admin.req(app_root+"editup",{id:json.id,av:av,af:obj.elem.name},function(res){
layer.tips(res.msg,obj.othis,{time:1000});
if(res.code === 0) obj.elem.checked = parseInt(obj.value);
},'post',{headersToken:true});
});
/*快编监听*/ /*快编监听*/
table.on('edit(course)',function(obj){ table.on('edit(course)',function(obj){
admin.req(app_root+"editup",{id:obj.data.id,av:obj.value,af:obj.field},function(res){ admin.req(app_root+"editup",{id:obj.data.id,av:obj.value,af:obj.field},function(res){
...@@ -256,10 +276,10 @@ ...@@ -256,10 +276,10 @@
layer.open({ layer.open({
type: 2, type: 2,
area: ['1000px', '900px'], area: ['900px', '90%'],
title: "课程详情", title: "课程详情",
btn: ['确定', '关闭'], btn: ['确定', '关闭'],
fixed: false, //不固定 // fixed: false, //不固定
content: '/admin/course.course/detail?id='+id, content: '/admin/course.course/detail?id='+id,
yes: function(index, layero){ yes: function(index, layero){
// var data = window["layui-layer-iframe" + index].callbackdata(); // var data = window["layui-layer-iframe" + index].callbackdata();
......
...@@ -117,10 +117,10 @@ ...@@ -117,10 +117,10 @@
} }
layer.open({ layer.open({
type: 2, type: 2,
area: ['900px', '900px'], area: ['800px', '90%'],
title: title, title: title,
btn: ['确定', '关闭'], btn: ['确定', '关闭'],
fixed: false, //不固定 // fixed: false, //不固定
content: app_root+'edit?id='+id, content: app_root+'edit?id='+id,
yes: function(index, layero){ yes: function(index, layero){
var data = window["layui-layer-iframe" + index].callbackdata(); var data = window["layui-layer-iframe" + index].callbackdata();
......
...@@ -117,10 +117,10 @@ ...@@ -117,10 +117,10 @@
layer.open({ layer.open({
type: 2, type: 2,
area: ['1000px', '900px'], area: ['900px', '90%'],
title: "作业详情", title: "作业详情",
btn: ['确定', '关闭'], btn: ['确定', '关闭'],
fixed: false, //不固定 // fixed: false, //不固定
content: '/admin/course.course_work/detail?id='+id, content: '/admin/course.course_work/detail?id='+id,
yes: function(index, layero){ yes: function(index, layero){
layer.close(index); // 关闭弹窗 layer.close(index); // 关闭弹窗
......
<tpl> <tpl>
<form class="layui-form " action="admin/Index/main" id="fjfrom">
<div class="layui-form-item">
<label class="layui-form-label">输入框</label>
<div class="layui-input-block">
<input type="text" name="title" placeholder="请输入标题" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">密码框</label>
<div class="layui-input-inline">
<input type="password" name="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
</div>
<div class="layui-form-mid layui-word-aux">辅助文字</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">选择框</label>
<div class="layui-input-block">
<select name="city" lay-verify="required">
<option value=""></option>
<option value="0">北京</option>
<option value="1">上海</option>
<option value="2">广州</option>
<option value="3">深圳</option>
<option value="4">杭州</option>
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">复选框</label>
<div class="layui-input-block">
<input type="checkbox" name="like[write]" title="写作">
<input type="checkbox" name="like[read]" title="阅读" checked>
<input type="checkbox" name="like[dai]" title="发呆">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">开关</label>
<div class="layui-input-block">
<input type="checkbox" name="admin_log" lay-skin="switch" lay-text="ON|OFF" lay-filter="admin_log" value="1" title="ON|OFF">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">单选框</label>
<div class="layui-input-block">
<input type="radio" name="sex" value="男" title="男">
<input type="radio" name="sex" value="女" title="女" checked>
</div>
</div>
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">文本域</label>
<div class="layui-input-block">
<textarea name="desc" placeholder="请输入内容" class="layui-textarea"></textarea>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">上传图片</label>
<div class="layui-input-block" id="imgboxheadimg">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">上传图片</label>
<div class="layui-input-block" id="imgboxheadimg2">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">多图上传</label>
<div class="layui-input-block" id="imgboxheadimg3">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">文件上传</label>
<div class="layui-input-block" id="imgboxheadimg4">
</div>
</div>
<div class="layui-form-item">
<button class="layui-btn ajax-post" type="button" target-form="layui-form">确认</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</form>
<script src="{STATIC__PATH}admin/tc.js"></script>
<script>
layui.use(['buildItems','form', 'laydate', 'util'], function(){
/*解析顶部分组选项*/
var str = [{
"name": "{$data.name}",
"title": "上传图片",
"value": "/static/file/upload/image/20250422/68073d795d609.png",
"pathid":11,
"type": "{$data.type}"
}];
layui.buildItems.build({
bid: 'imgboxheadimg',
fjbid:'fjfrom',
map: layui.cache.maps + 'system.upload/',
gid: 1,
data:str
});
var str = [{
"name": "{$data2.name}",
"title": "上传图片",
"value": "{$data2.value}",
"type": "{$data2.type}"
}];
layui.buildItems.build({
bid: 'imgboxheadimg2',
fjbid:'fjfrom',
map: layui.cache.maps + 'system.upload/',
gid: 1,
data:str
});
//
// var str = [{
// "name": "{$data3.name}",
// "title": "多图图片",
// "value": "{$data3.value}",
// "type": "{$data3.type}"
// }];
// layui.buildItems.build({
// bid: 'imgboxheadimg3',
// url: '',
// map: layui.cache.maps + 'system.upload/',
// gid: 1,
// data:str
// });
//
//
var str = [{
"name": "{$data4.name}",
"title": "文件上传",
"value": "{$data4.value}",
"type": "{$data4.type}"
}];
layui.buildItems.build({
bid: 'imgboxheadimg4',
fjbid:'fjfrom',
url: '',
map: layui.cache.maps + 'system.upload/',
gid: 1,
data:str
});
layui.buildItems.init();
form=layui.form;
form.render();
// 指定开关事件
form.on('switch(admin_log)', function(data){
layer.msg('开关 checked:'+ (this.checked ? 'true' : 'false'), {
offset: '6px'
});
});
});
</script>
</tpl> </tpl>
\ No newline at end of file
This diff is collapsed.
<div class="layui-fluid">
<style>
#paymentcategoryTreeBar{padding:10px 15px;border:1px solid #e6e6e6;background-color:#f2f2f2}
#paymentcategoryTree{border:1px solid #e6e6e6;border-top:none;padding:10px 5px;overflow:auto;height:-webkit-calc(100vh - 290px);height:-moz-calc(100vh - 290px);height:calc(100vh - 290px)}
.layui-tree-entry .layui-tree-txt{padding:0 5px;border:1px transparent solid;text-decoration:none!important}
.layui-tree-entry.organ-tree-click .layui-tree-txt{background-color:#fff3e0;border:1px #ffe6b0 solid}
.files_itemwpayment{width:30px;height:30px;line-height:30px;cursor:pointer;padding:1px;background:#fff;display:-webkit-box;-moz-box-align:center;-webkit-box-align:center;-moz-box-pack:center;-webkit-box-pack:center;}
.files_itemwpayment img{max-width:28px;max-height:28px;border:0}
</style>
<div class="layui-card">
<div class="layui-card-header">
<form class="layui-form render">
<input type="hidden" name="groupid" id="payment-groupid" value=""/>
<div class="layui-form-item">
<div class="layui-inline" style="width:250px;"><input type="text" name="kw" placeholder="支付单号" autocomplete="off" class="layui-input" lay-affix="clear"/></div>
<div class="layui-inline" style="width:250px;"><input type="text" name="user" placeholder="用户名,用户手机" autocomplete="off" class="layui-input" lay-affix="clear"/></div>
<div class="layui-inline" style="width:150px;">
<select name="pay_status">
<option value="-1">支付状态</option>
<option value="0">未支付</option>
<option value="1">已支付</option>
<option value="2">支付失败</option>
</select>
</div>
<div class="layui-inline">
<div class="layui-btn-group">
<button class="layui-btn" lay-submit lay-filter="search-payment"><i class="layui-icon layui-icon-search"></i> 搜索</button>
<a class="layui-btn" lay-submit lay-filter="search-payment-all" onclick="$('#payment-groupid').val('')"><i class="layui-icon layui-icon-light"></i>全部</a>
</div>
</div>
</div>
</form>
</div>
<div class="layui-card-body">
<table lay-filter="payment" id="payment"></table>
</div>
</div>
</div>
<script type="text/html" id="paystatus-demo">
{{# if (d.pay_status === 1) { }}
<a class="layui-btn layui-btn-xs layui-btn-normal" >{{=d.pay_status_text}}</a>
{{# } else { }}
{{# if(d.pay_status === 2) { }}
<a class="layui-btn layui-btn-xs layui-btn-danger">{{=d.pay_status_text}}</a>
{{# } else { }}
<a class="layui-btn layui-btn-xs">{{=d.pay_status_text}}</a>
{{# } }}
{{# } }}
</script>
<!--JS部分-->
<script>
layui.use(['vinfo', 'buildItems','dropdown'], function(){
var map_root = layui.cache.maps;
var app_root = map_root + 'order.payment/';
var layer = layui.layer,table=layui.table,form=layui.form,admin=layui.admin;
/*渲染数据*/
table.render({
elem: '#payment',
page: true,
limit:{$limit},
height: 'full-341',
url: app_root+"index?&do=json",
// css: 'td .layui-table-cell{height:80px;line-height:80px;padding:0 5px;}',
cols: [[
{type:'checkbox',fixed:'left'},
{field:'id',width:50,unresize:true,align:'center',title:'ID',sort:!0},
{field:'order_no',align:'center',width:200,title:'支付单号'},
{field:'username',align:'center',width:150,title:'用户名',templet:'<div>{{= d.getuserdata.username}}</div>'},
{field:'mobile',align:'center',width:120,title:'用户手机',templet:'<div>{{= d.getuserdata.mobile}}</div>'},
{field:'order_name',align:'center',title:'支付详细'},
{field:'pay_amount',align:'center',width:100,title:'支付金额'},
{field:"pay_status_text",width:100,align:'center',title:"支付状态",templet:'#paystatus-demo'},
{field:'pay_method_text',align:'center',width:100,title:'支付类型'},
{field:'pay_time_text',align:'center',width:150,title:'支付时间'},
{field:'createtime',width:150,align:'center',title:'时间'},
]],
done: function(){ admin.vShow($('[lay-table-id="payment"]'));
}
});
// 状态 - 开关操作
form.on('switch(is_sell-chang)', function(obj){
var json = JSON.parse(decodeURIComponent($(this).data('json')));
var av = obj.elem.checked ? 1 : 0;
admin.req(app_root+"editup",{id:json.id,av:av,af:obj.elem.name},function(res){
layer.tips(res.msg,obj.othis,{time:1000});
if(res.code === 0) obj.elem.checked = parseInt(obj.value);
},'post',{headersToken:true});
});
/*快编监听*/
table.on('edit(payment)',function(obj){
admin.req(app_root+"editup",{id:obj.data.id,av:obj.value,af:obj.field},function(res){
layer.msg(res.msg,{shade:[0.4,'#000'],time:500});
},'post',{headersToken:true});
});/**/
/*工具条监听*/
table.on('tool(payment)', function(obj){
var data = obj.data;
var id = data.id;
if(obj.event === 'detail'){
paymentOpen(data.id);
}else if(obj.event === 'del'){
del(id);
}else if(obj.event === 'payment-event-image'){
var src = $(this).attr('src'), alt = $(this).attr('alt');
layer.photos({photos:{data:[{alt:alt,src:src}],start:'0'},anim:5,shade:[0.4,'#000']});
}else if(obj.event === 'more'){
}
});/**/
/*删除*/
function del(ids){
layer.confirm('确定要删除所选记录吗?', function(){
admin.req(app_root+"del",{id:ids},function(res){
layer.msg(res.msg,{shade:[0.4,'#000'],time:1500},function(){
if(res.code==1) table.reloadData('payment');
});
},'post',{headersToken:true});
});
}/**/
/*顶部删除按钮*/
$('#payment-del').on('click', function(){
var checkRows = table.checkStatus('payment').data;
if(checkRows.length === 0){return layer.msg('请选择需删除的记录');}
var ids = checkRows.map(function(d){return d.id;});
console.log(ids);
del(ids);
});/**/
});
</script>
\ No newline at end of file
...@@ -246,10 +246,9 @@ ...@@ -246,10 +246,9 @@
layer.open({ layer.open({
type: 2, type: 2,
area: ['900px', '850px'], area: ['900px', '90%'],
title: title, title: title,
btn: ['确定', '关闭'], btn: ['确定', '关闭'],
fixed: false, //不固定
content: app_root+'/detail?id='+id+'&type='+type, content: app_root+'/detail?id='+id+'&type='+type,
yes: function(index, layero){ yes: function(index, layero){
layer.close(index); layer.close(index);
......
{extend name="base/header" /} {extend name="base/header" /}
{block name="body"} {block name="body"}
<div style="margin: 0px 10px"> <div style="margin: 0px 20px 0px 0px">
<form class="layui-form " style="margin-top: 20px;" id="fjfrom"> <form class="layui-form " style="margin-top: 20px;" id="fjfrom">
<div class="layui-form-item"> <div class="layui-form-item">
......
...@@ -117,10 +117,9 @@ ...@@ -117,10 +117,9 @@
} }
layer.open({ layer.open({
type: 2, type: 2,
area: ['900px', '900px'], area: ['900px', '90%'],
title: title, title: title,
btn: ['确定', '关闭'], btn: ['确定', '关闭'],
fixed: false, //不固定
content: app_root+'edit?id='+id, content: app_root+'edit?id='+id,
yes: function(index, layero){ yes: function(index, layero){
var data = window["layui-layer-iframe" + index].callbackdata(); var data = window["layui-layer-iframe" + index].callbackdata();
......
...@@ -175,10 +175,9 @@ ...@@ -175,10 +175,9 @@
function businessOpen(id='',type=''){ function businessOpen(id='',type=''){
layer.open({ layer.open({
type: 2, type: 2,
area: ['900px', '900px'], area: ['900px', '90%'],
title: '资料详情', title: '资料详情',
btn: ['确定', '关闭'], btn: ['确定', '关闭'],
fixed: false, //不固定
content: '/admin/users.business/detail?id='+id+'&type='+type, content: '/admin/users.business/detail?id='+id+'&type='+type,
yes: function(index, layero){ yes: function(index, layero){
layer.close(index); layer.close(index);
......
...@@ -179,10 +179,9 @@ ...@@ -179,10 +179,9 @@
function schoolOpen(id='',type=''){ function schoolOpen(id='',type=''){
layer.open({ layer.open({
type: 2, type: 2,
area: ['900px', '900px'], area: ['900px', '90%'],
title: '资料详情', title: '资料详情',
btn: ['确定', '关闭'], btn: ['确定', '关闭'],
fixed: false, //不固定
content: '/admin/users.school/detail?id='+id+'&type='+type, content: '/admin/users.school/detail?id='+id+'&type='+type,
yes: function(index, layero){ yes: function(index, layero){
layer.close(index); layer.close(index);
......
...@@ -181,10 +181,9 @@ ...@@ -181,10 +181,9 @@
function userOpen(id='',type=''){ function userOpen(id='',type=''){
layer.open({ layer.open({
type: 2, type: 2,
area: ['900px', '900px'], area: ['900px', '90%'],
title: '会员详情', title: '会员详情',
btn: ['确定', '关闭'], btn: ['确定', '关闭'],
fixed: false, //不固定
content: '/admin/users.user/detail?id='+id+'&type='+type, content: '/admin/users.user/detail?id='+id+'&type='+type,
yes: function(index, layero){ yes: function(index, layero){
layer.close(index); layer.close(index);
...@@ -198,7 +197,6 @@ ...@@ -198,7 +197,6 @@
area: ['900px', '600px'], area: ['900px', '600px'],
title: '资金记录', title: '资金记录',
btn: ['确定', '关闭'], btn: ['确定', '关闭'],
fixed: false, //不固定
content: '/admin/users.user/usermoneylog?user_id='+id+'&type='+type, content: '/admin/users.user/usermoneylog?user_id='+id+'&type='+type,
yes: function(index, layero){ yes: function(index, layero){
layer.close(index); layer.close(index);
......
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
namespace app\event; namespace app\event;
use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use think\facade\Db;
/** /**
* phpoffice excel导入导出类 * phpoffice excel导入导出类
...@@ -99,9 +102,74 @@ class PhpOffice ...@@ -99,9 +102,74 @@ class PhpOffice
unset($spreadsheet, $sheet, $data); unset($spreadsheet, $sheet, $data);
} }
} }
}
/*
* 导出excel
*/
public static function exportexcel($dataGenerator, $filenamedata = '', $chunkSize = 1000)
{
// 创建临时文件
$tempFile = tempnam(sys_get_temp_dir(), 'phpxlsx');
// 初始设置
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$writer = new Xlsx($spreadsheet);
// 写入表头
$headers = array_shift($dataGenerator);
$sheet->fromArray($headers, null, 'A1');
$row = 2; // 数据从第2行开始
$chunkCount = 0;
foreach ($dataGenerator as $item) {
// 写入数据
$sheet->fromArray($item, null, 'A' . $row++);
// 每处理$chunkSize行保存一次
if ($row % $chunkSize === 0) {
$writer->save($tempFile);
$spreadsheet->disconnectWorksheets(); // 释放内存
// 重新加载
$spreadsheet = IOFactory::load($tempFile);
$sheet = $spreadsheet->getActiveSheet();
$writer = new Xlsx($spreadsheet);
// $chunkCount++;
// echo "已处理 " . ($chunkCount * $chunkSize) . " 行数据\n";
}
}
// 最终保存
$writer->save($tempFile);
// 设置路径
$fileurl = VT_STATIC . 'downexcel/' . date('Ymd') . '/';
$savePath = VT_PUBLIC . $fileurl;
// 创建目录
if (!is_dir($savePath)) {
mkdir($savePath, 0755, true);
}
// 设置文件名
$filename = uniqid() . '.xlsx';
$fullPath = $savePath . $filename;//完整目录地址
$fileurl = $fileurl . $filename; //存数据库的地址
// 移动到最终位置
if (!rename($tempFile, $fullPath)) {
throw new \Exception('无法移动文件到目标位置');
}
return Db::name('excel_down')->insertGetId(['fileurl' => $fileurl, 'filename' => $filenamedata . '.xlsx', 'admin_id' => session(VT_MANAGER)['userid'], 'createtime' => time()]);
// // 输出到浏览器
// header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
// header('Content-Disposition: attachment;filename="' . $filename . '"');
// header('Cache-Control: max-age=0');
// readfile($tempFile);
// unlink($tempFile);
}
}
class ChunkReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter class ChunkReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter
{ {
private $startRow = 0; private $startRow = 0;
...@@ -118,4 +186,6 @@ class ChunkReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter ...@@ -118,4 +186,6 @@ class ChunkReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter
// 只读取指定行范围内的单元格 // 只读取指定行范围内的单元格
return ($row >= $this->startRow && $row <= $this->endRow); return ($row >= $this->startRow && $row <= $this->endRow);
} }
} }
\ No newline at end of file
<?php <?php
/**
* ===========================================================================
* Veitool 快捷开发框架系统
* Author: Niaho 26843818@qq.com
* Copyright (c)2019-2025 www.veitool.com All rights reserved.
* Licensed: 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
* ---------------------------------------------------------------------------
*/
namespace app\model; namespace app\model;
use app\api\service\UtilService;
use \app\model\CertCategory;
use app\model\project\User;
use app\model\system\SystemUploadFile;
use think\facade\Db;
use think\Model; use think\Model;
/**
* 课程模型
*/
class Payment extends Model class Payment extends Model
{ {
protected $autoWriteTimestamp = true;
protected $createTime = 'createtime';
//用户信息
public function getuserdata()
{
return $this->belongsTo(User::class, 'user_id')
->field('username,mobile,id');
}
public function getPayMethodTextAttr($value, $data)
{
switch ($data['pay_method']) {
case 2:
$text = '微信';
break;
default:
$text = '支付宝';
break;
}
return $text;
}
public function getPayStatusTextAttr($value, $data)
{
switch ($data['pay_status']) {
case 1:
$text = '支付成功';
break;
case 2:
$text = '支付失败';
break;
default:
$text = '未支付';
break;
}
return $text;
}
public function getPayTimeTextAttr($value, $data)
{
return date('Y-m-d H:i:s', $data['pay_time']);
}
public function getOrderNameAttr($value, $data)
{
$title = '';
if ($data['order_type'] == 1) {
//课程
$title = ShCourse::where('id', $data['order_id'])->value('title');
$title = '购买课程:' . $title;
} elseif ($data['order_type'] == 2) {
//证书
$certinfo = CertOrder::where('id', $data['order_id'])->with('certdata')->find();
$title = '购买证书:' . $certinfo['certdata']['title'];
}
return $title;
}
} }
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment