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 @@