This commit is contained in:
焦钰锟 2025-04-02 18:19:09 +08:00
parent 2980a9dd34
commit 6e879728ff
5 changed files with 3907 additions and 164 deletions

View File

@ -1,6 +1,7 @@
<?php <?php
namespace app\common\listener\classes; namespace app\common\listener\classes;
use app\common\model\dyqc\ManystoreShop; use app\common\model\dyqc\ManystoreShop;
use app\common\model\school\classes\ClassesLib;
use app\common\model\school\classes\Teacher; use app\common\model\school\classes\Teacher;
use app\common\model\school\classes\Visit; use app\common\model\school\classes\Visit;
use app\common\model\school\Message; use app\common\model\school\Message;
@ -19,6 +20,7 @@ class ClassesHook
$teacher_user = \app\common\model\User::get($classes["user_id"]); $teacher_user = \app\common\model\User::get($classes["user_id"]);
$teacher = Teacher::get($classes["teacher_id"]); $teacher = Teacher::get($classes["teacher_id"]);
$shop = ManystoreShop::get($classes["shop_id"]); $shop = ManystoreShop::get($classes["shop_id"]);
$classes = ClassesLib::where("id",$classes["id"])->find();
//课程推送给老师 //课程推送给老师
$desc = "您的新课程{$classes['title']}已提交审核审核时间为1-3日内,请耐心等待审核结果"; $desc = "您的新课程{$classes['title']}已提交审核审核时间为1-3日内,请耐心等待审核结果";
@ -79,6 +81,7 @@ class ClassesHook
$teacher_user = \app\common\model\User::get($classes["user_id"]); $teacher_user = \app\common\model\User::get($classes["user_id"]);
$teacher = Teacher::get($classes["teacher_id"]); $teacher = Teacher::get($classes["teacher_id"]);
$shop = ManystoreShop::get($classes["shop_id"]); $shop = ManystoreShop::get($classes["shop_id"]);
$classes = ClassesLib::where("id",$classes["id"])->find();
//课程推送给老师 //课程推送给老师
$desc = "您的新课程{$classes['title']}已审核通过,可以在后台操作课程上架!"; $desc = "您的新课程{$classes['title']}已审核通过,可以在后台操作课程上架!";
@ -128,6 +131,7 @@ class ClassesHook
$teacher_user = \app\common\model\User::get($classes["user_id"]); $teacher_user = \app\common\model\User::get($classes["user_id"]);
$teacher = Teacher::get($classes["teacher_id"]); $teacher = Teacher::get($classes["teacher_id"]);
$shop = ManystoreShop::get($classes["shop_id"]); $shop = ManystoreShop::get($classes["shop_id"]);
$classes = ClassesLib::where("id",$classes["id"])->find();
//课程推送给老师 //课程推送给老师
$desc = "您的新课程{$classes['title']}审核未通过,未通过原因为:{$classes['reason']},整改后,可以在后台重新提交!"; $desc = "您的新课程{$classes['title']}审核未通过,未通过原因为:{$classes['reason']},整改后,可以在后台重新提交!";

View File

@ -344,171 +344,171 @@ class BaseModel extends Model
} }
/** 通用新增(后台api版本) // /** 通用新增(后台api版本)
* @param $params // * @param $params
* @param $trans // * @param $trans
* @return $this // * @return $this
* @throws \Exception // * @throws \Exception
*/ // */
public function add($params,$trans=false){ // public function add($params,$trans=false){
//
if (empty($params)) { // if (empty($params)) {
throw new \Exception(__('Parameter %s can not be empty', '')); // throw new \Exception(__('Parameter %s can not be empty', ''));
}
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
$params[$this->dataLimitField] = $this->auth->id;
}
//判断逻辑
if($trans){
self::beginTrans();
}
$res = true;
try{
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
$this->validateFailException()->validate($validate);
}
$result = $this->allowField(true)->save($params);
if($trans){
self::commitTrans();
}
}catch (\Exception $e){
if($trans){
self::rollbackTrans();
}
throw new \Exception($e->getMessage().$e->getFile().$e->getLine());
}
return $this;
}
/** 通用编辑(后台api版本)
* @param $params
* @param $trans
* @return $this
* @throws \Exception
*/
public function edit($id,$params,$trans=false){
$row = $this->get($id);
if (!$row) {
throw new \Exception(__('No Results were found'));
}
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
throw new \Exception(__('You have no permission'));
}
if (empty($params)) {
throw new \Exception(__('Parameter %s can not be empty', ''));
}
//判断逻辑
if($trans){
self::beginTrans();
}
$res = true;
try{
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
$row->validateFailException()->validate($validate);
}
$result = $row->allowField(true)->save($params);
if($trans){
self::commitTrans();
}
}catch (\Exception $e){
if($trans){
self::rollbackTrans();
}
throw new \Exception($e->getMessage().$e->getFile().$e->getLine());
}
return $row;
}
/** 通用详情(后台api版本)
* @param $params
* @param $trans
* @return $this
* @throws \Exception
*/
public function detail($id,$show_field=[],$except_field=[]){
$row = $this->get($id);
if (!$row) {
throw new \Exception(__('No Results were found'));
}
if($show_field){
$row->visible($show_field);
}
if($except_field){
$row->hidden($except_field);
}
return $row;
}
// public function index($page,$limit,$where=[])
// {
// $adminIds = $this->getDataLimitAdminIds();
// $aliasName = "" ;
// if (is_array($adminIds)) {
// $where[] = [$aliasName . $this->dataLimitField, 'in', $adminIds];
// } // }
// //
// if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
// $params[$this->dataLimitField] = $this->auth->id;
// }
////判断逻辑
// if($trans){
// self::beginTrans();
// }
// $res = true;
// try{
//
// //是否采用模型验证
// if ($this->modelValidate) {
// $name = str_replace("\\model\\", "\\validate\\", get_class($this));
// $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
// $this->validateFailException()->validate($validate);
// }
//
// $result = $this->allowField(true)->save($params);
//
// if($trans){
// self::commitTrans();
// }
// }catch (\Exception $e){
// if($trans){
// self::rollbackTrans();
// }
// throw new \Exception($e->getMessage().$e->getFile().$e->getLine());
// }
// return $this;
// } // }
//
//
/** 通用删除(后台api版本) // /** 通用编辑(后台api版本)
* @param $params // * @param $params
* @param $trans // * @param $trans
* @return $this // * @return $this
* @throws \Exception // * @throws \Exception
*/ // */
public function del($ids = null,$trans=false){ // public function edit($id,$params,$trans=false){
if (empty($ids)) { //
throw new \Exception(__('Parameter %s can not be empty', 'ids')); // $row = $this->get($id);
} // if (!$row) {
//判断逻辑 // throw new \Exception(__('No Results were found'));
// }
$pk = $this->getPk(); //
$adminIds = $this->getDataLimitAdminIds(); // $adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds)) { // if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
$this->where($this->dataLimitField, 'in', $adminIds); // throw new \Exception(__('You have no permission'));
} // }
$list = $this->where($pk, 'in', $ids)->select(); //
$count = 0; // if (empty($params)) {
if($trans){ // throw new \Exception(__('Parameter %s can not be empty', ''));
self::beginTrans(); // }
} ////判断逻辑
$res = true; // if($trans){
try{ // self::beginTrans();
// }
foreach ($list as $item) { // $res = true;
$count += $item->delete(); // try{
} //
// //是否采用模型验证
if($trans){ // if ($this->modelValidate) {
self::commitTrans(); // $name = str_replace("\\model\\", "\\validate\\", get_class($this));
} // $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
}catch (\Exception $e){ // $row->validateFailException()->validate($validate);
if($trans){ // }
self::rollbackTrans(); // $result = $row->allowField(true)->save($params);
} //
throw new \Exception($e->getMessage().$e->getFile().$e->getLine()); // if($trans){
} // self::commitTrans();
return $count; // }
} // }catch (\Exception $e){
// if($trans){
// self::rollbackTrans();
// }
// throw new \Exception($e->getMessage().$e->getFile().$e->getLine());
// }
// return $row;
// }
//
//
// /** 通用详情(后台api版本)
// * @param $params
// * @param $trans
// * @return $this
// * @throws \Exception
// */
// public function detail($id,$show_field=[],$except_field=[]){
// $row = $this->get($id);
// if (!$row) {
// throw new \Exception(__('No Results were found'));
// }
// if($show_field){
// $row->visible($show_field);
// }
// if($except_field){
// $row->hidden($except_field);
// }
// return $row;
// }
//
//// public function index($page,$limit,$where=[])
//// {
//// $adminIds = $this->getDataLimitAdminIds();
//// $aliasName = "" ;
//// if (is_array($adminIds)) {
//// $where[] = [$aliasName . $this->dataLimitField, 'in', $adminIds];
//// }
////
//// }
//
//
// /** 通用删除(后台api版本)
// * @param $params
// * @param $trans
// * @return $this
// * @throws \Exception
// */
// public function del($ids = null,$trans=false){
// if (empty($ids)) {
// throw new \Exception(__('Parameter %s can not be empty', 'ids'));
// }
////判断逻辑
//
// $pk = $this->getPk();
// $adminIds = $this->getDataLimitAdminIds();
// if (is_array($adminIds)) {
// $this->where($this->dataLimitField, 'in', $adminIds);
// }
// $list = $this->where($pk, 'in', $ids)->select();
// $count = 0;
// if($trans){
// self::beginTrans();
// }
// $res = true;
// try{
//
// foreach ($list as $item) {
// $count += $item->delete();
// }
//
// if($trans){
// self::commitTrans();
// }
// }catch (\Exception $e){
// if($trans){
// self::rollbackTrans();
// }
// throw new \Exception($e->getMessage().$e->getFile().$e->getLine());
// }
// return $count;
// }
//
} }

View File

@ -361,6 +361,7 @@ class ClassesLib extends ManystoreBase
$spec = $params["spec"]; $spec = $params["spec"];
unset($params["spec"]); unset($params["spec"]);
$result = $this->model->allowField(true)->save($params); $result = $this->model->allowField(true)->save($params);
\app\common\model\school\classes\ClassesLib::add_virtual_init($this->model["id"]); \app\common\model\school\classes\ClassesLib::add_virtual_init($this->model["id"]);
//添加课程规格 //添加课程规格
foreach ($spec as $k=>$v){ foreach ($spec as $k=>$v){
@ -377,9 +378,11 @@ class ClassesLib extends ManystoreBase
} }
$this->update_classes($this->model["id"]); $this->update_classes($this->model["id"]);
if($this->have_auth){ if($this->have_auth){
//调用通过事件 //调用通过事件
$data = ['classes' => $this->model]; $data = ['classes' => $this->model];
\think\Hook::listen('classes_auth_need_after', $data); \think\Hook::listen('classes_auth_need_after', $data);
} }
@ -439,7 +442,9 @@ class ClassesLib extends ManystoreBase
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
$this->model->validateFailException(true)->validate($validate); $this->model->validateFailException(true)->validate($validate);
} }
// var_dump(111);
$this->update_check($params,$row=null); $this->update_check($params,$row=null);
$result = $this->model->allowField(true)->save($params); $result = $this->model->allowField(true)->save($params);
\app\common\model\school\classes\ClassesLib::add_virtual_init($this->model["id"]); \app\common\model\school\classes\ClassesLib::add_virtual_init($this->model["id"]);
$this->update_classes($this->model["id"]); $this->update_classes($this->model["id"]);

View File

@ -10,7 +10,7 @@ class ClassesLib extends Validate
* 验证规则 * 验证规则
*/ */
protected $rule = [ protected $rule = [
'title' => 'require|length:1,50|alphaNum', 'title' => 'require|length:1,50',
// 'alphaNum' 是自定义的规则,用于过滤中文、数字和拼音字符 // 'alphaNum' 是自定义的规则,用于过滤中文、数字和拼音字符
]; ];
/** /**
@ -19,7 +19,7 @@ class ClassesLib extends Validate
protected $message = [ protected $message = [
'title.require' => '课程名不能为空', 'title.require' => '课程名不能为空',
'title.length' => '课程名长度必须在1到50之间', 'title.length' => '课程名长度必须在1到50之间',
'title.alphaNum' =>'课程名只允许中文、数字和拼音字符' // 'title.alphaNum' =>'课程名只允许中文、数字和拼音字符'
]; ];
/** /**
* 验证场景 * 验证场景

3734
duoyangqingchunyexiao.sql Normal file

File diff suppressed because it is too large Load Diff