From 35904ee8bec224000b0b22a7a1d5d1d7866df626 Mon Sep 17 00:00:00 2001
From: 15090180611 <215509543@qq.com>
Date: Wed, 20 Nov 2024 18:05:45 +0800
Subject: [PATCH] =?UTF-8?q?1=EF=BC=8C=E5=AE=8C=E6=88=90=E6=80=BB=E5=90=8E?=
=?UTF-8?q?=E5=8F=B0=E5=88=86=E5=90=8E=E5=8F=B0=E8=AE=A2=E5=8D=95=E6=89=80?=
=?UTF-8?q?=E6=9C=89=E7=89=B9=E6=9D=83=E9=80=BB=E8=BE=91=202=EF=BC=8C?=
=?UTF-8?q?=E5=AE=8C=E6=88=90=E7=AB=99=E5=86=85=E4=BF=A1=E6=8E=A5=E5=8F=A3?=
=?UTF-8?q?=E5=92=8C=E5=90=8E=E5=8F=B0=E7=AE=A1=E7=90=86=203=EF=BC=8C?=
=?UTF-8?q?=E5=AE=8C=E6=88=90=E7=AB=99=E5=86=85=E4=BF=A1=E6=AF=8F=E4=B8=AA?=
=?UTF-8?q?=E6=B5=81=E7=A8=8B=E7=9A=84=E5=9F=8B=E7=82=B9=E5=92=8C=E9=80=9A?=
=?UTF-8?q?=E7=9F=A5=204=EF=BC=8C=E5=AF=B9=E6=8E=A5=E6=B5=8B=E8=AF=95?=
=?UTF-8?q?=E8=AE=A2=E5=8D=95=E9=A2=84=E7=BA=A6=E6=B5=81=E7=A8=8B=E5=AE=8C?=
=?UTF-8?q?=E6=88=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../admin/controller/manystore/Index.php | 27 +-
.../admin/controller/school/Message.php | 1 +
.../controller/school/classes/ClassesLib.php | 44 +++
.../school/classes/hourorder/Order.php | 251 +++++++++++++-
.../controller/school/classes/order/Order.php | 28 ++
application/admin/controller/user/User.php | 29 ++
.../lang/zh-cn/school/classes/classes_lib.php | 4 +-
.../zh-cn/school/classes/hourorder/order.php | 15 +-
.../admin/lang/zh-cn/school/message.php | 4 +
application/admin/model/school/Message.php | 33 +-
.../model/school/classes/hourorder/Order.php | 34 +-
.../admin/view/manystore/index/add.html | 7 +
.../admin/view/manystore/index/edit.html | 9 +
.../admin/view/manystore/index/index.html | 3 +
.../admin/view/manystore/user_auth/add.html | 6 +
.../admin/view/manystore/user_auth/edit.html | 7 +
.../view/school/classes/classes_lib/add.html | 20 ++
.../view/school/classes/classes_lib/edit.html | 20 ++
.../school/classes/classes_lib/index.html | 3 +
.../school/classes/hourorder/order/add.html | 107 +-----
.../school/classes/hourorder/order/edit.html | 110 +------
.../classes/hourorder/order/examine.html | 32 ++
.../school/classes/hourorder/order/index.html | 27 +-
.../classes/hourorder/order_log/index.html | 28 +-
.../view/school/classes/order/order/edit.html | 186 +++++------
.../school/classes/order/order/index.html | 4 +-
.../classes/order/order_detail/index.html | 14 +-
.../school/classes/order/order_log/index.html | 28 +-
.../view/school/classes/teacher/add.html | 7 +
.../view/school/classes/teacher/edit.html | 7 +
.../view/school/classes/verification/add.html | 6 +
.../school/classes/verification/edit.html | 6 +
.../school/classes/virtual_user/edit.html | 27 +-
.../admin/view/school/message/add.html | 8 +
.../admin/view/school/message/edit.html | 8 +
.../admin/view/user/user/changeuser.html | 27 ++
application/admin/view/user/user/index.html | 2 +
application/api/controller/school/Message.php | 129 ++++++++
application/common/hooks.php | 4 +-
application/common/library/Auth.php | 71 ++++
.../common/listener/classes/ClassesHook.php | 106 ++++++
.../listener/classeshourorder/OrderHook.php | 155 ++++++++-
.../listener/classesorder/OrderHook.php | 92 +++++-
.../common/listener/manystore/ShopHook.php | 81 +++++
application/common/model/User.php | 53 ++-
application/common/model/school/Message.php | 181 ++++++++++-
.../model/school/classes/ClassesLib.php | 3 +-
.../model/school/classes/hourorder/Order.php | 35 +-
.../school/classes/hourorder/OrderLog.php | 5 +-
.../model/school/classes/order/Order.php | 2 +-
.../model/school/classes/order/OrderLog.php | 2 +-
.../controller/manystore/UserAuth.php | 29 ++
.../controller/school/classes/ClassesLib.php | 19 ++
.../controller/school/classes/ClassesSpec.php | 6 +-
.../school/classes/hourorder/Order.php | 244 +++++++++++++-
.../controller/school/classes/order/Order.php | 30 ++
.../lang/zh-cn/school/classes/classes_lib.php | 4 +-
.../zh-cn/school/classes/hourorder/order.php | 15 +-
.../lang/zh-cn/school/classes/order/order.php | 1 +
application/manystore/model/ManystoreShop.php | 5 +-
.../model/school/classes/hourorder/Order.php | 20 +-
.../manystore/view/general/profile/index.html | 6 +-
.../view/manystore/user_auth/changeuser.html | 27 ++
.../view/school/classes/classes_lib/add.html | 31 +-
.../view/school/classes/classes_lib/edit.html | 18 +-
.../school/classes/hourorder/order/add.html | 107 +-----
.../school/classes/hourorder/order/edit.html | 111 +------
.../classes/hourorder/order/examine.html | 32 ++
.../school/classes/hourorder/order/index.html | 26 +-
.../classes/hourorder/order_log/index.html | 24 +-
.../view/school/classes/order/order/edit.html | 305 +++++++++---------
.../school/classes/order/order/index.html | 22 +-
.../classes/order/order_detail/index.html | 26 +-
.../school/classes/order/order_log/index.html | 24 +-
.../view/school/classes/teacher/add.html | 6 +-
.../view/school/classes/teacher/edit.html | 6 +-
.../view/school/classes/verification/add.html | 6 +-
.../school/classes/verification/edit.html | 6 +-
public/assets/js/backend/manystore/index.js | 71 +++-
.../assets/js/backend/manystore/user_auth.js | 20 ++
.../js/backend/school/classes/classes_lib.js | 44 ++-
.../js/backend/school/classes/classes_spec.js | 48 ++-
.../backend/school/classes/hourorder/order.js | 152 +++++++--
.../school/classes/hourorder/order_log.js | 11 +-
.../js/backend/school/classes/order/order.js | 210 +++++++++---
.../school/classes/order/order_detail.js | 75 +++--
.../backend/school/classes/order/order_log.js | 8 +-
.../js/backend/school/classes/teacher.js | 20 ++
.../js/backend/school/classes/verification.js | 20 ++
.../js/backend/school/classes/virtual_user.js | 3 +
public/assets/js/backend/school/message.js | 17 +-
public/assets/js/backend/user/user.js | 28 ++
.../js/manystore/manystore/user_auth.js | 24 ++
.../js/manystore/school/classes/cate.js | 4 +-
.../manystore/school/classes/classes_lib.js | 38 ++-
.../manystore/school/classes/classes_spec.js | 55 +++-
.../js/manystore/school/classes/collect.js | 2 +-
.../school/classes/hourorder/order.js | 158 +++++++--
.../school/classes/hourorder/order_log.js | 9 +-
.../manystore/school/classes/order/order.js | 214 +++++++++---
.../school/classes/order/order_detail.js | 75 +++--
.../school/classes/order/order_log.js | 11 +-
.../js/manystore/school/classes/teacher.js | 30 +-
.../manystore/school/classes/verification.js | 24 +-
104 files changed, 3518 insertions(+), 1107 deletions(-)
create mode 100644 application/admin/view/school/classes/hourorder/order/examine.html
create mode 100644 application/admin/view/user/user/changeuser.html
create mode 100644 application/api/controller/school/Message.php
create mode 100644 application/common/listener/classes/ClassesHook.php
create mode 100644 application/manystore/view/manystore/user_auth/changeuser.html
create mode 100644 application/manystore/view/school/classes/hourorder/order/examine.html
diff --git a/application/admin/controller/manystore/Index.php b/application/admin/controller/manystore/Index.php
index 4f638d2..e529569 100644
--- a/application/admin/controller/manystore/Index.php
+++ b/application/admin/controller/manystore/Index.php
@@ -58,6 +58,8 @@ class Index extends Backend
$this->shopModel = new ManystoreShop();
$this->view->assign("statusList", $this->shopModel->getStatusList());
$this->view->assign("typeList", $this->shopModel->getTypeList());
+ $this->view->assign("shop_backend_url", config("site.shop_backend_url"));
+
}
@@ -190,11 +192,11 @@ class Index extends Backend
if($params["status"] == 'hidden')$params["status"] = 'normal';
//当前密码
- $password = $params['password'] ? $params['password'] : \app\common\model\dyqc\ManystoreShop::getDefaultPassword($params["type"],$params["user_id"],$params);
+// $password = $params['password'] ? $params['password'] : \app\common\model\dyqc\ManystoreShop::getDefaultPassword($params["type"],$params["user_id"],$params);
//调用通过事件
- $data = ['shop' => $row,"password"=>$password];
- \think\Hook::listen('shop_auth_success_after', $data);
+// $data = ['shop' => $row,"password"=>$password];
+// \think\Hook::listen('shop_auth_success_after', $data);
}
@@ -203,8 +205,8 @@ class Index extends Backend
$params["status"] = 'hidden';
//调用通过事件
//调用通过事件
- $data = ['shop' => $row];
- \think\Hook::listen('shop_auth_fail_after', $data);
+// $data = ['shop' => $row];
+// \think\Hook::listen('shop_auth_fail_after', $data);
}
@@ -403,6 +405,21 @@ class Index extends Backend
$this->error(__("修改商家信息资料失败"));
}
+ if($this->success_auth){
+ //当前密码
+ $password = $params['password'] ? $params['password'] : \app\common\model\dyqc\ManystoreShop::getDefaultPassword($params["type"],$params["user_id"],$params);
+ //调用通过事件
+ $data = ['shop' => $row,"password"=>$password];
+ \think\Hook::listen('shop_auth_success_after', $data);
+ }
+ if($this->error_auth){
+
+ //调用通过事件
+ $data = ['shop' => $row];
+ \think\Hook::listen('shop_auth_fail_after', $data);
+ }
+
+
if ($params['password']) {
if (!Validate::is($params['password'], '\S{6,16}')) {
$this->error(__("Please input correct password"));
diff --git a/application/admin/controller/school/Message.php b/application/admin/controller/school/Message.php
index 3726907..728d563 100644
--- a/application/admin/controller/school/Message.php
+++ b/application/admin/controller/school/Message.php
@@ -25,6 +25,7 @@ class Message extends Backend
$this->view->assign("platformList", $this->model->getPlatformList());
$this->view->assign("operTypeList", $this->model->getOperTypeList());
$this->view->assign("toTypeList", $this->model->getToTypeList());
+ $this->view->assign("typeList", $this->model->getTypeList());
$this->view->assign("statusList", $this->model->getStatusList());
$this->view->assign("miniTypeList", $this->model->getMiniTypeList());
}
diff --git a/application/admin/controller/school/classes/ClassesLib.php b/application/admin/controller/school/classes/ClassesLib.php
index a82012f..9eabad6 100644
--- a/application/admin/controller/school/classes/ClassesLib.php
+++ b/application/admin/controller/school/classes/ClassesLib.php
@@ -40,6 +40,7 @@ class ClassesLib extends Backend
protected $have_auth = false;
protected $success_auth = false;
+ protected $error_auth = false;
public function _initialize()
{
@@ -130,11 +131,29 @@ class ClassesLib extends Backend
//审核通过
$this->success_auth = true;
}
+
+ if($params["auth_status"] == '2'){
+ //审核通过
+ $this->error_auth = true;
+ }
}
//审核通过
if($this->success_auth){
//如果是平台下架,则更新成正常下架
if($params["status"] == '3') $params["status"] = '2';
+
+ //调用通过事件
+// $data = ['shop' => $row];
+// \think\Hook::listen('classes_auth_success_after', $data);
+ }
+
+
+ if($this->error_auth){
+
+ //调用通过事件
+// $data = ['shop' => $row];
+// \think\Hook::listen('classes_auth_fail_after', $data);
+
}
}else{
@@ -387,6 +406,31 @@ class ClassesLib extends Backend
}
$this->update_check($params,$row);
$result = $row->allowField(true)->save($params);
+
+
+ if($this->success_auth){
+ //调用通过事件
+ $data = ['classes' => $row];
+ \think\Hook::listen('classes_auth_success_after', $data);
+ }
+
+
+ if($this->error_auth){
+ //调用通过事件
+ $data = ['classes' => $row];
+ \think\Hook::listen('classes_auth_fail_after', $data);
+
+ }
+ // protected $have_auth = false;
+ if($this->have_auth){
+ //调用通过事件
+ $data = ['classes' => $row];
+ \think\Hook::listen('classes_auth_need_after', $data);
+
+ }
+
+
+
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
diff --git a/application/admin/controller/school/classes/hourorder/Order.php b/application/admin/controller/school/classes/hourorder/Order.php
index 2b6f4a2..e0d105b 100644
--- a/application/admin/controller/school/classes/hourorder/Order.php
+++ b/application/admin/controller/school/classes/hourorder/Order.php
@@ -3,6 +3,12 @@
namespace app\admin\controller\school\classes\hourorder;
use app\common\controller\Backend;
+use think\Db;
+use think\db\exception\DataNotFoundException;
+use think\db\exception\ModelNotFoundException;
+use think\exception\DbException;
+use think\exception\PDOException;
+use think\exception\ValidateException;
/**
* 课时订单
@@ -18,11 +24,16 @@ class Order extends Backend
*/
protected $model = null;
+ protected $qSwitch = true;
+ protected $qFields = ["classes_order_id","classes_lib_spec_id","user_id","classes_order_detail_id","classes_lib_id"];
+
public function _initialize()
{
- parent::_initialize();
$this->model = new \app\admin\model\school\classes\hourorder\Order;
+ parent::_initialize();
+
$this->view->assign("statusList", $this->model->getStatusList());
+ $this->view->assign("authStatusList", $this->model->getAuthStatusList());
}
@@ -72,4 +83,242 @@ class Order extends Backend
return $this->view->fetch();
}
+
+
+
+
+
+
+
+ /**
+ * 添加
+ *
+ * @return string
+ * @throws \think\Exception
+ */
+ public function add()
+ {
+ if (false === $this->request->isPost()) {
+ return $this->view->fetch();
+ }
+ $params = $this->request->post('row/a');
+ if (empty($params)) {
+ $this->error(__('Parameter %s can not be empty', ''));
+ }
+ $params = $this->preExcludeFields($params);
+
+ if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
+ $params[$this->dataLimitField] = $this->auth->id;
+ }
+ $result = false;
+
+ 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);
+ }
+
+ //记录代下单人信息
+ $param = [
+ "type" =>'2',
+ "help_user_id" =>$this->auth->id,
+ "help_type" => 'admin',
+ ];
+ //确认订单
+ $res = (new \app\common\model\school\classes\hourorder\Order)->confirm($this->auth->id,$params['classes_order_id'],null, $params['classes_lib_spec_id'],$param, true);
+ $remark = "总后台管理员帮忙下课时预约";
+ //创建订单
+ $result = (new \app\common\model\school\classes\hourorder\Order)->cacheCreateOrder($res['order_no'], $this->auth->id,$remark, true);
+
+
+
+ } catch (ValidateException|PDOException|\Exception $e) {
+
+ $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;
+
+ 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);
+ }
+
+
+
+
+ //记录代下单人信息
+
+ //修改订单课时
+ $result = (new \app\common\model\school\classes\hourorder\Order)->updateClassesSpec($row["id"],$params["classes_lib_spec_id"],0,true,'admin',$this->auth->id,true);
+
+
+
+ } catch (ValidateException|PDOException|\Exception $e) {
+
+ $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();
+
+ $count = 0;
+
+ try {
+ foreach ($list as $item) {
+ $res = (new \app\common\model\school\classes\hourorder\Order)->cancel($item["id"],0,true,'admin',$this->auth->id,true);
+ $count++;
+ }
+
+ } catch (PDOException|\Exception $e) {
+
+ $this->error($e->getMessage());
+ }
+ if ($count) {
+ $this->success();
+ }
+ $this->error(__('No rows were deleted'));
+ }
+
+
+
+
+ /**预约审核
+ * @return string
+ * @throws \think\Exception
+ * @throws \think\exception\DbException
+ */
+ public function examine($ids = ""){
+
+ if($this->request->isPost())
+ {
+ try{
+ $params = $this->request->post("row/a");
+
+
+ $auth_status = $params["auth_status"];
+ $reason = $params["reason"];
+ $model = (new \app\common\model\school\classes\hourorder\Order);
+ $model->examine($params["id"],$auth_status,$reason,0,true,'admin',$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();
+ }
+
+
+
+
+
+ /**
+ * 后台核销
+ * @return string
+ * @throws \think\Exception
+ * @throws \think\db\exception\BindParamException
+ * @throws \think\exception\DbException
+ * @throws \think\exception\PDOException
+ */
+ public function verification($ids = ''){
+ $param = $this->request->param();
+ if($this->request->isPost()){
+ try{
+ if(isset($param['ids']))$ids = $param['ids'];
+ //设置模拟资格
+ $model = (new \app\common\model\school\classes\hourorder\Order);
+ $model->verification($ids,0,true,'admin',$this->auth->id,true);
+
+
+ }catch (\Exception $e){
+ $this->error($e->getMessage());
+ }
+ $this->success('核销成功!');
+ }
+ $row = $this->model->get($ids);
+ $this->view->assign('vo', $row);
+ return $this->view->fetch();
+ }
+
+
+
+
+
}
diff --git a/application/admin/controller/school/classes/order/Order.php b/application/admin/controller/school/classes/order/Order.php
index c40c9fd..894655a 100644
--- a/application/admin/controller/school/classes/order/Order.php
+++ b/application/admin/controller/school/classes/order/Order.php
@@ -77,4 +77,32 @@ class Order extends Backend
return $this->view->fetch();
}
+ /**
+ * 课程订单取消
+ * @return string
+ * @throws \think\Exception
+ * @throws \think\db\exception\BindParamException
+ * @throws \think\exception\DbException
+ * @throws \think\exception\PDOException
+ */
+ public function cancel($ids = ''){
+ $param = $this->request->param();
+ if($this->request->isPost()){
+ try{
+ if(isset($param['ids']))$ids = $param['ids'];
+ //设置模拟资格
+ $model = (new \app\common\model\school\classes\order\Order);
+ $model->cancel($ids,0,true,'admin',$this->auth->id,true);;
+
+
+ }catch (\Exception $e){
+ $this->error($e->getMessage());
+ }
+ $this->success('取消成功!');
+ }
+ $row = $this->model->get($ids);
+ $this->view->assign('vo', $row);
+ return $this->view->fetch();
+ }
+
}
diff --git a/application/admin/controller/user/User.php b/application/admin/controller/user/User.php
index 3ce698a..948664b 100644
--- a/application/admin/controller/user/User.php
+++ b/application/admin/controller/user/User.php
@@ -247,4 +247,33 @@ class User extends Backend
return json(['list' => $list, 'total' => $total]);
}
+
+
+ /**变更学员信息(教练专属)
+ * @return string
+ * @throws \think\Exception
+ * @throws \think\exception\DbException
+ */
+ public function changeuser(){
+ if($this->request->isPost())
+ {
+ try{
+ $people_name = $this->request->param('people_name/s');
+ $people_mobile = $this->request->param('people_mobile/s');
+ $user = \app\common\model\User::where("mobile",$people_mobile)->find();
+ //检测更新教练下单学员账号创建状态 2022/8/27 new
+ if(!$user)$user = (new \app\common\model\User)->addUserByMobile($people_mobile,$people_name);
+ $user['nickname'] = $people_name;
+ $user->save();
+ }catch (\Exception $e){
+ $this->error($e->getMessage());
+ }
+ //退押金
+ $this->success("已成功创建{$people_name}");
+ }
+// $row = $this->model->get($param['ids']);
+// $this->view->assign('vo', $row);
+ return $this->view->fetch();
+ }
+
}
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 372c5ef..a586afc 100644
--- a/application/admin/lang/zh-cn/school/classes/classes_lib.php
+++ b/application/admin/lang/zh-cn/school/classes/classes_lib.php
@@ -4,8 +4,8 @@ return [
'Manystore_id' => '机构账号id',
'Shop_id' => '机构店铺id',
'User_id' => '主讲师用户id',
- 'Classes_cate_ids' => '平台课程分类ids',
- 'Classes_label_ids' => '平台课程类型ids',
+ 'Classes_cate_ids' => '平台课程分类',
+ 'Classes_label_ids' => '平台课程热门标签',
'Self_label_tag' => '机构特色标签',
'Add_type' => '添加人类型',
'Add_type 1' => '机构',
diff --git a/application/admin/lang/zh-cn/school/classes/hourorder/order.php b/application/admin/lang/zh-cn/school/classes/hourorder/order.php
index 3432102..d9fb0de 100644
--- a/application/admin/lang/zh-cn/school/classes/hourorder/order.php
+++ b/application/admin/lang/zh-cn/school/classes/hourorder/order.php
@@ -2,8 +2,21 @@
return [
'Order_no' => '订单号',
+
+ 'Edit'=>'修改用户预约的课时',
+ 'Add'=>'帮用户预约课时',
+ 'Delete'=>'帮用户取消预约',
+ 'Del'=>'帮用户取消预约',
+ 'Auth_status' => '审核状态',
+ 'Auth_status 0' => '待审核',
+ 'Auth_status 1' => '审核通过',
+ 'Auth_status 2' => '审核失败',
+ 'Reason' => '审核不通过原因',
+ 'Auth_time' => '审核时间',
+ 'Admin_id' => '审核管理员id',
+
'Classes_order_id' => '课程订单id',
- 'Classes_lib_spec_id' => '课时id',
+ 'Classes_lib_spec_id' => '选择要预约的课时',
'User_id' => '下单人id',
'Classes_order_detail_id' => '订单课程id',
'Classes_lib_id' => '课程id',
diff --git a/application/admin/lang/zh-cn/school/message.php b/application/admin/lang/zh-cn/school/message.php
index d2c0e84..82dcca1 100644
--- a/application/admin/lang/zh-cn/school/message.php
+++ b/application/admin/lang/zh-cn/school/message.php
@@ -1,6 +1,10 @@
'已读状态',
+ 'Type 1' => '未读',
+ 'Type 2' => '已读',
+ 'Weigh' => '权重',
'Platform' => '消息平台',
'Platform admin' => '总后台',
'Platform user' => '用户端',
diff --git a/application/admin/model/school/Message.php b/application/admin/model/school/Message.php
index 45e1393..e9c6ab0 100644
--- a/application/admin/model/school/Message.php
+++ b/application/admin/model/school/Message.php
@@ -29,11 +29,36 @@ class Message extends Model
'oper_type_text',
'to_type_text',
'status_text',
- 'mini_type_text'
+ 'mini_type_text',
+ "type_text"
];
-
-
+ protected static function init()
+ {
+ self::afterInsert(function ($row) {
+ if (!$row['weigh']) {
+ $pk = $row->getPk();
+ $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
+ }
+ });
+ }
+
+
+
+ public function getTypeList()
+ {
+ return ['1' => __('Type 1'), '2' => __('Type 2')];
+ }
+
+ public function getTypeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
+ $list = $this->getTypeList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+
public function getPlatformList()
{
return ['admin' => __('Platform admin'), 'user' => __('Platform user'), 'shop' => __('Platform shop')];
@@ -60,6 +85,8 @@ class Message extends Model
}
+
+
public function getPlatformTextAttr($value, $data)
{
$value = $value ?: ($data['platform'] ?? '');
diff --git a/application/admin/model/school/classes/hourorder/Order.php b/application/admin/model/school/classes/hourorder/Order.php
index 5fa1483..e52c1dd 100644
--- a/application/admin/model/school/classes/hourorder/Order.php
+++ b/application/admin/model/school/classes/hourorder/Order.php
@@ -30,11 +30,33 @@ class Order extends Model
'status_text',
'reservation_time_text',
'finish_time_text',
- 'cancel_time_text'
+ 'cancel_time_text',
+ 'auth_status_text',
];
-
-
+
+ public function getAuthStatusList()
+ {
+ return ['0' => __('Auth_status 0'), '1' => __('Auth_status 1'), '2' => __('Auth_status 2')];
+ }
+
+ public function getAuthStatusTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['auth_status']) ? $data['auth_status'] : '');
+ $list = $this->getAuthStatusList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getStatusTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
+ $list = $this->getStatusList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+
public function getStatusList()
{
return ['-3' => __('Status -3'),'-1' => __('Status -1'), '0' => __('Status 0'), '3' => __('Status 3')];
@@ -55,12 +77,6 @@ class Order extends Model
}
- public function getStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
- $list = $this->getStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
public function getReservationTimeTextAttr($value, $data)
diff --git a/application/admin/view/manystore/index/add.html b/application/admin/view/manystore/index/add.html
index 1165bb4..22a177f 100644
--- a/application/admin/view/manystore/index/add.html
+++ b/application/admin/view/manystore/index/add.html
@@ -39,9 +39,16 @@
{:__('User_id')}:
+
+
\ No newline at end of file
diff --git a/application/admin/view/manystore/user_auth/add.html b/application/admin/view/manystore/user_auth/add.html
index a111e11..18b283c 100644
--- a/application/admin/view/manystore/user_auth/add.html
+++ b/application/admin/view/manystore/user_auth/add.html
@@ -10,6 +10,12 @@
{:__('User_id')}:
@@ -29,12 +36,25 @@
{:__('Classes_cate_ids')}:
@@ -30,12 +36,24 @@
{:__('Classes_cate_ids')}:
diff --git a/application/admin/view/school/classes/classes_lib/index.html b/application/admin/view/school/classes/classes_lib/index.html
index f7a8351..364a02e 100644
--- a/application/admin/view/school/classes/classes_lib/index.html
+++ b/application/admin/view/school/classes/classes_lib/index.html
@@ -16,6 +16,9 @@
+
+
+
+
+
+
+
+
+
model = new \app\common\model\school\Message();
+ parent::_initialize();
+
+ //判断登录用户是否是员工
+ }
+
+
+ /**
+ * @ApiTitle( 站内信详情-确认已读)
+ * @ApiSummary(站内信详情-确认已读)
+ * @ApiRoute(/api/school/message/detail)
+ * @ApiMethod(GET)
+ * @ApiParams(name = "id", type = "int",required=true,description = "消息id")
+ * @ApiReturn({
+ *
+ *})
+ */
+ public function detail(){
+ $id = $this->request->get('id/d','');
+
+ if(empty($id)){
+ $this->error(__('缺少必要参数'));
+ }
+
+ try {
+ $res = $this->model::getDetail($id);
+ } catch (\Exception $e){
+// Log::log($e->getMessage());
+ $this->error($e->getMessage(),['errcode'=>$e->getCode()]);
+ }
+ $this->success('获取成功', ['detail' => $res]);
+ }
+
+
+
+
+
+ /**
+ * @ApiTitle( 我的消息列表接口)
+ * @ApiSummary(我的消息列表接口)
+ * @ApiRoute(/api/school/message/message_list)
+ * @ApiMethod(GET)
+ * @ApiParams(name = "keywords", type = "string",required=false,description = "搜索关键字")
+ * @ApiParams(name = "page", type = "string",required=true,description = "页数")
+ * @ApiParams(name = "limit", type = "string",required=true,description = "条数")
+ * @ApiParams(name = "status", type = "string",required=false,description = "消息总类型:system=系统消息,classes=课程消息,order=订单消息")
+ * @ApiParams(name = "mini_type", type = "string",required=false,description = "小消息类型:order_notice=课程订单通知,classes_auth=课程报名审核,classes_apply=课程上新审核,shop_apply=机构审核,classes_order_notice=课时预约,user_auth=机构授权用户信息,aftercare=售后服务,other=其他")
+ *@ApiParams(name = "type", type = "string",required=false,description = "已读状态:1=未读,2=已读")
+ *
+ * @ApiReturn({
+ *
+ *})
+ */
+ public function message_list()
+ {
+ $user_id = 0;
+ $user = $this->auth->getUser();//登录用户
+ if($user)$user_id = $user['id'];
+ $page = $this->request->get('page/d', 0); //页数
+ $limit = $this->request->get('limit/d', 0); //条数
+ $keywords = $this->request->get('keywords/s', ''); //搜索关键字
+ $status = $this->request->get('status/s', ''); //搜索关键字
+ $mini_type = $this->request->get('mini_type/s', ''); //搜索关键字
+ $type = $this->request->get('type/s', ''); //搜索关键字
+// $type = $this->request->get('type/s', ''); //筛选学员和教练单
+ $to_id = $user_id;
+ try{
+ //当前申请状态
+ $res = $this->model::messageList($page, $limit,$to_id,$keywords,$status,$mini_type,$type);
+// if($user_id =='670153'){
+// file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql());
+// }
+ }catch (\Exception $e){
+
+ $this->error($e->getMessage());
+ }
+ $this->success('查询成功', $res);
+ }
+
+
+ /**
+ * @ApiTitle( 我的消息数量接口)
+ * @ApiSummary(我的消息数量接口)
+ * @ApiRoute(/api/school/message/message_count)
+ * @ApiMethod(GET)
+ * @ApiReturn({
+ *
+ *})
+ */
+ public function message_count(){
+ $user_id = 0;
+ $user = $this->auth->getUser();//登录用户
+ if($user)$user_id = $user['id'];
+
+ try{
+ $res = $this->model::messageCount($user_id);
+ }catch (\Throwable $e){
+ $this->error($e->getMessage());
+ }
+ $this->success('查询成功', $res);
+ }
+
+
+}
+
diff --git a/application/common/hooks.php b/application/common/hooks.php
index de55ef9..7c0374e 100644
--- a/application/common/hooks.php
+++ b/application/common/hooks.php
@@ -12,7 +12,7 @@ $defaultHooks = [
'app\\common\\listener\\classesorder\\OrderHook'
],
'classes_order_cancel_after' => [ // 订单取消后
- 'addons\\shopro\\listener\\classesorder\\OrderHook'
+ 'app\\common\\listener\\classesorder\\OrderHook'
],
'classes_order_finish_after' => [ // 订单完成后
@@ -54,7 +54,7 @@ $hourHooks = [
'app\\common\\listener\\classeshourorder\\OrderHook'
],
'classeshour_order_cancel_after' => [ // 订单取消后
- 'addons\\shopro\\listener\\classeshourorder\\OrderHook'
+ 'app\\common\\listener\\classeshourorder\\OrderHook'
],
];
diff --git a/application/common/library/Auth.php b/application/common/library/Auth.php
index cea4d32..c98aa9a 100644
--- a/application/common/library/Auth.php
+++ b/application/common/library/Auth.php
@@ -201,6 +201,77 @@ class Auth
return true;
}
+
+ /**
+ * 注册用户(自定义)
+ *
+ * @param string $username 用户名
+ * @param string $password 密码
+ * @param string $email 邮箱
+ * @param string $mobile 手机号
+ * @param array $extend 扩展参数
+ */
+ public function registerNoLogin($username, $password, $email = '', $mobile = '', $extend = [])
+ {
+ // 检测用户名、昵称、邮箱、手机号是否存在
+ if (User::getByUsername($username)) {
+ $this->setError('Username already exist');
+ return false;
+ }
+ if (User::getByNickname($username)) {
+ $this->setError('Nickname already exist');
+ return false;
+ }
+ if ($email && User::getByEmail($email)) {
+ $this->setError('Email already exist');
+ return false;
+ }
+ if ($mobile && User::getByMobile($mobile)) {
+ $this->setError('Mobile already exist');
+ return false;
+ }
+
+ $ip = request()->ip();
+ $time = time();
+
+ $data = [
+ 'username' => $username,
+ 'password' => $password,
+ 'email' => $email,
+ 'mobile' => $mobile,
+ 'level' => 1,
+ 'score' => 0,
+ 'avatar' => '',
+ ];
+ $params = array_merge($data, [
+ 'nickname' => preg_match("/^1[3-9]{1}\d{9}$/",$username) ? substr_replace($username,'****',3,4) : $username,
+ 'salt' => Random::alnum(),
+ 'jointime' => $time,
+ 'joinip' => $ip,
+ 'logintime' => $time,
+ 'loginip' => $ip,
+ 'prevtime' => $time,
+ 'status' => 'normal'
+ ]);
+ $params['password'] = $this->getEncryptPassword($password, $params['salt']);
+ $params = array_merge($params, $extend);
+
+ //账号注册时需要开启事务,避免出现垃圾数据
+ Db::startTrans();
+ try {
+ $user = User::create($params, true);
+
+ //注册成功的事件
+ Hook::listen("user_register_successed", $this->_user, $data);
+ Db::commit();
+ } catch (Exception $e) {
+ $this->setError($e->getMessage());
+ Db::rollback();
+ return false;
+ }
+ return User::get($user->id);
+ }
+
/**
* 用户登录
*
diff --git a/application/common/listener/classes/ClassesHook.php b/application/common/listener/classes/ClassesHook.php
new file mode 100644
index 0000000..a0d26f1
--- /dev/null
+++ b/application/common/listener/classes/ClassesHook.php
@@ -0,0 +1,106 @@
+$shop] = $params;
+
+
+ //记录订单日志
+
+ $desc = "您申请的认证{$shop['name']}已提交审核,审核时间为1-3日内,请耐心等待审核结果";
+
+ $title = "入驻申请提交";
+ $mini_type = "shop_apply";
+ $to_type="user";
+ $to_id = $shop["user_id"];
+ $status ="system";
+ $platform="user";
+ $oper_id=0;
+ $oper_type="system";
+ $params=[
+ "event"=>"shop_create_after",
+ "shop_id"=>$shop["id"],
+ "desc"=>$shop["desc"],
+ ];
+ Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type);
+
+
+
+
+ }
+
+
+
+ // 机构账号审核成功后
+ public function shopAuthSuccessAfter(&$params)
+ {
+ ['shop' => $shop,"password"=>$password] = $params;
+ $user = $shop->user;
+ $mobile = $user['mobile'] ?? "";
+ $shop_backend_url = config("site.shop_backend_ur");
+ $desc = "您申请的认证:{$shop['name']}已审核通过,您可登录官方后台补充完其余资料,并开始发布课程
+ 后台地址是: {$shop_backend_url}
+ 账号是: {$shop['username']} 或 您的手机号 {$mobile}
+ 初始化密码是: {$password}
+";
+
+ $title = "入驻申请通过";
+ $mini_type = "shop_apply";
+ $to_type="user";
+ $to_id = $shop["user_id"];
+ $status ="system";
+ $platform="user";
+ $oper_id=0;
+ $oper_type="system";
+ $params=[
+ "event"=>"shop_auth_success_after",
+ "shop_id"=>$shop["id"],
+ "desc"=>$shop["desc"],
+ ];
+ Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type);
+
+
+
+ }
+
+ // 机构账号审核失败后
+ public function shopAuthFailAfter(&$params)
+ {
+ ["shop"=>$shop] = $params;
+
+
+ //记录订单日志
+
+ $desc = "您申请的认证{$shop['name']}审核未通过,未通过原因为:{$shop['reason']},如已整改,可重新发起申请";
+
+ $title = "入驻申请失败";
+ $mini_type = "shop_apply";
+ $to_type="user";
+ $to_id = $shop["user_id"];
+ $status ="system";
+ $platform="user";
+ $oper_id=0;
+ $oper_type="system";
+ $params=[
+ "event"=>"shop_auth_fail_after",
+ "shop_id"=>$shop["id"],
+ "desc"=>$shop["desc"],
+ ];
+ Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type);
+
+
+
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/application/common/listener/classeshourorder/OrderHook.php b/application/common/listener/classeshourorder/OrderHook.php
index b471cb1..c6a0f0d 100644
--- a/application/common/listener/classeshourorder/OrderHook.php
+++ b/application/common/listener/classeshourorder/OrderHook.php
@@ -1,18 +1,46 @@
$user_id, 'classes_order_id'=>$classes_order_id,'param'=>$param, 'order_no'=>$order_no, 'price_info'=>$price_info,'classes_lib_spec_id'=>$classes_lib_spec_id] = $params;
+
+
}
// 订单创建成功后
public function classeshourOrderCreateAfter(&$params)
{
+ ["order"=>$order] = $params;
+ $detail = $order->detail;
+ //记录订单日志
+ if($order["type"] == "1"){
+ $desc = "{$detail["title"]}课程课时{$order["name"]}课程预约下单成功,等待机构老师审核";
+ }else{
+ $desc = "{$detail["title"]}课程课时{$order["name"]}预约机构老师代下单成功";
+ }
+ $title = "创建课时预约成功";
+ $mini_type = "classes_auth";
+ $to_type="user";
+ $to_id = $order["user_id"];
+ $status ="order";
+ $platform="user";
+ $oper_id=0;
+ $oper_type="system";
+ $params=[
+ "event"=>"classeshour_order_create_after",
+ "order_id"=>$order["id"],
+ "order_no"=>$order["order_no"],
+ ];
+ Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type);
}
@@ -20,6 +48,30 @@ class OrderHook
// 订单变更课时后
public function classeshourOrderUpdateAfter(&$params)
{
+ ['order' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id] = $params;
+ $detail = $order->detail;
+ //插入订单取消日志
+ if(!$user_id ||$order["user_id"] !=$user_id ){
+ $desc = "[员工操作]预约{$detail["title"]}课程订单规格已变更课时为{$order["name"]}";
+ }else{
+ $desc = "预约{$detail["title"]}课程订单规格已变更课时为{$order["name"]}";
+ }
+
+ $title = "课时预约单更换课时";
+ $mini_type = "classes_order_notice";
+ $to_type="user";
+ $to_id = $order["user_id"];
+ $status ="order";
+ $platform="user";
+ $oper_id=0;
+ $oper_type="system";
+ $params=[
+ "event"=>"classeshour_order_update_after",
+ "order_id"=>$order["id"],
+ "order_no"=>$order["order_no"],
+ ];
+ Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type);
+
}
@@ -29,18 +81,93 @@ class OrderHook
// 订单审核通过后
public function classeshourOrderAuthSuccessAfter(&$params)
{
+ ['order' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id] = $params;
+ $detail = $order->detail;
+ //插入订单取消日志
+ if(!$user_id ||$order["user_id"] !=$user_id ){
+ $pron = "[员工操作]";
+ }else{
+ $pron = "";
+ }
+ $desc = $pron."{$detail["title"]}课程课时{$order["name"]}预约单审核成功,预约成功等待核销!";
+ $title = "课时预约单审核通过";
+ $mini_type = "classes_auth";
+ $to_type="user";
+ $to_id = $order["user_id"];
+ $status ="order";
+ $platform="user";
+ $oper_id=0;
+ $oper_type="system";
+ $params=[
+ "event"=>"classeshour_order_auth_success_after",
+ "order_id"=>$order["id"],
+ "order_no"=>$order["order_no"],
+ ];
+ Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type);
}
// 订单审核失败后
public function classeshourOrderAuthFailAfter(&$params)
{
+ ['order' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id] = $params;
+ $detail = $order->detail;
+
+ //插入订单取消日志
+ if(!$user_id ||$order["user_id"] !=$user_id ){
+ $pron = "[员工操作]";
+ }else{
+ $pron = "";
+ }
+ $desc = $pron."{$detail["title"]}课程课时{$order["name"]}预约单审核不通过,原因;{$order['reason']},该课时单将取消以便重新下单";
+
+ $title = "课时预约单审核不通过";
+ $mini_type = "classes_auth";
+ $to_type="user";
+ $to_id = $order["user_id"];
+ $status ="order";
+ $platform="user";
+ $oper_id=0;
+ $oper_type="system";
+ $params=[
+ "event"=>"classeshour_order_auth_fail_after",
+ "order_id"=>$order["id"],
+ "order_no"=>$order["order_no"],
+ "reason"=>$order['reason']
+ ];
+ Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type);
+
}
// 订单核销完成后
public function classeshourOrderFinishAfter(&$params)
{
+ ['order' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id] = $params;
+ $detail = $order->detail;
+
+
+ if(!$user_id ||$order["user_id"] !=$user_id ){
+ $desc = "[员工操作]{$detail["title"]}课程课时{$order["name"]}预约单核销成功,当前课时已完成";
+ }else{
+ $desc = "{$detail["title"]}课程课时{$order["name"]}预约单核销成功,当前课时已完成";
+ }
+
+ $title = "课时预约单已核销";
+ $mini_type = "classes_order_notice";
+ $to_type="user";
+ $to_id = $order["user_id"];
+ $status ="order";
+ $platform="user";
+ $oper_id=0;
+ $oper_type="system";
+ $params=[
+ "event"=>"classeshour_order_finish_after",
+ "order_id"=>$order["id"],
+ "order_no"=>$order["order_no"],
+ ];
+ Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type);
+
}
@@ -50,6 +177,32 @@ class OrderHook
// 订单取消成功后
public function classeshourOrderCancelAfter(&$params)
{
+ ['order' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id] = $params;
+ $detail = $order->detail;
+
+ if(!$user_id ||$order["user_id"] !=$user_id ){
+ $desc = "[员工代操作]{$detail["title"]}课程课时{$order["name"]}预约单取消成功,课时已原路退回";
+ }else{
+ $desc = "{$detail["title"]}课程课时{$order["name"]}预约单取消成功,课时已原路退回";
+ }
+
+ $title = "课时预约单已取消";
+ $mini_type = "classes_order_notice";
+ $to_type="user";
+ $to_id = $order["user_id"];
+ $status ="order";
+ $platform="user";
+ $oper_id=0;
+ $oper_type="system";
+ $params=[
+ "event"=>"classeshour_order_cancel_after",
+ "order_id"=>$order["id"],
+ "order_no"=>$order["order_no"],
+ ];
+ Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type);
+
+
+
}
diff --git a/application/common/listener/classesorder/OrderHook.php b/application/common/listener/classesorder/OrderHook.php
index 4d667c9..ca68ebb 100644
--- a/application/common/listener/classesorder/OrderHook.php
+++ b/application/common/listener/classesorder/OrderHook.php
@@ -1,18 +1,41 @@
$user_id, 'classes_lib_id'=>$classes_lib_id,'param'=>$param, 'order_no'=>$order_no, 'price_info'=>$price_info] = $params;
}
// 订单创建成功后
public function classesOrderCreateAfter(&$params)
{
+ ["order"=>$order] = $params;
+ $detail = $order->detail;
+ //记录订单日志
+
+ $desc = "课程{$detail["title"]}订单创建成功,等待【学员】支付";
+
+ $title = "课程订单创建成功";
+ $mini_type = "order_notice";
+ $to_type="user";
+ $to_id = $order["user_id"];
+ $status ="classes";
+ $platform="user";
+ $oper_id=0;
+ $oper_type="system";
+ $params=[
+ "event"=>"classes_order_create_after",
+ "order_id"=>$order["id"],
+ "order_no"=>$order["order_no"],
+ ];
+ Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type);
+
}
@@ -21,18 +44,85 @@ class OrderHook
// 订单支付成功后
public function classesOrderPayedAfter(&$params)
{
+ ["order"=>$order] = $params;
+ $detail = $order->detail;
+ //记录订单日志
+
+ $desc = "课程{$detail["title"]}订单支付成功,您可以正常约课了";
+
+ $title = "课程订单支付成功";
+ $mini_type = "order_notice";
+ $to_type="user";
+ $to_id = $order["user_id"];
+ $status ="classes";
+ $platform="user";
+ $oper_id=0;
+ $oper_type="system";
+ $params=[
+ "event"=>"classes_order_payed_after",
+ "order_id"=>$order["id"],
+ "order_no"=>$order["order_no"],
+ "classes_lib_id"=>$order["classes_lib_id"],
+ ];
+ Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type);
+
}
// 订单取消成功后
public function classesOrderCancelAfter(&$params)
{
+ ['order' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id] = $params;
+
+ $detail = $order->detail;
+ if(!$user_id ||$order["user_id"] !=$user_id ){
+ $desc = "[系统操作]课程{$detail["title"]}订单未支付取消成功";
+ }else{
+ $desc = "课程{$detail["title"]}订单未支付取消成功";
+ }
+
+ $title = "课程订单已取消";
+ $mini_type = "order_notice";
+ $to_type="user";
+ $to_id = $order["user_id"];
+ $status ="classes";
+ $platform="user";
+ $oper_id=0;
+ $oper_type="system";
+ $params=[
+ "event"=>"classes_order_cancel_after",
+ "order_id"=>$order["id"],
+ "order_no"=>$order["order_no"],
+ ];
+ Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type);
}
// 订单完成后
public function classesOrderFinishAfter(&$params)
{
+ ["order"=>$order] = $params;
+ $detail = $order->detail;
+
+ //记录订单日志
+
+ $desc = "恭喜您!您的{$detail["title"]}课程完结啦";
+
+ $title = "课程完结撒花!";
+ $mini_type = "order_notice";
+ $to_type="user";
+ $to_id = $order["user_id"];
+ $status ="classes";
+ $platform="user";
+ $oper_id=0;
+ $oper_type="system";
+ $params=[
+ "event"=>"classes_order_finish_after",
+ "order_id"=>$order["id"],
+ "order_no"=>$order["order_no"],
+ "classes_lib_id"=>$order["classes_lib_id"],
+ ];
+ Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type);
}
diff --git a/application/common/listener/manystore/ShopHook.php b/application/common/listener/manystore/ShopHook.php
index c46f2e8..cf082b6 100644
--- a/application/common/listener/manystore/ShopHook.php
+++ b/application/common/listener/manystore/ShopHook.php
@@ -1,5 +1,7 @@
$shop] = $params;
+
+
+
+
}
@@ -15,6 +22,30 @@ class ShopHook
// 机构账号提交审核申请后
public function shopApplyAfter(&$params)
{
+ ["shop"=>$shop] = $params;
+
+
+ //记录订单日志
+
+ $desc = "您申请的认证{$shop['name']}已提交审核,审核时间为1-3日内,请耐心等待审核结果";
+
+ $title = "入驻申请提交";
+ $mini_type = "shop_apply";
+ $to_type="user";
+ $to_id = $shop["user_id"];
+ $status ="system";
+ $platform="user";
+ $oper_id=0;
+ $oper_type="system";
+ $params=[
+ "event"=>"shop_create_after",
+ "shop_id"=>$shop["id"],
+ "desc"=>$shop["desc"],
+ ];
+ Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type);
+
+
+
}
@@ -23,12 +54,62 @@ class ShopHook
// 机构账号审核成功后
public function shopAuthSuccessAfter(&$params)
{
+ ['shop' => $shop,"password"=>$password] = $params;
+ $user = $shop->user;
+ $mobile = $user['mobile'] ?? "";
+ $shop_backend_url = config("site.shop_backend_ur");
+ $desc = "您申请的认证:{$shop['name']}已审核通过,您可登录官方后台补充完其余资料,并开始发布课程
+ 后台地址是: {$shop_backend_url}
+ 账号是: {$shop['username']} 或 您的手机号 {$mobile}
+ 初始化密码是: {$password}
+";
+
+ $title = "入驻申请通过";
+ $mini_type = "shop_apply";
+ $to_type="user";
+ $to_id = $shop["user_id"];
+ $status ="system";
+ $platform="user";
+ $oper_id=0;
+ $oper_type="system";
+ $params=[
+ "event"=>"shop_auth_success_after",
+ "shop_id"=>$shop["id"],
+ "desc"=>$shop["desc"],
+ ];
+ Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type);
+
+
}
// 机构账号审核失败后
public function shopAuthFailAfter(&$params)
{
+ ["shop"=>$shop] = $params;
+
+
+ //记录订单日志
+
+ $desc = "您申请的认证{$shop['name']}审核未通过,未通过原因为:{$shop['reason']},如已整改,可重新发起申请";
+
+ $title = "入驻申请失败";
+ $mini_type = "shop_apply";
+ $to_type="user";
+ $to_id = $shop["user_id"];
+ $status ="system";
+ $platform="user";
+ $oper_id=0;
+ $oper_type="system";
+ $params=[
+ "event"=>"shop_auth_fail_after",
+ "shop_id"=>$shop["id"],
+ "desc"=>$shop["desc"],
+ ];
+ Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type);
+
+
+
}
diff --git a/application/common/model/User.php b/application/common/model/User.php
index 46e8565..9e77ba2 100644
--- a/application/common/model/User.php
+++ b/application/common/model/User.php
@@ -13,7 +13,7 @@ use think\Model;
/**
* 会员模型
*/
-class User extends Model
+class User extends BaseModel
{
// 开启自动写入时间戳字段
@@ -70,7 +70,7 @@ class User extends Model
public function getVerificationAttr($value, $data)
{
$value = array_filter((array)json_decode($value, true));
- $value = array_merge(['email' => 0, 'mobile' => 0], $value);
+ $value = array_merge(['email' => 0, 'mobile' => 0, 'mini_wechat' => 0], $value);
return (object)$value;
}
@@ -253,4 +253,53 @@ class User extends Model
}
+
+
+ /**添加用户:通过 手机号 和昵称
+ * @param $mobile
+ * @param $nickname
+ */
+ public function addUserByMobile($mobile,$nickname,$check=true){
+ if($check){
+ //去除空格
+ $nickname = trim($nickname);
+ $mobile = trim($mobile);
+ if(!is_numeric($mobile))throw new \Exception("不是合法手机号!");
+ if(strlen($mobile)!=11)throw new \Exception("请输入11位手机号!");
+ if (!preg_match("/[\x7f-\xff]/", $nickname)) throw new \Exception("名称必须是汉字,请去除空格和其他特殊符号!");
+ preg_match_all("/[\x{4e00}-\x{9fa5}]/u","$nickname",$result);
+ if(!$result || join('',$result[0])!=$nickname)throw new \Exception("名称必须是汉字,请去除空格和其他特殊符号!");
+ }
+
+
+ //判断用户存不存在
+ $user = self::where("mobile",$mobile)->find();
+ if($user){
+ //如果存在,直接返回
+ return $user;
+ }else{
+ //如果不存在,创建并返回
+ //得到认证实例
+ $auth = Auth::instance();
+ //拼装提交参数
+// $extend = $this->getUserDefaultFields();
+ $extend=[];
+ $extend['nickname'] = $nickname;
+ $extend['avatar'] = config("site.default_avatar");
+ //调用注册方法
+ $user = $auth->registerNoLogin("{$mobile}_user", rand(100000,999999), "{$mobile}@user.com", $mobile,$extend);
+ if(!$user)throw new \Exception($auth->getError());
+ //更新已认证方式
+ $user = self::where("id", $user->id)->find();
+ $verification = $user->verification;
+ $verification->mobile = 1;
+ $user->verification = $verification;
+ $user->save();
+ //返回对象
+ return self::where("id", $user->id)->find();
+ }
+ }
+
+
+
}
diff --git a/application/common/model/school/Message.php b/application/common/model/school/Message.php
index 5719707..d11421a 100644
--- a/application/common/model/school/Message.php
+++ b/application/common/model/school/Message.php
@@ -2,10 +2,11 @@
namespace app\common\model\school;
+use app\common\model\BaseModel;
use think\Model;
-class Message extends Model
+class Message extends BaseModel
{
@@ -29,11 +30,24 @@ class Message extends Model
'oper_type_text',
'to_type_text',
'status_text',
- 'mini_type_text'
+ 'mini_type_text',
+ "type_text"
];
-
+ public function getTypeList()
+ {
+ return ['1' => __('Type 1'), '2' => __('Type 2')];
+ }
+
+ public function getTypeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
+ $list = $this->getTypeList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+
-
public function getPlatformList()
{
return ['admin' => __('Platform admin'), 'user' => __('Platform user'), 'shop' => __('Platform shop')];
@@ -149,4 +163,163 @@ class Message extends Model
}
+
+ /**展示订单信息
+ * @param $order_no
+ * @param $price_info
+ * @return array
+ */
+ public static function showInfo($id, $price_info = []){
+ $data = [];
+ $data['id'] =$id;
+ $data['message_info'] = self::getDetail($id);
+ return array_merge($data,$price_info);
+ }
+
+
+
+
+ /**得到订单详情
+ * @param $order_no
+ */
+ public static function getDetail($id,$oper_id = []){
+ $model = self::where('id',$id);
+ if($oper_id)$model = $model->where("oper_id","in",$oper_id);
+ $data = $model->find();
+
+ if(!$data) return $data;
+
+ //如果非全局消息,更新成已读
+
+ if($data->to_id != 0){
+ $data["type"]= '2';
+ $data->save();
+ }
+
+// //加载订单详情
+// $data->detail->teacher;
+// //订单用户
+//// $data->user;
+// $data->user->visible(['id','nickname','mobile','avatar','realname']);
+//
+
+ return $data;
+ }
+
+
+
+
+
+
+
+
+ /**得到基础条件
+ * @param $status
+ * @param null $model
+ * @param string $alisa
+ */
+ public static function getBaseWhere($whereData = [], $model = null, $alisa = '',$with = false)
+ {
+
+ if (!$model) {
+ $model = new static;
+ if ($alisa&&!$with) $model = $model->alias($alisa);
+ }
+ if ($alisa) $alisa = $alisa . '.';
+ $tableFields = (new static)->getTableFields();
+ foreach ($tableFields as $fields)
+ {
+ if(in_array($fields, ['platform','oper_type','to_type','status','mini_type','to_id']))continue;
+// if (isset($whereData[$fields]) && $whereData[$fields]) $model = $model->where("{$alisa}{$fields}", '=', $whereData[$fields]);
+
+ if (isset($whereData[$fields]) && $whereData[$fields]){
+ if(is_array($whereData[$fields])){
+ $model = $model->where("{$alisa}{$fields}", $whereData[$fields][0], $whereData[$fields][1]);
+ }else{
+ $model = $model->where("{$alisa}{$fields}", '=', $whereData[$fields]);
+ }
+
+ }
+
+
+ }
+ 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}id|{$alisa}title|{$alisa}desc", '=', $whereData['keywords']);
+ if (isset($whereData['time'])&&$whereData['time']){
+ $model = $model->time($whereData['time']);
+ }
+ if (isset($whereData['user_id']) && $whereData['user_id']) $model = $model->where("{$alisa}to_id", '=', $whereData['user_id']);
+
+ if (isset($whereData['platform']) && $whereData['platform']){
+ $platforms = implode("|",explode(',',$whereData['platform']));
+ $model = $model->whereRaw(" {$alisa}platform REGEXP '({$platforms})'");
+// $model = $model->where("{$alisa}platform", 'in', $whereData['platform']);
+ }
+
+
+ if (isset($whereData['oper_type']) && $whereData['oper_type']) $model = $model->where("{$alisa}oper_type", 'in', $whereData['oper_type']);
+ if (isset($whereData['to_type']) && $whereData['to_type']) $model = $model->where("{$alisa}to_type", 'in', $whereData['to_type']);
+ if (isset($whereData['mini_type']) && $whereData['mini_type']) $model = $model->where("{$alisa}mini_type", 'in', $whereData['mini_type']);
+
+
+ if (isset($whereData['to_id']) && $whereData['to_id']){
+ $model = $model->where(function ($query) use($whereData,$alisa) {
+ $query->where("{$alisa}to_id", $whereData['to_id'])
+ ->whereOr("{$alisa}to_id", '=', 0);
+ });
+
+ }
+
+
+ return $model;
+ }
+
+
+
+
+
+
+ public static function baseCount($where = []){
+ $where["type"] = '1';
+ $where["platform"]= 'user';
+ $unread_number = self::getBaseWhere($where)->count();
+ $unread_system_number = self::getBaseWhere(array_merge(['status'=>'system'],$where))->count();
+ $unread_classes_number = self::getBaseWhere(array_merge(['status'=>'classes'],$where))->count();
+ $unread_order_number = self::getBaseWhere(array_merge(['status'=>'order'],$where))->count();
+
+ return compact('unread_number','unread_system_number','unread_classes_number','unread_order_number');
+ }
+
+
+
+ /**订单数量统计
+ * @param int $user_id
+ * @return array
+ */
+ public static function messageCount($user_id = 0){
+ return self::baseCount(['user_id'=>$user_id]);
+ }
+
+
+
+
+
+ public static function messageList($page, $limit,$to_id,$keywords,$status,$mini_type,$type){
+ $with_field = [
+ 'user'=>['nickname','mobile','avatar','realname'],
+ 'base'=>['*'],
+// 'shop'=>['*'],
+// 'detail'=>['*'],
+ ];
+
+ $alisa = (new self)->getWithAlisaName();
+ $sort = "field({$alisa}.type,'1','2') asc,{$alisa}.weigh desc,{$alisa}.id desc";
+ $serch_where = ["to_id"=>$to_id,'platform'=>"user",'status'=>$status,'keywords'=>$keywords,"mini_type"=>$mini_type,"type"=>$type];
+// if($type)$serch_where['type'] = $type;
+ return (new self)->getBaseList($serch_where, $page, $limit,$sort,$with_field);
+ }
+
+
+
}
diff --git a/application/common/model/school/classes/ClassesLib.php b/application/common/model/school/classes/ClassesLib.php
index 84e8555..f788052 100644
--- a/application/common/model/school/classes/ClassesLib.php
+++ b/application/common/model/school/classes/ClassesLib.php
@@ -426,7 +426,7 @@ class ClassesLib extends BaseModel
$order = $order?? 'normal';
- $per_page = $params['page'] ?? 10;
+ $per_page = $limit ?? 10;
$field = "{$a}id,{$a}shop_id,{$a}user_id,{$a}teacher_id,{$a}classes_cate_ids,{$a}classes_label_ids,{$a}self_label_tag,{$a}title,{$a}headimage,{$a}type,{$a}classes_date_text,{$a}classes_time_text,{$a}virtual_num,{$a}sale,{$a}price,{$a}underline_price,{$a}virtual_collect,{$a}status,{$a}auth_status,{$a}weigh,{$a}recommend,{$a}hot,{$a}new,{$a}selfhot,{$a}createtime,{$a}virtual_people,{$a}feel,{$a}limit_num,{$a}sign_num,{$a}verification_num";
@@ -568,6 +568,7 @@ class ClassesLib extends BaseModel
$selfetch = $selfetch->paginate($per_page);
+// var_dump(self::getLastSql());
//额外附加数据
return $selfetch;
diff --git a/application/common/model/school/classes/hourorder/Order.php b/application/common/model/school/classes/hourorder/Order.php
index d3d42df..1057d2a 100644
--- a/application/common/model/school/classes/hourorder/Order.php
+++ b/application/common/model/school/classes/hourorder/Order.php
@@ -6,6 +6,7 @@ use app\admin\model\Admin;
use app\common\model\school\classes\ClassesLib;
use app\common\model\school\classes\ClassesSpec;
use app\common\model\User;
+use app\manystore\model\Manystore;
use bw\Common;
use fast\Random;
use think\Cache;
@@ -594,12 +595,16 @@ class Order extends BaseModel
$order = $this->createOrder($user_id,$orderInfo['classes_order_id'],$orderInfo['classes_lib_spec_id'],$order_no,$orderInfo['param'],$remark);
//5删除缓存
self::deleteOrderCache($user_id, $order_no);
+// var_dump($order["type"]);
//代下单直接执行审核成功的预约中状态
if($order["type"] == '2'){
//兼容代下单逻辑,修正下单人信息
// $user_id =$order['user_id'];
+
+// var_dump($order["status"]);
+
//do something...
- $this->examine($order_no,1,"",0,false,$order["help_type"],$order["help_user_id"],false);
+ if(config("site.admin_approved_swtich"))$this->examine($order_no,1,"",0,false,$order["help_type"],$order["help_user_id"],false);
}
if ($trans) {
@@ -668,6 +673,7 @@ class Order extends BaseModel
$classes_lib_spec_data = $classes_lib_spec->toArray();
$classes_lib_spec_data['classes_lib_spec_id'] = $classes_lib_spec_data['id'];
unset($classes_lib_spec_data['id']);
+ unset($classes_lib_spec_data['status']);
unset($classes_lib_spec_data['createtime']);
unset($classes_lib_spec_data['updatetime']);
unset($classes_lib_spec_data['deletetime']);
@@ -705,13 +711,13 @@ class Order extends BaseModel
$order = self::buildLibSpec($res1,$classes_lib_spec_id);
//扣减课程数
- $res1 = \app\common\model\school\classes\order\Order::statisticsAndUpdateClassesNumber($classes_order_id);
+ \app\common\model\school\classes\order\Order::statisticsAndUpdateClassesNumber($classes_order_id);
//记录订单日志
if($order["type"] == "1"){
- OrderLog::log($res1['id'],"课时预约下单成功,等待机构老师审核",'user',$user_id);
+ OrderLog::log($order['id'],"课时预约下单成功,等待机构老师审核",'user',$user_id);
}else{
- OrderLog::log($res1['id'],"课时预约机构老师代下单成功",'user',$order["help_user_id"]);
+ OrderLog::log($order['id'],"课时预约机构老师代下单成功",'user',$order["help_user_id"]);
}
//7事件
@@ -772,10 +778,10 @@ class Order extends BaseModel
}
//调用订单取消事件
- $data = ['order' => $order];
+ $data = ['order' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
\think\Hook::listen('classeshour_order_cancel_after', $data);
//执行课时数更新
- $res1 = \app\common\model\school\classes\order\Order::statisticsAndUpdateClassesNumber($order['classes_order_id']);
+ \app\common\model\school\classes\order\Order::statisticsAndUpdateClassesNumber($order['classes_order_id']);
if($trans){
@@ -877,6 +883,10 @@ class Order extends BaseModel
$admin_info = Admin::where('id',$oper_id)->find();
if(!$admin_info) throw new \Exception("代下单管理员不存在!");
break;
+ case 'shop':
+ $admin_info = Manystore::where('id',$oper_id)->find();
+ if(!$admin_info) throw new \Exception("代下单管理员不存在!");
+ break;
default:
throw new \Exception("请选择正确的代下单类型!");
}
@@ -957,8 +967,11 @@ class Order extends BaseModel
* @throws \Exception
*/
public function examine($order_no,$auth_status,$reason="",$user_id=0,$check=false,$oper_type='user',$oper_id=0,$trans=false){
+
+
//得到可取消订单
$order = self::getHaveExamineOrder($order_no);
+
if($check){
//用户操作权限检测
self::checkOptionAuth($order['classes_order_id'],$user_id ?: $oper_id,$oper_type);
@@ -991,7 +1004,7 @@ class Order extends BaseModel
OrderLog::log($order['id'],$pron."课时预约单审核成功,预约成功等待核销!",$oper_type ?: 'user', $oper_id ?: $order['user_id']);
//调用订单事件
- $data = ['order' => $order];
+ $data = ['order' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
\think\Hook::listen('classeshour_order_auth_success_after', $data);
}else{
@@ -1002,7 +1015,7 @@ class Order extends BaseModel
//审核失败逻辑
OrderLog::log($order['id'],$pron."课时预约单审核不通过,原因;{$reason},该课时单将取消以便重新下单",$oper_type ?: 'user', $oper_id ?: $order['user_id']);
//调用订单事件
- $data = ['order' => $order];
+ $data = ['order' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
\think\Hook::listen('classeshour_order_auth_fail_after', $data);
//执行订单取消逻辑
@@ -1103,10 +1116,10 @@ class Order extends BaseModel
}
//调用订单取消事件
- $data = ['order' => $order];
+ $data = ['order' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
\think\Hook::listen('classeshour_order_finish_after', $data);
//执行课时数更新
- $res1 = \app\common\model\school\classes\order\Order::statisticsAndUpdateClassesNumber($order['classes_order_id']);
+ \app\common\model\school\classes\order\Order::statisticsAndUpdateClassesNumber($order['classes_order_id']);
if($trans){
@@ -1171,7 +1184,7 @@ class Order extends BaseModel
}
//调用订单事件
- $data = ['order' => $order];
+ $data = ['order' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
\think\Hook::listen('classeshour_order_update_after', $data);
//执行课时数更新
$res1 = \app\common\model\school\classes\order\Order::statisticsAndUpdateClassesNumber($order['classes_order_id']);
diff --git a/application/common/model/school/classes/hourorder/OrderLog.php b/application/common/model/school/classes/hourorder/OrderLog.php
index d3755e6..f602d1a 100644
--- a/application/common/model/school/classes/hourorder/OrderLog.php
+++ b/application/common/model/school/classes/hourorder/OrderLog.php
@@ -59,7 +59,10 @@ class OrderLog extends BaseModel
* @throws \Exception
*/
public static function log($order,$mark='更新订单状态',$oper_type='user',$oper_id = 0,$trans=false){
- if(is_numeric($order))$order = Order::where('order_no|id',$order)->find();
+// var_dump($order);
+ if(is_numeric($order)||is_string($order))$order = Order::where('order_no|id',$order)->find();
+
+
if(!$order)throw new \Exception("找不到订单");
//操作人信息(可扩展)
$data = [
diff --git a/application/common/model/school/classes/order/Order.php b/application/common/model/school/classes/order/Order.php
index 4b37e65..6c0e0fb 100644
--- a/application/common/model/school/classes/order/Order.php
+++ b/application/common/model/school/classes/order/Order.php
@@ -1044,7 +1044,7 @@ class Order extends BaseModel
}
//调用订单取消事件
- $data = ['order' => $order];
+ $data = ['order' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id];
\think\Hook::listen('classes_order_cancel_after', $data);
//执行课时数更新
$res1 = self::statisticsAndUpdateClassesNumber($order['id']);
diff --git a/application/common/model/school/classes/order/OrderLog.php b/application/common/model/school/classes/order/OrderLog.php
index fed2494..c912f0f 100644
--- a/application/common/model/school/classes/order/OrderLog.php
+++ b/application/common/model/school/classes/order/OrderLog.php
@@ -104,7 +104,7 @@ class OrderLog extends BaseModel
* @throws \Exception
*/
public static function log($order,$mark='更新订单状态',$oper_type='user',$oper_id = 0,$trans=false){
- if(is_numeric($order))$order = Order::where('order_no|id|pay_no',$order)->find();
+ if(is_numeric($order)||is_string($order))$order = Order::where('order_no|id|pay_no',$order)->find();
if(!$order)throw new \Exception("找不到订单");
//操作人信息(可扩展)
$data = [
diff --git a/application/manystore/controller/manystore/UserAuth.php b/application/manystore/controller/manystore/UserAuth.php
index 139a15b..45ede7e 100644
--- a/application/manystore/controller/manystore/UserAuth.php
+++ b/application/manystore/controller/manystore/UserAuth.php
@@ -72,4 +72,33 @@ class UserAuth extends ManystoreBase
return $this->view->fetch();
}
+
+
+ /**变更学员信息(教练专属)
+ * @return string
+ * @throws \think\Exception
+ * @throws \think\exception\DbException
+ */
+ public function changeuser(){
+ if($this->request->isPost())
+ {
+ try{
+ $people_name = $this->request->param('people_name/s');
+ $people_mobile = $this->request->param('people_mobile/s');
+ $user = \app\common\model\User::where("mobile",$people_mobile)->find();
+ //检测更新教练下单学员账号创建状态 2022/8/27 new
+ if(!$user)$user = (new \app\common\model\User)->addUserByMobile($people_mobile,$people_name);
+ $user['nickname'] = $people_name;
+ $user->save();
+ }catch (\Exception $e){
+ $this->error($e->getMessage());
+ }
+ //退押金
+ $this->success("已成功创建{$people_name}");
+ }
+// $row = $this->model->get($param['ids']);
+// $this->view->assign('vo', $row);
+ return $this->view->fetch();
+ }
+
}
diff --git a/application/manystore/controller/school/classes/ClassesLib.php b/application/manystore/controller/school/classes/ClassesLib.php
index f214ba9..e7b4052 100644
--- a/application/manystore/controller/school/classes/ClassesLib.php
+++ b/application/manystore/controller/school/classes/ClassesLib.php
@@ -326,6 +326,7 @@ class ClassesLib extends ManystoreBase
if($check_title){
$this->error("课程名称已存在或被其他机构占用,请更改!");
}
+ $this->have_auth = true;
}
}
@@ -365,6 +366,15 @@ class ClassesLib extends ManystoreBase
}
$this->update_check($params,$row=null);
$result = $this->model->allowField(true)->save($params);
+
+ if($this->have_auth){
+ //调用通过事件
+ $data = ['classes' => $this->model];
+ \think\Hook::listen('classes_auth_need_after', $data);
+
+ }
+
+
Db::commit();
} catch (ValidateException $e) {
Db::rollback();
@@ -417,6 +427,15 @@ class ClassesLib extends ManystoreBase
$result = $row->allowField(true)->save($params);
+
+ if($this->have_auth){
+ //调用通过事件
+ $data = ['classes' => $row];
+ \think\Hook::listen('classes_auth_need_after', $data);
+
+ }
+
+
Db::commit();
} catch (ValidateException $e) {
Db::rollback();
diff --git a/application/manystore/controller/school/classes/ClassesSpec.php b/application/manystore/controller/school/classes/ClassesSpec.php
index c8887ac..804e5d8 100644
--- a/application/manystore/controller/school/classes/ClassesSpec.php
+++ b/application/manystore/controller/school/classes/ClassesSpec.php
@@ -261,9 +261,9 @@ class ClassesSpec extends ManystoreBase
}
- $user = User::where("id", $row["user_id"])->find();
-// if(!$user) $this->error("未找到用户请先让用户登录小程序再提交表单");
- $row["user_id"] = $user["mobile"]?? ""; //nickname|realname|mobile
+// $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();
}
diff --git a/application/manystore/controller/school/classes/hourorder/Order.php b/application/manystore/controller/school/classes/hourorder/Order.php
index b21f1a2..1084f25 100644
--- a/application/manystore/controller/school/classes/hourorder/Order.php
+++ b/application/manystore/controller/school/classes/hourorder/Order.php
@@ -3,6 +3,9 @@
namespace app\manystore\controller\school\classes\hourorder;
use app\common\controller\ManystoreBase;
+use think\Db;
+use think\exception\PDOException;
+use think\exception\ValidateException;
/**
* 课时订单
@@ -18,11 +21,17 @@ class Order extends ManystoreBase
*/
protected $model = null;
+ protected $qSwitch = true;
+ protected $qFields = ["classes_order_id","classes_lib_spec_id","user_id","classes_order_detail_id","classes_lib_id"];
+
+
public function _initialize()
{
- parent::_initialize();
$this->model = new \app\manystore\model\school\classes\hourorder\Order;
+ parent::_initialize();
+
$this->view->assign("statusList", $this->model->getStatusList());
+ $this->view->assign("authStatusList", $this->model->getAuthStatusList());
}
public function import()
@@ -75,4 +84,237 @@ class Order extends ManystoreBase
return $this->view->fetch();
}
+
+
+
+ /**
+ * 添加
+ */
+ public function add()
+ {
+ if ($this->request->isPost()) {
+ $params = $this->request->post("row/a");
+ if ($params) {
+ $params = $this->preExcludeFields($params);
+
+ if($this->storeIdFieldAutoFill && STORE_ID ){
+ $params['store_id'] = STORE_ID;
+ }
+
+ if($this->shopIdAutoCondition && SHOP_ID){
+ $params['shop_id'] = SHOP_ID;
+ }
+
+ $result = false;
+
+ 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);
+ }
+
+
+ //记录代下单人信息
+ $param = [
+ "type" =>'2',
+ "help_user_id" =>$this->auth->id,
+ "help_type" => 'shop',
+ ];
+ //确认订单
+ $res = (new \app\common\model\school\classes\hourorder\Order)->confirm($this->auth->id,$params['classes_order_id'],null, $params['classes_lib_spec_id'],$param, true);
+ $remark = "总后台管理员帮忙下课时预约";
+ //创建订单
+ $result = (new \app\common\model\school\classes\hourorder\Order)->cacheCreateOrder($res['order_no'], $this->auth->id,$remark, true);
+
+
+
+
+ } catch (ValidateException $e) {
+
+ $this->error($e->getMessage());
+ } catch (PDOException $e) {
+
+ $this->error($e->getMessage());
+ } catch (\Exception $e) {
+
+ $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;
+
+ 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);
+ }
+
+
+ $result = (new \app\common\model\school\classes\hourorder\Order)->updateClassesSpec($row["id"],$params["classes_lib_spec_id"],0,true,'shop',$this->auth->id,true);
+
+
+
+ } catch (ValidateException $e) {
+
+ $this->error($e->getMessage());
+ } catch (PDOException $e) {
+
+ $this->error($e->getMessage());
+ } catch (\Exception $e) {
+
+ $this->error($e->getMessage());
+ }
+ if ($result !== false) {
+ $this->success();
+ } else {
+ $this->error(__('No rows were updated'));
+ }
+ }
+ $this->error(__('Parameter %s can not be empty', ''));
+ }
+ $this->view->assign("row", $row);
+ return $this->view->fetch();
+ }
+
+
+
+
+
+ /**
+ * 删除
+ */
+ public function del($ids = "")
+ {
+ if (!$this->request->isPost()) {
+ $this->error(__("Invalid parameters"));
+ }
+ $ids = $ids ? $ids : $this->request->post("ids");
+ if ($ids) {
+ $pk = $this->model->getPk();
+ if($this->shopIdAutoCondition){
+ $this->model->where(array('shop_id'=>SHOP_ID));
+ }
+ $list = $this->model->where($pk, 'in', $ids)->select();
+
+ $count = 0;
+
+ try {
+ foreach ($list as $k => $v) {
+ $res = (new \app\common\model\school\classes\hourorder\Order)->cancel($v["id"],0,true,'shop',$this->auth->id,true);
+
+ $count ++;
+ }
+
+ } catch (PDOException $e) {
+
+ $this->error($e->getMessage());
+ } catch (\Exception $e) {
+
+ $this->error($e->getMessage());
+ }
+ if ($count) {
+ $this->success();
+ } else {
+ $this->error(__('No rows were deleted'));
+ }
+ }
+ $this->error(__('Parameter %s can not be empty', 'ids'));
+ }
+
+
+
+ /**预约审核
+ * @return string
+ * @throws \think\Exception
+ * @throws \think\exception\DbException
+ */
+ public function examine($ids = ""){
+
+ if($this->request->isPost())
+ {
+ try{
+ $params = $this->request->post("row/a");
+
+
+ $auth_status = $params["auth_status"];
+ $reason = $params["reason"];
+ $model = (new \app\common\model\school\classes\hourorder\Order);
+ $model->examine($params["id"],$auth_status,$reason,0,true,'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();
+ }
+
+
+ /**
+ * 后台核销
+ * @return string
+ * @throws \think\Exception
+ * @throws \think\db\exception\BindParamException
+ * @throws \think\exception\DbException
+ * @throws \think\exception\PDOException
+ */
+ public function verification($ids = ''){
+ $param = $this->request->param();
+ if($this->request->isPost()){
+ try{
+ if(isset($param['ids']))$ids = $param['ids'];
+ //设置模拟资格
+ $model = (new \app\common\model\school\classes\hourorder\Order);
+ $model->verification($ids,0,true,'shop',$this->auth->id,true);
+
+
+ }catch (\Exception $e){
+ $this->error($e->getMessage());
+ }
+ $this->success('核销成功!');
+ }
+ $row = $this->model->get($ids);
+ $this->view->assign('vo', $row);
+ return $this->view->fetch();
+ }
+
}
diff --git a/application/manystore/controller/school/classes/order/Order.php b/application/manystore/controller/school/classes/order/Order.php
index b47fde2..e742407 100644
--- a/application/manystore/controller/school/classes/order/Order.php
+++ b/application/manystore/controller/school/classes/order/Order.php
@@ -80,4 +80,34 @@ class Order extends ManystoreBase
return $this->view->fetch();
}
+
+
+ /**
+ * 课程订单取消
+ * @return string
+ * @throws \think\Exception
+ * @throws \think\db\exception\BindParamException
+ * @throws \think\exception\DbException
+ * @throws \think\exception\PDOException
+ */
+ public function cancel($ids = ''){
+ $param = $this->request->param();
+ if($this->request->isPost()){
+ try{
+ if(isset($param['ids']))$ids = $param['ids'];
+ //设置模拟资格
+ $model = (new \app\common\model\school\classes\order\Order);
+ $model->cancel($ids,0,true,'admin',$this->auth->id,true);;
+
+
+ }catch (\Exception $e){
+ $this->error($e->getMessage());
+ }
+ $this->success('取消成功!');
+ }
+ $row = $this->model->get($ids);
+ $this->view->assign('vo', $row);
+ return $this->view->fetch();
+ }
+
}
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 90a7ca7..c7e0b18 100644
--- a/application/manystore/lang/zh-cn/school/classes/classes_lib.php
+++ b/application/manystore/lang/zh-cn/school/classes/classes_lib.php
@@ -4,8 +4,8 @@ return [
'Manystore_id' => '机构账号id',
'Shop_id' => '机构店铺id',
'User_id' => '主讲师用户id',
- 'Classes_cate_ids' => '平台课程分类ids',
- 'Classes_label_ids' => '平台课程类型ids',
+ 'Classes_cate_ids' => '平台课程分类',
+ 'Classes_label_ids' => '平台课程热门标签',
'Self_label_tag' => '机构特色标签',
'Add_type' => '添加人类型',
'Add_type 1' => '机构',
diff --git a/application/manystore/lang/zh-cn/school/classes/hourorder/order.php b/application/manystore/lang/zh-cn/school/classes/hourorder/order.php
index baf1820..79195f2 100644
--- a/application/manystore/lang/zh-cn/school/classes/hourorder/order.php
+++ b/application/manystore/lang/zh-cn/school/classes/hourorder/order.php
@@ -2,8 +2,21 @@
return [
'Order_no' => '订单号',
+
+ 'Edit'=>'修改用户预约的课时',
+ 'Add'=>'帮用户预约课时',
+ 'Delete'=>'帮用户取消预约',
+ 'Del'=>'帮用户取消预约',
+ 'Auth_status' => '审核状态',
+ 'Auth_status 0' => '待审核',
+ 'Auth_status 1' => '审核通过',
+ 'Auth_status 2' => '审核失败',
+ 'Reason' => '审核不通过原因',
+ 'Auth_time' => '审核时间',
+ 'Admin_id' => '审核管理员id',
+
'Classes_order_id' => '课程订单id',
- 'Classes_lib_spec_id' => '课时id',
+ 'Classes_lib_spec_id' => '选择要预约的课时',
'User_id' => '下单人id',
'Classes_order_detail_id' => '订单课程id',
'Classes_lib_id' => '课程id',
diff --git a/application/manystore/lang/zh-cn/school/classes/order/order.php b/application/manystore/lang/zh-cn/school/classes/order/order.php
index 934399c..c8bd3b9 100644
--- a/application/manystore/lang/zh-cn/school/classes/order/order.php
+++ b/application/manystore/lang/zh-cn/school/classes/order/order.php
@@ -4,6 +4,7 @@ return [
'Order_no' => '订单号',
'Pay_no' => '微信支付单号',
'User_id' => '下单人id',
+ 'Edit'=>'订单详情',
'Manystore_id' => '机构账号id',
'Shop_id' => '机构店铺id',
'Code' => '核销码',
diff --git a/application/manystore/model/ManystoreShop.php b/application/manystore/model/ManystoreShop.php
index ac59e87..6b9207f 100644
--- a/application/manystore/model/ManystoreShop.php
+++ b/application/manystore/model/ManystoreShop.php
@@ -29,7 +29,10 @@ class ManystoreShop extends Model
'update_time_text'
];
-
+ public function user()
+ {
+ return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ }
diff --git a/application/manystore/model/school/classes/hourorder/Order.php b/application/manystore/model/school/classes/hourorder/Order.php
index f1c0ddf..d75f040 100644
--- a/application/manystore/model/school/classes/hourorder/Order.php
+++ b/application/manystore/model/school/classes/hourorder/Order.php
@@ -30,11 +30,25 @@ class Order extends Model
'status_text',
'reservation_time_text',
'finish_time_text',
- 'cancel_time_text'
+ 'cancel_time_text',
+ 'auth_status_text',
];
-
-
+
+ public function getAuthStatusList()
+ {
+ return ['0' => __('Auth_status 0'), '1' => __('Auth_status 1'), '2' => __('Auth_status 2')];
+ }
+
+ public function getAuthStatusTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['auth_status']) ? $data['auth_status'] : '');
+ $list = $this->getAuthStatusList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+
public function getStatusList()
{
return ['-3' => __('Status -3'),'-1' => __('Status -1'), '0' => __('Status 0'), '3' => __('Status 3')];
diff --git a/application/manystore/view/general/profile/index.html b/application/manystore/view/general/profile/index.html
index 2384734..8af6e5d 100644
--- a/application/manystore/view/general/profile/index.html
+++ b/application/manystore/view/general/profile/index.html
@@ -213,9 +213,9 @@
data-toggle="city-picker" name="shop[address_city]"
value="{$shop_info.address_city}" type="text">
-
-
-
+
+
+
@@ -203,12 +210,12 @@
-
-
-
-
-
-
+
@@ -227,12 +234,12 @@
( 如果填零则为免费课程,课程下单后无需支付,直接可去预约课时! )
-
+
+
+
+
+
+
-
+
+
+
+
+
+