From 23f8715a95043d0f08062ca5d58982aa183c43f1 Mon Sep 17 00:00:00 2001 From: 15090180611 <215509543@qq.com> Date: Mon, 18 Nov 2024 19:01:04 +0800 Subject: [PATCH] =?UTF-8?q?1=EF=BC=8C=E5=AE=8C=E5=96=84=E6=9C=BA=E6=9E=84?= =?UTF-8?q?=E5=AE=A1=E6=A0=B8=20=E4=B8=A4=E4=B8=AA=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E7=9A=84=E7=AE=A1=E7=90=86=E5=8A=9F=E8=83=BD=202=EF=BC=8C?= =?UTF-8?q?=E7=AB=99=E5=86=85=E4=BF=A1=E6=8E=A5=E5=8F=A3=203=EF=BC=8C?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=A1=A8=E6=8E=A5=E5=8F=A3=204=EF=BC=8C?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E6=80=BB=E5=90=8E=E5=8F=B0/=E5=88=86?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E7=AE=A1=E7=90=86=EF=BC=88=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E4=B8=AD=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/manystore/Index.php | 62 +++++- .../controller/school/classes/ClassesLib.php | 7 +- .../school/classes/Verification.php | 202 ++++++++++++++++- .../lang/zh-cn/school/classes/order/order.php | 1 + .../model/school/classes/Verification.php | 13 +- .../admin/view/manystore/index/index.html | 10 + .../view/school/classes/classes_lib/add.html | 4 +- .../view/school/classes/order/order/edit.html | 47 ++-- .../school/classes/order/order/index.html | 18 +- .../view/school/classes/verification/add.html | 16 +- .../school/classes/verification/edit.html | 14 +- .../common/controller/ManystoreBase.php | 12 +- .../listener/classeshourorder/OrderHook.php | 2 +- .../common/model/dyqc/ManystoreShop.php | 15 ++ .../manystore/controller/general/Profile.php | 2 + .../controller/school/classes/ClassesLib.php | 6 +- .../school/classes/Verification.php | 209 +++++++++++++++++- application/manystore/lang/zh-cn.php | 5 +- .../manystore/lang/zh-cn/general/profile.php | 31 ++- application/manystore/library/Auth.php | 47 ++++ .../model/school/classes/Verification.php | 18 +- application/manystore/view/common/header.html | 6 +- application/manystore/view/common/menu.html | 6 +- .../manystore/view/dashboard/index.html | 16 ++ .../manystore/view/general/profile/index.html | 116 +++++++++- .../school/classes/classes_lib/index.html | 10 + .../view/school/classes/verification/add.html | 17 +- .../school/classes/verification/edit.html | 17 +- public/assets/js/backend/manystore/index.js | 129 ++++++++++- .../js/backend/school/classes/classes_lib.js | 8 +- .../js/backend/school/classes/verification.js | 22 +- .../manystore/school/classes/classes_lib.js | 7 +- .../manystore/school/classes/verification.js | 54 +++-- 33 files changed, 1010 insertions(+), 139 deletions(-) diff --git a/application/admin/controller/manystore/Index.php b/application/admin/controller/manystore/Index.php index 5e15cb5..4f638d2 100644 --- a/application/admin/controller/manystore/Index.php +++ b/application/admin/controller/manystore/Index.php @@ -4,7 +4,9 @@ namespace app\admin\controller\manystore; use app\admin\model\User; use app\common\model\school\classes\Order; + use app\manystore\model\Manystore; +use app\manystore\model\ManystoreLog; use app\manystore\model\ManystoreShop; use app\manystore\model\ManystoreAuthGroup; use app\manystore\model\ManystoreAuthGroupAccess; @@ -12,6 +14,7 @@ use app\common\controller\Backend; use fast\Random; use fast\Tree; use think\Exception; +use think\Hook; use think\Validate; /** @@ -35,7 +38,7 @@ class Index extends Backend //不用审核允许修改的字段 - protected $no_auth_fields = ['image','images','address_city','province',"city","district","address","address_detail", + protected $no_auth_fields = [ "name",'image','images','address_city','province',"city","district","address","address_detail", "longitude","latitude","content","desc" ]; @@ -57,6 +60,55 @@ class Index extends Backend $this->view->assign("typeList", $this->shopModel->getTypeList()); } + + + /** + * 免登录进入机构后台 + * @return string + * @throws \think\Exception + * @throws \think\db\exception\BindParamException + * @throws \think\exception\DbException + * @throws \think\exception\PDOException + */ + public function free($ids = ''){ + $param = $this->request->param(); + if($this->request->isPost()){ +// try{ + if(isset($param['ids']))$ids = $param['ids']; + //机构登录 + //如果存在登录,先退出登录 + $auth = \app\manystore\library\Auth::instance(); + if($auth->isLogin()){ + $auth->logout(); + Hook::listen("manystore_logout_after", $this->request); + } + //执行登录 + ManystoreLog::setTitle(__('Login')); + $result = $auth->freelogin($ids, 0); + if ($result === true) { + Hook::listen("admin_login_after", $this->request); + $this->success(__('Login successful'), null, [ 'id' => $auth->id, 'avatar' => $auth->avatar]); + } else { + $msg = $auth->getError(); + $msg = $msg ? $msg : __('Username or password is incorrect'); + $this->error($msg, null, ['token' => $this->request->token()]); + } + + + +// }catch (\Exception $e){ +// $this->error($e->getMessage()); +// } + + } + $row = $this->model->get($ids); + $this->view->assign('vo', $row); + return $this->view->fetch(); + } + + + + /** * 查看 */ @@ -135,9 +187,13 @@ class Index extends Backend //审核通过 if($this->success_auth){ //如果是平台下架,则更新成正常下架 - if($params["status"] == 'hidden') $params["status"] = 'normal'; + if($params["status"] == 'hidden')$params["status"] = 'normal'; + + //当前密码 + $password = $params['password'] ? $params['password'] : \app\common\model\dyqc\ManystoreShop::getDefaultPassword($params["type"],$params["user_id"],$params); + //调用通过事件 - $data = ['shop' => $row]; + $data = ['shop' => $row,"password"=>$password]; \think\Hook::listen('shop_auth_success_after', $data); diff --git a/application/admin/controller/school/classes/ClassesLib.php b/application/admin/controller/school/classes/ClassesLib.php index c2c2391..a82012f 100644 --- a/application/admin/controller/school/classes/ClassesLib.php +++ b/application/admin/controller/school/classes/ClassesLib.php @@ -22,6 +22,10 @@ use think\exception\ValidateException; class ClassesLib extends Backend { + protected $qSwitch = true; + protected $qFields = ["teacher_id","user_id","shop_id","manystore_id"]; + + /** * ClassesLib模型对象 * @var \app\admin\model\school\classes\ClassesLib @@ -39,8 +43,9 @@ class ClassesLib extends Backend public function _initialize() { - parent::_initialize(); $this->model = new \app\admin\model\school\classes\ClassesLib; + parent::_initialize(); + $this->view->assign("addTypeList", $this->model->getAddTypeList()); $this->view->assign("typeList", $this->model->getTypeList()); $this->view->assign("addressTypeList", $this->model->getAddressTypeList()); diff --git a/application/admin/controller/school/classes/Verification.php b/application/admin/controller/school/classes/Verification.php index 4dc78bd..1eb3121 100644 --- a/application/admin/controller/school/classes/Verification.php +++ b/application/admin/controller/school/classes/Verification.php @@ -3,6 +3,15 @@ namespace app\admin\controller\school\classes; use app\common\controller\Backend; +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; /** * 机构核销员 @@ -18,10 +27,14 @@ class Verification extends Backend */ protected $model = null; + protected $qSwitch = true; + protected $qFields = ["manystore_id","shop_id"]; + public function _initialize() { - parent::_initialize(); $this->model = new \app\admin\model\school\classes\Verification; + parent::_initialize(); + $this->view->assign("statusList", $this->model->getStatusList()); } @@ -70,4 +83,191 @@ class Verification extends Backend return $this->view->fetch(); } + + + protected function updateCheck($id,$params=[],$row=null){ + + // 课程存在售后订单则不允许操作 + } + + + protected function update_check(&$params,$row=null) + { + + $shop_id = $params["shop_id"]; + $manystore = Manystore::where("shop_id",$shop_id)->find(); + if(!$manystore){ + $this->error("店铺不存在"); + } + //用户不存在 + $user_id = $params["user_id"]; + $user = User::where("id",$user_id)->find(); + if(!$user){ + $this->error("用户不存在"); + } + + //修改 + if($row){ + //用户已是其他的教师(搜索) + $teacher_user = $this->model->where("user_id",$user_id)->where("id","<>",$row["id"])->find(); + if($teacher_user){ + $this->error("用户已存在或已是其他授权机构核销员!"); + } + }else{ + //新增 + //用户已是教师(搜索) + $teacher_user = $this->model->where("user_id",$user_id)->find(); + if($teacher_user){ + $this->error("用户已存在或已是其他授权机构核销员!"); + } + } + + + + + + + + $params["manystore_id"] = $manystore["id"]; + } + + + /** + * 添加 + * + * @return string + * @throws \think\Exception + */ + public function add() + { + if (false === $this->request->isPost()) { + return $this->view->fetch(); + } + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + $params = $this->preExcludeFields($params); + + if ($this->dataLimit && $this->dataLimitFieldAutoFill) { + $params[$this->dataLimitField] = $this->auth->id; + } + $result = false; + Db::startTrans(); + try { + //是否采用模型验证 + if ($this->modelValidate) { + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; + $this->model->validateFailException()->validate($validate); + } + $this->update_check($params,$row=null); + $result = $this->model->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if ($result === false) { + $this->error(__('No rows were inserted')); + } + $this->success(); + } + + /** + * 编辑 + * + * @param $ids + * @return string + * @throws DbException + * @throws \think\Exception + */ + public function edit($ids = null) + { + $row = $this->model->get($ids); + if (!$row) { + $this->error(__('No Results were found')); + } + $adminIds = $this->getDataLimitAdminIds(); + if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) { + $this->error(__('You have no permission')); + } + if (false === $this->request->isPost()) { + $this->view->assign('row', $row); + return $this->view->fetch(); + } + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + $params = $this->preExcludeFields($params); + $result = false; + Db::startTrans(); + try { + //是否采用模型验证 + if ($this->modelValidate) { + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; + $row->validateFailException()->validate($validate); + } + $this->update_check($params,$row); + $result = $row->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if (false === $result) { + $this->error(__('No rows were updated')); + } + $this->success(); + } + + /** + * 删除 + * + * @param $ids + * @return void + * @throws DbException + * @throws DataNotFoundException + * @throws ModelNotFoundException + */ + public function del($ids = null) + { + if (false === $this->request->isPost()) { + $this->error(__("Invalid parameters")); + } + $ids = $ids ?: $this->request->post("ids"); + if (empty($ids)) { + $this->error(__('Parameter %s can not be empty', 'ids')); + } + $pk = $this->model->getPk(); + $adminIds = $this->getDataLimitAdminIds(); + if (is_array($adminIds)) { + $this->model->where($this->dataLimitField, 'in', $adminIds); + } + $list = $this->model->where($pk, 'in', $ids)->select(); + foreach ($list as $item) { + $this->updateCheck($item->id); + } + + + $count = 0; + Db::startTrans(); + try { + foreach ($list as $item) { + $count += $item->delete(); + } + Db::commit(); + } catch (PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if ($count) { + $this->success(); + } + $this->error(__('No rows were deleted')); + } + + } diff --git a/application/admin/lang/zh-cn/school/classes/order/order.php b/application/admin/lang/zh-cn/school/classes/order/order.php index e9bd221..5affc8c 100644 --- a/application/admin/lang/zh-cn/school/classes/order/order.php +++ b/application/admin/lang/zh-cn/school/classes/order/order.php @@ -2,6 +2,7 @@ return [ 'Order_no' => '订单号', + 'Edit'=>'订单详情', 'Pay_no' => '微信支付单号', 'User_id' => '下单人id', 'Manystore_id' => '机构账号id', diff --git a/application/admin/model/school/classes/Verification.php b/application/admin/model/school/classes/Verification.php index 18bcc47..8884c91 100644 --- a/application/admin/model/school/classes/Verification.php +++ b/application/admin/model/school/classes/Verification.php @@ -25,8 +25,19 @@ class Verification extends Model // 追加属性 protected $append = [ - 'status_text' + 'status_text', + 'classes_title' ]; + + + public function getClassesTitleAttr($value, $data) + { + $classes_lib_ids = (isset($data['classes_lib_ids']) ? $data['classes_lib_ids'] : ''); + if(!$classes_lib_ids) return ''; + //$classes_cate_ids 查询分类表 names 已逗号拼接返回 + $classes_cate_title = ClassesLib::where('id','in',$classes_lib_ids)->column('title'); + return implode(',',$classes_cate_title); + } diff --git a/application/admin/view/manystore/index/index.html b/application/admin/view/manystore/index/index.html index 98b0428..6d4c4d4 100644 --- a/application/admin/view/manystore/index/index.html +++ b/application/admin/view/manystore/index/index.html @@ -15,6 +15,16 @@