diff --git a/application/admin/controller/school/Message.php b/application/admin/controller/school/Message.php index 728d563..fb6d67d 100644 --- a/application/admin/controller/school/Message.php +++ b/application/admin/controller/school/Message.php @@ -54,11 +54,12 @@ class Message extends Backend return $this->selectpage(); } list($where, $sort, $order, $offset, $limit) = $this->buildparams(); - + $as = $this->model->getWithAlisaName(); $list = $this->model ->with(['admin','user']) ->where($where) - ->order($sort, $order) +// ->order($sort, $order) + ->order("{$as}.weigh DESC,{$as}.id DESC") ->paginate($limit); foreach ($list as $row) { diff --git a/application/admin/controller/school/classes/ClassesLib.php b/application/admin/controller/school/classes/ClassesLib.php index 9eabad6..a0725a5 100644 --- a/application/admin/controller/school/classes/ClassesLib.php +++ b/application/admin/controller/school/classes/ClassesLib.php @@ -105,6 +105,7 @@ class ClassesLib extends Backend } + protected function authClasses(&$params,$row=null){ //审核失败需填写原因 if($params["auth_status"] == '2' && empty($params["reason"])){ @@ -233,6 +234,10 @@ class ClassesLib extends Backend $params["user_id"] = $teacher["user_id"]; + //课时必须大于等于1 + if($params["classes_num"] < 1) $this->error("课时必须大于等于1"); + if($params["price"] < 0) $this->error("售价必须大于0"); + //独立地点需传定位信息 if($params["address_type"] == "2"){ @@ -322,8 +327,20 @@ class ClassesLib extends Backend } } + //如果是上架,判断是否拥有课时规格,没有则无法上架 + if($params["status"]=="1"){ + if(!$row)$this->error("新添加的课程请先至少添加一个课时规格后再上架!"); + //判断是否拥有课时规格,没有则无法上架 + $check_spec = \app\common\model\school\classes\ClassesSpec::where("classes_lib_id",$row->id)->count(); + if(!$check_spec)$this->error("新添加的课程请先至少添加一个课时规格后再上架!"); + + } + } + protected function update_classes($classes_lib_id){ + \app\common\model\school\classes\ClassesLib::update_classes($classes_lib_id); + } /** @@ -357,6 +374,31 @@ class ClassesLib extends Backend } $this->update_check($params,$row=null); $result = $this->model->allowField(true)->save($params); + \app\common\model\school\classes\ClassesLib::add_virtual_init($this->model["id"]); + $this->update_classes($this->model["id"]); + + if($this->have_auth){ + //调用通过事件 + $data = ['classes' => $this->model]; + \think\Hook::listen('classes_auth_need_after', $data); + + } + + if($this->success_auth){ + //调用通过事件 + $data = ['classes' => $this->model]; + \think\Hook::listen('classes_auth_success_after', $data); + } + + + if($this->error_auth){ + //调用通过事件 + $data = ['classes' => $this->model]; + \think\Hook::listen('classes_auth_fail_after', $data); + + } + + Db::commit(); } catch (ValidateException|PDOException|Exception $e) { Db::rollback(); @@ -406,7 +448,13 @@ class ClassesLib extends Backend } $this->update_check($params,$row); $result = $row->allowField(true)->save($params); + $this->update_classes($row["id"]); + if($this->have_auth){ + //调用通过事件 + $data = ['classes' => $row]; + \think\Hook::listen('classes_auth_need_after', $data); + } if($this->success_auth){ //调用通过事件 @@ -422,12 +470,7 @@ class ClassesLib extends Backend } // protected $have_auth = false; - if($this->have_auth){ - //调用通过事件 - $data = ['classes' => $row]; - \think\Hook::listen('classes_auth_need_after', $data); - } diff --git a/application/admin/controller/school/classes/ClassesSpec.php b/application/admin/controller/school/classes/ClassesSpec.php index fe3644e..3b7aff2 100644 --- a/application/admin/controller/school/classes/ClassesSpec.php +++ b/application/admin/controller/school/classes/ClassesSpec.php @@ -134,11 +134,79 @@ class ClassesSpec extends Backend protected function update_check(&$params,$row=null) { + + //开始和结束时间不能为空 + $start_time = $params["start_time"]; + $end_time = $params["end_time"]; + if(empty($start_time) || empty($end_time)){ + $this->error("请选择开始和结束时间"); + } + //转化时间戳 + $start_time = $params["start_time"] && !is_numeric($params["start_time"]) ? strtotime($params["start_time"]) : $params["start_time"]; + $end_time = $params["end_time"] && !is_numeric($params["end_time"]) ? strtotime($params["end_time"]) : $params["end_time"]; + //结束时间不能小于开始时间 + if($end_time<=$start_time){ + $this->error("结束时间不能小于开始时间"); + } + + //结束时间不能是已经过去的时间 + $now_time = time(); + if($end_time<=$now_time){ + $this->error("结束时间不能是已经过去的时间"); + } + + + $orderTimeTableName = $this->model->getWithAlisaName(); //修改 if($row){ $this->updateCheck($row->id,$params,$row); + //规格名字不能一样(同课程下) + $spec_name = $params["name"]; + $classes_lib_id = $params["classes_lib_id"]; + $spec_name_exist = $this->model::where("name",$spec_name)->where("classes_lib_id",$classes_lib_id)->where("id","<>",$row->id)->find(); + if($spec_name_exist){ + $this->error("该课程下已存在该课时规格名称,请重新输入"); + } + //同课程下,各个课时的开始和结束时间不能有重叠(出现时间交叠也不行) + $spec_time_exist = $this->model::where(function ($query) use ($orderTimeTableName,$start_time,$end_time) { + //兩個時間區間重合 存在任意交集 都不行 + $query->where("start_time BETWEEN {$start_time} AND {$end_time}"); + $query->whereOr("end_time BETWEEN {$start_time} AND {$end_time}"); + $query->whereOr("start_time <= {$start_time} AND end_time >= {$end_time}"); + $query->whereOr("start_time >= {$start_time} AND end_time <= {$end_time}"); + }) + ->where("classes_lib_id",$classes_lib_id) + ->where("id","<>",$row->id)->find(); + + if($spec_time_exist){ + $this->error("该课程下,{$spec_time_exist['name']}课时的开始和结束时间与你有重叠"); + } + + }else{ //新增 + //规格名字不能一样(同课程下) + $spec_name = $params["name"]; + $classes_lib_id = $params["classes_lib_id"]; + $spec_name_exist = $this->model::where("name",$spec_name)->where("classes_lib_id",$classes_lib_id)->find(); + if($spec_name_exist){ + $this->error("该课程下已存在该课时规格名称,请重新输入"); + } + + //同课程下,各个课时的开始和结束时间不能有重叠(出现时间交叠也不行) + $spec_time_exist = $this->model::where(function ($query) use ($orderTimeTableName,$start_time,$end_time) { + //兩個時間區間重合 存在任意交集 都不行 + $query->where("start_time BETWEEN {$start_time} AND {$end_time}"); + $query->whereOr("end_time BETWEEN {$start_time} AND {$end_time}"); + $query->whereOr("start_time <= {$start_time} AND end_time >= {$end_time}"); + $query->whereOr("start_time >= {$start_time} AND end_time <= {$end_time}"); + }) + ->where("classes_lib_id",$classes_lib_id) + ->find(); + + if($spec_time_exist){ + $this->error("该课程下,{$spec_time_exist['name']}课时的开始和结束时间与你有重叠"); + } } diff --git a/application/admin/controller/school/classes/VirtualUser.php b/application/admin/controller/school/classes/VirtualUser.php index 41a0b06..2e8adee 100644 --- a/application/admin/controller/school/classes/VirtualUser.php +++ b/application/admin/controller/school/classes/VirtualUser.php @@ -34,7 +34,9 @@ class VirtualUser extends Backend $this->view->assign("havetypeList", $this->model->getHavetypeList()); } - + protected function update_classes($classes_lib_id){ + \app\common\model\school\classes\ClassesLib::update_classes($classes_lib_id); + } /** * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 @@ -81,6 +83,9 @@ class VirtualUser extends Backend + + + /** * 添加 * @@ -113,6 +118,8 @@ class VirtualUser extends Backend // $result = $this->model->allowField(true)->save($params); if(!$params["classes_lib_id"])throw new Exception( "请选择课程"); $res = (new Virtual)->getVirtualUser($params["num"],$params["classes_lib_id"],$params["time"],true); + + $this->update_classes($params["classes_lib_id"]); $result = true; Db::commit(); } catch (ValidateException|PDOException|Exception $e) { @@ -125,4 +132,57 @@ class VirtualUser extends Backend $this->success(); } + + + + /** + * 编辑 + * + * @param $ids + * @return string + * @throws DbException + * @throws \think\Exception + */ + public function edit($ids = null) + { + $row = $this->model->get($ids); + if (!$row) { + $this->error(__('No Results were found')); + } + $adminIds = $this->getDataLimitAdminIds(); + if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) { + $this->error(__('You have no permission')); + } + if (false === $this->request->isPost()) { + $this->view->assign('row', $row); + return $this->view->fetch(); + } + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + $params = $this->preExcludeFields($params); + $result = false; + Db::startTrans(); + try { + //是否采用模型验证 + if ($this->modelValidate) { + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; + $row->validateFailException()->validate($validate); + } + $result = $row->allowField(true)->save($params); + $this->update_classes($row["classes_lib_id"]); + + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if (false === $result) { + $this->error(__('No rows were updated')); + } + $this->success(); + } + } diff --git a/application/admin/model/school/Message.php b/application/admin/model/school/Message.php index e9c6ab0..32d46c1 100644 --- a/application/admin/model/school/Message.php +++ b/application/admin/model/school/Message.php @@ -2,10 +2,11 @@ namespace app\admin\model\school; +use app\common\model\BaseModel; use think\Model; -class Message extends Model +class Message extends BaseModel { diff --git a/application/admin/model/school/classes/ClassesLib.php b/application/admin/model/school/classes/ClassesLib.php index a5e313f..6b3bba2 100644 --- a/application/admin/model/school/classes/ClassesLib.php +++ b/application/admin/model/school/classes/ClassesLib.php @@ -2,6 +2,7 @@ namespace app\admin\model\school\classes; +use app\manystore\model\Manystore; use think\Model; use traits\model\SoftDelete; @@ -203,7 +204,7 @@ class ClassesLib extends Model public function manystore() { - return $this->belongsTo('app\admin\model\Manystore', 'manystore_id', 'id', [], 'LEFT')->setEagerlyType(0); + return $this->belongsTo(Manystore::class, 'manystore_id', 'id', [], 'LEFT')->setEagerlyType(0); } diff --git a/application/admin/model/school/classes/ClassesSpec.php b/application/admin/model/school/classes/ClassesSpec.php index c049492..2b7a62c 100644 --- a/application/admin/model/school/classes/ClassesSpec.php +++ b/application/admin/model/school/classes/ClassesSpec.php @@ -2,10 +2,11 @@ namespace app\admin\model\school\classes; +use app\common\model\BaseModel; use think\Model; use traits\model\SoftDelete; -class ClassesSpec extends Model +class ClassesSpec extends BaseModel { use SoftDelete; diff --git a/application/admin/view/school/classes/classes_lib/add.html b/application/admin/view/school/classes/classes_lib/add.html index ddc36d2..f18bccf 100644 --- a/application/admin/view/school/classes/classes_lib/add.html +++ b/application/admin/view/school/classes/classes_lib/add.html @@ -215,12 +215,12 @@ -
- -
- -
-
+ + + + + + diff --git a/application/admin/view/school/classes/classes_lib/edit.html b/application/admin/view/school/classes/classes_lib/edit.html index 7d3dc21..2bc0ac1 100644 --- a/application/admin/view/school/classes/classes_lib/edit.html +++ b/application/admin/view/school/classes/classes_lib/edit.html @@ -6,6 +6,45 @@ + +
+ +
+ +
+ {foreach name="statusList" item="vo"} + + {/foreach} +
+ +
+
+
+ +
+ +
+ {foreach name="authStatusList" item="vo"} + + {/foreach} +
+ +
+
+
+ +
+ +
+
+ +


+ + + + + +
@@ -258,36 +297,7 @@ -
- -
- -
- {foreach name="statusList" item="vo"} - - {/foreach} -
-
-
-
- -
- -
- {foreach name="authStatusList" item="vo"} - - {/foreach} -
- -
-
-
- -
- -
-
diff --git a/application/admin/view/user/user/edit.html b/application/admin/view/user/user/edit.html index f7c50f8..80ec703 100644 --- a/application/admin/view/user/user/edit.html +++ b/application/admin/view/user/user/edit.html @@ -19,6 +19,27 @@
+ + + +
+ +
+ +
+
+ + +
+ +
+ +
+
+ + + +
diff --git a/application/api/controller/Common.php b/application/api/controller/Common.php index dcac0bf..ae81e42 100644 --- a/application/api/controller/Common.php +++ b/application/api/controller/Common.php @@ -19,7 +19,7 @@ use think\Hook; */ class Common extends Api { - protected $noNeedLogin = ['init', 'captcha','virtualgenerate']; + protected $noNeedLogin = ['init', 'captcha','virtualgenerate','get_week_by_time']; protected $noNeedRight = '*'; public function _initialize() @@ -193,4 +193,29 @@ class Common extends Api $this->success('生成成功', $res); } + + + /** + * @ApiTitle(通过时间点得到当前的星期数据) + * @ApiSummary(通过时间点得到当前的星期数据) + * @ApiRoute(/api/common/get_week_by_time) + * @ApiMethod(GET) + * @ApiParams(name="time",type="string",required=true,description="选择的时间点") + * @ApiReturn({ unpaid_user_data 参与中 paid_user_data 已报名 }) + */ + public function get_week_by_time(){ + $time = $this->request->get('time/s',''); + + if(empty($time)){ + $this->error(__('缺少必要参数')); + } + try { + $res = (new Virtual)->getWeekByTime($time); + } catch (\Exception $e){ +// Log::log($e->getMessage()); + $this->error($e->getMessage(),['errcode'=>$e->getCode()]); + } + $this->success('生成成功', $res); + } + } diff --git a/application/common/controller/ManystoreBase.php b/application/common/controller/ManystoreBase.php index 393526f..fa0fe0a 100644 --- a/application/common/controller/ManystoreBase.php +++ b/application/common/controller/ManystoreBase.php @@ -256,9 +256,9 @@ class ManystoreBase extends Controller if($manystoreShop){ $url = Session::get('referer'); $url = $url ? $url : $this->request->url(); - if($manystoreShop["status"] !=1) { - $this->error(__('账号正处于审核中,无法进行任何操作!!'), url('index/login', ['url' => $url])); - } +// if($manystoreShop["status"] !=1) { +// $this->error(__('账号正处于审核中,无法进行任何操作!!'), url('index/login', ['url' => $url])); +// } $manystore = Manystore::where("id",$this->auth->id)->find(); if($manystore) { if($manystore["status"]!="normal") $this->error(__('账号正处于审核中,无法进行任何操作!!'), url('index/login', ['url' => $url])); diff --git a/application/common/hooks.php b/application/common/hooks.php index 7c0374e..611469b 100644 --- a/application/common/hooks.php +++ b/application/common/hooks.php @@ -79,6 +79,21 @@ $manystoreHooks = [ +//课程审核事件钩子 +$classesHooks = [ + // 订单创建 + 'classes_auth_need_after' => [ // 课程审核提交 + 'app\\common\\listener\\classes\\ClassesHook' + ], + 'classes_auth_success_after' => [ // 课程审核通过后 + 'app\\common\\listener\\classes\\ClassesHook' + ], + 'classes_auth_fail_after' => [ // 课程审核失败后 + 'app\\common\\listener\\classes\\ClassesHook' + ], +]; + + // //if (file_exists(ROOT_PATH . 'addons/shopro/listener/commission')) { @@ -86,5 +101,6 @@ $manystoreHooks = [ //} $defaultHooks = array_merge_recursive($defaultHooks, $hourHooks); $defaultHooks = array_merge_recursive($defaultHooks, $manystoreHooks); +$defaultHooks = array_merge_recursive($defaultHooks, $classesHooks); return $defaultHooks; diff --git a/application/common/library/Virtual.php b/application/common/library/Virtual.php index a746577..956220f 100644 --- a/application/common/library/Virtual.php +++ b/application/common/library/Virtual.php @@ -29,7 +29,7 @@ class Virtual //mysql随机查询$num个数据 $virtualHead = VirtualHead::orderRaw("rand()")->limit($num)->select(); //随机获得$num个虚拟用户昵称和头像 - foreach($virtualHead as $v) { + foreach($virtualHead as $k=>$v) { $nickname = $this->getNickName(); $head = $v->head_image; $r = rand(($time - 86400*7),$time); @@ -39,7 +39,7 @@ class Virtual "head_image"=>$head, "time"=>$r, "jointype" => "1", - "havetype" => "".($r % 2) + "havetype" => "".($k % 2) ]; } @@ -48,7 +48,7 @@ class Virtual }else{ $user_data=[]; - foreach($users as $user) { + foreach($users as $k=> $user) { $r = rand(($time - 86400*7),$time); $user_data[] = [ "nickname"=>$user["nickname"], @@ -56,12 +56,31 @@ class Virtual "classes_lib_id"=>$classes_lib_id, "time"=>$r, "jointype" => "1", - "havetype" => "".($r % 2) + "havetype" => $user["havetype"] ]; } (new VirtualUser)->saveAll($user_data); + + \app\common\model\school\classes\ClassesLib::update_classes($classes_lib_id); return $user_data; } + + } + + + public static function getWeekByTime($time){ + $time = $time && !is_numeric($time) ? strtotime($time) : time(); + + //得到当前日期所在周几 + $week = date("w",$time); + $week = $week == 0 ? '7' : $week; + + $sub = 7 -$week; + + $start_time = $time - ($sub*86400); + date("Y-m-d",$start_time); + + return ; } diff --git a/application/common/listener/classes/ClassesHook.php b/application/common/listener/classes/ClassesHook.php index a0d26f1..40997f7 100644 --- a/application/common/listener/classes/ClassesHook.php +++ b/application/common/listener/classes/ClassesHook.php @@ -8,92 +8,76 @@ class ClassesHook - // 机构账号提交审核申请后 - public function shopApplyAfter(&$params) + // 课程审核提交 + public function classesAuthNeedAfter(&$params) { - ["shop"=>$shop] = $params; + ['classes' => $classes] = $params; + //课程推送给老师 + $desc = "您的新课程{$classes['title']}已提交审核,审核时间为1-3日内,请耐心等待审核结果"; - - //记录订单日志 - - $desc = "您申请的认证{$shop['name']}已提交审核,审核时间为1-3日内,请耐心等待审核结果"; - - $title = "入驻申请提交"; - $mini_type = "shop_apply"; + $title = "新课程审核"; + $mini_type = "classes_apply"; $to_type="user"; - $to_id = $shop["user_id"]; - $status ="system"; + $to_id = $classes["user_id"]; + $status ="classes"; $platform="user"; $oper_id=0; $oper_type="system"; $params=[ - "event"=>"shop_create_after", - "shop_id"=>$shop["id"], - "desc"=>$shop["desc"], + "event"=>"classes_auth_need_after", + "classes_lib_id"=>$classes["id"], ]; Message::send($title,$desc,$mini_type,$to_id,$to_type,$status,$platform,$params,$oper_id,$oper_type); - - } - // 机构账号审核成功后 - public function shopAuthSuccessAfter(&$params) + // 课程审核通过后 + public function classesAuthSuccessAfter(&$params) { - ['shop' => $shop,"password"=>$password] = $params; - $user = $shop->user; - $mobile = $user['mobile'] ?? ""; - $shop_backend_url = config("site.shop_backend_ur"); - $desc = "您申请的认证:{$shop['name']}已审核通过,您可登录官方后台补充完其余资料,并开始发布课程
- 后台地址是: {$shop_backend_url}
- 账号是: {$shop['username']} 或 您的手机号 {$mobile}
- 初始化密码是: {$password}
-"; + ['classes' => $classes] = $params; - $title = "入驻申请通过"; - $mini_type = "shop_apply"; + //课程推送给老师 + $desc = "您的新课程{$classes['title']}已审核通过,可以在后台操作课程上架!"; + + $title = "新课程审核成功"; + $mini_type = "classes_apply"; $to_type="user"; - $to_id = $shop["user_id"]; - $status ="system"; + $to_id = $classes["user_id"]; + $status ="classes"; $platform="user"; $oper_id=0; $oper_type="system"; $params=[ - "event"=>"shop_auth_success_after", - "shop_id"=>$shop["id"], - "desc"=>$shop["desc"], + "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); - - } - // 机构账号审核失败后 - public function shopAuthFailAfter(&$params) + // 课程审核失败后 + public function classesFailNeedAfter(&$params) { - ["shop"=>$shop] = $params; + ['classes' => $classes] = $params; - //记录订单日志 + //课程推送给老师 + $desc = "您的新课程{$classes['title']}审核未通过,未通过原因为:{$classes['reason']},整改后,可以在后台重新提交!"; - $desc = "您申请的认证{$shop['name']}审核未通过,未通过原因为:{$shop['reason']},如已整改,可重新发起申请"; - - $title = "入驻申请失败"; - $mini_type = "shop_apply"; + $title = "新课程审核不通过"; + $mini_type = "classes_apply"; $to_type="user"; - $to_id = $shop["user_id"]; - $status ="system"; + $to_id = $classes["user_id"]; + $status ="classes"; $platform="user"; $oper_id=0; $oper_type="system"; $params=[ - "event"=>"shop_auth_fail_after", - "shop_id"=>$shop["id"], - "desc"=>$shop["desc"], + "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); diff --git a/application/common/model/school/classes/ClassesLib.php b/application/common/model/school/classes/ClassesLib.php index f788052..d8531c3 100644 --- a/application/common/model/school/classes/ClassesLib.php +++ b/application/common/model/school/classes/ClassesLib.php @@ -2,6 +2,7 @@ namespace app\common\model\school\classes; +use app\common\library\Virtual; use app\common\model\BaseModel; use app\common\model\dyqc\ManystoreShop; use app\common\model\school\classes\lib\Spec; @@ -581,10 +582,36 @@ class ClassesLib extends BaseModel if($classes_lib){ //所有课时加起来 $classes_lib->limit_num = ClassesSpec::where("classes_lib_id",$classes_lib_id)->sum( "limit_num"); + //更新虚拟用户数据 + //得到课程所有虚拟参与者数量 + $virtual_people = VirtualUser::where("jointype",'1')->where("classes_lib_id",$classes_lib_id)->count(); + //如果课程虚拟参与者字段 数量小于 虚拟参与者实际数量 ,则等于虚拟参与者实际数量 + $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; $classes_lib->save(); } } + public static function add_virtual_init($classes_lib_id){ + //更新课程规格库存 + $classes_lib = self::get($classes_lib_id); + if($classes_lib){ + //如果课程虚拟参与者字300-2000随机 + $classes_lib->virtual_people = mt_rand(300, 2000); + //如果课程虚拟报名者字段 + $classes_lib->virtual_num = 0; + $classes_lib->save(); + //生成20个虚拟参与者 + (new Virtual())->getVirtualUser(20,$classes_lib_id,time(),true); + } + } + + + } diff --git a/application/common/model/school/classes/ClassesSpec.php b/application/common/model/school/classes/ClassesSpec.php index 38dfd31..266be84 100644 --- a/application/common/model/school/classes/ClassesSpec.php +++ b/application/common/model/school/classes/ClassesSpec.php @@ -82,6 +82,6 @@ class ClassesSpec extends Model public function lib() { - return $this->belongsTo('Lib', 'classes_lib_id', 'id', [], 'LEFT')->setEagerlyType(0); + return $this->belongsTo(ClassesLib::class, 'classes_lib_id', 'id', [], 'LEFT')->setEagerlyType(0); } } diff --git a/application/common/model/school/classes/hourorder/Order.php b/application/common/model/school/classes/hourorder/Order.php index 1057d2a..b9aaf3b 100644 --- a/application/common/model/school/classes/hourorder/Order.php +++ b/application/common/model/school/classes/hourorder/Order.php @@ -555,6 +555,9 @@ class Order extends BaseModel $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'; @@ -847,6 +850,61 @@ class Order extends BaseModel } } + + + //判断是否是免费课 + $lib = $classes_lib_spec_info->lib; + if(!$lib){ + throw new \Exception("该课时课程信息缺失!"); + } + + if($lib["price"] == 0){ + //免费课开始和结束时间有交叠无法下预约 + if(!config("site.free_time_overlap_check")){ + //如果是免费课 + //判断时间是否有交叠 + $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']},无法再预约其他免费课程"); + + + } + + } + + if(!config("site.all_time_overlap_check")){ + //判断时间是否有交叠 + $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("{$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']},无法再预约其他课程"); + } + } diff --git a/application/manystore/controller/school/classes/ClassesLib.php b/application/manystore/controller/school/classes/ClassesLib.php index e7b4052..f0cc0d9 100644 --- a/application/manystore/controller/school/classes/ClassesLib.php +++ b/application/manystore/controller/school/classes/ClassesLib.php @@ -225,6 +225,12 @@ class ClassesLib extends ManystoreBase $params["user_id"] = $teacher["user_id"]; + //课时必须大于等于1 + if($params["classes_num"] < 1) $this->error("课时必须大于等于1"); + //售价必须大于0 + if($params["price"] < 0) $this->error("售价必须大于0"); + + //独立地点需传定位信息 if($params["address_type"] == "2"){ if(empty($params["address_city"]) @@ -329,9 +335,23 @@ class ClassesLib extends ManystoreBase $this->have_auth = true; } + //如果是上架,判断是否拥有课时规格,没有则无法上架 + if($params["status"]=="1"){ + if(!$row)$this->error("新添加的课程请先至少添加一个课时规格后再上架!"); + //判断是否拥有课时规格,没有则无法上架 + $check_spec = \app\common\model\school\classes\ClassesSpec::where("classes_lib_id",$row->id)->count(); + if(!$check_spec)$this->error("新添加的课程请先至少添加一个课时规格后再上架!"); + + } + + + + } - + protected function update_classes($classes_lib_id){ + \app\common\model\school\classes\ClassesLib::update_classes($classes_lib_id); + } /** @@ -366,7 +386,8 @@ class ClassesLib extends ManystoreBase } $this->update_check($params,$row=null); $result = $this->model->allowField(true)->save($params); - + \app\common\model\school\classes\ClassesLib::add_virtual_init($this->model["id"]); + $this->update_classes($this->model["id"]); if($this->have_auth){ //调用通过事件 $data = ['classes' => $this->model]; @@ -425,8 +446,8 @@ class ClassesLib extends ManystoreBase } $this->update_check($params,$row); - $result = $row->allowField(true)->save($params); + $this->update_classes($row["id"]); if($this->have_auth){ //调用通过事件 diff --git a/application/manystore/controller/school/classes/ClassesSpec.php b/application/manystore/controller/school/classes/ClassesSpec.php index 804e5d8..a412d26 100644 --- a/application/manystore/controller/school/classes/ClassesSpec.php +++ b/application/manystore/controller/school/classes/ClassesSpec.php @@ -139,12 +139,80 @@ class ClassesSpec extends ManystoreBase $this->error("店铺不存在"); } + //开始和结束时间不能为空 + $start_time = $params["start_time"]; + $end_time = $params["end_time"]; + if(empty($start_time) || empty($end_time)){ + $this->error("请选择开始和结束时间"); + } + //转化时间戳 + $start_time = $params["start_time"] && !is_numeric($params["start_time"]) ? strtotime($params["start_time"]) : $params["start_time"]; + $end_time = $params["end_time"] && !is_numeric($params["end_time"]) ? strtotime($params["end_time"]) : $params["end_time"]; + //结束时间不能小于开始时间 + if($end_time<=$start_time){ + $this->error("结束时间不能小于开始时间"); + } + + //结束时间不能是已经过去的时间 + $now_time = time(); + if($end_time<=$now_time){ + $this->error("结束时间不能是已经过去的时间"); + } + + + $orderTimeTableName = $this->model->getWithAlisaName(); //修改 if($row){ $this->updateCheck($row->id,$params,$row); + //规格名字不能一样(同课程下) + $spec_name = $params["name"]; + $classes_lib_id = $params["classes_lib_id"]; + $spec_name_exist = $this->model::where("name",$spec_name)->where("classes_lib_id",$classes_lib_id)->where("id","<>",$row->id)->find(); + if($spec_name_exist){ + $this->error("该课程下已存在该课时规格名称,请重新输入"); + } + + //同课程下,各个课时的开始和结束时间不能有重叠(出现时间交叠也不行) + $spec_time_exist = $this->model::where(function ($query) use ($orderTimeTableName,$start_time,$end_time) { + //兩個時間區間重合 存在任意交集 都不行 + $query->where("start_time BETWEEN {$start_time} AND {$end_time}"); + $query->whereOr("end_time BETWEEN {$start_time} AND {$end_time}"); + $query->whereOr("start_time <= {$start_time} AND end_time >= {$end_time}"); + $query->whereOr("start_time >= {$start_time} AND end_time <= {$end_time}"); + }) + ->where("classes_lib_id",$classes_lib_id) + ->where("id","<>",$row->id)->find(); + + if($spec_time_exist){ + $this->error("该课程下,{$spec_time_exist['name']}课时的开始和结束时间与你有重叠"); + } + }else{ + //规格名字不能一样(同课程下) + $spec_name = $params["name"]; + $classes_lib_id = $params["classes_lib_id"]; + $spec_name_exist = $this->model::where("name",$spec_name)->where("classes_lib_id",$classes_lib_id)->find(); + if($spec_name_exist){ + $this->error("该课程下已存在该课时规格名称,请重新输入"); + } + + //同课程下,各个课时的开始和结束时间不能有重叠(出现时间交叠也不行) + $spec_time_exist = $this->model::where(function ($query) use ($orderTimeTableName,$start_time,$end_time) { + //兩個時間區間重合 存在任意交集 都不行 + $query->where("start_time BETWEEN {$start_time} AND {$end_time}"); + $query->whereOr("end_time BETWEEN {$start_time} AND {$end_time}"); + $query->whereOr("start_time <= {$start_time} AND end_time >= {$end_time}"); + $query->whereOr("start_time >= {$start_time} AND end_time <= {$end_time}"); + }) + ->where("classes_lib_id",$classes_lib_id) + ->find(); + + if($spec_time_exist){ + $this->error("该课程下,{$spec_time_exist['name']}课时的开始和结束时间与你有重叠"); + } + } diff --git a/application/manystore/controller/school/classes/VirtualUser.php b/application/manystore/controller/school/classes/VirtualUser.php index c019d6d..382919a 100644 --- a/application/manystore/controller/school/classes/VirtualUser.php +++ b/application/manystore/controller/school/classes/VirtualUser.php @@ -39,6 +39,10 @@ class VirtualUser extends ManystoreBase parent::import(); } + protected function update_classes($classes_lib_id){ + \app\common\model\school\classes\ClassesLib::update_classes($classes_lib_id); + } + /** * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 @@ -111,6 +115,8 @@ class VirtualUser extends ManystoreBase // $result = $this->model->allowField(true)->save($params); if(!$params["classes_lib_id"])throw new Exception( "请选择课程"); $res = (new Virtual)->getVirtualUser($params["num"],$params["classes_lib_id"],$params["time"],true); + $this->update_classes($params["classes_lib_id"]); + $result = true; Db::commit(); } catch (ValidateException $e) { @@ -134,4 +140,58 @@ class VirtualUser extends ManystoreBase return $this->view->fetch(); } + + + /** + * 编辑 + */ + public function edit($ids = null) + { + if($this->shopIdAutoCondition){ + $this->model->where(array('shop_id'=>SHOP_ID)); + } + $row = $this->model->where(array('id'=>$ids))->find(); + if (!$row) { + $this->error(__('No Results were found')); + } + + if ($this->request->isPost()) { + $params = $this->request->post("row/a"); + if ($params) { + $params = $this->preExcludeFields($params); + $result = false; + Db::startTrans(); + try { + //是否采用模型验证 + if ($this->modelValidate) { + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; + $row->validateFailException(true)->validate($validate); + } + $result = $row->allowField(true)->save($params); + $this->update_classes($row["classes_lib_id"]); + + Db::commit(); + } catch (ValidateException $e) { + Db::rollback(); + $this->error($e->getMessage()); + } catch (PDOException $e) { + Db::rollback(); + $this->error($e->getMessage()); + } catch (Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if ($result !== false) { + $this->success(); + } else { + $this->error(__('No rows were updated')); + } + } + $this->error(__('Parameter %s can not be empty', '')); + } + $this->view->assign("row", $row); + return $this->view->fetch(); + } + } diff --git a/application/manystore/controller/user/User.php b/application/manystore/controller/user/User.php new file mode 100644 index 0000000..685b4f7 --- /dev/null +++ b/application/manystore/controller/user/User.php @@ -0,0 +1,72 @@ +model = new \app\manystore\model\user\User; + + } + + public function import() + { + parent::import(); + } + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + + + /** + * 查看 + */ + public function index() + { + //设置过滤方法 + $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(); + // $where[] = [$aliasName.'shop_id','eq',SHOP_ID]; + $user_ids = Order::where("shop_id",SHOP_ID)->where("status","<>","-3")->column("user_id"); + + + $list = $this->model + ->where($where) + ->where("id","in",$user_ids) + ->order($sort, $order) + ->paginate($limit); + + $result = array("total" => $list->total(), "rows" => $list->items()); + + return json($result); + } + return $this->view->fetch(); + } + +} diff --git a/application/manystore/lang/zh-cn/user/user.php b/application/manystore/lang/zh-cn/user/user.php new file mode 100644 index 0000000..611a513 --- /dev/null +++ b/application/manystore/lang/zh-cn/user/user.php @@ -0,0 +1,35 @@ + 'ID', + 'Group_id' => '组别ID', + 'Username' => '用户名', + 'Nickname' => '昵称', + 'Realname' => '真实姓名', + 'Work' => '职业', + 'Password' => '密码', + 'Salt' => '密码盐', + 'Email' => '电子邮箱', + 'Mobile' => '手机号', + 'Avatar' => '头像', + 'Level' => '等级', + 'Gender' => '性别', + 'Birthday' => '生日', + 'Bio' => '格言', + 'Money' => '余额', + 'Score' => '积分', + 'Successions' => '连续登录天数', + 'Maxsuccessions' => '最大连续登录天数', + 'Prevtime' => '上次登录时间', + 'Logintime' => '登录时间', + 'Loginip' => '登录IP', + 'Loginfailure' => '失败次数', + 'Loginfailuretime' => '最后登录失败时间', + 'Joinip' => '加入IP', + 'Jointime' => '加入时间', + 'Createtime' => '创建时间', + 'Updatetime' => '更新时间', + 'Token' => 'Token', + 'Status' => '状态', + 'Verification' => '验证' +]; diff --git a/application/manystore/model/school/classes/ClassesLib.php b/application/manystore/model/school/classes/ClassesLib.php index 4dd8950..ee04257 100644 --- a/application/manystore/model/school/classes/ClassesLib.php +++ b/application/manystore/model/school/classes/ClassesLib.php @@ -2,6 +2,7 @@ namespace app\manystore\model\school\classes; +use app\manystore\model\Manystore; use think\Model; use traits\model\SoftDelete; @@ -198,7 +199,7 @@ class ClassesLib extends Model public function manystore() { - return $this->belongsTo('app\manystore\model\Manystore', 'manystore_id', 'id', [], 'LEFT')->setEagerlyType(0); + return $this->belongsTo(Manystore::class, 'manystore_id', 'id', [], 'LEFT')->setEagerlyType(0); } diff --git a/application/manystore/model/school/classes/ClassesSpec.php b/application/manystore/model/school/classes/ClassesSpec.php index f8e4504..143b4e5 100644 --- a/application/manystore/model/school/classes/ClassesSpec.php +++ b/application/manystore/model/school/classes/ClassesSpec.php @@ -2,10 +2,11 @@ namespace app\manystore\model\school\classes; +use app\common\model\BaseModel; use think\Model; use traits\model\SoftDelete; -class ClassesSpec extends Model +class ClassesSpec extends BaseModel { use SoftDelete; diff --git a/application/manystore/model/user/User.php b/application/manystore/model/user/User.php new file mode 100644 index 0000000..cacd83d --- /dev/null +++ b/application/manystore/model/user/User.php @@ -0,0 +1,87 @@ + [], + 'edit' => [], + ]; + +} diff --git a/application/manystore/view/general/profile/index.html b/application/manystore/view/general/profile/index.html index 8af6e5d..1223450 100644 --- a/application/manystore/view/general/profile/index.html +++ b/application/manystore/view/general/profile/index.html @@ -62,6 +62,9 @@

{$manystore.username|htmlentities}

{$manystore.email|htmlentities}

+ +

所属前端用户ID: [{$manystore.user_id|htmlentities}]

+
-
- -
- -
-
+ + + + + + -
- -
- -
-
+ + + + + + diff --git a/application/manystore/view/school/classes/classes_lib/edit.html b/application/manystore/view/school/classes/classes_lib/edit.html index 3568f27..9227a76 100644 --- a/application/manystore/view/school/classes/classes_lib/edit.html +++ b/application/manystore/view/school/classes/classes_lib/edit.html @@ -1,5 +1,46 @@
+
+ +
+ +
+ {foreach name="authStatusList" item="vo"} + + {/foreach} +
+ {if ( $row.auth_status == 2) } + (不通过原因:{$row.reason}) + {else /} + + {/if} + +
+
+ + + + +
+ +
+ +
+ {foreach name="statusList" item="vo"} + + {/foreach} +
+ +
+
+ +


+ @@ -246,40 +287,8 @@ -
- -
-
- {foreach name="statusList" item="vo"} - - {/foreach} -
-
-
-
- -
- -
- {foreach name="authStatusList" item="vo"} - - {/foreach} -
- {if ( $row.auth_status == 2) } - (不通过原因:{$row.reason}) - {else /} - - {/if} - -
-
@@ -354,6 +363,9 @@
+ + +
diff --git a/application/manystore/view/user/user/add.html b/application/manystore/view/user/user/add.html new file mode 100644 index 0000000..20d6789 --- /dev/null +++ b/application/manystore/view/user/user/add.html @@ -0,0 +1,108 @@ + + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ + +
+ +
+
    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + {:build_heading()} + +
    +
    +
    +
    +
    + + + + + + + + + + + + + + +
    + +
    +
    +
    + +
    +
    +
    diff --git a/public/assets/js/backend/manystore/index.js b/public/assets/js/backend/manystore/index.js index 5475962..738ab62 100644 --- a/public/assets/js/backend/manystore/index.js +++ b/public/assets/js/backend/manystore/index.js @@ -25,7 +25,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, - {field: 'operate', title: __('Operate'),width:750, table: table , buttons: [ + {field: 'operate', title: __('Operate'),width:900, table: table , buttons: [ {name: 'free', text: '免登录进入机构后台', icon: 'fa fa-sign-in', @@ -110,8 +110,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin }, { name: 'order', - text: __('机构课程订单'), - title: __('机构课程订单'), + text: __('机构课程购买订单'), + title: __('机构课程购买订单'), classname: 'btn btn-xs btn-primary btn-dialog', icon: 'fa fa-list', url: order_url, @@ -122,6 +122,20 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin // return row.status == '2'||row.status == '3'; // } }, + { + name: 'hourorder', + text: __('机构课时预约记录'), + title: __('机构课时预约记录'), + classname: 'btn btn-xs btn-primary btn-dialog', + icon: 'fa fa-list', + url: hourorder_url, + callback: function (data) { + + }, + // visible: function (row) { + // return row.status == '2'||row.status == '3'; + // } + }, // // {name: 'unsetmockauth', @@ -155,7 +169,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'email', title: __('Email')}, {field: 'status', title: __("Status"), formatter: Table.api.formatter.status}, {field: 'shop.status', title: __('Auth_status'), searchList: {"0":__('Auth_status 0'),"1":__('Auth_status 1'),"2":__('Auth_status 2')}, formatter: Table.api.formatter.status}, - {field: 'user_id', title: __('User_id'),visible:false}, + {field: 'user_id', title: __('User_id')}, {field: 'shop.type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal}, {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'}, @@ -163,7 +177,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'user.avatar', title: __('User.avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image}, - + // {field: 'user_id', title: __('申请姓名|机构名'), operate: 'LIKE'}, {field: 'shop.name', title: __('申请姓名|机构名'), operate: 'LIKE'}, {field: 'shop.logo', title: __('Logo'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, {field: 'shop.image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, @@ -299,6 +313,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin return 'school/classes/order/order/index?shop_id='+row.id; } + //hourorder_url + var hourorder_url = function (row,dom) { + return 'school/classes/hourorder/order/index?shop_id='+row.id; + } return Controller; }); diff --git a/public/assets/js/backend/school/classes/classes_lib.js b/public/assets/js/backend/school/classes/classes_lib.js index 4756850..858afe6 100644 --- a/public/assets/js/backend/school/classes/classes_lib.js +++ b/public/assets/js/backend/school/classes/classes_lib.js @@ -88,6 +88,20 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin // return row.status == '2'||row.status == '3'; // } }, + { + name: 'classes_hourorder', + text: __('课时预约记录'), + title: __('课时预约记录'), + classname: 'btn btn-xs btn-danger btn-magic btn-dialog', + icon: 'fa fa-list', + url: classes_hourorder_url, + callback: function (data) { + + }, + // visible: function (row) { + // return row.status == '2'||row.status == '3'; + // } + }, // // {name: 'unsetmockauth', // text: '取消加圈资格', @@ -118,6 +132,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'feel', title: __('是否免费'), searchList: {"0":__('付费课程'),"1":__('免费课程')}, formatter: Table.api.formatter.normal}, + {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3')}, formatter: Table.api.formatter.status}, {field: 'classes_cate_title', title: __('Classes_cate_ids'), operate: false, formatter: Table.api.formatter.flag}, {field: 'classes_label_title', title: __('Classes_label_ids'), operate: false, formatter: Table.api.formatter.flag}, @@ -128,7 +143,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'headimage', title: __('Headimage'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, {field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images}, - {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3')}, formatter: Table.api.formatter.status}, {field: 'reason', title: __('Reason'), operate: 'LIKE' }, {field: 'auth_time', title: __('Auth_time'), operate:'RANGE',visible:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, @@ -143,7 +157,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'sale', title: __('Sale')}, {field: 'price', title: __('Price'), operate:'BETWEEN'}, {field: 'underline_price', title: __('Underline_price'), operate:'BETWEEN'}, - {field: 'admin_id', title: __('Admin_id'),visible:false}, + {field: 'admin_id', title: __('Admin_id'),visible:false}, {field: 'weigh', title: __('Weigh'), operate: false}, {field: 'recommend', title: __('Recommend'), searchList: {"0":__('Recommend 0'),"1":__('Recommend 1')}, formatter: Table.api.formatter.normal}, {field: 'hot', title: __('Hot'), searchList: {"0":__('Hot 0'),"1":__('Hot 1')}, formatter: Table.api.formatter.normal}, @@ -364,5 +378,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin } + var classes_hourorder_url = function (row,dom) { + return 'school/classes/hourorder/order/index?classes_lib_id='+row.id; + } + + return Controller; }); diff --git a/public/assets/js/backend/school/classes/hourorder/order.js b/public/assets/js/backend/school/classes/hourorder/order.js index ed74dd6..46cffa6 100644 --- a/public/assets/js/backend/school/classes/hourorder/order.js +++ b/public/assets/js/backend/school/classes/hourorder/order.js @@ -78,6 +78,20 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin // visible: function (row) { // return row.status == '2'||row.status == '3'; // } + }, + { + name: 'order_detail', + text: __('课程信息'), + title: __('课程信息'), + classname: 'btn btn-xs btn-primary btn-dialog', + icon: 'fa fa-list', + url: order_detail_url, + callback: function (data) { + + }, + // visible: function (row) { + // return row.paytime; + // } }, // // {name: 'unsetmockauth', @@ -111,6 +125,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'start_time', title: __('Start_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'end_time', title: __('End_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, + {field: 'auth_status', title: __('Auth_status'), searchList: {"0":__('Auth_status 0'),"1":__('Auth_status 1'),"2":__('Auth_status 2')}, formatter: Table.api.formatter.status}, + + + {field: 'order_no', title: __('Order_no'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'classes_order_id',visible:false, title: __('Classes_order_id')}, {field: 'classes_lib_spec_id',visible:false, title: __('Classes_lib_spec_id')}, @@ -137,6 +155,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'classesorder.order_no', title: __('Order.order_no'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + + {field: 'manystore_id', title: __('Manystore_id'),visible:false}, + {field: 'shop_id', title: __('Shop_id'),visible:false}, + // {field: 'spec.name', title: __('Spec.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, // {field: 'lib.title', title: __('Lib.title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} @@ -249,5 +271,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin return 'school/classes/hourorder/order_log/index?classes_hour_order_id='+row.id; } + var order_detail_url = function (row,dom) { + return 'school/classes/order/order_detail/index?id='+row.classes_order_detail_id; + } + return Controller; }); diff --git a/public/assets/js/backend/school/message.js b/public/assets/js/backend/school/message.js index d6ed92d..56e2f5c 100644 --- a/public/assets/js/backend/school/message.js +++ b/public/assets/js/backend/school/message.js @@ -29,7 +29,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {checkbox: true}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}, - {field: 'id', title: __('Id'),sortable: true}, + {field: 'id', title: __('Id')}, {field: 'weigh', title: __('Weigh'), operate: false,sortable: true}, {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal}, diff --git a/public/assets/js/backend/user/user.js b/public/assets/js/backend/user/user.js index 2920e0a..d573e5e 100644 --- a/public/assets/js/backend/user/user.js +++ b/public/assets/js/backend/user/user.js @@ -24,10 +24,62 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, + {field: 'operate', title: __('Operate'), table: table , buttons: [ + { + name: 'third', + text: __('三方账号信息'), + title: __('三方账号信息'), + classname: 'btn btn-xs btn-danger btn-magic btn-dialog', + icon: 'fa fa-list', + url: third_url, + callback: function (data) { + + }, + // visible: function (row) { + // return row.status == '2'||row.status == '3'; + // } + }, + + + { + name: 'classes_order', + text: __('课程购买单'), + title: __('课程购买单'), + classname: 'btn btn-xs btn-danger btn-magic btn-dialog', + icon: 'fa fa-list', + url: classes_order_url, + callback: function (data) { + + }, + // visible: function (row) { + // return row.status == '2'||row.status == '3'; + // } + }, + + { + name: 'classes_hourorder', + text: __('课时预约单'), + title: __('课时预约单'), + classname: 'btn btn-xs btn-danger btn-magic btn-dialog', + icon: 'fa fa-list', + url: classes_hourorder_url, + callback: function (data) { + + }, + // visible: function (row) { + // return row.status == '2'||row.status == '3'; + // } + }, + + ], events: Table.api.events.operate, formatter: Table.api.formatter.operate}, + + {field: 'id', title: __('Id'), sortable: true}, {field: 'group.name', title: __('Group')}, {field: 'username', title: __('Username'), operate: 'LIKE'}, {field: 'nickname', title: __('Nickname'), operate: 'LIKE'}, + {field: 'realname', title: __('真实姓名'), operate: 'LIKE'}, + {field: 'work', title: __('职业'), operate: 'LIKE'}, {field: 'email', title: __('Email'), operate: 'LIKE'}, {field: 'mobile', title: __('Mobile'), operate: 'LIKE'}, {field: 'avatar', title: __('Avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false}, @@ -41,7 +93,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'jointime', title: __('Jointime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true}, {field: 'joinip', title: __('Joinip'), formatter: Table.api.formatter.search}, {field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {normal: __('Normal'), hidden: __('Hidden')}}, - {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] }); @@ -89,5 +141,19 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin } } }; + + + var third_url = function (row,dom) { + return 'third/index?user_id='+row.id; + } + //classes_order_url + var classes_order_url = function (row,dom) { + return 'school/classes/order/order/index?user_id='+row.id; + } + //classes_hourorder_url + var classes_hourorder_url = function (row,dom) { + return 'school/classes/hourorder/order/index?user_id='+row.id; + } + return Controller; }); \ No newline at end of file diff --git a/public/assets/js/manystore/school/classes/classes_lib.js b/public/assets/js/manystore/school/classes/classes_lib.js index 6e1c1c1..049d482 100644 --- a/public/assets/js/manystore/school/classes/classes_lib.js +++ b/public/assets/js/manystore/school/classes/classes_lib.js @@ -84,6 +84,20 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin // return row.status == '2'||row.status == '3'; // } }, + { + name: 'classes_hourorder', + text: __('课时预约记录'), + title: __('课时预约记录'), + classname: 'btn btn-xs btn-danger btn-magic btn-dialog', + icon: 'fa fa-list', + url: classes_hourorder_url, + callback: function (data) { + + }, + // visible: function (row) { + // return row.status == '2'||row.status == '3'; + // } + }, // {name: 'unsetmockauth', // text: '取消加圈资格', // icon: 'fa fa-sign-in', @@ -113,6 +127,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'feel', title: __('是否免费'), searchList: {"0":__('付费课程'),"1":__('免费课程')}, formatter: Table.api.formatter.normal}, + {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3')}, formatter: Table.api.formatter.status}, {field: 'classes_cate_title', title: __('Classes_cate_ids'), operate: false, formatter: Table.api.formatter.flag}, @@ -124,7 +139,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'headimage', title: __('Headimage'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, {field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images}, - {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3')}, formatter: Table.api.formatter.status}, {field: 'reason', title: __('Reason'), operate: 'LIKE' }, {field: 'auth_time', title: __('Auth_time'), operate:'RANGE',visible:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, @@ -359,5 +373,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin return 'school/classes/order/order/index?classes_lib_id='+row.id +'&shop_id='+row.shop_id; } + var classes_hourorder_url = function (row,dom) { + return 'school/classes/hourorder/order/index?classes_lib_id='+row.id; + } + return Controller; }); diff --git a/public/assets/js/manystore/school/classes/hourorder/order.js b/public/assets/js/manystore/school/classes/hourorder/order.js index b94e90c..489ff3a 100644 --- a/public/assets/js/manystore/school/classes/hourorder/order.js +++ b/public/assets/js/manystore/school/classes/hourorder/order.js @@ -76,6 +76,20 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin // visible: function (row) { // return row.status == '2'||row.status == '3'; // } + }, + { + name: 'order_detail', + text: __('课程信息'), + title: __('课程信息'), + classname: 'btn btn-xs btn-primary btn-dialog', + icon: 'fa fa-list', + url: order_detail_url, + callback: function (data) { + + }, + // visible: function (row) { + // return row.paytime; + // } }, // // {name: 'unsetmockauth', @@ -110,6 +124,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'start_time', title: __('Start_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'end_time', title: __('End_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, + {field: 'auth_status', title: __('Auth_status'), searchList: {"0":__('Auth_status 0'),"1":__('Auth_status 1'),"2":__('Auth_status 2')}, formatter: Table.api.formatter.status}, + + {field: 'order_no', title: __('Order_no'), operate: 'LIKE'}, {field: 'classes_order_id',visible:false, title: __('Classes_order_id')}, {field: 'classes_lib_spec_id',visible:false, title: __('Classes_lib_spec_id')}, @@ -136,6 +153,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'schoolclassesorder.order_no',visible:false, title: __('Schoolclassesorder.order_no'), operate: 'LIKE'}, + + + {field: 'manystore_id', title: __('Manystore_id'),visible:false}, + {field: 'shop_id', title: __('Shop_id'),visible:false}, + // {field: 'schoolclasseslibspec.name',visible:false, title: __('Schoolclasseslibspec.name'), operate: 'LIKE'}, // {field: 'schoolclasseslib.title',visible:false, title: __('Schoolclasseslib.title'), operate: 'LIKE'}, // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} @@ -240,5 +262,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin return 'school/classes/hourorder/order_log/index?classes_hour_order_id='+row.id; } + + var order_detail_url = function (row,dom) { + return 'school/classes/order/order_detail/index?id='+row.classes_order_detail_id; + } + return Controller; }); \ No newline at end of file diff --git a/public/assets/js/manystore/user/user.js b/public/assets/js/manystore/user/user.js new file mode 100644 index 0000000..54bf724 --- /dev/null +++ b/public/assets/js/manystore/user/user.js @@ -0,0 +1,128 @@ +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { + + var Controller = { + index: function () { + // 初始化表格参数配置 + Table.api.init({ + extend: { + index_url: 'user/user/index' + location.search, + add_url: 'user/user/add', + edit_url: 'user/user/edit', + del_url: 'user/user/del', + multi_url: 'user/user/multi', + import_url: 'user/user/import', + table: 'user', + } + }); + + var table = $("#table"); + + // 初始化表格 + table.bootstrapTable({ + url: $.fn.bootstrapTable.defaults.extend.index_url, + pk: 'id', + sortName: 'id', + columns: [ + [ + {checkbox: true}, + + {field: 'operate', title: __('Operate'), table: table , buttons: [ + { + name: 'classes_order', + text: __('课程购买记录'), + title: __('课程购买记录'), + classname: 'btn btn-xs btn-danger btn-magic btn-dialog', + icon: 'fa fa-list', + url: classes_order_url, + callback: function (data) { + + }, + // visible: function (row) { + // return row.status == '2'||row.status == '3'; + // } + }, + + { + name: 'classes_hourorder', + text: __('课时预约记录'), + title: __('课时预约记录'), + classname: 'btn btn-xs btn-danger btn-magic btn-dialog', + icon: 'fa fa-list', + url: classes_hourorder_url, + callback: function (data) { + + }, + // visible: function (row) { + // return row.status == '2'||row.status == '3'; + // } + }, + + ], events: Table.api.events.operate, formatter: Table.api.formatter.operate}, + + + + {field: 'id', title: __('Id')}, + // {field: 'group_id', title: __('Group_id')}, + // {field: 'username', title: __('Username'), operate: 'LIKE'}, + {field: 'nickname', title: __('Nickname'), operate: 'LIKE'}, + {field: 'realname', title: __('Realname'), operate: 'LIKE'}, + {field: 'work', title: __('Work'), operate: 'LIKE'}, + // {field: 'password', title: __('Password'), operate: 'LIKE'}, + // {field: 'salt', title: __('Salt'), operate: 'LIKE'}, + // {field: 'email', title: __('Email'), operate: 'LIKE'}, + {field: 'bio', title: __('Bio'), operate: 'LIKE'}, + {field: 'mobile', title: __('Mobile'), operate: 'LIKE'}, + {field: 'avatar', title: __('Avatar'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, + // {field: 'level', title: __('Level')}, + // {field: 'gender', title: __('Gender')}, + // {field: 'birthday', title: __('Birthday'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + // {field: 'bio', title: __('Bio'), operate: 'LIKE'}, + // {field: 'money', title: __('Money'), operate:'BETWEEN'}, + // {field: 'score', title: __('Score')}, + // {field: 'successions', title: __('Successions')}, + // {field: 'maxsuccessions', title: __('Maxsuccessions')}, + // {field: 'prevtime', title: __('Prevtime')}, + // {field: 'logintime', title: __('Logintime')}, + // {field: 'loginip', title: __('Loginip'), operate: 'LIKE'}, + // {field: 'loginfailure', title: __('Loginfailure')}, + // {field: 'loginfailuretime', title: __('Loginfailuretime')}, + // {field: 'joinip', title: __('Joinip'), operate: 'LIKE'}, + // {field: 'jointime', title: __('Jointime')}, + // {field: 'createtime', title: __('Createtime')}, + // {field: 'updatetime', title: __('Updatetime')}, + // {field: 'token', title: __('Token'), operate: 'LIKE'}, + // {field: 'status', title: __('Status'), operate: 'LIKE', formatter: Table.api.formatter.status}, + // {field: 'verification', title: __('Verification'), operate: 'LIKE'}, + // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + ] + ] + }); + + // 为表格绑定事件 + Table.api.bindevent(table); + }, + add: function () { + Controller.api.bindevent(); + }, + edit: function () { + Controller.api.bindevent(); + }, + api: { + bindevent: function () { + Form.api.bindevent($("form[role=form]")); + } + } + }; + + + + var classes_order_url = function (row,dom) { + return 'school/classes/order/order/index?user_id='+row.id; + } + //classes_hourorder_url + var classes_hourorder_url = function (row,dom) { + return 'school/classes/hourorder/order/index?user_id='+row.id; + } + + return Controller; +}); \ No newline at end of file