From c88284e5b7cb38e967fee46d19cf5fbe7097a8ed Mon Sep 17 00:00:00 2001 From: xiaochong0302 Date: Tue, 28 Jul 2020 20:40:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E7=BE=A4=E7=BB=84=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Builders/ImGroupUserList.php | 33 ++ .../Admin/Controllers/OrderController.php | 9 +- .../Admin/Controllers/RefundController.php | 9 +- .../Admin/Controllers/TradeController.php | 9 +- app/Http/Admin/Views/order/order_info.volt | 25 +- app/Http/Admin/Views/order/show.volt | 16 +- .../{statuses.volt => status_history.volt} | 2 +- app/Http/Admin/Views/refund/show.volt | 26 +- .../{statuses.volt => status_history.volt} | 2 +- app/Http/Admin/Views/trade/show.volt | 12 +- .../{statuses.volt => status_history.volt} | 2 +- app/Http/Admin/Views/trade/trade_info.volt | 25 +- app/Http/Web/Controllers/ImController.php | 12 +- .../Web/Controllers/ImGroupController.php | 48 +- app/Http/Web/Services/Im.php | 2 +- app/Http/Web/Services/ImGroup.php | 92 +++- .../Web/Views/account/forget_password.volt | 2 +- app/Http/Web/Views/account/login.volt | 2 +- app/Http/Web/Views/account/register.volt | 2 +- app/Http/Web/Views/chapter/live.volt | 2 +- app/Http/Web/Views/chapter/read.volt | 2 +- app/Http/Web/Views/chapter/vod.volt | 2 +- app/Http/Web/Views/course/list.volt | 2 +- app/Http/Web/Views/course/show.volt | 2 +- app/Http/Web/Views/help/index.volt | 2 +- app/Http/Web/Views/help/show.volt | 2 +- app/Http/Web/Views/im/find.volt | 4 +- app/Http/Web/Views/im/find_users.volt | 2 +- app/Http/Web/Views/im_group/edit.volt | 23 + app/Http/Web/Views/im_group/manage.volt | 34 ++ app/Http/Web/Views/im_group/users.volt | 31 ++ app/Http/Web/Views/index/im.volt | 2 +- app/Http/Web/Views/index/index.volt | 2 +- app/Http/Web/Views/my/account.volt | 2 +- app/Http/Web/Views/my/consults.volt | 2 +- app/Http/Web/Views/my/courses.volt | 2 +- app/Http/Web/Views/my/favorites.volt | 2 +- app/Http/Web/Views/my/friends.volt | 2 +- app/Http/Web/Views/my/groups.volt | 8 +- app/Http/Web/Views/my/orders.volt | 2 +- app/Http/Web/Views/my/profile.volt | 2 +- app/Http/Web/Views/my/refunds.volt | 2 +- app/Http/Web/Views/my/reviews.volt | 2 +- app/Http/Web/Views/order/confirm.volt | 2 +- app/Http/Web/Views/order/pay.volt | 2 +- app/Http/Web/Views/page/show.volt | 2 +- app/Http/Web/Views/search/list.volt | 2 +- app/Http/Web/Views/teacher/list.volt | 2 +- .../Views/templates/{full.volt => main.volt} | 5 +- app/Http/Web/Views/topic/show.volt | 2 +- app/Http/Web/Views/user/friends.volt | 4 +- app/Http/Web/Views/user/show.volt | 2 +- app/Http/Web/Views/vip/index.volt | 2 +- app/Library/Collection.php | 514 ++++++++++++++++++ public/static/admin/css/common.css | 9 - public/static/admin/js/status-history.js | 15 + public/static/web/css/common.css | 22 +- public/static/web/js/my.im.js | 6 - public/static/web/js/my.js | 14 + 59 files changed, 894 insertions(+), 179 deletions(-) rename app/Http/Admin/Views/order/{statuses.volt => status_history.volt} (86%) rename app/Http/Admin/Views/refund/{statuses.volt => status_history.volt} (86%) rename app/Http/Admin/Views/trade/{statuses.volt => status_history.volt} (86%) create mode 100644 app/Http/Web/Views/im_group/edit.volt create mode 100644 app/Http/Web/Views/im_group/manage.volt create mode 100644 app/Http/Web/Views/im_group/users.volt rename app/Http/Web/Views/templates/{full.volt => main.volt} (97%) create mode 100644 app/Library/Collection.php create mode 100644 public/static/admin/js/status-history.js delete mode 100644 public/static/web/js/my.im.js diff --git a/app/Builders/ImGroupUserList.php b/app/Builders/ImGroupUserList.php index 9bdda5be..0f3e1846 100644 --- a/app/Builders/ImGroupUserList.php +++ b/app/Builders/ImGroupUserList.php @@ -19,6 +19,39 @@ class ImGroupUserList extends Builder return $relations; } + public function handleUsers(array $relations) + { + $users = $this->getUsers($relations); + + foreach ($relations as $key => $value) { + $relations[$key]['user'] = $users[$value['user_id']] ?? new \stdClass(); + } + + return $relations; + } + + public function getUsers(array $relations) + { + $ids = kg_array_column($relations, 'user_id'); + + $userRepo = new UserRepo(); + + $columns = ['id', 'name', 'avatar', 'about', 'vip']; + + $users = $userRepo->findByIds($ids, $columns); + + $baseUrl = kg_ci_base_url(); + + $result = []; + + foreach ($users->toArray() as $user) { + $user['avatar'] = $baseUrl . $user['avatar']; + $result[$user['id']] = $user; + } + + return $result; + } + public function getGroups(array $relations) { $ids = kg_array_column($relations, 'group_id'); diff --git a/app/Http/Admin/Controllers/OrderController.php b/app/Http/Admin/Controllers/OrderController.php index 2fd302a1..54597b42 100644 --- a/app/Http/Admin/Controllers/OrderController.php +++ b/app/Http/Admin/Controllers/OrderController.php @@ -51,15 +51,16 @@ class OrderController extends Controller } /** - * @Get("/{id:[0-9]+}/statuses", name="admin.order.statuses") + * @Get("/{id:[0-9]+}/status/history", name="admin.order.status_history") */ - public function statusesAction($id) + public function statusHistoryAction($id) { $orderService = new OrderService(); - $statuses = $orderService->getStatusHistory($id); + $statusHistory = $orderService->getStatusHistory($id); - $this->view->setVar('statuses', $statuses); + $this->view->pick('order/status_history'); + $this->view->setVar('status_history', $statusHistory); } } diff --git a/app/Http/Admin/Controllers/RefundController.php b/app/Http/Admin/Controllers/RefundController.php index b0c1df05..7271f416 100644 --- a/app/Http/Admin/Controllers/RefundController.php +++ b/app/Http/Admin/Controllers/RefundController.php @@ -51,15 +51,16 @@ class RefundController extends Controller } /** - * @Get("/{id:[0-9]+}/statuses", name="admin.refund.statuses") + * @Get("/{id:[0-9]+}/status/history", name="admin.refund.status_history") */ - public function statusesAction($id) + public function statusHistoryAction($id) { $refundService = new RefundService(); - $statuses = $refundService->getStatusHistory($id); + $statusHistory = $refundService->getStatusHistory($id); - $this->view->setVar('statuses', $statuses); + $this->view->pick('refund/status_history'); + $this->view->setVar('status_history', $statusHistory); } /** diff --git a/app/Http/Admin/Controllers/TradeController.php b/app/Http/Admin/Controllers/TradeController.php index add93e79..0eb539ce 100644 --- a/app/Http/Admin/Controllers/TradeController.php +++ b/app/Http/Admin/Controllers/TradeController.php @@ -51,15 +51,16 @@ class TradeController extends Controller } /** - * @Get("/{id:[0-9]+}/statuses", name="admin.trade.statuses") + * @Get("/{id:[0-9]+}/status/history", name="admin.trade.status_history") */ - public function statusesAction($id) + public function statusHistoryAction($id) { $tradeService = new TradeService(); - $statuses = $tradeService->getStatusHistory($id); + $statusHistory = $tradeService->getStatusHistory($id); - $this->view->setVar('statuses', $statuses); + $this->view->pick('trade/status_history'); + $this->view->setVar('status_history', $statusHistory); } /** diff --git a/app/Http/Admin/Views/order/order_info.volt b/app/Http/Admin/Views/order/order_info.volt index 74434b77..73b9dbca 100644 --- a/app/Http/Admin/Views/order/order_info.volt +++ b/app/Http/Admin/Views/order/order_info.volt @@ -1,4 +1,4 @@ -{% set order_status_url = url({'for':'admin.order.statuses','id':order.id}) %} +{% set order_sh_url = url({'for':'admin.order.status_history','id':order.id}) %}
订单信息 @@ -13,32 +13,13 @@ 订单金额 订单类型 订单状态 - 历史状态 创建时间 {{ item_info(order) }} {{ '¥%0.2f'|format(order.amount) }} {{ item_type(order.item_type) }} - {{ order_status(order.status) }} - - - + {{ order_status(order.status) }} {{ date('Y-m-d H:i:s',order.create_time) }} - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/Http/Admin/Views/order/show.volt b/app/Http/Admin/Views/order/show.volt index 5821d02d..4754ea23 100644 --- a/app/Http/Admin/Views/order/show.volt +++ b/app/Http/Admin/Views/order/show.volt @@ -24,13 +24,15 @@ {% for item in refunds %} + {% set refund_sh_url = url({'for':'admin.refund.status_history','id':item.id}) %} + {% set refund_show_url = url({'for':'admin.refund.show','id':item.id}) %} {{ item.sn }} {{ '¥%0.2f'|format(item.amount) }} {{ substr(item.apply_note,0,15) }} - {{ refund_status(item.status) }} + {{ refund_status(item.status) }} {{ date('Y-m-d H:i:s',item.create_time) }} - 详情 + 详情 {% endfor %} @@ -51,17 +53,21 @@ {% for item in trades %} + {% set trade_sh_url = url({'for':'admin.trade.status_history','id':item.id}) %} + {% set trade_show_url = url({'for':'admin.trade.show','id':item.id}) %} {{ item.sn }} {{ '¥%0.2f'|format(item.amount) }} {{ channel_type(item.channel) }} - {{ trade_status(item.status) }} + {{ trade_status(item.status) }} {{ date('Y-m-d H:i:s',item.create_time) }} - 详情 + 详情 {% endfor %}
{% endif %} -{{ partial('order/user_info') }} \ No newline at end of file +{{ partial('order/user_info') }} + +{{ js_include('admin/js/status-history.js') }} \ No newline at end of file diff --git a/app/Http/Admin/Views/order/statuses.volt b/app/Http/Admin/Views/order/status_history.volt similarity index 86% rename from app/Http/Admin/Views/order/statuses.volt rename to app/Http/Admin/Views/order/status_history.volt index f3a4f620..8ecbe456 100644 --- a/app/Http/Admin/Views/order/statuses.volt +++ b/app/Http/Admin/Views/order/status_history.volt @@ -5,7 +5,7 @@ 状态 时间 - {% for item in statuses %} + {% for item in status_history %} {{ order_status(item.status) }} {{ date('Y-m-d H:i:s',item.create_time) }} diff --git a/app/Http/Admin/Views/refund/show.volt b/app/Http/Admin/Views/refund/show.volt index b1c6d3d4..9ccb764c 100644 --- a/app/Http/Admin/Views/refund/show.volt +++ b/app/Http/Admin/Views/refund/show.volt @@ -2,7 +2,8 @@ {{ partial('trade/macro') }} {{ partial('refund/macro') }} -{% set refund_status_url = url({'for':'admin.refund.statuses','id':refund.id}) %} +{% set refund_sh_url = url({'for':'admin.refund.status_history','id':refund.id}) %} +{% set refund_review_url = url({'for':'admin.refund.review','id':refund.id}) %}
退款信息 @@ -14,7 +15,6 @@ 退款金额 退款备注 退款状态 - 历史状态 创建时间 @@ -28,10 +28,7 @@

审核意见:{{ refund.review_note }}

{% endif %} - {{ refund_status(refund.status) }} - - - + {{ refund_status(refund.status) }} {{ date('Y-m-d H:i:s',refund.create_time) }} @@ -39,7 +36,7 @@
{% if refund.status == 'pending' %} -
+
审核退款
@@ -82,17 +79,4 @@ {{ partial('order/user_info') }} - \ No newline at end of file +{{ js_include('admin/js/status-history.js') }} \ No newline at end of file diff --git a/app/Http/Admin/Views/refund/statuses.volt b/app/Http/Admin/Views/refund/status_history.volt similarity index 86% rename from app/Http/Admin/Views/refund/statuses.volt rename to app/Http/Admin/Views/refund/status_history.volt index 7f65791f..2dbb6726 100644 --- a/app/Http/Admin/Views/refund/statuses.volt +++ b/app/Http/Admin/Views/refund/status_history.volt @@ -5,7 +5,7 @@ 状态 时间 - {% for item in statuses %} + {% for item in status_history %} {{ refund_status(item.status) }} {{ date('Y-m-d H:i:s',item.create_time) }} diff --git a/app/Http/Admin/Views/trade/show.volt b/app/Http/Admin/Views/trade/show.volt index 02aa5ee2..32ce6e26 100644 --- a/app/Http/Admin/Views/trade/show.volt +++ b/app/Http/Admin/Views/trade/show.volt @@ -6,9 +6,11 @@
+{% set trade_refund_url = url({'for':'admin.trade.refund','id':trade.id}) %} +
{% if trade.status == 'finished' %} - + {% endif %}
@@ -27,13 +29,15 @@ {% for item in refunds %} + {% set refund_sh_url = url({'for':'admin.refund.status_history','id':item.id}) %} + {% set refund_show_url = url({'for':'admin.refund.show','id':item.id}) %} {{ item.sn }} {{ '¥%0.2f'|format(item.amount) }} {{ substr(item.apply_note,0,15) }} - {{ refund_status(item) }} + {{ refund_status(item) }} {{ date('Y-m-d H:i:s',item.create_time) }} - 详情 + 详情 {% endfor %} @@ -47,6 +51,8 @@ {{ partial('order/user_info') }} +{{ js_include('admin/js/status-history.js') }} + \ No newline at end of file + \ No newline at end of file diff --git a/app/Http/Web/Controllers/ImController.php b/app/Http/Web/Controllers/ImController.php index 5f90e478..9fffbce6 100644 --- a/app/Http/Web/Controllers/ImController.php +++ b/app/Http/Web/Controllers/ImController.php @@ -147,14 +147,14 @@ class ImController extends LayerController { $service = new ImService(); - $usersPager = $service->getNewUsers(); - $groupsPager = $service->getNewGroups(); + $userPager = $service->getNewUsers(); + $groupPager = $service->getNewGroups(); - $usersPager->items = kg_array_object($usersPager->items); - $groupsPager->items = kg_array_object($groupsPager->items); + $userPager->items = kg_array_object($userPager->items); + $groupPager->items = kg_array_object($groupPager->items); - $this->view->setVar('users_pager', $usersPager); - $this->view->setVar('groups_pager', $groupsPager); + $this->view->setVar('user_pager', $userPager); + $this->view->setVar('group_pager', $groupPager); } /** diff --git a/app/Http/Web/Controllers/ImGroupController.php b/app/Http/Web/Controllers/ImGroupController.php index 0d9dd7e8..060d16b6 100644 --- a/app/Http/Web/Controllers/ImGroupController.php +++ b/app/Http/Web/Controllers/ImGroupController.php @@ -2,6 +2,8 @@ namespace App\Http\Web\Controllers; +use App\Http\Web\Services\ImGroup as ImGroupService; + /** * @RoutePrefix("/im/group") */ @@ -16,44 +18,52 @@ class ImGroupController extends Controller } - /** - * @Get("/{id:[0-9]+}/manage", name="web.im_group.manage") - */ - public function manageAction() - { - - } - /** * @Get("/{id:[0-9]+}/users", name="web.im_group.users") */ - public function usersAction() + public function usersAction($id) { + $service = new ImGroupService(); + $group = $service->getGroup($id); + + $pager = $service->getGroupUsers($id); + + $pager->items = kg_array_object($pager->items); + + $this->view->setVar('group', $group); + $this->view->setVar('pager', $pager); } /** - * @Post("/user/delete", name="web.im_group.delete_user") + * @Post("/{id:[0-9]+}/update", name="web.im_group.update") */ - public function deleteUserAction() + public function updateAction() { + $service = new ImGroupService(); + $service->updateGroup($id); + + $content = ['msg' => '更新群组成功']; + + return $this->jsonSuccess($content); } /** - * @Post("/user/block", name="web.im_group.block_user") + * @Post("/{gid:[0-9]+}/user/{uid:[0-9]+}/delete", name="web.im_group.delete_user") */ - public function blockUserAction() + public function deleteGroupUserAction($gid, $uid) { + $service = new ImGroupService(); - } + $service->deleteGroupUser($gid, $uid); - /** - * @Post("/user/unblock", name="web.im_group.unblock_user") - */ - public function unblockUserAction() - { + $content = [ + 'location' => $this->request->getHTTPReferer(), + 'msg' => '移除用户成功', + ]; + return $this->jsonSuccess($content); } } diff --git a/app/Http/Web/Services/Im.php b/app/Http/Web/Services/Im.php index a129ea2c..59898b74 100644 --- a/app/Http/Web/Services/Im.php +++ b/app/Http/Web/Services/Im.php @@ -132,7 +132,7 @@ class Im extends Service $validator = new ImGroupValidator(); - $group = $validator->checkGroupCache($id); + $group = $validator->checkGroup($id); $groupRepo = new ImGroupRepo(); diff --git a/app/Http/Web/Services/ImGroup.php b/app/Http/Web/Services/ImGroup.php index 18afa1ac..a5741d85 100644 --- a/app/Http/Web/Services/ImGroup.php +++ b/app/Http/Web/Services/ImGroup.php @@ -2,27 +2,109 @@ namespace App\Http\Web\Services; +use App\Builders\ImGroupUserList as ImGroupUserListBuilder; +use App\Library\Paginator\Query as PagerQuery; +use App\Repos\ImGroupUser as ImGroupUserRepo; +use App\Validators\ImGroup as ImGroupValidator; +use App\Validators\ImGroupUser as ImGroupUserValidator; + class ImGroup extends Service { public function getGroups() { + + } + + public function updateGroup($id) + { + $post = $this->request->getPost(); + + $user = $this->getLoginUser(); + + $validator = new ImGroupValidator(); + + $group = $validator->checkGroup($id); + + $validator->checkOwner($user->id, $group->owner_id); + + $data = []; + + $data['name'] = $validator->checkName($post['name']); + $data['about'] = $validator->checkAbout($post['about']); + + $group->update($data); + + return $group; + } + + public function getGroup($id) + { + $validator = new ImGroupValidator(); + + return $validator->checkGroup($id); } public function getGroupUsers($id) { + $validator = new ImGroupValidator(); + + $group = $validator->checkGroup($id); + + $pagerQuery = new PagerQuery(); + + $params = $pagerQuery->getParams(); + + $params['group_id'] = $group->id; + + $sort = $pagerQuery->getSort(); + $page = $pagerQuery->getPage(); + $limit = $pagerQuery->getLimit(); + + $repo = new ImGroupUserRepo(); + + $pager = $repo->paginate($params, $sort, $page, $limit); + + return $this->handleGroupUsers($pager); } - public function deleteUser() + public function deleteGroupUser($groupId, $userId) { + $loginUser = $this->getLoginUser(); + + $validator = new ImGroupUserValidator(); + + $group = $validator->checkGroup($groupId); + + $validator->checkOwner($loginUser->id, $group->owner_id); + + $groupUser = $validator->checkGroupUser($groupId, $userId); + + $groupUser->delete(); } - public function blockUser() + protected function handleGroupUsers($pager) { - } + if ($pager->total_items == 0) { + return $pager; + } - public function unblockUser() - { + $builder = new ImGroupUserListBuilder(); + + $relations = $pager->items->toArray(); + + $users = $builder->getUsers($relations); + + $items = []; + + foreach ($relations as $relation) { + $user = $users[$relation['user_id']] ?? new \stdClass(); + $items[] = $user; + } + + $pager->items = $items; + + return $pager; } } diff --git a/app/Http/Web/Views/account/forget_password.volt b/app/Http/Web/Views/account/forget_password.volt index a7b0c88d..b45a438b 100644 --- a/app/Http/Web/Views/account/forget_password.volt +++ b/app/Http/Web/Views/account/forget_password.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/account/login.volt b/app/Http/Web/Views/account/login.volt index 8db0fe73..b1f24d85 100644 --- a/app/Http/Web/Views/account/login.volt +++ b/app/Http/Web/Views/account/login.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/account/register.volt b/app/Http/Web/Views/account/register.volt index 6dee31f4..2c8a1815 100644 --- a/app/Http/Web/Views/account/register.volt +++ b/app/Http/Web/Views/account/register.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/chapter/live.volt b/app/Http/Web/Views/chapter/live.volt index 984101b8..7cf965b9 100644 --- a/app/Http/Web/Views/chapter/live.volt +++ b/app/Http/Web/Views/chapter/live.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/chapter/read.volt b/app/Http/Web/Views/chapter/read.volt index 1950232e..1e8ac0e3 100644 --- a/app/Http/Web/Views/chapter/read.volt +++ b/app/Http/Web/Views/chapter/read.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/chapter/vod.volt b/app/Http/Web/Views/chapter/vod.volt index 25ed4e51..443129da 100644 --- a/app/Http/Web/Views/chapter/vod.volt +++ b/app/Http/Web/Views/chapter/vod.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/course/list.volt b/app/Http/Web/Views/course/list.volt index 52aed001..58f48de8 100644 --- a/app/Http/Web/Views/course/list.volt +++ b/app/Http/Web/Views/course/list.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/course/show.volt b/app/Http/Web/Views/course/show.volt index aeae5f0c..d9d4d409 100644 --- a/app/Http/Web/Views/course/show.volt +++ b/app/Http/Web/Views/course/show.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/help/index.volt b/app/Http/Web/Views/help/index.volt index 2577af32..cfd853da 100644 --- a/app/Http/Web/Views/help/index.volt +++ b/app/Http/Web/Views/help/index.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/help/show.volt b/app/Http/Web/Views/help/show.volt index 7d5b2e58..56ddd2ff 100644 --- a/app/Http/Web/Views/help/show.volt +++ b/app/Http/Web/Views/help/show.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/im/find.volt b/app/Http/Web/Views/im/find.volt index 8be4ba60..f0e82dad 100644 --- a/app/Http/Web/Views/im/find.volt +++ b/app/Http/Web/Views/im/find.volt @@ -15,10 +15,10 @@
- {{ partial('im/find_users',{'pager':users_pager}) }} + {{ partial('im/find_users',{'pager':user_pager}) }}
- {{ partial('im/find_groups',{'pager':groups_pager}) }} + {{ partial('im/find_groups',{'pager':group_pager}) }}
diff --git a/app/Http/Web/Views/im/find_users.volt b/app/Http/Web/Views/im/find_users.volt index 4a321f3a..21c49110 100644 --- a/app/Http/Web/Views/im/find_users.volt +++ b/app/Http/Web/Views/im/find_users.volt @@ -12,7 +12,7 @@
{{ item.name }}
- 加为好友 +
diff --git a/app/Http/Web/Views/im_group/edit.volt b/app/Http/Web/Views/im_group/edit.volt new file mode 100644 index 00000000..8dd0a02c --- /dev/null +++ b/app/Http/Web/Views/im_group/edit.volt @@ -0,0 +1,23 @@ +{% set update_group_url = url({'for':'web.im_group.update','id':group.id}) %} + + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + +
+
+
\ No newline at end of file diff --git a/app/Http/Web/Views/im_group/manage.volt b/app/Http/Web/Views/im_group/manage.volt new file mode 100644 index 00000000..00469748 --- /dev/null +++ b/app/Http/Web/Views/im_group/manage.volt @@ -0,0 +1,34 @@ +{% extends 'templates/layer.volt' %} + +{% block content %} + +
+
+ {% for item in pager.items %} +
+
+ {% if item.vip == 1 %} + 会员 + {% endif %} +
+ {{ item.name }} +
+
{{ item.name }}
+ +
+
+ {% endfor %} +
+
+ + {{ partial('partials/pager') }} + +{% endblock %} + +{% block include_js %} + + {{ js_include('web/js/my.im.js') }} + +{% endblock %} \ No newline at end of file diff --git a/app/Http/Web/Views/im_group/users.volt b/app/Http/Web/Views/im_group/users.volt new file mode 100644 index 00000000..8ab7fd46 --- /dev/null +++ b/app/Http/Web/Views/im_group/users.volt @@ -0,0 +1,31 @@ +{% extends 'templates/layer.volt' %} + +{% block content %} + +
+
+
+ {% for item in pager.items %} + {% set delete_url = url({'for':'web.im_group.delete_user','gid':group.id,'uid':item.id}) %} +
+
+ {% if item.vip == 1 %} + 会员 + {% endif %} +
+ {{ item.name }} +
+
{{ item.name }}
+
+ +
+
+
+ {% endfor %} +
+
+ {{ partial('partials/pager') }} +
+ +{% endblock %} + diff --git a/app/Http/Web/Views/index/im.volt b/app/Http/Web/Views/index/im.volt index 4daf086d..7491f503 100644 --- a/app/Http/Web/Views/index/im.volt +++ b/app/Http/Web/Views/index/im.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/index/index.volt b/app/Http/Web/Views/index/index.volt index 8d3cebd0..20784477 100644 --- a/app/Http/Web/Views/index/index.volt +++ b/app/Http/Web/Views/index/index.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/my/account.volt b/app/Http/Web/Views/my/account.volt index 102f1ec2..988ff2e5 100644 --- a/app/Http/Web/Views/my/account.volt +++ b/app/Http/Web/Views/my/account.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/my/consults.volt b/app/Http/Web/Views/my/consults.volt index 6c0e091b..fcdd0683 100644 --- a/app/Http/Web/Views/my/consults.volt +++ b/app/Http/Web/Views/my/consults.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/my/courses.volt b/app/Http/Web/Views/my/courses.volt index 1f823e9c..53e17d9f 100644 --- a/app/Http/Web/Views/my/courses.volt +++ b/app/Http/Web/Views/my/courses.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/my/favorites.volt b/app/Http/Web/Views/my/favorites.volt index 20b9cb22..1a0b1797 100644 --- a/app/Http/Web/Views/my/favorites.volt +++ b/app/Http/Web/Views/my/favorites.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/my/friends.volt b/app/Http/Web/Views/my/friends.volt index c302c498..9cbe57f6 100644 --- a/app/Http/Web/Views/my/friends.volt +++ b/app/Http/Web/Views/my/friends.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/my/groups.volt b/app/Http/Web/Views/my/groups.volt index 6e221af8..5b35b402 100644 --- a/app/Http/Web/Views/my/groups.volt +++ b/app/Http/Web/Views/my/groups.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} @@ -34,7 +34,7 @@ {% for item in pager.items %} {% set owner_url = url({'for':'web.user.show','id':item.owner.id}) %} - {% set manage_url = url({'for':'web.im_group.manage','id':item.id}) %} + {% set manage_url = url({'for':'web.im_group.users','id':item.id}) %} {% set delete_url = url({'for':'web.im.quit_group','id':item.id}) %} {{ item.name }} {{ type_info(item.type) }} @@ -42,7 +42,7 @@ {{ item.user_count }} {% if auth_user.id == item.owner.id %} - + {% else %} {% endif %} @@ -61,6 +61,6 @@ {% block include_js %} - {{ js_include('web/js/my.im.js') }} + {{ js_include('web/js/my.js') }} {% endblock %} \ No newline at end of file diff --git a/app/Http/Web/Views/my/orders.volt b/app/Http/Web/Views/my/orders.volt index 05c3ca26..d881dc5e 100644 --- a/app/Http/Web/Views/my/orders.volt +++ b/app/Http/Web/Views/my/orders.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/my/profile.volt b/app/Http/Web/Views/my/profile.volt index d958eb10..6e844b05 100644 --- a/app/Http/Web/Views/my/profile.volt +++ b/app/Http/Web/Views/my/profile.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/my/refunds.volt b/app/Http/Web/Views/my/refunds.volt index 36fad6b0..9995a767 100644 --- a/app/Http/Web/Views/my/refunds.volt +++ b/app/Http/Web/Views/my/refunds.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/my/reviews.volt b/app/Http/Web/Views/my/reviews.volt index 9bba649f..651aa613 100644 --- a/app/Http/Web/Views/my/reviews.volt +++ b/app/Http/Web/Views/my/reviews.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/order/confirm.volt b/app/Http/Web/Views/order/confirm.volt index c8e29e7d..3450cb56 100644 --- a/app/Http/Web/Views/order/confirm.volt +++ b/app/Http/Web/Views/order/confirm.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/order/pay.volt b/app/Http/Web/Views/order/pay.volt index 0392f098..51353937 100644 --- a/app/Http/Web/Views/order/pay.volt +++ b/app/Http/Web/Views/order/pay.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/page/show.volt b/app/Http/Web/Views/page/show.volt index 373d4a68..5a2d37de 100644 --- a/app/Http/Web/Views/page/show.volt +++ b/app/Http/Web/Views/page/show.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/search/list.volt b/app/Http/Web/Views/search/list.volt index c9278178..ca5f5d28 100644 --- a/app/Http/Web/Views/search/list.volt +++ b/app/Http/Web/Views/search/list.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/teacher/list.volt b/app/Http/Web/Views/teacher/list.volt index 2f581f08..61fef5da 100644 --- a/app/Http/Web/Views/teacher/list.volt +++ b/app/Http/Web/Views/teacher/list.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/templates/full.volt b/app/Http/Web/Views/templates/main.volt similarity index 97% rename from app/Http/Web/Views/templates/full.volt rename to app/Http/Web/Views/templates/main.volt index 7166528b..be3b3be9 100644 --- a/app/Http/Web/Views/templates/full.volt +++ b/app/Http/Web/Views/templates/main.volt @@ -14,16 +14,13 @@ {% block link_css %}{% endblock %} {% block inline_css %}{% endblock %} - - + -
{% block content %}{% endblock %}
- diff --git a/app/Http/Web/Views/topic/show.volt b/app/Http/Web/Views/topic/show.volt index 0e0eb7af..7c9c0a1b 100644 --- a/app/Http/Web/Views/topic/show.volt +++ b/app/Http/Web/Views/topic/show.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/user/friends.volt b/app/Http/Web/Views/user/friends.volt index 6096a353..fa61874e 100644 --- a/app/Http/Web/Views/user/friends.volt +++ b/app/Http/Web/Views/user/friends.volt @@ -8,9 +8,9 @@ 会员 {% endif %}
- {{ item.name }} + {{ item.name }}
-
{{ item.name }}
+
{{ item.name }}
diff --git a/app/Http/Web/Views/user/show.volt b/app/Http/Web/Views/user/show.volt index 8885cdee..bfb90fd1 100644 --- a/app/Http/Web/Views/user/show.volt +++ b/app/Http/Web/Views/user/show.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Http/Web/Views/vip/index.volt b/app/Http/Web/Views/vip/index.volt index eeecbac8..fe9d2bdf 100644 --- a/app/Http/Web/Views/vip/index.volt +++ b/app/Http/Web/Views/vip/index.volt @@ -1,4 +1,4 @@ -{% extends 'templates/full.volt' %} +{% extends 'templates/main.volt' %} {% block content %} diff --git a/app/Library/Collection.php b/app/Library/Collection.php new file mode 100644 index 00000000..8fdcb423 --- /dev/null +++ b/app/Library/Collection.php @@ -0,0 +1,514 @@ +items = $this->convertToArray($items); + } + + public static function make($items = []) + { + return new static($items); + } + + public function isEmpty() + { + return empty($this->items); + } + + public function toArray() + { + return array_map(function ($value) { + return ($value instanceof self) ? $value->toArray() : $value; + }, $this->items); + } + + public function all() + { + return $this->items; + } + + /** + * 合并数组 + * + * @param mixed $items + * @return static + */ + public function merge($items) + { + return new static(array_merge($this->items, $this->convertToArray($items))); + } + + /** + * 交换数组中的键和值 + * + * @return static + */ + public function flip() + { + return new static(array_flip($this->items)); + } + + /** + * 按指定键整理数据 + * + * @param mixed $items 数据 + * @param string $indexKey 键名 + * @return array + */ + public function dictionary($items = null, &$indexKey = null) + { + if ($items instanceof self) { + $items = $items->all(); + } + + $items = is_null($items) ? $this->items : $items; + + if (isset($indexKey) && is_string($indexKey)) { + return array_column($items, null, $indexKey); + } + + return $items; + } + + /** + * 比较数组,返回差集 + * + * @param mixed $items 数据 + * @param string $indexKey 指定比较的键名 + * @return static + */ + public function diff($items, $indexKey = null) + { + if ($this->isEmpty() || is_scalar($this->items[0])) { + return new static(array_diff($this->items, $this->convertToArray($items))); + } + + $diff = []; + + $dictionary = $this->dictionary($items, $indexKey); + + if (is_string($indexKey)) { + foreach ($this->items as $item) { + if (!isset($dictionary[$item[$indexKey]])) { + $diff[] = $item; + } + } + } + + return new static($diff); + } + + /** + * 比较数组,返回交集 + * + * @param mixed $items 数据 + * @param string $indexKey 指定比较的键名 + * @return static + */ + public function intersect($items, $indexKey = null) + { + if ($this->isEmpty() || is_scalar($this->items[0])) { + return new static(array_diff($this->items, $this->convertToArray($items))); + } + + $intersect = []; + + $dictionary = $this->dictionary($items, $indexKey); + + if (is_string($indexKey)) { + foreach ($this->items as $item) { + if (isset($dictionary[$item[$indexKey]])) { + $intersect[] = $item; + } + } + } + + return new static($intersect); + } + + /** + * 返回数组中所有的键名 + * + * @return array + */ + public function keys() + { + $current = current($this->items); + + if (is_scalar($current)) { + $array = $this->items; + } elseif (is_array($current)) { + $array = $current; + } else { + $array = $current->toArray(); + } + + return array_keys($array); + } + + /** + * 删除数组的最后一个元素(出栈) + * + * @return mixed + */ + public function pop() + { + return array_pop($this->items); + } + + /** + * 通过使用用户自定义函数,以字符串返回数组 + * + * @param callable $callback + * @param mixed $initial + * @return mixed + */ + public function reduce(callable $callback, $initial = null) + { + return array_reduce($this->items, $callback, $initial); + } + + /** + * 以相反的顺序返回数组。 + * + * @return static + */ + public function reverse() + { + return new static(array_reverse($this->items)); + } + + /** + * 删除数组中首个元素,并返回被删除元素的值 + * + * @return mixed + */ + public function shift() + { + return array_shift($this->items); + } + + /** + * 在数组结尾插入一个元素 + * + * @param mixed $value + * @param mixed $key + * @return void + */ + public function push($value, $key = null) + { + if (is_null($key)) { + $this->items[] = $value; + } else { + $this->items[$key] = $value; + } + } + + /** + * 把一个数组分割为新的数组块. + * + * @param int $size + * @param bool $preserveKeys + * @return static + */ + public function chunk($size, $preserveKeys = false) + { + $chunks = []; + + foreach (array_chunk($this->items, $size, $preserveKeys) as $chunk) { + $chunks[] = new static($chunk); + } + + return new static($chunks); + } + + /** + * 在数组开头插入一个元素 + * + * @param mixed $value + * @param mixed $key + * @return void + */ + public function unshift($value, $key = null) + { + if (is_null($key)) { + array_unshift($this->items, $value); + } else { + $this->items = [$key => $value] + $this->items; + } + } + + /** + * 给每个元素执行个回调 + * + * @param callable $callback + * @return $this + */ + public function each(callable $callback) + { + foreach ($this->items as $key => $item) { + $result = $callback($item, $key); + if (false === $result) { + break; + } elseif (!is_object($item)) { + $this->items[$key] = $result; + } + } + + return $this; + } + + /** + * 用回调函数处理数组中的元素 + * + * @param callable|null $callback + * @return static + */ + public function map(callable $callback) + { + return new static(array_map($callback, $this->items)); + } + + /** + * 用回调函数过滤数组中的元素 + * + * @param callable|null $callback + * @return static + */ + public function filter(callable $callback = null) + { + if ($callback) { + return new static(array_filter($this->items, $callback)); + } + + return new static(array_filter($this->items)); + } + + /** + * 根据字段条件过滤数组中的元素 + * + * @param string $field 字段名 + * @param mixed $operator 操作符 + * @param mixed $value 数据 + * @return static + */ + public function where($field, $operator, $value = null) + { + if (is_null($value)) { + $value = $operator; + $operator = '='; + } + + return $this->filter(function ($data) use ($field, $operator, $value) { + + if (strpos($field, '.')) { + list($field, $relation) = explode('.', $field); + $result = isset($data[$field][$relation]) ? $data[$field][$relation] : null; + } else { + $result = isset($data[$field]) ? $data[$field] : null; + } + + switch ($operator) { + case '===': + return $result === $value; + case '!==': + return $result !== $value; + case '!=': + case '<>': + return $result != $value; + case '>': + return $result > $value; + case '>=': + return $result >= $value; + case '<': + return $result < $value; + case '<=': + return $result <= $value; + case 'like': + return is_string($result) && false !== strpos($result, $value); + case 'not_like': + return is_string($result) && false === strpos($result, $value); + case 'in': + return is_scalar($result) && in_array($result, $value, true); + case 'not_in': + return is_scalar($result) && !in_array($result, $value, true); + case 'between': + list($min, $max) = is_string($value) ? explode(',', $value) : $value; + return is_scalar($result) && $result >= $min && $result <= $max; + case 'not_between': + list($min, $max) = is_string($value) ? explode(',', $value) : $value; + return is_scalar($result) && $result > $max || $result < $min; + case '==': + case '=': + default: + return $result == $value; + } + }); + } + + /** + * 返回数据中指定的一列 + * + * @param mixed $columnKey 键名 + * @param mixed $indexKey 作为索引值的列 + * @return array + */ + public function column($columnKey, $indexKey = null) + { + return array_column($this->items, $columnKey, $indexKey); + } + + /** + * 对数组排序 + * + * @access public + * @param callable|null $callback + * @return static + */ + public function sort(callable $callback = null) + { + $items = $this->items; + + $callback = $callback ?: function ($a, $b) { + return $a == $b ? 0 : (($a < $b) ? -1 : 1); + }; + + uasort($items, $callback); + + return new static($items); + } + + /** + * 指定字段排序 + * + * @param string $field 排序字段 + * @param string $order 排序 + * @param bool $intSort 是否为数字排序 + * @return $this + */ + public function order($field, $order = null, $intSort = true) + { + return $this->sort(function ($a, $b) use ($field, $order, $intSort) { + + $fieldA = isset($a[$field]) ? $a[$field] : null; + $fieldB = isset($b[$field]) ? $b[$field] : null; + + if ($intSort) { + return 'desc' == strtolower($order) ? $fieldB >= $fieldA : $fieldA >= $fieldB; + } else { + return 'desc' == strtolower($order) ? strcmp($fieldB, $fieldA) : strcmp($fieldA, $fieldB); + } + }); + } + + /** + * 将数组打乱 + * + * @return static + */ + public function shuffle() + { + $items = $this->items; + + shuffle($items); + + return new static($items); + } + + /** + * 截取数组 + * + * @param int $offset + * @param int $length + * @param bool $preserveKeys + * @return static + */ + public function slice($offset, $length = null, $preserveKeys = false) + { + return new static(array_slice($this->items, $offset, $length, $preserveKeys)); + } + + public function offsetExists($offset) + { + return array_key_exists($offset, $this->items); + } + + public function offsetGet($offset) + { + return $this->items[$offset]; + } + + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->items[] = $value; + } else { + $this->items[$offset] = $value; + } + } + + public function offsetUnset($offset) + { + unset($this->items[$offset]); + } + + public function count() + { + return count($this->items); + } + + public function getIterator() + { + return new ArrayIterator($this->items); + } + + public function jsonSerialize() + { + return $this->toArray(); + } + + /** + * 转换当前数据集为JSON字符串 + * + * @param integer $options json参数 + * @return string + */ + public function toJson($options = JSON_UNESCAPED_UNICODE) + { + return json_encode($this->toArray(), $options); + } + + public function __toString() + { + return $this->toJson(); + } + + /** + * 转换成数组 + * + * @param mixed $items + * @return array + */ + protected function convertToArray($items) + { + if ($items instanceof self) { + return $items->all(); + } + + return (array)$items; + } + +} diff --git a/public/static/admin/css/common.css b/public/static/admin/css/common.css index 9626e547..f2f037b2 100644 --- a/public/static/admin/css/common.css +++ b/public/static/admin/css/common.css @@ -179,12 +179,3 @@ img.kg-qrcode { padding-top: 0; border-top: none; } - -.kg-status-history { - line-height: 30px; -} - -.kg-status-history .time { - margin-left: 10px; - color: #666; -} diff --git a/public/static/admin/js/status-history.js b/public/static/admin/js/status-history.js new file mode 100644 index 00000000..6a0526c8 --- /dev/null +++ b/public/static/admin/js/status-history.js @@ -0,0 +1,15 @@ +layui.use(['jquery', 'layer'], function () { + + var $ = layui.jquery; + var layer = layui.layer; + + $('.kg-status-history').on('click', function () { + layer.open({ + type: 2, + title: '历史状态', + content: $(this).data('url'), + area: ['640px', '320px'] + }); + }); + +}); \ No newline at end of file diff --git a/public/static/web/css/common.css b/public/static/web/css/common.css index efd9f33b..963ef814 100644 --- a/public/static/web/css/common.css +++ b/public/static/web/css/common.css @@ -1,4 +1,4 @@ -.full { +.main { background-color: #f2f2f2; } @@ -61,9 +61,9 @@ box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); } -.layer-wrap { +.bg-wrap { padding: 20px; - margin-bottom: 20px; + background-color: #f2f2f2; } .pager { @@ -1501,6 +1501,11 @@ body { width: 10%; } +.im-manage-wrap { + padding: 20px 20px 10px 20px; + background-color: #f2f2f2; +} + .im-search-wrap { padding: 20px; background-color: #f2f2f2; @@ -1542,6 +1547,17 @@ body { font-size: 10px; } +.im-user-list .action button { + padding: 0 5px; + height: 20px; + line-height: 20px; + font-size: 12px; +} + +.im-user-list .layui-btn + .layui-btn { + margin-left: 5px; +} + .layim-msgbox { margin: 15px; } diff --git a/public/static/web/js/my.im.js b/public/static/web/js/my.im.js deleted file mode 100644 index eb77410f..00000000 --- a/public/static/web/js/my.im.js +++ /dev/null @@ -1,6 +0,0 @@ -layui.use(['jquery', 'layer'], function () { - - var $ = layui.jquery; - var layer = layui.layer; - -}); \ No newline at end of file diff --git a/public/static/web/js/my.js b/public/static/web/js/my.js index 6e75789e..a1ded7e3 100644 --- a/public/static/web/js/my.js +++ b/public/static/web/js/my.js @@ -93,6 +93,20 @@ layui.use(['jquery', 'layer', 'helper'], function () { }); }); + /** + * 群组管理 + */ + $('.btn-manage-group').on('click', function () { + var url = $(this).data('url'); + layer.open({ + type: 2, + title: '群组管理', + maxmin: true, + resize: false, + content: [url, 'no'], + area: ['1000px', '510px'] + }); + }); if ($('#tab-courses').length > 0) { var $tabCourses = $('#tab-courses');