From a4b369c59dead423bd3486fd2afa197b6f0bc64c Mon Sep 17 00:00:00 2001 From: 15090180611 <215509543@qq.com> Date: Thu, 14 Nov 2024 18:40:04 +0800 Subject: [PATCH] =?UTF-8?q?1=EF=BC=8C=E8=AF=BE=E6=97=B6=E7=AE=A1=E7=90=86?= =?UTF-8?q?=EF=BC=88=E6=9C=BA=E6=9E=84=E7=AB=AF=E5=92=8C=E6=80=BB=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E7=AB=AF=EF=BC=89=202=EF=BC=8C=E6=95=99=E5=B8=88?= =?UTF-8?q?=E7=AE=A1=E7=90=86=EF=BC=88=E6=9C=BA=E6=9E=84=E7=AB=AF=E5=92=8C?= =?UTF-8?q?=E6=80=BB=E5=90=8E=E5=8F=B0=E7=AB=AF=EF=BC=89=203=EF=BC=8C?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E7=94=9F=E6=88=90=E8=99=9A=E6=8B=9F=E5=8F=82?= =?UTF-8?q?=E4=B8=8E=E8=80=85=EF=BC=88=E6=9C=BA=E6=9E=84=E7=AB=AF=E5=92=8C?= =?UTF-8?q?=E6=80=BB=E5=90=8E=E5=8F=B0=E7=AB=AF=EF=BC=89=204=EF=BC=8C?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=89=A9=E5=B1=95=E5=85=8D=E8=B4=B9=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E5=B9=B6=E5=AE=9E=E7=8E=B0=E6=9C=BA=E6=9E=84=E7=AB=AF?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=8F=90=E4=BA=A4=E5=AE=A1=E6=A0=B8=205?= =?UTF-8?q?=EF=BC=8C=E8=AE=BE=E8=AE=A1=E6=8E=88=E6=9D=83=E6=9C=BA=E6=9E=84?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E9=80=BB=E8=BE=91=E8=A1=A8=E5=92=8C=E7=AB=99?= =?UTF-8?q?=E5=86=85=E4=BF=A1=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/famysql/Field.php | 2 +- .../controller/school/classes/ClassesLib.php | 58 ++++- .../controller/school/classes/ClassesSpec.php | 7 +- .../controller/school/classes/Teacher.php | 201 ++++++++++++++++- .../controller/school/classes/VirtualUser.php | 57 ++++- application/admin/controller/user/User.php | 147 ++++++++++++- .../lang/zh-cn/school/classes/classes_lib.php | 2 +- .../view/school/classes/classes_lib/add.html | 1 + .../view/school/classes/classes_lib/edit.html | 1 + .../view/school/classes/classes_spec/add.html | 26 +-- .../school/classes/classes_spec/edit.html | 24 +- .../view/school/classes/teacher/add.html | 16 +- .../view/school/classes/teacher/edit.html | 14 +- .../view/school/classes/virtual_user/add.html | 22 +- application/common/controller/Backend.php | 52 +++++ .../common/controller/ManystoreBase.php | 80 ++++++- application/common/library/Virtual.php | 2 + .../common/model/dyqc/ManystoreShop.php | 128 ++++++++++- .../model/school/classes/order/Order.php | 9 +- .../controller/school/classes/ClassesLib.php | 88 +++++++- .../controller/school/classes/ClassesSpec.php | 6 +- .../controller/school/classes/Teacher.php | 208 +++++++++++++++++- .../controller/school/classes/VirtualUser.php | 64 +++++- .../lang/zh-cn/school/classes/teacher.php | 2 +- .../view/school/classes/classes_lib/add.html | 58 ++--- .../view/school/classes/classes_lib/edit.html | 27 ++- .../school/classes/classes_lib/index.html | 5 + .../view/school/classes/classes_spec/add.html | 26 +-- .../school/classes/classes_spec/edit.html | 26 +-- .../view/school/classes/teacher/add.html | 16 +- .../view/school/classes/teacher/edit.html | 15 +- .../view/school/classes/virtual_user/add.html | 64 +++--- .../school/classes/virtual_user/edit.html | 3 +- .../js/backend/school/classes/classes_lib.js | 86 +++++++- .../js/backend/school/classes/classes_spec.js | 4 +- .../js/backend/school/classes/teacher.js | 4 +- .../js/backend/school/classes/virtual_user.js | 6 +- .../manystore/school/classes/classes_lib.js | 86 +++++++- .../manystore/school/classes/classes_spec.js | 11 +- .../js/manystore/school/classes/teacher.js | 35 +-- .../manystore/school/classes/virtual_user.js | 10 +- 41 files changed, 1473 insertions(+), 226 deletions(-) diff --git a/application/admin/controller/famysql/Field.php b/application/admin/controller/famysql/Field.php index 3f7781c..00cc4ea 100644 --- a/application/admin/controller/famysql/Field.php +++ b/application/admin/controller/famysql/Field.php @@ -576,7 +576,7 @@ class Field extends Backend return $typeList; } - protected function getCommonFields($fields = '') + public function getCommonFields($fields = '') { $fieldList = include ADDON_PATH . 'famysql' . DS . 'data' . DS . 'fields.php'; diff --git a/application/admin/controller/school/classes/ClassesLib.php b/application/admin/controller/school/classes/ClassesLib.php index 1b74ba2..a2e269c 100644 --- a/application/admin/controller/school/classes/ClassesLib.php +++ b/application/admin/controller/school/classes/ClassesLib.php @@ -180,7 +180,8 @@ class ClassesLib extends Backend protected function update_check(&$params,$row=null) { - $shop_id = $row["shop_id"]; + + $shop_id = $params["shop_id"]; $manystore = Manystore::where("shop_id",$shop_id)->find(); if(!$manystore){ $this->error("店铺不存在"); @@ -189,7 +190,7 @@ class ClassesLib extends Backend //验证老师id - $teacher_id = $row['teacher_id']; + $teacher_id = $params['teacher_id']; $teacher = \app\admin\model\school\classes\Teacher::where("id",$teacher_id)->find(); if(!$teacher){ $this->error("老师不存在"); @@ -215,11 +216,48 @@ class ClassesLib extends Backend || empty($params["longitude"]) || empty($params["latitude"])) $this->error("独立地点需传定位信息"); + }else{ + //地址取机构的 + $shop = ManystoreShop::where("id",$shop_id)->find(); + if(!$shop){ + $this->error("店铺不存在"); + } + if(empty($shop["address_city"]) + || empty($shop["province"]) + || empty($shop["city"]) + || empty($shop["district"]) + || empty($shop["longitude"]) + || empty($shop["latitude"])) $this->error("当前机构地址并未完善,请在机构处完善!"); + + + + $params["address_city"] = $shop["address_city"]; + $params["province"] = $shop["province"]; + $params["city"] = $shop["city"]; + $params["district"] = $shop["district"]; + $params["longitude"] = $shop["longitude"]; + $params["latitude"] = $shop["latitude"]; + } //特有认证判断 $this->authClasses($params,$row); // var_dump($row);die; + + //收费免费判断 + if($params["price"]==0){ + $params["feel"] = "1"; + }else{ + + //个人认证无法下付费课程 + $shop = ManystoreShop::where("id",$shop_id)->find(); + if($shop["type"]=="1"){ + $this->error("这个机构属于个人认证,无法发布付费课程!"); + } + + $params["feel"] = "0"; + } + //更新 if($row){ $this->have_auth = false; @@ -234,10 +272,26 @@ class ClassesLib extends Backend } $this->updateCheck($row->id,$params,$row); + + + //名称title不能与其他课程重复 + $check_title = $this->model->where('id','<>',$row["id"])->where('title',$params["title"])->find(); + if($check_title){ + $this->error("课程名称已存在或被其他机构占用,请更改!"); + } + + }else{ //新增 $params["add_type"] = '2'; $params["add_id"] = $this->auth->id; + + + //名称title不能重复 + $check_title = $this->model->where('title',$params["title"])->find(); + if($check_title){ + $this->error("课程名称已存在或被其他机构占用,请更改!"); + } } } diff --git a/application/admin/controller/school/classes/ClassesSpec.php b/application/admin/controller/school/classes/ClassesSpec.php index 8140743..9cf5910 100644 --- a/application/admin/controller/school/classes/ClassesSpec.php +++ b/application/admin/controller/school/classes/ClassesSpec.php @@ -18,10 +18,15 @@ class ClassesSpec extends Backend */ protected $model = null; + protected $qSwitch = true; + protected $qFields = ["classes_lib_id"]; + + public function _initialize() { - parent::_initialize(); $this->model = new \app\admin\model\school\classes\ClassesSpec; + parent::_initialize(); + $this->view->assign("statusList", $this->model->getStatusList()); } diff --git a/application/admin/controller/school/classes/Teacher.php b/application/admin/controller/school/classes/Teacher.php index 2a6b2e1..b6dadd9 100644 --- a/application/admin/controller/school/classes/Teacher.php +++ b/application/admin/controller/school/classes/Teacher.php @@ -3,7 +3,16 @@ namespace app\admin\controller\school\classes; use app\common\controller\Backend; +use app\common\model\User; +use app\manystore\model\Manystore; use fast\Tree; +use think\Db; +use think\db\exception\DataNotFoundException; +use think\db\exception\ModelNotFoundException; +use think\Exception; +use think\exception\DbException; +use think\exception\PDOException; +use think\exception\ValidateException; use think\Model; /** @@ -23,11 +32,14 @@ class Teacher extends Backend protected $selectpageFields = 'id,name,head_image,manystore_id,shop_id,user_id'; protected $searchFields = 'id,name,user_id'; + protected $qSwitch = true; + protected $qFields = ["manystore_id","shop_id"]; public function _initialize() { - parent::_initialize(); $this->model = new \app\admin\model\school\classes\Teacher; + parent::_initialize(); + $this->view->assign("statusList", $this->model->getStatusList()); } @@ -218,4 +230,191 @@ class Teacher extends Backend return json(['list' => $list, 'total' => $total]); } + + + protected function updateCheck($id,$params=[],$row=null){ + + // 课程存在售后订单则不允许操作 + } + + + protected function update_check(&$params,$row=null) + { + + $shop_id = $params["shop_id"]; + $manystore = Manystore::where("shop_id",$shop_id)->find(); + if(!$manystore){ + $this->error("店铺不存在"); + } + //用户不存在 + $user_id = $params["user_id"]; + $user = User::where("id",$user_id)->find(); + if(!$user){ + $this->error("用户不存在"); + } + + //修改 + if($row){ + //用户已是其他的教师(搜索) + $teacher_user = $this->model->where("user_id",$user_id)->where("id","<>",$row["id"])->find(); + if($teacher_user){ + $this->error("用户已存在或已是其他授权机构教师!"); + } + }else{ + //新增 + //用户已是教师(搜索) + $teacher_user = $this->model->where("user_id",$user_id)->find(); + if($teacher_user){ + $this->error("用户已存在或已是其他授权机构教师!"); + } + } + + + + + + + + $params["manystore_id"] = $manystore["id"]; + } + + + /** + * 添加 + * + * @return string + * @throws \think\Exception + */ + public function add() + { + if (false === $this->request->isPost()) { + return $this->view->fetch(); + } + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + $params = $this->preExcludeFields($params); + + if ($this->dataLimit && $this->dataLimitFieldAutoFill) { + $params[$this->dataLimitField] = $this->auth->id; + } + $result = false; + Db::startTrans(); + try { + //是否采用模型验证 + if ($this->modelValidate) { + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; + $this->model->validateFailException()->validate($validate); + } + $this->update_check($params,$row=null); + $result = $this->model->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if ($result === false) { + $this->error(__('No rows were inserted')); + } + $this->success(); + } + + /** + * 编辑 + * + * @param $ids + * @return string + * @throws DbException + * @throws \think\Exception + */ + public function edit($ids = null) + { + $row = $this->model->get($ids); + if (!$row) { + $this->error(__('No Results were found')); + } + $adminIds = $this->getDataLimitAdminIds(); + if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) { + $this->error(__('You have no permission')); + } + if (false === $this->request->isPost()) { + $this->view->assign('row', $row); + return $this->view->fetch(); + } + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + $params = $this->preExcludeFields($params); + $result = false; + Db::startTrans(); + try { + //是否采用模型验证 + if ($this->modelValidate) { + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; + $row->validateFailException()->validate($validate); + } + $this->update_check($params,$row); + $result = $row->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if (false === $result) { + $this->error(__('No rows were updated')); + } + $this->success(); + } + + /** + * 删除 + * + * @param $ids + * @return void + * @throws DbException + * @throws DataNotFoundException + * @throws ModelNotFoundException + */ + public function del($ids = null) + { + if (false === $this->request->isPost()) { + $this->error(__("Invalid parameters")); + } + $ids = $ids ?: $this->request->post("ids"); + if (empty($ids)) { + $this->error(__('Parameter %s can not be empty', 'ids')); + } + $pk = $this->model->getPk(); + $adminIds = $this->getDataLimitAdminIds(); + if (is_array($adminIds)) { + $this->model->where($this->dataLimitField, 'in', $adminIds); + } + $list = $this->model->where($pk, 'in', $ids)->select(); + foreach ($list as $item) { + $this->updateCheck($item->id); + } + + + $count = 0; + Db::startTrans(); + try { + foreach ($list as $item) { + $count += $item->delete(); + } + Db::commit(); + } catch (PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if ($count) { + $this->success(); + } + $this->error(__('No rows were deleted')); + } + + } diff --git a/application/admin/controller/school/classes/VirtualUser.php b/application/admin/controller/school/classes/VirtualUser.php index a35ccc2..41a0b06 100644 --- a/application/admin/controller/school/classes/VirtualUser.php +++ b/application/admin/controller/school/classes/VirtualUser.php @@ -3,6 +3,11 @@ namespace app\admin\controller\school\classes; use app\common\controller\Backend; +use app\common\library\Virtual; +use think\Db; +use think\Exception; +use think\exception\PDOException; +use think\exception\ValidateException; /** * 课程虚拟参与者 @@ -17,11 +22,14 @@ class VirtualUser extends Backend * @var \app\admin\model\school\classes\VirtualUser */ protected $model = null; + protected $qSwitch = true; + protected $qFields = ["classes_lib_id"]; public function _initialize() { - parent::_initialize(); $this->model = new \app\admin\model\school\classes\VirtualUser; + parent::_initialize(); + $this->view->assign("jointypeList", $this->model->getJointypeList()); $this->view->assign("havetypeList", $this->model->getHavetypeList()); } @@ -70,4 +78,51 @@ class VirtualUser extends Backend return $this->view->fetch(); } + + + + /** + * 添加 + * + * @return string + * @throws \think\Exception + */ + public function add() + { + if (false === $this->request->isPost()) { + return $this->view->fetch(); + } + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + $params = $this->preExcludeFields($params); + + if ($this->dataLimit && $this->dataLimitFieldAutoFill) { + $params[$this->dataLimitField] = $this->auth->id; + } + $result = false; + Db::startTrans(); + try { + //是否采用模型验证 +// if ($this->modelValidate) { +// $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); +// $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; +// $this->model->validateFailException()->validate($validate); +// } +// $result = $this->model->allowField(true)->save($params); + if(!$params["classes_lib_id"])throw new Exception( "请选择课程"); + $res = (new Virtual)->getVirtualUser($params["num"],$params["classes_lib_id"],$params["time"],true); + $result = true; + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage().$e->getFile().$e->getLine()); + } + if ($result === false) { + $this->error(__('No rows were inserted')); + } + $this->success(); + } + } diff --git a/application/admin/controller/user/User.php b/application/admin/controller/user/User.php index 6908ad6..3ce698a 100644 --- a/application/admin/controller/user/User.php +++ b/application/admin/controller/user/User.php @@ -4,6 +4,8 @@ namespace app\admin\controller\user; use app\common\controller\Backend; use app\common\library\Auth; +use fast\Tree; +use think\Model; /** * 会员管理 @@ -15,7 +17,7 @@ class User extends Backend protected $relationSearch = true; protected $searchFields = 'id,username,nickname'; - + protected $selectpageFields = '*'; /** * @var \app\admin\model\User */ @@ -102,4 +104,147 @@ class User extends Backend $this->success(); } + + + /** + * Selectpage的实现方法 + * + * 当前方法只是一个比较通用的搜索匹配,请按需重载此方法来编写自己的搜索逻辑,$where按自己的需求写即可 + * 这里示例了所有的参数,所以比较复杂,实现上自己实现只需简单的几行即可 + * + */ + protected function selectpage() + { + //设置过滤方法 + $this->request->filter(['trim', 'strip_tags', 'htmlspecialchars']); + + //搜索关键词,客户端输入以空格分开,这里接收为数组 + $word = (array)$this->request->request("q_word/a"); + //当前页 + $page = $this->request->request("pageNumber"); + //分页大小 + $pagesize = $this->request->request("pageSize"); + //搜索条件 + $andor = $this->request->request("andOr", "and", "strtoupper"); + //排序方式 + $orderby = (array)$this->request->request("orderBy/a"); + //显示的字段 + $field = $this->request->request("showField"); + //主键 + $primarykey = $this->request->request("keyField"); + //主键值 + $primaryvalue = $this->request->request("keyValue"); + //搜索字段 + $searchfield = (array)$this->request->request("searchField/a"); + //自定义搜索条件 + $custom = (array)$this->request->request("custom/a"); + //是否返回树形结构 + $istree = $this->request->request("isTree", 0); + $ishtml = $this->request->request("isHtml", 0); + if ($istree) { + $word = []; + $pagesize = 999999; + } + $order = []; + foreach ($orderby as $k => $v) { + $order[$v[0]] = $v[1]; + } + $field = $field ? $field : 'name'; + + //如果有primaryvalue,说明当前是初始化传值 + if ($primaryvalue !== null) { + $where = [$primarykey => ['in', $primaryvalue]]; + $pagesize = 999999; + } else { + $where = function ($query) use ($word, $andor, $field, $searchfield, $custom) { + $logic = $andor == 'AND' ? '&' : '|'; + $searchfield = is_array($searchfield) ? implode($logic, $searchfield) : $searchfield; + $searchfield = str_replace(',', $logic, $searchfield); + $word = array_filter(array_unique($word)); + if (count($word) == 1) { + $query->where($searchfield, "like", "%" . reset($word) . "%"); + } else { + $query->where(function ($query) use ($word, $searchfield) { + foreach ($word as $index => $item) { + $query->whereOr(function ($query) use ($item, $searchfield) { + $query->where($searchfield, "like", "%{$item}%"); + }); + } + }); + } + if ($custom && is_array($custom)) { + foreach ($custom as $k => $v) { + if (is_array($v) && 2 == count($v)) { + $query->where($k, trim($v[0]), $v[1]); + } else { + $query->where($k, '=', $v); + } + } + } + }; + } + $adminIds = $this->getDataLimitAdminIds(); + if (is_array($adminIds)) { + $this->model->where($this->dataLimitField, 'in', $adminIds); + } + $list = []; + $total = $this->model->where($where)->count(); + if ($total > 0) { + if (is_array($adminIds)) { + $this->model->where($this->dataLimitField, 'in', $adminIds); + } + + $fields = is_array($this->selectpageFields) ? $this->selectpageFields : ($this->selectpageFields && $this->selectpageFields != '*' ? explode(',', $this->selectpageFields) : []); + + //如果有primaryvalue,说明当前是初始化传值,按照选择顺序排序 + if ($primaryvalue !== null && preg_match("/^[a-z0-9_\-]+$/i", $primarykey)) { + $primaryvalue = array_unique(is_array($primaryvalue) ? $primaryvalue : explode(',', $primaryvalue)); + //修复自定义data-primary-key为字符串内容时,给排序字段添加上引号 + $primaryvalue = array_map(function ($value) { + return '\'' . $value . '\''; + }, $primaryvalue); + + $primaryvalue = implode(',', $primaryvalue); + + $this->model->orderRaw("FIELD(`{$primarykey}`, {$primaryvalue})"); + } else { + $this->model->order($order); + } + + $datalist = $this->model->where($where) + ->page($page, $pagesize) + ->select(); + + foreach ($datalist as $index => $item) { + unset($item['password'], $item['salt']); + if ($this->selectpageFields == '*') { + $result = [ + $primarykey => $item[$primarykey] ?? '', + $field => $item[$field] ?? '', + 'nickname' => isset($item['nickname']) ? $item['nickname'] : '', + 'mobile' => isset($item['mobile']) ? $item['mobile'] : '', + 'realname' => isset($item['realname']) ? $item['realname'] : '', + ]; + } else { + $result = array_intersect_key(($item instanceof Model ? $item->toArray() : (array)$item), array_flip($fields)); + } + $result['pid'] = isset($item['pid']) ? $item['pid'] : (isset($item['parent_id']) ? $item['parent_id'] : 0); + $list[] = $result; + } + if ($istree && !$primaryvalue) { + $tree = Tree::instance(); + $tree->init(collection($list)->toArray(), 'pid'); + $list = $tree->getTreeList($tree->getTreeArray(0), $field); + if (!$ishtml) { + foreach ($list as &$item) { + $item = str_replace(' ', ' ', $item); + } + unset($item); + } + } + } + //这里一定要返回有list这个字段,total是可选的,如果total<=list的数量,则会隐藏分页按钮 + return json(['list' => $list, 'total' => $total]); + } + } diff --git a/application/admin/lang/zh-cn/school/classes/classes_lib.php b/application/admin/lang/zh-cn/school/classes/classes_lib.php index e94ca9f..48ad08f 100644 --- a/application/admin/lang/zh-cn/school/classes/classes_lib.php +++ b/application/admin/lang/zh-cn/school/classes/classes_lib.php @@ -43,7 +43,7 @@ return [ 'Set status to 1' => '设为上架', 'Status 2' => '下架', 'Set status to 2' => '设为下架', - 'Status 3' => '平台下架', + 'Status 3' => '(审核课程)平台下架', 'Set status to 3' => '设为平台下架', 'Auth_status' => '审核状态', 'Auth_status 0' => '待审核', diff --git a/application/admin/view/school/classes/classes_lib/add.html b/application/admin/view/school/classes/classes_lib/add.html index 94740c8..8261553 100644 --- a/application/admin/view/school/classes/classes_lib/add.html +++ b/application/admin/view/school/classes/classes_lib/add.html @@ -224,6 +224,7 @@
+ ( 如果填零则为免费课程,课程下单后无需支付,直接可去预约课时! )
diff --git a/application/admin/view/school/classes/classes_lib/edit.html b/application/admin/view/school/classes/classes_lib/edit.html index dc4c8b6..446f065 100644 --- a/application/admin/view/school/classes/classes_lib/edit.html +++ b/application/admin/view/school/classes/classes_lib/edit.html @@ -215,6 +215,7 @@
+ ( 如果填零则为免费课程,课程下单后无需支付,直接可去预约课时! )
diff --git a/application/admin/view/school/classes/classes_spec/add.html b/application/admin/view/school/classes/classes_spec/add.html index 7bd1198..1133042 100644 --- a/application/admin/view/school/classes/classes_spec/add.html +++ b/application/admin/view/school/classes/classes_spec/add.html @@ -3,7 +3,7 @@
- +
@@ -30,18 +30,18 @@
-
- -
- -
-
-
- -
- -
-
+ + + + + + + + + + + +
diff --git a/application/admin/view/school/classes/classes_spec/edit.html b/application/admin/view/school/classes/classes_spec/edit.html index 010c27a..35af5d8 100644 --- a/application/admin/view/school/classes/classes_spec/edit.html +++ b/application/admin/view/school/classes/classes_spec/edit.html @@ -30,18 +30,18 @@
-
- -
- -
-
-
- -
- -
-
+ + + + + + + + + + + +
diff --git a/application/admin/view/school/classes/teacher/add.html b/application/admin/view/school/classes/teacher/add.html index 3c41870..b5bb5ed 100644 --- a/application/admin/view/school/classes/teacher/add.html +++ b/application/admin/view/school/classes/teacher/add.html @@ -1,21 +1,21 @@
-
- -
- -
-
+ + + + + +
- +
- +
diff --git a/application/admin/view/school/classes/teacher/edit.html b/application/admin/view/school/classes/teacher/edit.html index f528fa6..7b4aa0b 100644 --- a/application/admin/view/school/classes/teacher/edit.html +++ b/application/admin/view/school/classes/teacher/edit.html @@ -1,11 +1,11 @@ -
- -
- -
-
+ + + + + +
@@ -15,7 +15,7 @@
- +
diff --git a/application/admin/view/school/classes/virtual_user/add.html b/application/admin/view/school/classes/virtual_user/add.html index 1b2618a..0a585a3 100644 --- a/application/admin/view/school/classes/virtual_user/add.html +++ b/application/admin/view/school/classes/virtual_user/add.html @@ -1,29 +1,17 @@
- +
- -
-
-
- -
-
- -
- - -
- -
-
    +
    + +
    - +
    diff --git a/application/common/controller/Backend.php b/application/common/controller/Backend.php index 3963be4..96fc3be 100644 --- a/application/common/controller/Backend.php +++ b/application/common/controller/Backend.php @@ -2,7 +2,9 @@ namespace app\common\controller; +use app\admin\controller\famysql\Field; use app\admin\library\Auth; +use Monolog\Handler\IFTTTHandler; use think\Config; use think\Controller; use think\Hook; @@ -109,6 +111,55 @@ class Backend extends Controller */ protected $importHeadType = 'comment'; + + protected $qSwitch = false; + protected $qFields = []; + + + + protected function checkAssemblyParameters(){ + if(!$this->qSwitch)return false; + //得到所有get参数 + $get = $this->request->get(); + //得到当前model所有字段 + + + $fields = $this->model->getTableFields(); + +// $commonFields = (new Field())->getCommonFields(); +// var_dump($commonFields); + $fieldLists = $fields; +// foreach ($commonFields as $commonField) { +// if (!in_array($commonField['column_name'], $fields)) { +// $fieldLists[] = $commonField; +// } +// } + $q_fields = []; + + foreach ($get as $kay=>$getField) { + if (in_array($kay, $fieldLists)) { + $q_fields[$kay] = $getField; + } + } + + + //将q_fields塞入模板中 + foreach ($q_fields as $k=>$v) { + //渲染站点配置 + $this->assign('q_'.$k, $v); + } + + foreach ($this->qFields as $k) { + //渲染站点配置 + if(!isset($q_fields[$k]))$this->assign('q_'.$k, ""); + } + + + } + + + + /** * 引入后台控制器的traits */ @@ -228,6 +279,7 @@ class Backend extends Controller $this->assign('auth', $this->auth); //渲染管理员对象 $this->assign('admin', Session::get('admin')); + $this->checkAssemblyParameters(); } /** diff --git a/application/common/controller/ManystoreBase.php b/application/common/controller/ManystoreBase.php index 7ac2c89..3e5188a 100644 --- a/application/common/controller/ManystoreBase.php +++ b/application/common/controller/ManystoreBase.php @@ -2,6 +2,8 @@ namespace app\common\controller; +use app\admin\controller\famysql\Field; +use app\common\model\dyqc\ManystoreShop; use app\manystore\library\Auth; use app\common\model\ManystoreConfig; use think\Config; @@ -109,6 +111,57 @@ class ManystoreBase extends Controller 'setShopAutoRelation', ]; + + + + + protected $qSwitch = false; + protected $qFields = []; + + + + protected function checkAssemblyParameters(){ + if(!$this->qSwitch)return false; + //得到所有get参数 + $get = $this->request->get(); + //得到当前model所有字段 + + + $fields = $this->model->getTableFields(); + +// $commonFields = (new Field())->getCommonFields(); +// var_dump($commonFields); + $fieldLists = $fields; +// foreach ($commonFields as $commonField) { +// if (!in_array($commonField['column_name'], $fields)) { +// $fieldLists[] = $commonField; +// } +// } + $q_fields = []; + + foreach ($get as $kay=>$getField) { + if (in_array($kay, $fieldLists)) { + $q_fields[$kay] = $getField; + } + } + + + //将q_fields塞入模板中 + foreach ($q_fields as $k=>$v) { + //渲染站点配置 + $this->assign('q_'.$k, $v); + } + + foreach ($this->qFields as $k) { + //渲染站点配置 + if(!isset($q_fields[$k]))$this->assign('q_'.$k, ""); + } + + + } + + + /** * 引入后台控制器的traits */ @@ -165,6 +218,11 @@ class ManystoreBase extends Controller if(!defined('SHOP_ID')){ define('SHOP_ID', $this->auth->shop_id); } + $manystoreShop = ManystoreShop::where("id",$this->auth->shop_id)->find(); + if(!defined('SHOP_USER_ID')) { + define('SHOP_USER_ID', $manystoreShop->user_id ?:0); + } + if(!defined('STORE_ID')) { define('STORE_ID', $this->auth->id); @@ -209,6 +267,8 @@ class ManystoreBase extends Controller // 上传信息配置后 Hook::listen("upload_config_init", $upload); + + // 配置信息 $config = [ 'site' => array_intersect_key($site, array_flip(['name', 'indexurl', 'cdnurl', 'version', 'timezone', 'languages'])), @@ -219,7 +279,10 @@ class ManystoreBase extends Controller 'jsname' => 'manystore/' . str_replace('.', '/', $controllername), 'moduleurl' => rtrim(url("/{$modulename}", '', false), '/'), 'language' => $lang, - 'referer' => Session::get("referer") + 'referer' => Session::get("referer"), + 'shop_id' => $this->auth->shop_id, + 'store_id' => $this->auth->id, + 'shop_user_id' => $manystoreShop->user_id ?:0, ]; $config = array_merge($config, Config::get("view_replace_str")); @@ -237,6 +300,21 @@ class ManystoreBase extends Controller $this->assign('auth', $this->auth); //渲染管理员对象 $this->assign('manystore', Session::get('manystore')); + + + $this->assign('shop_id', $this->auth->shop_id); + + $this->assign('store_id', $this->auth->id); + $this->assign('shop_user_id', $manystoreShop->user_id ?:0 ); + +// if(!defined('SHOP_ID')){ +// define('SHOP_ID', $this->auth->shop_id); +// } +// +// if(!defined('STORE_ID')) { +// define('STORE_ID', $this->auth->id); +// } + $this->checkAssemblyParameters(); } /** diff --git a/application/common/library/Virtual.php b/application/common/library/Virtual.php index 6e38963..a746577 100644 --- a/application/common/library/Virtual.php +++ b/application/common/library/Virtual.php @@ -22,6 +22,8 @@ class Virtual } public function getVirtualUser($num=10,$classes_lib_id = 0,$time=null,$set=false){ + if(!is_numeric($time)) $time = strtotime($time); //日期字符格式化时间戳 + $users = []; if(!$time)$time = time(); //mysql随机查询$num个数据 diff --git a/application/common/model/dyqc/ManystoreShop.php b/application/common/model/dyqc/ManystoreShop.php index 8ef3b59..e422563 100644 --- a/application/common/model/dyqc/ManystoreShop.php +++ b/application/common/model/dyqc/ManystoreShop.php @@ -2,12 +2,14 @@ namespace app\common\model\dyqc; +use app\common\model\BaseModel; use app\common\model\school\classes\ClassesLib; use app\common\model\school\classes\Teacher; +use app\common\model\User; use think\Model; -class ManystoreShop extends Model +class ManystoreShop extends BaseModel { @@ -175,4 +177,128 @@ class ManystoreShop extends Model return $data; } + + + + + + + /**申请机构 + * @param $type 申请类型 类型:1=个人,2=机构 + * @param int $user_id 申请人 + * @param $params 申请参数 + * @param bool $check + * @param bool $trans + * @return bool + * @throws \Exception + */ + public function apply($type,$user_id=0,$params=[],$check=false,$oper_type='user',$oper_id=0,$trans=false){ + + if($check){ + $user = User::get($user_id); + if(!$user)throw new \Exception("用户不存在"); + //已经是机构 + $shop = ManystoreShop::where( 'user_id',$user_id)->where("status","1")->find(); + if($shop)throw new \Exception("已申请机构,请勿重复申请"); + + //验证参数 + //$type 1=个人,2=机构 + if(!in_array($type,['1','2']))throw new \Exception("类型参数错误"); + //switch不同类型type做不同验证 + //未传手机号则默认用户手机号 + if(empty($params['tel'])) $params['tel'] = $user['mobile']; + + switch ($type) { + case '1': //个人 + $rule = [ + 'name' => 'require', + 'tel' => 'require|number', +// 'desc' => 'require', + 'front_idcard_image' => 'require', + 'reverse_idcard_image' => 'require', + ]; + $rule_msg = [ + 'name.require' => '姓名必须填写', + 'tel.require' => '服务电话必须填写', + 'tel.number' => '服务电话必须是数字', +// 'desc.require' => '申请备注必须填写', + 'front_idcard_image.require' => '身份证正面必须上传', + 'reverse_idcard_image.require' => '身份证反面必须上传', + ]; + break; + case '2': //机构 + + $rule = [ + 'name' => 'require', + 'tel' => 'require|number', +// 'desc' => 'require', + 'front_idcard_image' => 'require', + 'reverse_idcard_image' => 'require', + 'images' => 'require', + 'yyzz_images' => 'require', + ]; + + $rule_msg = [ + 'name.require' => '机构名称必须填写', + 'tel.require' => '服务电话必须填写', + 'tel.number' => '服务电话必须是数字', +// 'desc.require' => '申请备注必须填写', + 'front_idcard_image.require' => '法人身份证正面必须上传', + 'reverse_idcard_image.require' => '法人身份证反面必须上传', + 'images.require' => '机构环境照片必须上传', + 'yyzz_images.require' => '营业执照照片必须上传', + ]; + + break; + } + self::check($params,$rule,$rule_msg); + } + $params["type"] = $type; + + //得到申请单(没有则创建) + $shop = ManystoreShop::where( 'user_id',$user_id)->where("status","1")->find(); + //如果存在申请单,则直接更新这个单的状态 + //如果不存在则创建一个新单 + +// $order = self::getHaveCancelOrder($order_no); + + //判断逻辑 + if($trans){ + self::beginTrans(); + } + $res = true; + try{ + //事务逻辑 +// //更新订单取消状态 +// $order = Order::updateCancel($order); +// //插入订单取消日志 +// if(!$user_id ||$order["user_id"] !=$user_id ){ +// OrderLog::log($order['id'],"[员工代操作]课时预约单取消成功,课时已原路退回",$oper_type ?: 'user', $oper_id ?: $order['user_id']); +// }else{ +// OrderLog::log($order['id'],"课时预约单取消成功,课时已原路退回",$oper_type ?: 'user', $oper_id ?: $order['user_id']); +// } +// +// //调用订单取消事件 +// $data = ['order' => $order]; +// \think\Hook::listen('classeshour_order_cancel_after', $data); +// //执行课时数更新 +// $res1 = \app\common\model\school\classes\order\Order::statisticsAndUpdateClassesNumber($order['classes_order_id']); + + + if($trans){ + self::commitTrans(); + } + }catch (\Exception $e){ + if($trans){ + self::rollbackTrans(); + } + throw new \Exception($e->getMessage()); + } + return $res; + } + + + + + } diff --git a/application/common/model/school/classes/order/Order.php b/application/common/model/school/classes/order/Order.php index a797377..f032ea5 100644 --- a/application/common/model/school/classes/order/Order.php +++ b/application/common/model/school/classes/order/Order.php @@ -353,9 +353,16 @@ class Order extends BaseModel } try { //1订单执行创建 - $this->createOrder($user_id,$orderInfo['classes_lib_id'],$order_no,$orderInfo['param'],$remark); + $order = $this->createOrder($user_id,$orderInfo['classes_lib_id'],$order_no,$orderInfo['param'],$remark); //5删除缓存 self::deleteOrderCache($user_id, $order_no); + + //如果是免费订单,则直接调用支付完成 + if ($order['totalprice'] == 0) { + //调用订单支付成功事件 + $this->paySuccess($order_no,['platform'=>"miniapp",'pay_type'=>'yue']); + } + if ($trans) { self::commitTrans(); } diff --git a/application/manystore/controller/school/classes/ClassesLib.php b/application/manystore/controller/school/classes/ClassesLib.php index 3da6946..b7458f7 100644 --- a/application/manystore/controller/school/classes/ClassesLib.php +++ b/application/manystore/controller/school/classes/ClassesLib.php @@ -30,7 +30,7 @@ class ClassesLib extends ManystoreBase protected $model = null; //不用审核允许修改的字段 - protected $no_auth_fields = ['headimage','images','notice','content',"virtual_num","virtual_collect","underline_price"]; + protected $no_auth_fields = ['headimage','images','notice','content',"virtual_num","virtual_collect","underline_price","selfhot","price","classes_num"]; //更新数据是否需要触发审核开关 protected $need_auth = true; @@ -51,6 +51,7 @@ class ClassesLib extends ManystoreBase $this->view->assign("hotList", $this->model->getHotList()); $this->view->assign("newList", $this->model->getNewList()); $this->view->assign("selfhotList", $this->model->getSelfhotList()); + } public function import() @@ -87,6 +88,8 @@ class ClassesLib extends ManystoreBase ->order($sort, $order) ->paginate($limit); +// var_dump($this->model->getLastSql());die; + foreach ($list as $row) { $row->getRelation('manystore')->visible(['nickname']); @@ -136,8 +139,11 @@ class ClassesLib extends ManystoreBase if($params["status"] == '3') $params["status"] = '2'; } + + }else{ //新增 + } } @@ -187,8 +193,9 @@ class ClassesLib extends ManystoreBase protected function update_check(&$params,$row=null) { - - $shop_id = $row["shop_id"]; + unset($params["auth_status"]); + if(!isset($params['status']))$params['status'] = "3"; + $shop_id = SHOP_ID; $manystore = Manystore::where("shop_id",$shop_id)->find(); if(!$manystore){ $this->error("店铺不存在"); @@ -197,7 +204,7 @@ class ClassesLib extends ManystoreBase //验证老师id - $teacher_id = $row['teacher_id']; + $teacher_id = $params['teacher_id']; $teacher = \app\admin\model\school\classes\Teacher::where("id",$teacher_id)->find(); if(!$teacher){ $this->error("老师不存在"); @@ -223,17 +230,58 @@ class ClassesLib extends ManystoreBase || empty($params["longitude"]) || empty($params["latitude"])) $this->error("独立地点需传定位信息"); - } + }else{ + //地址取机构的 + $shop = ManystoreShop::where("id",$shop_id)->find(); + if(!$shop){ + $this->error("店铺不存在"); + } + if(empty($shop["address_city"]) + || empty($shop["province"]) + || empty($shop["city"]) + || empty($shop["district"]) + || empty($shop["longitude"]) + || empty($shop["latitude"])) $this->error("当前机构地址并未完善!请去【个人资料】完善信息"); + + + //地址取机构的 + $shop = ManystoreShop::where("id",$shop_id)->find(); + if(!$shop){ + $this->error("店铺不存在"); + } + $params["address_city"] = $shop["address_city"]; + $params["province"] = $shop["province"]; + $params["city"] = $shop["city"]; + $params["district"] = $shop["district"]; + $params["longitude"] = $shop["longitude"]; + $params["latitude"] = $shop["latitude"]; + + } + //收费免费判断 + if($params["price"]==0){ + $params["feel"] = "1"; + }else{ + //个人认证无法下付费课程 + $shop = ManystoreShop::where("id",$shop_id)->find(); + if($shop["type"]=="1"){ + $this->error("当前属于个人认证,无法发布付费课程!"); + } + + + $params["feel"] = "0"; + } //特有认证判断 // $this->authClasses($params,$row); // var_dump($row);die; //更新 if($row){ + if($row['status'] == "3" && $params['status'] != $row['status']){ $this->error("平台下架审核的课程无法上架!"); } + $this->have_auth = false; if($this->need_auth){ //判断更新的变动数据 @@ -241,15 +289,39 @@ class ClassesLib extends ManystoreBase if($this->have_auth){ $params['status'] = "3"; - $params['auth_status'] = "0"; + $params['auth_status'] = 0; + $params["reason"] = ""; } } $this->updateCheck($row->id,$params,$row); + + //如果是审核失败,提交后自动更新成审核中 + if($row['auth_status'] == 2){ + $params['status'] = "3"; + $params['auth_status'] = 0; + $params["reason"] = ""; + } + + + //名称title不能与其他课程重复 + $check_title = $this->model->where('id','<>',$row["id"])->where('title',$params["title"])->find(); + if($check_title){ + $this->error("课程名称已存在或被其他机构占用,请更改!"); + } + }else{ - //新增 - $params["add_type"] = '2'; + //新增(需审核) + $params["add_type"] = '1'; $params["add_id"] = $this->auth->id; + $params['status'] = "3";//平台下架 + $params['auth_status'] = 0; + + //名称title不能重复 + $check_title = $this->model->where('title',$params["title"])->find(); + if($check_title){ + $this->error("课程名称已存在或被其他机构占用,请更改!"); + } } } diff --git a/application/manystore/controller/school/classes/ClassesSpec.php b/application/manystore/controller/school/classes/ClassesSpec.php index cec6dc6..3a5c0db 100644 --- a/application/manystore/controller/school/classes/ClassesSpec.php +++ b/application/manystore/controller/school/classes/ClassesSpec.php @@ -18,10 +18,14 @@ class ClassesSpec extends ManystoreBase */ protected $model = null; + protected $qSwitch = true; + protected $qFields = ["classes_lib_id"]; + public function _initialize() { - parent::_initialize(); $this->model = new \app\manystore\model\school\classes\ClassesSpec; + parent::_initialize(); + $this->view->assign("statusList", $this->model->getStatusList()); } diff --git a/application/manystore/controller/school/classes/Teacher.php b/application/manystore/controller/school/classes/Teacher.php index 74aa362..e145cde 100644 --- a/application/manystore/controller/school/classes/Teacher.php +++ b/application/manystore/controller/school/classes/Teacher.php @@ -3,6 +3,12 @@ namespace app\manystore\controller\school\classes; use app\common\controller\ManystoreBase; +use app\common\model\User; +use app\manystore\model\Manystore; +use think\Db; +use think\Exception; +use think\exception\PDOException; +use think\exception\ValidateException; /** * 机构老师 @@ -18,10 +24,14 @@ class Teacher extends ManystoreBase */ protected $model = null; + protected $qSwitch = true; + protected $qFields = ["manystore_id","shop_id"]; + public function _initialize() { - parent::_initialize(); $this->model = new \app\manystore\model\school\classes\Teacher; + parent::_initialize(); + $this->view->assign("statusList", $this->model->getStatusList()); } @@ -73,4 +83,200 @@ class Teacher extends ManystoreBase return $this->view->fetch(); } + + protected function updateCheck($id,$params=[],$row=null){ + + // 课程存在售后订单则不允许操作 + } + + + protected function update_check(&$params,$row=null) + { + + $shop_id = SHOP_ID; + $manystore = Manystore::where("shop_id", $shop_id)->find(); + if (!$manystore) { + $this->error("店铺不存在"); + } + $params["manystore_id"] = $manystore["id"]; + $params["shop_id"] = $shop_id; + $user = User::where("nickname|realname|mobile", $params["user_id"])->find(); + if(!$user) $this->error("未找到用户请先让用户登录小程序再提交表单"); + $params["user_id"] = $user["id"]; + + $user_id = $params["user_id"]; + //修改 + if($row){ + //用户已是其他的教师(搜索) + $teacher_user = $this->model->where("user_id",$user_id)->where("id","<>",$row["id"])->find(); + if($teacher_user){ + $this->error("用户已存在或已是其他授权机构教师!"); + } + }else{ + //新增 + //用户已是教师(搜索) + $teacher_user = $this->model->where("user_id",$user_id)->find(); + if($teacher_user){ + $this->error("用户已存在或已是其他授权机构教师!"); + } + } + + + } + + + + /** + * 添加 + * + * @return string + * @throws \think\Exception + */ + public function add() + { + if ($this->request->isPost()) { + $params = $this->request->post("row/a"); + if ($params) { + $params = $this->preExcludeFields($params); + + if($this->storeIdFieldAutoFill && STORE_ID ){ + $params['store_id'] = STORE_ID; + } + + if($this->shopIdAutoCondition && SHOP_ID){ + $params['shop_id'] = SHOP_ID; + } + + $result = false; + Db::startTrans(); + try { + //是否采用模型验证 + if ($this->modelValidate) { + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; + $this->model->validateFailException(true)->validate($validate); + } + $this->update_check($params,$row=null); + $result = $this->model->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException $e) { + Db::rollback(); + $this->error($e->getMessage()); + } catch (PDOException $e) { + Db::rollback(); + $this->error($e->getMessage()); + } catch (Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if ($result !== false) { + $this->success(); + } else { + $this->error(__('No rows were inserted')); + } + } + $this->error(__('Parameter %s can not be empty', '')); + } + return $this->view->fetch(); + } + + /** + * 编辑 + */ + public function edit($ids = null) + { + if($this->shopIdAutoCondition){ + $this->model->where(array('shop_id'=>SHOP_ID)); + } + $row = $this->model->where(array('id'=>$ids))->find(); + if (!$row) { + $this->error(__('No Results were found')); + } + + if ($this->request->isPost()) { + $params = $this->request->post("row/a"); + if ($params) { + $params = $this->preExcludeFields($params); + $result = false; + Db::startTrans(); + try { + //是否采用模型验证 + if ($this->modelValidate) { + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; + $row->validateFailException(true)->validate($validate); + } + $this->update_check($params,$row); + + + $result = $row->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException $e) { + Db::rollback(); + $this->error($e->getMessage()); + } catch (PDOException $e) { + Db::rollback(); + $this->error($e->getMessage()); + } catch (Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if ($result !== false) { + $this->success(); + } else { + $this->error(__('No rows were updated')); + } + } + $this->error(__('Parameter %s can not be empty', '')); + } + + + $user = User::where("id", $row["user_id"])->find(); +// if(!$user) $this->error("未找到用户请先让用户登录小程序再提交表单"); + $row["user_id"] = $user["mobile"]?? ""; //nickname|realname|mobile + $this->view->assign("row", $row); + return $this->view->fetch(); + } + + /** + * 删除 + */ + public function del($ids = "") + { + if (!$this->request->isPost()) { + $this->error(__("Invalid parameters")); + } + $ids = $ids ? $ids : $this->request->post("ids"); + if ($ids) { + $pk = $this->model->getPk(); + if($this->shopIdAutoCondition){ + $this->model->where(array('shop_id'=>SHOP_ID)); + } + $list = $this->model->where($pk, 'in', $ids)->select(); + foreach ($list as $item) { + $this->updateCheck($item->id); + } + $count = 0; + Db::startTrans(); + try { + foreach ($list as $k => $v) { + $count += $v->delete(); + } + Db::commit(); + } catch (PDOException $e) { + Db::rollback(); + $this->error($e->getMessage()); + } catch (Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if ($count) { + $this->success(); + } else { + $this->error(__('No rows were deleted')); + } + } + $this->error(__('Parameter %s can not be empty', 'ids')); + } + } diff --git a/application/manystore/controller/school/classes/VirtualUser.php b/application/manystore/controller/school/classes/VirtualUser.php index d009d3d..c019d6d 100644 --- a/application/manystore/controller/school/classes/VirtualUser.php +++ b/application/manystore/controller/school/classes/VirtualUser.php @@ -3,6 +3,11 @@ namespace app\manystore\controller\school\classes; use app\common\controller\ManystoreBase; +use app\common\library\Virtual; +use think\Db; +use think\Exception; +use think\exception\PDOException; +use think\exception\ValidateException; /** * 课程虚拟参与者 @@ -17,11 +22,14 @@ class VirtualUser extends ManystoreBase * @var \app\manystore\model\school\classes\VirtualUser */ protected $model = null; + protected $qSwitch = true; + protected $qFields = ["classes_lib_id"]; public function _initialize() { - parent::_initialize(); $this->model = new \app\manystore\model\school\classes\VirtualUser; + parent::_initialize(); + $this->view->assign("jointypeList", $this->model->getJointypeList()); $this->view->assign("havetypeList", $this->model->getHavetypeList()); } @@ -72,4 +80,58 @@ class VirtualUser extends ManystoreBase return $this->view->fetch(); } + + /** + * 添加 + */ + public function add() + { + if ($this->request->isPost()) { + $params = $this->request->post("row/a"); + if ($params) { + $params = $this->preExcludeFields($params); + + if($this->storeIdFieldAutoFill && STORE_ID ){ + $params['store_id'] = STORE_ID; + } + + if($this->shopIdAutoCondition && SHOP_ID){ + $params['shop_id'] = SHOP_ID; + } + + $result = false; + Db::startTrans(); + try { + //是否采用模型验证 +// if ($this->modelValidate) { +// $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); +// $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; +// $this->model->validateFailException(true)->validate($validate); +// } +// $result = $this->model->allowField(true)->save($params); + if(!$params["classes_lib_id"])throw new Exception( "请选择课程"); + $res = (new Virtual)->getVirtualUser($params["num"],$params["classes_lib_id"],$params["time"],true); + $result = true; + Db::commit(); + } catch (ValidateException $e) { + Db::rollback(); + $this->error($e->getMessage()); + } catch (PDOException $e) { + Db::rollback(); + $this->error($e->getMessage()); + } catch (Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if ($result !== false) { + $this->success(); + } else { + $this->error(__('No rows were inserted')); + } + } + $this->error(__('Parameter %s can not be empty', '')); + } + return $this->view->fetch(); + } + } diff --git a/application/manystore/lang/zh-cn/school/classes/teacher.php b/application/manystore/lang/zh-cn/school/classes/teacher.php index 4a2c073..764733e 100644 --- a/application/manystore/lang/zh-cn/school/classes/teacher.php +++ b/application/manystore/lang/zh-cn/school/classes/teacher.php @@ -3,7 +3,7 @@ return [ 'Manystore_id' => '机构账号id', 'Shop_id' => '机构店铺id', - 'User_id' => '教师前台用户id', + 'User_id' => '教师前台用户', 'Name' => '教师名', 'Head_image' => '教师头像', 'Content' => '教师简介', diff --git a/application/manystore/view/school/classes/classes_lib/add.html b/application/manystore/view/school/classes/classes_lib/add.html index 35e3ad9..ea20a7f 100644 --- a/application/manystore/view/school/classes/classes_lib/add.html +++ b/application/manystore/view/school/classes/classes_lib/add.html @@ -224,6 +224,7 @@
    + ( 如果填零则为免费课程,课程下单后无需支付,直接可去预约课时! )
    @@ -238,35 +239,35 @@
    -
    - -
    + + + -
    - {foreach name="statusList" item="vo"} - - {/foreach} -
    + + + + + + + + + + -
    -
    -
    - -
    + + + + + -
    - {foreach name="authStatusList" item="vo"} - - {/foreach} -
    + + + + + -
    -
    + + @@ -340,8 +341,13 @@ + \ No newline at end of file diff --git a/application/manystore/view/school/classes/classes_lib/edit.html b/application/manystore/view/school/classes/classes_lib/edit.html index 5d0b2b8..923b498 100644 --- a/application/manystore/view/school/classes/classes_lib/edit.html +++ b/application/manystore/view/school/classes/classes_lib/edit.html @@ -6,12 +6,12 @@ -
    - -
    - -
    -
    + + + + + + @@ -215,6 +215,7 @@
    + ( 如果填零则为免费课程,课程下单后无需支付,直接可去预约课时! )
    @@ -262,9 +263,14 @@
    {foreach name="authStatusList" item="vo"} - + {/foreach}
    + {if ( $row.auth_status == 2) } + (不通过原因:{$row.reason}) + {else /} + + {/if}
    @@ -341,8 +347,13 @@ + \ No newline at end of file diff --git a/application/manystore/view/school/classes/classes_lib/index.html b/application/manystore/view/school/classes/classes_lib/index.html index 5dd9ed6..01a15a2 100644 --- a/application/manystore/view/school/classes/classes_lib/index.html +++ b/application/manystore/view/school/classes/classes_lib/index.html @@ -42,3 +42,8 @@
    + \ No newline at end of file diff --git a/application/manystore/view/school/classes/classes_spec/add.html b/application/manystore/view/school/classes/classes_spec/add.html index e4730ee..9bea2a8 100644 --- a/application/manystore/view/school/classes/classes_spec/add.html +++ b/application/manystore/view/school/classes/classes_spec/add.html @@ -3,7 +3,7 @@
    - +
    @@ -30,18 +30,18 @@
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    + + + + + + + + + + + +
    diff --git a/application/manystore/view/school/classes/classes_spec/edit.html b/application/manystore/view/school/classes/classes_spec/edit.html index f246645..6e7d90c 100644 --- a/application/manystore/view/school/classes/classes_spec/edit.html +++ b/application/manystore/view/school/classes/classes_spec/edit.html @@ -3,7 +3,7 @@
    - +
    @@ -30,18 +30,18 @@
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    + + + + + + + + + + + +
    diff --git a/application/manystore/view/school/classes/teacher/add.html b/application/manystore/view/school/classes/teacher/add.html index 4770de0..332cf8b 100644 --- a/application/manystore/view/school/classes/teacher/add.html +++ b/application/manystore/view/school/classes/teacher/add.html @@ -1,17 +1,19 @@
    -
    - -
    - -
    -
    + + + + + +
    - + + (请先让对方登录小程序,之后输入小程序端用户:手机号,昵称 或 姓名 )
    +
    diff --git a/application/manystore/view/school/classes/teacher/edit.html b/application/manystore/view/school/classes/teacher/edit.html index 3a06c6f..02f7ff7 100644 --- a/application/manystore/view/school/classes/teacher/edit.html +++ b/application/manystore/view/school/classes/teacher/edit.html @@ -1,15 +1,16 @@ -
    - -
    - -
    -
    + + + + + +
    - + + (请先让对方登录小程序,之后输入小程序端用户:手机号,昵称 或 姓名 )
    diff --git a/application/manystore/view/school/classes/virtual_user/add.html b/application/manystore/view/school/classes/virtual_user/add.html index 0dbc179..adf54be 100644 --- a/application/manystore/view/school/classes/virtual_user/add.html +++ b/application/manystore/view/school/classes/virtual_user/add.html @@ -1,29 +1,15 @@
    - +
    - -
    -
    -
    - -
    -
    - -
    - - -
    - -
    -
      +
      - +
      @@ -32,30 +18,30 @@
      -
      - -
      - - + + + + + + + + + -
      -
      -
      - -
      - - + + + + + + + + + + + -
      -
      + +