diff --git a/application/admin/controller/school/SearchCity.php b/application/admin/controller/school/SearchCity.php new file mode 100644 index 0000000..dc97ed7 --- /dev/null +++ b/application/admin/controller/school/SearchCity.php @@ -0,0 +1,37 @@ +model = new \app\admin\model\school\SearchCity; + + } + + + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + +} diff --git a/application/admin/controller/school/classes/Cate.php b/application/admin/controller/school/classes/Cate.php index 2c7e1f1..5a335f5 100644 --- a/application/admin/controller/school/classes/Cate.php +++ b/application/admin/controller/school/classes/Cate.php @@ -23,6 +23,7 @@ class Cate extends Backend parent::_initialize(); $this->model = new \app\admin\model\school\classes\Cate; $this->view->assign("statusList", $this->model->getStatusList()); + $this->view->assign("hotList", $this->model->getHotList()); } diff --git a/application/admin/controller/school/classes/ClassesLib.php b/application/admin/controller/school/classes/ClassesLib.php index d6f8f03..1b74ba2 100644 --- a/application/admin/controller/school/classes/ClassesLib.php +++ b/application/admin/controller/school/classes/ClassesLib.php @@ -2,7 +2,17 @@ namespace app\admin\controller\school\classes; +use app\admin\model\dyqc\ManystoreShop; use app\common\controller\Backend; +use app\common\model\school\classes\Order; +use app\manystore\model\Manystore; +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; /** * 机构课程库 @@ -18,6 +28,15 @@ class ClassesLib extends Backend */ protected $model = null; + //不用审核允许修改的字段 + protected $no_auth_fields = ['headimage','images','notice','content',"virtual_num","virtual_collect","underline_price"]; + + //更新数据是否需要触发审核开关 + protected $need_auth = false; + protected $have_auth = false; + + protected $success_auth = false; + public function _initialize() { parent::_initialize(); @@ -79,4 +98,288 @@ class ClassesLib extends Backend return $this->view->fetch(); } + + protected function authClasses(&$params,$row=null){ + //审核失败需填写原因 + if($params["auth_status"] == '2' && empty($params["reason"])){ + $this->error("审核失败需填写原因"); + } + + if($params["auth_status"] == '2'){ + //审核不通过会平台下架 + $params["status"] = '3'; + } + + //更新 + if($row){ + + if($params["auth_status"] != '1' && $row["auth_status"] == '1'){ + $this->error("审核已通过的课程不允许再修改审核状态!"); + } + + if($params["auth_status"] != '0' && $row["auth_status"] == '0'){ + //填写审核时间和审核人 + $params["auth_time"] = time(); + $params["admin_id"] = $this->auth->id; + if($params["auth_status"] == '1'){ + //审核通过 + $this->success_auth = true; + } + } + //审核通过 + if($this->success_auth){ + //如果是平台下架,则更新成正常下架 + if($params["status"] == '3') $params["status"] = '2'; + } + + }else{ + //新增 + } + + } + + protected function no_auth_fields_check($params,$row){ + + foreach ($params as $k=>$v){ + + //说明数值有变动 + //$params[$k] 去掉两端空格 + $params[$k] = trim($v); + + if($row[$k]!=$params[$k]){ + //当修改参数不在允许修改的字段中 + if(!in_array($k,$this->no_auth_fields)){ + + $this->have_auth = true;break; + + } + } + + } + + return $this->have_auth; + + } + + protected function updateCheck($id,$params=[],$row=null){ + if($params && $row){ + + if(!$this->no_auth_fields_check($params,$row)){ + return true; + } + } + + // 课程存在未完成订单则不允许操作 + $order = Order::where("classes_lib_id",$id)->where("status","in","0,3")->find(); + if($order)$this->error("存在正在使用中的课程订单或存在正在售后中的课程订单无法继续操作!"); + // 课程存在售后订单则不允许操作 + } + + + + protected function update_check(&$params,$row=null) + { + + $shop_id = $row["shop_id"]; + $manystore = Manystore::where("shop_id",$shop_id)->find(); + if(!$manystore){ + $this->error("店铺不存在"); + } + $params["manystore_id"] = $manystore["id"]; + + + //验证老师id + $teacher_id = $row['teacher_id']; + $teacher = \app\admin\model\school\classes\Teacher::where("id",$teacher_id)->find(); + if(!$teacher){ + $this->error("老师不存在"); + } + if(!$teacher["user_id"]){ + $this->error("当前老师没有前端用户!请换一个!"); + } + //老师与当前机构id不一致 + if($teacher["manystore_id"] != $manystore["id"]){ + $this->error("当前老师与当前机构不匹配,请换一个老师!"); + } + + + $params["user_id"] = $teacher["user_id"]; + + + //独立地点需传定位信息 + if($params["address_type"] == "2"){ + if(empty($params["address_city"]) + || empty($params["province"]) + || empty($params["city"]) + || empty($params["district"]) + || empty($params["longitude"]) + || empty($params["latitude"])) $this->error("独立地点需传定位信息"); + + } + + //特有认证判断 + $this->authClasses($params,$row); +// var_dump($row);die; + //更新 + if($row){ + $this->have_auth = false; + if($this->need_auth){ + //判断更新的变动数据 + $this->no_auth_fields_check($params,$row); + + if($this->have_auth){ + $params['status'] = "3"; + $params['auth_status'] = "0"; + } + } + + $this->updateCheck($row->id,$params,$row); + }else{ + //新增 + $params["add_type"] = '2'; + $params["add_id"] = $this->auth->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/Teacher.php b/application/admin/controller/school/classes/Teacher.php index 9de468e..2a6b2e1 100644 --- a/application/admin/controller/school/classes/Teacher.php +++ b/application/admin/controller/school/classes/Teacher.php @@ -3,6 +3,8 @@ namespace app\admin\controller\school\classes; use app\common\controller\Backend; +use fast\Tree; +use think\Model; /** * 机构老师 @@ -18,6 +20,10 @@ class Teacher extends Backend */ protected $model = null; + protected $selectpageFields = 'id,name,head_image,manystore_id,shop_id,user_id'; + protected $searchFields = 'id,name,user_id'; + + public function _initialize() { parent::_initialize(); @@ -70,4 +76,146 @@ class Teacher extends Backend return $this->view->fetch(); } + + + + /** + * 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] ?? '', + + ]; + } 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/cate.php b/application/admin/lang/zh-cn/school/classes/cate.php index 29e7fc8..33cf25a 100644 --- a/application/admin/lang/zh-cn/school/classes/cate.php +++ b/application/admin/lang/zh-cn/school/classes/cate.php @@ -2,6 +2,9 @@ return [ 'Name' => '分类名', + 'Hot' => '平台热门', + 'Hot 0' => '否', + 'Hot 1' => '是', 'Status' => '状态', 'Status 1' => '上架', 'Set status to 1'=> '设为上架', diff --git a/application/admin/lang/zh-cn/school/search_city.php b/application/admin/lang/zh-cn/school/search_city.php new file mode 100644 index 0000000..485980c --- /dev/null +++ b/application/admin/lang/zh-cn/school/search_city.php @@ -0,0 +1,9 @@ + '城市选择', + 'Province' => '省编号', + 'City' => '市编号', + 'District' => '县区编号', + 'Deletetime' => '删除时间' +]; diff --git a/application/admin/model/school/SearchCity.php b/application/admin/model/school/SearchCity.php new file mode 100644 index 0000000..b0f69be --- /dev/null +++ b/application/admin/model/school/SearchCity.php @@ -0,0 +1,40 @@ + __('Hot 0'), '1' => __('Hot 1')]; + } + + + public function getHotTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['hot']) ? $data['hot'] : ''); + $list = $this->getHotList(); + return isset($list[$value]) ? $list[$value] : ''; + } } diff --git a/application/admin/model/school/classes/ClassesLib.php b/application/admin/model/school/classes/ClassesLib.php index 2d5e784..a5e313f 100644 --- a/application/admin/model/school/classes/ClassesLib.php +++ b/application/admin/model/school/classes/ClassesLib.php @@ -34,8 +34,30 @@ class ClassesLib extends Model 'recommend_text', 'hot_text', 'new_text', - 'selfhot_text' + 'selfhot_text', + 'classes_cate_title', + 'classes_label_title', ]; + + public function getClassesCateTitleAttr($value, $data) + { + $classes_cate_ids = (isset($data['classes_cate_ids']) ? $data['classes_cate_ids'] : ''); + if(!$classes_cate_ids) return ''; + //$classes_cate_ids 查询分类表 names 已逗号拼接返回 + $classes_cate_title = Cate::where('id','in',$classes_cate_ids)->column('name'); + return implode(',',$classes_cate_title); + } + + public function getClassesLabelTitleAttr($value, $data) + { + $classes_cate_ids = (isset($data['classes_label_ids']) ? $data['classes_label_ids'] : ''); + if(!$classes_cate_ids) return ''; + //$classes_cate_ids 查询分类表 names 已逗号拼接返回 + $classes_cate_title = Label::where('id','in',$classes_cate_ids)->column('name'); + return implode(',',$classes_cate_title); + } + + protected static function init() diff --git a/application/admin/validate/school/SearchCity.php b/application/admin/validate/school/SearchCity.php new file mode 100644 index 0000000..d0e5f35 --- /dev/null +++ b/application/admin/validate/school/SearchCity.php @@ -0,0 +1,27 @@ + [], + 'edit' => [], + ]; + +} diff --git a/application/admin/view/school/classes/cate/add.html b/application/admin/view/school/classes/cate/add.html index 6d8c4f6..578bda2 100644 --- a/application/admin/view/school/classes/cate/add.html +++ b/application/admin/view/school/classes/cate/add.html @@ -6,6 +6,20 @@ + +
+ +
+ + + +
+
+
diff --git a/application/admin/view/school/classes/cate/edit.html b/application/admin/view/school/classes/cate/edit.html index 9abb38c..fcde473 100644 --- a/application/admin/view/school/classes/cate/edit.html +++ b/application/admin/view/school/classes/cate/edit.html @@ -6,6 +6,21 @@
+ +
+ +
+ + + +
+
+ +
diff --git a/application/admin/view/school/classes/classes_lib/add.html b/application/admin/view/school/classes/classes_lib/add.html index a164db6..94740c8 100644 --- a/application/admin/view/school/classes/classes_lib/add.html +++ b/application/admin/view/school/classes/classes_lib/add.html @@ -1,23 +1,23 @@
-
- -
- -
-
+ + + + + +
-
- -
- -
-
+ + + + + +
@@ -43,18 +43,18 @@
-
- -
- - + + + + + + + + + -
-
+ + @@ -64,14 +64,14 @@
- +
- +
@@ -85,7 +85,7 @@
- +
@@ -110,69 +110,67 @@
- +
+ +
- - {$vo} {/foreach} - - + ( 如果选独立位置需填写具体位置信息! ) +
+ + + + +
-
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- +
+ +
+ + +
- +
+ +
- +
-
- +
+
-
-
-
- +
+
+ +
+ +
@@ -194,7 +192,7 @@
- +
@@ -216,12 +214,12 @@ -
- -
- -
-
+ + + + + +
@@ -270,12 +268,12 @@
-
- -
- -
-
+ + + + + +
diff --git a/application/admin/view/school/classes/classes_lib/edit.html b/application/admin/view/school/classes/classes_lib/edit.html index 7857c04..dc4c8b6 100644 --- a/application/admin/view/school/classes/classes_lib/edit.html +++ b/application/admin/view/school/classes/classes_lib/edit.html @@ -1,23 +1,23 @@ -
- -
- -
-
+ + + + + +
-
- -
- -
-
+ + + + + +
@@ -44,18 +44,18 @@
-
- -
- - + + + + + + + + + -
-
+ + @@ -65,14 +65,14 @@
- +
- +
@@ -86,7 +86,7 @@
- +
@@ -111,69 +111,70 @@
- +
+ + + + +
- - {$vo} {/foreach} - - + ( 如果选独立位置需填写具体位置信息! ) +
+ + + + +
-
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- +
+ +
+ + +
- +
+ +
- +
-
- +
+
-
-
-
- +
+
+
+ + +
@@ -195,7 +196,7 @@
- +
@@ -204,12 +205,12 @@
-
- -
- -
-
+ + + + + +
@@ -268,12 +269,12 @@
-
- -
- -
-
+ + + + + +
diff --git a/application/admin/view/school/search_city/add.html b/application/admin/view/school/search_city/add.html new file mode 100644 index 0000000..3d68e6f --- /dev/null +++ b/application/admin/view/school/search_city/add.html @@ -0,0 +1,20 @@ + + +
+ +
+
+ +
+ + + +
+
+ + diff --git a/application/admin/view/school/search_city/edit.html b/application/admin/view/school/search_city/edit.html new file mode 100644 index 0000000..4c8119d --- /dev/null +++ b/application/admin/view/school/search_city/edit.html @@ -0,0 +1,20 @@ +
+ +
+ +
+
+ +
+ + + +
+
+ +
diff --git a/application/admin/view/school/search_city/index.html b/application/admin/view/school/search_city/index.html new file mode 100644 index 0000000..fb7a2de --- /dev/null +++ b/application/admin/view/school/search_city/index.html @@ -0,0 +1,29 @@ +
+ {:build_heading()} + + +
diff --git a/application/admin/view/school/search_city/recyclebin.html b/application/admin/view/school/search_city/recyclebin.html new file mode 100644 index 0000000..a8094f1 --- /dev/null +++ b/application/admin/view/school/search_city/recyclebin.html @@ -0,0 +1,25 @@ +
+ {:build_heading()} + +
+
+
+ +
+ +
+
+
diff --git a/application/api/controller/school/Order.php b/application/api/controller/school/Order.php index b928c21..2f230de 100644 --- a/application/api/controller/school/Order.php +++ b/application/api/controller/school/Order.php @@ -120,6 +120,30 @@ class Order extends Base } + /** + * @ApiTitle( 预约课时单取消接口) + * @ApiSummary(预约课时单取消接口(已完成的单无法取消)) + * @ApiRoute(/api/school/order/cancel) + * @ApiMethod(POST) + * @ApiParams(name = "order_no", type = "string",required=true,description = "订单号") + * @ApiReturn({ + * + *}) + */ + public function cancel(){ + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + $order_no = $this->request->post('order_no/s', ''); //订单号 + try{ + //当前申请状态 + $res = $this->model->cancel($order_no,$user_id,true,'user',0,true); + }catch (\Throwable $e){ + $this->error($e->getMessage()); + } + $this->success('预约课时取消成功', $res); + } + diff --git a/application/api/controller/school/worker/HourOrder.php b/application/api/controller/school/worker/HourOrder.php index 5d568f8..0f78fb5 100644 --- a/application/api/controller/school/worker/HourOrder.php +++ b/application/api/controller/school/worker/HourOrder.php @@ -107,7 +107,7 @@ class HourOrder extends Base /** - * @ApiTitle( 预约课时单取消接口) + * @ApiTitle( 员工代操作:预约课时单取消接口) * @ApiSummary(预约课时单取消接口(已完成的单无法取消)) * @ApiRoute(/api/school/worker/hour_order/cancel) * @ApiMethod(POST) @@ -135,6 +135,95 @@ class HourOrder extends Base + /** + * @ApiTitle( 员工代操作:预约课时单审核接口) + * @ApiSummary(预约课时单审核接口) + * @ApiRoute(/api/school/worker/hour_order/examine) + * @ApiMethod(POST) + * @ApiParams(name = "order_no", type = "string",required=true,description = "订单号") + * @ApiParams(name = "auth_status", type = "int",required=true,description = "审核状态:1=审核通过,2=审核失败") + * @ApiParams(name = "reason", type = "string",required=false,description = "审核失败理由") + * @ApiReturn({ + * + *}) + */ + public function examine(){ + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + $order_no = $this->request->post('order_no/s', ''); //订单号 + $auth_status = $this->request->post('auth_status/d', ''); //审核状态 + $reason = $this->request->post('reason/s', ''); //审核失败理由 + try{ + //当前申请状态 + $res = $this->model->examine($order_no,$auth_status,$reason,0,true,'user',$user_id,true); + }catch (\Throwable $e){ + $this->error($e->getMessage()); + } + $this->success('预约课时取消成功', $res); + } + + + + + /** + * @ApiTitle( 员工代操作:预约课时单核销完成接口) + * @ApiSummary(预约课时单核销完成接口) + * @ApiRoute(/api/school/worker/hour_order/verification) + * @ApiMethod(POST) + * @ApiParams(name = "order_no", type = "string",required=true,description = "订单号") + * @ApiReturn({ + * + *}) + */ + public function verification(){ + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + $order_no = $this->request->post('order_no/s', ''); //订单号 + try{ + //当前申请状态 + $res = $this->model->verification($order_no,0,true,'user',$user_id,true); + }catch (\Throwable $e){ + $this->error($e->getMessage()); + } + $this->success('预约课时核销成功', $res); + } + + + + + + + /** + * @ApiTitle( 员工代操作:预约课修改课时接口) + * @ApiSummary(预约课修改课时接口) + * @ApiRoute(/api/school/worker/hour_order/update_spec) + * @ApiMethod(POST) + * @ApiParams(name = "order_no", type = "string",required=true,description = "订单号") + * @ApiParams(name = "classes_lib_spec_id", type = "int",required=true,description = "要更换的课时id") + * @ApiReturn({ + * + *}) + */ + public function update_spec(){ + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + $order_no = $this->request->post('order_no/s', ''); //订单号 + $classes_lib_spec_id = $this->request->post('classes_lib_spec_id/d', 0); //审核状态 + try{ + //当前申请状态 + $res = $this->model->updateClassesSpec($order_no,$classes_lib_spec_id,0,true,'user',$user_id,true); + }catch (\Throwable $e){ + $this->error($e->getMessage()); + } + $this->success('预约课时取消成功', $res); + } + + + + /** diff --git a/application/api/controller/school/worker/Order.php b/application/api/controller/school/worker/Order.php index 7c70bba..2152a37 100644 --- a/application/api/controller/school/worker/Order.php +++ b/application/api/controller/school/worker/Order.php @@ -33,7 +33,7 @@ class Order extends Base /** * @ApiTitle( 订单详情) * @ApiSummary(订单详情) - * @ApiRoute(/api/school/order/detail) + * @ApiRoute(/api/school/worker/order/detail) * @ApiMethod(GET) * @ApiParams(name = "id", type = "int",required=true,description = "订单id或订单号") * @ApiReturn({ @@ -62,7 +62,7 @@ class Order extends Base /** * @ApiTitle( 我的订单列表接口) * @ApiSummary(我的订单列表接口) - * @ApiRoute(/api/school/order/order_list) + * @ApiRoute(/api/school/worker/order/order_list) * @ApiMethod(GET) * @ApiParams(name = "keywords", type = "string",required=false,description = "搜索关键字") * @ApiParams(name = "page", type = "string",required=true,description = "页数") @@ -98,11 +98,36 @@ class Order extends Base $this->success('查询成功', $res); } + /** + * @ApiTitle( 员工代操作:课程订单未支付取消接口) + * @ApiSummary(课程订单未支付取消接口(已支付单无法取消,要走售后)) + * @ApiRoute(/api/school/worker/order/cancel) + * @ApiMethod(POST) + * @ApiParams(name = "order_no", type = "string",required=true,description = "订单号") + * @ApiReturn({ + * + *}) + */ + public function cancel(){ + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + $order_no = $this->request->post('order_no/s', ''); //订单号 + try{ + //当前申请状态 + $res = $this->model->cancel($order_no,0,true,'user',$user_id,true); + }catch (\Throwable $e){ + $this->error($e->getMessage()); + } + $this->success('预约课时取消成功', $res); + } + + /** * @ApiTitle( 我的订单数量接口) * @ApiSummary(返回订单各个数量) - * @ApiRoute(/api/school/order/order_count) + * @ApiRoute(/api/school/worker/order/order_count) * @ApiMethod(GET) * @ApiParams(name = "classes_lib_id", type = "int",required=false,description = "课程id") * @ApiReturn({ diff --git a/application/common/model/school/Area.php b/application/common/model/school/Area.php new file mode 100644 index 0000000..71e2186 --- /dev/null +++ b/application/common/model/school/Area.php @@ -0,0 +1,21 @@ +where('classes_lib_id',$classes_lib_id) ->find(); @@ -985,6 +987,103 @@ class Order extends BaseModel //执行课时数更新 // $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 $order; + } + + + + + /**更新订单核销状态 + * @param $order + * @return array|false|\PDOStatement|string|Model + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\ModelNotFoundException + * @throws \think\exception\DbException + */ + public static function updateVerification($order,$oper_id = 0,$oper_type='user'){ + if(is_string($order))$order = self::getHaveVerificationOrder($order); + $order->status = "3";//refund_status + $order->verification_user_id = $oper_id; + $order->verification_type = $oper_type; + $order->finish_time = time(); + $order->save(); + return $order; + } + + + + + + /**得到可核销订单 + * @param $order_no + * @return array|false|\PDOStatement|string|Model + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\ModelNotFoundException + * @throws \think\exception\DbException + */ + public static function getHaveVerificationOrder($order_no){ +// $where = [self::STATUS_NOPAY,self::STATUS_PAYED]; + $order = self::where('order_no|id',$order_no)->where("status","in",['-1',"0"])->find(); + if(!$order)throw new \Exception("不是待核销的订单!"); + + return $order; + } + + + + + /**订单核销 + * @param $order_no + * @param int $user_id + * @param bool $check + * @param bool $trans + * @return bool + * @throws \Exception + */ + public function verification($order_no,$user_id=0,$check=false,$oper_type='user',$oper_id=0,$trans=false){ + //得到可取消订单 + $order = self::getHaveVerificationOrder($order_no); + if($check){ + //用户操作权限检测 + self::checkOptionAuth($order['classes_order_id'],$user_id ?: $oper_id,$oper_type); + } + + //判断逻辑 + if($trans){ + self::beginTrans(); + } + $res = true; + try{ + //事务逻辑 + //更新订单状态 + //如果没有审核,先审核成功再核销 + if($order["status"] == '-1'){ + $order = $this->examine($order_no,'1',"",$user_id,$check,$oper_type,$oper_id); + } + $order = Order::updateVerification($order,$user_id ?: $oper_id,$oper_type); + //插入订单取消日志 + 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_finish_after', $data); + //执行课时数更新 + $res1 = \app\common\model\school\classes\order\Order::statisticsAndUpdateClassesNumber($order['classes_order_id']); + + if($trans){ self::commitTrans(); } @@ -1001,4 +1100,62 @@ class Order extends BaseModel + + /**订单修改课时 + * @param $order_no + * @param int $user_id + * @param bool $check + * @param bool $trans + * @return bool + * @throws \Exception + */ + public function updateClassesSpec($order_no,$classes_lib_spec_id,$user_id=0,$check=false,$oper_type='user',$oper_id=0,$trans=false){ + //得到可取消订单 + $order = self::getHaveUpdateOrder($order_no); + if($check){ + //用户操作权限检测 + self::checkOptionAuth($order['classes_order_id'],$user_id ?: $oper_id,$oper_type); + } + self::checkLibSpec($order['user_id'],$order["classes_lib_id"],$classes_lib_spec_id); + + //判断逻辑 + if($trans){ + self::beginTrans(); + } + $res = true; + try{ + //事务逻辑 + //更新订单状态 + + //课时规格更新 + $order = self::buildLibSpec($order_no,$classes_lib_spec_id); + //插入订单取消日志 + 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_update_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 $order; + } + + + + } diff --git a/application/common/model/school/classes/order/Order.php b/application/common/model/school/classes/order/Order.php index 8f11145..a797377 100644 --- a/application/common/model/school/classes/order/Order.php +++ b/application/common/model/school/classes/order/Order.php @@ -3,6 +3,7 @@ namespace app\common\model\school\classes\order; +use app\admin\model\Admin; use app\common\model\BaseModel; use app\common\model\dyqc\ManystoreShop; use app\common\model\school\classes\ClassesLib; @@ -886,6 +887,7 @@ class Order extends BaseModel $order->total_refundprice = bcsub($order->totalprice,$detail->used_price,2); $order->save(); + //课程下单时已核销人数更新 $lib = $order->lib; if($lib){ @@ -895,23 +897,159 @@ class Order extends BaseModel $specs = $lib->specs; if($specs){ foreach ($specs as $spec){ - // '已核销人数', $spec->verification_num = \app\common\model\school\classes\hourorder\Order::where("classes_lib_spec_id",$spec["id"])->where("status","=","3")->count(); //已报名人数 $spec->sign_num = \app\common\model\school\classes\hourorder\Order::where("classes_lib_spec_id",$spec["id"])->where("status","in",["-1","0"])->count(); - $spec->save(); } } } + //检测订单完成状态 + self::statisticsAndUpdateOrderFinish($order->id); + + return $order; + } + + /** 检测订单完成状态 + * @param $order + * @return void + * @throws \think\Exception + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\ModelNotFoundException + * @throws \think\exception\DbException + */ + public static function statisticsAndUpdateOrderFinish($order){ + if(is_string($order)||is_numeric($order))$order = self::getOrder($order); + $detail = $order->detail; + if(!$detail)throw new \think\Exception("订单信息缺失!"); + //得到当前订单的所有已完成课时订单 + $hourorderOrderCount = \app\common\model\school\classes\hourorder\Order::where("status","=",'3') + ->where("classes_order_id","=",$order["id"]) + ->count(); + //可完成的订单 + if($order["status"] == '3' && (in_array($order["server_status"],['0','6'])) && !$order['finishtime']){ + //判定是否达成完成条件 + //条件:课程课时已全部完成 + if($hourorderOrderCount >= $detail->classes_num){ + //执行订单完成的更新逻辑 + self::updateFinish($order); + } + } + } + + /** 更新订单成已完成 + * @param $order + * @return void + */ + public static function updateFinish($order){ + if(is_string($order)||is_numeric($order))$order = self::getOrder($order); + //更新订单 + $order["status"] = '9'; + $order["finishtime"] = time(); + + $order->save(); + //记录订单日志 + OrderLog::log($order['id'],"课程订单,课时已全部完成",'user',$order['user_id']); + //调用支付成功事件 + $data = ['order' => $order]; + \think\Hook::listen('classes_order_finish_after', $data); + } + + + + + /**得到可取消订单 + * @param $order_no + * @return array|false|\PDOStatement|string|Model + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\ModelNotFoundException + * @throws \think\exception\DbException + */ + public static function getHaveCancelOrder($order_no){ +// $where = [self::STATUS_NOPAY,self::STATUS_PAYED]; + $order = self::where('order_no|id|pay_no|code',$order_no) + ->where("status","in",['0']) + ->find(); + if(!$order)throw new \Exception("只有待支付订单可取消,已支付请走售后申请,已取消请忽略!"); + + return $order; + } + + + /**更新订单取消状态 + * @param $order + * @return array|false|\PDOStatement|string|Model + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\ModelNotFoundException + * @throws \think\exception\DbException + */ + public static function updateCancel($order){ + if(is_string($order))$order = self::getHaveCancelOrder($order); + $order->status = "-3";//refund_status + $order->canceltime = time(); + $order->save(); return $order; } + + + /**订单取消 + * @param $order_no + * @param int $user_id + * @param bool $check + * @param bool $trans + * @return bool + * @throws \Exception + */ + public function cancel($order_no,$user_id=0,$check=false,$oper_type='user',$oper_id=0,$trans=false){ + //得到可取消订单 + $order = self::getHaveCancelOrder($order_no); + if($check){ + //用户操作权限检测 + \app\common\model\school\classes\hourorder\Order::checkOptionAuth($order['id'],$user_id ?: $oper_id,$oper_type); + } + + //判断逻辑 + 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('classes_order_cancel_after', $data); + //执行课时数更新 + $res1 = self::statisticsAndUpdateClassesNumber($order['id']); + + + if($trans){ + self::commitTrans(); + } + }catch (\Exception $e){ + if($trans){ + self::rollbackTrans(); + } + throw new \Exception($e->getMessage()); + } + return $res1; + } + + } diff --git a/application/manystore/controller/school/classes/ClassesLib.php b/application/manystore/controller/school/classes/ClassesLib.php index 65e9122..3da6946 100644 --- a/application/manystore/controller/school/classes/ClassesLib.php +++ b/application/manystore/controller/school/classes/ClassesLib.php @@ -3,6 +3,17 @@ namespace app\manystore\controller\school\classes; use app\common\controller\ManystoreBase; +use app\admin\model\dyqc\ManystoreShop; +use app\common\controller\Backend; +use app\common\model\school\classes\Order; +use app\manystore\model\Manystore; +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; /** * 机构课程库 @@ -18,6 +29,15 @@ class ClassesLib extends ManystoreBase */ protected $model = null; + //不用审核允许修改的字段 + protected $no_auth_fields = ['headimage','images','notice','content',"virtual_num","virtual_collect","underline_price"]; + + //更新数据是否需要触发审核开关 + protected $need_auth = true; + protected $have_auth = false; + + protected $success_auth = false; + public function _initialize() { parent::_initialize(); @@ -68,7 +88,7 @@ class ClassesLib extends ManystoreBase ->paginate($limit); foreach ($list as $row) { - + $row->getRelation('manystore')->visible(['nickname']); $row->getRelation('manystoreshop')->visible(['name','image','address_city','province','city','district','address','address_detail']); $row->getRelation('user')->visible(['nickname','realname','mobile','avatar']); @@ -82,4 +102,308 @@ class ClassesLib extends ManystoreBase return $this->view->fetch(); } + + protected function authClasses(&$params,$row=null){ + //审核失败需填写原因 + if($params["auth_status"] == '2' && empty($params["reason"])){ + $this->error("审核失败需填写原因"); + } + + if($params["auth_status"] == '2'){ + //审核不通过会平台下架 + $params["status"] = '3'; + } + + //更新 + if($row){ + + if($params["auth_status"] != '1' && $row["auth_status"] == '1'){ + $this->error("审核已通过的课程不允许再修改审核状态!"); + } + + if($params["auth_status"] != '0' && $row["auth_status"] == '0'){ + //填写审核时间和审核人 + $params["auth_time"] = time(); + $params["admin_id"] = $this->auth->id; + if($params["auth_status"] == '1'){ + //审核通过 + $this->success_auth = true; + } + } + //审核通过 + if($this->success_auth){ + //如果是平台下架,则更新成正常下架 + if($params["status"] == '3') $params["status"] = '2'; + } + + }else{ + //新增 + } + + } + + protected function no_auth_fields_check($params,$row){ + + foreach ($params as $k=>$v){ + + //说明数值有变动 + //$params[$k] 去掉两端空格 + $params[$k] = trim($v); + + if($row[$k]!=$params[$k]){ + //特殊:如果是上架状态或下架状态也可以修改 + if($k=="status" && ($params[$k]=='1' || $params[$k]=='2')){ + continue; + } + //当修改参数不在允许修改的字段中 + if(!in_array($k,$this->no_auth_fields)){ + + $this->have_auth = true;break; + + } + } + + } + + return $this->have_auth; + + } + + protected function updateCheck($id,$params=[],$row=null){ + if($params && $row){ + + if(!$this->no_auth_fields_check($params,$row)){ + return true; + } + } + + // 课程存在未完成订单则不允许操作 + $order = Order::where("classes_lib_id",$id)->where("status","in","0,3")->find(); + if($order)$this->error("存在正在使用中的课程订单或存在正在售后中的课程订单无法继续操作!"); + // 课程存在售后订单则不允许操作 + } + + + + protected function update_check(&$params,$row=null) + { + + $shop_id = $row["shop_id"]; + $manystore = Manystore::where("shop_id",$shop_id)->find(); + if(!$manystore){ + $this->error("店铺不存在"); + } + $params["manystore_id"] = $manystore["id"]; + + + //验证老师id + $teacher_id = $row['teacher_id']; + $teacher = \app\admin\model\school\classes\Teacher::where("id",$teacher_id)->find(); + if(!$teacher){ + $this->error("老师不存在"); + } + if(!$teacher["user_id"]){ + $this->error("当前老师没有前端用户!请换一个!"); + } + //老师与当前机构id不一致 + if($teacher["manystore_id"] != $manystore["id"]){ + $this->error("当前老师与当前机构不匹配,请换一个老师!"); + } + + + $params["user_id"] = $teacher["user_id"]; + + + //独立地点需传定位信息 + if($params["address_type"] == "2"){ + if(empty($params["address_city"]) + || empty($params["province"]) + || empty($params["city"]) + || empty($params["district"]) + || empty($params["longitude"]) + || empty($params["latitude"])) $this->error("独立地点需传定位信息"); + + } + + + //特有认证判断 +// $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){ + //判断更新的变动数据 + $this->no_auth_fields_check($params,$row); + + if($this->have_auth){ + $params['status'] = "3"; + $params['auth_status'] = "0"; + } + } + + $this->updateCheck($row->id,$params,$row); + }else{ + //新增 + $params["add_type"] = '2'; + $params["add_id"] = $this->auth->id; + } + + } + + + + + /** + * 添加 + * + * @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', '')); + } + $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/lang/zh-cn/school/classes/classes_lib.php b/application/manystore/lang/zh-cn/school/classes/classes_lib.php index 7c2789e..c65923a 100644 --- a/application/manystore/lang/zh-cn/school/classes/classes_lib.php +++ b/application/manystore/lang/zh-cn/school/classes/classes_lib.php @@ -41,7 +41,7 @@ return [ 'Status' => '状态', 'Status 1' => '上架', 'Status 2' => '下架', - 'Status 3' => '平台下架', + 'Status 3' => '(审核中课程)平台下架', 'Auth_status' => '审核状态', 'Auth_status 0' => '待审核', 'Auth_status 1' => '审核通过', diff --git a/application/manystore/model/school/classes/ClassesLib.php b/application/manystore/model/school/classes/ClassesLib.php index f91808e..4dd8950 100644 --- a/application/manystore/model/school/classes/ClassesLib.php +++ b/application/manystore/model/school/classes/ClassesLib.php @@ -34,9 +34,28 @@ class ClassesLib extends Model 'recommend_text', 'hot_text', 'new_text', - 'selfhot_text' + 'selfhot_text', + 'classes_cate_title', + 'classes_label_title', ]; - + + public function getClassesCateTitleAttr($value, $data) + { + $classes_cate_ids = (isset($data['classes_cate_ids']) ? $data['classes_cate_ids'] : ''); + if(!$classes_cate_ids) return ''; + //$classes_cate_ids 查询分类表 names 已逗号拼接返回 + $classes_cate_title = Cate::where('id','in',$classes_cate_ids)->column('name'); + return implode(',',$classes_cate_title); + } + + public function getClassesLabelTitleAttr($value, $data) + { + $classes_cate_ids = (isset($data['classes_label_ids']) ? $data['classes_label_ids'] : ''); + if(!$classes_cate_ids) return ''; + //$classes_cate_ids 查询分类表 names 已逗号拼接返回 + $classes_cate_title = Label::where('id','in',$classes_cate_ids)->column('name'); + return implode(',',$classes_cate_title); + } protected static function init() { diff --git a/application/manystore/view/school/classes/classes_lib/add.html b/application/manystore/view/school/classes/classes_lib/add.html index 25f5f37..35e3ad9 100644 --- a/application/manystore/view/school/classes/classes_lib/add.html +++ b/application/manystore/view/school/classes/classes_lib/add.html @@ -1,66 +1,79 @@
+ + + + + + + + + + + + + + + + + +
- +
- -
-
-
- -
- +
+
- +
- +
- +
-
- -
- - + + + + + + + + + -
-
-
- -
- -
-
+ + + + + + + +
- +
- +
- +
@@ -72,9 +85,9 @@
- +
- +
@@ -85,10 +98,10 @@
- + @@ -97,69 +110,67 @@
- +
+ +
- - {$vo} {/foreach} - + ( 如果选独立位置需填写具体位置信息! ) +
+
+
+ + + +
+
+ +
+
+ +
+ + + +
-
-
- -
-
+
+ +
+
+ +
+
-
-
- -
- +
+ +
+ +
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- +
+ +
+ +
+ +
+ +
+
+ +
@@ -181,7 +192,7 @@
- +
@@ -190,12 +201,25 @@
-
- -
- -
-
+ + + + + + + + + + + + + + + + + + +
@@ -217,11 +241,16 @@
- +
- {foreach name="statusList" item="vo"} - - {/foreach} + {foreach name="statusList" item="vo"} + + {/foreach}
@@ -229,82 +258,80 @@
- +
- {foreach name="authStatusList" item="vo"} - - {/foreach} + {foreach name="authStatusList" item="vo"} + + {/foreach}
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- - + -
-
-
- -
- - -
-
-
- -
- - -
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
- + diff --git a/application/manystore/view/school/classes/classes_lib/edit.html b/application/manystore/view/school/classes/classes_lib/edit.html index 77bdd48..5d0b2b8 100644 --- a/application/manystore/view/school/classes/classes_lib/edit.html +++ b/application/manystore/view/school/classes/classes_lib/edit.html @@ -1,66 +1,80 @@ + + + + + +
- +
- +
+ + + + + + +
- +
- +
+
- +
- +
- +
-
- -
- - + + + + + + + + + -
-
-
- -
- -
-
+ + + + + + + +
- +
- +
- +
@@ -72,9 +86,9 @@
- +
- +
@@ -85,10 +99,10 @@
- + @@ -97,69 +111,70 @@
- +
+ + + + +
- - {$vo} {/foreach} - + ( 如果选独立位置需填写具体位置信息! ) +
+
+
+ + + +
+
+ +
+
+ +
+ + + +
+
+
+ +
+
+ +
+
+
+
+ +
+ +
+
+
+ +
+ +
+ +
+ +
-
- -
-
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
+ + +
@@ -181,7 +196,7 @@
- +
@@ -190,12 +205,12 @@
-
- -
- -
-
+ + + + + +
@@ -214,14 +229,29 @@
+ +
+ +
+ +
+
+ + +
- +
- {foreach name="statusList" item="vo"} - - {/foreach} + {foreach name="statusList" item="vo"} + + {/foreach}
@@ -229,87 +259,85 @@
- +
- {foreach name="authStatusList" item="vo"} - - {/foreach} + {foreach name="authStatusList" item="vo"} + + {/foreach}
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- - + + + + + + + + + + + + + + + + + + + + + -
-
-
- -
- - + + + + + -
-
-
- -
- - + + + + + -
-
+ + + + + + + + + + + + + + + + + + + +
- +
+ + + +