diff --git a/application/admin/controller/school/classes/Teacher.php b/application/admin/controller/school/classes/Teacher.php
index aa8bfd7..b2adbef 100644
--- a/application/admin/controller/school/classes/Teacher.php
+++ b/application/admin/controller/school/classes/Teacher.php
@@ -105,8 +105,17 @@ class Teacher extends Backend
protected function updateCheck($id,$params=[],$row=null){
+ if($params && $row){
- // 课程存在售后订单则不允许操作
+ if(!$this->no_auth_fields_check($params,$row)){
+ return true;
+ }
+ }
+
+ // 课程存在未完成订单则不允许操作
+ $classesLib = \app\common\model\school\classes\ClassesLib::where("teacher_id",$id)->find();
+
+ if($classesLib)$this->error("存在正在教授的课程无法继续操作!请将课程讲师更换成其他人或者删除该课程后再操作!");
}
@@ -262,6 +271,16 @@ class Teacher extends Backend
}
$this->update_check($params,$row);
$result = $row->allowField(true)->save($params);
+
+ //执行课程修改
+ $classesLibs = \app\common\model\school\classes\ClassesLib::where( ['teacher_id'=>$row["id"]])->select();
+ foreach ($classesLibs as $classesLib){
+ $classesLib->user_id = $row["user_id"];
+ $classesLib->save();
+ //执行课程订单更新
+ \app\common\model\school\classes\ClassesLib::update_classes($classesLib["id"]);
+ }
+
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
@@ -306,7 +325,7 @@ class Teacher extends Backend
Db::startTrans();
try {
foreach ($list as $item) {
- $count += $item->delete();
+// $count += $item->delete();
}
Db::commit();
} catch (PDOException|Exception $e) {
diff --git a/application/admin/controller/school/classes/Visit.php b/application/admin/controller/school/classes/Visit.php
index d7eb44e..0895da0 100644
--- a/application/admin/controller/school/classes/Visit.php
+++ b/application/admin/controller/school/classes/Visit.php
@@ -44,7 +44,7 @@ class Visit extends Backend
{
//当前是否为关联查询
$this->relationSearch = true;
- $this->searchFields = ["id","classes_lib_id","classes_activity_id","lib.title","user.nickname","user.realname","user.mobile","activity.title"];
+ $this->searchFields = ["id","classes_lib_id","helparticle.title","classes_activity_id","lib.title","user.nickname","user.realname","user.mobile","activity.title"];
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax()) {
@@ -55,7 +55,7 @@ class Visit extends Backend
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
- ->with(['lib','activity',"user"])
+ ->with(['lib','activity',"user","helparticle"])
->where($where)
->order($sort, $order)
->paginate($limit);
@@ -65,6 +65,7 @@ class Visit extends Backend
$row->getRelation('lib')->visible(['title','headimage']);
$row->getRelation('activity')->visible(['title','headimage']);
$row->getRelation('user')->visible(['nickname', 'realname', 'mobile', 'avatar']);
+ $row->getRelation('helparticle')->visible(['title']);
}
$result = array("total" => $list->total(), "rows" => $list->items());
diff --git a/application/admin/controller/school/help/Article.php b/application/admin/controller/school/help/Article.php
index 0504a80..2b92f4c 100644
--- a/application/admin/controller/school/help/Article.php
+++ b/application/admin/controller/school/help/Article.php
@@ -77,7 +77,12 @@ class Article extends Backend
->whereRaw(...$expireWhere)
->order($sort, $order)
->paginate($limit);
- $result = ['total' => $list->total(), 'rows' => $list->items()];
+ $rows = $list->items();
+ foreach ($rows as &$row){
+
+ }
+
+ $result = ['total' => $list->total(), 'rows' => $rows];
return json($result);
}
diff --git a/application/admin/controller/school/help/Cate.php b/application/admin/controller/school/help/Cate.php
index b9e7583..f6f1432 100644
--- a/application/admin/controller/school/help/Cate.php
+++ b/application/admin/controller/school/help/Cate.php
@@ -40,6 +40,8 @@ class Cate extends Backend
// $v['name'] = str_replace(' ', ' ', $v['name']);
$ruledata[$v['id']] = $v['name'];
+
+
}
unset($v);
$this->view->assign('ruledata', $ruledata);
@@ -89,9 +91,12 @@ class Cate extends Backend
$this->token();
$params = $this->request->post("row/a", [], 'strip_tags');
if ($params) {
-// if (!$params['ismenu'] && !$params['pid']) {
-// $this->error(__('The non-menu rule must have parent'));
-// }
+ if ($params['pid']) {
+ $parent = \app\admin\model\school\help\Cate::get($params['pid']);
+ if ($parent && $parent['level_num'] > 1) {
+ $this->error(__('分类不能超过二级!'));
+ }
+ }
$result = $this->model->save($params);
if ($result === false) {
$this->error($this->model->getError());
@@ -129,6 +134,13 @@ class Cate extends Backend
$this->error(__('Can not change the parent to child'));
}
}
+ if ($params['pid']) {
+ $parent = \app\admin\model\school\help\Cate::get($params['pid']);
+ if ($parent && $parent['level_num'] > 1) {
+ $this->error(__('分类不能超过二级!'));
+ }
+ }
+
//这里需要针对name做唯一验证
$ruleValidate = \app\admin\model\school\help\Cate::where( 'name' , $params['name'] )-> where( 'id' , '<>' , $row['id'] )->find();
diff --git a/application/admin/lang/zh-cn/school/classes/visit.php b/application/admin/lang/zh-cn/school/classes/visit.php
index fec1bae..53dd02b 100644
--- a/application/admin/lang/zh-cn/school/classes/visit.php
+++ b/application/admin/lang/zh-cn/school/classes/visit.php
@@ -8,6 +8,9 @@ return [
'Set status to 1' => '设为课程',
'Status 2' => '活动',
'Set status to 2' => '设为活动',
+ 'Status 3' => '帮助文章',
+ 'Set status to 3' => '设为帮助文章',
+
'Createtime' => '访问时间',
'Lib.title' => '课程标题',
'Lib.headimage' => '课程头图',
diff --git a/application/admin/model/school/classes/Visit.php b/application/admin/model/school/classes/Visit.php
index fcb044d..de83489 100644
--- a/application/admin/model/school/classes/Visit.php
+++ b/application/admin/model/school/classes/Visit.php
@@ -2,6 +2,7 @@
namespace app\admin\model\school\classes;
+use app\common\model\school\help\Article;
use think\Model;
@@ -32,7 +33,7 @@ class Visit extends Model
public function getStatusList()
{
- return ['1' => __('Status 1'), '2' => __('Status 2')];
+ return ['1' => __('Status 1'), '2' => __('Status 2'), '3' => __('Status 3')];
}
@@ -61,4 +62,7 @@ class Visit extends Model
{
return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
+ public function helparticle(){
+ return $this->belongsTo(Article::class, 'help_article_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ }
}
diff --git a/application/admin/model/school/help/Cate.php b/application/admin/model/school/help/Cate.php
index 096bac3..6e3005d 100644
--- a/application/admin/model/school/help/Cate.php
+++ b/application/admin/model/school/help/Cate.php
@@ -25,7 +25,8 @@ class Cate extends Model
// 追加属性
protected $append = [
- 'status_text'
+ 'status_text',
+ 'level_num',
];
@@ -54,6 +55,19 @@ class Cate extends Model
}
+ public function getLevelNumAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['id']) ? $data['id'] : '');
+ if(!$value) return 0;
+ $level = 0;
+ while($value)
+ {
+ $value = $this->where('id', $value)->value('pid');
+ $level++;
+ }
+ return $level;
+ }
+
diff --git a/application/admin/view/school/help/cate/index.html b/application/admin/view/school/help/cate/index.html
index 0b478cb..39c07cc 100644
--- a/application/admin/view/school/help/cate/index.html
+++ b/application/admin/view/school/help/cate/index.html
@@ -25,6 +25,7 @@
{:__('Toggle all')}
+
( 注意:帮助文章只能在子分类下添加!如果分类只有一级,请先添加子分类再添加文章!)
{:__('Title')} | -{:__('Content')} | -
---|---|
{:__($key)} | -{$vo|htmlentities} | -