Commit 51ebe32a authored by wangtao's avatar wangtao

管理后台 消息管理 上传

parent ebbcd743
......@@ -68,8 +68,8 @@ class Withdrawal extends AdminBase
public function del()
{
$post = input();
$ids = is_array($post['id']) ? implode(',', $post['id']) : $post['id'];
if ($this->withdrawal->destroy([$ids])) {
// $ids = is_array($post['id']) ? implode(',', $post['id']) : $post['id'];
if ($this->withdrawal->destroy($post['id'])) {
return $this->returnMsg("删除成功", 1);
} else {
return $this->returnMsg("删除失败");
......
......@@ -55,7 +55,7 @@ class Course extends AdminBase
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','is_hot_arr'])->order('createtime desc')->paginate($post['limit']);
return $this->returnMsg($list);
}
......@@ -142,4 +142,23 @@ class Course extends AdminBase
return $this->fetch('', '', false);
}
//推荐
public function tuijian()
{
$post = input();
if($this->request->isAjax()){
$data['is_hot'] = isset($post['is_hot']) ? $post['is_hot'] : 0;
$data['is_tj'] = isset($post['is_tj']) ? $post['is_tj'] : 0;
$this->course->where('id', $post['id'])->update($data);
event('Course', ['course_id' => $post['id'], 'tasktype' => 'course', 'action' => 'shcourseupdate']);
return $this->returnMsg("操作成功", 1);
}
$info = $this->course->where('id', $post['id'])->find();
$this->assign('info', $info);
return $this->fetch('', '', false);
}
}
\ No newline at end of file
......@@ -83,8 +83,8 @@ class Project extends AdminBase
public function del()
{
$post = input();
$ids = is_array($post['id']) ? implode(',', $post['id']) : $post['id'];
if ($this->project->destroy([$ids])) {
// $ids = is_array($post['id']) ? implode(',', $post['id']) : $post['id'];
if ($this->project->destroy($post['id'])) {
return $this->returnMsg("删除成功", 1);
} else {
return $this->returnMsg("删除失败");
......@@ -102,6 +102,24 @@ class Project extends AdminBase
}
//推荐
public function tuijian()
{
$post = input();
if($this->request->isAjax()){
$data['is_hot'] = isset($post['is_hot']) ? $post['is_hot'] : 0;
$data['is_tj'] = isset($post['is_tj']) ? $post['is_tj'] : 0;
$this->project->where('id', $post['id'])->update($data);
return $this->returnMsg("操作成功", 1);
}
$info = $this->project->where('id', $post['id'])->find();
$this->assign('info', $info);
return $this->fetch('', '', false);
}
//审核
public function shenheproject()
{
......@@ -119,6 +137,7 @@ class Project extends AdminBase
$updatedata['sh_status'] = $shstatus;
$updatedata['sh_status_desc'] = $errordesc;
$updatedata['sh_status_time'] = time(); //项目审核时间
$result = $this->project->where('id', $post['id'])->update($updatedata);
if ($result) {
......
<?php
/**
* ===========================================================================
* Veitool 快捷开发框架系统
* Author: Niaho 26843818@qq.com
* Copyright (c)2019-2025 www.veitool.com All rights reserved.
* Licensed: 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
* ---------------------------------------------------------------------------
*/
namespace app\admin\controller\users;
use app\admin\controller\AdminBase;
use app\admin\validate\MailValidate;
use think\App;
use think\facade\Db;
use app\model\project\Mail as MailModel;
/**
* 后台主控制器
*/
class Mail extends AdminBase
{
protected $mail;
public function __construct(App $app)
{
parent::__construct($app);
$this->mail = new MailModel();
}
// 列表
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[] = ['content', 'like', '%' . $post['kw'] . '%'];
}
if (isset($post['user']) && !empty($post['user'])) {
$hasmap[] = ['username|mobile', 'like', '%' . $post['user'] . '%'];
}
$list = $this->mail->where($map)->hasWhere('getuserdata', $hasmap)->with(['getuserdata'])->append(['type_text'])->order('createtime desc')->paginate($post['limit']);
return $this->returnMsg($list);
}
$this->assign('limit', $limit);
return $this->fetch('', '', false);
}
//新增
public function add()
{
$post = input();
if ($this->request->isPost()) {
$check = (new MailValidate())->goCheck();
if ($check !== true) {
return $check;
}
try {
$map[] = ['is_del', '=', '0'];
if ($post['user']) {
$map[] = ['id|mobile', 'in', $post['user']];
}
$stime = time();
$maildata = Db::name('user')->field('id')->where($map)->select()->each(function ($item, $key) use ($post, $stime) {
return ['content' => $post['content'], 'type' => 1, 'user_id' => $item['id'], 'createtime' => $stime];
});
$this->mail->saveAll($maildata);
} catch (\Exception $e) {
return $this->returnMsg($e->getMessage(), 0);
}
return $this->returnMsg('发送成功', 1);
}
return $this->fetch('', '', false);
}
//快速编辑
public function editup()
{
$post = input();
$result = $this->mail->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->mail->destroy($post['id'])) {
return $this->returnMsg("删除成功", 1);
} else {
return $this->returnMsg("删除失败");
}
}
}
\ No newline at end of file
<?php
namespace app\admin\validate;
use think\Validate;
use app\model;
use app\api\validate\BaseValidate;
class MailValidate extends BaseValidate
{
protected $rule = [
'content' => 'require',
];
protected $message = [
'content.require' => '内容不能为空',
];
}
\ No newline at end of file
......@@ -78,6 +78,22 @@
{{# } }}
{{# } }}
</script>
<script type="text/html" id="ishot-demo">
{{# if (d.is_hot === 1 || d.is_tj === 1) { }}
{{# if (d.is_hot === 1) { }}
<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="sethot">热门</a>
{{# } }}
{{# if (d.is_tj === 1) { }}
<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="sethot">推荐</a>
{{# } }}
{{# } else { }}
<a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="sethot">未设置</a>
{{# } }}
</script>
<div></div>
<!--JS部分-->
<script>
......@@ -127,11 +143,12 @@
{field:'title',width:300,align:'center',title:'课程名称'},
{field:'username',width:150,align:'center',title:'发布者',templet:'<div>{{d.user_info.username}}</div>'},
{field:'cate_name',width:120,align:'center',title:'类别'},
{field:'price',width:120,align:'center',title:'价格'},
{field:'createtime',width:120,align:'center',title:'发布时间'},
{field:'price',width:100,align:'center',title:'价格'},
{field:'is_hot',width:100,align:'center',title:'推荐',templet:'#ishot-demo'},
{field:"status_text",width:80,align:'center',title:"状态",templet:'#status-demo'},
// {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:'createtime',width:120,align:'center',title:'发布时间'},
{field:"teacher_name",width:100,align:'center',title:"讲师"},
{field:'tag_title',width:100,align:'center',title:'标签'},
......@@ -169,6 +186,41 @@
del(id);
}else if(obj.event === 'statuserror'){
layer.alert(data.sh_error_desc,{title:'失败原因'});
}else if(obj.event === 'sethot'){
// 在此处输入 layer 的任意代码
layer.open({
type: 2, // page 层类型
area: ['500px', '300px'],
title: "课程推荐",
shade: 0.6, // 遮罩透明度
shadeClose: true, // 点击遮罩区域,关闭弹层
btn: ['确定', '关闭'],
content: '/admin/course.course/tuijian?id='+id,
yes: function(index, layero){
var data = window["layui-layer-iframe" + index].callbackdata();
$.ajax({
method: "post",
url: layui.cache.maps+'/course.course/tuijian',
data: data,
dataType: "json",
success: function (res){
if(res.code===1) {
layer.msg(res.msg,{icon:1,shade:[0.4,'#000'],time:1500},function (){
layer.close(index);
table.reloadData('course');
});
}else{
layer.msg(res.msg,{icon:2,shade:[0.4,'#000'],time:1500},function (){
});
}
// layer.closeAll();
}
});
}
});
}else if(obj.event === 'shenhei'){
layer.confirm('选择审核状态?', {
......
{extend name="base/header" /}
{block name="body"}
<style>
.layui-table .widthtd{ width: 120px;}
</style>
<div style="margin: 0px 20px 0px 0px; background: #fff;">
<form class="layui-form layui-form-pane" style="margin-top: 20px;" id="fjfrom">
<div class="layui-form-item" pane="">
<label class="layui-form-label">推荐</label>
<div class="layui-input-block">
<input type="checkbox" name="is_hot" value="1" title="热门" {eq name="$info.is_hot|default=''" value="1"} checked {/eq} >
<input type="checkbox" name="is_tj" value="1" title="推荐" {eq name="$info.is_tj|default=''" value="1"} checked {/eq} >
</div>
</div>
<input type="hidden" name="id" value="{$info.id|default=0}">
</form>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
var course_id = "{$info.id}";
layui.use(['buildItems', 'form'], function () {
var form=layui.form;
});
var callbackdata = function () {
var data = $(".layui-form").serialize();
return data;
};
</script>
{/block}
\ No newline at end of file
......@@ -103,6 +103,20 @@
{{# } }}
{{# } }}
</script>
<script type="text/html" id="projectishot-demo">
{{# if (d.is_hot === 1 || d.is_tj === 1) { }}
{{# if (d.is_hot === 1) { }}
<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="sethot">热门</a>
{{# } }}
{{# if (d.is_tj === 1) { }}
<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="sethot">推荐</a>
{{# } }}
{{# } else { }}
<a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="sethot">未设置</a>
{{# } }}
</script>
<!--JS部分-->
<script>
......@@ -156,6 +170,7 @@
{field:'zhouqi',width:120,align:'center',title:'周期/天'},
{field:'sh_status',width:100,align:'center',title:'审核状态',templet:'#proshstatus-demo'},
{field:'status',width:100,align:'center',title:'项目状态',templet:'#prostatus-demo'},
{field:'is_hot',width:100,align:'center',title:'推荐',templet:'#projectishot-demo'},
{field:'createtime',width:120,align:'center',title:'发布时间'},
{fixed:'right',width:150,align:'center', templet: '#projectDemo',title:'操作'}
]],
......@@ -194,6 +209,41 @@
layer.photos({photos:{data:[{alt:alt,src:src}],start:'0'},anim:5,shade:[0.4,'#000']});
}else if(obj.event === 'more'){
}else if(obj.event === 'sethot'){
// 在此处输入 layer 的任意代码
layer.open({
type: 2, // page 层类型
area: ['500px', '300px'],
title: "课程推荐",
shade: 0.6, // 遮罩透明度
shadeClose: true, // 点击遮罩区域,关闭弹层
btn: ['确定', '关闭'],
content: '/admin/project.project/tuijian?id='+id,
yes: function(index, layero){
var data = window["layui-layer-iframe" + index].callbackdata();
$.ajax({
method: "post",
url: layui.cache.maps+'/project.project/tuijian',
data: data,
dataType: "json",
success: function (res){
if(res.code===1) {
layer.msg(res.msg,{icon:1,shade:[0.4,'#000'],time:1500},function (){
layer.close(index);
table.reloadData('project');
});
}else{
layer.msg(res.msg,{icon:2,shade:[0.4,'#000'],time:1500},function (){
});
}
// layer.closeAll();
}
});
}
});
}else if(obj.event === 'shenhei'){
layer.confirm('选择审核状态?', {
......
{extend name="base/header" /}
{block name="body"}
<style>
.layui-table .widthtd{ width: 120px;}
</style>
<div style="margin: 0px 20px 0px 0px; background: #fff;">
<form class="layui-form layui-form-pane" style="margin-top: 20px;" id="fjfrom">
<div class="layui-form-item" pane="">
<label class="layui-form-label">推荐</label>
<div class="layui-input-block">
<input type="checkbox" name="is_hot" value="1" title="热门" {eq name="$info.is_hot|default=''" value="1"} checked {/eq} >
<input type="checkbox" name="is_tj" value="1" title="推荐" {eq name="$info.is_tj|default=''" value="1"} checked {/eq} >
</div>
</div>
<input type="hidden" name="id" value="{$info.id|default=0}">
</form>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
var course_id = "{$info.id}";
layui.use(['buildItems', 'form'], function () {
var form=layui.form;
});
var callbackdata = function () {
var data = $(".layui-form").serialize();
return data;
};
</script>
{/block}
\ No newline at end of file
{extend name="base/header" /}
{block name="body"}
<style>
.layui-tab-content{ margin-right:15px;}
.el-cascader{ width:100%;}
</style>
<div style="margin: 0px 20px 0px 0px">
<form class="layui-form " style="margin-top: 20px;" id="fjfrom">
<div class="layui-form-item">
<label class="layui-form-label">填写用户</label>
<div class="layui-input-block">
<textarea placeholder="请输入用户id或者手机号,多个用户用英文逗号隔开,为空代表给所有用户发送消息" name="user" class="layui-textarea"></textarea>
<div class="layui-form-mid layui-text-em">请输入用户id或者手机号,多个用户用英文逗号隔开,为空代表给所有用户发送消息</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">消息内容</label>
<div class="layui-input-block">
<textarea placeholder="请输入消息内容" name="content" class="layui-textarea"></textarea>
</div>
</div>
</form>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
layui.use(['tagsInput','buildItems', 'form', 'laydate', 'util'], function () {
var form = layui.form;
var inputTags = layui.tagsInput;
form.render();
$("#inputTags").tagsInput();
});
var callbackdata = function () {
var data = $(".layui-form").serialize();
return data;
};
</script>
{/block}
\ No newline at end of file
<div class="layui-fluid">
<style>
#mailcategoryTreeBar{padding:10px 15px;border:1px solid #e6e6e6;background-color:#f2f2f2}
#mailcategoryTree{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_itemwmail{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_itemwmail 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="mail-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">
<div class="layui-btn-group">
<button class="layui-btn" lay-submit lay-filter="search-mail"><i class="layui-icon layui-icon-search"></i> 搜索</button>
<a class="layui-btn" lay-submit lay-filter="search-mail-all" onclick="$('#mail-groupid').val('')"><i class="layui-icon layui-icon-light"></i>全部</a>
<a class="layui-btn" id="mail-add" ><i class="layui-icon layui-icon-add-circle"></i> 添加</a>
<a class="layui-btn" id="mail-del"><i class="layui-icon layui-icon-delete"></i> 删除</a>
</div>
</div>
</div>
</form>
</div>
<div class="layui-card-body">
<table lay-filter="mail" id="mail"></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 + 'users.mail/';
var layer = layui.layer,table=layui.table,form=layui.form,admin=layui.admin;
/*渲染数据*/
table.render({
elem: '#mail',
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:'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:'content',align:'center',title:'消息内容'},
{field:'type_text',align:'center',width:100,title:'类型'},
{field:'createtime',width:150,align:'center',title:'时间'},
{fixed:'right',width:130,align:'center',toolbar:'<div><a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a></div>',title:'操作'}
]],
done: function(){ admin.vShow($('[lay-table-id="mail"]'));
}
});
/*快编监听*/
table.on('edit(mail)',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(mail)', function(obj){
var data = obj.data;
var id = data.id;
if(obj.event === 'detail'){
mailOpen(data.id);
}else if(obj.event === 'del'){
del(id);
}else if(obj.event === 'mail-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('mail');
});
},'post',{headersToken:true});
});
}/**/
/*顶部删除按钮*/
$('#mail-del').on('click', function(){
var checkRows = table.checkStatus('mail').data;
if(checkRows.length === 0){return layer.msg('请选择需删除的记录');}
var ids = checkRows.map(function(d){return d.id;});
console.log(ids);
del(ids);
});/**/
$('#mail-add').on('click',function(){mailOpen();});/**/
/*弹出窗*/
function mailOpen(id='',type=''){
layer.open({
type: 2,
area: ['900px', '90%'],
title: '发送消息',
btn: ['确定', '关闭'],
content: app_root+'/add?id='+id+'&type='+type,
yes: function(index, layero){
var data = window["layui-layer-iframe" + index].callbackdata();
$.ajax({
method: "post",
url: app_root+'/add',
data: data,
dataType: "json",
success: function (res){
if(res.code===1) {
layer.msg(res.msg,{icon:1,shade:[0.4,'#000'],time:1500},function (){
layer.close(index);
table.reloadData('mail');
});
}else{
layer.msg(res.msg,{icon:2,shade:[0.4,'#000'],time:1500},function (){
});
}
// layer.closeAll();
}
});
},
});
}/**/
});
</script>
\ No newline at end of file
......@@ -11,6 +11,7 @@ use app\Request;
use think\facade\Db;
use app\model\project\User;
use app\event\PhpOffice;
use OSS\OssClient;
class Student extends BaseController
{
......@@ -147,6 +148,7 @@ class Student extends BaseController
return $vo;
}
$parm = $request->param();
$checkfiled = ['realname', 'sex', 'age', 'idcard', 'mobile', 'xq', 'nj', 'bj', 'xh'];
try {
$fileinfo = get_upload_file($parm['file_id'], 'info');
......@@ -200,6 +202,7 @@ class Student extends BaseController
//导入学生
public function StudentExcel(Request $request)
{
set_time_limit(0); // 无时间限制
ini_set('memory_limit', '512M');
$vo = (new StudentValidate())->goCheck(['file_id']);
......@@ -207,16 +210,20 @@ class Student extends BaseController
return $vo;
}
$parm = $request->param();
$checkfiled = ['realname', 'sex', 'age', 'idcard', 'mobile', 'xq', 'nj', 'bj', 'xh'];
try {
$fileinfo = get_upload_file($parm['file_id'], 'info');
$filePath = $fileinfo['fileurl'];
$filepath = '.' . strstr($filePath, '/static/');
if (!file_exists($filepath)) {
throw new \Exception("文件不存在: " . $filepath);
if ($fileinfo['storage'] == 'aliyun') {
$filepath = PhpOffice::ossdowntem($filePath);
} else {
$filepath = '.' . strstr($filePath, '/static/');
if (!file_exists($filepath)) {
throw new \Exception("文件不存在: " . $filepath);
}
}
$school_user_id = \request()->userId;
PhpOffice::chunkedImportXlsx($filepath, function ($list, $startRow, $endRow) use ($checkfiled, $school_user_id) {
// echo "处理行 {$startRow} 到 {$endRow}" . PHP_EOL;
......@@ -251,7 +258,10 @@ class Student extends BaseController
}
StudentModel::saveAll($createdata);
});
if ($fileinfo['storage'] == 'aliyun') {
// 处理完成后删除临时文件
unlink($filePath);
}
return $this->returnMsg('导入成功', 1);
} catch (\Exception $e) {
......
......@@ -49,6 +49,8 @@ function get_upload_file($fileid = '', $datatype = '')
}
//从阿里云
/**
* md5判断
* @param string $w 字符
......
......@@ -10,6 +10,7 @@
namespace app\event;
use OSS\OssClient;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
......@@ -168,6 +169,31 @@ class PhpOffice
// unlink($tempFile);
}
/*
* 从阿里云oss文件保存到本地临时文件
*/
public static function ossdowntem($filePath)
{
//保存阿里云上面的地址
$filePath = str_replace(vconfig('aliyun_domain').'/', "", $filePath);
$domain = str_replace('https://' . vconfig('aliyun_bucket') . '.', "", vconfig('aliyun_domain'));
// $filePath = strstr($filePath, 'public/');
// 1. 初始化OSS客户端
$ossClient = new OssClient(vconfig('access_key_id'), vconfig('access_key_secret'), $domain);
// 2. 创建临时文件
$tempFile = tempnam(sys_get_temp_dir(), 'oss_temp_' . uniqid());
// 或者指定临时目录:
// $tempFile = '/tmp/oss_temp_' . uniqid() . '.xlsx';
// 3. 从OSS下载文件到临时文件
$options = array(
OssClient::OSS_FILE_DOWNLOAD => $tempFile
);
$ossClient->getObject(vconfig('aliyun_bucket'), $filePath, $options);
return $tempFile;
}
}
class ChunkReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter
......
......@@ -99,7 +99,7 @@ class Jobtask
} elseif ($data['action'] == 'shcourseupdate') {
//更新状态数据 删除,上下架
$courseinfo = ShCourse::field('id,is_sell,is_del')->where('id', $data['course_id'])->find();
$courseinfo = ShCourse::field('id,is_sell,is_del,is_hot,is_tj')->where('id', $data['course_id'])->find();
CourseModel::update($courseinfo);
//处理课时
......
......@@ -94,4 +94,6 @@ class ShCourse extends Model
return $selltext;
}
}
\ No newline at end of file
......@@ -3,8 +3,25 @@
namespace app\model\project;
use think\Model;
use think\model\concern\SoftDelete;
class Mail extends Model
{
use SoftDelete;
protected $deleteTime = 'deletetime';
protected $autoWriteTimestamp = true;
protected $createTime = 'createtime';
//用户信息
public function getuserdata()
{
return $this->belongsTo(User::class, 'user_id')
->field('username,mobile,id');
}
public function getTypeTextAttr($value, $data)
{
return $data['type'] == 1 ? '系统通知' : '后台发送';
}
}
\ No newline at end of file
......@@ -7,6 +7,7 @@
* Licensed: 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
* ---------------------------------------------------------------------------
*/
namespace veitool\storage\engine;
use OSS\OssClient;
......@@ -19,7 +20,7 @@ use OSS\Core\OssException;
*/
class Aliyun extends Server
{
private $config;
// private $config;
/**
* 构造方法
......@@ -28,8 +29,8 @@ class Aliyun extends Server
*/
public function __construct($config)
{
parent::__construct();
$this->config = $config;
parent::__construct($config);
// $this->config = $config;
}
/**
......@@ -45,6 +46,7 @@ class Aliyun extends Server
$this->config['domain'],
true
);
$result = $ossClient->uploadFile(
$this->config['bucket'],
$this->fileName,
......
......@@ -17,7 +17,7 @@ use think\facade\Filesystem;
*/
class Local extends Server
{
private $config;
// private $config;
/**
* 构造方法
......@@ -25,8 +25,8 @@ class Local extends Server
*/
public function __construct($config)
{
parent::__construct();
$this->config = $config;
parent::__construct($config);
// $this->config = $config;
}
/**
......
......@@ -7,6 +7,7 @@
* Licensed: 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
* ---------------------------------------------------------------------------
*/
namespace veitool\storage\engine;
use think\Exception;
......@@ -23,12 +24,16 @@ abstract class Server
protected $error;
protected $fileName;
protected $fileInfo;
protected $config;
/**
* 构造函数
* Server constructor.
*/
protected function __construct(){}
protected function __construct($config)
{
$this->config = $config;
}
/**
* 设置上传的文件信息
......@@ -45,7 +50,7 @@ abstract class Server
// 生成保存文件名
$this->fileName = $this->buildSaveName();
// 文件信息
$this->fileInfo = ['name'=>$this->file->getFilename(),'oname'=> $this->file->getOriginalName(),'size'=>$this->file->getSize(),'type' => $this->file->getMime(),'ext' => $this->file->getOriginalExtension()];
$this->fileInfo = ['name' => $this->file->getFilename(), 'oname' => $this->file->getOriginalName(), 'size' => $this->file->getSize(), 'type' => $this->file->getMime(), 'ext' => $this->file->getOriginalExtension()];
}
/**
......@@ -95,7 +100,7 @@ abstract class Server
// 扩展名
$ext = $this->file->getOriginalExtension();
// 自动生成文件名
return date('YmdHis') . substr(md5($realPath), 0, 5) . str_pad(rand(0, 9999), 4, '0', STR_PAD_LEFT) . '.' . $ext;
return $this->config['upfile'] . date('YmdHis') . substr(md5($realPath), 0, 5) . str_pad(rand(0, 9999), 4, '0', STR_PAD_LEFT) . '.' . $ext;
}
}
\ No newline at end of file
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