From 637bd5cbdf233391e2e55a65e1704a773665b45b Mon Sep 17 00:00:00 2001 From: 15090180611 <215509543@qq.com> Date: Wed, 4 Dec 2024 18:17:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E6=A0=B7=E9=9D=92=E6=98=A5=E5=A4=9C?= =?UTF-8?q?=E6=A0=A1=20=E5=94=AE=E5=90=8E=E5=8D=95=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=20=E5=91=98=E5=B7=A5=E7=AB=AF=E5=92=8C?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=AB=AF=20=E5=94=AE=E5=90=8E=E5=8D=95?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E6=8E=A5=E5=8F=A3=20=E5=91=98=E5=B7=A5?= =?UTF-8?q?=E7=AB=AF=E5=92=8C=E7=94=A8=E6=88=B7=E7=AB=AF=20=E5=94=AE?= =?UTF-8?q?=E5=90=8E=E5=8D=95=E5=8F=96=E6=B6=88=20=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=20=E5=94=AE=E5=90=8E=E5=8D=95=E7=94=B3=E8=AF=B7=20?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=AB=AF=20=E6=A0=B8=E9=94=80=E5=91=98?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=8F=AF=E6=A0=B8=E9=94=80=E5=85=A8=E9=83=A8?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/manystore/Index.php | 85 +- .../controller/school/classes/ClassesLib.php | 42 +- .../school/classes/order/ServiceOrder.php | 80 ++ .../school/classes/order/ServiceOrderLog.php | 77 ++ .../admin/lang/zh-cn/manystore/index.php | 1 + .../lang/zh-cn/school/classes/order/order.php | 2 + .../zh-cn/school/classes/order/order_log.php | 2 + .../school/classes/order/service_order.php | 68 ++ .../classes/order/service_order_log.php | 45 + .../model/school/classes/order/Order.php | 2 +- .../model/school/classes/order/OrderLog.php | 2 +- .../school/classes/order/ServiceOrder.php | 206 +++++ .../school/classes/order/ServiceOrderLog.php | 106 +++ .../school/classes/order/ServiceOrder.php | 27 + .../school/classes/order/ServiceOrderLog.php | 27 + .../view/school/classes/classes_lib/edit.html | 2 +- .../classes/order/service_order/add.html | 219 +++++ .../classes/order/service_order/edit.html | 219 +++++ .../classes/order/service_order/index.html | 46 + .../order/service_order/recyclebin.html | 25 + .../classes/order/service_order_log/add.html | 105 +++ .../classes/order/service_order_log/edit.html | 105 +++ .../order/service_order_log/index.html | 46 + .../view/school/classes/verification/add.html | 12 +- .../school/classes/verification/edit.html | 12 +- application/api/controller/User.php | 7 +- application/api/controller/school/Classes.php | 20 +- .../api/controller/school/HourOrder.php | 34 +- application/api/controller/school/Message.php | 38 +- .../api/controller/school/ServiceOrder.php | 236 +++++ application/api/controller/school/Shop.php | 19 +- .../api/controller/school/UserAuth.php | 2 +- .../controller/school/worker/HourOrder.php | 4 +- .../controller/school/worker/ServiceOrder.php | 178 ++++ application/common.php | 31 + application/common/controller/Api.php | 2 + application/common/hooks.php | 25 + application/common/library/Virtual.php | 19 + .../common/listener/classes/ClassesHook.php | 19 + .../listener/classesorder/OrderHook.php | 1 + .../common/listener/manystore/ShopHook.php | 15 +- .../listener/serviceorder/OrderHook.php | 75 ++ application/common/listener/user/UserHook.php | 117 ++- application/common/model/User.php | 2 +- .../common/model/dyqc/ManystoreShop.php | 21 + application/common/model/school/Message.php | 101 ++- .../model/school/classes/ClassesLib.php | 134 ++- .../model/school/classes/ClassesSpec.php | 16 +- .../model/school/classes/hourorder/Order.php | 154 +++- .../model/school/classes/order/Order.php | 40 +- .../model/school/classes/order/OrderLog.php | 2 +- .../school/classes/order/ServiceOrder.php | 827 ++++++++++++++++++ .../school/classes/order/ServiceOrderLog.php | 261 ++++++ application/config.php | 9 + .../manystore/controller/general/Profile.php | 2 + .../controller/school/classes/ClassesLib.php | 55 +- .../school/classes/order/ServiceOrder.php | 83 ++ .../school/classes/order/ServiceOrderLog.php | 80 ++ .../manystore/lang/zh-cn/general/profile.php | 1 + .../lang/zh-cn/school/classes/order/order.php | 2 + .../zh-cn/school/classes/order/order_log.php | 2 + .../school/classes/order/service_order.php | 63 ++ .../classes/order/service_order_log.php | 41 + .../model/school/classes/order/Order.php | 2 +- .../model/school/classes/order/OrderLog.php | 2 +- .../school/classes/order/ServiceOrder.php | 205 +++++ .../school/classes/order/ServiceOrderLog.php | 106 +++ .../school/classes/order/ServiceOrder.php | 27 + .../school/classes/order/ServiceOrderLog.php | 27 + .../view/school/classes/classes_lib/edit.html | 2 +- .../classes/order/service_order/add.html | 214 +++++ .../classes/order/service_order/edit.html | 214 +++++ .../classes/order/service_order/index.html | 44 + .../order/service_order/recyclebin.html | 25 + .../classes/order/service_order_log/add.html | 100 +++ .../classes/order/service_order_log/edit.html | 100 +++ .../order/service_order_log/index.html | 44 + .../view/school/classes/verification/add.html | 12 +- .../school/classes/verification/edit.html | 12 +- extend/bw/Redis.php | 68 ++ extend/traits/CacheTrait.php | 11 +- .../js/backend/school/classes/classes_lib.js | 32 +- .../js/backend/school/classes/order/order.js | 17 +- .../backend/school/classes/order/order_log.js | 2 +- .../school/classes/order/service_order.js | 155 ++++ .../school/classes/order/service_order_log.js | 76 ++ .../js/backend/school/classes/verification.js | 2 +- public/assets/js/manystore/general/profile.js | 17 + .../manystore/school/classes/classes_lib.js | 31 +- .../manystore/school/classes/order/order.js | 18 +- .../school/classes/order/order_log.js | 2 +- .../school/classes/order/service_order.js | 151 ++++ .../school/classes/order/service_order_log.js | 74 ++ .../manystore/school/classes/verification.js | 2 +- 94 files changed, 5856 insertions(+), 239 deletions(-) create mode 100644 application/admin/controller/school/classes/order/ServiceOrder.php create mode 100644 application/admin/controller/school/classes/order/ServiceOrderLog.php create mode 100644 application/admin/lang/zh-cn/school/classes/order/service_order.php create mode 100644 application/admin/lang/zh-cn/school/classes/order/service_order_log.php create mode 100644 application/admin/model/school/classes/order/ServiceOrder.php create mode 100644 application/admin/model/school/classes/order/ServiceOrderLog.php create mode 100644 application/admin/validate/school/classes/order/ServiceOrder.php create mode 100644 application/admin/validate/school/classes/order/ServiceOrderLog.php create mode 100644 application/admin/view/school/classes/order/service_order/add.html create mode 100644 application/admin/view/school/classes/order/service_order/edit.html create mode 100644 application/admin/view/school/classes/order/service_order/index.html create mode 100644 application/admin/view/school/classes/order/service_order/recyclebin.html create mode 100644 application/admin/view/school/classes/order/service_order_log/add.html create mode 100644 application/admin/view/school/classes/order/service_order_log/edit.html create mode 100644 application/admin/view/school/classes/order/service_order_log/index.html create mode 100644 application/api/controller/school/ServiceOrder.php create mode 100644 application/api/controller/school/worker/ServiceOrder.php create mode 100644 application/common/listener/serviceorder/OrderHook.php create mode 100644 application/common/model/school/classes/order/ServiceOrder.php create mode 100644 application/common/model/school/classes/order/ServiceOrderLog.php create mode 100644 application/manystore/controller/school/classes/order/ServiceOrder.php create mode 100644 application/manystore/controller/school/classes/order/ServiceOrderLog.php create mode 100644 application/manystore/lang/zh-cn/school/classes/order/service_order.php create mode 100644 application/manystore/lang/zh-cn/school/classes/order/service_order_log.php create mode 100644 application/manystore/model/school/classes/order/ServiceOrder.php create mode 100644 application/manystore/model/school/classes/order/ServiceOrderLog.php create mode 100644 application/manystore/validate/school/classes/order/ServiceOrder.php create mode 100644 application/manystore/validate/school/classes/order/ServiceOrderLog.php create mode 100644 application/manystore/view/school/classes/order/service_order/add.html create mode 100644 application/manystore/view/school/classes/order/service_order/edit.html create mode 100644 application/manystore/view/school/classes/order/service_order/index.html create mode 100644 application/manystore/view/school/classes/order/service_order/recyclebin.html create mode 100644 application/manystore/view/school/classes/order/service_order_log/add.html create mode 100644 application/manystore/view/school/classes/order/service_order_log/edit.html create mode 100644 application/manystore/view/school/classes/order/service_order_log/index.html create mode 100644 extend/bw/Redis.php create mode 100644 public/assets/js/backend/school/classes/order/service_order.js create mode 100644 public/assets/js/backend/school/classes/order/service_order_log.js create mode 100644 public/assets/js/manystore/school/classes/order/service_order.js create mode 100644 public/assets/js/manystore/school/classes/order/service_order_log.js diff --git a/application/admin/controller/manystore/Index.php b/application/admin/controller/manystore/Index.php index 491ca7e..cce8a69 100644 --- a/application/admin/controller/manystore/Index.php +++ b/application/admin/controller/manystore/Index.php @@ -157,7 +157,7 @@ class Index extends Backend protected function authClasses(&$params,&$shop,$row=null){ //审核失败需填写原因 if($shop["status"] == '2' && empty($shop["reason"])){ - $this->error("审核失败需填写原因"); + throw new \Exception("审核失败需填写原因"); } if($shop["status"] == '2'){ @@ -169,7 +169,7 @@ class Index extends Backend if($row){ if($shop["status"] != '1' && $row["status"] == '1'){ - $this->error("审核已通过的课程不允许再修改审核状态!"); + throw new \Exception("审核已通过的课程不允许再修改审核状态!"); } if($shop["status"] != '0' && $row["status"] == '0'){ @@ -228,7 +228,7 @@ class Index extends Backend // 课程存在未完成订单则不允许操作 $order = Order::where("manystore_id",$id)->where("status","in","0,3")->find(); - if($order)$this->error("存在正在使用中的课程订单或存在正在售后中的课程订单无法继续操作!"); + if($order)throw new \Exception("存在正在使用中的课程订单或存在正在售后中的课程订单无法继续操作!"); // 课程存在售后订单则不允许操作 } @@ -244,6 +244,7 @@ class Index extends Backend if(!$shop["user_id"])throw new \Exception("认证用户不存在!"); $user = User::get($shop["user_id"]); if(!$user) throw new \Exception("认证用户不存在!"); + if($shop["address_city"] && !$shop["province"])throw new Exception("请选择所在城市"); @@ -282,12 +283,12 @@ class Index extends Backend //名称title不能与其他课程重复 $check_title = $this->shopModel->where('id','<>',$row["id"])->where('name',$shop["name"])->find(); if($check_title){ - $this->error("机构或个人认证名称已存在或被其他机构占用,请更改!"); + throw new \Exception("机构或个人认证名称已存在或被其他机构占用,请更改!"); } //user_id不能与其他机构重复 $check_user_id = $this->shopModel->where('id','<>',$row["id"])->where('user_id',$shop["user_id"])->find(); if($check_user_id){ - $this->error("机构或个人认证用户已存在或被其他机构占用,请更改!"); + throw new \Exception("机构或个人认证用户已存在或被其他机构占用,请更改!"); } }else{ @@ -297,12 +298,12 @@ class Index extends Backend //名称title不能重复 $check_title = $this->shopModel->where('name',$shop["name"])->find(); if($check_title){ - $this->error("机构或个人认证名称已存在或被其他机构占用,请更改!"); + throw new \Exception("机构或个人认证名称已存在或被其他机构占用,请更改!"); } //user_id不能与其他机构重复 $check_user_id = $this->shopModel->where('user_id',$shop["user_id"])->find(); if($check_user_id){ - $this->error("机构或个人认证用户已存在或被其他机构占用,请更改!"); + throw new \Exception("机构或个人认证用户已存在或被其他机构占用,请更改!"); } } @@ -332,7 +333,7 @@ class Index extends Backend $this->update_check($params,$shop,$row=null); $shop_info = $this->shopModel->save($shop); if($shop_info === false){ - $this->error($this->shopModel->getError()); + throw new \Exception($this->shopModel->getError()); } $params['shop_id'] = $this->shopModel->id; @@ -345,10 +346,12 @@ class Index extends Backend $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; $result = $this->model->validate($validate)->save($params); if ($result === false) { - $this->error($this->model->getError()); + throw new \Exception($this->model->getError()); } + + $manystoreAuthGroupModel = new ManystoreAuthGroup(); $group = []; $group['shop_id'] = $this->shopModel->id; @@ -358,7 +361,7 @@ class Index extends Backend $group['updatetime'] = time(); $group_id = $manystoreAuthGroupModel->insertGetId($group); if(!$group_id){ - $this->error('添加失败'); + throw new \Exception('添加失败'); } $manystoreAuthGroupAccessModel = new ManystoreAuthGroupAccess(); @@ -374,12 +377,12 @@ class Index extends Backend \think\Hook::listen('shop_create_after', $data); db()->commit(); - $this->success(); - }catch (Exception $e){ + + }catch (\Exception $e){ db()->rollback(); $this->error($e->getMessage()); } - + $this->success(); } $this->error(); } @@ -404,31 +407,25 @@ class Index extends Backend $params = $this->request->post("row/a"); $shop = $this->request->post("shop/a"); if ($params) { - $shop["user_id"] = $params['user_id']; + $shop["user_id"] = $params['user_id']; + + db()->startTrans(); + try{ $this->update_check($params,$shop,$shop_info); + $result = $shop_info->save($shop); if($result === false){ - $this->error(__("修改商家信息资料失败")); + throw new \Exception(__("修改商家信息资料失败")); } - 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){ +//当前密码 + $password = $params['password'] ? $params['password'] : \app\common\model\dyqc\ManystoreShop::getDefaultPassword($shop["type"],$params["user_id"],$params); - //调用通过事件 - $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")); + throw new \Exception(__("Please input correct password")); } $params['salt'] = Random::alnum(); $params['password'] = md5(md5($params['password']) . $params['salt']); @@ -448,13 +445,34 @@ class Index extends Backend $result = $row->validate($validate)->save($params); if ($result === false) { - $this->error($row->getError()); + throw new \Exception($row->getError()); } - //调用事件 $data = ['shop' => $shop_info]; - \think\Hook::listen('shop_update_after', $data); + \think\Hook::listen('shop_update_after', $data); + + if($this->success_auth){ + + + //调用通过事件 + $data = ['shop' => $shop_info,"password"=>$password]; + \think\Hook::listen('shop_auth_success_after', $data); + + } + if($this->error_auth){ + + //调用通过事件 + $data = ['shop' => $shop_info]; + \think\Hook::listen('shop_auth_fail_after', $data); + } + + + db()->commit(); + }catch (\Exception $e){ + db()->rollback(); + $this->error($e->getMessage().$e->getFile().$e->getLine()); + } $this->success(); } $this->error(); @@ -482,10 +500,11 @@ class Index extends Backend $this->error(__('No Results were found')); } - $this->updateCheck($ids); + db()->startTrans(); try{ + $this->updateCheck($ids); $result = $row->delete(); if(!$result){ exception('账号信息删除失败'); @@ -496,7 +515,7 @@ class Index extends Backend } db()->commit(); $this->success('删除成功'); - }catch (Exception $e){ + }catch (\Exception $e){ db()->rollback(); $this->error($e->getMessage()); } diff --git a/application/admin/controller/school/classes/ClassesLib.php b/application/admin/controller/school/classes/ClassesLib.php index 8566b55..8d385a6 100644 --- a/application/admin/controller/school/classes/ClassesLib.php +++ b/application/admin/controller/school/classes/ClassesLib.php @@ -211,7 +211,7 @@ class ClassesLib extends Backend protected function update_check(&$params,$row=null) { - try { +// try { $classesLib = new \app\common\model\school\classes\ClassesLib(); $classesLib->no_auth_fields = $this->no_auth_fields; $classesLib->need_auth = $this->need_auth; @@ -222,9 +222,9 @@ class ClassesLib extends Backend $this->need_auth = $classesLib->need_auth; $this->have_auth = $classesLib->have_auth; - }catch (\Exception $e){ - $this->error($e->getMessage()); - } +// }catch (\Exception $e){ +// $this->error($e->getMessage()); +// } //特有认证判断 @@ -249,7 +249,17 @@ class ClassesLib extends Backend } protected function update_classes($classes_lib_id){ + //课时数必须大于等于课时核销数 + $count = \app\common\model\school\classes\ClassesSpec::where("classes_lib_id",$classes_lib_id)->count(); + $classes_num = \app\common\model\school\classes\ClassesLib::where("id",$classes_lib_id)->value("classes_num"); + if($count < $classes_num){ + throw new \Exception("课时数必须大于等于课时核销数"); + } + + \app\common\model\school\classes\ClassesLib::update_classes($classes_lib_id); + + } @@ -310,7 +320,7 @@ class ClassesLib extends Backend Db::commit(); - } catch (ValidateException|PDOException|Exception $e) { + } catch (ValidateException|PDOException|\Exception $e) { Db::rollback(); $this->error($e->getMessage()); } @@ -362,6 +372,14 @@ class ClassesLib extends Backend \app\common\model\school\classes\ClassesSpec::create($v); } + //因为是批量添加,所有规格重新进行检测,防止出现时间重叠 + $specss = \app\common\model\school\classes\ClassesSpec::where("classes_lib_id",$this->model["id"])->select(); + foreach ($specss as $k=>$specs){ + $params =$specs; + (new \app\common\model\school\classes\ClassesSpec)->specCheck($params,null,$specs); + } + + $this->update_classes($this->model["id"]); if($this->have_auth){ @@ -387,7 +405,7 @@ class ClassesLib extends Backend Db::commit(); - } catch (ValidateException|PDOException|Exception $e) { + } catch (ValidateException|PDOException|\Exception $e) { Db::rollback(); $this->error($e->getMessage()); } @@ -441,6 +459,9 @@ class ClassesLib extends Backend $this->update_check($params,$row); $spec = $params["spec"] ?? []; + +// var_dump($spec); + $delete_spec_ids = $params["delete_spec_ids"] ?? []; unset($params["spec"]); unset($params["delete_spec_ids"]); @@ -461,6 +482,13 @@ class ClassesLib extends Backend $delete_spec->delete(); } + //因为是批量添加,所有规格重新进行检测,防止出现时间重叠 + $specss = \app\common\model\school\classes\ClassesSpec::where("classes_lib_id",$row["id"])->select(); + foreach ($specss as $k=>$specs){ + $params =$specs; + (new \app\common\model\school\classes\ClassesSpec)->specCheck($params,null,$specs); + } + $this->update_classes($row["id"]); if($this->have_auth){ //调用通过事件 @@ -488,7 +516,7 @@ class ClassesLib extends Backend Db::commit(); - } catch (ValidateException|PDOException|Exception $e) { + } catch (ValidateException|PDOException|\Exception $e) { Db::rollback(); $this->error($e->getMessage()); } diff --git a/application/admin/controller/school/classes/order/ServiceOrder.php b/application/admin/controller/school/classes/order/ServiceOrder.php new file mode 100644 index 0000000..d9e34ed --- /dev/null +++ b/application/admin/controller/school/classes/order/ServiceOrder.php @@ -0,0 +1,80 @@ +model = new \app\admin\model\school\classes\order\ServiceOrder; + $this->view->assign("statusList", $this->model->getStatusList()); + $this->view->assign("serviceStautsList", $this->model->getServiceStautsList()); + $this->view->assign("salesTypeList", $this->model->getSalesTypeList()); + $this->view->assign("platformList", $this->model->getPlatformList()); + $this->view->assign("payTypeList", $this->model->getPayTypeList()); + } + + + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + + /** + * 查看 + */ + public function index() + { + //当前是否为关联查询 + $this->relationSearch = true; + //设置过滤方法 + $this->request->filter(['strip_tags', 'trim']); + if ($this->request->isAjax()) { + //如果发送的来源是Selectpage,则转发到Selectpage + if ($this->request->request('keyField')) { + return $this->selectpage(); + } + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + + $list = $this->model + ->with(['classesorder','user','detail','lib','manystore','shop']) + ->where($where) + ->order($sort, $order) + ->paginate($limit); + + foreach ($list as $row) { + + $row->getRelation('classesorder')->visible(['order_no','pay_no']); + $row->getRelation('user')->visible(['nickname','realname','mobile','avatar']); + $row->getRelation('detail')->visible(['title','headimage']); + $row->getRelation('lib')->visible(['title','headimage']); + $row->getRelation('manystore')->visible(['nickname']); + $row->getRelation('shop')->visible(['name','logo']); + } + + $result = array("total" => $list->total(), "rows" => $list->items()); + + return json($result); + } + return $this->view->fetch(); + } + +} diff --git a/application/admin/controller/school/classes/order/ServiceOrderLog.php b/application/admin/controller/school/classes/order/ServiceOrderLog.php new file mode 100644 index 0000000..4e19bf5 --- /dev/null +++ b/application/admin/controller/school/classes/order/ServiceOrderLog.php @@ -0,0 +1,77 @@ +model = new \app\admin\model\school\classes\order\ServiceOrderLog; + $this->view->assign("statusList", $this->model->getStatusList()); + $this->view->assign("serviceStautsList", $this->model->getServiceStautsList()); + $this->view->assign("salesTypeList", $this->model->getSalesTypeList()); + } + + + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + + /** + * 查看 + */ + public function index() + { + //当前是否为关联查询 + $this->relationSearch = true; + //设置过滤方法 + $this->request->filter(['strip_tags', 'trim']); + if ($this->request->isAjax()) { + //如果发送的来源是Selectpage,则转发到Selectpage + if ($this->request->request('keyField')) { + return $this->selectpage(); + } + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + + $list = $this->model + ->with(['serviceorder','classesorder','user','detail','admin']) + ->where($where) + ->order($sort, $order) + ->paginate($limit); + + foreach ($list as $row) { + + $row->getRelation('serviceorder')->visible(['order_no']); + $row->getRelation('classesorder')->visible(['order_no','pay_no']); + $row->getRelation('user')->visible(['nickname','realname','mobile','avatar']); + $row->getRelation('detail')->visible(['title']); + $row->getRelation('admin')->visible(['nickname']); + } + + $result = array("total" => $list->total(), "rows" => $list->items()); + + return json($result); + } + return $this->view->fetch(); + } + +} diff --git a/application/admin/lang/zh-cn/manystore/index.php b/application/admin/lang/zh-cn/manystore/index.php index 4075b06..2e7d4a5 100644 --- a/application/admin/lang/zh-cn/manystore/index.php +++ b/application/admin/lang/zh-cn/manystore/index.php @@ -8,6 +8,7 @@ return [ 'Please input correct password' => '密码长度必须在6-16位之间,不能包含空格', 'Please input correct nickname' => '昵称仅支持输入中文、英文字母(大小写)、数字、下划线', 'Please input length nickname' => '昵称请最多填写10个字符', + 'Loss_ratio' => '课程损耗比(百分制)', 'user_id' => '申请用户', 'Logo' => 'Logo', 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 5affc8c..24e1a0d 100644 --- a/application/admin/lang/zh-cn/school/classes/order/order.php +++ b/application/admin/lang/zh-cn/school/classes/order/order.php @@ -25,6 +25,8 @@ return [ 'Set status to 0' => '设为待支付', 'Status 3' => '使用中', 'Set status to 3' => '设为使用中', + 'Status 4' => '售后中', + 'Set status to 4' => '设为售后中', 'Status 6' => '已退款', 'Set status to 6' => '设为已退款', 'Status 9' => '已完成', diff --git a/application/admin/lang/zh-cn/school/classes/order/order_log.php b/application/admin/lang/zh-cn/school/classes/order/order_log.php index 47870e1..aa6cdd0 100644 --- a/application/admin/lang/zh-cn/school/classes/order/order_log.php +++ b/application/admin/lang/zh-cn/school/classes/order/order_log.php @@ -9,6 +9,8 @@ return [ 'Set status to 0' => '设为待支付', 'Status 3' => '使用中', 'Set status to 3' => '设为使用中', + 'Status 4' => '售后中', + 'Set status to 4' => '设为售后中', 'Status 6' => '已退款', 'Set status to 6' => '设为已退款', 'Status 9' => '已完成', diff --git a/application/admin/lang/zh-cn/school/classes/order/service_order.php b/application/admin/lang/zh-cn/school/classes/order/service_order.php new file mode 100644 index 0000000..1e81ee8 --- /dev/null +++ b/application/admin/lang/zh-cn/school/classes/order/service_order.php @@ -0,0 +1,68 @@ + '售后单号', + 'Reason' => '售后申请原因', + 'Classes_order_id' => '课程订单id', + 'User_id' => '下单人id', + 'Classes_order_detail_id' => '订单课程id', + 'Classes_lib_id' => '课程id', + 'Manystore_id' => '机构账号id', + 'Shop_id' => '机构店铺id', + 'Status' => '售后状态', + 'Status 1' => '待处理', + 'Set status to 1' => '设为待处理', + 'Status 4' => '处理中', + 'Set status to 4' => '设为处理中', + 'Status 7' => '已结单', + 'Set status to 7' => '设为已结单', + 'Status -3' => '已取消', + 'Set status to -3' => '设为已取消', + 'Service_stauts' => '售后处理状态', + 'Service_stauts 1' => '待机构处理', + 'Service_stauts 4' => '待用户确认', + 'Service_stauts 7' => '售后通过结单', + 'Service_stauts -3' => '售后驳回结单', + 'Sales_type' => '结单类型', + 'Sales_type -3' => '未结单', + 'Sales_type 1' => '机构驳回', + 'Sales_type 4' => '用户驳回', + 'Sales_type 7' => '平台驳回', + 'Sales_type 10' => '成功退款', + 'Reject_reason' => '驳回原因', + 'Reject_images' => '驳回图片资料', + 'Auto_price' => '自动计算应退全额', + 'Loss_proportion' => '课程损耗比例', + 'Auto_loss_price' => '自动计算损耗金额', + 'Tbc_price' => '售后待确认退款金额', + 'C_price' => '售后已确认退款金额', + 'Real_refundprice' => '实际退款金额', + 'Sub_refundprice' => '剩余未退金额', + 'Platform' => '退款平台', + 'Platform miniapp' => '微信小程序', + 'Pay_type' => '退款方式', + 'Pay_type yue' => '余额', + 'Pay_type wechat' => '微信', + 'Pay_json' => '三方支付信息json', + 'Deletetime' => '删除时间', + 'Refundtime' => '退款时间', + 'Rejecttime' => '驳回时间', + 'Handletime' => '处理时间', + 'Confirmtime' => '确认时间', + 'Checkouttime' => '结单时间', + 'Createtime' => '创建时间', + 'Updatetime' => '修改时间', + 'Order.order_no' => '订单号', + 'Order.pay_no' => '微信支付单号', + 'User.nickname' => '昵称', + 'User.realname' => '真实姓名', + 'User.mobile' => '手机号', + 'User.avatar' => '头像', + 'Detail.title' => '标题', + 'Detail.headimage' => '头图', + 'Lib.title' => '标题', + 'Lib.headimage' => '头图', + 'Manystore.nickname' => '昵称', + 'Shop.name' => '店铺名称', + 'Shop.logo' => '品牌LOGO' +]; diff --git a/application/admin/lang/zh-cn/school/classes/order/service_order_log.php b/application/admin/lang/zh-cn/school/classes/order/service_order_log.php new file mode 100644 index 0000000..c8accc7 --- /dev/null +++ b/application/admin/lang/zh-cn/school/classes/order/service_order_log.php @@ -0,0 +1,45 @@ + '课程售后订单id', + 'Classes_order_id' => '课程订单id', + 'User_id' => '下单人id', + 'Classes_order_detail_id' => '订单课程id', + 'Classes_lib_id' => '课程id', + 'Manystore_id' => '机构账号id', + 'Shop_id' => '机构店铺id', + 'Status' => '售后状态', + 'Status 1' => '待处理', + 'Set status to 1' => '设为待处理', + 'Status 4' => '处理中', + 'Set status to 4' => '设为处理中', + 'Status 7' => '已结单', + 'Set status to 7' => '设为已结单', + 'Status -3' => '已取消', + 'Set status to -3' => '设为已取消', + 'Service_stauts' => '售后处理状态', + 'Service_stauts 1' => '待机构处理', + 'Service_stauts 4' => '待用户确认', + 'Service_stauts 7' => '售后通过结单', + 'Service_stauts -3' => '售后驳回结单', + 'Sales_type' => '结单类型', + 'Sales_type -3' => '未结单', + 'Sales_type 1' => '机构驳回', + 'Sales_type 4' => '用户驳回', + 'Sales_type 7' => '平台驳回', + 'Sales_type 10' => '成功退款', + 'Log_text' => '记录内容', + 'Oper_id' => '记录人id', + 'Oper_type' => '记录人类型', + 'Createtime' => '创建时间', + 'Updatetime' => '修改时间', + 'Order.order_no' => '售后单号', + 'Order.order_no' => '订单号', + 'Order.pay_no' => '微信支付单号', + 'User.nickname' => '昵称', + 'User.realname' => '真实姓名', + 'User.mobile' => '手机号', + 'User.avatar' => '头像', + 'Detail.title' => '标题', + 'Admin.nickname' => '昵称' +]; diff --git a/application/admin/model/school/classes/order/Order.php b/application/admin/model/school/classes/order/Order.php index eea5811..a4640ba 100644 --- a/application/admin/model/school/classes/order/Order.php +++ b/application/admin/model/school/classes/order/Order.php @@ -45,7 +45,7 @@ class Order extends Model public function getStatusList() { - return ['-3' => __('Status -3'), '0' => __('Status 0'), '3' => __('Status 3'), '6' => __('Status 6'), '9' => __('Status 9')]; + return ['-3' => __('Status -3'), '0' => __('Status 0'), '3' => __('Status 3'),'4' => __('Status 4'), '6' => __('Status 6'), '9' => __('Status 9')]; } public function getBeforeStatusList() diff --git a/application/admin/model/school/classes/order/OrderLog.php b/application/admin/model/school/classes/order/OrderLog.php index ba4251c..a5237eb 100644 --- a/application/admin/model/school/classes/order/OrderLog.php +++ b/application/admin/model/school/classes/order/OrderLog.php @@ -35,7 +35,7 @@ class OrderLog extends Model public function getStatusList() { - return ['-3' => __('Status -3'), '0' => __('Status 0'), '3' => __('Status 3'), '6' => __('Status 6'), '9' => __('Status 9')]; + return ['-3' => __('Status -3'), '0' => __('Status 0'), '3' => __('Status 3'),'4' => __('Status 4'), '6' => __('Status 6'), '9' => __('Status 9')]; } public function getBeforeStatusList() diff --git a/application/admin/model/school/classes/order/ServiceOrder.php b/application/admin/model/school/classes/order/ServiceOrder.php new file mode 100644 index 0000000..e491808 --- /dev/null +++ b/application/admin/model/school/classes/order/ServiceOrder.php @@ -0,0 +1,206 @@ + __('Status 1'), '4' => __('Status 4'), '7' => __('Status 7'), '-3' => __('Status -3')]; + } + + public function getServiceStautsList() + { + return ['1' => __('Service_stauts 1'), '4' => __('Service_stauts 4'), '7' => __('Service_stauts 7'), '-3' => __('Service_stauts -3')]; + } + + public function getSalesTypeList() + { + return ['-3' => __('Sales_type -3'), '1' => __('Sales_type 1'), '4' => __('Sales_type 4'), '7' => __('Sales_type 7'), '10' => __('Sales_type 10')]; + } + + public function getPlatformList() + { + return ['miniapp' => __('Platform miniapp')]; + } + + public function getPayTypeList() + { + return ['yue' => __('Pay_type yue'), 'wechat' => __('Pay_type wechat')]; + } + + + public function getStatusTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['status']) ? $data['status'] : ''); + $list = $this->getStatusList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getServiceStautsTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['service_stauts']) ? $data['service_stauts'] : ''); + $list = $this->getServiceStautsList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getSalesTypeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['sales_type']) ? $data['sales_type'] : ''); + $list = $this->getSalesTypeList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getPlatformTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['platform']) ? $data['platform'] : ''); + $list = $this->getPlatformList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getPayTypeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['pay_type']) ? $data['pay_type'] : ''); + $list = $this->getPayTypeList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getRefundtimeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['refundtime']) ? $data['refundtime'] : ''); + return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; + } + + + public function getRejecttimeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['rejecttime']) ? $data['rejecttime'] : ''); + return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; + } + + + public function getHandletimeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['handletime']) ? $data['handletime'] : ''); + return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; + } + + + public function getConfirmtimeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['confirmtime']) ? $data['confirmtime'] : ''); + return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; + } + + + public function getCheckouttimeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['checkouttime']) ? $data['checkouttime'] : ''); + return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; + } + + protected function setRefundtimeAttr($value) + { + return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); + } + + protected function setRejecttimeAttr($value) + { + return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); + } + + protected function setHandletimeAttr($value) + { + return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); + } + + protected function setConfirmtimeAttr($value) + { + return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); + } + + protected function setCheckouttimeAttr($value) + { + return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); + } + + + public function classesorder() + { + return $this->belongsTo(Order::class, 'classes_order_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function user() + { + return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function detail() + { + return $this->belongsTo(OrderDetail::class, 'classes_order_detail_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function lib() + { + return $this->belongsTo(ClassesLib::class, 'classes_lib_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function manystore() + { + return $this->belongsTo(Manystore::class, 'manystore_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function shop() + { + return $this->belongsTo(ManystoreShop::class, 'shop_id', 'id', [], 'LEFT')->setEagerlyType(0); + } +} diff --git a/application/admin/model/school/classes/order/ServiceOrderLog.php b/application/admin/model/school/classes/order/ServiceOrderLog.php new file mode 100644 index 0000000..dff936e --- /dev/null +++ b/application/admin/model/school/classes/order/ServiceOrderLog.php @@ -0,0 +1,106 @@ + __('Status 1'), '4' => __('Status 4'), '7' => __('Status 7'), '-3' => __('Status -3')]; + } + + public function getServiceStautsList() + { + return ['1' => __('Service_stauts 1'), '4' => __('Service_stauts 4'), '7' => __('Service_stauts 7'), '-3' => __('Service_stauts -3')]; + } + + public function getSalesTypeList() + { + return ['-3' => __('Sales_type -3'), '1' => __('Sales_type 1'), '4' => __('Sales_type 4'), '7' => __('Sales_type 7'), '10' => __('Sales_type 10')]; + } + + + public function getStatusTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['status']) ? $data['status'] : ''); + $list = $this->getStatusList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getServiceStautsTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['service_stauts']) ? $data['service_stauts'] : ''); + $list = $this->getServiceStautsList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getSalesTypeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['sales_type']) ? $data['sales_type'] : ''); + $list = $this->getSalesTypeList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + + + public function serviceorder() + { + return $this->belongsTo(ServiceOrder::class, 'classes_service_order_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function classesorder() + { + return $this->belongsTo(Order::class, 'classes_order_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function user() + { + return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function detail() + { + return $this->belongsTo(OrderDetail::class, 'classes_order_detail_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function admin() + { + return $this->belongsTo(Admin::class, 'oper_id', 'id', [], 'LEFT')->setEagerlyType(0); + } +} diff --git a/application/admin/validate/school/classes/order/ServiceOrder.php b/application/admin/validate/school/classes/order/ServiceOrder.php new file mode 100644 index 0000000..7f23f79 --- /dev/null +++ b/application/admin/validate/school/classes/order/ServiceOrder.php @@ -0,0 +1,27 @@ + [], + 'edit' => [], + ]; + +} diff --git a/application/admin/validate/school/classes/order/ServiceOrderLog.php b/application/admin/validate/school/classes/order/ServiceOrderLog.php new file mode 100644 index 0000000..9ed94a9 --- /dev/null +++ b/application/admin/validate/school/classes/order/ServiceOrderLog.php @@ -0,0 +1,27 @@ + [], + 'edit' => [], + ]; + +} diff --git a/application/admin/view/school/classes/classes_lib/edit.html b/application/admin/view/school/classes/classes_lib/edit.html index 9343a5b..ce09c5e 100644 --- a/application/admin/view/school/classes/classes_lib/edit.html +++ b/application/admin/view/school/classes/classes_lib/edit.html @@ -176,7 +176,7 @@
- + (填写几节意味着客户购买课程后能预约上课核销几次,即购买本课程的课程节数)
diff --git a/application/admin/view/school/classes/order/service_order/add.html b/application/admin/view/school/classes/order/service_order/add.html new file mode 100644 index 0000000..f518ed3 --- /dev/null +++ b/application/admin/view/school/classes/order/service_order/add.html @@ -0,0 +1,219 @@ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+ {foreach name="statusList" item="vo"} + + {/foreach} +
+ +
+
+
+ +
+ + + +
+
+
+ +
+ + + +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ + +
+ +
+
    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + + +
    +
    +
    + +
    + + + +
    +
    +
    + +
    + +
    +
    + {:__('Key')} + {:__('Value')} +
    +
    {:__('Append')}
    + +
    + + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    + +
    diff --git a/application/admin/view/school/classes/order/service_order/edit.html b/application/admin/view/school/classes/order/service_order/edit.html new file mode 100644 index 0000000..3667d1d --- /dev/null +++ b/application/admin/view/school/classes/order/service_order/edit.html @@ -0,0 +1,219 @@ +
    + +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    + {foreach name="statusList" item="vo"} + + {/foreach} +
    + +
    +
    +
    + +
    + + + +
    +
    +
    + +
    + + + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    + + +
    + +
    +
      +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + + + +
      +
      +
      + +
      + + + +
      +
      +
      + +
      + +
      +
      + {:__('Key')} + {:__('Value')} +
      +
      {:__('Append')}
      + +
      + + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      + +
      diff --git a/application/admin/view/school/classes/order/service_order/index.html b/application/admin/view/school/classes/order/service_order/index.html new file mode 100644 index 0000000..f6b245f --- /dev/null +++ b/application/admin/view/school/classes/order/service_order/index.html @@ -0,0 +1,46 @@ +
      + +
      + {:build_heading(null,FALSE)} + +
      + + +
      +
      +
      +
      +
      + + {:__('Add')} + {:__('Edit')} + {:__('Delete')} + + + + + {:__('Recycle bin')} +
      + +
      +
      +
      + +
      +
      +
      diff --git a/application/admin/view/school/classes/order/service_order/recyclebin.html b/application/admin/view/school/classes/order/service_order/recyclebin.html new file mode 100644 index 0000000..c4353f1 --- /dev/null +++ b/application/admin/view/school/classes/order/service_order/recyclebin.html @@ -0,0 +1,25 @@ +
      + {:build_heading()} + +
      +
      +
      + +
      + +
      +
      +
      diff --git a/application/admin/view/school/classes/order/service_order_log/add.html b/application/admin/view/school/classes/order/service_order_log/add.html new file mode 100644 index 0000000..7fd5c3e --- /dev/null +++ b/application/admin/view/school/classes/order/service_order_log/add.html @@ -0,0 +1,105 @@ +
      + +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      + {foreach name="statusList" item="vo"} + + {/foreach} +
      + +
      +
      +
      + +
      + + + +
      +
      +
      + +
      + + + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      + +
      diff --git a/application/admin/view/school/classes/order/service_order_log/edit.html b/application/admin/view/school/classes/order/service_order_log/edit.html new file mode 100644 index 0000000..e0072fa --- /dev/null +++ b/application/admin/view/school/classes/order/service_order_log/edit.html @@ -0,0 +1,105 @@ +
      + +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      + {foreach name="statusList" item="vo"} + + {/foreach} +
      + +
      +
      +
      + +
      + + + +
      +
      +
      + +
      + + + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      + +
      diff --git a/application/admin/view/school/classes/order/service_order_log/index.html b/application/admin/view/school/classes/order/service_order_log/index.html new file mode 100644 index 0000000..696b02f --- /dev/null +++ b/application/admin/view/school/classes/order/service_order_log/index.html @@ -0,0 +1,46 @@ +
      + +
      + {:build_heading(null,FALSE)} + +
      + + +
      +
      +
      +
      +
      + + {:__('Add')} + {:__('Edit')} + {:__('Delete')} + + + + + +
      + +
      +
      +
      + +
      +
      +
      diff --git a/application/admin/view/school/classes/verification/add.html b/application/admin/view/school/classes/verification/add.html index 7746a20..ea9785b 100644 --- a/application/admin/view/school/classes/verification/add.html +++ b/application/admin/view/school/classes/verification/add.html @@ -24,12 +24,12 @@
      -
      - -
      - -
      -
      + + + + + +
      diff --git a/application/admin/view/school/classes/verification/edit.html b/application/admin/view/school/classes/verification/edit.html index 1faffd1..98a2a5e 100644 --- a/application/admin/view/school/classes/verification/edit.html +++ b/application/admin/view/school/classes/verification/edit.html @@ -24,12 +24,12 @@
      -
      - -
      - -
      -
      + + + + + +
      diff --git a/application/api/controller/User.php b/application/api/controller/User.php index 481717e..84c5996 100644 --- a/application/api/controller/User.php +++ b/application/api/controller/User.php @@ -66,7 +66,7 @@ class User extends Api } catch (\Exception $e){ $this->error($e->getMessage()); } - Cache::set('wechat_mini_code'.$code.$result['openid'],"1",60); + Cache::set('wechat_miniapp_code'.$code.$result['openid'],"1",60); $this->success('',$result); } @@ -123,15 +123,16 @@ class User extends Api $params['unionid'] = $this->request->param('unionid/s',''); $params['apptype'] = $this->request->param('apptype/s','miniapp'); $params['openid'] = $this->request->param('openid/s',''); + $platform = $this->request->param('platform/s','wechat'); $code = $this->request->param('code/s',''); if(empty($code)){ $this->error(__('缺少code')); } - $wechat_mini_code = Cache::get('wechat_mini_code'.$code.$params['openid']); + $wechat_mini_code = Cache::get("{$platform}_{$params['apptype']}_code".$code.$params['openid']); if(!$wechat_mini_code)$this->error("授权code已过期或已使用,请重新发起授权!",['errcode'=>30002]); - $platform = $this->request->param('platform/s','wechat'); + //推荐人:逻辑未实现 $rec_user_id = $this->request->param('rec_user_id',0,'xilufitness_get_id_value'); $keeptime = $this->request->param('keeptime/d',0); diff --git a/application/api/controller/school/Classes.php b/application/api/controller/school/Classes.php index be1ae26..9429ee0 100644 --- a/application/api/controller/school/Classes.php +++ b/application/api/controller/school/Classes.php @@ -140,17 +140,33 @@ class Classes extends Base * @ApiRoute(/api/school/classes/spec) * @ApiMethod(GET) * @ApiParams(name = "id", type = "int",required=true,description = "课程id") + * @ApiParams(name = "user_id", type = "int",required=true,description = "需要查询是否下单的用户id") * @ApiReturn({ spec 课时规格 }) */ public function spec(){ + $user_id = $this->request->get('user_id/d',0); $id = $this->request->get('id/d',''); + $user = $this->auth->getUser();//登录用户 if(empty($id)){ $this->error(__('缺少必要参数')); } try { - $res = $this->model->spec($id); + //如果是员工端操作 + if($user_id && $id && $user){ + //判断是否有操作权限 + $classes_lib_ids = (new ClassesLib)->getClassesAuthIds($user['id']); + //判断当前订单课程是否在此课程授权范围内 + if(!in_array($id,$classes_lib_ids)) throw new \Exception("该课程不在您的授权范围内,无法查看!"); + + } + + + if($user && !$user_id)$user_id = $user['id']; + + + $res = $this->model->spec($id,$user_id); } catch (\Exception $e){ // Log::log($e->getMessage()); $this->error($e->getMessage(),['errcode'=>$e->getCode()]); @@ -266,7 +282,7 @@ class Classes extends Base * @ApiParams(name = "selfhot", type = "string",required=false,description = "机构热门:0=否,1=是") * @ApiParams(name = "feel", type = "string",required=false,description = "是否免费:0=否,1=是") * @ApiParams(name = "collect", type = "int",required=false,description = "是否专查我的收藏(需登录):1=是") - * @ApiParams(name = "order", type = "string",required=false,description = " normal=综合排序推薦優先,distance=距离优先,hot=熱門优先,new=平台最新优先,selfhot=机构热门优先,sale=銷量优先") + * @ApiParams(name = "order", type = "string",required=false,description = " normal=综合排序推薦優先,distance=距离优先,hot=熱門优先,new=平台最新优先,selfhot=机构热门优先,sale=銷量优先,views=浏览量优先,collect=收藏量优先") * @ApiParams(name = "nearby", type = "string",required=false,description = "限制最大搜索距离(米)") * @ApiParams(name = "latitude", type = "string",required=false,description = "latitude") * @ApiParams(name = "longitude", type = "string",required=false,description = "longitude") diff --git a/application/api/controller/school/HourOrder.php b/application/api/controller/school/HourOrder.php index 48bc084..bfd8ec0 100644 --- a/application/api/controller/school/HourOrder.php +++ b/application/api/controller/school/HourOrder.php @@ -9,7 +9,7 @@ use app\common\model\school\classes\hourorder\Order as OrderModel; */ class HourOrder extends Base { - protected $noNeedLogin = []; + protected $noNeedLogin = ["get_month_by_time"]; protected $noNeedRight = '*'; protected $model = null; @@ -169,6 +169,7 @@ class HourOrder extends Base * @ApiParams(name = "status", type = "string",required=false,description = "订单状态:-3=已取消,-1=已报名待审核,0=已预约,3=已完成") * @ApiParams(name = "classes_order_id", type = "int",required=true,description = "课程订单id") * @ApiParams(name = "classes_lib_id", type = "int",required=false,description = "课程id") + * @ApiParams(name = "time", type = "string",required=false,description = "按开始和结束时间区间查(传值格式:Y/m/d H:M:S-Y/m/d H:M:S)") * @ApiParams(name = "start_time", type = "string",required=false,description = "按开始时间区间查(传值格式:Y/m/d H:M:S-Y/m/d H:M:S)") * @ApiParams(name = "createtime", type = "string",required=false,description = "按创建时间区间查(传值格式:Y/m/d H:M:S-Y/m/d H:M:S)") * @ApiReturn({ @@ -189,18 +190,19 @@ class HourOrder extends Base $start_time = $this->request->get('start_time/s', ''); //搜索关键字 $createtime = $this->request->get('createtime/s', ''); //搜索关键字 + $time = $this->request->get('time/s', ''); //搜索关键字 // $type = $this->request->get('type/s', ''); //筛选学员和教练单 try{ //当前申请状态 - $res = $this->model::allList($user_id,$page, $limit,$keywords,$status,$classes_order_id,$classes_lib_ids,$start_time,$createtime); + $res = $this->model::allList($user_id,$page, $limit,$keywords,$status,$classes_order_id,$classes_lib_ids,$start_time,$createtime,$time); // if($user_id =='670153'){ // file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql()); // } }catch (\Exception $e){ - $this->error($e->getMessage()); + $this->error($this->model::getLastSql()); } $this->success('查询成功', $res); } @@ -233,5 +235,31 @@ class HourOrder extends Base $this->success('查询成功', $res); } + + /** + * @ApiTitle(通过时间点得到当前的月份数据) + * @ApiSummary(通过时间点得到当前的月份数据) + * @ApiMethod(GET) + * @ApiParams(name="time",type="string",required=true,description="选择的时间点时间戳") + * @ApiParams(name = "status", type = "string",required=false,description = "订单状态:-3=已取消,-1=已报名待审核,0=已预约,3=已完成") + */ + public function get_month_by_time(){ + $time = $this->request->get('time/s',''); + $status = $this->request->get('status/s','-1,0'); + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; +// if(empty($time)){ +// $this->error(__('缺少必要参数')); +// } + try { + $res = $this->model::getMonthByTime($time,$user_id,$status); + } catch (\Exception $e){ +// Log::log($e->getMessage()); + $this->error($e->getMessage(),['errcode'=>$e->getCode()]); + } + $this->success('生成成功', $res); + } + } diff --git a/application/api/controller/school/Message.php b/application/api/controller/school/Message.php index 7330bb5..a00ab80 100644 --- a/application/api/controller/school/Message.php +++ b/application/api/controller/school/Message.php @@ -10,7 +10,7 @@ use app\common\model\school\classes\Teacher as Teachermodel; */ class Message extends Base { - protected $noNeedLogin = []; + protected $noNeedLogin = ['message_count']; protected $noNeedRight = '*'; protected $model = null; @@ -127,5 +127,41 @@ class Message extends Base } + + /** + * @ApiTitle( 设置一键已读) + * @ApiSummary(设置一键已读) + * @ApiMethod(GET) + * @ApiParams(name = "id", type = "string",required=false,description = "默认* 多值逗号拼接") + * @ApiParams(name = "event", type = "string",required=false,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=其他") + * @ApiReturn({ + * + *}) + */ + public function batch() + { + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + + $id = $this->request->get('id/s', '*'); //条数 + $event = $this->request->get('event/s', ''); //搜索关键字 + $status = $this->request->get('status/s', ''); //搜索关键字 + $mini_type = $this->request->get('mini_type/s', ''); //搜索关键字 + + try{ + //当前申请状态 + $res = $this->model::batchRead($id,$user_id,$status,$mini_type,$event,'user',$user_id,true); + + }catch (\Exception $e){ + + $this->error($e->getMessage()); + } + $this->success('操作成功'); + } + + } diff --git a/application/api/controller/school/ServiceOrder.php b/application/api/controller/school/ServiceOrder.php new file mode 100644 index 0000000..d8c11da --- /dev/null +++ b/application/api/controller/school/ServiceOrder.php @@ -0,0 +1,236 @@ +model = new OrderModel; + parent::_initialize(); + + //判断登录用户是否是员工 + } + + + /** + * @ApiTitle( 售后订单详情) + * @ApiSummary(售后订单详情) + * @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 = OrderModel::getDetail($id); + } catch (\Exception $e){ +// Log::log($e->getMessage()); + $this->error($e->getMessage(),['errcode'=>$e->getCode()]); + } + $this->success('获取成功', ['detail' => $res]); + } + + + + + + /** + * @ApiTitle( 订单申请售后接口 ) + * @ApiSummary(订单申请售后) + * @ApiMethod(POST) + * @ApiParams(name = "classes_order_id", type = "int",required=true,description = "需要售后的课程订单id") + * @ApiParams(name = "reason", type = "string",required=true,description = "申请理由") + * @ApiReturn({ + * + *}) + */ + public function create(){ + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + $classes_order = $this->request->post('classes_order_id/d', 0); //课程id + $reason = $this->request->post('reason/s', ''); //订单号 + try{ + //当前申请状态 + $res = $this->model->afterSales($classes_order,$reason,'','user',$user_id,true); + }catch (\Exception $e){ +// Log::log($e->getMessage()); + $this->error($e->getMessage(),['errcode'=>$e->getCode()]); + } + $this->success('申请售后成功', $res); + } + + + + + + /** + * @ApiTitle( 售后申请取消接口) + * @ApiSummary(售后申请取消(处理中的无法再取消)) + * @ApiMethod(POST) + * @ApiParams(name = "order_no", type = "string",required=true,description = "售后订单id或售后订号") + * @ApiReturn({ + * + *}) + */ + public function cancel(){ + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + $order_no = $this->request->post('order_no/s', ''); //订单号 + try{ + //当前申请状态 + $res = $this->model->cancel($order_no,$user_id,true,'user',0,true); + }catch (\Throwable $e){ + $this->error($e->getMessage()); + } + $this->success('售后申请取消成功', $res); + } + + + + + /** + * @ApiTitle( 我的售后订单列表接口) + * @ApiSummary(我的售后订单列表接口) + * @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 = "状态搜索条件:售后状态:1=待处理,4=处理中,7=已结单,-3=已取消") + * @ApiParams(name = "service_stauts", type = "string",required=false,description = "售后处理状态:1=待机构处理,4=待用户确认,7=售后通过结单,-3=售后驳回结单") + * @ApiParams(name = "sales_type", type = "string",required=false,description = "结单类型:-3=未结单,1=机构驳回,4=用户驳回,7=平台驳回,10=成功退款") + * @ApiParams(name = "classes_lib_id", type = "int",required=false,description = "课程id") + * @ApiParams(name = "classes_order_id", type = "int",required=false,description = "课程订单id") + * @ApiParams(name = "classes_order_detail_id", type = "int",required=false,description = "订单课程id") + * @ApiReturn({ + * + *}) + */ + public function order_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', ''); //搜索关键字 + $service_stauts = $this->request->get('service_stauts/s', ''); //搜索关键字 + $sales_type = $this->request->get('sales_type/s', ''); //搜索关键字 + $classes_order_id = $this->request->get('classes_order_id/s', ''); //搜索关键字 + $classes_order_detail_id = $this->request->get('classes_order_detail_id/s', ''); //搜索关键字 + $classes_lib_id = $this->request->get('classes_lib_id/s', ''); //搜索关键字 +// $type = $this->request->get('type/s', ''); //筛选学员和教练单 + + try{ + //当前申请状态 + $res = $this->model::allList($user_id,$page, $limit,$keywords,$status,$service_stauts,$sales_type,$classes_order_id,$classes_order_detail_id,$classes_lib_id); +// if($user_id =='670153'){ +// file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql()); +// } + }catch (\Exception $e){ + + $this->error($e->getMessage()); + } + $this->success('查询成功', $res); + } + + + /** + * @ApiTitle( 我的售后订单数量接口) + * @ApiSummary(返回售后订单各个数量) + * @ApiMethod(GET) + * @ApiParams(name = "classes_lib_id", type = "int",required=false,description = "课程id") + * @ApiParams(name = "classes_order_id", type = "int",required=false,description = "课程订单id") + * @ApiReturn({ + * + *}) + */ + public function order_count(){ + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + + $classes_lib_id = $this->request->get('classes_lib_id/s', ''); //搜索关键字 + $classes_order_id = $this->request->get('classes_order_id/s', ''); + try{ + $res = $this->model::orderCount($user_id,$classes_order_id,$classes_lib_id); + }catch (\Throwable $e){ + $this->error($e->getMessage()); + } + $this->success('查询成功', $res); + } + + + + + + /** + * @ApiTitle( 我的售后订单记录列表接口) + * @ApiSummary(我的售后订单记录列表接口) + * @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 = "状态搜索条件:售后状态:1=待处理,4=处理中,7=已结单,-3=已取消") + * @ApiParams(name = "service_stauts", type = "string",required=false,description = "售后处理状态:1=待机构处理,4=待用户确认,7=售后通过结单,-3=售后驳回结单") + * @ApiParams(name = "sales_type", type = "string",required=false,description = "结单类型:-3=未结单,1=机构驳回,4=用户驳回,7=平台驳回,10=成功退款") + * @ApiParams(name = "classes_service_order_id", type = "int",required=false,description = "售后订单id") + * @ApiReturn({ + * + *}) + */ + public function order_log_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', ''); //搜索关键字 + $service_stauts = $this->request->get('service_stauts/s', ''); //搜索关键字 + $sales_type = $this->request->get('sales_type/s', ''); //搜索关键字 + $classes_service_order_id = $this->request->get('classes_service_order_id/s', ''); //搜索关键字 +// $type = $this->request->get('type/s', ''); //筛选学员和教练单 + + try{ + //当前申请状态 + $res = ServiceOrderLog::allList($user_id,$page, $limit,$keywords,$status,$service_stauts,$sales_type,$classes_service_order_id); +// if($user_id =='670153'){ +// file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql()); +// } + }catch (\Exception $e){ + $this->error($e->getMessage()); + } + $this->success('查询成功', $res); + } + + +} + diff --git a/application/api/controller/school/Shop.php b/application/api/controller/school/Shop.php index 357c6ce..086d145 100644 --- a/application/api/controller/school/Shop.php +++ b/application/api/controller/school/Shop.php @@ -9,7 +9,7 @@ use app\common\model\dyqc\ManystoreShop; */ class Shop extends Base { - protected $noNeedLogin = ["detail",'people','spec','shop_list']; + protected $noNeedLogin = ["detail",'people','spec','shop_list','auth_info']; protected $noNeedRight = '*'; protected $model = null; @@ -71,6 +71,10 @@ class Shop extends Base * @ApiParams(name = "reverse_idcard_image", type = "string",required=true,description = "法人身份证反面") * @ApiParams(name = "images", type = "string",required=true,description = "机构环境照片(多个逗号拼接)") * @ApiParams(name = "yyzz_images", type = "string",required=true,description = "营业执照照片(多个逗号拼接)") + * @ApiParams(name = "address", type = "string",required=true,description = "店铺地址") + * @ApiParams(name = "address_detail", type = "string",required=true,description = "店铺详细地址") + * @ApiParams(name = "longitude", type = "string",required=true,description = "经度") + * @ApiParams(name = "latitude", type = "string",required=true,description = "纬度") * @ApiReturn({ * *}) @@ -86,6 +90,13 @@ class Shop extends Base $params["images"] = $this->request->post('images/s',''); $params["yyzz_images"] = $this->request->post('yyzz_images/s',''); + $params["address"] = $this->request->post('address/s',''); + $params["address_detail"] = $this->request->post('address_detail/s',''); + $params["longitude"] = $this->request->post('longitude/s',''); + $params["latitude"] = $this->request->post('latitude/s',''); + + + // if(empty($id)){ // $this->error(__('缺少必要参数')); // } @@ -150,9 +161,11 @@ class Shop extends Base * @ApiMethod(GET) */ public function auth_info(){ - + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; try { - $res = ManystoreShop::getAuthInfo($this->auth->id); + $res = ManystoreShop::getAuthInfo($user_id); } catch (\Exception $e){ // Log::log($e->getMessage()); $this->error($e->getMessage(),['errcode'=>$e->getCode()]); diff --git a/application/api/controller/school/UserAuth.php b/application/api/controller/school/UserAuth.php index f34b708..a809556 100644 --- a/application/api/controller/school/UserAuth.php +++ b/application/api/controller/school/UserAuth.php @@ -121,7 +121,7 @@ class UserAuth extends Base $status = $this->request->post('status/d', 0); //搜索关键字 try{ - $res = UserAuth::auth($id,$shop_id,$user_id,$status,'user',$user_id,true); + $res = $this->model::auth($id,$shop_id,$user_id,$status,'user',$user_id,true); }catch (\Throwable $e){ $this->error($e->getMessage()); } diff --git a/application/api/controller/school/worker/HourOrder.php b/application/api/controller/school/worker/HourOrder.php index 0070f5a..0e80aac 100644 --- a/application/api/controller/school/worker/HourOrder.php +++ b/application/api/controller/school/worker/HourOrder.php @@ -269,6 +269,7 @@ class HourOrder extends Base * @ApiParams(name = "classes_lib_id", type = "int",required=false,description = "课程id") * @ApiParams(name = "start_time", type = "string",required=false,description = "按开始时间区间查(传值格式:Y/m/d H:M:S-Y/m/d H:M:S)") * @ApiParams(name = "createtime", type = "string",required=false,description = "按创建时间区间查(传值格式:Y/m/d H:M:S-Y/m/d H:M:S)") + * @ApiParams(name = "time", type = "string",required=false,description = "按开始和结束时间区间查(传值格式:Y/m/d H:M:S-Y/m/d H:M:S)") * @ApiReturn({ * *}) @@ -289,12 +290,13 @@ class HourOrder extends Base $start_time = $this->request->get('start_time/s', ''); //搜索关键字 $createtime = $this->request->get('createtime/s', ''); //搜索关键字 + $time = $this->request->get('time/s', ''); //搜索关键字 // $type = $this->request->get('type/s', ''); //筛选学员和教练单 try{ //当前申请状态 - $res = $this->model::workList($page, $limit,$keywords,$status,$classes_order_id,0,$this->classes_lib_ids,$classes_lib_ids,$start_time,$createtime); + $res = $this->model::workList($page, $limit,$keywords,$status,$classes_order_id,0,$this->classes_lib_ids,$classes_lib_ids,$start_time,$createtime,$time); // var_dump($this->model->getLastSql());die; // if($user_id =='670153'){ // file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql()); diff --git a/application/api/controller/school/worker/ServiceOrder.php b/application/api/controller/school/worker/ServiceOrder.php new file mode 100644 index 0000000..41d1d0e --- /dev/null +++ b/application/api/controller/school/worker/ServiceOrder.php @@ -0,0 +1,178 @@ +model = new OrderModel; + parent::_initialize(); + + //判断登录用户是否是员工 + } + + + /** + * @ApiTitle( 用户售后订单详情) + * @ApiSummary(用户售后订单详情) + * @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 = OrderModel::getDetail($id,$this->classes_lib_ids); + if(!$res)throw new \Exception('您无操作权限!',40003); + } catch (\Exception $e){ +// Log::log($e->getMessage()); + $this->error($e->getMessage(),['errcode'=>$e->getCode()]); + } + $this->success('获取成功', ['detail' => $res]); + } + + + + /** + * @ApiTitle( 用户售后订单列表接口) + * @ApiSummary(用户售后订单列表接口) + * @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 = "状态搜索条件:售后状态:1=待处理,4=处理中,7=已结单,-3=已取消") + * @ApiParams(name = "service_stauts", type = "string",required=false,description = "售后处理状态:1=待机构处理,4=待用户确认,7=售后通过结单,-3=售后驳回结单") + * @ApiParams(name = "sales_type", type = "string",required=false,description = "结单类型:-3=未结单,1=机构驳回,4=用户驳回,7=平台驳回,10=成功退款") + * @ApiParams(name = "classes_lib_id", type = "int",required=false,description = "课程id") + * @ApiParams(name = "classes_order_id", type = "int",required=false,description = "课程订单id") + * @ApiParams(name = "classes_order_detail_id", type = "int",required=false,description = "订单课程id") + * @ApiReturn({ + * + *}) + */ + public function order_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', ''); //搜索关键字 + $service_stauts = $this->request->get('service_stauts/s', ''); //搜索关键字 + $sales_type = $this->request->get('sales_type/s', ''); //搜索关键字 + $classes_order_id = $this->request->get('classes_order_id/s', ''); //搜索关键字 + $classes_order_detail_id = $this->request->get('classes_order_detail_id/s', ''); //搜索关键字 + $classes_lib_id = $this->request->get('classes_lib_id/s', ''); //搜索关键字 +// $type = $this->request->get('type/s', ''); //筛选学员和教练单 + + try{ + //当前申请状态 + $res = $this->model::workList($page, $limit,$keywords,$status,$service_stauts,$sales_type,$classes_order_id,$classes_order_detail_id,$classes_lib_id,$this->classes_lib_ids); +// if($user_id =='670153'){ +// file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql()); +// } + }catch (\Exception $e){ + + $this->error($e->getMessage()); + } + $this->success('查询成功', $res); + } + + + /** + * @ApiTitle( 用户售后订单数量接口) + * @ApiSummary(返回售后订单各个数量) + * @ApiMethod(GET) + * @ApiParams(name = "classes_lib_id", type = "int",required=false,description = "课程id") + * @ApiParams(name = "classes_order_id", type = "int",required=false,description = "课程订单id") + * @ApiReturn({ + * + *}) + */ + public function order_count(){ + $user_id = 0; + $user = $this->auth->getUser();//登录用户 + if($user)$user_id = $user['id']; + + $classes_lib_id = $this->request->get('classes_lib_id/s', ''); //搜索关键字 + $classes_order_id = $this->request->get('classes_order_id/s', ''); + try{ + $res = $this->model::workCount($classes_order_id,$classes_lib_id,$this->classes_lib_ids); + }catch (\Throwable $e){ + $this->error($e->getMessage()); + } + $this->success('查询成功', $res); + } + + + + /** + * @ApiTitle( 售后订单记录列表接口) + * @ApiSummary(售后订单记录列表接口) + * @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 = "状态搜索条件:售后状态:1=待处理,4=处理中,7=已结单,-3=已取消") + * @ApiParams(name = "service_stauts", type = "string",required=false,description = "售后处理状态:1=待机构处理,4=待用户确认,7=售后通过结单,-3=售后驳回结单") + * @ApiParams(name = "sales_type", type = "string",required=false,description = "结单类型:-3=未结单,1=机构驳回,4=用户驳回,7=平台驳回,10=成功退款") + * @ApiParams(name = "classes_service_order_id", type = "int",required=false,description = "售后订单id") + * @ApiReturn({ + * + *}) + */ + public function order_log_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', ''); //搜索关键字 + $service_stauts = $this->request->get('service_stauts/s', ''); //搜索关键字 + $sales_type = $this->request->get('sales_type/s', ''); //搜索关键字 + $classes_service_order_id = $this->request->get('classes_service_order_id/s', ''); //搜索关键字 +// $type = $this->request->get('type/s', ''); //筛选学员和教练单 + + try{ + //当前申请状态 + $res = ServiceOrderLog::workList($page, $limit,$keywords,$status,$service_stauts,$sales_type,$classes_service_order_id,$this->classes_lib_ids); +// if($user_id =='670153'){ +// file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql()); +// } + }catch (\Exception $e){ + $this->error($e->getMessage()); + } + $this->success('查询成功', $res); + } + + +} + diff --git a/application/common.php b/application/common.php index cec1e4e..9570b64 100644 --- a/application/common.php +++ b/application/common.php @@ -578,3 +578,34 @@ if (!function_exists('getDistanceBuilder')) { return "ROUND(6378.138 * 2 * ASIN(SQRT(POW(SIN((". matchLatLng($lat) . " * PI() / 180 - latitude * PI() / 180) / 2), 2) + COS(". matchLatLng($lat). " * PI() / 180) * COS(latitude * PI() / 180) * POW(SIN((". matchLatLng($lng). " * PI() / 180 - longitude * PI() / 180) / 2), 2))) * 1000) AS distance"; } } + + + +/** + * 后端防抖 + */ +if (!function_exists('repeat_filter')) { + function repeat_filter($key = null, $expire = 5) + { + if (!$key) { + $url = request()->baseUrl(); + $ip = request()->ip(); + + $key = md5($url . ':' . $ip); + } + + $hasRedis = config('redis'); + if ($hasRedis) { + $redis = (new \bw\Redis())->getRedis(); + if ($redis->exists($key)) { + throw new \bw\UrlLockException("请等待{$expire}秒再操作"); + } + $redis->setex($key, $expire, time()); // 缓存 五秒 + } else { + if (cache('?' . $key)) { + throw new \bw\UrlLockException("请等待{$expire}秒再操作"); + } + cache($key, time(), $expire); + } + } +} diff --git a/application/common/controller/Api.php b/application/common/controller/Api.php index 357b0c6..3b05fbe 100644 --- a/application/common/controller/Api.php +++ b/application/common/controller/Api.php @@ -3,6 +3,7 @@ namespace app\common\controller; use app\common\library\Auth; +use app\common\library\Virtual; use think\Config; use think\exception\HttpResponseException; use think\exception\ValidateException; @@ -144,6 +145,7 @@ class Api // 加载当前控制器语言包 $this->loadlang($controllername); + Virtual::visitNnmberUpdate(); } /** diff --git a/application/common/hooks.php b/application/common/hooks.php index cc115fd..2856d63 100644 --- a/application/common/hooks.php +++ b/application/common/hooks.php @@ -94,6 +94,17 @@ $classesHooks = [ 'classes_auth_fail_after' => [ // 课程审核失败后 'app\\common\\listener\\classes\\ClassesHook' ], + 'classes_view_after' => [ // 课程触发浏览后 + 'app\\common\\listener\\classes\\ClassesHook' + ], + 'classes_collect_success_after' => [ // 课程收藏后 + 'app\\common\\listener\\classes\\ClassesHook' + ], + 'classes_collect_cancel_after' => [ // 课程取消收藏后 + 'app\\common\\listener\\classes\\ClassesHook' + ], + + ]; @@ -112,6 +123,19 @@ $userHooks = [ ]; +//售后事件钩子 +$serviceHooks = [ + // 订单创建 + 'classes_serviceorder_create_after' => [ // 售后单创建后 + 'app\\common\\listener\\serviceorder\\OrderHook' + ], + + 'classes_serviceorder_cancel_after' => [ // 订单取消后 + 'app\\common\\listener\\serviceorder\\OrderHook' + ], + +]; + // //if (file_exists(ROOT_PATH . 'addons/shopro/listener/commission')) { @@ -121,5 +145,6 @@ $defaultHooks = array_merge_recursive($defaultHooks, $hourHooks); $defaultHooks = array_merge_recursive($defaultHooks, $manystoreHooks); $defaultHooks = array_merge_recursive($defaultHooks, $classesHooks); $defaultHooks = array_merge_recursive($defaultHooks, $userHooks); +$defaultHooks = array_merge_recursive($defaultHooks, $serviceHooks); return $defaultHooks; diff --git a/application/common/library/Virtual.php b/application/common/library/Virtual.php index b9b46f9..3b38d95 100644 --- a/application/common/library/Virtual.php +++ b/application/common/library/Virtual.php @@ -104,4 +104,23 @@ class Virtual } + public static function visitNnmberUpdate(){ + $key = "night_school_total_visit"; + $redis = (new \bw\Redis())->getRedis(); + if (!$redis->exists($key)) { + $redis->set($key, 0); // 缓存 五秒 + } + // 进行累加 + return $redis->incr($key); + } + + public static function getVisitNnmber(){ + $key = "night_school_total_visit"; + $redis = (new \bw\Redis())->getRedis(); + return $redis->get($key); + + } + + + } \ No newline at end of file diff --git a/application/common/listener/classes/ClassesHook.php b/application/common/listener/classes/ClassesHook.php index 86450cd..e2aa40f 100644 --- a/application/common/listener/classes/ClassesHook.php +++ b/application/common/listener/classes/ClassesHook.php @@ -90,4 +90,23 @@ class ClassesHook } + public function classesViewAfter(&$params) + { + ['classes' => $classes,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id] = $params; + + } + + public function classesCollectSuccessAfter(&$params) + { + ['classes' => $classes,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id] = $params; + + } + + public function classesCollectCancelAfter(&$params) + { + ['classes' => $classes,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id] = $params; + + } + + } \ No newline at end of file diff --git a/application/common/listener/classesorder/OrderHook.php b/application/common/listener/classesorder/OrderHook.php index f524e09..92a082f 100644 --- a/application/common/listener/classesorder/OrderHook.php +++ b/application/common/listener/classesorder/OrderHook.php @@ -33,6 +33,7 @@ class OrderHook "event"=>"classes_order_create_after", "order_id"=>$order["id"], "order_no"=>$order["order_no"], + "classes_lib_id"=>$order["classes_lib_id"], ]; Message::$event_name = $params["event"]; 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 82edf23..574c598 100644 --- a/application/common/listener/manystore/ShopHook.php +++ b/application/common/listener/manystore/ShopHook.php @@ -2,6 +2,7 @@ namespace app\common\listener\manystore; use app\common\model\school\classes\ClassesLib; use app\common\model\school\Message; +use app\manystore\model\Manystore; class ShopHook { @@ -82,11 +83,12 @@ class ShopHook { ['shop' => $shop,"password"=>$password] = $params; $user = $shop->user; + $manystore = Manystore::where("shop_id",$shop["id"])->find(); $mobile = $user['mobile'] ?? ""; - $shop_backend_url = config("site.shop_backend_ur"); + $shop_backend_url = config("site.shop_backend_url"); $desc = "您申请的认证:{$shop['name']}已审核通过,您可登录官方后台补充完其余资料,并开始发布课程
      后台地址是: {$shop_backend_url}
      - 账号是: {$shop['username']} 或 您的手机号 {$mobile}
      + 账号是: 您的手机号 {$mobile}
      初始化密码是: {$password}
      "; @@ -99,9 +101,12 @@ class ShopHook $oper_id=0; $oper_type="system"; $params=[ - "event"=>"shop_auth_success_after", - "shop_id"=>$shop["id"], - "desc"=>$shop["desc"], + "event"=>"shop_auth_success_after", + "shop_id"=>$shop["id"], + "desc"=>$shop["desc"], + "username"=>$manystore["username"], + "mobile"=>$mobile, + "password"=>$password, ]; Message::$event_name = $params["event"]; Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type); diff --git a/application/common/listener/serviceorder/OrderHook.php b/application/common/listener/serviceorder/OrderHook.php new file mode 100644 index 0000000..cb9000e --- /dev/null +++ b/application/common/listener/serviceorder/OrderHook.php @@ -0,0 +1,75 @@ + $serverorder,"oper_type"=>$oper_type,"oper_id"=>$oper_id] = $params; + + $detail = $serverorder->detail; + //记录订单日志 + + $desc = "课程{$detail["title"]}订单已申请售后,等待机构处理"; + + $title = "课程订单已提交售后"; + $mini_type = "aftercare"; + $to_type="user"; + $to_id = $serverorder["user_id"]; + $status ="classes"; + $platform="user"; + $oper_id=0; + $oper_type="system"; + $params=[ + "event"=>"classes_serviceorder_create_after", + "order_id"=>$serverorder["id"], + "classes_order_id"=>$serverorder["classes_order_id"], + "order_no"=>$serverorder["order_no"], + ]; + Message::$event_name = $params["event"]; + Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type); + + + } + + + + + + // 订单取消成功后 + public function classesServiceorderCancelAfter(&$params) + { + ['serviceorder' => $serviceorder,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id] = $params; + + $detail = $serviceorder->detail; + //记录订单日志 + + $desc = "课程{$detail["title"]}订单已取消售后,订单恢复原状态"; + + $title = "课程订单已取消售后"; + $mini_type = "aftercare"; + $to_type="user"; + $to_id = $serviceorder["user_id"]; + $status ="classes"; + $platform="user"; + $oper_id=0; + $oper_type="system"; + $params=[ + "event"=>"classes_serviceorder_cancel_after", + "order_id"=>$serviceorder["id"], + "classes_order_id"=>$serviceorder["classes_order_id"], + "order_no"=>$serviceorder["order_no"], + ]; + Message::$event_name = $params["event"]; + 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/user/UserHook.php b/application/common/listener/user/UserHook.php index dd92382..9014aa1 100644 --- a/application/common/listener/user/UserHook.php +++ b/application/common/listener/user/UserHook.php @@ -1,6 +1,8 @@ $user_auth,"oper_type"=>$oper_type,"oper_id"=>$oper_id] = $params; - + $shop = $user_auth->shop; // //课程推送给老师 -// $desc = "您的新课程{$classes['title']}已审核通过,可以在后台操作课程上架!"; -// -// $title = "新课程审核成功"; -// $mini_type = "classes_apply"; -// $to_type="user"; -// $to_id = $classes["user_id"]; -// $status ="classes"; -// $platform="user"; -// $oper_id=0; -// $oper_type="system"; -// $params=[ -// "event"=>"classes_auth_success_after", -// "classes_lib_id"=>$classes["id"], -// ]; -// Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type); + $desc = "机构{$shop['name']}已发起授权申请,请确实是否同意!"; + + $title = "机构授权申请待确认"; + $mini_type = "user_auth"; + $to_type="user"; + $to_id = $user_auth["user_id"]; + $status ="system"; + $platform="user"; + $oper_id=0; + $oper_type="system"; + $params=[ + "event"=>"user_auth_need_after", + "shop_id"=>$user_auth["shop_id"], + ]; + Message::$event_name = $params["event"]; + Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type); } @@ -36,22 +39,40 @@ class UserHook { ['user_auth' => $user_auth,"oper_type"=>$oper_type,"oper_id"=>$oper_id] = $params; + $shop = $user_auth->shop; // //课程推送给老师 -// $desc = "您的新课程{$classes['title']}已审核通过,可以在后台操作课程上架!"; -// -// $title = "新课程审核成功"; -// $mini_type = "classes_apply"; -// $to_type="user"; -// $to_id = $classes["user_id"]; -// $status ="classes"; -// $platform="user"; -// $oper_id=0; -// $oper_type="system"; -// $params=[ -// "event"=>"classes_auth_success_after", -// "classes_lib_id"=>$classes["id"], -// ]; -// Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type); + $desc = "您已同意机构{$shop['name']}发起的授权申请。"; + + $title = "机构授权已确认"; + $mini_type = "user_auth"; + $to_type="user"; + $to_id = $user_auth["user_id"]; + $status ="system"; + $platform="user"; + $oper_id=0; + $oper_type="system"; + $params=[ + "event"=>"user_auth_success_after", + "shop_id"=>$user_auth["shop_id"], + ]; + Message::$event_name = $params["event"]; + Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type); + $manystore = Manystore::where("shop_id",$user_auth["shop_id"])->find(); + if($manystore){ + //加入核销员 + $verification = Verification::where("user_id",$user_auth["user_id"]) + ->where("shop_id",$user_auth["shop_id"]) + ->where("manystore_id",$manystore["id"])->find(); + if(!$verification){ + Verification::create([ + "user_id"=>$user_auth["user_id"], + "shop_id"=>$user_auth["shop_id"], + "manystore_id"=>$manystore["id"], + "status"=>'2', + "classes_lib_ids"=>"", + ]); + } + } } @@ -60,24 +81,24 @@ class UserHook { ['user_auth' => $user_auth,"oper_type"=>$oper_type,"oper_id"=>$oper_id] = $params; -// -// //课程推送给老师 -// $desc = "您的新课程{$classes['title']}审核未通过,未通过原因为:{$classes['reason']},整改后,可以在后台重新提交!"; -// -// $title = "新课程审核不通过"; -// $mini_type = "classes_apply"; -// $to_type="user"; -// $to_id = $classes["user_id"]; -// $status ="classes"; -// $platform="user"; -// $oper_id=0; -// $oper_type="system"; -// $params=[ -// "event"=>"classes_auth_success_after", -// "classes_lib_id"=>$classes["id"], -// ]; -// Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type); + $shop = $user_auth->shop; +// //课程推送给老师 + $desc = "您已拒绝机构{$shop['name']}发起的授权申请。"; + $title = "机构授权已拒绝"; + $mini_type = "user_auth"; + $to_type="user"; + $to_id = $user_auth["user_id"]; + $status ="system"; + $platform="user"; + $oper_id=0; + $oper_type="system"; + $params=[ + "event"=>"user_auth_fail_after", + "shop_id"=>$user_auth["shop_id"], + ]; + Message::$event_name = $params["event"]; + 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 9e77ba2..e7d70c9 100644 --- a/application/common/model/User.php +++ b/application/common/model/User.php @@ -70,7 +70,7 @@ class User extends BaseModel public function getVerificationAttr($value, $data) { $value = array_filter((array)json_decode($value, true)); - $value = array_merge(['email' => 0, 'mobile' => 0, 'mini_wechat' => 0], $value); + $value = array_merge(['email' => 0, 'mobile' => 0, 'wechat_miniapp' => 0], $value); return (object)$value; } diff --git a/application/common/model/dyqc/ManystoreShop.php b/application/common/model/dyqc/ManystoreShop.php index 925f266..8111126 100644 --- a/application/common/model/dyqc/ManystoreShop.php +++ b/application/common/model/dyqc/ManystoreShop.php @@ -294,9 +294,20 @@ class ManystoreShop extends BaseModel 'reverse_idcard_image' => 'require', 'images' => 'require', 'yyzz_images' => 'require', + + + 'address' => 'require', + 'address_detail' => 'require', + 'longitude' => 'require', + 'latitude' => 'require', + ]; $rule_msg = [ + 'address.require' => '机构地址必填', + 'address_detail.require' => '机构详细地址必填', + 'longitude.require' => '经度必填', + 'latitude.require' => '纬度必填', 'name.require' => '机构名称必须填写', 'tel.require' => '服务电话必须填写', 'tel.number' => '服务电话必须是数字', @@ -331,7 +342,14 @@ class ManystoreShop extends BaseModel if(!$shop){ //创建申请单 $shop = $this->creatShop($type,$user_id,$params); + }else{ + //商家表单更新 + $shop_info = $shop->allowField(true)->save($params); + if($shop_info === false){ + throw new \Exception($shop->getError()); + } } + $shop = ManystoreShop::where( 'user_id',$user_id)->find(); //更新申请单状态为审核中 $shop['status']= '0'; //清空审核时间 @@ -501,6 +519,9 @@ public static function getAuthInfo($user_id){ $shop_id = 0; $type = '1'; $reason =""; //失败原因 + $apply_info = null; + if(!$user_id)return compact('auth_status','shop_id','reason','apply_info',"type"); + //得到申请单 $apply_info = self::where("user_id",$user_id)->where("status","1")->find(); if(!$apply_info)$apply_info = self::where("user_id",$user_id)->find(); diff --git a/application/common/model/school/Message.php b/application/common/model/school/Message.php index c127b38..a44c6e3 100644 --- a/application/common/model/school/Message.php +++ b/application/common/model/school/Message.php @@ -31,8 +31,18 @@ class Message extends BaseModel 'to_type_text', 'status_text', 'mini_type_text', - "type_text" + "type_text", + 'createtime_text', ]; + + public function getCreatetimeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['createtime']) ? $data['createtime'] : ''); + return is_numeric($value) ? date("Y.m.d|H:i", $value) : $value; + } + + + public function getTypeList() { return ['1' => __('Type 1'), '2' => __('Type 2')]; @@ -260,7 +270,7 @@ class Message extends BaseModel 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(['createtime',$whereData['time']]); + $model = $model->time(["{$alisa}createtime",$whereData['time']]); } if (isset($whereData['user_id']) && $whereData['user_id']) $model = $model->where("{$alisa}to_id", '=', $whereData['user_id']); @@ -300,7 +310,18 @@ class Message extends BaseModel $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'); + + + $where["type"] = '2'; + $read_number = self::getBaseWhere($where)->count(); + $read_system_number = self::getBaseWhere(array_merge(['status'=>'system'],$where))->count(); + $read_classes_number = self::getBaseWhere(array_merge(['status'=>'classes'],$where))->count(); + $read_order_number = self::getBaseWhere(array_merge(['status'=>'order'],$where))->count(); + + + + return compact('unread_number','unread_system_number','unread_classes_number','unread_order_number', + 'read_number','read_system_number','read_classes_number','read_order_number'); } @@ -310,6 +331,29 @@ class Message extends BaseModel * @return array */ public static function messageCount($user_id = 0){ + + if(!$user_id){ + $unread_number = 0; + $unread_system_number = 0; + $unread_classes_number = 0; + $unread_order_number = 0; + + $read_number = 0; + $read_system_number = 0; + $read_classes_number = 0; + $read_order_number = 0; + + return compact('unread_number', + 'unread_system_number', + 'unread_classes_number', + 'unread_order_number', + 'read_number', + 'read_system_number', + 'read_classes_number', + 'read_order_number' + ); + } + return self::baseCount(['user_id'=>$user_id]); } @@ -336,4 +380,55 @@ class Message extends BaseModel + + + + /**设置一键已读 + * @param $id + * @param int $user_id + * @param bool $check + * @param bool $trans + * @throws \Exception + */ + public static function batchRead($id,$user_id,$status=null,$mini_type=null,$event=null,$oper_type='user',$oper_id=0,$trans=false){ + //匹配已读查询条件 + + $model = self::where("to_id",$user_id); + if($status)$model = $model->where("status","in","".$status); + if($mini_type)$model = $model->where("mini_type","in","".$mini_type); + if($event)$model = $model->where("event","in","".$event); + if($id && $id!="*")$model = $model->where("id","in","".$id); + //判断逻辑 + if($trans){ + self::beginTrans(); + } + + try{ + //事务逻辑 + $ids = $model->column("id"); + //$ids逗号拼接 + $ids = implode(",",$ids); + //合并成数组 + $update_data = ['type'=>'2']; + self::where("id","in",$ids)->update($update_data); + + //调用事件 +// $data = ['classes' => $classes_lib,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id]; +// \think\Hook::listen('classes_view_after', $data); + + if($trans){ + self::commitTrans(); + } + }catch (\Exception $e){ + if($trans){ + self::rollbackTrans(); + } + throw new \Exception($e->getMessage()); + } + return true; + } + + + + } diff --git a/application/common/model/school/classes/ClassesLib.php b/application/common/model/school/classes/ClassesLib.php index 016aadb..5d3b5cb 100644 --- a/application/common/model/school/classes/ClassesLib.php +++ b/application/common/model/school/classes/ClassesLib.php @@ -325,7 +325,7 @@ class ClassesLib extends BaseModel * @return ClassesLib|null * @throws \think\exception\DbException */ - public function detail($id,$user_id=0){ + public function detail($id,$user_id=0,$oper_type='user',$trans=false){ $self = $this->get($id,['shop','teacher']); //是否收藏 @@ -345,11 +345,29 @@ class ClassesLib extends BaseModel //有用户进来,参与人数+1 if(!$self['have_buy'])$self['virtual_people'] = $self['virtual_people'] + 1; } + + $cate_list = Cate::where("status",'1')->column("name","id"); + $label_list = Label::where("status",'1')->column("name","id"); + + $classes_label_ids = $self['classes_label_ids']; + $classes_cate_ids = $self['classes_cate_ids']; + $classes_label = $classes_cate = []; + foreach (explode(",", $classes_label_ids) as $classes_label_id){ + if(isset($label_list[$classes_label_id]))$classes_label[] = $label_list[$classes_label_id]; + } + foreach (explode(",", $classes_cate_ids) as $classes_cate_id){ + if(isset($cate_list[$classes_cate_id]))$classes_cate[] = $cate_list[$classes_cate_id]; + } + $self['classes_label'] = $classes_label; + $self['classes_cate'] = $classes_cate; + + //下架判断 // if($self['status'] != '1'){ // $this->error("该课程已下架"); // } // + $this->setViews($id,$user_id,$oper_type,$user_id,$trans); //参与人数 = 虚拟人数 + 平台人数 @@ -357,6 +375,47 @@ class ClassesLib extends BaseModel } + + /**设置浏览量 + * @param $id + * @param int $user_id + * @param bool $check + * @param bool $trans + * @throws \Exception + */ + public function setViews($id,$user_id,$oper_type='user',$oper_id=0,$trans=false){ + $classes_lib = self::where("id",$id)->find(); + if(!$classes_lib)throw new \Exception("找不到课程!"); + //判断逻辑 + if($trans){ + self::beginTrans(); + } + + try{ + //事务逻辑 + $classes_lib->views = $classes_lib->views + 1; + //查询是否已收藏 + $classes_lib->save(); + + + //调用事件 + $data = ['classes' => $classes_lib,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id]; + \think\Hook::listen('classes_view_after', $data); + + + if($trans){ + self::commitTrans(); + } + }catch (\Exception $e){ + if($trans){ + self::rollbackTrans(); + } + throw new \Exception($e->getMessage()); + } + return $classes_lib; + } + + /**课程参与人员信息 * @param $id * @@ -495,10 +554,17 @@ $user_unpaid_order = $user_paid_order =null; * @param $id * */ - public function spec($id){ + public function spec($id,$user_id=0){ //课程规格 $spec_data = ClassesSpec::where("classes_lib_id",$id)->where("status",'1')->order("weigh desc")->select(); + foreach ($spec_data as &$spec){ + //默认未下单预约 + $spec["user_reservation"] = null; + if($user_id){ + $spec["user_reservation"] = \app\common\model\school\classes\hourorder\Order::where("classes_lib_id",$id)->where("classes_lib_spec_id",$spec['id'])->where("user_id",$user_id)->where("status","in",["0",'-1'])->find(); + } + } return $spec_data; } @@ -510,7 +576,14 @@ $user_unpaid_order = $user_paid_order =null; * @throws \think\exception\DbException */ public function getClassesAuthIds($user_id){ - $classes_lib_ids = Verification::where("user_id",$user_id)->where("status",'1')->column("classes_lib_ids"); +// $classes_lib_ids = Verification::where("user_id",$user_id)->where("status",'1')->column("classes_lib_ids"); + //核销员有核销全部课程权力 + $classes_lib_ids = []; + $shop_id = Verification::where("user_id",$user_id)->where("status",'1')->value("shop_id"); + if($shop_id){ + $classes_libids = ClassesLib::where("shop_id",$shop_id)->column("id"); + if($classes_libids)$classes_lib_ids[] = implode(",", $classes_libids); + } if($classes_lib_ids){ //遍历课程ids foreach ($classes_lib_ids as $classes_lib_id){ @@ -545,7 +618,8 @@ $user_unpaid_order = $user_paid_order =null; - + $cate_list = Cate::where("status",'1')->column("name","id"); + $label_list = Label::where("status",'1')->column("name","id"); // 查询自提点 @@ -706,8 +780,12 @@ $user_unpaid_order = $user_paid_order =null; case "sale": //銷量优先 $selfetch = $selfetch->order("{$a}sale desc,{$a}verification_num desc,{$a}sign_num desc,{$a}recommend desc,{$a}weigh desc"); break; - - + case "views": //浏览量优先 + $selfetch = $selfetch->order("{$a}views desc,{$a}recommend desc,{$a}weigh desc,{$a}verification_num desc,{$a}sale desc"); + break; + case "collect": //收藏量优先 + $selfetch = $selfetch->order("{$a}collect desc,{$a}recommend desc,{$a}weigh desc,{$a}verification_num desc,{$a}sale desc"); + break; default: throw new \Exception("不支持的排序类型"); } @@ -729,6 +807,17 @@ $user_unpaid_order = $user_paid_order =null; if($row->is_collect){ $row["collect"] = Collect::where("user_id",$my_user_id)->find(); } + $classes_label_ids = $row['classes_label_ids']; + $classes_cate_ids = $row['classes_cate_ids']; + $classes_label = $classes_cate = []; + foreach (explode(",", $classes_label_ids) as $classes_label_id){ + if(isset($label_list[$classes_label_id]))$classes_label[] = $label_list[$classes_label_id]; + } + foreach (explode(",", $classes_cate_ids) as $classes_cate_id){ + if(isset($cate_list[$classes_cate_id]))$classes_cate[] = $cate_list[$classes_cate_id]; + } + $row['classes_label'] = $classes_label; + $row['classes_cate'] = $classes_cate; } @@ -748,16 +837,19 @@ $user_unpaid_order = $user_paid_order =null; //如果课程虚拟参与者字段 数量小于 虚拟参与者实际数量 ,则等于虚拟参与者实际数量 $classes_lib->virtual_people = $classes_lib->virtual_people < $virtual_people ? $virtual_people : $classes_lib->virtual_people; - //得到课程所有虚拟报名者数量 - $virtual_num = VirtualUser::where("havetype",'1')->where("classes_lib_id",$classes_lib_id)->count(); - //如果课程虚拟报名者字段 数量小于 虚拟报名者实际数量 ,则等于虚拟报名者实际数量 havetype - $classes_lib->virtual_num = $classes_lib->virtual_num < $virtual_num ? $virtual_num : $classes_lib->virtual_num; +// //得到课程所有虚拟报名者数量 +// $virtual_num = VirtualUser::where("havetype",'1')->where("classes_lib_id",$classes_lib_id)->count(); +// //如果课程虚拟报名者字段 数量小于 虚拟报名者实际数量 ,则等于虚拟报名者实际数量 havetype +// $classes_lib->virtual_num = $classes_lib->virtual_num < $virtual_num ? $virtual_num : $classes_lib->virtual_num; //更新课程信息开始和结束时间信息 //课程开始和结束时间等于所有课时的最早开始和最晚结束时间 $classes_lib->start_time = ClassesSpec::where("classes_lib_id",$classes_lib_id)->min("start_time"); $classes_lib->end_time = ClassesSpec::where("classes_lib_id",$classes_lib_id)->max("end_time"); + //设置课程收藏 + $classes_lib->collect = Collect::where("classes_lib_id",$classes_lib_id)->count(); + $classes_lib->save(); //将课程信息和课时信息同步到所有已下单的订单信息中 @@ -847,11 +939,24 @@ $user_unpaid_order = $user_paid_order =null; $res1 = new Collect(); $res1->allowField(true)->save($where); } + + \app\common\model\school\classes\ClassesLib::update_classes($classes_lib["id"]); + //调用事件 + $data = ['classes' => $classes_lib,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id]; + \think\Hook::listen('classes_collect_success_after', $data); + }else{ //取消收藏 $res1 = Collect::where($where)->delete(); + \app\common\model\school\classes\ClassesLib::update_classes($classes_lib["id"]); + //调用事件 + $data = ['classes' => $classes_lib,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id]; + \think\Hook::listen('classes_collect_cancel_after', $data); + + } + if($trans){ self::commitTrans(); } @@ -877,7 +982,7 @@ $user_unpaid_order = $user_paid_order =null; // 课程存在未完成订单则不允许操作 $order = Order::where("classes_lib_id",$id)->where("status","in","0,3")->find(); - if($order)$this->error("存在正在使用中的课程订单或存在正在售后中的课程订单无法继续操作!"); + if($order)throw new \Exception("存在正在使用中的课程订单或存在正在售后中的课程订单无法继续操作!"); // 课程存在售后订单则不允许操作 } @@ -923,7 +1028,7 @@ $user_unpaid_order = $user_paid_order =null; $params["user_id"] = $teacher["user_id"]; //课时必须大于等于1 - if($params["classes_num"] < 1) throw new \Exception("课时必须大于等于1"); +// if($params["classes_num"] < 1) throw new \Exception("课时必须大于等于1"); if($params["price"] < 0) throw new \Exception("售价必须大于0"); @@ -1019,7 +1124,8 @@ $user_unpaid_order = $user_paid_order =null; foreach ($spec as $k=>&$v){ $v["classes_lib_id"] = $row->id; - (new ClassesSpec)->specCheck($v,$shop_id,empty($v["id"])? null : ClassesSpec::get($v["id"])); + //先不进行判定,交给提交后再判定 + (new ClassesSpec)->specCheck($v,$shop_id,empty($v["id"])? null : ClassesSpec::get($v["id"]),false); } $params["spec"] = $spec; @@ -1056,7 +1162,7 @@ $user_unpaid_order = $user_paid_order =null; $params["spec"] = array_reverse($params["spec"]); $insert_spec = []; foreach ($params["spec"] as $k=>&$v){ - $v["weigh"] = $k; + $v["weigh"] = $k + 1; if(!empty($v["id"]))$insert_spec[] = $v["id"]; } if($insert_spec && $row){ diff --git a/application/common/model/school/classes/ClassesSpec.php b/application/common/model/school/classes/ClassesSpec.php index 6763d32..66016e4 100644 --- a/application/common/model/school/classes/ClassesSpec.php +++ b/application/common/model/school/classes/ClassesSpec.php @@ -42,6 +42,16 @@ class ClassesSpec extends BaseModel }); } + + public function getTimeAttr($value, $data) + { + $start_time = isset($data['start_time']) ? $data['start_time'] : ''; + $end_time = isset($data['end_time']) ? $data['end_time'] : ''; + $start_time = is_numeric($start_time) ? date("Y/m/d H:i", $start_time) : $start_time; + $end_time = is_numeric($end_time) ? date("Y/m/d H:i", $end_time) : $end_time; + return $start_time .' - '.$end_time; + } + public function getStatusList() { @@ -101,7 +111,7 @@ class ClassesSpec extends BaseModel } - public function specCheck(&$params,$shop_id=null,$row=null) + public function specCheck(&$params,$shop_id=null,$row=null,$check=true) { //限定人数必须大于0 @@ -173,7 +183,7 @@ class ClassesSpec extends BaseModel ->where("classes_lib_id",$classes_lib_id) ->where("id","<>",$row->id)->find(); - if($spec_time_exist){ + if($check && $spec_time_exist){ throw new \Exception("该课程下,{$spec_time_exist['name']}课时的开始和结束时间与你有重叠"); } @@ -198,7 +208,7 @@ class ClassesSpec extends BaseModel ->where("classes_lib_id",$classes_lib_id) ->find(); - if($spec_time_exist){ + if($check && $spec_time_exist){ throw new \Exception("该课程下,{$spec_time_exist['name']}课时的开始和结束时间与你有重叠"); } diff --git a/application/common/model/school/classes/hourorder/Order.php b/application/common/model/school/classes/hourorder/Order.php index 8bfee0f..587ac4b 100644 --- a/application/common/model/school/classes/hourorder/Order.php +++ b/application/common/model/school/classes/hourorder/Order.php @@ -188,12 +188,12 @@ class Order extends BaseModel if (isset($whereData['keywords'])&&$whereData['keywords']) $model = $model->where("{$alisa}order_no|{$alisa}id", '=', $whereData['keywords']); if (isset($whereData['createtime'])&&$whereData['createtime']){ - $model = $model->time(["createtime",$whereData['createtime']]); + $model = $model->time(["{$alisa}createtime",$whereData['createtime']]); } if (isset($whereData['start_time'])&&$whereData['start_time']){ - $model = $model->time(["start_time",$whereData['start_time']]); + $model = $model->time(["{$alisa}start_time",$whereData['start_time']]); } if (isset($whereData['user_id']) && $whereData['user_id']) $model = $model->where("{$alisa}user_id", '=', $whereData['user_id']); @@ -201,6 +201,32 @@ class Order extends BaseModel if (isset($whereData['classes_lib_ids']) && $whereData['classes_lib_ids']) $model = $model->where("{$alisa}classes_lib_id", 'in', $whereData['classes_lib_ids']); if (isset($whereData['classes_lib_id']) && $whereData['classes_lib_id']) $model = $model->where("{$alisa}classes_lib_id", 'in', $whereData['classes_lib_id']); + + + if (isset($whereData['time'])&&$whereData['time']){ + + if(strstr($whereData['time'], '---') !== false){ + [$startTime, $endTime] = explode('---', $whereData['time']); + }elseif (strstr($whereData['time'], '-') !== false){ + [$startTime, $endTime] = explode('-', $whereData['time']); + } + $start_time = trim($startTime); + $end_time = trim($endTime); + $start_time = strtotime($startTime); + $end_time = strtotime($endTime); + + + //sudo:此方法必须是时间戳 + $model = $model->where(function ($query) use ($alisa,$start_time,$end_time) { +// if($alisa)$alisa = "`order`."; + //兩個時間區間重合 存在任意交集 都不行 + $query->where("{$alisa}start_time BETWEEN {$start_time} AND {$end_time}"); + $query->whereOr("{$alisa}end_time BETWEEN {$start_time} AND {$end_time}"); + $query->whereOr("{$alisa}start_time <= {$start_time} AND {$alisa}end_time >= {$end_time}"); + $query->whereOr("{$alisa}start_time >= {$start_time} AND {$alisa}end_time <= {$end_time}"); + }); + } + return $model; } @@ -254,7 +280,7 @@ class Order extends BaseModel - public static function allList($user_id,$page, $limit,$keywords,$status,$classes_order_id=0,$classes_lib_id = [],$start_time = null,$createtime = null){ + public static function allList($user_id,$page, $limit,$keywords,$status,$classes_order_id=0,$classes_lib_id = [],$start_time = null,$createtime = null,$time = null){ $with_field = [ 'user'=>['nickname','mobile','avatar','realname'], 'base'=>['*'], @@ -268,7 +294,7 @@ class Order extends BaseModel $FINISH = '3'; $alisa = (new self)->getWithAlisaName(); $sort = "field({$alisa}.status,'{$NOAUDIT}','{$HAVE}','{$FINISH}','{$CANCEL}') asc,{$alisa}.id desc"; - $serch_where = ['status'=>$status,'user_id'=>$user_id,'keywords'=>$keywords,'classes_order_id'=>$classes_order_id,'classes_lib_id'=>$classes_lib_id,"start_time"=>$start_time,"createtime"=>$createtime]; + $serch_where = ['status'=>$status,'user_id'=>$user_id,'keywords'=>$keywords,'classes_order_id'=>$classes_order_id,'classes_lib_id'=>$classes_lib_id,"start_time"=>$start_time,"createtime"=>$createtime,"time"=>$time]; // if($type)$serch_where['type'] = $type; return (new self)->getBaseList($serch_where, $page, $limit,$sort,$with_field); } @@ -312,7 +338,7 @@ class Order extends BaseModel - public static function workList($page, $limit,$keywords,$status,$classes_order_id=0,$user_id=0,$classes_lib_id = [],$classes_lib_ids = [],$start_time = null,$createtime = null){ + public static function workList($page, $limit,$keywords,$status,$classes_order_id=0,$user_id=0,$classes_lib_id = [],$classes_lib_ids = [],$start_time = null,$createtime = null,$time=null){ $with_field = [ 'user'=>['nickname','mobile','avatar','realname'], 'base'=>['*'], @@ -326,7 +352,7 @@ class Order extends BaseModel $FINISH = '3'; $alisa = (new self)->getWithAlisaName(); $sort = "field({$alisa}.status,'{$NOAUDIT}','{$HAVE}','{$FINISH}','{$CANCEL}') asc,{$alisa}.id desc"; - $serch_where = ['status'=>$status,'user_id'=>$user_id,'keywords'=>$keywords,'classes_order_id'=>$classes_order_id,"classes_lib_id"=>$classes_lib_id,"classes_lib_ids"=>$classes_lib_ids,"start_time"=>$start_time,"createtime"=>$createtime]; + $serch_where = ['status'=>$status,'user_id'=>$user_id,'keywords'=>$keywords,'classes_order_id'=>$classes_order_id,"classes_lib_id"=>$classes_lib_id,"classes_lib_ids"=>$classes_lib_ids,"start_time"=>$start_time,"createtime"=>$createtime,"time"=>$time]; // if($type)$serch_where['type'] = $type; return (new self)->getBaseList($serch_where, $page, $limit,$sort,$with_field); } @@ -949,6 +975,59 @@ class Order extends BaseModel } + + + public static function checkOnlyone($user_id,$classes_lib_info,$check=false){ + $as = (new self)->getWithAlisaName(); + //配置 + $onlyone_check = config("site.free_classes_onlyone_check"); + if(!$onlyone_check)return true; + + //同个免费课只能只能买一次 + $order_count = \app\common\model\school\classes\order\Order::with("detail")->where("{$as}.status",'not in',["-3"]) + ->where("detail.feel",'1') + ->where("{$as}.user_id",$user_id) + ->where("{$as}.classes_lib_id" ,'=',$classes_lib_info["id"]) + ->count(); + //已达到进入黑名单条件 + if($check && $order_count){ + throw new \Exception("您已有正在进行的同类型免费课程,无需重复报名!"); + + } + + + //免费课开始和结束时间有交叠无法下预约 + if(!config("site.free_time_overlap_check")){ + //如果是免费课 + $specs = $classes_lib_info->specs; + foreach ($specs as $classes_lib_spec_info){ + //判断时间是否有交叠 + $start_time = $classes_lib_spec_info['start_time']; + $end_time = $classes_lib_spec_info['end_time']; + + $as = (new self)->getWithAlisaName(); + //判断时间是否有交叠(只查所有的免费的预约记录) + $order_info = self::with("detail")->where("detail.price",0) + ->where("{$as}.status","in",["-1","0"]) + ->where(function ($query) use ($as,$start_time,$end_time) { + //兩個時間區間重合 存在任意交集 都不行 + $query->where("{$as}.start_time BETWEEN {$start_time} AND {$end_time}"); + $query->whereOr("{$as}.end_time BETWEEN {$start_time} AND {$end_time}"); + $query->whereOr("{$as}.start_time <= {$start_time} AND {$as}.end_time >= {$end_time}"); + $query->whereOr("{$as}.start_time >= {$start_time} AND {$as}.end_time <= {$end_time}"); + }) + ->where("{$as}.user_id",$user_id)->find(); + if($order_info) throw new \Exception("当前课程的上课时间区间内,您已预约免费课程{$order_info['detail']['title']},无法再下单其他免费课程"); + + } + + + } + + + } + + //执行免费课黑名单判断 public static function checkBlackList($user_id,$check=false){ $as = (new self)->getWithAlisaName(); @@ -1021,6 +1100,10 @@ class Order extends BaseModel case 'shop': $admin_info = Manystore::where('id',$oper_id)->find(); if(!$admin_info) throw new \Exception("代下单管理员不存在!"); + $classes_lib_ids = ClassesLib::where("manystore_id",$oper_id)->column("id"); + //判断当前订单课程是否在此课程授权范围内 + if(!in_array($classesOrder["classes_lib_id"],$classes_lib_ids)) throw new \Exception("该课程不在您的授权范围内,无法代操作!"); + break; default: throw new \Exception("请选择正确的代下单类型!"); @@ -1340,4 +1423,63 @@ class Order extends BaseModel + public static function getMonthByTime($time,$user_id=null,$status="-1,0"){ + $statistics_data_time = $time; + if(!$statistics_data_time)throw new \Exception("请输入时间!"); + //如果不是时间戳先格式 + if(!is_numeric($statistics_data_time)){ + $statistics_data_time = strtotime($statistics_data_time); + } + + if($statistics_data_time){ + //得到开始和结束时间 + $start_time = strtotime(date( 'Y-m-1 00:00:00', $statistics_data_time )); + $end_time = strtotime('+1 month', $start_time) -1; + } + + //得到$start_time 到 $end_time 时间戳的所有天 + $days = []; + for($i = $start_time; $i <= $end_time; $i += 86400){ + $day = []; + //得到$date当前是周几 + //需处理周日为7 + $day["week"] = date('w',$i)==0? '7' :date('w',$i); + $day["day"] = date('d',$i); + $day["month"] = date('m',$i); + $day["year"] = date('Y',$i); + //得到$date的开始和结束时间 + $day["start_time"] = strtotime(date('Y-m-d 00:00:00',$i)); + $day["end_time"] = strtotime(date('Y-m-d 23:59:59',$i)); + $day["field"] = "day".$day["day"]; + $week_field = $day['week']; + $day["title"] = $day["day"]."号"."-周{$week_field}"; + $day["check"] = false; + if($statistics_data_time >= $day["start_time"] && $statistics_data_time <= $day["end_time"]){ + $day["check"] = true; + } + $days[] = $day; + } + $as = ""; + foreach ($days as $i=>&$day){ + $start_time =$day["start_time"]; + $end_time = $day["end_time"]; + //查询用户在开始和结束事件内的预约 + $model = new self; + if($user_id)$model = $model->where($as.'user_id',$user_id); + $model = $model->where($as.'status',"in",$status); + $day["hour_order_ids"] = $model->where(function ($query) use ($as,$start_time,$end_time) { + //兩個時間區間重合 存在任意交集 都不行 + $query->where("{$as}start_time BETWEEN {$start_time} AND {$end_time}"); + $query->whereOr("{$as}end_time BETWEEN {$start_time} AND {$end_time}"); + $query->whereOr("{$as}start_time <= {$start_time} AND {$as}end_time >= {$end_time}"); + $query->whereOr("{$as}start_time >= {$start_time} AND {$as}end_time <= {$end_time}"); + })->column("{$as}id"); + $day["number"] = count($day["hour_order_ids"]); + } + return $days; + } + + + + } diff --git a/application/common/model/school/classes/order/Order.php b/application/common/model/school/classes/order/Order.php index 97b3da5..d168e42 100644 --- a/application/common/model/school/classes/order/Order.php +++ b/application/common/model/school/classes/order/Order.php @@ -7,6 +7,7 @@ use app\admin\model\Admin; use app\common\model\BaseModel; use app\common\model\dyqc\ManystoreShop; use app\common\model\school\classes\ClassesLib; +use app\common\model\school\classes\ClassesSpec; use app\common\model\User; use bw\Common; use fast\Random; @@ -54,7 +55,7 @@ class Order extends BaseModel public function getStatusList() { - return ['-3' => __('Status -3'), '0' => __('Status 0'), '3' => __('Status 3'), '6' => __('Status 6'), '9' => __('Status 9')]; + return ['-3' => __('Status -3'), '0' => __('Status 0'), '3' => __('Status 3'),'4' => __('Status 4'), '6' => __('Status 6'), '9' => __('Status 9')]; } public function getBeforeStatusList() @@ -196,6 +197,15 @@ class Order extends BaseModel return $this->belongsTo('app\admin\model\Admin', 'admin_id', 'id', [], 'LEFT')->setEagerlyType(0); } + + + public function serviceorder() + { + return $this->belongsTo(ServiceOrder::class, 'classes_service_order_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function getCodeimageAttr($value, $data) { if (!empty($value)) return cdnurl($value, true); @@ -283,6 +293,9 @@ class Order extends BaseModel $data->user->visible(['id','nickname','mobile','avatar','realname']); //订单机构 $data->shop; + //售后单信息 + $data->serviceorder; + // //得到二维码 // $data->code_url = Common::getQrcode([ // 'text' => $data['code'], @@ -414,6 +427,7 @@ class Order extends BaseModel $data = ['order' => $res1]; \think\Hook::listen('classes_order_create_after', $data); + //更新订单数据 self::statisticsAndUpdateClassesNumber($res1); @@ -454,6 +468,11 @@ class Order extends BaseModel if($classes_lib_info && $classes_lib_info['feel']=='1'){ \app\common\model\school\classes\hourorder\Order::checkBlackList($user_id,true); } + //免费课才进行判断(同個免費單只能买一次) + if($classes_lib_info && $classes_lib_info['feel']=='1'){ + \app\common\model\school\classes\hourorder\Order::checkOnlyone($user_id,$classes_lib_info,true); + } + //用户存不存在 $user_info = User::where('id',$user_id)->find(); @@ -496,9 +515,15 @@ class Order extends BaseModel $order_data["totalprice"] = $classes_lib_info["price"]; $order_data["payprice"] = $classes_lib_info["price"]; $order_data["status"] = '0'; + $order_type = "multiple"; + //如果课程只存在一个规格,则订单类型为单课 + $classes_spec_count = ClassesSpec::where('classes_lib_id',$classes_lib_id)->count(); + if($classes_spec_count==1){ + $order_type = "single"; + } - return compact('order_data','classes_lib_info','user_data'); + return compact('order_data','classes_lib_info','user_data','order_type'); } @@ -661,6 +686,9 @@ class Order extends BaseModel //事务逻辑 //不拆分订单,直接执行 self::paySetData($order,$notify); + + //如果是免费单且是单规格 + if($trans){ self::commitTrans(); } @@ -711,6 +739,8 @@ class Order extends BaseModel $order->payprice = $notify['pay_fee'] ?? $order->totalprice; } $order->platform = $notify['platform'] ?? 'miniapp'; + $order->sub_refundprice = $order->payprice; //剩余未退 = 支付金额 + $order->save(); return $order; } @@ -898,6 +928,12 @@ class Order extends BaseModel //更新已用课程金额和剩余课程金额 $detail->used_price = bcmul($detail->unit_price , $detail->use_num,2); $detail->save(); + + //得到所有售后单的已退金额 + $order->real_refundprice = ServiceOrder::where("classes_order_id" , $order["id"])->where("status","in",['7'])->where("sales_type","in",['10'])->sum("real_refundprice"); + //实际付款额 - 已退金额 = 剩余未退 + //更新剩余未退 + $order->sub_refundprice = bcsub($order->payprice,$order->real_refundprice,2); //更新订单应退金额 $order->total_refundprice = bcsub($order->totalprice,$detail->used_price,2); $order->save(); diff --git a/application/common/model/school/classes/order/OrderLog.php b/application/common/model/school/classes/order/OrderLog.php index c912f0f..62dc70d 100644 --- a/application/common/model/school/classes/order/OrderLog.php +++ b/application/common/model/school/classes/order/OrderLog.php @@ -36,7 +36,7 @@ class OrderLog extends BaseModel public function getStatusList() { - return ['-3' => __('Status -3'), '0' => __('Status 0'), '3' => __('Status 3'), '6' => __('Status 6'), '9' => __('Status 9')]; + return ['-3' => __('Status -3'), '0' => __('Status 0'), '3' => __('Status 3'),'4' => __('Status 4'), '6' => __('Status 6'), '9' => __('Status 9')]; } public function getBeforeStatusList() diff --git a/application/common/model/school/classes/order/ServiceOrder.php b/application/common/model/school/classes/order/ServiceOrder.php new file mode 100644 index 0000000..a1da81e --- /dev/null +++ b/application/common/model/school/classes/order/ServiceOrder.php @@ -0,0 +1,827 @@ + __('Status 1'), '4' => __('Status 4'), '7' => __('Status 7'), '-3' => __('Status -3')]; + } + + public function getServiceStautsList() + { + return ['1' => __('Service_stauts 1'), '4' => __('Service_stauts 4'), '7' => __('Service_stauts 7'), '-3' => __('Service_stauts -3')]; + } + + public function getSalesTypeList() + { + return ['-3' => __('Sales_type -3'), '1' => __('Sales_type 1'), '4' => __('Sales_type 4'), '7' => __('Sales_type 7'), '10' => __('Sales_type 10')]; + } + + public function getPlatformList() + { + return ['miniapp' => __('Platform miniapp')]; + } + + public function getPayTypeList() + { + return ['yue' => __('Pay_type yue'), 'wechat' => __('Pay_type wechat')]; + } + + + public function getStatusTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['status']) ? $data['status'] : ''); + $list = $this->getStatusList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getServiceStautsTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['service_stauts']) ? $data['service_stauts'] : ''); + $list = $this->getServiceStautsList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getSalesTypeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['sales_type']) ? $data['sales_type'] : ''); + $list = $this->getSalesTypeList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getPlatformTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['platform']) ? $data['platform'] : ''); + $list = $this->getPlatformList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getPayTypeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['pay_type']) ? $data['pay_type'] : ''); + $list = $this->getPayTypeList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getRefundtimeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['refundtime']) ? $data['refundtime'] : ''); + return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; + } + + + public function getRejecttimeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['rejecttime']) ? $data['rejecttime'] : ''); + return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; + } + + + public function getHandletimeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['handletime']) ? $data['handletime'] : ''); + return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; + } + + + public function getConfirmtimeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['confirmtime']) ? $data['confirmtime'] : ''); + return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; + } + + + public function getCheckouttimeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['checkouttime']) ? $data['checkouttime'] : ''); + return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; + } + + protected function setRefundtimeAttr($value) + { + return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); + } + + protected function setRejecttimeAttr($value) + { + return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); + } + + protected function setHandletimeAttr($value) + { + return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); + } + + protected function setConfirmtimeAttr($value) + { + return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); + } + + protected function setCheckouttimeAttr($value) + { + return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); + } + + + public function classesorder() + { + return $this->belongsTo(Order::class, 'classes_order_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function user() + { + return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function detail() + { + return $this->belongsTo(OrderDetail::class, 'classes_order_detail_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function lib() + { + return $this->belongsTo(ClassesLib::class, 'classes_lib_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function manystore() + { + return $this->belongsTo(Manystore::class, 'manystore_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function shop() + { + return $this->belongsTo(ManystoreShop::class, 'shop_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + /**发起售后 + * @param $params + * @param bool $trans + * @throws \Exception + */ + public function afterSales($classes_order,$reason,$mark='更新订单状态',$oper_type='user',$oper_id = 0,$trans=false){ +// var_dump($order); + if(is_numeric($classes_order)||is_string($classes_order))$classes_order = Order::where('order_no|id',$classes_order)->find(); + + + if(!$classes_order)throw new \Exception("找不到订单"); + //操作人信息(可扩展) + $data = [ + 'oper_type'=>$oper_type ?: 'user', + 'oper_id'=>$oper_id ?: $classes_order['user_id'], + 'log_text'=>$mark, + ]; + //判断逻辑 + if($trans){ + self::beginTrans(); + } + $res = true; + try{ + //事务逻辑 + $order = $this->createOrder($classes_order,$reason,$mark,$oper_type,$oper_id); + if($trans){ + self::commitTrans(); + } + }catch (\Exception $e){ + if($trans){ + self::rollbackTrans(); + } + throw new \Exception($e->getMessage()); + } + return $order; + } + + + + public static function getCost($order_no,$classes_order,$reason,$param=[],$check = false){ + if(is_numeric($classes_order)||is_string($classes_order))$classes_order = Order::where('order_no|id',$classes_order)->find(); + //先更新订单为最新订单 + Order::statisticsAndUpdateClassesNumber($classes_order->id); + + //代下单时将下单人修正成课程下单人,不影响后续判断 + $user_id = $classes_order["user_id"]; + + if(isset($param["help_user_id"]) && $param["help_user_id"]){ + + + } + + + + //校验订单参数 + + $detail = $classes_order->detail; + $classes_lib_info = $detail; + + + //用户 + $user_info = User::get($user_id); + $user_data = [ + "nickname"=>$user_info["nickname"], + "realname"=>$user_info["realname"], + "avatar"=>$user_info["avatar"], + "mobile"=>$user_info["mobile"], + "money" =>$user_info["money"], + "score" =>$user_info["score"], + ]; + + //组装订单下单数据 + $order_data = []; + $order_data["order_no"] = $order_no; + $order_data["user_id"] = $user_id; + $order_data["classes_order_id"] = $classes_order["id"]; + $order_data["classes_order_detail_id"] = $detail["id"]; + $order_data["classes_lib_id"] = $detail["classes_lib_id"]; + $order_data["manystore_id"] = $detail["manystore_id"]; + $order_data["shop_id"] = $detail["shop_id"]; + $order_data["status"] = '1'; + $order_data["service_stauts"] = '1'; + $order_data["sales_type"] = '-3'; + $order_data["platform"] = $classes_order["platform"]; + $order_data["pay_type"] = $classes_order["pay_type"]; + $order_data["reason"] = $reason; + + //计算退款金额 + //得到租户端配置 + $manystore_config = ManystoreConfig::manystore_config($detail["shop_id"]); + $loss_ratio = $manystore_config["loss_ratio"]; + //修正比例:大于100则等于100,小于0则等于0 + $loss_ratio = $loss_ratio > 100 ? 100 : $loss_ratio; + $loss_ratio = $loss_ratio < 0 ? 0 : $loss_ratio; + $order_data["loss_proportion"] = $loss_ratio; + //自动计算应退全额: + // (课程单价 减去 (课程单价乘以课程损耗比) )等于 每个课时应退金额 + //损耗单价 + $unit_loss_price = bcdiv(bcmul($detail["unit_price"],$loss_ratio,2), 100,2); + //修复误差小于0 + $unit_loss_price = $unit_loss_price < 0 ? 0 : $unit_loss_price; + //损耗后单价 + $unit_sub_loss_price = bcsub($detail["unit_price"],$unit_loss_price,2); + //修复误差小于0 + $unit_sub_loss_price = $unit_sub_loss_price < 0 ? 0 : $unit_sub_loss_price; + //剩余课时数 + $sub_num = $detail["sub_num"]; + + //用bc系列函数计算(小数取两位): 剩余课时数 * 每个课时应退金额 = 课程应退金额 + $order_data["auto_recommend_price"] = bcmul($sub_num,$unit_sub_loss_price,2); + //修复误差:如果金额大于剩余未退金额,则取剩余未退金额 + $order_data["auto_recommend_price"] = $order_data["auto_recommend_price"] > $classes_order["sub_refundprice"] ? $classes_order["sub_refundprice"] : $order_data["auto_recommend_price"]; + //用bc系列函数计算(小数取两位):剩余课时数 * 每个课时单价 = 课程应退全额 + $order_data["auto_price"] = bcmul($sub_num,$detail["unit_price"],2); + //修复误差:如果金额大于剩余未退金额,则取剩余未退金额 + $order_data["auto_price"] = $order_data["auto_price"] > $classes_order["sub_refundprice"] ? $classes_order["sub_refundprice"] : $order_data["auto_price"]; + + //用bc系列函数计算(小数取两位):(课程单价乘以课程损耗比)* 剩余课时数 等于 每个课时应退金额 + $order_data["auto_loss_price"] = bcmul($sub_num,$unit_loss_price,2); + $order_data["auto_loss_unit_price"] = $unit_loss_price; + $order_data["sub_refundprice"] = $classes_order["sub_refundprice"]; + + + $classes_order_data = [ + 'before_status'=>$classes_order["status"], + 'status' => "4", + 'server_status' => '3', + 'reason' => $reason, + 'classes_service_order_id'=>0, + ]; + + return compact('order_data','classes_lib_info','user_data','classes_order_data'); + } + + + + + + public function createOrder($classes_order,$reason,$mark='更新订单状态',$oper_type='user',$oper_id = 0){ + if(is_numeric($classes_order)||is_string($classes_order))$classes_order = Order::where('order_no|id',$classes_order)->find(); + + $order_no = get_order_sn(); + $this->orderVaild($order_no,$classes_order,$reason,$oper_type,$oper_id,[],true); + //订单创建信息 + $order_info = self::getCost($order_no,$classes_order,$reason,[],true); + + //组装订单数据 + $order_data = $order_info["order_data"]; + $classes_order_data = $order_info["classes_order_data"]; + + + //创建售后单 + $serverorder = self::create($order_data); + $classes_order_data["classes_service_order_id"] = $serverorder["id"]; + //更新课程订单 + $classes_order->allowField(true)->save($classes_order_data); + //记录订单日志 + ServiceOrderLog::log($classes_order['id'],$mark ?:"售后单申请已提交,等待商家处理",$oper_type,$oper_id); + //7事件 + $data = ['serviceorder' => $serverorder,"oper_type"=>$oper_type,"oper_id"=>$oper_id]; + \think\Hook::listen('classes_serviceorder_create_after', $data); + + + + return self::showInfo($order_no); + } + + + + /**展示订单信息 + * @param $order_no + * @param $price_info + * @return array + */ + public static function showInfo($order_no, $price_info = []){ + $data = []; + $data['order_no'] =$order_no; + $data['order_info'] = self::getDetail($order_no); + return array_merge($data,$price_info); + } + + + + + /**得到订单详情 + * @param $order_no + */ + public static function getDetail($order_no,$classes_lib_id = []){ + $model = self::where('order_no|id',$order_no); + if($classes_lib_id)$model = $model->where("classes_lib_id","in",$classes_lib_id); + $data = $model->find(); + + if(!$data) return $data; + //加载订单详情 + $data->detail->teacher; + //订单用户 +// $data->user; + $data->user->visible(['id','nickname','mobile','avatar','realname']); + //订单机构 + $data->shop; +// //得到二维码 +// $data->code_url = Common::getQrcode([ +// 'text' => $data['code'], +// 'size' => 200, +// ]); +// $data->one_code_url = Common::getBarcode([ +// 'text' => $data['code'], +// 'size' => 200, +// ]); + + return $data; + } + + + + + + + + + /**订单校验 + * @param $user_id 用户id + * @param $classes_lib_id 课程id + * @param $order_no 订单号 + * @param $param 表单扩展参数 + * @return bool + */ + public function orderVaild($order_no,$classes_order,$reason,$oper_type='user',$oper_id = 0,$params=[],$check=false){ + if(is_numeric($classes_order)||is_string($classes_order))$classes_order = Order::where('order_no|id',$classes_order)->find(); + + if(!$classes_order||!$reason )throw new \Exception("缺少必要参数"); + + //默认校验订单是否已创建 + if($check){ + //判断订单是否已创建 + $order_info = self::where(['order_no'=>$order_no])->find(); + if($order_info) throw new \Exception("订单已生成,如需重新下单请退出页面重新进入!"); + } + $user_id = $classes_order["user_id"]; + //校验订单参数 + //操作人权限验证 + self::checkOptionAuth($classes_order["id"],$oper_id ?:$user_id,$oper_type); + + //免费单无法申请售后 + if($classes_order["payprice"]==0 && $classes_order["totalprice"] == 0 ) throw new \Exception("免费课程无法申请售后!"); + + //只有使用中的订单可以申请售后 + if($classes_order["status"] != '3' ) throw new \Exception("该订单当前状态无法申请售后!"); + + //存在售后中的订单 + $count = self::where( 'classes_order_id',$classes_order["id"])->where("status","not in","7,-3")->count(); + if($count > 0) throw new \Exception("该订单已存在正在进行中的售后单,请等待售后处理!"); + + + //用户存不存在 + $user_info = User::where('id',$user_id)->find(); + if(!$user_info) throw new \Exception("用户不存在!"); + + return true; + } + + + /** 课程售后操作权限检测 + * @param $order 订单 + * @param $oper_id 操作人id + * @param $oper_type 操作人类型:user-用户或员工,admin-管理员 + * @return void + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\ModelNotFoundException + * @throws \think\exception\DbException + */ + public static function checkOptionAuth($classes_order_id,$oper_id,$oper_type){ + + //课程是否存在并上架 + $classesOrder = \app\common\model\school\classes\order\Order::where("id",$classes_order_id)->find(); + if(!$classesOrder)throw new \Exception("订单不存在!"); + + switch ($oper_type) { + case 'user': + //自己或操作员 + if($oper_id != $classesOrder["user_id"]){ + //说明是操作员 + $help_user_info = User::where('id',$oper_id)->find(); + if(!$help_user_info) throw new \Exception("代下单员工不存在!"); + $classes_lib_ids = (new ClassesLib)->getClassesAuthIds($oper_id); + //判断当前订单课程是否在此课程授权范围内 + if(!in_array($classesOrder["classes_lib_id"],$classes_lib_ids)) throw new \Exception("该课程不在您的授权范围内,无法代操作!"); + } + break; + case 'admin': + $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("代下单管理员不存在!"); + $classes_lib_ids = ClassesLib::where("manystore_id",$oper_id)->column("id"); + //判断当前订单课程是否在此课程授权范围内 + if(!in_array($classesOrder["classes_lib_id"],$classes_lib_ids)) throw new \Exception("该课程不在您的授权范围内,无法代操作!"); + + break; + default: + throw new \Exception("请选择正确的代下单类型!"); + } + + + } + + + /**得到可取消订单 + * @param $order_no + * @return array|false|\PDOStatement|string|Model + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\ModelNotFoundException + * @throws \think\exception\DbException + */ + public static function getHaveCancelOrder($order_no){ +// $where = [self::STATUS_NOPAY,self::STATUS_PAYED]; + $order = self::where('order_no|id',$order_no) + ->where("status","in",['1']) + ->find(); + if(!$order)throw new \Exception("只有待处理售后单可取消!"); + + return $order; + } + + /**更新订单取消状态 + * @param $order + * @return array|false|\PDOStatement|string|Model + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\ModelNotFoundException + * @throws \think\exception\DbException + */ + public static function updateCancel($order){ + if(is_string($order))$order = self::getHaveCancelOrder($order); + $order->status = "-3";//refund_status + $order->canceltime = time(); + $order->save(); + return $order; + } + + + /**更新课程订单还原原状态 + * @param $order + * @return array|false|\PDOStatement|string|Model + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\ModelNotFoundException + * @throws \think\exception\DbException + */ + public static function orderRestore($classes_order){ + if(is_numeric($classes_order)||is_string($classes_order))$classes_order = Order::where('order_no|id',$classes_order)->find(); + $classes_order->status = $classes_order->before_status;//refund_status + $classes_order->before_status = '0'; + $classes_order->server_status = '0';//refund_status + $classes_order->reason = ''; + $classes_order->classes_service_order_id = 0; + $classes_order->save(); + return $classes_order; + } + + + /**订单取消 + * @param $order_no + * @param int $user_id + * @param bool $check + * @param bool $trans + * @return bool + * @throws \Exception + */ + public function cancel($order_no,$user_id=0,$check=false,$oper_type='user',$oper_id=0,$trans=false){ + //得到可取消订单 + $order = self::getHaveCancelOrder($order_no); + if($check){ + //用户操作权限检测 + \app\common\model\school\classes\hourorder\Order::checkOptionAuth($order['id'],$user_id ?: $oper_id,$oper_type); + } + + + //判断逻辑 + if($trans){ + self::beginTrans(); + } + $res = true; + try{ + //事务逻辑 + //更新售后为取消状态 + $order = self::updateCancel($order); + //还原课程订单 + self::orderRestore($order["classes_order_id"]); + //插入订单取消日志 + if(!$user_id ||$order["user_id"] !=$user_id ){ + ServiceOrderLog::log($order['id'],"[系统操作]课程订单已取消售后",$oper_type ?: 'user', $oper_id ?: $order['user_id']); + }else{ + ServiceOrderLog::log($order['id'],"课程订单已取消售后",$oper_type ?: 'user', $oper_id ?: $order['user_id']); + } + + //调用订单取消事件 + $data = ['serviceorder' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id]; + \think\Hook::listen('classes_serviceorder_cancel_after', $data); + //执行课时数更新 + $res1 = order::statisticsAndUpdateClassesNumber($order['classes_order_id']); + + + if($trans){ + self::commitTrans(); + } + }catch (\Exception $e){ + if($trans){ + self::rollbackTrans(); + } + throw new \Exception($e->getMessage()); + } + return $res1; + } + + + + + + /**得到基础条件 + * @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, ['status',"service_stauts","sales_type",'classes_lib_id','classes_order_id','user_id','classes_order_detail_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['service_stauts'])) $model = $model->where("{$alisa}service_stauts", 'in', $whereData['service_stauts']); + if (isset($whereData['sales_type'])) $model = $model->where("{$alisa}sales_type", 'in', $whereData['sales_type']); + + if (isset($whereData['not_status'])) $model = $model->where("{$alisa}status", 'not in', $whereData['not_status']); + if (isset($whereData['keywords'])&&$whereData['keywords']) $model = $model->where("{$alisa}order_no|{$alisa}id|{$alisa}reason", '=', $whereData['keywords']); + if (isset($whereData['time'])&&$whereData['time']){ + + $model = $model->time(["{$alisa}createtime",$whereData['time']]); + } + if (isset($whereData['user_id']) && $whereData['user_id']) $model = $model->where("{$alisa}user_id", '=', $whereData['user_id']); + + + if (isset($whereData['classes_order_id']) && $whereData['classes_order_id']) $model = $model->where("{$alisa}classes_order_id", 'in', $whereData['classes_order_id']); + + //classes_order_detail_id + + if (isset($whereData['classes_order_detail_id']) && $whereData['classes_order_detail_id']) $model = $model->where("{$alisa}classes_order_detail_id", 'in', $whereData['classes_order_detail_id']); + + + if (isset($whereData['classes_lib_ids']) && $whereData['classes_lib_ids']) $model = $model->where("{$alisa}classes_lib_id", 'in', $whereData['classes_lib_ids']); + if (isset($whereData['classes_lib_id']) && $whereData['classes_lib_id']) $model = $model->where("{$alisa}classes_lib_id", 'in', $whereData['classes_lib_id']); + + return $model; + } + + + + + + + public static function allList($user_id,$page, $limit,$keywords,$status,$service_stauts,$sales_type,$classes_order_id=[],$classes_order_detail_id=[],$classes_lib_id=[]){ + $with_field = [ + 'user'=>['nickname','mobile','avatar','realname'], + 'base'=>['*'], + 'classesorder'=>['*'], + 'detail'=>['*'], + ]; + + $alisa = (new self)->getWithAlisaName(); + $sort = "field({$alisa}.status,'1','4','7','-3') asc,{$alisa}.id desc"; + $serch_where = ['status'=>$status,'user_id'=>$user_id, + 'keywords'=>$keywords,"classes_order_id"=>$classes_order_id, + "classes_order_detail_id"=>$classes_order_detail_id,"classes_lib_id"=>$classes_lib_id, + "service_stauts"=>$service_stauts,"sales_type"=>$sales_type + ]; +// if($type)$serch_where['type'] = $type; + return (new self)->getBaseList($serch_where, $page, $limit,$sort,$with_field); + } + + + + + public static function baseCount($where = []){ + + $cancel_number = self::getBaseWhere(array_merge(['status'=>'-3'],$where))->count(); + $processing_number = self::getBaseWhere(array_merge(['status'=>'4'],$where))->count(); + $un_processing_number = self::getBaseWhere(array_merge(['status'=>'1'],$where))->count(); + $finish_number = self::getBaseWhere(array_merge(['status'=>'7'],$where))->count(); + return compact('cancel_number','processing_number','un_processing_number','finish_number'); + } + + + + /**订单数量统计 + * @param int $user_id + * @return array + */ + public static function orderCount($user_id = 0,$classes_order_id=0,$classes_lib_id=[]){ + return self::baseCount(['user_id'=>$user_id,"classes_lib_id"=>$classes_lib_id,"classes_order_id"=>$classes_order_id]); + } + + + + + + public static function workList($page, $limit,$keywords,$status,$service_stauts,$sales_type,$classes_order_id=[],$classes_order_detail_id=[],$classes_lib_id=[],$classes_lib_ids=[]){ + $with_field = [ + 'user'=>['nickname','mobile','avatar','realname'], + 'base'=>['*'], + 'classesorder'=>['*'], + 'detail'=>['*'], + ]; + + $alisa = (new self)->getWithAlisaName(); + $sort = "field({$alisa}.status,'1','4','7','-3') asc,{$alisa}.id desc"; + $serch_where = ['status'=>$status,'keywords'=>$keywords,"classes_lib_id"=>$classes_lib_id,"classes_lib_ids"=>$classes_lib_ids,"classes_order_id"=>$classes_order_id,"classes_order_detail_id"=>$classes_order_detail_id + ,"service_stauts"=>$service_stauts,"sales_type"=>$sales_type + ]; +// if($type)$serch_where['type'] = $type; + return (new self)->getBaseList($serch_where, $page, $limit,$sort,$with_field); + } + + + + + + + /**订单数量统计 + * @param int $user_id + * @return array + */ + public static function workCount($classes_order_id=0,$classes_lib_id=[],$classes_lib_ids=[]){ + return self::baseCount(["classes_lib_id"=>$classes_lib_id,"classes_lib_ids"=>$classes_lib_ids,"classes_order_id"=>$classes_order_id]); + } + + + + /**机构售后提交确认信息 + * @param $order_no + * @param int $user_id + * @param bool $check + * @param bool $trans + * @return bool + * @throws \Exception + */ + public function shopConfirmation($order_no,$user_id=0,$check=false,$oper_type='user',$oper_id=0,$trans=false){ + //得到机构售后提交确认订单 + $order = self::getHaveShopConfirmationOrder($order_no); + if($check){ + //用户操作权限检测 + \app\common\model\school\classes\hourorder\Order::checkOptionAuth($order['id'],$user_id ?: $oper_id,$oper_type); + } + + + //判断逻辑 + if($trans){ + self::beginTrans(); + } + $res = true; + try{ + //事务逻辑 + //更新售后为取消状态 + $order = self::updateCancel($order); + //还原课程订单 + self::orderRestore($order["classes_order_id"]); + //插入订单取消日志 + if(!$user_id ||$order["user_id"] !=$user_id ){ + ServiceOrderLog::log($order['id'],"[系统操作]课程订单已取消售后",$oper_type ?: 'user', $oper_id ?: $order['user_id']); + }else{ + ServiceOrderLog::log($order['id'],"课程订单已取消售后",$oper_type ?: 'user', $oper_id ?: $order['user_id']); + } + + //调用订单取消事件 + $data = ['serviceorder' => $order,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id]; + \think\Hook::listen('classes_serviceorder_cancel_after', $data); + //执行课时数更新 + $res1 = order::statisticsAndUpdateClassesNumber($order['classes_order_id']); + + + if($trans){ + self::commitTrans(); + } + }catch (\Exception $e){ + if($trans){ + self::rollbackTrans(); + } + throw new \Exception($e->getMessage()); + } + return $res1; + } + + + +} diff --git a/application/common/model/school/classes/order/ServiceOrderLog.php b/application/common/model/school/classes/order/ServiceOrderLog.php new file mode 100644 index 0000000..2be308a --- /dev/null +++ b/application/common/model/school/classes/order/ServiceOrderLog.php @@ -0,0 +1,261 @@ + __('Status 1'), '4' => __('Status 4'), '7' => __('Status 7'), '-3' => __('Status -3')]; + } + + public function getServiceStautsList() + { + return ['1' => __('Service_stauts 1'), '4' => __('Service_stauts 4'), '7' => __('Service_stauts 7'), '-3' => __('Service_stauts -3')]; + } + + public function getSalesTypeList() + { + return ['-3' => __('Sales_type -3'), '1' => __('Sales_type 1'), '4' => __('Sales_type 4'), '7' => __('Sales_type 7'), '10' => __('Sales_type 10')]; + } + + + public function getStatusTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['status']) ? $data['status'] : ''); + $list = $this->getStatusList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getServiceStautsTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['service_stauts']) ? $data['service_stauts'] : ''); + $list = $this->getServiceStautsList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getSalesTypeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['sales_type']) ? $data['sales_type'] : ''); + $list = $this->getSalesTypeList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + + + public function serviceorder() + { + return $this->belongsTo(ServiceOrder::class, 'classes_service_order_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function classesorder() + { + return $this->belongsTo(Order::class, 'classes_order_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function user() + { + return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function detail() + { + return $this->belongsTo(OrderDetail::class, 'classes_order_detail_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function admin() + { + return $this->belongsTo(Admin::class, 'oper_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + + /**记录订单日志 + * @param $params + * @param bool $trans + * @throws \Exception + */ + public static function log($order,$mark='更新订单状态',$oper_type='user',$oper_id = 0,$trans=false){ +// var_dump($order); + if(is_numeric($order)||is_string($order))$order = Order::where('order_no|id',$order)->find(); + + + if(!$order)throw new \Exception("找不到订单"); + //操作人信息(可扩展) + $data = [ + 'oper_type'=>$oper_type ?: 'user', + 'oper_id'=>$oper_id ?: $order['user_id'], + 'log_text'=>$mark, + ]; + //判断逻辑 + if($trans){ + self::beginTrans(); + } + $res = true; + try{ + //事务逻辑 + $log_data = $order->toArray(); + $log_data["classes_service_order_id"] = $order['id']; + unset($log_data['id']); + unset($log_data['createtime']); + if($mark)$log_data['log_text'] = $mark; + + + $log_data = array_merge($log_data,$data); + + $log = (new self); + $log->allowField(true)->save($log_data); + if($trans){ + self::commitTrans(); + } + }catch (\Exception $e){ + if($trans){ + self::rollbackTrans(); + } + throw new \Exception($e->getMessage()); + } + return $log; + } + + + /**得到基础条件 + * @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, ['status','classes_lib_id','classes_order_id','user_id','classes_order_detail_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['service_stauts'])) $model = $model->where("{$alisa}service_stauts", 'in', $whereData['service_stauts']); + if (isset($whereData['sales_type'])) $model = $model->where("{$alisa}sales_type", 'in', $whereData['sales_type']); + + + if (isset($whereData['not_status'])) $model = $model->where("{$alisa}status", 'not in', $whereData['not_status']); + if (isset($whereData['keywords'])&&$whereData['keywords']) $model = $model->where("{$alisa}order_no|{$alisa}id|{$alisa}reason", '=', $whereData['keywords']); + if (isset($whereData['time'])&&$whereData['time']){ + + $model = $model->time(["{$alisa}createtime",$whereData['time']]); + } + if (isset($whereData['user_id']) && $whereData['user_id']) $model = $model->where("{$alisa}user_id", '=', $whereData['user_id']); + + + if (isset($whereData['classes_order_id']) && $whereData['classes_order_id']) $model = $model->where("{$alisa}classes_order_id", 'in', $whereData['classes_order_id']); + + if (isset($whereData['classes_service_order_id']) && $whereData['classes_service_order_id']) $model = $model->where("{$alisa}classes_service_order_id", 'in', $whereData['classes_service_order_id']); + + //classes_order_detail_id + + if (isset($whereData['classes_order_detail_id']) && $whereData['classes_order_detail_id']) $model = $model->where("{$alisa}classes_order_detail_id", 'in', $whereData['classes_order_detail_id']); + + + if (isset($whereData['classes_lib_ids']) && $whereData['classes_lib_ids']) $model = $model->where("{$alisa}classes_lib_id", 'in', $whereData['classes_lib_ids']); + if (isset($whereData['classes_lib_id']) && $whereData['classes_lib_id']) $model = $model->where("{$alisa}classes_lib_id", 'in', $whereData['classes_lib_id']); + + return $model; + } + + + + + + + public static function allList($user_id,$page, $limit,$keywords,$status,$service_stauts,$sales_type,$classes_service_order_id=[]){ + $with_field = [ + 'user'=>['nickname','mobile','avatar','realname'], + 'base'=>['*'], + 'classesorder'=>['*'], + 'detail'=>['*'], + ]; + + $alisa = (new self)->getWithAlisaName(); + $sort = "{$alisa}.id desc"; + $serch_where = ['status'=>$status,'user_id'=>$user_id, + 'keywords'=>$keywords,"classes_service_order_id"=>$classes_service_order_id, + "service_stauts"=>$service_stauts,"sales_type"=>$sales_type + ]; +// if($type)$serch_where['type'] = $type; + return (new self)->getBaseList($serch_where, $page, $limit,$sort,$with_field); + } + + + + public static function workList($page, $limit,$keywords,$status,$service_stauts,$sales_type,$classes_service_order_id=[],$classes_lib_ids=[]){ + $with_field = [ + 'user'=>['nickname','mobile','avatar','realname'], + 'base'=>['*'], + 'classesorder'=>['*'], + 'detail'=>['*'], + ]; + + $alisa = (new self)->getWithAlisaName(); + $sort = "{$alisa}.id desc"; + $serch_where = ['status'=>$status,'keywords'=>$keywords,"classes_service_order_id"=>$classes_service_order_id,"classes_lib_ids"=>$classes_lib_ids + ,"service_stauts"=>$service_stauts,"sales_type"=>$sales_type + ]; +// if($type)$serch_where['type'] = $type; + return (new self)->getBaseList($serch_where, $page, $limit,$sort,$with_field); + } + + + +} diff --git a/application/config.php b/application/config.php index 95d436c..8f5001e 100644 --- a/application/config.php +++ b/application/config.php @@ -306,4 +306,13 @@ return [ //API接口地址 'api_url' => 'https://api.fastadmin.net', ], + //增加 redis 配置 + 'redis' => [ + 'host' => '127.0.0.1', // redis 主机地址 + 'password' => '', // redis 密码 + 'port' => 6379, // redis 端口 + 'select' => 3, // redis 数据库 + 'timeout' => 0, // redis 超时时间 + 'persistent' => false, // redis 持续性,连接复用 + ] ]; diff --git a/application/manystore/controller/general/Profile.php b/application/manystore/controller/general/Profile.php index c371558..eba901a 100644 --- a/application/manystore/controller/general/Profile.php +++ b/application/manystore/controller/general/Profile.php @@ -83,6 +83,8 @@ class Profile extends ManystoreBase if ($this->request->isPost()) { $this->token(); $shop = $this->request->post("shop/a"); + if($shop["address_city"] && !$shop["province"])$this->error("请选择所在城市"); + $shopModel = new ManystoreShop(); $shopModel->save($shop,array('id'=>SHOP_ID)); diff --git a/application/manystore/controller/school/classes/ClassesLib.php b/application/manystore/controller/school/classes/ClassesLib.php index aecaa8f..cf83466 100644 --- a/application/manystore/controller/school/classes/ClassesLib.php +++ b/application/manystore/controller/school/classes/ClassesLib.php @@ -261,6 +261,12 @@ class ClassesLib extends ManystoreBase } protected function update_classes($classes_lib_id){ + //课时数必须大于等于课时核销数 + $count = \app\common\model\school\classes\ClassesSpec::where("classes_lib_id",$classes_lib_id)->count(); + $classes_num = \app\common\model\school\classes\ClassesLib::where("id",$classes_lib_id)->value("classes_num"); + if($count < $classes_num){ + throw new \Exception("课时数必须大于等于课时核销数"); + } \app\common\model\school\classes\ClassesLib::update_classes($classes_lib_id); } @@ -286,17 +292,18 @@ class ClassesLib extends ManystoreBase if($this->shopIdAutoCondition && SHOP_ID){ $params['shop_id'] = SHOP_ID; } - - $result = false; - Db::startTrans(); - try { - //是否采用模型验证 + //是否采用模型验证 if ($this->modelValidate) { $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; $this->model->validateFailException(true)->validate($validate); } - $this->update_check($params,$row=null); + $this->update_check($params,$row=null); + $result = false; + Db::startTrans(); + try { + + $spec = $params["spec"]; unset($params["spec"]); $result = $this->model->allowField(true)->save($params); @@ -307,6 +314,13 @@ class ClassesLib extends ManystoreBase \app\common\model\school\classes\ClassesSpec::create($v); } + //因为是批量添加,所有规格重新进行检测,防止出现时间重叠 + $specss = \app\common\model\school\classes\ClassesSpec::where("classes_lib_id",$this->model["id"])->select(); + foreach ($specss as $k=>$specs){ + $params =$specs; + (new \app\common\model\school\classes\ClassesSpec)->specCheck($params,null,$specs); + } + $this->update_classes($this->model["id"]); if($this->have_auth){ //调用通过事件 @@ -323,7 +337,7 @@ class ClassesLib extends ManystoreBase } catch (PDOException $e) { Db::rollback(); $this->error($e->getMessage()); - } catch (Exception $e) { + } catch (\Exception $e) { Db::rollback(); $this->error($e->getMessage()); } @@ -389,7 +403,7 @@ class ClassesLib extends ManystoreBase } catch (PDOException $e) { Db::rollback(); $this->error($e->getMessage()); - } catch (Exception $e) { + } catch (\Exception $e) { Db::rollback(); $this->error($e->getMessage()); } @@ -421,17 +435,18 @@ class ClassesLib extends ManystoreBase $params = $this->request->post("row/a"); if ($params) { $params = $this->preExcludeFields($params); + + //是否采用模型验证 +// if ($this->modelValidate) { +// $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); +// $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; +// $row->validateFailException(true)->validate($validate); +// } + $this->update_check($params,$row); $result = false; Db::startTrans(); try { - //是否采用模型验证 - if ($this->modelValidate) { - $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); - $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; - $row->validateFailException(true)->validate($validate); - } - $this->update_check($params,$row); $spec = $params["spec"] ?? [];//$params["delete_spec_ids"] $delete_spec_ids = $params["delete_spec_ids"] ?? []; @@ -454,6 +469,14 @@ class ClassesLib extends ManystoreBase $delete_spec->delete(); } + //因为是批量添加,所有规格重新进行检测,防止出现时间重叠 + $specss = \app\common\model\school\classes\ClassesSpec::where("classes_lib_id",$row["id"])->select(); + foreach ($specss as $k=>$specs){ + $params =$specs; + (new \app\common\model\school\classes\ClassesSpec)->specCheck($params,null,$specs); + } + + $this->update_classes($row["id"]); if($this->have_auth){ @@ -471,7 +494,7 @@ class ClassesLib extends ManystoreBase } catch (PDOException $e) { Db::rollback(); $this->error($e->getMessage()); - } catch (Exception $e) { + } catch (\Exception $e) { Db::rollback(); $this->error($e->getMessage()); } diff --git a/application/manystore/controller/school/classes/order/ServiceOrder.php b/application/manystore/controller/school/classes/order/ServiceOrder.php new file mode 100644 index 0000000..deee654 --- /dev/null +++ b/application/manystore/controller/school/classes/order/ServiceOrder.php @@ -0,0 +1,83 @@ +model = new \app\manystore\model\school\classes\order\ServiceOrder; + $this->view->assign("statusList", $this->model->getStatusList()); + $this->view->assign("serviceStautsList", $this->model->getServiceStautsList()); + $this->view->assign("salesTypeList", $this->model->getSalesTypeList()); + $this->view->assign("platformList", $this->model->getPlatformList()); + $this->view->assign("payTypeList", $this->model->getPayTypeList()); + } + + public function import() + { + parent::import(); + } + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + + /** + * 查看 + */ + public function index() + { + //当前是否为关联查询 + $this->relationSearch = true; + //设置过滤方法 + $this->request->filter(['strip_tags', 'trim']); + if ($this->request->isAjax()) { + //如果发送的来源是Selectpage,则转发到Selectpage + if ($this->request->request('keyField')) { + return $this->selectpage(); + } + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + + $list = $this->model + ->with(['schoolclassesorder','user','schoolclassesorderdetail','schoolclasseslib','manystore','manystoreshop']) + ->where($where) + ->order($sort, $order) + ->paginate($limit); + + foreach ($list as $row) { + + $row->getRelation('schoolclassesorder')->visible(['order_no','pay_no']); + $row->getRelation('user')->visible(['nickname','realname','mobile','avatar']); + $row->getRelation('schoolclassesorderdetail')->visible(['title','headimage']); + $row->getRelation('schoolclasseslib')->visible(['title','headimage']); + $row->getRelation('manystore')->visible(['nickname']); + $row->getRelation('manystoreshop')->visible(['name','logo']); + } + + $result = array("total" => $list->total(), "rows" => $list->items()); + + return json($result); + } + return $this->view->fetch(); + } + +} diff --git a/application/manystore/controller/school/classes/order/ServiceOrderLog.php b/application/manystore/controller/school/classes/order/ServiceOrderLog.php new file mode 100644 index 0000000..890fdf0 --- /dev/null +++ b/application/manystore/controller/school/classes/order/ServiceOrderLog.php @@ -0,0 +1,80 @@ +model = new \app\manystore\model\school\classes\order\ServiceOrderLog; + $this->view->assign("statusList", $this->model->getStatusList()); + $this->view->assign("serviceStautsList", $this->model->getServiceStautsList()); + $this->view->assign("salesTypeList", $this->model->getSalesTypeList()); + } + + public function import() + { + parent::import(); + } + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + + /** + * 查看 + */ + public function index() + { + //当前是否为关联查询 + $this->relationSearch = true; + //设置过滤方法 + $this->request->filter(['strip_tags', 'trim']); + if ($this->request->isAjax()) { + //如果发送的来源是Selectpage,则转发到Selectpage + if ($this->request->request('keyField')) { + return $this->selectpage(); + } + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + + $list = $this->model + ->with(['schoolclassesserviceorder','schoolclassesorder','user','schoolclassesorderdetail','admin']) + ->where($where) + ->order($sort, $order) + ->paginate($limit); + + foreach ($list as $row) { + + $row->getRelation('schoolclassesserviceorder')->visible(['order_no']); + $row->getRelation('schoolclassesorder')->visible(['order_no','pay_no']); + $row->getRelation('user')->visible(['nickname','realname','mobile','avatar']); + $row->getRelation('schoolclassesorderdetail')->visible(['title']); + $row->getRelation('admin')->visible(['nickname']); + } + + $result = array("total" => $list->total(), "rows" => $list->items()); + + return json($result); + } + return $this->view->fetch(); + } + +} diff --git a/application/manystore/lang/zh-cn/general/profile.php b/application/manystore/lang/zh-cn/general/profile.php index 6a7b1ff..8a926e5 100644 --- a/application/manystore/lang/zh-cn/general/profile.php +++ b/application/manystore/lang/zh-cn/general/profile.php @@ -7,6 +7,7 @@ return [ 'Email already exists' => '邮箱已经存在', 'Please input correct nickname' => '昵称仅支持输入中文、英文字母(大小写)、数字、下划线', 'Please input length nickname' => '昵称请最多填写10个字符', + 'Loss_ratio' => '课程损耗比(百分制)', 'Front_idcard_image' => '身份证人像面', 'Reverse_idcard_image' => '身份证国徽面', 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 c8bd3b9..d0c1f10 100644 --- a/application/manystore/lang/zh-cn/school/classes/order/order.php +++ b/application/manystore/lang/zh-cn/school/classes/order/order.php @@ -22,6 +22,8 @@ return [ 'Status -3' => '已取消', 'Status 0' => '待支付', 'Status 3' => '使用中', + 'Status 4' => '售后中', + 'Set status to 4' => '设为售后中', 'Status 6' => '已退款', 'Status 9' => '已完成', 'Before_status' => '售后前状态', diff --git a/application/manystore/lang/zh-cn/school/classes/order/order_log.php b/application/manystore/lang/zh-cn/school/classes/order/order_log.php index a7212cf..8f88f72 100644 --- a/application/manystore/lang/zh-cn/school/classes/order/order_log.php +++ b/application/manystore/lang/zh-cn/school/classes/order/order_log.php @@ -6,6 +6,8 @@ return [ 'Status -3' => '已取消', 'Status 0' => '待支付', 'Status 3' => '使用中', + 'Status 4' => '售后中', + 'Set status to 4' => '设为售后中', 'Status 6' => '已退款', 'Status 9' => '已完成', 'Before_status' => '售后前状态', diff --git a/application/manystore/lang/zh-cn/school/classes/order/service_order.php b/application/manystore/lang/zh-cn/school/classes/order/service_order.php new file mode 100644 index 0000000..4cced36 --- /dev/null +++ b/application/manystore/lang/zh-cn/school/classes/order/service_order.php @@ -0,0 +1,63 @@ + '售后单号', + 'Reason' => '售后申请原因', + 'Classes_order_id' => '课程订单id', + 'User_id' => '下单人id', + 'Classes_order_detail_id' => '订单课程id', + 'Classes_lib_id' => '课程id', + 'Manystore_id' => '机构账号id', + 'Shop_id' => '机构店铺id', + 'Status' => '售后状态', + 'Status 1' => '待处理', + 'Status 4' => '处理中', + 'Status 7' => '已结单', + 'Status -3' => '已取消', + 'Service_stauts' => '售后处理状态', + 'Service_stauts 1' => '待机构处理', + 'Service_stauts 4' => '待用户确认', + 'Service_stauts 7' => '售后通过结单', + 'Service_stauts -3' => '售后驳回结单', + 'Sales_type' => '结单类型', + 'Sales_type -3' => '未结单', + 'Sales_type 1' => '机构驳回', + 'Sales_type 4' => '用户驳回', + 'Sales_type 7' => '平台驳回', + 'Sales_type 10' => '成功退款', + 'Reject_reason' => '驳回原因', + 'Reject_images' => '驳回图片资料', + 'Auto_price' => '自动计算应退全额', + 'Loss_proportion' => '课程损耗比例', + 'Auto_loss_price' => '自动计算损耗金额', + 'Tbc_price' => '售后待确认退款金额', + 'C_price' => '售后已确认退款金额', + 'Real_refundprice' => '实际退款金额', + 'Sub_refundprice' => '剩余未退金额', + 'Platform' => '退款平台:miniapp=微信小程序', + 'Pay_type' => '退款方式', + 'Pay_type yue' => '余额', + 'Pay_type wechat' => '微信', + 'Pay_json' => '三方支付信息json', + 'Deletetime' => '删除时间', + 'Refundtime' => '退款时间', + 'Rejecttime' => '驳回时间', + 'Handletime' => '处理时间', + 'Confirmtime' => '确认时间', + 'Checkouttime' => '结单时间', + 'Createtime' => '创建时间', + 'Updatetime' => '修改时间', + 'Schoolclassesorder.order_no' => '订单号', + 'Schoolclassesorder.pay_no' => '微信支付单号', + 'User.nickname' => '昵称', + 'User.realname' => '真实姓名', + 'User.mobile' => '手机号', + 'User.avatar' => '头像', + 'Schoolclassesorderdetail.title' => '标题', + 'Schoolclassesorderdetail.headimage' => '头图', + 'Schoolclasseslib.title' => '标题', + 'Schoolclasseslib.headimage' => '头图', + 'Manystore.nickname' => '昵称', + 'Manystoreshop.name' => '店铺名称', + 'Manystoreshop.logo' => '品牌LOGO' +]; diff --git a/application/manystore/lang/zh-cn/school/classes/order/service_order_log.php b/application/manystore/lang/zh-cn/school/classes/order/service_order_log.php new file mode 100644 index 0000000..f859a6b --- /dev/null +++ b/application/manystore/lang/zh-cn/school/classes/order/service_order_log.php @@ -0,0 +1,41 @@ + '课程售后订单id', + 'Classes_order_id' => '课程订单id', + 'User_id' => '下单人id', + 'Classes_order_detail_id' => '订单课程id', + 'Classes_lib_id' => '课程id', + 'Manystore_id' => '机构账号id', + 'Shop_id' => '机构店铺id', + 'Status' => '售后状态', + 'Status 1' => '待处理', + 'Status 4' => '处理中', + 'Status 7' => '已结单', + 'Status -3' => '已取消', + 'Service_stauts' => '售后处理状态', + 'Service_stauts 1' => '待机构处理', + 'Service_stauts 4' => '待用户确认', + 'Service_stauts 7' => '售后通过结单', + 'Service_stauts -3' => '售后驳回结单', + 'Sales_type' => '结单类型', + 'Sales_type -3' => '未结单', + 'Sales_type 1' => '机构驳回', + 'Sales_type 4' => '用户驳回', + 'Sales_type 7' => '平台驳回', + 'Sales_type 10' => '成功退款', + 'Log_text' => '记录内容', + 'Oper_id' => '记录人id', + 'Oper_type' => '记录人类型', + 'Createtime' => '创建时间', + 'Updatetime' => '修改时间', + 'Schoolclassesserviceorder.order_no' => '售后单号', + 'Schoolclassesorder.order_no' => '订单号', + 'Schoolclassesorder.pay_no' => '微信支付单号', + 'User.nickname' => '昵称', + 'User.realname' => '真实姓名', + 'User.mobile' => '手机号', + 'User.avatar' => '头像', + 'Schoolclassesorderdetail.title' => '标题', + 'Admin.nickname' => '昵称' +]; diff --git a/application/manystore/model/school/classes/order/Order.php b/application/manystore/model/school/classes/order/Order.php index b721545..c6a7b34 100644 --- a/application/manystore/model/school/classes/order/Order.php +++ b/application/manystore/model/school/classes/order/Order.php @@ -45,7 +45,7 @@ class Order extends Model public function getStatusList() { - return ['-3' => __('Status -3'), '0' => __('Status 0'), '3' => __('Status 3'), '6' => __('Status 6'), '9' => __('Status 9')]; + return ['-3' => __('Status -3'), '0' => __('Status 0'), '3' => __('Status 3'),'4' => __('Status 4'), '6' => __('Status 6'), '9' => __('Status 9')]; } public function getBeforeStatusList() diff --git a/application/manystore/model/school/classes/order/OrderLog.php b/application/manystore/model/school/classes/order/OrderLog.php index 209dc97..6ef8e4f 100644 --- a/application/manystore/model/school/classes/order/OrderLog.php +++ b/application/manystore/model/school/classes/order/OrderLog.php @@ -35,7 +35,7 @@ class OrderLog extends Model public function getStatusList() { - return ['-3' => __('Status -3'), '0' => __('Status 0'), '3' => __('Status 3'), '6' => __('Status 6'), '9' => __('Status 9')]; + return ['-3' => __('Status -3'), '0' => __('Status 0'), '3' => __('Status 3'),'4' => __('Status 4'), '6' => __('Status 6'), '9' => __('Status 9')]; } public function getBeforeStatusList() diff --git a/application/manystore/model/school/classes/order/ServiceOrder.php b/application/manystore/model/school/classes/order/ServiceOrder.php new file mode 100644 index 0000000..002f350 --- /dev/null +++ b/application/manystore/model/school/classes/order/ServiceOrder.php @@ -0,0 +1,205 @@ + __('Status 1'), '4' => __('Status 4'), '7' => __('Status 7'), '-3' => __('Status -3')]; + } + + public function getServiceStautsList() + { + return ['1' => __('Service_stauts 1'), '4' => __('Service_stauts 4'), '7' => __('Service_stauts 7'), '-3' => __('Service_stauts -3')]; + } + + public function getSalesTypeList() + { + return ['-3' => __('Sales_type -3'), '1' => __('Sales_type 1'), '4' => __('Sales_type 4'), '7' => __('Sales_type 7'), '10' => __('Sales_type 10')]; + } + + public function getPlatformList() + { + return ['miniapp' => __('Miniapp')]; + } + + public function getPayTypeList() + { + return ['yue' => __('Pay_type yue'), 'wechat' => __('Pay_type wechat')]; + } + + + public function getStatusTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['status']) ? $data['status'] : ''); + $list = $this->getStatusList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getServiceStautsTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['service_stauts']) ? $data['service_stauts'] : ''); + $list = $this->getServiceStautsList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getSalesTypeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['sales_type']) ? $data['sales_type'] : ''); + $list = $this->getSalesTypeList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getPlatformTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['platform']) ? $data['platform'] : ''); + $list = $this->getPlatformList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getPayTypeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['pay_type']) ? $data['pay_type'] : ''); + $list = $this->getPayTypeList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getRefundtimeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['refundtime']) ? $data['refundtime'] : ''); + return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; + } + + + public function getRejecttimeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['rejecttime']) ? $data['rejecttime'] : ''); + return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; + } + + + public function getHandletimeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['handletime']) ? $data['handletime'] : ''); + return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; + } + + + public function getConfirmtimeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['confirmtime']) ? $data['confirmtime'] : ''); + return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; + } + + + public function getCheckouttimeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['checkouttime']) ? $data['checkouttime'] : ''); + return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; + } + + protected function setRefundtimeAttr($value) + { + return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); + } + + protected function setRejecttimeAttr($value) + { + return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); + } + + protected function setHandletimeAttr($value) + { + return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); + } + + protected function setConfirmtimeAttr($value) + { + return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); + } + + protected function setCheckouttimeAttr($value) + { + return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); + } + + + public function schoolclassesorder() + { + return $this->belongsTo(Order::class, 'classes_order_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function user() + { + return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function schoolclassesorderdetail() + { + return $this->belongsTo(OrderDetail::class, 'classes_order_detail_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function schoolclasseslib() + { + return $this->belongsTo(ClassesLib::class, 'classes_lib_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function manystore() + { + return $this->belongsTo(\app\manystore\model\Manystore::class, 'manystore_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function manystoreshop() + { + return $this->belongsTo(ManystoreShop::class, 'shop_id', 'id', [], 'LEFT')->setEagerlyType(0); + } +} diff --git a/application/manystore/model/school/classes/order/ServiceOrderLog.php b/application/manystore/model/school/classes/order/ServiceOrderLog.php new file mode 100644 index 0000000..7ae062c --- /dev/null +++ b/application/manystore/model/school/classes/order/ServiceOrderLog.php @@ -0,0 +1,106 @@ + __('Status 1'), '4' => __('Status 4'), '7' => __('Status 7'), '-3' => __('Status -3')]; + } + + public function getServiceStautsList() + { + return ['1' => __('Service_stauts 1'), '4' => __('Service_stauts 4'), '7' => __('Service_stauts 7'), '-3' => __('Service_stauts -3')]; + } + + public function getSalesTypeList() + { + return ['-3' => __('Sales_type -3'), '1' => __('Sales_type 1'), '4' => __('Sales_type 4'), '7' => __('Sales_type 7'), '10' => __('Sales_type 10')]; + } + + + public function getStatusTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['status']) ? $data['status'] : ''); + $list = $this->getStatusList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getServiceStautsTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['service_stauts']) ? $data['service_stauts'] : ''); + $list = $this->getServiceStautsList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getSalesTypeTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['sales_type']) ? $data['sales_type'] : ''); + $list = $this->getSalesTypeList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + + + public function schoolclassesserviceorder() + { + return $this->belongsTo(ServiceOrder::class, 'classes_service_order_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function schoolclassesorder() + { + return $this->belongsTo(Order::class, 'classes_order_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function user() + { + return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function schoolclassesorderdetail() + { + return $this->belongsTo(OrderDetail::class, 'classes_order_detail_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function admin() + { + return $this->belongsTo(Admin::class, 'oper_id', 'id', [], 'LEFT')->setEagerlyType(0); + } +} diff --git a/application/manystore/validate/school/classes/order/ServiceOrder.php b/application/manystore/validate/school/classes/order/ServiceOrder.php new file mode 100644 index 0000000..f920b4f --- /dev/null +++ b/application/manystore/validate/school/classes/order/ServiceOrder.php @@ -0,0 +1,27 @@ + [], + 'edit' => [], + ]; + +} diff --git a/application/manystore/validate/school/classes/order/ServiceOrderLog.php b/application/manystore/validate/school/classes/order/ServiceOrderLog.php new file mode 100644 index 0000000..35ea513 --- /dev/null +++ b/application/manystore/validate/school/classes/order/ServiceOrderLog.php @@ -0,0 +1,27 @@ + [], + 'edit' => [], + ]; + +} diff --git a/application/manystore/view/school/classes/classes_lib/edit.html b/application/manystore/view/school/classes/classes_lib/edit.html index 94c6ce0..e201f25 100644 --- a/application/manystore/view/school/classes/classes_lib/edit.html +++ b/application/manystore/view/school/classes/classes_lib/edit.html @@ -158,7 +158,7 @@
      - + (填写几节意味着客户购买课程后能预约上课核销几次,即购买本课程的课程节数)
      diff --git a/application/manystore/view/school/classes/order/service_order/add.html b/application/manystore/view/school/classes/order/service_order/add.html new file mode 100644 index 0000000..f969812 --- /dev/null +++ b/application/manystore/view/school/classes/order/service_order/add.html @@ -0,0 +1,214 @@ +
      + +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      + {foreach name="statusList" item="vo"} + + {/foreach} +
      + +
      +
      +
      + +
      + + + +
      +
      +
      + +
      + + + +
      +
      +
      + +
      + +
      +
      +
      + +
      +
      + +
      + + +
      + +
      +
        +
        +
        +
        + +
        + +
        +
        +
        + +
        + +
        +
        +
        + +
        + +
        +
        +
        + +
        + +
        +
        +
        + +
        + +
        +
        +
        + +
        + +
        +
        +
        + +
        + +
        +
        +
        + +
        + + + +
        +
        +
        + +
        + + + +
        +
        +
        + +
        + +
        +
        + {:__('Key')} + {:__('Value')} +
        +
        {:__('Append')}
        + +
        + + +
        +
        +
        + +
        + +
        +
        +
        + +
        + +
        +
        +
        + +
        + +
        +
        +
        + +
        + +
        +
        +
        + +
        + +
        +
        + +
        diff --git a/application/manystore/view/school/classes/order/service_order/edit.html b/application/manystore/view/school/classes/order/service_order/edit.html new file mode 100644 index 0000000..fafa1c7 --- /dev/null +++ b/application/manystore/view/school/classes/order/service_order/edit.html @@ -0,0 +1,214 @@ +
        + +
        + +
        + +
        +
        +
        + +
        + +
        +
        +
        + +
        + +
        +
        +
        + +
        + +
        +
        +
        + +
        + +
        +
        +
        + +
        + +
        +
        +
        + +
        + +
        + {foreach name="statusList" item="vo"} + + {/foreach} +
        + +
        +
        +
        + +
        + + + +
        +
        +
        + +
        + + + +
        +
        +
        + +
        + +
        +
        +
        + +
        +
        + +
        + + +
        + +
        +
          +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          +
          +
          + +
          + + + +
          +
          +
          + +
          + + + +
          +
          +
          + +
          + +
          +
          + {:__('Key')} + {:__('Value')} +
          +
          {:__('Append')}
          + +
          + + +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          +
          + +
          diff --git a/application/manystore/view/school/classes/order/service_order/index.html b/application/manystore/view/school/classes/order/service_order/index.html new file mode 100644 index 0000000..93d5790 --- /dev/null +++ b/application/manystore/view/school/classes/order/service_order/index.html @@ -0,0 +1,44 @@ +
          + +
          + {:build_heading(null,FALSE)} + +
          + + + +
          diff --git a/application/manystore/view/school/classes/order/service_order/recyclebin.html b/application/manystore/view/school/classes/order/service_order/recyclebin.html new file mode 100644 index 0000000..c4353f1 --- /dev/null +++ b/application/manystore/view/school/classes/order/service_order/recyclebin.html @@ -0,0 +1,25 @@ +
          + {:build_heading()} + +
          +
          +
          + +
          + +
          +
          +
          diff --git a/application/manystore/view/school/classes/order/service_order_log/add.html b/application/manystore/view/school/classes/order/service_order_log/add.html new file mode 100644 index 0000000..d0ab9cf --- /dev/null +++ b/application/manystore/view/school/classes/order/service_order_log/add.html @@ -0,0 +1,100 @@ +
          + +
          + +
          + +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          + {foreach name="statusList" item="vo"} + + {/foreach} +
          + +
          +
          +
          + +
          + + + +
          +
          +
          + +
          + + + +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          +
          + +
          diff --git a/application/manystore/view/school/classes/order/service_order_log/edit.html b/application/manystore/view/school/classes/order/service_order_log/edit.html new file mode 100644 index 0000000..e0a6887 --- /dev/null +++ b/application/manystore/view/school/classes/order/service_order_log/edit.html @@ -0,0 +1,100 @@ +
          + +
          + +
          + +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          + {foreach name="statusList" item="vo"} + + {/foreach} +
          + +
          +
          +
          + +
          + + + +
          +
          +
          + +
          + + + +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          +
          + +
          diff --git a/application/manystore/view/school/classes/order/service_order_log/index.html b/application/manystore/view/school/classes/order/service_order_log/index.html new file mode 100644 index 0000000..cf62f45 --- /dev/null +++ b/application/manystore/view/school/classes/order/service_order_log/index.html @@ -0,0 +1,44 @@ +
          + +
          + {:build_heading(null,FALSE)} + +
          + + + +
          diff --git a/application/manystore/view/school/classes/verification/add.html b/application/manystore/view/school/classes/verification/add.html index b6661ba..c328371 100644 --- a/application/manystore/view/school/classes/verification/add.html +++ b/application/manystore/view/school/classes/verification/add.html @@ -17,12 +17,12 @@
          -
          - -
          - -
          -
          + + + + + +
          diff --git a/application/manystore/view/school/classes/verification/edit.html b/application/manystore/view/school/classes/verification/edit.html index df6f52e..e121419 100644 --- a/application/manystore/view/school/classes/verification/edit.html +++ b/application/manystore/view/school/classes/verification/edit.html @@ -17,12 +17,12 @@
          -
          - -
          - -
          -
          + + + + + +
          diff --git a/extend/bw/Redis.php b/extend/bw/Redis.php new file mode 100644 index 0000000..5481f7f --- /dev/null +++ b/extend/bw/Redis.php @@ -0,0 +1,68 @@ + '127.0.0.1', + 'port' => 6379, + 'password' => '', + 'select' => 0, + 'timeout' => 0, + 'expire' => 0, + 'persistent' => false, + 'prefix' => '', + ]; + + /** + * 构造函数 + * @param array $options 缓存参数 + * @access public + */ + public function __construct($options = []) + { + if (!extension_loaded('redis')) { + throw new \BadFunctionCallException('not support: redis'); + } + + // 获取 redis 配置 + $config = \think\Config::get('redis'); + if (empty($config) && empty($options)) { + throw new \Exception('redis connection fail: no redis config'); + } + + if (!empty($config)) { + $this->options = array_merge($this->options, $config); + } + + if (!empty($options)) { + $this->options = array_merge($this->options, $options); + } + $this->handler = new \Redis(); + if ($this->options['persistent']) { + $this->handler->pconnect($this->options['host'], $this->options['port'], $this->options['timeout'], 'persistent_id_' . $this->options['select']); + } else { + $this->handler->connect($this->options['host'], $this->options['port'], $this->options['timeout']); + } + + if ('' != $this->options['password']) { + $this->handler->auth($this->options['password']); + } + + if (0 != $this->options['select']) { + $this->handler->select($this->options['select']); + } + + // 赋值全局,避免多次实例化 + $GLOBALS['SPREDIS'] = $this->handler; + } + + public function getRedis() { + return $this->handler; + } +} \ No newline at end of file diff --git a/extend/traits/CacheTrait.php b/extend/traits/CacheTrait.php index 542d98b..79f48e9 100644 --- a/extend/traits/CacheTrait.php +++ b/extend/traits/CacheTrait.php @@ -1,14 +1,9 @@