From 839555dd0f707423f8155f5710042c16a336588c Mon Sep 17 00:00:00 2001 From: 15090180611 <215509543@qq.com> Date: Fri, 13 Dec 2024 18:37:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A5=E9=A9=BB=E6=9C=BA=E6=9E=84=E5=AE=8C?= =?UTF-8?q?=E6=88=90,=E8=87=AA=E5=8A=A8=E5=B0=86=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E4=BA=BA=E7=BB=91=E5=AE=9A=E4=B8=BA=E8=AF=A5=E6=9C=BA=E6=9E=84?= =?UTF-8?q?=E7=9A=84=E8=80=81=E5=B8=88=20=E5=95=86=E5=AE=B6,=E5=8F=AF?= =?UTF-8?q?=E4=B8=BB=E5=8A=A8=E5=8F=91=E8=B5=B7,=E5=B7=B2=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E8=AE=A2=E5=8D=95=E7=9A=84=E9=80=80=E6=AC=BE=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=20=E8=AF=BE=E7=A8=8B=E6=93=8D=E4=BD=9C=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=EF=BC=88=E5=A2=9E=E5=8A=A0=EF=BC=8C=E5=88=A0=E9=99=A4?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=94=B9=EF=BC=89=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=B8=80=E4=BA=9Bbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/manystore/Index.php | 37 +- .../controller/school/classes/ClassesLib.php | 8 + .../controller/school/classes/Evaluate.php | 213 ++++++++- .../controller/school/classes/order/Order.php | 2 +- .../admin/lang/zh-cn/manystore/index.php | 18 + .../lang/zh-cn/school/classes/classes_lib.php | 6 +- .../lang/zh-cn/school/classes/evaluate.php | 13 +- .../admin/model/school/classes/Evaluate.php | 10 +- .../admin/validate/manystore/Index.php | 6 +- .../admin/view/manystore/index/add.html | 176 ++++++-- .../admin/view/manystore/index/edit.html | 176 ++++++-- .../school/classes/classes_lib/index.html | 4 +- .../view/school/classes/evaluate/add.html | 69 ++- .../view/school/classes/evaluate/edit.html | 79 ++-- .../service_order/shop_confirmation.html | 4 +- application/api/controller/Index.php | 9 +- application/api/controller/User.php | 6 + application/api/controller/school/Classes.php | 3 + .../api/controller/school/worker/Classes.php | 222 +++++++++ .../controller/school/worker/ServiceOrder.php | 6 + application/common/hooks.php | 3 + application/common/library/Sqlscript.php | 8 +- .../common/listener/manystore/ShopHook.php | 4 + application/common/listener/user/UserHook.php | 13 +- application/common/model/BaseModel.php | 4 +- .../common/model/dyqc/ManystoreShop.php | 103 ++++- .../model/school/classes/ClassesLib.php | 424 +++++++++++++++++- .../model/school/classes/ClassesSpec.php | 3 +- .../common/model/school/classes/Evaluate.php | 11 +- .../model/school/classes/hourorder/Order.php | 19 +- .../model/school/classes/order/Order.php | 5 +- .../school/classes/order/ServiceOrder.php | 14 +- application/extra/upload.php | 4 +- .../manystore/controller/Dashboard.php | 3 + .../manystore/controller/general/Profile.php | 11 +- .../controller/school/classes/ClassesLib.php | 8 + .../controller/school/classes/Evaluate.php | 215 ++++++++- .../controller/school/classes/order/Order.php | 37 +- .../manystore/lang/zh-cn/general/profile.php | 18 +- .../lang/zh-cn/school/classes/classes_lib.php | 2 +- .../lang/zh-cn/school/classes/evaluate.php | 12 +- application/manystore/model/ManystoreShop.php | 27 ++ application/manystore/validate/Manystore.php | 12 +- .../manystore/view/dashboard/index.html | 2 + .../manystore/view/general/profile/index.html | 173 ++++++- .../school/classes/classes_lib/index.html | 5 +- .../view/school/classes/evaluate/index.html | 24 +- .../classes/order/order/after_sales.html | 21 + .../service_order/shop_confirmation.html | 4 +- public/assets/js/backend/manystore/index.js | 89 +++- .../js/backend/school/classes/classes_lib.js | 25 +- .../js/backend/school/classes/evaluate.js | 63 ++- .../js/backend/school/classes/order/order.js | 21 +- .../school/classes/order/service_order.js | 19 + .../js/backend/school/classes/teacher.js | 51 ++- public/assets/js/manystore/general/profile.js | 73 +++ .../manystore/school/classes/classes_lib.js | 28 +- .../js/manystore/school/classes/evaluate.js | 73 +-- .../manystore/school/classes/order/order.js | 43 ++ .../school/classes/order/service_order.js | 17 + .../js/manystore/school/classes/teacher.js | 54 ++- 61 files changed, 2530 insertions(+), 282 deletions(-) create mode 100644 application/api/controller/school/worker/Classes.php create mode 100644 application/manystore/view/school/classes/order/order/after_sales.html diff --git a/application/admin/controller/manystore/Index.php b/application/admin/controller/manystore/Index.php index 7da7b55..a32b36a 100644 --- a/application/admin/controller/manystore/Index.php +++ b/application/admin/controller/manystore/Index.php @@ -2,7 +2,11 @@ namespace app\admin\controller\manystore; +use app\admin\model\school\classes\ClassesLib; +use app\admin\model\school\classes\Teacher; +use app\admin\model\school\classes\Verification; use app\admin\model\User; +use app\common\model\manystore\Shop; use app\common\model\school\classes\Order; use app\manystore\model\Manystore; @@ -146,6 +150,12 @@ class Index extends Backend ->order($sort, $order) ->limit($offset, $limit) ->select(); + // $this->view->assign('check_full',(new \app\common\model\dyqc\ManystoreShop)->checkFull($shop_info->id)); + foreach ($list as $k => &$v){ + + $v["check_full"] = (new \app\common\model\dyqc\ManystoreShop)->checkFull($v["shop"]["id"]); + } + $result = array("total" => $total, "rows" => $list); @@ -231,6 +241,20 @@ class Index extends Backend $order = Order::where("manystore_id",$id)->where("status","in","0,3")->find(); if($order)throw new \Exception("存在正在使用中的课程订单或存在正在售后中的课程订单无法继续操作!"); // 课程存在售后订单则不允许操作 + //有课程不允许删 + $classesLib = ClassesLib::where("manystore_id",$id)->find(); + if($classesLib)throw new \Exception("请先删除课程后再删除机构!"); + //有老师不允许删 + $teacher = Teacher::where("manystore_id",$id)->find(); + if($teacher)throw new \Exception("请先删除老师后再删除机构!"); + //有核销员不允许删 + $verification = Verification::where("manystore_id",$id)->find(); + if($verification)throw new \Exception("请先删除核销员后再删除机构!"); + $shop_id = Manystore::where("id",$id)->value("shop_id"); + //有授权用户不允许删 + $auth = \app\common\model\manystore\UserAuth::where("shop_id",$shop_id)->find(); + if($auth)throw new \Exception("请先删除授权用户后再删除机构!"); + } @@ -245,7 +269,11 @@ class Index extends Backend if(!$shop["user_id"])throw new \Exception("认证用户不存在!"); $user = User::get($shop["user_id"]); if(!$user) throw new \Exception("认证用户不存在!"); - if($shop["address_city"] && !$shop["province"])throw new Exception("请选择所在城市"); + if($shop["address_city"] && !$shop["district"])throw new Exception("请选择所在城市"); + + //账号昵称和头像取用户的 + $params["nickname"] = $user["realname"] ?: $user["nickname"]; + $params["avatar"] = $user["avatar"] ?:"/assets/img/avatar.png"; @@ -340,7 +368,7 @@ class Index extends Backend $params['shop_id'] = $this->shopModel->id; $params['salt'] = Random::alnum(); $params['password'] = md5(md5($params['password']) . $params['salt']); - $params['avatar'] = '/assets/img/avatar.png'; //设置新管理员默认头像。 + if(empty($params['avatar']))$params['avatar'] = '/assets/img/avatar.png'; //设置新管理员默认头像。 $params['is_main'] = 1; $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); @@ -485,6 +513,11 @@ class Index extends Backend } $this->view->assign("row", $row); $this->view->assign("shop", $shop_info); + $this->view->assign('check_full',(new \app\common\model\dyqc\ManystoreShop)->checkFull($shop_info->id)); + $this->view->assign('check_full_msg',(new \app\common\model\dyqc\ManystoreShop)->checkFullMsg($shop_info->id)); + + + $this->view->assign("groupids", $groupids); return $this->view->fetch(); } diff --git a/application/admin/controller/school/classes/ClassesLib.php b/application/admin/controller/school/classes/ClassesLib.php index 6ae2ec3..94a47cf 100644 --- a/application/admin/controller/school/classes/ClassesLib.php +++ b/application/admin/controller/school/classes/ClassesLib.php @@ -4,6 +4,7 @@ namespace app\admin\controller\school\classes; use app\admin\model\dyqc\ManystoreShop; use app\common\controller\Backend; +use app\common\model\school\classes\lib\Spec; use app\common\model\school\classes\Order; use app\manystore\model\Manystore; use think\Db; @@ -211,6 +212,9 @@ class ClassesLib extends Backend $order = Order::where("classes_lib_id",$id)->where("status","in","0,3")->find(); if($order)$this->error("存在正在使用中的课程订单或存在正在售后中的课程订单无法继续操作!"); // 课程存在售后订单则不允许操作 + + + } @@ -571,6 +575,10 @@ class ClassesLib extends Backend Db::startTrans(); try { foreach ($list as $item) { + //删除课程规格 + Spec::where("classes_lib_id",$item->id)->delete(); + + $count += $item->delete(); } Db::commit(); diff --git a/application/admin/controller/school/classes/Evaluate.php b/application/admin/controller/school/classes/Evaluate.php index 79413d4..69b82ca 100644 --- a/application/admin/controller/school/classes/Evaluate.php +++ b/application/admin/controller/school/classes/Evaluate.php @@ -3,6 +3,16 @@ namespace app\admin\controller\school\classes; use app\common\controller\Backend; +use app\common\model\manystore\UserAuth; +use app\common\model\User; +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; /** * 课程反馈管理 @@ -19,7 +29,7 @@ class Evaluate extends Backend protected $model = null; protected $qSwitch = true; - protected $qFields = ["user_id","classes_lib_id","classes_order_id","manystore_id","shop_id","teacher_id"]; + protected $qFields = ["user_id","classes_lib_id","classes_order_id","manystore_id","shop_id","teacher_id","image","nickname"]; public function _initialize() { @@ -78,4 +88,205 @@ class Evaluate extends Backend return $this->view->fetch(); } + + + protected function updateCheck($id,$params=[],$row=null){ + + // 课程存在售后订单则不允许操作 + } + + protected function update_after(&$row) + { + //重新统计总评分 + \app\common\model\school\classes\Evaluate::evaluateStatistics($row["id"]); + if($row["classes_order_id"]){ + $order = \app\common\model\school\classes\order\Order::get($row["classes_order_id"]); + if($order){ + if(!$order["classes_evaluate_id"])$order->save(["classes_evaluate_id"=>$row["classes_order_id"]]); + } + } + } + + + 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("用户不存在"); +// } + $params["classes_star"] = bcdiv($params["classes_star"],10,1); + $params["teacher_star"] = bcdiv($params["teacher_star"],10,1); + $params["shop_star"] = bcdiv($params["shop_star"],10,1); + //修改 + if($row){ + + }else{ + //新增 + + } + + + + + + + + $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); + $this->update_after($this->model); + 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); + $this->update_after($row); + 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/order/Order.php b/application/admin/controller/school/classes/order/Order.php index c43a9ed..447277a 100644 --- a/application/admin/controller/school/classes/order/Order.php +++ b/application/admin/controller/school/classes/order/Order.php @@ -66,7 +66,7 @@ class Order extends Backend $row->getRelation('user')->visible(['nickname','realname','mobile','avatar']); $row->getRelation('shop')->visible(['name','image','address_city','province','city','district','address','address_detail']); $row->getRelation('lib')->visible(['title','headimage']); - $row->getRelation('detail')->visible(['title','headimage',"feel"]); + $row->getRelation('detail')->visible(['title','headimage',"feel","teacher_id"]); $row->getRelation('admin')->visible(['nickname','avatar']); } diff --git a/application/admin/lang/zh-cn/manystore/index.php b/application/admin/lang/zh-cn/manystore/index.php index 713b15d..4698ed7 100644 --- a/application/admin/lang/zh-cn/manystore/index.php +++ b/application/admin/lang/zh-cn/manystore/index.php @@ -9,6 +9,7 @@ return [ 'Please input correct nickname' => '昵称仅支持输入中文、英文字母(大小写)、数字、下划线', 'Please input length nickname' => '昵称请最多填写10个字符', 'Loss_ratio' => '课程损耗比(百分制)', + "Login successful" => '机构后台已自动登录成功!', 'user_id' => '申请用户', 'Logo' => 'Logo', @@ -51,4 +52,21 @@ return [ 'Type 1' => '个人认证', 'Type 2' => '机构认证', 'Desc' => '申请备注', + + "Establish_time" => '成立时间', + "People" => '员工人数', + "Legal_entity" => '法人姓名', + "Gender" => '性别', + "Nation" => '民族', + "Out_look" => '政治面貌', + "Birthtime" => '出生日期', + "Native_place" => '籍贯', + "Card_number" => '身份证号码', + "Diploma" => '学历', + "Post" => '职务', + "Social_position" => '社会职务', + //Male'), '0'=>__('Female' + 'Male' => '男', + 'Female' => '女', + ]; 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 447c165..ef9bcd5 100644 --- a/application/admin/lang/zh-cn/school/classes/classes_lib.php +++ b/application/admin/lang/zh-cn/school/classes/classes_lib.php @@ -2,7 +2,7 @@ return [ 'Manystore_id' => '机构账号id', - 'Shop_id' => '机构店铺id', + 'Shop_id' => '机构id', 'User_id' => '主讲师用户id', 'Classes_cate_ids' => '标签', 'Classes_label_ids' => '热门', @@ -79,8 +79,8 @@ return [ 'Shop.province' => '省编号', 'Shop.city' => '市编号', 'Shop.district' => '县区编号', - 'Shop.address' => '店铺地址', - 'Shop.address_detail' => '店铺详细地址', + 'Shop.address' => '机构地址', + 'Shop.address_detail' => '机构详细地址', 'User.nickname' => '昵称', 'User.realname' => '真实姓名', 'User.mobile' => '手机号', diff --git a/application/admin/lang/zh-cn/school/classes/evaluate.php b/application/admin/lang/zh-cn/school/classes/evaluate.php index 2824325..909256c 100644 --- a/application/admin/lang/zh-cn/school/classes/evaluate.php +++ b/application/admin/lang/zh-cn/school/classes/evaluate.php @@ -1,12 +1,13 @@ '评价用户id', - 'Classes_lib_id' => '课程id', - 'Classes_order_id' => '课程订单id', - 'Manystore_id' => '机构账号id', - 'Shop_id' => '机构店铺id', - 'Teacher_id' => '老师id', + 'User_id' => '评价用户', + 'Add' => '添加虚拟反馈', + 'Classes_lib_id' => '课程', + 'Classes_order_id' => '课程订单', + 'Manystore_id' => '机构账号', + 'Shop_id' => '机构店铺', + 'Teacher_id' => '老师', 'Image' => '评价人头像', 'Nickname' => '评价人昵称', 'Classes_star' => '课程评分', diff --git a/application/admin/model/school/classes/Evaluate.php b/application/admin/model/school/classes/Evaluate.php index 84e161f..037c0fc 100644 --- a/application/admin/model/school/classes/Evaluate.php +++ b/application/admin/model/school/classes/Evaluate.php @@ -62,6 +62,12 @@ class Evaluate extends Model } + protected function setEvaluateTimeAttr($value) + { + return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); + } + + public function getStatusTextAttr($value, $data) { $value = $value ? $value : (isset($data['status']) ? $data['status'] : ''); @@ -77,10 +83,6 @@ class Evaluate extends Model return isset($list[$value]) ? $list[$value] : ''; } - protected function setEvaluateTimeAttr($value) - { - return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); - } public function user() diff --git a/application/admin/validate/manystore/Index.php b/application/admin/validate/manystore/Index.php index 4552495..67cec26 100644 --- a/application/admin/validate/manystore/Index.php +++ b/application/admin/validate/manystore/Index.php @@ -33,15 +33,15 @@ class Index extends Validate * 验证场景 */ protected $scene = [ - 'add' => ['username', 'email', 'nickname', 'password'], - 'edit' => ['email', 'nickname', 'password'], + 'add' => ['username', 'email', 'password'], + 'edit' => ['email', 'password'], ]; public function __construct(array $rules = [], $message = [], $field = []) { $this->field = [ 'username' => __('Username'), - 'nickname' => __('Nickname'), +// 'nickname' => __('Nickname'), 'password' => __('Password'), 'email' => __('Email'), ]; diff --git a/application/admin/view/manystore/index/add.html b/application/admin/view/manystore/index/add.html index 1d870b6..7e786cb 100644 --- a/application/admin/view/manystore/index/add.html +++ b/application/admin/view/manystore/index/add.html @@ -23,12 +23,12 @@ -
- -
- -
-
+ + + + + +
@@ -175,31 +175,6 @@
-
- - -
- -
- -
-
-
- -
-
- -
- - -
- -
-
    -
    -
    - -
    @@ -241,6 +216,145 @@
    + + +
    + + +
    + +
    + +
    +
    +
    + +
    +
    + +
    + + +
    + +
    +
      +
      +
      + + +
      + +
      + +
      +
      + + +
      + +
      + +
      +
      + +
      + +
      + +
      +
      + + + + + + +
      +
      + + +
      +
      + +
      + {:build_radios('shop[gender]', ['1'=>__('Male'), '0'=>__('Female')], 1)} +
      +
      + + +
      + +
      + +
      +
      + + + +
      + +
      + +
      +
      + + + + +
      + +
      + +
      +
      + + + +
      + +
      + +
      +
      + + +
      + +
      + +
      +
      + + +
      + +
      + +
      +
      + + +
      + +
      + +
      +
      + +
      + +
      + +
      +
      + + + + + + +
      diff --git a/application/admin/view/manystore/index/edit.html b/application/admin/view/manystore/index/edit.html index 38bfc94..f839192 100644 --- a/application/admin/view/manystore/index/edit.html +++ b/application/admin/view/manystore/index/edit.html @@ -23,12 +23,12 @@
      -
      - -
      - -
      -
      + + + + + +
      @@ -80,6 +80,10 @@
      + + {$check_full_msg} + +
      @@ -186,32 +190,6 @@
      -
      - -
      - -
      - -
      -
      -
      - -
      -
      - -
      - - -
      - -
      -
        -
        -
        - - -
        - @@ -256,6 +234,140 @@
        + + +
        + +
        + +
        + +
        +
        +
        + +
        +
        + +
        + + +
        + +
        +
          +
          +
          + + +
          + +
          + +
          +
          + + +
          + +
          + +
          +
          + + + +
          + +
          + +
          +
          + + + + + + +
          +
          + +
          + +
          + +
          + {:build_radios('shop[gender]', ['1'=>__('Male'), '0'=>__('Female')], $shop['gender'])} +
          +
          + + +
          + +
          + +
          +
          + + +
          + +
          + +
          +
          + + + +
          + +
          + +
          +
          + +
          + +
          + +
          +
          + + + +
          + +
          + +
          +
          + + +
          + +
          + +
          +
          + + +
          + +
          + +
          +
          + + +
          + +
          + +
          +
          + + +
          diff --git a/application/admin/view/school/classes/classes_lib/index.html b/application/admin/view/school/classes/classes_lib/index.html index 30b1ce6..493811b 100644 --- a/application/admin/view/school/classes/classes_lib/index.html +++ b/application/admin/view/school/classes/classes_lib/index.html @@ -20,10 +20,10 @@ - + {:__('Add')} - {:__('Add')} + {:__('Edit')} {:__('Delete')} diff --git a/application/admin/view/school/classes/evaluate/add.html b/application/admin/view/school/classes/evaluate/add.html index 7b90d3b..25e5131 100644 --- a/application/admin/view/school/classes/evaluate/add.html +++ b/application/admin/view/school/classes/evaluate/add.html @@ -1,21 +1,39 @@
          +
          - +
          - + +
          +
          +
          + +
          +
          - +
          + + +
          + +
          + + (虚拟反馈则此项无需填写) +
          +
          +
          - + + (虚拟反馈则此项无需填写)
          @@ -24,23 +42,13 @@ -
          - -
          - -
          -
          -
          - -
          - -
          -
          + +
          - +
          @@ -53,27 +61,44 @@
          - +
          + + + +
          - +
          - + + + + (5-50 对应 0.5星-5.0星)
          - + + + + (5-50 对应 0.5星-5.0星)
          - + + + + + (5-50 对应 0.5星-5.0星)
          + + +
          diff --git a/application/admin/view/school/classes/evaluate/edit.html b/application/admin/view/school/classes/evaluate/edit.html index dab0b5f..386614a 100644 --- a/application/admin/view/school/classes/evaluate/edit.html +++ b/application/admin/view/school/classes/evaluate/edit.html @@ -1,41 +1,50 @@ -
          - -
          - -
          -
          -
          - -
          - -
          -
          -
          - -
          - -
          -
          -
          - -
          - -
          -
          +
          - +
          - +
          + + +
          + +
          + +
          +
          + +
          + +
          + + (虚拟反馈则此项无需填写) +
          +
          + + +
          + +
          + + (虚拟反馈则此项无需填写) +
          +
          + + + + + + +
          @@ -57,21 +66,31 @@
          - +
          - + + + + (5-50 对应 0.5星-5.0星)
          - + + + + (5-50 对应 0.5星-5.0星)
          - + + + + + (5-50 对应 0.5星-5.0星)
          diff --git a/application/admin/view/school/classes/order/service_order/shop_confirmation.html b/application/admin/view/school/classes/order/service_order/shop_confirmation.html index ad84362..3b1972b 100644 --- a/application/admin/view/school/classes/order/service_order/shop_confirmation.html +++ b/application/admin/view/school/classes/order/service_order/shop_confirmation.html @@ -21,8 +21,8 @@
          - - ( 当前订单损耗比为 {$row.loss_proportion|htmlentities}% | 忽略损耗应退全额为 {$row.auto_price|htmlentities} | 退款金额不能超过订单应退全额 ) + + ( 当前订单损耗比为 {$row.loss_proportion|htmlentities}% | 忽略损耗应退全额为 {$row.auto_price|htmlentities} [若为0说明课时已用完或计算应退金额小于0.01,请自行决定是否退全款] | 退款金额不能超过订单应退全额{$row.sub_refundprice|htmlentities} )
          diff --git a/application/api/controller/Index.php b/application/api/controller/Index.php index 993926a..d0c9f37 100644 --- a/application/api/controller/Index.php +++ b/application/api/controller/Index.php @@ -6,6 +6,7 @@ use app\common\controller\Api; use app\common\library\Sqlscript; use app\common\library\Virtual; use app\common\model\school\Area; +use app\common\model\school\classes\order\ServiceOrder; use app\common\model\style\HomeImages; use think\Db; use think\exception\PDOException; @@ -26,6 +27,8 @@ class Index extends Api { Db::startTrans(); try { +// $da = ServiceOrder::getCost("dgadasdasdsds12343","2024121214396382520","aaaaa",$param=[],true); +// var_dump($da); Sqlscript::importClasses(1,1000); Db::commit(); } catch (PDOException|\Exception $e) { @@ -37,7 +40,7 @@ class Index extends Api /** * 各种协议文章 - * @ApiSummary(about_us 关于夜校 entry_agreement 入驻协议 privacy 隐私协议) + * @ApiSummary(about_us 关于夜校 entry_agreement 入驻协议 privacy 隐私协议 user_protocol 用户协议) * @ApiMethod (GET) */ public function agreement() @@ -47,6 +50,10 @@ class Index extends Api 'about_us' => config("site.about_us"), 'entry_agreement' => config("site.entry_agreement"), "privacy"=> config("site.privacy"), + "user_protocol"=> config("site.user_protocol"), + 'entry_agreement_file' => config("site.entry_agreement_file"), + "privacy_file"=> config("site.privacy_file"), + "user_protocol_file"=> config("site.user_protocol_file"), ]; $this->success(__('查询成功'), $data); diff --git a/application/api/controller/User.php b/application/api/controller/User.php index 50ed9f3..aaba952 100644 --- a/application/api/controller/User.php +++ b/application/api/controller/User.php @@ -343,6 +343,12 @@ class User extends Api if(in_array('birthday', $update_fields))$user->birthday = $birthday; if(in_array('work', $update_fields))$user->work = $work; $user->save(); + //调用事件 + $datas = ['user' => $user]; + \think\Hook::listen('user_update_after', $datas); + + + $this->success(); } diff --git a/application/api/controller/school/Classes.php b/application/api/controller/school/Classes.php index 4a055ba..974d22b 100644 --- a/application/api/controller/school/Classes.php +++ b/application/api/controller/school/Classes.php @@ -330,6 +330,7 @@ class Classes extends Base * @ApiParams(name = "nearby", type = "string",required=false,description = "限制最大搜索距离(米)") * @ApiParams(name = "latitude", type = "string",required=false,description = "latitude") * @ApiParams(name = "longitude", type = "string",required=false,description = "longitude") + * @ApiParams(name = "auth_status", type = "string",required=false,description = "审核状态:-1=不计入条件 ,0=待审核,1=审核通过,2=审核失败") * @ApiReturn({ * *}) @@ -380,6 +381,8 @@ class Classes extends Base $params["start_time"] = $this->request->get('start_time/d', ''); //主讲师用户id $params["end_time"] = $this->request->get('end_time/d', ''); //机构店铺id + $params["auth_status"] = $this->request->get('auth_status/d', '-1'); //机构店铺id + // $type = $this->request->get('type/s', ''); //筛选学员和教练单 diff --git a/application/api/controller/school/worker/Classes.php b/application/api/controller/school/worker/Classes.php new file mode 100644 index 0000000..83e4603 --- /dev/null +++ b/application/api/controller/school/worker/Classes.php @@ -0,0 +1,222 @@ +model = new ClassesLib; + parent::_initialize(); + + //判断登录用户是否是员工 'add','edit','del' + } + + + /** + * @ApiTitle(员工课程添加) + * @ApiSummary(员工课程添加) + * @ApiMethod(POST) + * @ApiParams(name = "classes_num", type = "int",required=true,description = "核销次数") + * @ApiParams(name = "status", type = "string",required=true,description = "上架状态:1=上架,2=下架,3=平台下架") + * @ApiParams(name = "teacher_id", type = "int",required=true,description = "老师id") + * @ApiParams(name = "classes_type", type = "string",required=true,description = "课程类型") + * @ApiParams(name = "classes_cate_ids", type = "string",required=true,description = "课程标签ids 多值逗号拼接") + * @ApiParams(name = "classes_label_ids", type = "string",required=true,description = "课程热门标签") + * @ApiParams(name = "self_label_tag", type = "string",required=true,description = "机构热门标签:多值逗号拼接") + * @ApiParams(name = "title", type = "string",required=true,description = "课程标题") + * @ApiParams(name = "headimage", type = "string",required=true,description = "课程头图") + * @ApiParams(name = "images", type = "string",required=true,description = "课程轮播图多值逗号拼接") + * @ApiParams(name = "type", type = "string",required=true,description = "地点类型:out=户外,in=室内") + * @ApiParams(name = "spec", type = "string",required=true,description = "课时多规格:[{'id':665,'classes_lib_id':570,'name':'xxxxx','limit_num':100,'status':'1','weigh':665,'time':'2024\/12\/12 19:00 - 2024\/12\/12 20:00'}] ") + * @ApiParams(name = "address_type", type = "string",required=true,description = "地址类型:1=按机构,2=独立位置") + * @ApiParams(name = "province", type = "string",required=false,description = "省编号") + * @ApiParams(name = "city", type = "string",required=false,description = "市编号") + * @ApiParams(name = "district", type = "string",required=false,description = "县区编号") + * @ApiParams(name = "address", type = "string",required=false,description = "地图定位地址") + * @ApiParams(name = "address_detail", type = "string",required=false,description = "手录详细地址") + * @ApiParams(name = "longitude", type = "string",required=false,description = "经度") + * @ApiParams(name = "latitude", type = "string",required=false,description = "纬度") + * @ApiParams(name = "content", type = "string",required=false,description = "课程详情") + * @ApiParams(name = "notice", type = "string",required=false,description = "课程须知") + * @ApiParams(name = "price", type = "string",required=false,description = "课程价格 0为免费") + * @ApiParams(name = "selfhot", type = "string",required=false,description = "机构热门:0=否,1=是") + * @ApiReturn({ + * + *}) + */ + public function add(){ + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + $params = []; + $params["status"] = $this->request->post('status/s', 0); //上架状态:1=上架,2=下架,3=平台下架 + $params["teacher_id"] = $this->request->post('teacher_id/d', 0); //老师id + $params["classes_type"] = $this->request->post('classes_type/s', 0); //老师id + $params["classes_cate_ids"] = $this->request->post('classes_cate_ids/s', 0); //课程标签 + $params["classes_label_ids"] = $this->request->post('classes_label_ids/s', 0); //课程热门标签 + $params["self_label_tag"] = $this->request->post('self_label_tag/s', 0); //老师id + $params["title"] = $this->request->post('title/s', 0); //老师id + $params["headimage"] = $this->request->post('headimage/s', 0); //老师id + $params["images"] = $this->request->post('images/s', 0); //老师id + $params["type"] = $this->request->post('type/s', 0); //老师id + $params["spec"] = $this->request->post('spec/s', 0); //老师id + $params["classes_num"] = $this->request->post('classes_num/d', 0); //核销次数 + // + $params["address_type"] = $this->request->post('address_type/s', 0); //老师id + $params["province"] = $this->request->post('province/d', 0); //老师id + $params["city"] = $this->request->post('city/d', 0); //老师id + $params["district"] = $this->request->post('district/d', 0); //老师id + $params["address"] = $this->request->post('address/s', 0); //老师id + $params["address_detail"] = $this->request->post('address_detail/s', 0); //老师id + $params["longitude"] = $this->request->post('longitude/s', 0); //老师id + $params["latitude"] = $this->request->post('latitude/s', 0); //老师id + $params["content"] = $this->request->post('content/s', 0); //老师id + $params["notice"] = $this->request->post('notice/s', 0); //老师id + $params["price"] = $this->request->post('price/f', 0); //老师id + $params["selfhot"] = $this->request->post('selfhot/s', 0); //老师id + + + //classes_type + + try{ + $res = $this->model->createClassesByOper($params,true,'user',$user_id,true); + }catch (\Throwable $e){ + $this->error($e->getMessage()); + } + $this->success('添加成功', $res); + } + + + + + + + /** + * @ApiTitle(员工课程编辑) + * @ApiSummary(员工课程编辑) + * @ApiMethod(POST) + * @ApiParams(name = "id", type = "string",required=true,description = "课程id") + * @ApiParams(name = "status", type = "string",required=true,description = "上架状态:1=上架,2=下架,3=平台下架") + * @ApiParams(name = "teacher_id", type = "int",required=true,description = "老师id") + * @ApiParams(name = "classes_type", type = "string",required=true,description = "课程类型") + * @ApiParams(name = "classes_cate_ids", type = "string",required=true,description = "课程标签ids 多值逗号拼接") + * @ApiParams(name = "classes_label_ids", type = "string",required=true,description = "课程热门标签") + * @ApiParams(name = "self_label_tag", type = "string",required=true,description = "机构热门标签:多值逗号拼接") + * @ApiParams(name = "title", type = "string",required=true,description = "课程标题") + * @ApiParams(name = "headimage", type = "string",required=true,description = "课程头图") + * @ApiParams(name = "images", type = "string",required=true,description = "课程轮播图多值逗号拼接") + * @ApiParams(name = "type", type = "string",required=true,description = "地点类型:out=户外,in=室内") + * @ApiParams(name = "spec", type = "string",required=true,description = "课时多规格:[{'id':665,'classes_lib_id':570,'name':'xxxxx','limit_num':100,'status':'1','weigh':665,'time':'2024\/12\/12 19:00 - 2024\/12\/12 20:00'}] ") + * @ApiParams(name = "address_type", type = "string",required=true,description = "地址类型:1=按机构,2=独立位置") + * @ApiParams(name = "province", type = "string",required=false,description = "省编号") + * @ApiParams(name = "city", type = "string",required=false,description = "市编号") + * @ApiParams(name = "district", type = "string",required=false,description = "县区编号") + * @ApiParams(name = "address", type = "string",required=false,description = "地图定位地址") + * @ApiParams(name = "address_detail", type = "string",required=false,description = "手录详细地址") + * @ApiParams(name = "longitude", type = "string",required=false,description = "经度") + * @ApiParams(name = "latitude", type = "string",required=false,description = "纬度") + * @ApiParams(name = "content", type = "string",required=false,description = "课程详情") + * @ApiParams(name = "notice", type = "string",required=false,description = "课程须知") + * @ApiParams(name = "price", type = "string",required=false,description = "课程价格 0为免费") + * @ApiParams(name = "selfhot", type = "string",required=false,description = "机构热门:0=否,1=是") + * @ApiReturn({ + * + *}) + */ + public function edit(){ + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + $params = []; + $id = $this->request->post('id/d', 0); + $params["status"] = $this->request->post('status/s', 0); //上架状态:1=上架,2=下架,3=平台下架 + $params["teacher_id"] = $this->request->post('teacher_id/d', 0); //老师id + $params["classes_type"] = $this->request->post('classes_type/s', 0); //老师id + $params["classes_cate_ids"] = $this->request->post('classes_cate_ids/s', 0); //课程标签 + $params["classes_label_ids"] = $this->request->post('classes_label_ids/s', 0); //课程热门标签 + $params["self_label_tag"] = $this->request->post('self_label_tag/s', 0); //老师id + $params["title"] = $this->request->post('title/s', 0); //老师id + $params["headimage"] = $this->request->post('headimage/s', 0); //老师id + $params["images"] = $this->request->post('images/s', 0); //老师id + $params["type"] = $this->request->post('type/s', 0); //老师id + $params["spec"] = $this->request->post('spec/s', 0); //老师id + $params["address_type"] = $this->request->post('address_type/s', 0); //老师id + $params["province"] = $this->request->post('province/d', 0); //老师id + $params["city"] = $this->request->post('city/d', 0); //老师id + $params["district"] = $this->request->post('district/d', 0); //老师id + $params["address"] = $this->request->post('address/s', 0); //老师id + $params["address_detail"] = $this->request->post('address_detail/s', 0); //老师id + $params["longitude"] = $this->request->post('longitude/s', 0); //老师id + $params["latitude"] = $this->request->post('latitude/s', 0); //老师id + $params["content"] = $this->request->post('content/s', 0); //老师id + $params["notice"] = $this->request->post('notice/s', 0); //老师id + $params["price"] = $this->request->post('price/f', 0); //老师id + $params["selfhot"] = $this->request->post('selfhot/s', 0); //老师id + + + //classes_type + + try{ + $res = $this->model->updateClassesByOper($params,$id,true,'user',$user_id,true); + }catch (\Throwable $e){ + $this->error($e->getMessage()); + } + $this->success('编辑成功', $res); + } + + + + + + /** + * @ApiTitle(员工课程批量删除) + * @ApiSummary(员工课程批量删除) + * @ApiMethod(POST) + * @ApiParams(name = "ids", type = "string",required=true,description = "需要删除的一组课程id,多值逗号拼接") + * @ApiReturn({ + * + *}) + */ + public function del(){ + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + + $ids = $this->request->post('ids/s', ''); + + try{ + $res = $this->model->deleteClassesByOper($ids,true,'user',$user_id,true); + }catch (\Throwable $e){ + $this->error($e->getMessage()); + } + $this->success("成功删除{$res}条数据",["delete_number"=>$res]); + } + + + + + + +} \ No newline at end of file diff --git a/application/api/controller/school/worker/ServiceOrder.php b/application/api/controller/school/worker/ServiceOrder.php index 94f3f53..93ae7b8 100644 --- a/application/api/controller/school/worker/ServiceOrder.php +++ b/application/api/controller/school/worker/ServiceOrder.php @@ -209,5 +209,11 @@ class ServiceOrder extends Base } + + + + + + } diff --git a/application/common/hooks.php b/application/common/hooks.php index c192ab6..91cef72 100644 --- a/application/common/hooks.php +++ b/application/common/hooks.php @@ -128,6 +128,9 @@ $userHooks = [ 'user_auth_fail_after' => [ // 用户授权机构不通过 'app\\common\\listener\\user\\UserHook' ], + 'user_update_after' => [ // 用户信息更新后 + 'app\\common\\listener\\user\\UserHook' + ], ]; diff --git a/application/common/library/Sqlscript.php b/application/common/library/Sqlscript.php index c6d253f..a1ee00d 100644 --- a/application/common/library/Sqlscript.php +++ b/application/common/library/Sqlscript.php @@ -22,10 +22,10 @@ class Sqlscript ->page($page,$limit)->select(); //默认机构id - $manystore_id = 2; - $shop_id = 2; - $user_id = 25; - $teacher_id = 8; + $manystore_id = 1; + $shop_id = 1; + $user_id = 72; + $teacher_id = 15; foreach ($kechengs as $k=>$v){ $classes_cate_ids = Cate::where( "name",$v["gongyi"])->value("id"); diff --git a/application/common/listener/manystore/ShopHook.php b/application/common/listener/manystore/ShopHook.php index 574c598..2094a94 100644 --- a/application/common/listener/manystore/ShopHook.php +++ b/application/common/listener/manystore/ShopHook.php @@ -1,5 +1,6 @@ id); + diff --git a/application/common/listener/user/UserHook.php b/application/common/listener/user/UserHook.php index 9014aa1..260eac9 100644 --- a/application/common/listener/user/UserHook.php +++ b/application/common/listener/user/UserHook.php @@ -100,8 +100,19 @@ class UserHook Message::$event_name = $params["event"]; Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type); + } - + public function userUpdateAfter(&$params) + { + //设置用户更新信息 + ['user' => $user] = $params; + //如果存在机构端,则同时同步机构端账号信息 + $manystore = Manystore::where("user_id",$user["id"])->find(); + if($manystore){ + $manystore["nickname"] = $user["realname"] ?:$user["nickname"]; + if($user["avatar"])$manystore["avatar"] = $user["avatar"]; + $manystore->save(); + } } } \ No newline at end of file diff --git a/application/common/model/BaseModel.php b/application/common/model/BaseModel.php index af19744..737921f 100644 --- a/application/common/model/BaseModel.php +++ b/application/common/model/BaseModel.php @@ -150,7 +150,7 @@ class BaseModel extends Model $alisa_name = ''; if($alisa)$alisa_name = "{$alisa}."; if(!$sort)$sort = "{$alisa_name}id asc"; - $self = static::getBaseWhere($whereData, null, $alisa,true); + $self = static::getBaseWhere($whereData, null, $alisa,$this->withTable); if($this->withTable)$self = $self->with($this->withTable); if($page&&$limit)$self = $self->orderRaw($sort)->where($where)->page($page, $limit); $list = $self->select(); @@ -175,7 +175,7 @@ class BaseModel extends Model } } if($toArray)$list = collection($list)->toArray(); - $countSelf = static::getBaseWhere($whereData, null, $alisa,true); + $countSelf = static::getBaseWhere($whereData, null, $alisa,$this->withTable); if($this->withTable)$countSelf = $countSelf->with($this->withTable); $count = $countSelf->where($where)->count(); return compact('list', 'count','page','limit'); diff --git a/application/common/model/dyqc/ManystoreShop.php b/application/common/model/dyqc/ManystoreShop.php index 5ca54b1..5ab21f3 100644 --- a/application/common/model/dyqc/ManystoreShop.php +++ b/application/common/model/dyqc/ManystoreShop.php @@ -6,6 +6,7 @@ use app\common\model\BaseModel; use app\common\model\school\Area; use app\common\model\school\classes\ClassesLib; use app\common\model\school\classes\Teacher; +use app\common\model\school\classes\Verification; use app\common\model\User; use app\manystore\model\Manystore; use app\manystore\model\ManystoreAuthGroup; @@ -199,11 +200,36 @@ class ManystoreShop extends BaseModel || empty($self["images"]) || empty($self["content"]) || empty($self["tel"]) + || empty($self["logo"]) ) return false; return true; } + public function checkFullMsg($id){ + if($this->checkFull($id)){ + //必要信息已完善 + return '
          + 必要展示信息已完善!可正常上架课程!
          '; + }else{ + //必要信息未完善 + return "
          必要展示信息未完善,请先在机构完善展示信息

          + + 必要展示信息为:


          + 1:地址信息:包括详细地址、所在城市、所在省、所在市、所在县、经纬度
          + 2:店铺名称
          + 3:店铺logo
          + 4:店铺封面图
          + 5:店铺环境照
          + 6:服务电话
          + 7:店铺详情


          + 请您确保上述信息均已完善后才能正常上架课程。

          + 若已完善请您刷新页面。

          +
          +"; + } + } + @@ -336,7 +362,7 @@ class ManystoreShop extends BaseModel 'reverse_idcard_image' => 'require', 'images' => 'require', 'yyzz_images' => 'require', - 'yyzzdm' => 'require', +// 'yyzzdm' => 'require', 'address' => 'require', @@ -376,7 +402,7 @@ class ManystoreShop extends BaseModel 'reverse_idcard_image.require' => '法人身份证反面必须上传', 'images.require' => '机构环境照片必须上传', 'yyzz_images.require' => '营业执照照片必须上传', - 'yyzzdm.require' => '企业统一信用代码必填', +// 'yyzzdm.require' => '企业统一信用代码必填', // 'establish_time.require' => '成立时间必填', // 'people.require' => '员工人数必填', @@ -407,6 +433,10 @@ class ManystoreShop extends BaseModel + + + + // $order = self::getHaveCancelOrder($order_no); //判断逻辑 @@ -421,6 +451,14 @@ class ManystoreShop extends BaseModel //如果存在申请单,则直接更新这个单的状态 //如果不存在则创建一个新单 if(!$shop){ + + //申请认证的时候不能是老师或其他机构的核销员 + $teacher = Teacher::where("user_id" ,$user_id)->find(); + if($teacher) throw new \Exception("您已经是老师,不能申请认证!"); + + $verification = Verification::where("user_id" ,$user_id)->find(); + if($verification) throw new \Exception("您已经是机构核销员,不能申请认证!"); + //创建申请单 $shop = $this->creatShop($type,$user_id,$params); }else{ @@ -430,6 +468,7 @@ class ManystoreShop extends BaseModel throw new \Exception($shop->getError()); } } + $shop = ManystoreShop::where( 'user_id',$user_id)->find(); //更新申请单状态为审核中 $shop['status']= '0'; @@ -529,9 +568,16 @@ public function creatShop($type,$user_id,$params){ if($shop_info === false){ throw new \Exception($shop->getError()); } + + + + + $user = User::where("id",$user_id)->find(); + if(!$user) throw new \Exception("用户不存在"); + //账号主表 $manystore_params = [ - "nickname" => $params["name"], + "nickname" => $user["realname"] ?: $user["nickname"], "user_id"=>$user_id, ]; $manystore_params["username"] = $params["tel"] ?: self::$pinyin->permalink($manystore_params["nickname"]); @@ -543,6 +589,10 @@ public function creatShop($type,$user_id,$params){ $manystore_params['salt'] = Random::alnum(); $manystore_params['password'] = md5(md5($manystore_params['password']) . $manystore_params['salt']); $manystore_params['avatar'] = '/assets/img/avatar.png'; //设置新管理员默认头像。 + + //如果用户存在头像取用户头像 + if($user["avatar"]) $manystore_params['avatar'] = $user["avatar"]; + $manystore_params['is_main'] = 1; $manystore_params['status'] = "hidden"; $model = new Manystore(); @@ -743,7 +793,54 @@ public static function getAuthInfo($user_id){ return $selfetch; } + /** 机构初始化数据 + * @param $shop_id + * @return void + */ + public static function initData($shop_id){ + //设置初始化课程 + $shop = self::where("id",$shop_id)->find(); + if($shop){ + $user = $shop->user; + + $manystore = Manystore::where("shop_id" ,$shop_id)->find(); + if($user && $manystore){ + //授权认证成功 + $result = \app\common\model\manystore\UserAuth::auth(0,$shop["id"],$shop["user_id"],"1",'admin',0); + //删除用户所有老师和核销员 + Teacher::where("user_id",$user["id"])->delete(); + Verification::where("user_id",$user["id"])->delete(); + //为用户初始化老师和核销员 + $teacherData = [ + "manystore_id"=> $manystore["id"], + "shop_id" => $shop["id"], + "user_id" => $user["id"], + "name" => $shop["name"] . "讲师", + "head_image" => $user["avatar"], + "content" => $shop["name"] . "讲师".",为您提供授课,核销,专人指导等服务。", + "status" => "2", + "weigh" => 0, + ]; + Teacher::create($teacherData); + + $verification_data =[ + "manystore_id"=> $manystore["id"], + "shop_id" => $shop["id"], + "user_id" => $user["id"], + "status" => "1", + ]; + Verification::create($verification_data); + } + } + + } + +// public static function deleteDataByShopId($shop_id){ +// $ids = ClassesLib::where("shop_id",$shop_id)->column("id"); +// +// +// } } diff --git a/application/common/model/school/classes/ClassesLib.php b/application/common/model/school/classes/ClassesLib.php index 5bec3fd..eec2e25 100644 --- a/application/common/model/school/classes/ClassesLib.php +++ b/application/common/model/school/classes/ClassesLib.php @@ -2,9 +2,12 @@ namespace app\common\model\school\classes; +use app\admin\model\Admin; use app\common\library\Virtual; use app\common\model\BaseModel; use app\common\model\dyqc\ManystoreShop; +use app\common\model\manystore\Shop; +use app\common\model\school\Area; use app\common\model\school\classes\lib\Spec; use app\common\model\User; use app\manystore\model\Manystore; @@ -326,7 +329,7 @@ class ClassesLib extends BaseModel * @throws \think\exception\DbException */ public function detail($id,$user_id=0,$oper_type='user',$trans=false){ - $self = $this->get($id,['shop','teacher','user']); + $self = $this->get($id,['shop','teacher','user','specs']); //是否收藏 $self['is_collect'] = 0; @@ -348,18 +351,26 @@ class ClassesLib extends BaseModel $cate_list = Cate::where("status",'1')->column("name","id"); $label_list = Label::where("status",'1')->column("name","id"); + $type_list = Label::where("status",'1')->column("name","id"); $classes_label_ids = $self['classes_label_ids']; $classes_cate_ids = $self['classes_cate_ids']; - $classes_label = $classes_cate = []; + $classes_type_ids = $self['classes_type']; + $classes_label = $classes_cate = $classes_type = []; foreach (explode(",", $classes_label_ids) as $classes_label_id){ if(isset($label_list[$classes_label_id]))$classes_label[] = $label_list[$classes_label_id]; } foreach (explode(",", $classes_cate_ids) as $classes_cate_id){ if(isset($cate_list[$classes_cate_id]))$classes_cate[] = $cate_list[$classes_cate_id]; } + + foreach (explode(",", $classes_type_ids) as $classes_type_id){ + if(isset($type_list[$classes_type_id]))$classes_type[] = $type_list[$classes_type_id]; + } + $self['classes_label'] = $classes_label; $self['classes_cate'] = $classes_cate; + $self['classes_type_name'] = $classes_type; //下架判断 @@ -620,15 +631,22 @@ $user_unpaid_order = $user_paid_order =null; $cate_list = Cate::where("status",'1')->column("name","id"); $label_list = Label::where("status",'1')->column("name","id"); - + $type_list = Type::where("status",'1')->column("name","id"); // 查询自提点 if(isset($status) && in_array($status, ['1','2','3'])){ $selfetch = self::with($with); }else{ - $selfetch = self::with($with)->where($a.'status', '1')->where("{$a}auth_status",1); + $selfetch = self::with($with)->where($a.'status', '1'); } + if(isset($auth_status) && in_array($auth_status, ['0','1','2'])){ + + }else{ + $selfetch = $selfetch->where("{$a}auth_status",1); + } + + $order = $order?? 'normal'; $per_page = $limit ?? 10; @@ -723,6 +741,11 @@ $user_unpaid_order = $user_paid_order =null; $selfetch = $selfetch->where("{$a}feel", 'in', ''.$feel); } + //设置订单信息 + if(isset($auth_status) && $auth_status != -1){ + $selfetch = $selfetch->where("{$a}auth_status", 'in', ''.$auth_status); + } + //区域搜索 @@ -837,15 +860,23 @@ $user_unpaid_order = $user_paid_order =null; } $classes_label_ids = $row['classes_label_ids']; $classes_cate_ids = $row['classes_cate_ids']; - $classes_label = $classes_cate = []; + $classes_type_ids = $row['classes_type']; + $classes_label = $classes_cate = $classes_type = []; foreach (explode(",", $classes_label_ids) as $classes_label_id){ if(isset($label_list[$classes_label_id]))$classes_label[] = $label_list[$classes_label_id]; } foreach (explode(",", $classes_cate_ids) as $classes_cate_id){ if(isset($cate_list[$classes_cate_id]))$classes_cate[] = $cate_list[$classes_cate_id]; } + + foreach (explode(",", $classes_type_ids) as $classes_type_id){ + if(isset($type_list[$classes_type_id]))$classes_type[] = $type_list[$classes_type_id]; + } + + $row['classes_label'] = $classes_label; $row['classes_cate'] = $classes_cate; + $row['classes_type_name'] = $classes_type; } @@ -1021,9 +1052,15 @@ $user_unpaid_order = $user_paid_order =null; public $no_auth_fields = ["user_id","teacher_id","classes_type","classes_cate_ids","classes_label_ids","self_label_tag",'headimage','images','notice','content',"virtual_num","virtual_collect","underline_price"]; + public $need_auth = false; + public $have_auth = false; + + public $success_auth = false; + public $error_auth = false; + public function classesCheck(&$params,$shop_id=null,$row=null) { -// if($row)$params["auth_status"] = $params["auth_status"] ?? $row["auth_status"]; + if($row)$params["auth_status"] = $params["auth_status"] ?? $row["auth_status"]; $params["auth_status"] = $params["auth_status"] ?? '0'; $params["status"] = $params["status"] ?? '3'; @@ -1226,4 +1263,379 @@ $user_unpaid_order = $user_paid_order =null; + + protected function update_check(&$params,$row=null,$shop_id=0) + { + + + + $this->classesCheck($params,$shop_id,$row); + + //特有认证判断 +// $this->authClasses($params,$row); +// var_dump($row);die; + //更新 + if($row){ + if($row['status'] == "3" && $params['status'] != $row['status']){ + $this->error("平台下架审核的课程无法上架!"); + } + + //如果是审核失败,提交后自动更新成审核中 + if($row['auth_status'] == 2){ + $params['status'] = "3"; + $params['auth_status'] = 0; + $params["reason"] = ""; + } + }else{ + //新增(需审核) + $params["add_type"] = '1'; + $params["add_id"] = $this->auth->id; + $params['status'] = "3";//平台下架 + $params['auth_status'] = 0; + + $this->have_auth = true; + } + + + + + } + + + + + /** 操作权限检测 + * @param $order 订单 + * @param $oper_id 操作人id + * @param $oper_type 操作人类型:user-用户或员工,admin-管理员 + * @return void + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\ModelNotFoundException + * @throws \think\exception\DbException + */ + public static function checkOptionAuth($classes_id,$oper_id,$oper_type,$only_user=false,$only_shop=false,$only_admin=false){ + $classes = null; + $shop_id = 0; + //课程是否存在并上架 + if($classes_id){ + $classes = self::get($classes_id); + if(!$classes) throw new \Exception("课程不存在或已下架!"); + $shop_id = $classes["shop_id"]; + } + + + switch ($oper_type) { + case 'user': + if($only_admin)throw new \Exception("您无权操作该订单!"); + if($only_shop)throw new \Exception("您无权操作该订单!"); + //自己或操作员 + $Shop = Shop::where("user_id",$oper_id)->find(); + if($Shop)$shop_id = $Shop["id"]; + if($Shop && $classes){ + if($Shop["id"] == $classes["shop_id"]){ + break; + } + } + + + //说明是操作员 + $help_user_info = User::where('id',$oper_id)->find(); + if(!$help_user_info) throw new \Exception("代下单员工不存在!"); + $classes_lib_ids = (new ClassesLib)->getClassesAuthIds($oper_id); + + if(!$shop_id)$shop_id = self::where("id" ,"in", $classes_lib_ids)->value("shop_id"); + + //判断当前订单课程是否在此课程授权范围内 + if($classes && !in_array($classes_id,$classes_lib_ids)) throw new \Exception("该课程不在您的授权范围内,无法代操作!"); + + break; + case 'admin': + $admin_info = Admin::where('id',$oper_id)->find(); + if(!$admin_info) throw new \Exception("代下单管理员不存在!"); + break; + case 'shop': + if($only_admin)throw new \Exception("您无权操作该订单!"); + + if($only_user) throw new \Exception("您无权操作该订单!"); + + $admin_info = Manystore::where('id',$oper_id)->find(); + if(!$admin_info) throw new \Exception("代下单管理员不存在!"); + $shop_id = $admin_info["shop_id"]; + + $classes_lib_ids = ClassesLib::where("manystore_id",$oper_id)->column("id"); + //判断当前订单课程是否在此课程授权范围内 + if($classes && !in_array($classes_id,$classes_lib_ids)) throw new \Exception("该课程不在您的授权范围内,无法代操作!"); + break; + default: + throw new \Exception("请选择正确的代下单类型!"); + } + if(!$shop_id) throw new \Exception("无法判定课程所属店铺!"); + + return $shop_id; + } + + + + + + + + + /** 小程序端操作课程添加 + * @param bool $check + * @param bool $trans + * @return bool + * @throws \Exception + */ + public function createClassesByOper($params,$check=false,$oper_type='user',$oper_id=0,$trans=false){ + + $model = new self; + + + //用户操作权限检测 + $shop_id = self::checkOptionAuth(0, $oper_id,$oper_type); + + + $this->update_check($params,$row=null,$shop_id); + $spec = $params["spec"]; + unset($params["spec"]); + + + $province_name = Area::where("id" ,$params['province'])->value("name"); + if(!$province_name) throw new \Exception("省份不存在"); + $city_name = Area::where("id" ,$params['city'])->value("name"); + if(!$city_name) throw new \Exception("市不存在"); + $district_name = Area::where("id" ,$params['district'])->value("name"); + if(!$district_name) throw new \Exception("区县不存在"); + $params['address_city'] = $province_name."/".$city_name."/".$district_name; + + //判断逻辑 + if($trans){ + self::beginTrans(); + } + $res = true; + try{ + //事务逻辑 + + + $result = $model->allowField(true)->save($params); + \app\common\model\school\classes\ClassesLib::add_virtual_init($model["id"]); + + //添加课程规格 + foreach ($spec as $k=>$v){ + $v["classes_lib_id"] = $model["id"]; + \app\common\model\school\classes\ClassesSpec::create($v); + } + + //因为是批量添加,所有规格重新进行检测,防止出现时间重叠 + $specss = \app\common\model\school\classes\ClassesSpec::where("classes_lib_id",$model["id"])->select(); + foreach ($specss as $k=>$specs){ + $params =$specs; + (new \app\common\model\school\classes\ClassesSpec)->specCheck($params,null,$specs); + } + + //课时数必须大于等于课时核销数 + $count = \app\common\model\school\classes\ClassesSpec::where("classes_lib_id",$model["id"])->count(); + $classes_num = \app\common\model\school\classes\ClassesLib::where("id",$model["id"])->value("classes_num"); + if($count < $classes_num){ + throw new \Exception("课时数必须大于等于课时核销数"); + } + + + $this->update_classes($model["id"]); + if($this->have_auth){ + //调用通过事件 + $data = ['classes' => $model]; + \think\Hook::listen('classes_auth_need_after', $data); + + } + +// if($this->success_auth){ +// //调用通过事件 +// $data = ['classes' => $model]; +// \think\Hook::listen('classes_auth_success_after', $data); +// } +// +// +// if($this->error_auth){ +// //调用通过事件 +// $data = ['classes' => $model]; +// \think\Hook::listen('classes_auth_fail_after', $data); +// +// } + + + + + if($trans){ + self::commitTrans(); + } + }catch (\Exception $e){ + if($trans){ + self::rollbackTrans(); + } + throw new \Exception($e->getMessage().$e->getFile().$e->getLine()); + } + return $model; + } + + + + + /** 小程序端操作课程修改 + * @param bool $check + * @param bool $trans + * @return bool + * @throws \Exception + */ + public function updateClassesByOper($params,$ids,$check=false,$oper_type='user',$oper_id=0,$trans=false){ + + //用户操作权限检测 + $shop_id = self::checkOptionAuth($ids, $oper_id,$oper_type); + + + $row = self::where('id',$ids)->where("shop_id",$shop_id)->find(); + if(!$row) throw new \Exception("课程不存在!"); + + + $this->update_check($params,$row,$shop_id); + $spec = $params["spec"] ?? [];//$params["delete_spec_ids"] + $delete_spec_ids = $params["delete_spec_ids"] ?? []; + unset($params["spec"]); + unset($params["delete_spec_ids"]); + + + $province_name = Area::where("id" ,$params['province'])->value("name"); + if(!$province_name) throw new \Exception("省份不存在"); + $city_name = Area::where("id" ,$params['city'])->value("name"); + if(!$city_name) throw new \Exception("市不存在"); + $district_name = Area::where("id" ,$params['district'])->value("name"); + if(!$district_name) throw new \Exception("区县不存在"); + $params['address_city'] = $province_name."/".$city_name."/".$district_name; + + + + //判断逻辑 + if($trans){ + self::beginTrans(); + } + $res = true; + try{ + //事务逻辑 + + $result = $row->allowField(true)->save($params); + + foreach ($spec as $k=>$v){ + $v["classes_lib_id"] = $row["id"]; + //有id更新,否则新增 + if(isset($v["id"]) && $v["id"]){ + \app\common\model\school\classes\ClassesSpec::update((new \app\common\model\school\classes\ClassesSpec)->checkAssemblyParameters($v)); + }else{ + \app\common\model\school\classes\ClassesSpec::create((new \app\common\model\school\classes\ClassesSpec)->checkAssemblyParameters($v)); + } + } + //删除规格 + foreach ($delete_spec_ids as $k=>$delete_spec){ + (new \app\common\model\school\classes\ClassesSpec)->updateCheck($delete_spec["id"]); + + $delete_spec->delete(); + } + + //因为是批量添加,所有规格重新进行检测,防止出现时间重叠 + $specss = \app\common\model\school\classes\ClassesSpec::where("classes_lib_id",$row["id"])->select(); + foreach ($specss as $k=>$specs){ + $params =$specs; + (new \app\common\model\school\classes\ClassesSpec)->specCheck($params,null,$specs); + } + + + $this->update_classes($row["id"]); + + if($this->have_auth){ + //调用通过事件 + $data = ['classes' => $row]; + \think\Hook::listen('classes_auth_need_after', $data); + + } + +// if($this->success_auth){ +// //调用通过事件 +// $data = ['classes' => $model]; +// \think\Hook::listen('classes_auth_success_after', $data); +// } +// +// +// if($this->error_auth){ +// //调用通过事件 +// $data = ['classes' => $model]; +// \think\Hook::listen('classes_auth_fail_after', $data); +// +// } + + + + + + if($trans){ + self::commitTrans(); + } + }catch (\Exception $e){ + if($trans){ + self::rollbackTrans(); + } + throw new \Exception($e->getMessage().$e->getFile().$e->getLine()); + } + return $row; + } + + + + + /** 小程序端操作课程修改 + * @param bool $check + * @param bool $trans + * @return bool + * @throws \Exception + */ + public function deleteClassesByOper($ids,$check=false,$oper_type='user',$oper_id=0,$trans=false){ + + //用户操作权限检测 + $shop_id = self::checkOptionAuth($ids, $oper_id,$oper_type); + + $row = self::where('id',$ids)->where("shop_id",$shop_id)->find(); + if(!$row) throw new \Exception("课程不存在!"); + + + $list = self::where("id", 'in', $ids)->select(); + foreach ($list as $item) { + $this->updateCheck($item->id); + } + //判断逻辑 + if($trans){ + self::beginTrans(); + } + $res = true; + try{ + $count = 0; + //事务逻辑 + //删除前检测 + foreach ($list as $k => $v) { + //删除课程规格 + Spec::where("classes_lib_id",$v->id)->delete(); + $count += $v->delete(); + } + if($trans){ + self::commitTrans(); + } + }catch (\Exception $e){ + if($trans){ + self::rollbackTrans(); + } + throw new \Exception($e->getMessage().$e->getFile().$e->getLine()); + } + return $count; + } + + + } diff --git a/application/common/model/school/classes/ClassesSpec.php b/application/common/model/school/classes/ClassesSpec.php index 3794b09..173636a 100644 --- a/application/common/model/school/classes/ClassesSpec.php +++ b/application/common/model/school/classes/ClassesSpec.php @@ -28,7 +28,8 @@ class ClassesSpec extends BaseModel protected $append = [ 'start_time_text', 'end_time_text', - 'status_text' + 'status_text' , + 'time' ]; public $no_auth_fields = ['name','limit_num','status','weigh']; diff --git a/application/common/model/school/classes/Evaluate.php b/application/common/model/school/classes/Evaluate.php index 9cebd58..26ee855 100644 --- a/application/common/model/school/classes/Evaluate.php +++ b/application/common/model/school/classes/Evaluate.php @@ -200,6 +200,7 @@ class Evaluate extends BaseModel */ public static function detail($id,$user_id=0,$oper_type='user',$trans=false){ $self = self::get($id,['user','shop',"lib",'teacher','classesorder']); + if(!$self) throw new \Exception("未找到相关数据"); if($user_id){ if($self["user_id"] != $user_id) throw new \Exception("非法访问"); @@ -230,7 +231,7 @@ class Evaluate extends BaseModel $order = \app\common\model\school\classes\order\Order::getHaveEvaluateOrder($order_no); if($check){ //用户操作权限检测 - \app\common\model\school\classes\hourorder\Order::checkOptionAuth($order['classes_order_id'],$user_id ?: $oper_id,$oper_type,true); + \app\common\model\school\classes\hourorder\Order::checkOptionAuth($order['id'],$user_id ?: $oper_id,$oper_type,true); } $detail = $order->detail; @@ -323,7 +324,7 @@ class Evaluate extends BaseModel $order = \app\common\model\school\classes\order\Order::getHaveEvaluateOrder($order_no); if($check){ //用户操作权限检测 - \app\common\model\school\classes\hourorder\Order::checkOptionAuth($order['classes_order_id'],$user_id ?: $oper_id,$oper_type,true); + \app\common\model\school\classes\hourorder\Order::checkOptionAuth($order['id'],$user_id ?: $oper_id,$oper_type,true); } $detail = $order->detail; $user = $order->user; @@ -453,7 +454,7 @@ class Evaluate extends BaseModel }else{ $teacher_star = 5; } - $teacher->save(['teacher_star'=>$teacher_star]); + $teacher->save(['teacher_star'=>$teacher_star,'star_number'=>$count]); } $shop = $self->shop; //shop_star @@ -474,7 +475,7 @@ class Evaluate extends BaseModel }else{ $shop_star = 5; } - $shop->save(['shop_star'=>$shop_star]); + $shop->save(['shop_star'=>$shop_star,'star_number'=>$count]); } $lib = $self->lib; //classes_star if($lib){ @@ -495,7 +496,7 @@ class Evaluate extends BaseModel }else{ $classes_star = 5; } - $lib->save(['classes_star'=>$classes_star]); + $lib->save(['classes_star'=>$classes_star,'star_number'=>$count]); } diff --git a/application/common/model/school/classes/hourorder/Order.php b/application/common/model/school/classes/hourorder/Order.php index 96e7feb..c713cb4 100644 --- a/application/common/model/school/classes/hourorder/Order.php +++ b/application/common/model/school/classes/hourorder/Order.php @@ -4,6 +4,7 @@ namespace app\common\model\school\classes\hourorder; use app\admin\model\Admin; use app\admin\model\school\classes\Blacklist; +use app\common\model\manystore\Shop; use app\common\model\school\classes\ClassesLib; use app\common\model\school\classes\ClassesSpec; use app\common\model\User; @@ -185,7 +186,14 @@ class Order extends BaseModel } if (isset($whereData['status'])) $model = $model->where("{$alisa}status", 'in', $whereData['status']); if (isset($whereData['not_status'])) $model = $model->where("{$alisa}status", 'not in', $whereData['not_status']); - if (isset($whereData['keywords'])&&$whereData['keywords']) $model = $model->where("{$alisa}order_no|{$alisa}id", '=', $whereData['keywords']); + if (isset($whereData['keywords'])&&$whereData['keywords']){ + if($with && in_array('detail',$with)){ + $model = $model->where("{$alisa}order_no|{$alisa}id|{$alisa}name|detail.title", 'like', "%" .$whereData['keywords'] . "%"); + }else{ + $model = $model->where("{$alisa}order_no|{$alisa}id|{$alisa}name", 'like', "%" .$whereData['keywords'] . "%"); + } + + } if (isset($whereData['createtime'])&&$whereData['createtime']){ $model = $model->time(["{$alisa}createtime",$whereData['createtime']]); @@ -1107,6 +1115,15 @@ class Order extends BaseModel //自己或操作员 if($oper_id != $classesOrder["user_id"]){ if($only_user) throw new \Exception("您无权操作该订单!"); + + $Shop = Shop::where("user_id",$oper_id)->find(); + if($Shop){ + if($Shop["id"] == $classesOrder["shop_id"]){ + break; + } + + } + //说明是操作员 $help_user_info = User::where('id',$oper_id)->find(); if(!$help_user_info) throw new \Exception("代下单员工不存在!"); diff --git a/application/common/model/school/classes/order/Order.php b/application/common/model/school/classes/order/Order.php index ce3cdce..90bc17a 100644 --- a/application/common/model/school/classes/order/Order.php +++ b/application/common/model/school/classes/order/Order.php @@ -904,7 +904,7 @@ class Order extends BaseModel $model = $model->whereExists(function ($query) use ($alisa) { $order_table_name = (new \app\common\model\school\classes\hourorder\Order())->getQuery()->getTable(); $query->table($order_table_name)->where($order_table_name . '.classes_order_id=' . $alisa . 'id')->where('status', '=', '3'); - }); + })->where("{$alisa}classes_evaluate_id", '=', 0); } } @@ -923,6 +923,7 @@ class Order extends BaseModel 'base'=>['*'], 'shop'=>['*'], 'detail'=>['*'], + 'evaluate'=>['*'], ]; $CANCEL = '-3'; $NOPAY = '0'; @@ -1145,7 +1146,7 @@ class Order extends BaseModel $order = self::where('order_no|id|pay_no|code',$order_no)->whereExists(function ($query){ $self_order_table_name = (new \app\common\model\school\classes\hourorder\Order())->getQuery()->getTable(); $order_table_name = (new self())->getQuery()->getTable(); - $query->table($order_table_name)->where($order_table_name . '.classes_order_id=' . $self_order_table_name . '.id')->where('status', '=', '3'); + $query->table($self_order_table_name)->whereRaw($self_order_table_name . '.classes_order_id=' . $order_table_name . '.id')->where('status', '=', '3'); })->find(); if(!$order)throw new \Exception("只有一次核销之后订单可评价!"); diff --git a/application/common/model/school/classes/order/ServiceOrder.php b/application/common/model/school/classes/order/ServiceOrder.php index 3a89f2a..a736292 100644 --- a/application/common/model/school/classes/order/ServiceOrder.php +++ b/application/common/model/school/classes/order/ServiceOrder.php @@ -478,14 +478,15 @@ class ServiceOrder extends BaseModel //校验订单参数 //操作人权限验证 - self::checkOptionAuth($classes_order["id"],$oper_id ?:$user_id,$oper_type,true); + self::checkOptionAuth($classes_order["id"],$oper_id ?:$user_id,$oper_type); //免费单无法申请售后 if($classes_order["payprice"]==0 && $classes_order["totalprice"] == 0 ) throw new \Exception("免费课程无法申请售后!"); //只有使用中的订单可以申请售后 - if($classes_order["status"] != '3' ) throw new \Exception("该订单当前状态无法申请售后!"); + if(($oper_id == $classes_order["user_id"] || $oper_type == 'user')&& $classes_order["status"] != '3' ) throw new \Exception("该订单当前状态无法申请售后!"); + if(!in_array($classes_order["status"],['3','9']))throw new \Exception("只有进行中和已完成的订单可以申请售后!"); //存在售后中的订单 $count = self::where( 'classes_order_id',$classes_order["id"])->where("status","not in","7,-3")->count(); if($count > 0) throw new \Exception("该订单已存在正在进行中的售后单,请等待售后处理!"); @@ -524,12 +525,21 @@ class ServiceOrder extends BaseModel //自己或操作员 if($oper_id != $classesOrder["user_id"]){ if($only_user) throw new \Exception("您无权操作该订单!"); + + $Shop = Shop::where("user_id",$oper_id)->find(); + if($Shop){ + if($Shop["id"] == $classesOrder["shop_id"]){ + break; + } + + } //说明是操作员 $help_user_info = User::where('id',$oper_id)->find(); if(!$help_user_info) throw new \Exception("代下单员工不存在!"); $classes_lib_ids = (new ClassesLib)->getClassesAuthIds($oper_id); //判断当前订单课程是否在此课程授权范围内 if(!in_array($classesOrder["classes_lib_id"],$classes_lib_ids)) throw new \Exception("该课程不在您的授权范围内,无法代操作!"); + }else{ $classes_lib_ids = (new ClassesLib)->getClassesAuthIds($oper_id); //不是员工并且想操作只有机构能操作的单 diff --git a/application/extra/upload.php b/application/extra/upload.php index 50e57ab..e4cdab1 100644 --- a/application/extra/upload.php +++ b/application/extra/upload.php @@ -17,11 +17,11 @@ return [ /** * 最大可上传大小 */ - 'maxsize' => '5mb', + 'maxsize' => '2mb', /** * 可上传的文件类型 */ - 'mimetype' => 'jpg,png,bmp,jpeg,gif,webp,zip,rar,wav,mp4,mp3,webm,p12,pem', + 'mimetype' => 'jpg,png,bmp,jpeg,gif,webp,zip,rar,wav,mp4,mp3,webm,p12,pem,doc,docx,xls,xlsx,pdf,txt,md,xml', /** * 是否支持批量上传 */ diff --git a/application/manystore/controller/Dashboard.php b/application/manystore/controller/Dashboard.php index 93513c5..835edc3 100644 --- a/application/manystore/controller/Dashboard.php +++ b/application/manystore/controller/Dashboard.php @@ -50,6 +50,9 @@ class Dashboard extends ManystoreBase 'uploadmode' => $uploadmode ]); + $this->view->assign('check_full',(new \app\common\model\dyqc\ManystoreShop)->checkFull(SHOP_ID)); + $this->view->assign('check_full_msg',(new \app\common\model\dyqc\ManystoreShop)->checkFullMsg(SHOP_ID)); + return $this->view->fetch(); } diff --git a/application/manystore/controller/general/Profile.php b/application/manystore/controller/general/Profile.php index fdc0da1..68b7fdd 100644 --- a/application/manystore/controller/general/Profile.php +++ b/application/manystore/controller/general/Profile.php @@ -29,6 +29,9 @@ class Profile extends ManystoreBase $this->view->assign('typeList',$shop_info->getTypeList()); $this->view->assign('shop_info',$shop_info); + $this->view->assign('check_full',(new \app\common\model\dyqc\ManystoreShop)->checkFull(SHOP_ID)); + $this->view->assign('check_full_msg',(new \app\common\model\dyqc\ManystoreShop)->checkFullMsg(SHOP_ID)); + $this->getCity(); return $this->view->fetch(); } @@ -49,9 +52,9 @@ class Profile extends ManystoreBase if (!Validate::is($params['email'], "email")) { $this->error(__("Please input correct email")); } - if (!Validate::is($params['nickname'], "/^[\x{4e00}-\x{9fa5}a-zA-Z0-9_-]+$/u")) { - $this->error(__("Please input correct nickname")); - } +// if (!Validate::is($params['nickname'], "/^[\x{4e00}-\x{9fa5}a-zA-Z0-9_-]+$/u")) { +// $this->error(__("Please input correct nickname")); +// } if (isset($params['password'])) { if (!Validate::is($params['password'], "/^[\S]{6,16}$/")) { $this->error(__("Please input correct password")); @@ -84,7 +87,7 @@ class Profile extends ManystoreBase if ($this->request->isPost()) { $this->token(); $shop = $this->request->post("shop/a"); - if($shop["address_city"] && !$shop["province"])$this->error("请选择所在城市"); + if($shop["address_city"] && !$shop["district"])$this->error("请选择所在城市"); $shopModel = new ManystoreShop(); diff --git a/application/manystore/controller/school/classes/ClassesLib.php b/application/manystore/controller/school/classes/ClassesLib.php index 7efeaaf..8a6f842 100644 --- a/application/manystore/controller/school/classes/ClassesLib.php +++ b/application/manystore/controller/school/classes/ClassesLib.php @@ -5,6 +5,7 @@ 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\lib\Spec; use app\common\model\school\classes\Order; use app\manystore\model\Manystore; use think\Db; @@ -64,6 +65,9 @@ class ClassesLib extends ManystoreBase $this->view->assign("specStatusList", (new \app\manystore\model\school\classes\ClassesSpec)->getStatusList()); $this->getCity(); + + $this->view->assign('check_full',(new \app\common\model\dyqc\ManystoreShop)->checkFull(SHOP_ID)); + $this->view->assign('check_full_msg',(new \app\common\model\dyqc\ManystoreShop)->checkFullMsg(SHOP_ID)); } public function import() @@ -556,6 +560,10 @@ class ClassesLib extends ManystoreBase Db::startTrans(); try { foreach ($list as $k => $v) { + + //删除课程规格 + Spec::where("classes_lib_id",$v->id)->delete(); + $count += $v->delete(); } Db::commit(); diff --git a/application/manystore/controller/school/classes/Evaluate.php b/application/manystore/controller/school/classes/Evaluate.php index ad5a4ef..f636174 100644 --- a/application/manystore/controller/school/classes/Evaluate.php +++ b/application/manystore/controller/school/classes/Evaluate.php @@ -3,6 +3,13 @@ namespace app\manystore\controller\school\classes; use app\common\controller\ManystoreBase; +use app\common\model\manystore\UserAuth; +use app\common\model\User; +use app\manystore\model\Manystore; +use think\Db; +use think\Exception; +use think\exception\PDOException; +use think\exception\ValidateException; /** * 课程反馈管理 @@ -19,7 +26,7 @@ class Evaluate extends ManystoreBase protected $model = null; protected $qSwitch = true; - protected $qFields = ["user_id","classes_lib_id","classes_order_id","manystore_id","shop_id","teacher_id"]; + protected $qFields = ["user_id","classes_lib_id","classes_order_id","manystore_id","shop_id","teacher_id","image","nickname"]; @@ -82,4 +89,210 @@ class Evaluate extends ManystoreBase return $this->view->fetch(); } + + + protected function updateCheck($id,$params=[],$row=null){ + + // 课程存在售后订单则不允许操作 + } + + protected function update_after(&$row) + { + + } + + + 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("id|nickname|realname|mobile", $params["user_id"])->find(); + if(!$user) $this->error("未找到用户请先让用户登录小程序再提交表单".$params["user_id"]); + + + $params["user_id"] = $user["id"]; + + $user_id = $params["user_id"]; + //修改 + if($row){ + + }else{ + //新增 + + } + + + } + + + + /** + * 添加 + * + * @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); + + $this->update_after($this->model); + 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); + $this->update_after($row); + + 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/order/Order.php b/application/manystore/controller/school/classes/order/Order.php index dc14ec1..d3fab3f 100644 --- a/application/manystore/controller/school/classes/order/Order.php +++ b/application/manystore/controller/school/classes/order/Order.php @@ -69,7 +69,7 @@ class Order extends ManystoreBase $row->getRelation('user')->visible(['nickname','realname','mobile','avatar']); $row->getRelation('manystoreshop')->visible(['name','image','address_city','province','city','district','address','address_detail']); $row->getRelation('schoolclasseslib')->visible(['title','headimage']); - $row->getRelation('schoolclassesorderdetail')->visible(['title','headimage',"feel"]); + $row->getRelation('schoolclassesorderdetail')->visible(['title','headimage',"feel","teacher_id"]); $row->getRelation('admin')->visible(['nickname','avatar']); } @@ -110,4 +110,39 @@ class Order extends ManystoreBase return $this->view->fetch(); } + + + /**发起售后 + * @return string + * @throws \think\Exception + * @throws \think\exception\DbException + */ + public function after_sales($ids = ""){ + + if($this->request->isPost()) + { + try{ + $params = $this->request->post("row/a"); + $classes_order = $params["id"]; + $reason = $params["reason"]; + + $model = (new \app\common\model\school\classes\order\ServiceOrder()); + $remark = "机构端管理员帮忙下售后单"; + $model->afterSales($classes_order,$reason,$remark,'shop',$this->auth->id,true); + }catch (\Exception $e){ + $this->error($e->getMessage()); + } + $this->success("执行成功"); + } + + $row = $this->model->where(array('id'=>$ids))->find(); + if (!$row) { + $this->error(__('No Results were found')); + } + +// $row = $this->model->get($param['ids']); + $this->view->assign('row', $row); + return $this->view->fetch(); + } + } diff --git a/application/manystore/lang/zh-cn/general/profile.php b/application/manystore/lang/zh-cn/general/profile.php index 441b6e1..cccfad0 100644 --- a/application/manystore/lang/zh-cn/general/profile.php +++ b/application/manystore/lang/zh-cn/general/profile.php @@ -45,5 +45,21 @@ return [ 'Status 2' => '审核失败', 'Reason' => '审核不通过原因', 'Create_time' => '创建时间', - 'Update_time' => '修改时间' + 'Update_time' => '修改时间', + + "Establish_time" => '成立时间', + "People" => '员工人数', + "Legal_entity" => '法人姓名', + "Gender" => '性别', + "Nation" => '民族', + "Out_look" => '政治面貌', + "Birthtime" => '出生日期', + "Native_place" => '籍贯', + "Card_number" => '身份证号码', + "Diploma" => '学历', + "Post" => '职务', + "Social_position" => '社会职务', + //Male'), '0'=>__('Female' + 'Male' => '男', + 'Female' => '女', ]; 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 0ed1160..8fae615 100644 --- a/application/manystore/lang/zh-cn/school/classes/classes_lib.php +++ b/application/manystore/lang/zh-cn/school/classes/classes_lib.php @@ -22,7 +22,7 @@ return [ 'Type' => '地点类型', 'Type out' => '户外', 'Type in' => '室内', - 'Classes_num' => '多少节课', + 'Classes_num' => '核销次数', 'Address_type' => '地址类型', 'Address_type 1' => '按机构', 'Address_type 2' => '独立位置', diff --git a/application/manystore/lang/zh-cn/school/classes/evaluate.php b/application/manystore/lang/zh-cn/school/classes/evaluate.php index 477941a..b4374f0 100644 --- a/application/manystore/lang/zh-cn/school/classes/evaluate.php +++ b/application/manystore/lang/zh-cn/school/classes/evaluate.php @@ -1,12 +1,12 @@ '评价用户id', - 'Classes_lib_id' => '课程id', - 'Classes_order_id' => '课程订单id', - 'Manystore_id' => '机构账号id', - 'Shop_id' => '机构店铺id', - 'Teacher_id' => '老师id', + 'User_id' => '评价用户', + 'Classes_lib_id' => '课程', + 'Classes_order_id' => '课程订单', + 'Manystore_id' => '机构账号', + 'Shop_id' => '机构店铺', + 'Teacher_id' => '老师', 'Image' => '评价人头像', 'Nickname' => '评价人昵称', 'Classes_star' => '课程评分', diff --git a/application/manystore/model/ManystoreShop.php b/application/manystore/model/ManystoreShop.php index 6b9207f..8d931e6 100644 --- a/application/manystore/model/ManystoreShop.php +++ b/application/manystore/model/ManystoreShop.php @@ -125,4 +125,31 @@ class ManystoreShop extends Model ->update(); } + + public function getEstablishTimeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['establish_time']) ? $data['establish_time'] : ''); + return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; + } + + + protected function setEstablishTimeAttr($value) + { + return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); + } + + + public function getBirthtimeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['birthtime']) ? $data['birthtime'] : ''); + return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; + } + + + protected function setBirthtimeAttr($value) + { + return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); + } + + } diff --git a/application/manystore/validate/Manystore.php b/application/manystore/validate/Manystore.php index 1a07818..5c87b0b 100644 --- a/application/manystore/validate/Manystore.php +++ b/application/manystore/validate/Manystore.php @@ -12,7 +12,7 @@ class Manystore extends Validate */ protected $rule = [ 'username' => 'require|regex:\w{3,12}|unique:manystore', - 'nickname' => 'require|length:0,30|regex:/^[\x{4e00}-\x{9fa5}a-zA-Z0-9_-]+$/u', +// 'nickname' => 'require|length:0,30|regex:/^[\x{4e00}-\x{9fa5}a-zA-Z0-9_-]+$/u', 'password' => 'require|regex:\S{32}', 'email' => 'require|email|unique:manystore,email', ]; @@ -33,23 +33,23 @@ class Manystore extends Validate * 验证场景 */ protected $scene = [ - 'add' => ['username', 'email', 'nickname', 'password'], - 'edit' => ['username', 'email', 'nickname', 'password'], + 'add' => ['username', 'email', 'password'], + 'edit' => ['username', 'email', 'password'], ]; public function __construct(array $rules = [], $message = [], $field = []) { $this->field = [ 'username' => __('Username'), - 'nickname' => __('Nickname'), +// 'nickname' => __('Nickname'), 'password' => __('Password'), 'email' => __('Email'), ]; $this->message = array_merge($this->message, [ 'username.regex' => __('Please input correct username'), 'password.regex' => __('Please input correct password'), - 'nickname.regex' => __('Please input correct nickname'), - 'nickname.length' => __('Please input length nickname'), +// 'nickname.regex' => __('Please input correct nickname'), +// 'nickname.length' => __('Please input length nickname'), ]); parent::__construct($rules, $message, $field); } diff --git a/application/manystore/view/dashboard/index.html b/application/manystore/view/dashboard/index.html index a67dc81..0e85d79 100644 --- a/application/manystore/view/dashboard/index.html +++ b/application/manystore/view/dashboard/index.html @@ -176,6 +176,8 @@
          + {$check_full_msg} +
          diff --git a/application/manystore/view/general/profile/index.html b/application/manystore/view/general/profile/index.html index 1dd6c47..f4eba85 100644 --- a/application/manystore/view/general/profile/index.html +++ b/application/manystore/view/general/profile/index.html @@ -105,6 +105,9 @@ {:token()}
          + + {$check_full_msg} +
          @@ -114,6 +117,17 @@
          + + + + + + +
          @@ -214,7 +228,7 @@ + value="{$shop_info.address_city}" type="text">
          @@ -253,17 +267,20 @@ name="shop[latitude]" type="text" value="{$shop_info.latitude}">
          -