From 2f5e30e6d64a073c7d08897cb9db50580a21e60f Mon Sep 17 00:00:00 2001 From: lqmac Date: Wed, 27 Mar 2024 22:46:08 +0800 Subject: [PATCH] 1 --- .DS_Store | Bin 10244 -> 8196 bytes .gitignore | 3 +- application/.DS_Store | Bin 6148 -> 6148 bytes .../controller/institution/Priselecturer.php | 497 ++++++++++++++++++ .../admin/controller/live/AliyunLive.php | 2 +- .../controller/store/StoreEntityCategory.php | 181 +++++++ .../admin/model/store/StoreEntityCategory.php | 94 ++++ .../view/institution/priselecturer/create.php | 411 +++++++++++++++ .../view/institution/priselecturer/index.php | 413 +++++++++++++++ .../priselecturer/lecturer_order.php | 133 +++++ .../institution/priselecturer/mercreate.php | 206 ++++++++ .../admin/view/special/lecturer/create.php | 2 +- .../store/store_entity_category/create.php | 215 ++++++++ .../store/store_entity_category/index.php | 224 ++++++++ application/common.php | 20 + application/wap/controller/Clearance.php | 269 ++++++++++ application/wap/controller/Index.php | 36 +- application/wap/controller/My.php | 74 ++- application/wap/controller/Special.php | 31 +- application/wap/controller/Topic.php | 15 +- .../wap/model/activity/EventRegistration.php | 25 +- .../model/institution/InstitutionFollow.php | 2 +- .../wap/model/merchant/MerchantFollow.php | 2 +- application/wap/model/store/StoreCart.php | 2 +- .../wap/model/topic/ExaminationRecord.php | 11 + application/wap/model/user/Message.php | 26 + application/wap/model/user/MessageType.php | 26 + application/wap/model/wap/City.php | 26 + application/wap/model/wap/Clearance.php | 26 + .../wap/model/wap/ClearanceSubject.php | 26 + .../wap/model/wap/ClearanceSubjectChapter.php | 26 + application/wap/model/wap/Feedback.php | 33 ++ application/wap/model/wap/Helpcenter.php | 33 ++ application/wap/model/wap/UserClearance.php | 26 + .../wap/model/wap/UserClearanceDetail.php | 26 + application/wap/model/wap/UserStudy.php | 26 + application/wap/view/first/live/index.html | 4 +- extend/service/ClearanceService.php | 87 +++ extend/service/MessageService.php | 18 + 39 files changed, 3246 insertions(+), 31 deletions(-) create mode 100755 application/admin/controller/institution/Priselecturer.php create mode 100755 application/admin/controller/store/StoreEntityCategory.php create mode 100755 application/admin/model/store/StoreEntityCategory.php create mode 100755 application/admin/view/institution/priselecturer/create.php create mode 100755 application/admin/view/institution/priselecturer/index.php create mode 100755 application/admin/view/institution/priselecturer/lecturer_order.php create mode 100755 application/admin/view/institution/priselecturer/mercreate.php create mode 100755 application/admin/view/store/store_entity_category/create.php create mode 100755 application/admin/view/store/store_entity_category/index.php create mode 100644 application/wap/controller/Clearance.php create mode 100644 application/wap/model/user/Message.php create mode 100644 application/wap/model/user/MessageType.php create mode 100644 application/wap/model/wap/City.php create mode 100644 application/wap/model/wap/Clearance.php create mode 100644 application/wap/model/wap/ClearanceSubject.php create mode 100644 application/wap/model/wap/ClearanceSubjectChapter.php create mode 100644 application/wap/model/wap/Feedback.php create mode 100644 application/wap/model/wap/Helpcenter.php create mode 100644 application/wap/model/wap/UserClearance.php create mode 100644 application/wap/model/wap/UserClearanceDetail.php create mode 100644 application/wap/model/wap/UserStudy.php create mode 100644 extend/service/ClearanceService.php create mode 100644 extend/service/MessageService.php diff --git a/.DS_Store b/.DS_Store index e25b16395a515a2d63cb2e4883bf6d8b5ea2c20a..3b5858a61ae57066c9fe105c01be637626f03a20 100644 GIT binary patch delta 105 zcmZn(XmOBWU|?W$DortDU;r^WfEYvza8E20o2aMAD7GnHmPD{nRvzR0q%vW;Dk8EgcD0ymI$1-Woz;dkcA{4#+e eOb~Z#fD|w?Fc^U7$ptdKlQ)YAZk{3Xi3tEePBORv diff --git a/.gitignore b/.gitignore index 1c975851..3cb0103e 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,5 @@ *.pid /public/public/qrcode /vendor/workerman/_www_wwwroot_zhishi.tczxkj.com_think.pid -sftp-config.json \ No newline at end of file +sftp-config.json +*.DS_Store \ No newline at end of file diff --git a/application/.DS_Store b/application/.DS_Store index 81b9086956cb27eb9c7a424a436802ac705972fc..d8112f89c78cfb65eb89c1bb03537ad5d729bd8f 100755 GIT binary patch delta 52 zcmZoMXfc@J&&aniU^g=(-((&ZU2#^1M1~ZGT!u`Byt3e;yqx^JbOr_n#?59d+nG1B IbNuB80Be5@=>Px# delta 31 ncmZoMXfc@J&&azmU^g=(?_?ep-Oa%)TbL&{NNr~4_{$FfnXCz| diff --git a/application/admin/controller/institution/Priselecturer.php b/application/admin/controller/institution/Priselecturer.php new file mode 100755 index 00000000..a07623e3 --- /dev/null +++ b/application/admin/controller/institution/Priselecturer.php @@ -0,0 +1,497 @@ +fetch(); + } + + /** + * 机构列表获取 + * @return + * */ + public function lecturer_list() + { + $where = parent::getMore([ + ['page', 1], + ['is_show', ''], + ['limit', 20], + ['title', ''], + ['entry_type',2], + ['mer_id',0] + + ]); + return JsonService::successlayui(LecturerModel::getLecturerList($where)); + } + + /**添加/编辑 + * @param int $id + * @return mixed|void + * @throws \think\exception\DbException + */ + public function create($id = 0) + { + $select_list = EducationModel::getSelectList(); + if ($id) { + $lecturer = LecturerModel::get($id); + $lecturer['label'] = json_decode($lecturer['label']); + $lecturer['introduction'] = htmlspecialchars_decode($lecturer['introduction']); + $qualifications = json_decode($lecturer['certificate'],true); + $cert_id = $lecturer['cert_id']; + if (!$lecturer) return JsonService::fail('机构信息不存在!'); + } else { + $lecturer = []; + $qualifications = count($select_list) == 0 ? '' : json_decode($select_list[0]['qualifications'],true); + $cert_id = count($select_list) == 0 ? 0 : $select_list[0]['id']; + } + $this->assign('cert_id', $cert_id); + $this->assign('all', json_encode($select_list)); + $this->assign('qualifications_list', json_encode($qualifications)); + $this->assign(['lecturer' => json_encode($lecturer), 'id' => $id]); + return $this->fetch(); + } + /** + * 添加和修改机构 + * @param int $id 修改 + * @return JsonService + * */ + public function save_lecturer($id = 0) + { + $data = parent::postMore([ + ['lecturer_name', ''], + ['lecturer_head', ''], + ['label', []], + ['phone', ''], + ['explain', ''], + ['introduction', ''], + ['sort', 0], + ['is_show', 1], + ['certificate', ''], + ['card_id', 0], + ['business_license',''], + ['corporate_name',''], + ['credit_code',''], + ['business_term',''], + ['card_straight',''], + ['card_side',''], + ['card_straight',''], + ['emial',''], + ]); + $data['lecturer_name'] = preg_replace("#(^( |\s)+|( |\s)+$)#", "", $data['lecturer_name']); + $data['entry_type'] = 2; + if (!$data['lecturer_name']) return JsonService::fail('请输入机构名称'); + if (mb_strlen($data['lecturer_name']) > 8) return JsonService::fail('机构名称不能超过8个字'); + if (!$data['lecturer_head']) return JsonService::fail('请输入机构头像'); + $data['label'] = json_encode($data['label']); + $data['introduction'] = htmlspecialchars($data['introduction']); + if ($id) { + LecturerModel::edit($data, $id); + return JsonService::successful('修改成功'); + } else { + $data['add_time'] = time(); + if (!LecturerModel::be(['lecturer_name' => $data['lecturer_name'], 'lecturer_head' => $data['lecturer_head'], 'label' => $data['label'], 'phone' => $data['phone'], 'is_del' => 0])) { + $res = LecturerModel::set($data); + } else { + return JsonService::fail('机构已存在'); + } + if ($res) + return JsonService::successful('添加成功'); + else + return JsonService::fail('添加失败'); + } + } + + /** + * 设置单个产品上架|下架 + * @param int $is_show 是否显示 + * @param int $id 修改的主键 + * @return JsonService + */ + public function set_show($is_show = '', $id = '') + { + ($is_show == '' || $id == '') && JsonService::fail('缺少参数'); + $res = parent::getDataModification('lecturer_institution', $id, 'is_show', (int)$is_show); + if ($res) { + $mer_id = LecturerModel::where('id', $id)->value('mer_id'); + if ($mer_id) { + $data['estate'] = $is_show; + InstitutionModel::edit($data, $mer_id, 'id'); + } + return JsonService::successful($is_show == 1 ? '显示成功' : '隐藏成功'); + } else { + return JsonService::fail($is_show == 1 ? '显示失败' : '隐藏失败'); + } + } + + /** + * 快速编辑 + * @param string $field 字段名 + * @param int $id 修改的主键 + * @param string value 修改后的值 + * @return JsonService + */ + public function set_value($field = '', $id = '', $value = '') + { + ($field == '' || $id == '' || $value == '') && JsonService::fail('缺少参数'); + $res = parent::getDataModification('lecturer', $id, $field, $value); + if ($res) + return JsonService::successful('保存成功'); + else + return JsonService::fail('保存失败'); + } + + /** + * 删除机构 + * @param int $id 修改的主键 + * @return json + * */ + public function delete($id = 0) + { + if (!$id) return JsonService::fail('缺少参数'); + if (LecturerModel::delLecturer($id)) + return JsonService::successful('删除成功'); + else + return JsonService::fail(LecturerModel::getErrorInfo('删除失败')); + } + + /** + * 机构课程订单 + */ + public function lecturer_order($id = 0) + { + $this->assign([ + 'year' => getMonth('h'), + 'lecturer_id' => $id, + ]); + return $this->fetch(); + } + + /**机构课程购买记录 + * @throws \think\exception\DbException + */ + public function lecturer_order_list() + { + $where = parent::getMore([ + ['lecturer_id', 0], + ['page', 1], + ['limit', 10], + ['data', ''], + ]); + if (!$where['lecturer_id']) return JsonService::fail('缺少参数!'); + $lecturer = LecturerModel::get($where['lecturer_id']); + if (!$lecturer) return JsonService::fail('机构不存在!'); + $list = LecturerModel::lecturerOrderList($where); + return JsonService::successlayui($list); + } + + /** + * 机构盈利 + */ + public function getBadge() + { + $where = parent::postMore([ + ['lecturer_id', 0], + ['data', ''], + ]); + if (!$where['lecturer_id']) return JsonService::fail('缺少参数!'); + $lecturer = LecturerModel::get($where['lecturer_id']); + if (!$lecturer) return JsonService::fail('机构不存在!'); + $list = LecturerModel::getBadge($where); + return JsonService::successful($list); + } + + /** + * 添加推荐 + * @param int $special_id + * @return mixed + * @throws \think\exception\DbException + */ + public function web_recommend($lecturer_id = 0) + { + if (!$lecturer_id) $this->failed('缺少参数'); + $lecturer = LecturerModel::get($lecturer_id); + if (!$lecturer) $this->failed('没有查到此机构'); + if ($lecturer->is_del) $this->failed('此机构已删除'); + $form = Form::create(Url::build('save_web_recommend', ['lecturer_id' => $lecturer_id]), [ + Form::select('recommend_id', '推荐')->setOptions(function () { + $model = WebRecommend::where(['is_show' => 1, 'type' => 2]); + $list = $model->field('title,id')->order('sort desc,add_time desc')->select(); + $menus = []; + foreach ($list as $menu) { + $menus[] = ['value' => $menu['id'], 'label' => $menu['title']]; + } + return $menus; + })->filterable(1), + Form::number('sort', '排序'), + ]); + $form->setMethod('post')->setTitle('推荐设置')->setSuccessScript('parent.$(".J_iframe:visible")[0].contentWindow.location.reload(); setTimeout(function(){parent.layer.close(parent.layer.getFrameIndex(window.name));},800);'); + $this->assign(compact('form')); + return $this->fetch('public/form-builder'); + } + + /** + * 保存推荐 + * @param int $special_id + * @throws \think\exception\DbException + */ + public function save_web_recommend($lecturer_id = 0) + { + if (!$lecturer_id) $this->failed('缺少参数'); + $data = parent::postMore([ + ['recommend_id', 0], + ['sort', 0], + ]); + if (!$data['recommend_id']) return JsonService::fail('请选择推荐'); + $recommend = WebRecommend::get($data['recommend_id']); + if (!$recommend) return JsonService::fail('导航菜单不存在'); + $data['add_time'] = time(); + $data['type'] = $recommend->type; + $data['link_id'] = $lecturer_id; + if (WebRecommendRelation::be(['type' => $recommend->type, 'link_id' => $lecturer_id, 'recommend_id' => $data['recommend_id']])) return JsonService::fail('已推荐,请勿重复推荐'); + if (WebRecommendRelation::set($data)) + return JsonService::successful('推荐成功'); + else + return JsonService::fail('推荐失败'); + } + + /**取消推荐 + * @param int $id + */ + public function cancel_web_recommendation($id = 0, $lecturer_id = 0) + { + if (!$id || !$lecturer_id) return JsonService::fail('缺少参数'); + if (WebRecommendRelation::be(['id' => $id, 'link_id' => $lecturer_id])) { + $res = WebRecommendRelation::where(['id' => $id, 'link_id' => $lecturer_id])->delete(); + if ($res) + return JsonService::successful('取消推荐成功'); + else + return JsonService::fail('取消推荐失败'); + } else { + return JsonService::fail('推荐不存在'); + } + } + + /** + * 添加推荐 + * @param int $special_id + * @return mixed + * @throws \think\exception\DbException + */ + public function recommend($lecturer_id = 0) + { + if (!$lecturer_id) $this->failed('缺少参数'); + $lecturer = LecturerModel::get($lecturer_id); + if (!$lecturer) $this->failed('没有查到此机构'); + if ($lecturer->is_del) $this->failed('此机构已删除'); + $form = Form::create(Url::build('save_recommend', ['lecturer_id' => $lecturer_id]), [ + Form::select('recommend_id', '推荐')->setOptions(function () { + $model = Recommend::where(['is_show' => 1, 'type' => 6]); + $list = $model->field('title,id')->order('sort desc,add_time desc')->select(); + $menus = []; + foreach ($list as $menu) { + $menus[] = ['value' => $menu['id'], 'label' => $menu['title']]; + } + return $menus; + })->filterable(1), + Form::number('sort', '排序'), + ]); + $form->setMethod('post')->setTitle('推荐设置')->setSuccessScript('parent.$(".J_iframe:visible")[0].contentWindow.location.reload(); setTimeout(function(){parent.layer.close(parent.layer.getFrameIndex(window.name));},800);'); + $this->assign(compact('form')); + return $this->fetch('public/form-builder'); + } + + /** + * 保存推荐 + * @param int $special_id + * @throws \think\exception\DbException + */ + public function save_recommend($lecturer_id = 0) + { + if (!$lecturer_id) $this->failed('缺少参数'); + $data = parent::postMore([ + ['recommend_id', 0], + ['sort', 0], + ]); + if (!$data['recommend_id']) return JsonService::fail('请选择推荐'); + $recommend = Recommend::get($data['recommend_id']); + if (!$recommend) return JsonService::fail('导航菜单不存在'); + $data['add_time'] = time(); + $data['type'] = $recommend->type; + $data['link_id'] = $lecturer_id; + if (RecommendRelation::be(['type' => $recommend->type, 'link_id' => $lecturer_id, 'recommend_id' => $data['recommend_id']])) return JsonService::fail('已推荐,请勿重复推荐'); + if (RecommendRelation::set($data)) + return JsonService::successful('推荐成功'); + else + return JsonService::fail('推荐失败'); + } + + /**取消推荐 + * @param int $id + */ + public function cancel_recommendation($id = 0, $lecturer_id = 0) + { + if (!$id || !$lecturer_id) return JsonService::fail('缺少参数'); + if (RecommendRelation::be(['id' => $id, 'link_id' => $lecturer_id])) { + $res = RecommendRelation::where(['id' => $id, 'link_id' => $lecturer_id])->delete(); + if ($res) + return JsonService::successful('取消推荐成功'); + else + return JsonService::fail('取消推荐失败'); + } else { + return JsonService::fail('推荐不存在'); + } + } + + /**生成机构后台 + * @return mixed + */ + public function mercreate($id) + { + $lecturer = LecturerModel::get($id); + $this->assign([ + 'title' => '添加机构后台', + 'lecturer' => json_encode($lecturer), + 'action' => Url::build('save'), + 'menus' => json(InstitutionMenus::ruleList())->getContent() + ]); + return $this->fetch(); + } + + /** + * 添加机构商户 + */ + public function save() + { + $data = parent::postMore([ + 'account', + ['id', 0], + ['uid', 0], + 'conf_pwd', + 'pwd', + 'mer_name', + 'real_name', + 'mer_phone', + 'mer_avatar', + 'mer_special_divide', + 'mer_store_divide', + 'mer_event_divide', + 'mer_data_divide', + 'mer_test_divide', + 'gold_divide', + 'mark', + 'mer_address', + ['checked_menus', [], '', 'rules'], + ['is_source', 0], + ['is_audit', 0], + ['status', 0] + ]); + if (!is_array($data['rules']) || !count($data['rules'])) return JsonService::fail('请选择最少一个权限'); + $data['rules'] = implode(',', $data['rules']); + if (!$data['account']) return JsonService::fail('请输入机构后台账号'); + if (InstitutionAdminModel::where('account', trim($data['account']))->where('is_del', 0)->count()) return JsonService::fail('商户账号已存在,请使用别的商户账号注册'); + if (!$data['pwd']) return JsonService::fail('请输入机构后台登陆密码'); + if ($data['pwd'] != $data['conf_pwd']) return JsonService::fail('两次输入密码不相同'); + if (!$data['mer_name']) return JsonService::fail('请输入机构后台名称'); + if (!$data['uid']) return JsonService::fail('请输入绑定的用户ID'); + $user = User::where('uid', $data['uid'])->find(); + if (!$user) { + return JsonService::fail('绑定的用户不存在'); + } else { + if ($user['business'] == 1) { + return JsonService::fail('该用户已是讲师/机构'); + } + } + $id = $data['id']; + $data['pwd'] = trim(md5($data['pwd'])); + $data['reg_time'] = time(); + $data['add_time'] = time(); + $data['reg_admin_id'] = $this->adminId; + $data['lecturer_id'] = $id; + $data['estate'] = 1; + $admin = array(); + $admin['account'] = trim($data['account']); + $admin['pwd'] = $data['pwd']; + unset($data['id']); + unset($data['conf_pwd']); + unset($data['account']); + unset($data['pwd']); + InstitutionModel::beginTrans(); + $res = InstitutionModel::set($data); + $res1 = false; + if ($res) { + $admin['uid'] = $data['uid']; + $admin['mer_id'] = $res->id; + $admin['real_name'] = $data['mer_name']; + $admin['rules'] = $data['rules']; + $admin['phone'] = $data['mer_phone']; + $admin['add_time'] = time(); + $admin['status'] = 1; + $admin['level'] = 0; + $res1 = InstitutionAdminModel::set($admin); + } + $bool = false; + if ($res1 && $res) $bool = true; + InstitutionModel::checkTrans($bool); + if ($bool) { + LecturerModel::where('id', $id)->update(['mer_id' => $res->id, 'lecturer_name' => $data['mer_name'], 'phone' => $data['mer_phone']]); + Special::where('lecturer_id', $id)->update(['mer_id' => $res->id]); + User::where('uid', $data['uid'])->update(['business' => 1]); + Db::name('cache_merchant')->insert( + [ + 'mer_id' => $res->id, + 'add_time' => time(), + 'key'=> 'wechat_menus', + 'result' => '[{"type":"view","name":"\u8bb2\u5e08\u9996\u9875","sub_button":[],"url":"https:\/\/www.ideaketang.com\/\/h5"},{"type":"click","name":"\u5e73\u53f0\u9996\u9875","sub_button":[],"key":"https:\/\/www.ideaketang.com\/h5"},{"type":"view","name":"\u670d\u52a1\u4e2d\u5fc3","sub_button":[],"key":"https:\/\/www.ideaketang.com\/h5","url":"https:\/\/www.ideaketang.com\/h5"}]' + ] + + ); + return JsonService::successful('添加机构后台成功!'); + } else { + return JsonService::successful('添加机构后台失败!'); + } + + } + + public function select_list(){ + $data = parent::getMore([ + ['id', 0] + ]); + $select_list = EducationModel::where('id',$data['id'])->find(); + $select_list['qualifications'] = json_decode($select_list['qualifications'],true); + $data = $select_list['qualifications']; + foreach($data as &$item){ + if($item['event_value'] == 3){ + $item['eventValue'] = implode(',',$item['event_value']); + } + } + return JsonService::successful($select_list); + } +} diff --git a/application/admin/controller/live/AliyunLive.php b/application/admin/controller/live/AliyunLive.php index bce580af..f4ca6fe5 100755 --- a/application/admin/controller/live/AliyunLive.php +++ b/application/admin/controller/live/AliyunLive.php @@ -97,7 +97,7 @@ class AliyunLive extends AuthController { if (!$field || !$id) return Json::fail('缺少参数'); $value = str_replace('免密', '', $value); - $res = parent::getDataModification('studio', $id, $field, $value); + $res = parent::getDataModification('live_studio', $id, $field, $value); if ($res) return Json::successful('修改成功'); else diff --git a/application/admin/controller/store/StoreEntityCategory.php b/application/admin/controller/store/StoreEntityCategory.php new file mode 100755 index 00000000..50952753 --- /dev/null +++ b/application/admin/controller/store/StoreEntityCategory.php @@ -0,0 +1,181 @@ +fetch(); + } + + public function get_category_list() + { + $where = parent::getMore([ + ['page', 1], + ['limit', 20], + ['grade_id', 0], + ['name', ''] + ]); + return Json::successful(StoreEntityCategoryModel::getAllList($where)); + } + + /** + * 创建分类 + * @param int $id + * @return mixed + * @throws \think\exception\DbException + */ + public function create($id = 0) + { + $cate = $id > 0 ? StoreEntityCategoryModel::get($id) : []; + // var_dump($cate); + // exit(); + $this->assign(['cate' => json_encode($cate), 'id' => $id]); + return $this->fetch(); + } + + public function get_cate_list() + { + $category = StoreEntityCategoryModel::taskCategoryAll(2); + return Json::successful($category); + } + + public function add_cate_list() + { + $category = StoreEntityCategoryModel::where(['grade_id' => 0, 'is_del' => 0])->select(); + $category = count($category) > 0 ? $category->toArray() : []; + $array = []; + $oneCate['id'] = 0; + $oneCate['name'] = '顶级分类'; + array_push($array, $oneCate); + foreach ($category as $key => $value) { + array_push($array, $value); + } + return Json::successful($array); + } + + /** + * 快速编辑 + * + * @return json + */ + public function set_value($field = '', $id = '', $value = '') + { + $field == '' || $id == '' || $value == '' && Json::fail('缺少参数'); + $res = parent::getDataModification('store_entity_category', $id, $field, $value); + if ($res) + return Json::successful('保存成功'); + else + return Json::fail('保存失败'); + } + + /** + * 新增或者修改 + * + * @return json + */ + public function save($id = 0) + { + $post = parent::postMore([ + ['name', ''], + ['grade_id', ''], + ['is_recommend', ''], + ['is_show', ''], + ['pic', ''], + ['sort', 0] + ]); + if (!$post['name']) return Json::fail('请输入分类名称'); + if ($id) { + $cate = StoreEntityCategoryModel::get($id); + if (!$cate['grade_id'] && $post['grade_id'] && StoreEntityCategoryModel::be(['grade_id' => $id, 'is_del' => 0])) return Json::fail('无法移动有下级的分类'); + if (StoreEntityCategoryModel::where(['name' => $post['name'], 'is_del' => 0])->where('id', '<>', $id)->count() >= 1) return Json::fail('分类名称已存在'); + $res = StoreEntityCategoryModel::edit($post, $id); + if ($res) + return Json::successful('修改成功'); + else + return Json::fail('修改失败'); + } else { + $post['add_time'] = time(); + if (StoreEntityCategoryModel::be(['name' => $post['name'], 'is_del' => 0])) { + return Json::fail('分类名称已存在!'); + } + $res = StoreEntityCategoryModel::set($post); + if ($res) + return Json::successful('添加成功'); + else + return Json::fail('添加失败'); + } + } + + /** + * 删除 + * + * @return json + */ + public function delete($id = 0) + { + if (!$id) return Json::fail('缺少参数'); + $cate = StoreEntityCategoryModel::get($id); + if (!$cate['grade_id']) { + $count = StoreEntityCategoryModel::where('grade_id', $id)->where(['is_del' => 0])->count(); + if ($count) return Json::fail('暂无法删除,请删除下级分类'); + } + // if (QuestionsModel::where('pid', $id)->where(['is_del' => 0, 'mer_id' => 0])->count()) return Json::fail('暂无法删除,请先删除题目'); + $res = parent::getDataModification('store_entity_category', $id, 'is_del', 1); + if ($res) + return Json::successful('删除成功'); + else + return Json::fail('删除失败'); + } + /**二级分是否显示快捷操作 + * @param string $is_show + * @param string $id + * @return mixed + */ + public function set_show($is_show = '', $id = '') + { + ($is_show == '' || $id == '') && Json::fail('缺少参数'); + $res = parent::getDataModification('store_entity_category', $id, 'is_show', (int)$is_show); + if ($res) { + return Json::successful($is_show == 1 ? '显示成功' : '隐藏成功'); + } else { + return Json::fail($is_show == 1 ? '显示失败' : '隐藏失败'); + } + } + /**二级分是否显示快捷操作 + * @param string $is_show + * @param string $id + * @return mixed + */ + public function set_recommend($is_recommend = '', $id = '') + { + ($is_recommend == '' || $id == '') && Json::fail('缺少参数'); + $res = parent::getDataModification('store_entity_category', $id, 'is_recommend', (int)$is_recommend); + if ($res) { + return Json::successful($is_recommend == 1 ? '显示成功' : '隐藏成功'); + } else { + return Json::fail($is_recommend == 1 ? '显示失败' : '隐藏失败'); + } + } + + + +} diff --git a/application/admin/model/store/StoreEntityCategory.php b/application/admin/model/store/StoreEntityCategory.php new file mode 100755 index 00000000..6f308a1f --- /dev/null +++ b/application/admin/model/store/StoreEntityCategory.php @@ -0,0 +1,94 @@ + 0]); + if ($type == 1) { + $model = $model->where('grade_id', 0); + } + $list = $model->order('sort desc,add_time desc')->select(); + $list = count($list) > 0 ? $list->toArray() : []; + $list = Util::sortListTier($list); + return $list; + } + + /** + * 试题分类列表 + */ + public static function getAllList($where) + { + $data = self::setWhere($where)->column('id,grade_id'); + $list = []; + foreach ($data as $ket => $item) { + $cate = self::where('id', $ket)->find(); + if ($cate) { + $cate = $cate->toArray(); + // if ($item > 0) { + // $cate['sum'] = QuestionsModel::where(['is_del' => 0])->where('grade_id', $ket)->count(); + // } else { + // $pids = self::categoryId($ket); + // $cate['sum'] = QuestionsModel::where(['is_del' => 0,])->where('grade_id', 'in', $pids)->count(); + // } + array_push($list, $cate); + unset($cate); + } + if ($item > 0 && !array_key_exists($item, $data)) { + $cate = self::where('id', $item)->find(); + if ($cate) { + $cate = $cate->toArray(); + $pids = self::categoryId($item); + //$cate['sum'] = QuestionsModel::where(['is_del' => 0])->where('grade_id', 'in', $pids)->count(); + array_push($list, $cate); + } + } + } + return $list; + } + + public static function setWhere($where) + { + $model = self::order('sort desc,add_time desc')->where(['is_del' => 0]); + if ($where['grade_id']) $model = $model->where('id', $where['grade_id']); + if ($where['name'] != '') $model = $model->where('name', 'like', "%$where[name]%"); + return $model; + } + + /**获取一个分类下的所有分类ID + * @param int $pid + */ + public static function categoryId($pid = 0) + { + $data = self::where(['is_del' => 0])->where('grade_id', $pid)->column('id'); + array_push($data, $pid); + return $data; + } + +} diff --git a/application/admin/view/institution/priselecturer/create.php b/application/admin/view/institution/priselecturer/create.php new file mode 100755 index 00000000..c00376aa --- /dev/null +++ b/application/admin/view/institution/priselecturer/create.php @@ -0,0 +1,411 @@ +{extend name="public/container"} +{block name='head_top'} + + + + + +{/block} +{block name="content"} +
+
+ +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+

+ + +

+
+
+
+
+

选择图片

+
+
+
+
+ +
+
+ +
+

+ + +

+
+
+
+
+

选择图片

+
+
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+ +
+ +
+
+ +
+

+ + +

+
+
+
+
+

选择图片

+
+
+
+
+
+ +
+
+
+ +
+
+ +
+

+ + +

+
+
+
+
+

选择图片

+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + +
+
+
+
+ + +
+
+ +
+
+
+ +{/block} +{block name='script'} + +{/block} diff --git a/application/admin/view/institution/priselecturer/index.php b/application/admin/view/institution/priselecturer/index.php new file mode 100755 index 00000000..597ff71f --- /dev/null +++ b/application/admin/view/institution/priselecturer/index.php @@ -0,0 +1,413 @@ +{extend name="public/container"} +{block name="content"} +
+
+
机构列表
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+
+ + +
+
+ + + + + + + + +
+
+
+ +{/block} +{block name="script"} + +{/block} diff --git a/application/admin/view/institution/priselecturer/lecturer_order.php b/application/admin/view/institution/priselecturer/lecturer_order.php new file mode 100755 index 00000000..8b6ebf1a --- /dev/null +++ b/application/admin/view/institution/priselecturer/lecturer_order.php @@ -0,0 +1,133 @@ +{extend name="public/container"} +{block name="content"} +
+
+
+
+
搜索条件
+
+
+
+
+ +
+ + + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+ {{item.name}} + {{item.field}} +
+
+

{{item.count}}

+

+ {{item.content}} + {{item.sum}} +

+
+
+
+ +
+
+
+
课程订单
+
+
+
+
+
+
+
+ + +{/block} diff --git a/application/admin/view/institution/priselecturer/mercreate.php b/application/admin/view/institution/priselecturer/mercreate.php new file mode 100755 index 00000000..d5c63d2a --- /dev/null +++ b/application/admin/view/institution/priselecturer/mercreate.php @@ -0,0 +1,206 @@ + + + + {include file="public/head"} + {$title|default=''} + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 入驻 + 平台 + + + + + 开启 + 关闭 + + + + + 开启 + 关闭 + + + + + + + 提交 + + +
+ + + diff --git a/application/admin/view/special/lecturer/create.php b/application/admin/view/special/lecturer/create.php index 138dc2de..b65037a8 100755 --- a/application/admin/view/special/lecturer/create.php +++ b/application/admin/view/special/lecturer/create.php @@ -113,7 +113,7 @@ {block name='script'} + + +{/block} +{block name='script'} + +{/block} diff --git a/application/admin/view/store/store_entity_category/index.php b/application/admin/view/store/store_entity_category/index.php new file mode 100755 index 00000000..53516ef7 --- /dev/null +++ b/application/admin/view/store/store_entity_category/index.php @@ -0,0 +1,224 @@ +{extend name="public/container"} +{block name="head"} + +{/block} +{block name="content"} +
+
+
+
+
商品分类
+
+
+
+
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+
+ +{/block} +{block name="script"} + +{/block} diff --git a/application/common.php b/application/common.php index 94fe1ab2..30379ff0 100755 --- a/application/common.php +++ b/application/common.php @@ -242,3 +242,23 @@ function getversion() } return $version_arr; } + +/** + * 数据多层级 + * @param array $data + * @param int $pid + * @return array + */ +function subTree(array $data, int $pid = 0) { + // 返回的结果 + $arr = []; + foreach ($data as $val) { + // 给定的PID是当前记录的上级ID + if ($pid == $val['pid']) { + // 递归 + $val['children'] = subTree($data,$val['id']); + $arr[] = $val; + } + } + return $arr; +} diff --git a/application/wap/controller/Clearance.php b/application/wap/controller/Clearance.php new file mode 100644 index 00000000..2dcf9317 --- /dev/null +++ b/application/wap/controller/Clearance.php @@ -0,0 +1,269 @@ +where('status',1)->order('sort DESC,id desc')->select(); + //刷题 + $brush_questions = ClearanceModel::where('type',2)->where('status',1)->order('sort DESC,id desc')->select(); + $activity = EventRegistration::eventRegistrationList(1, 4, $city, $subject_id, 0); + $uid = $this->uid; + $where = [ + 'grade_id' => 1, + 'subject_id' => $subject_id, + 'search' => '', + 'page' => 1, + 'limit' => 4, + 'type' => 0, + 'special_type' => 3, + 'is_member' => 0, + 'uid' => $uid, + ]; + $video = SpecialModel::getSpecialList($where); + $where['special_type'] = 4; + $live = SpecialModel::getSpecialList($where); + + + + $sql = "SELECT rank,days FROM (SELECT @rank:=@rank+1 as rank, user_id, days,cate_id FROM tc_user_clearance, (SELECT @rank:=0) r ORDER BY days DESC ) t WHERE user_id = ".$uid ." and cate_id = ".$subject_id; + $userClearance = Db::query($sql); + + $sql = "SELECT rank,recite_num FROM (SELECT @rank:=@rank+1 as rank, user_id, recite_num,cate_id FROM tc_user_clearance, (SELECT @rank:=0) r ORDER BY recite_num DESC ) t WHERE user_id = ".$uid ." and cate_id = ".$subject_id; + $userClearance1 = Db::query($sql); + + $sql = "SELECT rank,accuracy FROM (SELECT @rank:=@rank+1 as rank, user_id, accuracy,cate_id FROM tc_user_clearance, (SELECT @rank:=0) r ORDER BY accuracy DESC ) t WHERE user_id = ".$uid ." and cate_id = ".$subject_id; + $userClearance2 = Db::query($sql); + + //用户进入学习中心展示哪个科目问题处理 + if (!$subject_id) { + $userStudy = UserStudy::where('user_id', $this->uid)->find(); + if ($userStudy) { + $subject_id = $userStudy['cate_id']; + } else { + $specialSubject = SpecialSubject::where('is_show', 1)->where('is_del', 0)->find(); + $subject_id = $specialSubject['id']; + } + } + $specialSubject = SpecialSubject::where('id', $subject_id)->find(); + $test_paper = TestPaper::where('id',$specialSubject['exam_id'])->field('id,title as name')->select(); + // var_dump($res); + // var_dump($userClearance); + // exit(); + $date = date("Y-m-d"); + $recite_num = UserClearanceDetail::where('user_id', $this->uid)->where('type', 1)->group('section_id')->count(); + $brush_question_num = UserClearanceDetail::where('user_id', $this->uid)->where('type', 2)->group('item_id')->count(); + + $total_num = $specialSubject['recite_num'] + $specialSubject['brush_question_num']; + return JsonService::successful('ok', [ + 'exam' => [ + 'grade_id' => $specialSubject['grade_id'], + 'subject_id' => $subject_id, + 'name' => $specialSubject['name'], + 'date' => date("Y-m-d", $specialSubject['exam_time'] ?? 0), + 'distance_exam_day' => ceil((($specialSubject['exam_time'] ?? 0) - time()) / 86400), + ], + 'user_study' => [ + 'days' => $userClearance[0]['days'] ?? 0, + 'rank' => $userClearance[0]['rank'] ?? 0, + ], + 'user_recite' => [ + 'points' => $userClearance1[0]['recite_num'] ?? 0, + 'rank' => $userClearance1[0]['rank'] ?? 0, + ], + 'user_brush_questions' => [ + 'accuracy' => ($userClearance2[0]['accuracy'] ?? 0)."%", + 'rank' => $userClearance2[0]['rank'] ?? 0, + ], + 'user_clock_in' => [ + 'progress' => $total_num ? round(($recite_num + $brush_question_num) / $total_num ) : 0, + 'list' => $this->dealClockInRecord("", 1, 2), + ], + 'exam_list' => $test_paper, + 'banner' => GroupDataService::getData('mxtk_banner') ?: [], + 'recite' => $recite, + 'brush_questions' => $brush_questions, + 'video' => $video, + 'live' => $live, + 'offline_courses' => $activity, + ]); + } + /** + * 背诵过关 + * [clearanceSubject description] + * @return [type] [description] + */ + public function clearanceSubject($recite_id = 0){ + $recite_subject_list = ClearanceSubject::where('status',1)->where('recite_id',$recite_id)->order('sort DESC,id desc')->select(); + return JsonService::successful('ok', $recite_subject_list); + } + /** + * 背诵章节 + * [clearanceSubjectChapter description] + * @param integer $recite_subject_id [description] + * @return [type] [description] + */ + public function clearanceSubjectChapter($recite_subject_id = 0){ + $chapters = ClearanceSubjectChapter::where('status',1)->where('recite_subject_id',$recite_subject_id)->order('sort DESC,id desc')->select(); + $chapters = subTree($chapters->toArray()); + return JsonService::successful('ok', $chapters); + } + /** + * 背诵接口 + * [recite description] + * @param integer $chapter_id [description] + * @param integer $section_id [description] + * @return [type] [description] + */ + public function recite($chapter_id = 0, $section_id = 0){ + //var_dump($this->uid);exit(); + $info = ClearanceSubjectChapter::where('id', $section_id)->where('pid', $chapter_id)->find(); + if (!$info) { + return JsonService::fail('背诵内容不存在'); + } + $recite_subject = ClearanceSubject::where('id', $info['recite_subject_id'])->find(); + if (!$recite_subject) { + return JsonService::fail('背诵内容不存在'); + } + $recite = ClearanceModel::where('id', $recite_subject['recite_id'])->find(); + if (!$recite) { + return JsonService::fail('背诵内容不存在'); + } + + ClearanceService::clockIn($this->uid, $recite['subject_id'], 1, $recite['id'], $recite_subject['id'], $chapter_id, $section_id); + + return JsonService::successful('ok'); + } + + + protected function dealClockInRecord($date = "", $page = 1, $limit = 10){ + $date = $date ? $date : date("Y-m-d"); + $list = UserClearanceDetail::where('user_id', $this->uid)->where('date', $date)->order("id desc")->page($page, $limit)->select(); + foreach ($list as &$value) { + if ($value['type'] == 1) { + $chapter = ClearanceSubjectChapter::where('id',$value['chapter_id'])->find(); + $section = ClearanceSubjectChapter::where('id',$value['section_id'])->find(); + $value['name'] = ($chapter['name'] ?? "")." ".($section['name'] ?? ""); + } else { + $test_paper = TestPaper::where('id',$value['item_id'])->field('id,title as name')->find(); + $value['name'] = $test_paper['name'] ?? ""; + $hour = round($value['use_time'] / 3600); + $result = $value['use_time'] % 3600; + $minute = round($result / 60); + $value['use_time'] = $hour."小时".$minute."分"; + } + } + return $list; + } + + public function getMonthRecord($month){ + $start_time = strtotime("{$month}-01"); // 月份的开始时间 + $end_time = strtotime("+1 month", $start_time) - 1; // 月份的结束时间 + + $list = UserClearanceDetail::where('user_id', $this->uid)->where('add_time', ">=", $start_time)->where('add_time', "<=", $end_time)->field('date')->group('date')->select(); + return JsonService::successful('ok', $list); + } + /** + * 用户打卡记录 + * [clockInRecord description] + * @return [type] [description] + */ + public function clockInRecord($date = "", $page = 1, $limit = 10){ + + + $list = $this->dealClockInRecord($date, $page, $limit); + return JsonService::successful('ok', $list); + } + /** + * 学习项目切换 + * [study description] + * @param integer $cate_id [description] + * @return [type] [description] + */ + public function study($subject_id = 0){ + + $info = UserStudy::where('user_id', $this->uid)->find(); + if ($info) { + UserStudy::where('id', $info['id'])->update(['cate_id' => $subject_id, 'update_time' => time()]); + return JsonService::successful('ok'); + } + UserStudy::create(['user_id' => $this->uid, 'cate_id' => $subject_id, 'add_time' => time(), 'update_time' => time()]); + return JsonService::successful('ok'); + } + + + + + + + + + + + + + + + + +} diff --git a/application/wap/controller/Index.php b/application/wap/controller/Index.php index b1056e1b..ab7810aa 100755 --- a/application/wap/controller/Index.php +++ b/application/wap/controller/Index.php @@ -22,6 +22,7 @@ use app\wap\model\special\SpecialSubject; use app\wap\model\user\PhoneUser; use app\wap\model\user\User; use app\wap\model\wap\Search; +use app\wap\model\wap\City; use service\GroupDataService; use service\JsonService; use service\SystemConfigService; @@ -34,7 +35,6 @@ use think\Cookie; use think\Url; use think\Db; use service\JwtService; - /**首页控制器 * Class Index * @package app\wap\controller @@ -65,10 +65,32 @@ class Index extends AuthController 'qcode_login', 'get_search_history', 'agreeMa', - 'index_data' + 'index_data', + 'city_list', ]; } - + /** + * @return mixed + */ + public function city_list($search = "") + { + + $model = City::where('status', 1); + if ($search) { + $model = $model->where('name|first_letter', 'like', "%$search%"); + } + $city_list = $model->select(); + $hotList = []; + $list = []; + foreach ($city_list as $seq => &$item) { + if ($item['is_hot'] == 1) { + $hotList[] = $item; + } + $list[$item['first_letter']][] = $item; + } + $result = ['hotList'=>$hotList, "cityList"=>$list]; + return JsonService::successful($result); + } /** * @return mixed */ @@ -136,14 +158,14 @@ class Index extends AuthController //获取推荐列表 $exists_recommend_reids = false; $this->redisModel->HEXISTS($this->subjectUrl . "wap_index_has", "recommend_list"); - if (!$exists_recommend_reids) { + //if (!$exists_recommend_reids) { $is_member = isset($this->userInfo['level']) ? $this->userInfo['level'] : 0; $recommend_list = json_encode(Recommend::getContentRecommend($this->uid, $is_member)); $this->redisModel->hset($this->subjectUrl . "wap_index_has", "recommend_list", $recommend_list); $this->redisModel->expire($this->subjectUrl . "wap_index_has", 120); - } else { - $recommend_list = $this->redisModel->hget($this->subjectUrl . "wap_index_has", "recommend_list"); - } + // } else { + // $recommend_list = $this->redisModel->hget($this->subjectUrl . "wap_index_has", "recommend_list"); + // } } catch (\Exception $e) { } diff --git a/application/wap/controller/My.php b/application/wap/controller/My.php index 571d5afb..c7bfe687 100755 --- a/application/wap/controller/My.php +++ b/application/wap/controller/My.php @@ -32,6 +32,8 @@ use app\wap\model\user\UserBill; use app\wap\model\user\UserExtract; use app\wap\model\user\UserAddress; use app\wap\model\user\UserSign; +use app\wap\model\user\Message; +use app\wap\model\user\MessageType; use service\CacheService; use service\GroupDataService; use service\JsonService; @@ -44,7 +46,8 @@ use think\Url; use app\wap\model\recommend\Recommend; use app\wap\model\merchant\Merchant as MerchantModel; use app\wap\model\institution\Institution as InstitutionModel; - +use app\wap\model\wap\Feedback; +use app\wap\model\wap\Helpcenter; /**my 控制器 * Class My * @package app\wap\controller @@ -62,10 +65,43 @@ class My extends AuthController 'about_us', 'getPersonalCenterMenu', 'questionModule', - 'base_data_api' + 'base_data_api', + 'helpcenter', ]; } - + /** + * 未读消息总数 + * [unReadMsgNum description] + * @return [type] [description] + */ + public function unReadMsgNum(){ + $unReadMsgNum = Message::where('user_id', $this->uid)->where('is_read', 0)->count(); + return JsonService::successful(['unReadMsgNum' => $unReadMsgNum]); + } + /** + * 消息列表 + * [messageList description] + * @param integer $page [description] + * @param integer $limit [description] + * @return [type] [description] + */ + public function messageList($page = 1, $limit = 10){ + $list = Message::where('user_id', $this->uid)->page($page, $limit)->select()->toArray(); + if (!$list) { + return JsonService::successful($list); + } + $message_types = array_column($list, "message_type"); + $types = MessageType::whereIn('id', $message_types)->select()->toArray(); + $types = array_column($types, null, "id"); + foreach ($list as &$value) { + $value['message_types'] = $types[$value['message_type']] ?? []; + } + return JsonService::successful($list); + } + public function setReaded($id = 0){ + Message::where('id', $id)->update(['is_read' => 1,'update_time' => time()]); + return JsonService::successful("ok"); + } /** * 退出手机号码登录 */ @@ -572,7 +608,37 @@ class My extends AuthController 'content' => get_config_content('about_us'), ]); } - + /** + * 帮助中心 + * [helpcenter description] + * @return [type] [description] + */ + public function helpcenter(){ + $list = Helpcenter::where('status', 1)->order('sort DESC,add_time DESC')->select(); + return JsonService::successful([ + 'helpcenter' => $list + ]); + } + /** + * 提交反馈 + * [addfeedback description] + * @return [type] [description] + */ + public function addfeedback(){ + $data = UtilService::postMore([ + ['content', ''], + ], $this->request); + $inData = [ + 'content' => $data['content'], + 'user_id' => $this->uid, + 'add_time' => time(), + ]; + if (Feedback::create($inData)){ + return JsonService::successful('提交成功'); + } else { + return JsonService::fail('提交失败'); + } + } public function getUserGoldBill() { $user_info = $this->userInfo; diff --git a/application/wap/controller/Special.php b/application/wap/controller/Special.php index 8840a2cc..f53a974f 100755 --- a/application/wap/controller/Special.php +++ b/application/wap/controller/Special.php @@ -121,10 +121,25 @@ class Special extends AuthController 'data_details', 'exchange', 'question_index', + 'getSpecialSubject', 'special_validity' ]; } + /**获取分类 new + * @throws \think\exception\DbException + */ + public function getSpecialSubject() + { + $category = SpecialSubject::with('children')->where(['is_show' => 1, 'is_del' => 0])->order('sort desc,id desc')->where('grade_id', 0)->select(); + + $recommend = SpecialSubject::where(['is_show' => 1, 'is_del' => 0, 'is_recommend' => 1])->where('grade_id', 'neq', 0)->order('sort desc,id desc')->select(); + return JsonService::successful([ + 'category_list' => $category, + 'recommend' => $recommend + ]); + } + /**获取视频上传地址和凭证 * @param string $videoId * @param int $type @@ -177,6 +192,7 @@ class Special extends AuthController if ($order->total_num == $order->gift_count) return JsonService::fail('礼物已被领取完'); } $special = SpecialModel::getOneSpecial($this->uid, $id); + if ($special === false) return JsonService::fail(SpecialModel::getErrorInfo('无法访问')); $is_member = isset($this->userInfo['level']) ? $this->userInfo['level'] : 0; if (!isset($special['special'])) $this->failed('专题信息未获得', Url::build('index/index')); @@ -1833,10 +1849,11 @@ class Special extends AuthController */ public function grade_index() { - $category = SpecialSubject::where(['is_show' => 1, 'is_del' => 0])->order('sort desc,id desc')->where('grade_id', 1)->limit(7)->select(); + $category = SpecialSubject::where(['is_show' => 1, 'is_del' => 0])->order('sort desc,id desc')->where('is_recommend', 1)->limit(7)->select(); $is_member = isset($this->userInfo['level']) ? $this->userInfo['level'] : 0; $my = SpecialModel::getMyGradeList(1, 4, $this->uid, $is_member, 0); - $offlineCourse = (new \app\wap\model\special\OfflineCourse)->order('id desc')->limit(4)->select(); + //$offlineCourse = (new \app\wap\model\special\OfflineCourse)->order('id desc')->limit(4)->select(); + $activity = EventRegistration::eventRegistrationList(1, 4, "", 0 ,0); $uid = $this->uid; $hot = SpecialModel::getSpecialList(['grade_id' => 0, 'subject_id' => 0, 'search' => '', 'page' => 1, 'limit' => 4, 'type' => 0, 'uid' => $uid, 'is_hot' => 1]); @@ -1846,7 +1863,7 @@ class Special extends AuthController 'category_list' => $category->toArray(), 'my_course' => $my['list'], 'hot_course' => $hot, - 'offline_courses' => $offlineCourse, + 'offline_courses' => $activity, ]); } @@ -2330,8 +2347,12 @@ class Special extends AuthController */ public function getOrderPrice($cartId = '', $cateNum = 1) { - $res = StoreCart::changeUserCartNum($cartId, $cateNum, $this->uid); - if (!$res) return JsonService::fail('商品数量修改失败!'); + $cartIds = explode(",", $cartId); + $cateNums = explode(",", $cateNum); + foreach ($cartIds as $seq => $value) { + $res = StoreCart::changeUserCartNum($value, $cateNums[$seq] ?? 1, $this->uid); + if (!$res) return JsonService::fail('商品数量修改失败!'); + } $user = $this->userInfo; $cartGroup = StoreCart::getUserProductCartList($this->uid, $cartId, 1, $user['level']); $vip_price_subtract = bcmul($cartGroup['valid'][0]['productInfo']['vip_price'], $cateNum, 2); diff --git a/application/wap/controller/Topic.php b/application/wap/controller/Topic.php index 2fa33b90..01532f6e 100755 --- a/application/wap/controller/Topic.php +++ b/application/wap/controller/Topic.php @@ -523,21 +523,26 @@ class Topic extends AuthController */ public function specialTestPaper() { - list($special_id, $type) = UtilService::PostMore([ + list($special_id, $type, $relationship) = UtilService::PostMore([ ['special_id', 0], - ['type', 1], + ['type', 1],//试卷类型 1练习2考试 + ['relationship', 1], ], $this->request, true); if (!$special_id) return JsonService::fail('缺少参数,无法访问'); $data = []; switch ($type) { case 1: - $relationship = 1; + $relationship1 = 1; break; case 2: - $relationship = 2; + $relationship1 = 2; break; } - $test_ids = Relation::setWhere($relationship, $special_id)->column('relation_id'); + //兼容刷题过关的试卷 + if ($relationship > 2) { + $relationship1 = $relationship; + } + $test_ids = Relation::setWhere($relationship1, $special_id)->column('relation_id'); if (count($test_ids)) { $data = TestPaper::PreExercisesWhere()->where('type', $type)->where('id', 'in', $test_ids)->order('sort desc,id desc')->select(); $data = count($data) > 0 ? $data->toArray() : []; diff --git a/application/wap/model/activity/EventRegistration.php b/application/wap/model/activity/EventRegistration.php index 91ab5c90..6a4c2d1a 100755 --- a/application/wap/model/activity/EventRegistration.php +++ b/application/wap/model/activity/EventRegistration.php @@ -28,15 +28,36 @@ class EventRegistration extends ModelBasic * @param int $limit * @return array */ - public static function eventRegistrationList($page = 1, $limit = 10) + public static function eventRegistrationList($page = 1, $limit = 10, $city = "", $subject_id = 0, $type = "") { - $list = self::PreWhere()->order('sort DESC,add_time DESC')->page((int)$page, (int)$limit)->select(); + $where = []; + if ($city) { + $where['city'] = ['like',"%".$city."%"]; + } + if ($subject_id) { + $where['subject_id'] = $subject_id; + } + if ($type !== "") { + $where['type'] = $type; + } + $list = self::PreWhere()->where($where)->order('sort DESC,add_time DESC')->page((int)$page, (int)$limit)->select(); $list = count($list) > 0 ? $list->toArray() : []; foreach ($list as &$v) { $v = self::singleActivity($v); $start_time = date('y/m/d H:i', $v['start_time']); $end_time = date('y/m/d H:i', $v['end_time']); $v['time'] = $start_time . '~' . $end_time; + $v['baoming'] = $start_time . '~' . $end_time; + $v['start'] = date('y/m/d H:i', $v['signup_start_time']) . '~' . date('y/m/d H:i', $v['signup_end_time']); + $activity_status = 0; + if ($v['start_time'] < time()) { + $activity_status = 0; + } elseif ($v['start_time'] > time() && $v['end_time'] > time()) { + $activity_status = 1; + } elseif ($v['end_time'] < time()) { + $activity_status = 2; + } + $v['activity_status'] = $activity_status; $v['count'] = EventSignUp::signUpCount($v['id']); } return $list; diff --git a/application/wap/model/institution/InstitutionFollow.php b/application/wap/model/institution/InstitutionFollow.php index 88fdadbc..b9c34d15 100755 --- a/application/wap/model/institution/InstitutionFollow.php +++ b/application/wap/model/institution/InstitutionFollow.php @@ -53,7 +53,7 @@ class InstitutionFollow extends ModelBasic $data = self::alias('f')->where(['f.uid' => $uid, 'f.is_follow' => 1,'l.is_show' => 1, 'l.is_del' => 0]) ->join('Lecturer l', 'f.mer_id=l.mer_id') ->where('l.mer_id','>',0)->page((int)$page, (int)$limit) - ->order('f.follow_time desc')->field('f.uid,f.mer_id,f.is_follow,l.id,l.mer_id,l.is_show,l.is_del,l.lecturer_name,l.lecturer_head,l.label,l.introduction,l.study,l.curriculum') + ->order('f.follow_time desc')->field('f.uid,f.mer_id,f.is_follow,l.id,l.mer_id,l.is_show,l.is_del,l.lecturer_name,l.lecturer_head,l.label,l.introduction,l.study,l.curriculum,l.explain') ->select(); $data = count($data) > 0 ? $data->toArray() : []; return $data; diff --git a/application/wap/model/merchant/MerchantFollow.php b/application/wap/model/merchant/MerchantFollow.php index 7d9ae82e..883069a0 100755 --- a/application/wap/model/merchant/MerchantFollow.php +++ b/application/wap/model/merchant/MerchantFollow.php @@ -53,7 +53,7 @@ class MerchantFollow extends ModelBasic $data = self::alias('f')->where(['f.uid' => $uid, 'f.is_follow' => 1,'l.is_show' => 1, 'l.is_del' => 0]) ->join('Lecturer l', 'f.mer_id=l.mer_id') ->where('l.mer_id','>',0)->page((int)$page, (int)$limit) - ->order('f.follow_time desc')->field('f.uid,f.mer_id,f.is_follow,l.id,l.mer_id,l.is_show,l.is_del,l.lecturer_name,l.lecturer_head,l.label,l.introduction,l.study,l.curriculum') + ->order('f.follow_time desc')->field('f.uid,f.mer_id,f.is_follow,l.id,l.mer_id,l.is_show,l.is_del,l.lecturer_name,l.lecturer_head,l.label,l.introduction,l.study,l.curriculum,l.explain') ->select(); $data = count($data) > 0 ? $data->toArray() : []; return $data; diff --git a/application/wap/model/store/StoreCart.php b/application/wap/model/store/StoreCart.php index 849e45d0..fea33845 100755 --- a/application/wap/model/store/StoreCart.php +++ b/application/wap/model/store/StoreCart.php @@ -82,7 +82,7 @@ class StoreCart extends ModelBasic */ public static function removeUserCart($uid, $ids) { - return self::where('uid', $uid)->where('id', 'IN', $ids)->update(['is_del' => 1]); + return self::where('uid', $uid)->where('id', 'IN', explode(",", $ids))->update(['is_del' => 1]); } /**获取购物车数量 diff --git a/application/wap/model/topic/ExaminationRecord.php b/application/wap/model/topic/ExaminationRecord.php index 198fce4e..178d89c4 100755 --- a/application/wap/model/topic/ExaminationRecord.php +++ b/application/wap/model/topic/ExaminationRecord.php @@ -18,6 +18,9 @@ use app\wap\model\topic\ExaminationWrongBank; use app\wap\model\topic\TestPaper; use app\wap\model\topic\TestPaperObtain; use app\admin\model\questions\TestPaperScoreGrade; +use app\wap\model\wap\Clearance; + +use service\ClearanceService; /** * 用户考试记录 Model @@ -76,10 +79,18 @@ class ExaminationRecord extends ModelBasic $array['yes_questions'] = $yes_questions; $array['wrong_question'] = $wrong_question; $array['is_submit'] = 1; + $array['end_time'] = time(); $array['duration'] = $data['duration']; $array['score'] = ExaminationTestRecord::where(['e_id' => $record['id'], 'type' => $record['type'], 'is_correct' => 2])->sum('score'); $array['grade'] = TestPaperScoreGrade::getTestPaperScoreGrade($record['test_id'], $array['score']); $res = self::edit($array, $record['id']); + //记录打卡记录 + $clearance = Clearance::where('id', $data['special_id'] ?? 0)->find(); + if ($clearance) { + ClearanceService::clockIn($uid, $clearance['subject_id'], 2, $clearance['id'], $data['examination_id'], 0, 0, $array['score'], $array['accuracy'], $array['end_time'] - $record['start_time']); + } + + if (!$res) return self::setErrorInfo('记录修改错误!'); $res1 = ExaminationWrongBank::addWrongBank($record['id'], $record['test_id'], $record['type'], $uid); $res2 = TestPaper::PreExercisesWhere()->where(['id' => $record['test_id']])->setInc('answer'); diff --git a/application/wap/model/user/Message.php b/application/wap/model/user/Message.php new file mode 100644 index 00000000..9287debd --- /dev/null +++ b/application/wap/model/user/Message.php @@ -0,0 +1,26 @@ +where("CONCAT(',',cid,',') LIKE '%,$cid,%'", 'exp'); + return $model->field($field)->where('status', 1)->where('hide', 0)->order('sort DESC,add_time DESC')->limit($first, $limit)->select(); + } +} diff --git a/application/wap/model/wap/Helpcenter.php b/application/wap/model/wap/Helpcenter.php new file mode 100644 index 00000000..4c10d99b --- /dev/null +++ b/application/wap/model/wap/Helpcenter.php @@ -0,0 +1,33 @@ +where("CONCAT(',',cid,',') LIKE '%,$cid,%'", 'exp'); + return $model->field($field)->where('status', 1)->where('hide', 0)->order('sort DESC,add_time DESC')->limit($first, $limit)->select(); + } +} diff --git a/application/wap/model/wap/UserClearance.php b/application/wap/model/wap/UserClearance.php new file mode 100644 index 00000000..3ca8c70e --- /dev/null +++ b/application/wap/model/wap/UserClearance.php @@ -0,0 +1,26 @@ + -
diff --git a/extend/service/ClearanceService.php b/extend/service/ClearanceService.php new file mode 100644 index 00000000..8765bdc8 --- /dev/null +++ b/extend/service/ClearanceService.php @@ -0,0 +1,87 @@ +where('cate_id', $cate_id) + ->where('clearance_id', $clearance_id) + ->where('item_id', $item_id) + ->where('chapter_id', $chapter_id) + ->where('section_id', $section_id) + ->where('date',$date)->find(); + if ($detail) { + return true; + } + } + //写入打卡记录 + $clearance_data = [ + 'user_id' => $user_id, + 'cate_id' => $cate_id, + 'type' => $type, + 'clearance_id' => $clearance_id, + 'item_id' => $item_id, + 'chapter_id' => $chapter_id, + 'section_id' => $section_id, + 'score' => $score, + 'accuracy' => $accuracy, + 'use_time' => $use_time, + 'add_time' => time(), + 'date' => $date, + ]; + UserClearanceDetail::create($clearance_data); + //判断是否写了总记录 + $info = UserClearance::where('user_id',$user_id)->where('cate_id', $cate_id)->find(); + if (!$info) { + $userClearance = [ + 'user_id' => $user_id, + 'cate_id' => $cate_id, + 'add_time' => time(), + 'days' => 1, + 'recite_num' => 1, + 'accuracy' => $accuracy, + ]; + UserClearance::create($userClearance); + } else { + $detail = UserClearanceDetail::where('user_id',$user_id)->where('cate_id', $cate_id)->where('date',$date)->find(); + //当前没打卡,天数+1 + if (!$detail) { + $update_data['days'] = $info['days'] + 1; + } + //背诵 + if ($type == 1) { + $update_data['recite_num'] = $info['recite_num'] + 1; + } + if ($type == 2) { + $update_data['accuracy'] = $accuracy;//round(($info['accuracy'] + $accuracy) / 2); + } + UserClearance::where('id', $info['id'])->update($update_data); + } + } +} diff --git a/extend/service/MessageService.php b/extend/service/MessageService.php new file mode 100644 index 00000000..499d2f27 --- /dev/null +++ b/extend/service/MessageService.php @@ -0,0 +1,18 @@ + $user_id, + 'message_type' => $message_type, + 'content' => $content, + 'add_time' => time(), + ]; + Message::create($msg); + return true; + } +}