diff --git a/app/Caches/FlashSale.php b/app/Caches/FlashSale.php new file mode 100644 index 00000000..53827597 --- /dev/null +++ b/app/Caches/FlashSale.php @@ -0,0 +1,31 @@ +lifetime; + } + + public function getKey($id = null) + { + return "flash_sale:{$id}"; + } + + public function getContent($id = null) + { + $saleRepo = new FlashSaleRepo(); + + $sale = $saleRepo->findById($id); + + return $sale ?: null; + } + +} diff --git a/app/Caches/MaxFlashSaleId.php b/app/Caches/MaxFlashSaleId.php new file mode 100644 index 00000000..393305f7 --- /dev/null +++ b/app/Caches/MaxFlashSaleId.php @@ -0,0 +1,29 @@ +lifetime; + } + + public function getKey($id = null) + { + return 'max_flash_sale_id'; + } + + public function getContent($id = null) + { + $sale = FlashSaleModel::findFirst(['order' => 'id DESC']); + + return $sale->id ?? 0; + } + +} diff --git a/app/Caches/PointGift.php b/app/Caches/PointGift.php index 6a027a71..757684e9 100644 --- a/app/Caches/PointGift.php +++ b/app/Caches/PointGift.php @@ -7,7 +7,7 @@ use App\Repos\PointGift as PointGiftRepo; class PointGift extends Cache { - protected $lifetime = 365 * 86400; + protected $lifetime = 1 * 86400; public function getLifetime() { diff --git a/app/Console/Tasks/CloseFlashSaleOrderTask.php b/app/Console/Tasks/CloseFlashSaleOrderTask.php new file mode 100644 index 00000000..df750198 --- /dev/null +++ b/app/Console/Tasks/CloseFlashSaleOrderTask.php @@ -0,0 +1,62 @@ +findOrders(); + + if ($orders->count() == 0) return; + + foreach ($orders as $order) { + $this->pushFlashSaleQueue($order->promotion_id); + $this->deleteUserOrderCache($order->owner_id, $order->promotion_id); + $order->status = OrderModel::STATUS_CLOSED; + $order->update(); + } + } + + protected function pushFlashSaleQueue($saleId) + { + $queue = new FlashSaleQueue(); + + $queue->push($saleId); + } + + protected function deleteUserOrderCache($userId, $saleId) + { + $cache = new UserOrderCache(); + + $cache->delete($userId, $saleId); + } + + /** + * 查找待关闭订单 + * + * @param int $limit + * @return ResultsetInterface|Resultset|OrderModel[] + */ + protected function findOrders($limit = 1000) + { + $status = OrderModel::STATUS_PENDING; + $type = OrderModel::PROMOTION_FLASH_SALE; + $time = time() - 15 * 60; + + return OrderModel::query() + ->where('status = :status:', ['status' => $status]) + ->andWhere('promotion_type = :type:', ['type' => $type]) + ->andWhere('create_time < :time:', ['time' => $time]) + ->limit($limit) + ->execute(); + } + +} diff --git a/app/Console/Tasks/CloseOrderTask.php b/app/Console/Tasks/CloseOrderTask.php index 713d225c..c0f38fe9 100644 --- a/app/Console/Tasks/CloseOrderTask.php +++ b/app/Console/Tasks/CloseOrderTask.php @@ -13,9 +13,7 @@ class CloseOrderTask extends Task { $orders = $this->findOrders(); - if ($orders->count() == 0) { - return; - } + if ($orders->count() == 0) return; foreach ($orders as $order) { $order->status = OrderModel::STATUS_CLOSED; @@ -32,12 +30,13 @@ class CloseOrderTask extends Task protected function findOrders($limit = 1000) { $status = OrderModel::STATUS_PENDING; - - $createTime = time() - 12 * 3600; + $time = time() - 12 * 3600; + $type = 0; return OrderModel::query() ->where('status = :status:', ['status' => $status]) - ->andWhere('create_time < :create_time:', ['create_time' => $createTime]) + ->andWhere('promotion_type = :type:', ['type' => $type]) + ->andWhere('create_time < :time:', ['time' => $time]) ->limit($limit) ->execute(); } diff --git a/app/Console/Tasks/CloseTradeTask.php b/app/Console/Tasks/CloseTradeTask.php index efe84b3a..3de10428 100644 --- a/app/Console/Tasks/CloseTradeTask.php +++ b/app/Console/Tasks/CloseTradeTask.php @@ -15,9 +15,7 @@ class CloseTradeTask extends Task { $trades = $this->findTrades(); - if ($trades->count() == 0) { - return; - } + if ($trades->count() == 0) return; foreach ($trades as $trade) { if ($trade->channel == TradeModel::CHANNEL_ALIPAY) { diff --git a/app/Console/Tasks/CourseIndexTask.php b/app/Console/Tasks/CourseIndexTask.php index ec4fc523..087c04b8 100644 --- a/app/Console/Tasks/CourseIndexTask.php +++ b/app/Console/Tasks/CourseIndexTask.php @@ -60,11 +60,11 @@ class CourseIndexTask extends Task $index = $handler->getXS()->getIndex(); - echo 'start clean course index' . PHP_EOL; + echo '------ start clean course index ------' . PHP_EOL; $index->clean(); - echo 'end clean course index' . PHP_EOL; + echo '------ end clean course index ------' . PHP_EOL; } /** @@ -82,7 +82,7 @@ class CourseIndexTask extends Task $index = $handler->getXS()->getIndex(); - echo 'start rebuild course index' . PHP_EOL; + echo '------ start rebuild course index ------' . PHP_EOL; $index->beginRebuild(); @@ -93,7 +93,7 @@ class CourseIndexTask extends Task $index->endRebuild(); - echo 'end rebuild course index' . PHP_EOL; + echo '------ end rebuild course index ------' . PHP_EOL; } /** diff --git a/app/Console/Tasks/GroupIndexTask.php b/app/Console/Tasks/GroupIndexTask.php index 2b3818c8..26c32709 100644 --- a/app/Console/Tasks/GroupIndexTask.php +++ b/app/Console/Tasks/GroupIndexTask.php @@ -60,11 +60,11 @@ class GroupIndexTask extends Task $index = $handler->getXS()->getIndex(); - echo 'start clean group index' . PHP_EOL; + echo '------ start clean group index ------' . PHP_EOL; $index->clean(); - echo 'end clean group index' . PHP_EOL; + echo '------ end clean group index ------' . PHP_EOL; } /** @@ -82,7 +82,7 @@ class GroupIndexTask extends Task $index = $handler->getXS()->getIndex(); - echo 'start rebuild group index' . PHP_EOL; + echo '------ start rebuild group index ------' . PHP_EOL; $index->beginRebuild(); @@ -93,7 +93,7 @@ class GroupIndexTask extends Task $index->endRebuild(); - echo 'end rebuild group index' . PHP_EOL; + echo '------ end rebuild group index ------' . PHP_EOL; } /** diff --git a/app/Console/Tasks/OptimizeTableTask.php b/app/Console/Tasks/OptimizeTableTask.php index f690cb8a..26f60d75 100644 --- a/app/Console/Tasks/OptimizeTableTask.php +++ b/app/Console/Tasks/OptimizeTableTask.php @@ -26,7 +26,7 @@ class OptimizeTableTask extends Task $tableName = $sessionModel->getSource(); - $this->db->delete($tableName, "expire_time < :expire_time", [ + $this->db->delete($tableName, 'expire_time < :expire_time', [ 'expire_time' => strtotime('-3 days'), ]); @@ -39,7 +39,7 @@ class OptimizeTableTask extends Task $tableName = $tokenModel->getSource(); - $this->db->delete($tableName, "expire_time < :expire_time", [ + $this->db->delete($tableName, 'expire_time < :expire_time', [ 'expire_time' => strtotime('-3 days'), ]); @@ -56,7 +56,7 @@ class OptimizeTableTask extends Task $tableName = $messageModel->getSource(); - $this->db->delete($tableName, "create_time < :create_time", [ + $this->db->delete($tableName, 'create_time < :create_time', [ 'create_time' => strtotime('-6 months'), ]); @@ -73,7 +73,7 @@ class OptimizeTableTask extends Task $tableName = $learningModel->getSource(); - $this->db->delete($tableName, "create_time < :create_time", [ + $this->db->delete($tableName, 'create_time < :create_time', [ 'create_time' => strtotime('-6 months'), ]); @@ -90,7 +90,7 @@ class OptimizeTableTask extends Task $tableName = $taskModel->getSource(); - $this->db->delete($tableName, "create_time < :create_time AND status > :status", [ + $this->db->delete($tableName, 'create_time < :create_time AND status > :status', [ 'create_time' => strtotime('-6 months'), 'status' => TaskModel::STATUS_PENDING, ]); diff --git a/app/Console/Tasks/UpgradeTask.php b/app/Console/Tasks/UpgradeTask.php index cfd14aab..2667186d 100644 --- a/app/Console/Tasks/UpgradeTask.php +++ b/app/Console/Tasks/UpgradeTask.php @@ -23,7 +23,7 @@ class UpgradeTask extends Task */ public function resetSettingAction() { - echo "start reset setting..." . PHP_EOL; + echo '------ start reset setting ------' . PHP_EOL; $rows = SettingModel::query()->columns('section')->distinct(true)->execute(); @@ -32,7 +32,7 @@ class UpgradeTask extends Task $cache->rebuild($row->section); } - echo "end reset setting..." . PHP_EOL; + echo '------ end reset setting ------' . PHP_EOL; } /** @@ -48,7 +48,7 @@ class UpgradeTask extends Task $keys = $redis->sMembers($statsKey); - echo "start reset annotation..." . PHP_EOL; + echo '------ start reset annotation ------' . PHP_EOL; if (count($keys) > 0) { $keys = $this->handlePhKeys($keys); @@ -56,7 +56,7 @@ class UpgradeTask extends Task $redis->del($statsKey); } - echo "end reset annotation..." . PHP_EOL; + echo '------ end reset annotation ------' . PHP_EOL; } /** @@ -72,7 +72,7 @@ class UpgradeTask extends Task $keys = $redis->sMembers($statsKey); - echo "start reset metadata..." . PHP_EOL; + echo '------ start reset metadata ------' . PHP_EOL; if (count($keys) > 0) { $keys = $this->handlePhKeys($keys); @@ -90,7 +90,7 @@ class UpgradeTask extends Task */ public function resetVoltAction() { - echo "start reset volt..." . PHP_EOL; + echo '------ start reset volt ------' . PHP_EOL; $dir = cache_path('volt'); @@ -100,7 +100,7 @@ class UpgradeTask extends Task } } - echo "end reset volt..." . PHP_EOL; + echo '------ end reset volt ------' . PHP_EOL; } protected function handlePhKeys($keys) diff --git a/app/Console/Tasks/UserIndexTask.php b/app/Console/Tasks/UserIndexTask.php index ccf999f4..7cae5add 100644 --- a/app/Console/Tasks/UserIndexTask.php +++ b/app/Console/Tasks/UserIndexTask.php @@ -60,11 +60,11 @@ class UserIndexTask extends Task $index = $handler->getXS()->getIndex(); - echo 'start clean user index' . PHP_EOL; + echo '------ start clean user index ------' . PHP_EOL; $index->clean(); - echo 'end clean user index' . PHP_EOL; + echo '------ end clean user index ------' . PHP_EOL; } /** @@ -82,7 +82,7 @@ class UserIndexTask extends Task $index = $handler->getXS()->getIndex(); - echo 'start rebuild user index' . PHP_EOL; + echo '------ start rebuild user index ------' . PHP_EOL; $index->beginRebuild(); @@ -93,7 +93,7 @@ class UserIndexTask extends Task $index->endRebuild(); - echo 'end rebuild user index' . PHP_EOL; + echo '------ end rebuild user index ------' . PHP_EOL; } /** diff --git a/app/Http/Admin/Controllers/Controller.php b/app/Http/Admin/Controllers/Controller.php index 724497a0..36b974c9 100644 --- a/app/Http/Admin/Controllers/Controller.php +++ b/app/Http/Admin/Controllers/Controller.php @@ -47,8 +47,8 @@ class Controller extends \Phalcon\Mvc\Controller * 特例白名单 */ $whitelist = [ - 'controllers' => ['public', 'index', 'vod', 'upload', 'test', 'xm_course'], - 'routes' => ['admin.package.guiding'], + 'controllers' => ['public', 'index', 'vod', 'upload', 'test'], + 'routes' => [], ]; $controller = $dispatcher->getControllerName(); diff --git a/app/Http/Admin/Controllers/CourseController.php b/app/Http/Admin/Controllers/CourseController.php index 9b927b52..e2aa5c79 100644 --- a/app/Http/Admin/Controllers/CourseController.php +++ b/app/Http/Admin/Controllers/CourseController.php @@ -59,7 +59,11 @@ class CourseController extends Controller */ public function addAction() { + $courseService = new CourseService(); + $modelTypes = $courseService->getModelTypes(); + + $this->view->setVar('model_types', $modelTypes); } /** diff --git a/app/Http/Admin/Controllers/FlashSaleController.php b/app/Http/Admin/Controllers/FlashSaleController.php new file mode 100644 index 00000000..133179f2 --- /dev/null +++ b/app/Http/Admin/Controllers/FlashSaleController.php @@ -0,0 +1,148 @@ +getFlashSales(); + + $this->view->setVar('pager', $pager); + } + + /** + * @Get("/search", name="admin.flash_sale.search") + */ + public function searchAction() + { + $service = new FlashSaleService(); + + $itemTypes = $service->getItemTypes(); + + $this->view->setVar('item_types', $itemTypes); + } + + /** + * @Get("/add", name="admin.flash_sale.add") + */ + public function addAction() + { + $service = new FlashSaleService(); + + $itemTypes = $service->getItemTypes(); + $xmPackages = $service->getXmPackages(); + $xmCourses = $service->getXmCourses(); + $xmVips = $service->getXmVips(); + + $this->view->setVar('item_types', $itemTypes); + $this->view->setVar('xm_packages', $xmPackages); + $this->view->setVar('xm_courses', $xmCourses); + $this->view->setVar('xm_vips', $xmVips); + } + + /** + * @Get("/{id:[0-9]+}/edit", name="admin.flash_sale.edit") + */ + public function editAction($id) + { + $service = new FlashSaleService(); + + $sale = $service->getFlashSale($id); + $xmSchedules = $service->getXmSchedules($id); + + $this->view->setVar('sale', $sale); + $this->view->setVar('xm_schedules', $xmSchedules); + } + + /** + * @Post("/create", name="admin.flash_sale.create") + */ + public function createAction() + { + $service = new FlashSaleService(); + + $sale = $service->createFlashSale(); + + $location = $this->url->get([ + 'for' => 'admin.flash_sale.edit', + 'id' => $sale->id, + ]); + + $content = [ + 'location' => $location, + 'msg' => '添加商品成功', + ]; + + return $this->jsonSuccess($content); + } + + /** + * @Post("/{id:[0-9]+}/update", name="admin.flash_sale.update") + */ + public function updateAction($id) + { + $service = new FlashSaleService(); + + $service->updateFlashSale($id); + + $location = $this->url->get(['for' => 'admin.flash_sale.list']); + + $content = [ + 'location' => $location, + 'msg' => '更新商品成功', + ]; + + return $this->jsonSuccess($content); + } + + /** + * @Post("/{id:[0-9]+}/delete", name="admin.flash_sale.delete") + */ + public function deleteAction($id) + { + $service = new FlashSaleService(); + + $service->deleteFlashSale($id); + + $location = $this->request->getHTTPReferer(); + + $content = [ + 'location' => $location, + 'msg' => '删除商品成功', + ]; + + return $this->jsonSuccess($content); + } + + /** + * @Post("/{id:[0-9]+}/restore", name="admin.flash_sale.restore") + */ + public function restoreAction($id) + { + $service = new FlashSaleService(); + + $service->restoreFlashSale($id); + + $location = $this->request->getHTTPReferer(); + + $content = [ + 'location' => $location, + 'msg' => '还原商品成功', + ]; + + return $this->jsonSuccess($content); + } + +} diff --git a/app/Http/Admin/Controllers/ImGroupController.php b/app/Http/Admin/Controllers/ImGroupController.php index e1f73991..e5659778 100644 --- a/app/Http/Admin/Controllers/ImGroupController.php +++ b/app/Http/Admin/Controllers/ImGroupController.php @@ -34,6 +34,7 @@ class ImGroupController extends Controller $types = $groupService->getGroupTypes(); $this->view->pick('im/group/search'); + $this->view->setVar('types', $types); } diff --git a/app/Http/Admin/Controllers/PackageController.php b/app/Http/Admin/Controllers/PackageController.php index 3c177089..8d8639f1 100644 --- a/app/Http/Admin/Controllers/PackageController.php +++ b/app/Http/Admin/Controllers/PackageController.php @@ -18,22 +18,6 @@ class PackageController extends Controller } - /** - * @Get("/guiding", name="admin.package.guiding") - */ - public function guidingAction() - { - $xmCourseIds = $this->request->getQuery('xm_course_ids'); - - $packageService = new PackageService(); - - $courses = $packageService->getGuidingCourses($xmCourseIds); - $guidingPrice = $packageService->getGuidingPrice($courses); - - $this->view->setVar('courses', $courses); - $this->view->setVar('guiding_price', $guidingPrice); - } - /** * @Get("/list", name="admin.package.list") */ diff --git a/app/Http/Admin/Controllers/PointGiftController.php b/app/Http/Admin/Controllers/PointGiftController.php index 1135eb9d..0cfd9b41 100644 --- a/app/Http/Admin/Controllers/PointGiftController.php +++ b/app/Http/Admin/Controllers/PointGiftController.php @@ -15,9 +15,9 @@ class PointGiftController extends Controller */ public function listAction() { - $giftService = new PointGiftService(); + $service = new PointGiftService(); - $pager = $giftService->getGifts(); + $pager = $service->getPointGifts(); $this->view->pick('point/gift/list'); @@ -29,7 +29,13 @@ class PointGiftController extends Controller */ public function searchAction() { + $service = new PointGiftService(); + + $types = $service->getTypes(); + $this->view->pick('point/gift/search'); + + $this->view->setVar('types', $types); } /** @@ -37,7 +43,15 @@ class PointGiftController extends Controller */ public function addAction() { + $service = new PointGiftService(); + + $xmCourses = $service->getXmCourses(); + $types = $service->getTypes(); + $this->view->pick('point/gift/add'); + + $this->view->setVar('xm_courses', $xmCourses); + $this->view->setVar('types', $types); } /** @@ -45,9 +59,9 @@ class PointGiftController extends Controller */ public function editAction($id) { - $giftService = new PointGiftService(); + $service = new PointGiftService(); - $gift = $giftService->getGift($id); + $gift = $service->getPointGift($id); $this->view->pick('point/gift/edit'); @@ -59,9 +73,9 @@ class PointGiftController extends Controller */ public function createAction() { - $giftService = new PointGiftService(); + $service = new PointGiftService(); - $gift = $giftService->createGift(); + $gift = $service->createPointGift(); $location = $this->url->get([ 'for' => 'admin.point_gift.edit', @@ -81,9 +95,9 @@ class PointGiftController extends Controller */ public function updateAction($id) { - $giftService = new PointGiftService(); + $service = new PointGiftService(); - $giftService->updateGift($id); + $service->updatePointGift($id); $location = $this->url->get(['for' => 'admin.point_gift.list']); @@ -100,9 +114,9 @@ class PointGiftController extends Controller */ public function deleteAction($id) { - $giftService = new PointGiftService(); + $service = new PointGiftService(); - $giftService->deleteGift($id); + $service->deletePointGift($id); $location = $this->request->getHTTPReferer(); @@ -119,9 +133,9 @@ class PointGiftController extends Controller */ public function restoreAction($id) { - $giftService = new PointGiftService(); + $service = new PointGiftService(); - $giftService->restoreGift($id); + $service->restorePointGift($id); $location = $this->request->getHTTPReferer(); diff --git a/app/Http/Admin/Controllers/SlideController.php b/app/Http/Admin/Controllers/SlideController.php index 8369c875..19cee2ca 100644 --- a/app/Http/Admin/Controllers/SlideController.php +++ b/app/Http/Admin/Controllers/SlideController.php @@ -22,12 +22,32 @@ class SlideController extends Controller $this->view->setVar('pager', $pager); } + /** + * @Get("/search", name="admin.slide.search") + */ + public function searchAction() + { + $slideService = new SlideService(); + + $targetTypes = $slideService->getTargetTypes(); + + $this->view->setVar('target_types', $targetTypes); + } + /** * @Get("/add", name="admin.slide.add") */ public function addAction() { + $slideService = new SlideService(); + $targetTypes = $slideService->getTargetTypes(); + $xmCourses = $slideService->getXmCourses(); + $xmPages = $slideService->getXmPages(); + + $this->view->setVar('target_types', $targetTypes); + $this->view->setVar('xm_courses', $xmCourses); + $this->view->setVar('xm_pages', $xmPages); } /** diff --git a/app/Http/Admin/Controllers/TestController.php b/app/Http/Admin/Controllers/TestController.php index 8ee8b549..38991007 100644 --- a/app/Http/Admin/Controllers/TestController.php +++ b/app/Http/Admin/Controllers/TestController.php @@ -27,14 +27,10 @@ class TestController extends Controller { $storageService = new StorageService(); - $result = []; + $result = $storageService->uploadTestFile(); - $result['hello'] = $storageService->uploadTestFile(); - $result['avatar'] = $storageService->uploadDefaultAvatarImage(); - $result['cover'] = $storageService->uploadDefaultCoverImage(); - - if ($result['hello'] && $result['avatar'] && $result['cover']) { - return $this->jsonSuccess(['msg' => '上传文件成功,请到控制台确认']); + if ($result) { + return $this->jsonSuccess(['msg' => '上传文件成功']); } else { return $this->jsonError(['msg' => '上传文件失败,请检查相关配置']); } diff --git a/app/Http/Admin/Controllers/UploadController.php b/app/Http/Admin/Controllers/UploadController.php index 878b784a..a6acddf0 100644 --- a/app/Http/Admin/Controllers/UploadController.php +++ b/app/Http/Admin/Controllers/UploadController.php @@ -10,6 +10,48 @@ use App\Services\MyStorage as StorageService; class UploadController extends Controller { + /** + * @Post("/site/logo", name="admin.upload.site_logo") + */ + public function uploadSiteLogoAction() + { + $service = new StorageService(); + + $file = $service->uploadSiteLogo(); + + if (!$file) { + return $this->jsonError(['msg' => '上传文件失败']); + } + + $data = [ + 'src' => $service->getImageUrl($file->path), + 'title' => $file->name, + ]; + + return $this->jsonSuccess(['data' => $data]); + } + + /** + * @Post("/site/favicon", name="admin.upload.site_favicon") + */ + public function uploadSiteFaviconAction() + { + $service = new StorageService(); + + $file = $service->uploadSiteFavicon(); + + if (!$file) { + return $this->jsonError(['msg' => '上传文件失败']); + } + + $data = [ + 'src' => $service->getImageUrl($file->path), + 'title' => $file->name, + ]; + + return $this->jsonSuccess(['data' => $data]); + } + /** * @Post("/cover/img", name="admin.upload.cover_img") */ @@ -73,6 +115,28 @@ class UploadController extends Controller return $this->jsonSuccess(['data' => $data]); } + /** + * @Post("/default/img", name="admin.upload.default_img") + */ + public function uploadDefaultImageAction() + { + $service = new StorageService(); + + $items = []; + + $items['user_avatar'] = $service->uploadDefaultUserAvatar(); + $items['group_avatar'] = $service->uploadDefaultGroupAvatar(); + $items['course_cover'] = $service->uploadDefaultCourseCover(); + $items['group_cover'] = $service->uploadDefaultPackageCover(); + $items['vip_cover'] = $service->uploadDefaultVipCover(); + + foreach ($items as $item) { + if (!$item) return $this->jsonError(['msg' => '上传文件失败']); + } + + return $this->jsonSuccess(['msg' => '上传文件成功']); + } + /** * @Get("/sign", name="admin.upload.sign") */ diff --git a/app/Http/Admin/Controllers/XmCourseController.php b/app/Http/Admin/Controllers/XmCourseController.php deleted file mode 100644 index b186843c..00000000 --- a/app/Http/Admin/Controllers/XmCourseController.php +++ /dev/null @@ -1,43 +0,0 @@ -getAllCourses(); - - return $this->jsonSuccess([ - 'count' => $pager->total_items, - 'data' => $pager->items, - ]); - } - - /** - * @Get("/paid", name="admin.xm.course.paid") - */ - public function paidAction() - { - $xmCourseService = new XmCourseService(); - - $pager = $xmCourseService->getPaidCourses(); - - return $this->jsonSuccess([ - 'count' => $pager->total_items, - 'data' => $pager->items, - ]); - } - -} diff --git a/app/Http/Admin/Services/AuthNode.php b/app/Http/Admin/Services/AuthNode.php index 9bb89df8..236ae11b 100644 --- a/app/Http/Admin/Services/AuthNode.php +++ b/app/Http/Admin/Services/AuthNode.php @@ -412,6 +412,12 @@ class AuthNode extends Service 'type' => 'button', 'route' => 'admin.slide.delete', ], + [ + 'id' => '2-5-5', + 'title' => '搜索轮播', + 'type' => 'menu', + 'route' => 'admin.slide.search', + ], ], ], [ @@ -525,6 +531,43 @@ class AuthNode extends Service ], ], ], + [ + 'id' => '2-9', + 'title' => '限时秒杀', + 'type' => 'menu', + 'children' => [ + [ + 'id' => '2-9-1', + 'title' => '商品列表', + 'type' => 'menu', + 'route' => 'admin.flash_sale.list', + ], + [ + 'id' => '2-9-2', + 'title' => '添加商品', + 'type' => 'menu', + 'route' => 'admin.flash_sale.add', + ], + [ + 'id' => '2-9-3', + 'title' => '搜索商品', + 'type' => 'menu', + 'route' => 'admin.flash_sale.search', + ], + [ + 'id' => '2-9-4', + 'title' => '编辑商品', + 'type' => 'button', + 'route' => 'admin.flash_sale.edit', + ], + [ + 'id' => '2-9-5', + 'title' => '删除商品', + 'type' => 'button', + 'route' => 'admin.flash_sale.delete', + ], + ], + ], ], ]; } diff --git a/app/Http/Admin/Services/Course.php b/app/Http/Admin/Services/Course.php index 1768f428..7ee7204d 100644 --- a/app/Http/Admin/Services/Course.php +++ b/app/Http/Admin/Services/Course.php @@ -261,18 +261,13 @@ class Course extends Service 'deleted' => 0, ]); - if ($allCategories->count() == 0) { - return []; - } + if ($allCategories->count() == 0) return []; $courseCategoryIds = []; if ($id > 0) { - $courseRepo = new CourseRepo(); - $courseCategories = $courseRepo->findCategories($id); - if ($courseCategories->count() > 0) { foreach ($courseCategories as $category) { $courseCategoryIds[] = $category->id; @@ -300,8 +295,8 @@ class Course extends Service $parentId = $category->parent_id; if ($category->level == 2) { $list[$parentId]['children'][] = [ - 'id' => $category->id, 'name' => $category->name, + 'value' => $category->id, 'selected' => $selected, ]; } @@ -316,18 +311,13 @@ class Course extends Service $allTeachers = $userRepo->findTeachers(); - if ($allTeachers->count() == 0) { - return []; - } + if ($allTeachers->count() == 0) return []; $courseTeacherIds = []; if ($id > 0) { - $courseRepo = new CourseRepo(); - $courseTeachers = $courseRepo->findTeachers($id); - if ($courseTeachers->count() > 0) { foreach ($courseTeachers as $teacher) { $courseTeacherIds[] = $teacher->id; @@ -340,8 +330,8 @@ class Course extends Service foreach ($allTeachers as $teacher) { $selected = in_array($teacher->id, $courseTeacherIds); $list[] = [ - 'id' => $teacher->id, 'name' => $teacher->name, + 'value' => $teacher->id, 'selected' => $selected, ]; } @@ -355,19 +345,29 @@ class Course extends Service $courses = $courseRepo->findRelatedCourses($id); - $list = []; + $courseIds = []; if ($courses->count() > 0) { foreach ($courses as $course) { - $list[] = [ - 'id' => $course->id, - 'title' => $course->title, - 'selected' => true, - ]; + $courseIds[] = $course->id; } } - return $list; + $items = $courseRepo->findAll(['published' => 1]); + + if ($items->count() == 0) return []; + + $result = []; + + foreach ($items as $item) { + $result[] = [ + 'name' => sprintf('%s(¥%0.2f)', $item->title, $item->market_price), + 'value' => $item->id, + 'selected' => in_array($item->id, $courseIds), + ]; + } + + return $result; } public function getChapters($id) @@ -431,7 +431,6 @@ class Course extends Service 'user_id' => $teacherId, 'role_type' => CourseUserModel::ROLE_TEACHER, 'source_type' => CourseUserModel::SOURCE_IMPORT, - 'expiry_time' => strtotime('+10 years'), ]); } } diff --git a/app/Http/Admin/Services/FlashSale.php b/app/Http/Admin/Services/FlashSale.php new file mode 100644 index 00000000..e8dea649 --- /dev/null +++ b/app/Http/Admin/Services/FlashSale.php @@ -0,0 +1,353 @@ +findOrFail($id); + + $result = []; + + foreach ($schedules as $schedule) { + $result[] = [ + 'name' => $schedule['name'], + 'value' => $schedule['hour'], + 'selected' => in_array($schedule['hour'], $sale->schedules), + ]; + } + + return $result; + } + + public function getXmCourses() + { + $courseRepo = new CourseRepo(); + + $items = $courseRepo->findAll(['free' => 0, 'published' => 1]); + + if ($items->count() == 0) return []; + + $result = []; + + foreach ($items as $item) { + $result[] = [ + 'name' => sprintf('%s(¥%0.2f)', $item->title, $item->market_price), + 'value' => $item->id, + ]; + } + + return $result; + } + + public function getXmPackages() + { + $packageRepo = new PackageRepo(); + + $items = $packageRepo->findAll(['published' => 1]); + + if ($items->count() == 0) return []; + + $result = []; + + foreach ($items as $item) { + $result[] = [ + 'name' => sprintf('%s(¥%0.2f)', $item->title, $item->market_price), + 'value' => $item->id, + ]; + } + + return $result; + } + + public function getXmVips() + { + $vipRepo = new VipRepo(); + + $items = $vipRepo->findAll(); + + if ($items->count() == 0) return []; + + $result = []; + + foreach ($items as $item) { + $result[] = [ + 'name' => sprintf('%s(¥%0.2f)', $item->title, $item->price), + 'value' => $item->id, + ]; + } + + return $result; + } + + public function getFlashSales() + { + $pagerQuery = new PagerQuery(); + + $params = $pagerQuery->getParams(); + + $params['deleted'] = $params['deleted'] ?? 0; + + $sort = $pagerQuery->getSort(); + $page = $pagerQuery->getPage(); + $limit = $pagerQuery->getLimit(); + + $saleRepo = new FlashSaleRepo(); + + return $saleRepo->paginate($params, $sort, $page, $limit); + } + + public function getFlashSale($id) + { + return $this->findOrFail($id); + } + + public function createFlashSale() + { + $post = $this->request->getPost(); + + $validator = new FlashSaleValidator(); + + $post['item_type'] = $validator->checkItemType($post['item_type']); + + $sale = new FlashSaleModel(); + + switch ($post['item_type']) { + case FlashSaleModel::ITEM_COURSE: + $sale = $this->createCourseFlashSale($post); + break; + case FlashSaleModel::ITEM_PACKAGE: + $sale = $this->createPackageFlashSale($post); + break; + case FlashSaleModel::ITEM_VIP: + $sale = $this->createVipFlashSale($post); + break; + } + + return $sale; + } + + public function updateFlashSale($id) + { + $sale = $this->findOrFail($id); + + $post = $this->request->getPost(); + + $originInfo = $this->getOriginInfo($sale->item_id, $sale->item_type); + + $validator = new FlashSaleValidator(); + + $data = []; + + $data['item_info'] = $originInfo['item_info']; + + if (isset($post['start_time']) && isset($post['end_time'])) { + $data['start_time'] = $validator->checkStartTime($post['start_time']); + $data['end_time'] = $validator->checkEndTime($post['end_time']); + $validator->checkTimeRange($data['start_time'], $data['end_time']); + } + + if (isset($post['xm_schedules'])) { + $data['schedules'] = $validator->checkSchedules($post['xm_schedules']); + } + + if (isset($post['stock'])) { + $data['stock'] = $validator->checkStock($post['stock']); + } + + if (isset($post['price'])) { + $data['price'] = $validator->checkPrice($originInfo['item_price'], $post['price']); + } + + if (isset($post['published'])) { + $data['published'] = $validator->checkPublishStatus($post['published']); + } + + $sale->update($data); + + $this->initFlashSaleQueue($sale->id); + + return $sale; + } + + public function deleteFlashSale($id) + { + $sale = $this->findOrFail($id); + + $sale->deleted = 1; + + $sale->update(); + + return $sale; + } + + public function restoreFlashSale($id) + { + $sale = $this->findOrFail($id); + + $sale->deleted = 0; + + $sale->update(); + + return $sale; + } + + protected function createCourseFlashSale($post) + { + $validator = new FlashSaleValidator(); + + $course = $validator->checkCourse($post['xm_course_id']); + + $originInfo = $this->getOriginInfo($course->id, FlashSaleModel::ITEM_COURSE); + + $sale = new FlashSaleModel(); + + $sale->item_id = $course->id; + $sale->item_type = FlashSaleModel::ITEM_COURSE; + $sale->item_info = $originInfo['item_info']; + + $sale->create(); + + return $sale; + } + + protected function createPackageFlashSale($post) + { + $validator = new FlashSaleValidator(); + + $package = $validator->checkPackage($post['xm_package_id']); + + $originInfo = $this->getOriginInfo($package->id, FlashSaleModel::ITEM_PACKAGE); + + $sale = new FlashSaleModel(); + + $sale->item_id = $package->id; + $sale->item_type = FlashSaleModel::ITEM_PACKAGE; + $sale->item_info = $originInfo['item_info']; + + $sale->create(); + + return $sale; + } + + protected function createVipFlashSale($post) + { + $validator = new FlashSaleValidator(); + + $vip = $validator->checkVip($post['xm_vip_id']); + + $originInfo = $this->getOriginInfo($vip->id, FlashSaleModel::ITEM_VIP); + + $sale = new FlashSaleModel(); + + $sale->item_id = $vip->id; + $sale->item_type = FlashSaleModel::ITEM_VIP; + $sale->item_info = $originInfo['item_info']; + + $sale->create(); + + return $sale; + } + + protected function getOriginInfo($itemId, $itemType) + { + $result = [ + 'item_info' => [], + 'item_price' => 0.00, + ]; + + if ($itemType == FlashSaleModel::ITEM_COURSE) { + + $courseRepo = new CourseRepo(); + + $course = $courseRepo->findById($itemId); + + $result = [ + 'item_info' => [ + 'course' => [ + 'id' => $course->id, + 'title' => $course->title, + 'cover' => CourseModel::getCoverPath($course->cover), + 'market_price' => $course->market_price, + ], + ], + 'item_price' => $course->market_price, + ]; + + } elseif ($itemType == FlashSaleModel::ITEM_PACKAGE) { + + $packageRepo = new PackageRepo(); + + $package = $packageRepo->findById($itemId); + + $result = [ + 'item_info' => [ + 'package' => [ + 'id' => $package->id, + 'title' => $package->title, + 'cover' => PackageModel::getCoverPath($package->cover), + 'market_price' => $package->market_price, + ], + ], + 'item_price' => $package->market_price, + ]; + + } elseif ($itemType == FlashSaleModel::ITEM_VIP) { + + $vipRepo = new VipRepo(); + + $vip = $vipRepo->findById($itemId); + + $result = [ + 'item_info' => [ + 'vip' => [ + 'id' => $vip->id, + 'title' => $vip->title, + 'cover' => VipModel::getCoverPath($vip->cover), + 'expiry' => $vip->expiry, + 'price' => $vip->price, + ], + ], + 'item_price' => $vip->price, + ]; + } + + return $result; + } + + protected function initFlashSaleQueue($id) + { + $queue = new FlashSaleQueue(); + + $queue->init($id); + } + + protected function findOrFail($id) + { + $validator = new FlashSaleValidator(); + + return $validator->checkFlashSale($id); + } + +} diff --git a/app/Http/Admin/Services/Package.php b/app/Http/Admin/Services/Package.php index e288eb88..f89a13ce 100644 --- a/app/Http/Admin/Services/Package.php +++ b/app/Http/Admin/Services/Package.php @@ -16,6 +16,39 @@ use App\Validators\Package as PackageValidator; class Package extends Service { + public function getXmCourses($id) + { + $packageRepo = new PackageRepo(); + + $courses = $packageRepo->findCourses($id); + + $courseIds = []; + + if ($courses->count() > 0) { + foreach ($courses as $course) { + $courseIds[] = $course->id; + } + } + + $courseRepo = new CourseRepo(); + + $items = $courseRepo->findAll(['free' => 0, 'published' => 1]); + + if ($items->count() == 0) return []; + + $result = []; + + foreach ($items as $item) { + $result[] = [ + 'name' => sprintf('%s(¥%0.2f)', $item->title, $item->market_price), + 'value' => $item->id, + 'selected' => in_array($item->id, $courseIds), + ]; + } + + return $result; + } + public function getPackages() { $pagerQuery = new PagerQuery(); @@ -68,6 +101,10 @@ class Package extends Service $data = []; + if (isset($post['cover'])) { + $data['cover'] = $validator->checkCover($post['cover']); + } + if (isset($post['title'])) { $data['title'] = $validator->checkTitle($post['title']); } @@ -127,61 +164,6 @@ class Package extends Service return $package; } - public function getGuidingCourses($courseIds) - { - if (empty($courseIds)) { - return []; - } - - $courseRepo = new CourseRepo(); - - $ids = explode(',', $courseIds); - - return $courseRepo->findByIds($ids); - } - - public function getGuidingPrice($courses) - { - $totalMarketPrice = 0; - $totalVipPrice = 0; - - if ($courses) { - foreach ($courses as $course) { - $totalMarketPrice += $course->market_price; - $totalVipPrice += $course->vip_price; - } - } - - $sgtMarketPrice = sprintf('%0.2f', intval($totalMarketPrice * 0.9)); - $sgtVipPrice = sprintf('%0.2f', intval($totalVipPrice * 0.8)); - - return [ - 'market_price' => $sgtMarketPrice, - 'vip_price' => $sgtVipPrice, - ]; - } - - public function getXmCourses($id) - { - $packageRepo = new PackageRepo(); - - $courses = $packageRepo->findCourses($id); - - $list = []; - - if ($courses->count() > 0) { - foreach ($courses as $course) { - $list[] = [ - 'id' => $course->id, - 'title' => $course->title, - 'selected' => true, - ]; - } - } - - return $list; - } - protected function saveCourses(PackageModel $package, $courseIds) { $packageRepo = new PackageRepo(); diff --git a/app/Http/Admin/Services/PointGift.php b/app/Http/Admin/Services/PointGift.php index b87211fe..0480bb65 100644 --- a/app/Http/Admin/Services/PointGift.php +++ b/app/Http/Admin/Services/PointGift.php @@ -4,13 +4,41 @@ namespace App\Http\Admin\Services; use App\Library\Paginator\Query as PagerQuery; use App\Models\PointGift as PointGiftModel; +use App\Repos\Course as CourseRepo; use App\Repos\PointGift as PointGiftRepo; use App\Validators\PointGift as PointGiftValidator; class PointGift extends Service { - public function getGifts() + public function getTypes() + { + return PointGiftModel::types(); + } + + public function getXmCourses() + { + $courseRepo = new CourseRepo(); + + $where = ['free' => 0, 'published' => 1]; + + $pager = $courseRepo->paginate($where, $sort = 'latest', 1, 10000); + + if ($pager->total_items == 0) return []; + + $result = []; + + foreach ($pager->items as $item) { + $result[] = [ + 'name' => sprintf('%s(¥%0.2f)', $item->title, $item->market_price), + 'value' => $item->id, + ]; + } + + return $result; + } + + public function getPointGifts() { $pagerQuery = new PagerQuery(); @@ -27,12 +55,12 @@ class PointGift extends Service return $giftRepo->paginate($params, $sort, $page, $limit); } - public function getGift($id) + public function getPointGift($id) { return $this->findOrFail($id); } - public function createGift() + public function createPointGift() { $post = $this->request->getPost(); @@ -44,17 +72,17 @@ class PointGift extends Service switch ($post['type']) { case PointGiftModel::TYPE_COURSE: - $gift = $this->createCourseGift($post); + $gift = $this->createCoursePointGift($post); break; case PointGiftModel::TYPE_GOODS: - $gift = $this->createCommodityGift($post); + $gift = $this->createGoodsPointGift($post); break; } return $gift; } - public function updateGift($id) + public function updatePointGift($id) { $gift = $this->findOrFail($id); @@ -101,7 +129,7 @@ class PointGift extends Service return $gift; } - public function deleteGift($id) + public function deletePointGift($id) { $gift = $this->findOrFail($id); @@ -112,7 +140,7 @@ class PointGift extends Service return $gift; } - public function restoreGift($id) + public function restorePointGift($id) { $gift = $this->findOrFail($id); @@ -123,11 +151,11 @@ class PointGift extends Service return $gift; } - protected function createCourseGift($post) + protected function createCoursePointGift($post) { $validator = new PointGiftValidator(); - $course = $validator->checkCourse($post['course_id']); + $course = $validator->checkCourse($post['xm_course_id']); $gift = new PointGiftModel(); @@ -139,7 +167,7 @@ class PointGift extends Service return $gift; } - protected function createCommodityGift($post) + protected function createGoodsPointGift($post) { $validator = new PointGiftValidator(); @@ -157,7 +185,7 @@ class PointGift extends Service { $validator = new PointGiftValidator(); - return $validator->checkGift($id); + return $validator->checkPointGift($id); } } diff --git a/app/Http/Admin/Services/Slide.php b/app/Http/Admin/Services/Slide.php index 54c7895b..50a19b2c 100644 --- a/app/Http/Admin/Services/Slide.php +++ b/app/Http/Admin/Services/Slide.php @@ -5,12 +5,59 @@ namespace App\Http\Admin\Services; use App\Caches\IndexSlideList as IndexSlideListCache; use App\Library\Paginator\Query as PagerQuery; use App\Models\Slide as SlideModel; +use App\Repos\Course as CourseRepo; +use App\Repos\Page as PageRepo; use App\Repos\Slide as SlideRepo; use App\Validators\Slide as SlideValidator; class Slide extends Service { + public function getTargetTypes() + { + return SlideModel::targetTypes(); + } + + public function getXmCourses() + { + $courseRepo = new CourseRepo(); + + $items = $courseRepo->findAll(['published' => 1]); + + if ($items->count() == 0) return []; + + $result = []; + + foreach ($items as $item) { + $result[] = [ + 'name' => sprintf('%s(¥%0.2f)', $item->title, $item->market_price), + 'value' => $item->id, + ]; + } + + return $result; + } + + public function getXmPages() + { + $pageRepo = new PageRepo(); + + $items = $pageRepo->findAll(['published' => 1]); + + if ($items->count() == 0) return []; + + $result = []; + + foreach ($items as $item) { + $result[] = [ + 'name' => $item->title, + 'value' => $item->id, + ]; + } + + return $result; + } + public function getSlides() { $pagerQuery = new PagerQuery(); @@ -39,26 +86,18 @@ class Slide extends Service $validator = new SlideValidator(); - $data['title'] = $validator->checkTitle($post['title']); - $data['target'] = $validator->checkTarget($post['target']); - - if ($post['target'] == SlideModel::TARGET_COURSE) { - $course = $validator->checkCourse($post['content']); - $data['content'] = $course->id; - $data['cover'] = $course->cover; - $data['summary'] = $course->summary; - } elseif ($post['target'] == SlideModel::TARGET_PAGE) { - $page = $validator->checkPage($post['content']); - $data['content'] = $page->id; - } elseif ($post['target'] == SlideModel::TARGET_LINK) { - $data['content'] = $validator->checkLink($post['content']); - } - - $data['priority'] = 20; + $post['title'] = $validator->checkTitle($post['title']); + $post['target'] = $validator->checkTarget($post['target']); $slide = new SlideModel(); - $slide->create($data); + if ($post['target'] == SlideModel::TARGET_COURSE) { + $slide = $this->createCourseSlide($post); + } elseif ($post['target'] == SlideModel::TARGET_PAGE) { + $slide = $this->createPageSlide($post); + } elseif ($post['target'] == SlideModel::TARGET_LINK) { + $slide = $this->createLinkSlide($post); + } $this->rebuildSlideCache(); @@ -79,26 +118,10 @@ class Slide extends Service $data['title'] = $validator->checkTitle($post['title']); } - if (isset($post['summary'])) { - $data['summary'] = $validator->checkSummary($post['summary']); - } - if (isset($post['cover'])) { $data['cover'] = $validator->checkCover($post['cover']); } - if (isset($post['content'])) { - if ($slide->target == SlideModel::TARGET_COURSE) { - $course = $validator->checkCourse($post['content']); - $data['content'] = $course->id; - } elseif ($slide->target == SlideModel::TARGET_PAGE) { - $page = $validator->checkPage($post['content']); - $data['content'] = $page->id; - } elseif ($slide->target == SlideModel::TARGET_LINK) { - $data['content'] = $validator->checkLink($post['content']); - } - } - if (isset($post['priority'])) { $data['priority'] = $validator->checkPriority($post['priority']); } @@ -140,6 +163,60 @@ class Slide extends Service return $slide; } + protected function createCourseSlide($post) + { + $validator = new SlideValidator(); + + $course = $validator->checkCourse($post['xm_course_id']); + + $slide = new SlideModel(); + + $slide->title = $post['title']; + $slide->target = $post['target']; + $slide->content = $course->id; + $slide->target_attrs = [ + 'course' => ['id' => $course->id, 'title' => $course->title] + ]; + + return $slide; + } + + protected function createPageSlide($post) + { + $validator = new SlideValidator(); + + $page = $validator->checkPage($post['xm_page_id']); + + $slide = new SlideModel(); + + $slide->title = $post['title']; + $slide->target = $post['target']; + $slide->content = $page->id; + $data['target_attrs'] = [ + 'page' => ['id' => $page->id, 'title' => $page->title] + ]; + + return $slide; + } + + protected function createLinkSlide($post) + { + $validator = new SlideValidator(); + + $link = $validator->checkLink($post['url']); + + $slide = new SlideModel(); + + $slide->title = $post['title']; + $slide->target = $post['target']; + $slide->content = $link; + $slide->target_attrs = [ + 'link' => ['url' => $link] + ]; + + return $slide; + } + protected function rebuildSlideCache() { $cache = new IndexSlideListCache(); diff --git a/app/Http/Admin/Services/Topic.php b/app/Http/Admin/Services/Topic.php index 7b0f2544..e5d966ed 100644 --- a/app/Http/Admin/Services/Topic.php +++ b/app/Http/Admin/Services/Topic.php @@ -6,6 +6,7 @@ use App\Caches\Topic as TopicCache; use App\Library\Paginator\Query as PagerQuery; use App\Models\CourseTopic as CourseTopicModel; use App\Models\Topic as TopicModel; +use App\Repos\Course as CourseRepo; use App\Repos\CourseTopic as CourseTopicRepo; use App\Repos\Topic as TopicRepo; use App\Validators\Topic as TopicValidator; @@ -13,6 +14,39 @@ use App\Validators\Topic as TopicValidator; class Topic extends Service { + public function getXmCourses($id) + { + $topicRepo = new TopicRepo(); + + $courses = $topicRepo->findCourses($id); + + $courseIds = []; + + if ($courses->count() > 0) { + foreach ($courses as $course) { + $courseIds[] = $course->id; + } + } + + $courseRepo = new CourseRepo(); + + $items = $courseRepo->findAll(['published' => 1]); + + if ($items->count() == 0) return []; + + $result = []; + + foreach ($items as $item) { + $result[] = [ + 'name' => sprintf('%s(¥%0.2f)', $item->title, $item->market_price), + 'value' => $item->id, + 'selected' => in_array($item->id, $courseIds), + ]; + } + + return $result; + } + public function getTopics() { $pagerQuery = new PagerQuery(); @@ -116,27 +150,6 @@ class Topic extends Service return $topic; } - public function getXmCourses($id) - { - $topicRepo = new TopicRepo(); - - $courses = $topicRepo->findCourses($id); - - $list = []; - - if ($courses->count() > 0) { - foreach ($courses as $course) { - $list[] = [ - 'id' => $course->id, - 'title' => $course->title, - 'selected' => true, - ]; - } - } - - return $list; - } - protected function saveCourses(TopicModel $topic, $courseIds) { $topicRepo = new TopicRepo(); diff --git a/app/Http/Admin/Services/XmCourse.php b/app/Http/Admin/Services/XmCourse.php deleted file mode 100644 index fbf35967..00000000 --- a/app/Http/Admin/Services/XmCourse.php +++ /dev/null @@ -1,46 +0,0 @@ -getParams(); - - $params['deleted'] = 0; - - $sort = $pagerQuery->getSort(); - $page = $pagerQuery->getPage(); - $limit = $pagerQuery->getLimit(); - - $courseRepo = new CourseRepo(); - - return $courseRepo->paginate($params, $sort, $page, $limit); - } - - public function getPaidCourses() - { - $pagerQuery = new PagerQuery(); - - $params = $pagerQuery->getParams(); - - $params['free'] = 0; - $params['deleted'] = 0; - - $sort = $pagerQuery->getSort(); - $page = $pagerQuery->getPage(); - $limit = $pagerQuery->getLimit(); - - $courseRepo = new CourseRepo(); - - return $courseRepo->paginate($params, $sort, $page, $limit); - } - -} diff --git a/app/Http/Admin/Views/category/list.volt b/app/Http/Admin/Views/category/list.volt index 6a2e9b04..65a614ad 100644 --- a/app/Http/Admin/Views/category/list.volt +++ b/app/Http/Admin/Views/category/list.volt @@ -58,8 +58,8 @@ {% else %} {{ item.name }} {% endif %} - {{ item.level }} - {{ item.child_count }} + {{ item.level }} + {{ item.child_count }} diff --git a/app/Http/Admin/Views/consult/edit.volt b/app/Http/Admin/Views/consult/edit.volt index 22fe2f62..b3d2b799 100644 --- a/app/Http/Admin/Views/consult/edit.volt +++ b/app/Http/Admin/Views/consult/edit.volt @@ -9,7 +9,7 @@
- +
{{ consult.question }}
@@ -18,13 +18,6 @@
-
- -
- - -
-
diff --git a/app/Http/Admin/Views/consult/list.volt b/app/Http/Admin/Views/consult/list.volt index c4bba140..aed642e2 100644 --- a/app/Http/Admin/Views/consult/list.volt +++ b/app/Http/Admin/Views/consult/list.volt @@ -63,7 +63,14 @@

昵称:{{ item.owner.name }}

编号:{{ item.owner.id }}

- {{ date('Y-m-d H:i:s',item.create_time) }} + +

提问:{{ date('Y-m-d H:i:s',item.create_time) }}

+ {% if item.reply_time > 0 %} +

回复:{{ date('Y-m-d H:i:s',item.reply_time) }}

+ {% else %} +

回复:N/A

+ {% endif %} +
diff --git a/app/Http/Admin/Views/course/add.volt b/app/Http/Admin/Views/course/add.volt index a90cd2e7..f457c85c 100644 --- a/app/Http/Admin/Views/course/add.volt +++ b/app/Http/Admin/Views/course/add.volt @@ -9,9 +9,10 @@
- - - + {% for value,title in model_types %} + {% set checked = value == 1 ? 'checked="checked"' : '' %} + + {% endfor %}
diff --git a/app/Http/Admin/Views/course/edit.volt b/app/Http/Admin/Views/course/edit.volt index 4fa6ff3e..2fac4899 100644 --- a/app/Http/Admin/Views/course/edit.volt +++ b/app/Http/Admin/Views/course/edit.volt @@ -41,7 +41,6 @@ {{ js_include('https://cdn.jsdelivr.net/npm/vditor/dist/index.min.js', false) }} {{ js_include('lib/xm-select.js') }} - {{ js_include('admin/js/xm-course.js') }} {{ js_include('admin/js/cover.upload.js') }} {{ js_include('admin/js/vditor.js') }} @@ -74,7 +73,14 @@ data: {{ xm_teachers|json_encode }} }); - xmCourse({{ xm_courses|json_encode }}, '/admin/xm/course/all'); + xmSelect.render({ + el: '#xm-course-ids', + name: 'xm_course_ids', + autoRow: true, + filterable: true, + max: 10, + data: {{ xm_courses|json_encode }} + }); diff --git a/app/Http/Admin/Views/course/edit_sale.volt b/app/Http/Admin/Views/course/edit_sale.volt index 039907e7..29365161 100644 --- a/app/Http/Admin/Views/course/edit_sale.volt +++ b/app/Http/Admin/Views/course/edit_sale.volt @@ -21,7 +21,7 @@
- +
diff --git a/app/Http/Admin/Views/course/list.volt b/app/Http/Admin/Views/course/list.volt index 77429637..cc89bb0e 100644 --- a/app/Http/Admin/Views/course/list.volt +++ b/app/Http/Admin/Views/course/list.volt @@ -4,18 +4,17 @@ {%- macro model_info(value) %} {% if value == 1 %} - 点播 + 点播 {% elseif value == 2 %} - 直播 + 直播 {% elseif value == 3 %} - 专栏 + 专栏 {% else %} - 未知 + 未知 {% endif %} {%- endmacro %} {%- macro level_info(value) %} - 难度: {% if value == 1 %} 入门 {% elseif value == 2 %} @@ -30,20 +29,6 @@ {%- endmacro %} - {%- macro category_info(category) %} - {% if category.id is defined %} - {% set url = url({'for':'admin.course.list'},{'category_id':category.id}) %} - 分类:{{ category.name }} - {% endif %} - {%- endmacro %} - - {%- macro teacher_info(teacher) %} - {% if teacher.id is defined %} - {% set url = url({'for':'admin.course.list'},{'teacher_id':teacher.id}) %} - 讲师:{{ teacher.name }} - {% endif %} - {%- endmacro %} - {% set add_url = url({'for':'admin.course.add'}) %} {% set search_url = url({'for':'admin.course.search'}) %} @@ -65,8 +50,8 @@ - - + + @@ -76,8 +61,8 @@ - + @@ -98,11 +83,19 @@ {% set review_url = url({'for':'admin.review.list'},{'course_id':item.id}) %} {% set consult_url = url({'for':'admin.consult.list'},{'course_id':item.id}) %} - + diff --git a/app/Http/Admin/Views/course/search.volt b/app/Http/Admin/Views/course/search.volt index 23a444dc..15c2732a 100644 --- a/app/Http/Admin/Views/course/search.volt +++ b/app/Http/Admin/Views/course/search.volt @@ -99,10 +99,7 @@ el: '#xm-category-ids', name: 'xm_category_ids', max: 5, - prop: { - name: 'name', - value: 'id' - }, + filterable: true, data: {{ xm_categories|json_encode }} }); @@ -110,10 +107,7 @@ el: '#xm-teacher-ids', name: 'xm_teacher_ids', max: 5, - prop: { - name: 'name', - value: 'id' - }, + filterable: true, data: {{ xm_teachers|json_encode }} }); diff --git a/app/Http/Admin/Views/flash_sale/add.volt b/app/Http/Admin/Views/flash_sale/add.volt new file mode 100644 index 00000000..4e959894 --- /dev/null +++ b/app/Http/Admin/Views/flash_sale/add.volt @@ -0,0 +1,99 @@ +{% extends 'templates/main.volt' %} + +{% block content %} + + +
+ 添加商品 +
+
+ +
+ {% for value,title in item_types %} + + {% endfor %} +
+
+ + + +
+ +
+ + +
+
+ + +{% endblock %} + +{% block include_js %} + + {{ js_include('lib/xm-select.js') }} + +{% endblock %} + +{% block inline_js %} + + + +{% endblock %} \ No newline at end of file diff --git a/app/Http/Admin/Views/flash_sale/edit.volt b/app/Http/Admin/Views/flash_sale/edit.volt new file mode 100644 index 00000000..6142bac2 --- /dev/null +++ b/app/Http/Admin/Views/flash_sale/edit.volt @@ -0,0 +1,103 @@ +{% extends 'templates/main.volt' %} + +{% block content %} + + {{ partial('macros/flash_sale') }} + + {% set sale.item_info = array_object(sale.item_info) %} + {% set sale.start_time = sale.start_time > 0 ? date('Y-m-d H:i:s',sale.start_time) : '' %} + {% set sale.end_time = sale.end_time > 0 ? date('Y-m-d H:i:s',sale.end_time) : '' %} + + +
+ 编辑商品 +
+
+ +
+ {{ item_full_info(sale.item_type,sale.item_info) }} +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+ + +{% endblock %} + +{% block include_js %} + + {{ js_include('lib/xm-select.js') }} + +{% endblock %} + +{% block inline_js %} + + + +{% endblock %} \ No newline at end of file diff --git a/app/Http/Admin/Views/flash_sale/list.volt b/app/Http/Admin/Views/flash_sale/list.volt new file mode 100644 index 00000000..d8e113b5 --- /dev/null +++ b/app/Http/Admin/Views/flash_sale/list.volt @@ -0,0 +1,83 @@ +{% extends 'templates/main.volt' %} + +{% block content %} + + {{ partial('macros/flash_sale') }} + + {% set add_url = url({'for':'admin.flash_sale.add'}) %} + {% set search_url = url({'for':'admin.flash_sale.search'}) %} + + + +
编号 课程类型 课时数 用户数 价格
{{ item.id }} -

标题:{{ item.title }} {{ model_info(item.model) }}

-

{{ category_info(item.category) }}  {{ teacher_info(item.teacher) }}  {{ level_info(item.level) }}

+

标题:{{ item.title }}({{ item.id }})

+

+ {% if item.category.id is defined %} + 分类:{{ item.category.name }} + {% endif %} + {% if item.teacher.id is defined %} + 讲师:{{ item.teacher.name }} + {% endif %} + 难度:{{ level_info(item.level) }} +

{{ model_info(item.model) }} {{ item.lesson_count }} @@ -115,7 +108,7 @@

原始价:{{ '¥%0.2f'|format(item.origin_price) }}

-

优惠价:{{ '¥%0.2f'|format(item.market_price) }}

+

市场价:{{ '¥%0.2f'|format(item.market_price) }}

会员价:{{ '¥%0.2f'|format(item.vip_price) }}

+ + + + + + + + + + + + + + + + + + + + + + {% for item in pager.items %} + {% set edit_url = url({'for':'admin.flash_sale.edit','id':item.id}) %} + {% set update_url = url({'for':'admin.flash_sale.update','id':item.id}) %} + {% set delete_url = url({'for':'admin.flash_sale.delete','id':item.id}) %} + {% set restore_url = url({'for':'admin.flash_sale.restore','id':item.id}) %} + + + + + + + + + + {% endfor %} + +
商品信息秒杀价格秒杀库存秒杀时间参与场次发布操作
{{ item_full_info(item.item_type,item.item_info) }}{{ '¥%0.2f'|format(item.price) }}{{ item.stock }} +

开始:{{ date('Y-m-d H:i:s',item.start_time) }}

+

结束:{{ date('Y-m-d H:i:s',item.end_time) }}

+
{{ schedules_info(item.schedules) }} +
+ + +
+
+ + {{ partial('partials/pager') }} + +{% endblock %} \ No newline at end of file diff --git a/app/Http/Admin/Views/flash_sale/search.volt b/app/Http/Admin/Views/flash_sale/search.volt new file mode 100644 index 00000000..0036dd70 --- /dev/null +++ b/app/Http/Admin/Views/flash_sale/search.volt @@ -0,0 +1,46 @@ +{% extends 'templates/main.volt' %} + +{% block content %} + +
+
+ 搜索商品 +
+
+ +
+ +
+
+
+ +
+ {% for value,title in item_types %} + + {% endfor %} +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +{% endblock %} \ No newline at end of file diff --git a/app/Http/Admin/Views/help/add.volt b/app/Http/Admin/Views/help/add.volt index bd4ce5e2..fe2a2508 100644 --- a/app/Http/Admin/Views/help/add.volt +++ b/app/Http/Admin/Views/help/add.volt @@ -36,13 +36,6 @@
-
- -
- - -
-
diff --git a/app/Http/Admin/Views/im/group/list.volt b/app/Http/Admin/Views/im/group/list.volt index 89ecddfb..6f1724d0 100644 --- a/app/Http/Admin/Views/im/group/list.volt +++ b/app/Http/Admin/Views/im/group/list.volt @@ -4,19 +4,20 @@ {%- macro type_info(value) %} {% if value == 1 %} - + 课程 {% elseif value == 2 %} - + 水吧 {% elseif value == 3 %} - + 职工 {% else %} - 未知 + 未知 {% endif %} {%- endmacro %} {%- macro owner_info(owner) %} {% if owner.id is defined %} - {{ owner.name }}({{ owner.id }}) + {% set filter_url = url({'for':'admin.im_group.list'},{'owner_id':owner.id}) %} + {{ owner.name }}({{ owner.id }}) {% else %} 未设置 {% endif %} @@ -48,12 +49,14 @@ + 编号 名称 + 类型 群主 成员 发布 @@ -69,7 +72,8 @@ {% set restore_url = url({'for':'admin.im_group.restore','id':item.id}) %} {{ item.id }} - {{ item.name }} {{ type_info(item.type) }} + {{ item.name }} + {{ type_info(item.type) }} {{ owner_info(item.owner) }} {{ item.user_count }} diff --git a/app/Http/Admin/Views/macros/flash_sale.volt b/app/Http/Admin/Views/macros/flash_sale.volt new file mode 100644 index 00000000..4a63a320 --- /dev/null +++ b/app/Http/Admin/Views/macros/flash_sale.volt @@ -0,0 +1,31 @@ +{%- macro item_type_info(value) %} + {% if value == 1 %} + 课程 + {% elseif value == 2 %} + 套餐 + {% elseif value == 3 %} + 会员 + {% endif %} +{%- endmacro %} + +{%- macro item_full_info(item_type,item_info) %} + {% if item_type == 1 %} + {% set course = item_info.course %} +

名称:{{ course.title }}({{ course.id }})

+

类型:{{ item_type_info(item_type) }} 价格:{{ '¥%0.2f'|format(course.market_price) }}

+ {% elseif item_type == 2 %} + {% set package = item_info.package %} +

名称:{{ package.title }}({{ package.id }})

+

类型:{{ item_type_info(item_type) }} 价格:{{ '¥%0.2f'|format(package.market_price) }}

+ {% elseif item_type == 3 %} + {% set vip = item_info.vip %} +

期限:{{ '%d个月'|format(vip.expiry) }}({{ vip.id }})

+

类型:{{ item_type_info(item_type) }} 价格:{{ '¥%0.2f'|format(vip.price) }}

+ {% endif %} +{%- endmacro %} + +{%- macro schedules_info(schedules) %} + {% for value in schedules %} + {{ value }}点 + {% endfor %} +{%- endmacro %} \ No newline at end of file diff --git a/app/Http/Admin/Views/macros/point.volt b/app/Http/Admin/Views/macros/point.volt index 06aced06..85bcbc60 100644 --- a/app/Http/Admin/Views/macros/point.volt +++ b/app/Http/Admin/Views/macros/point.volt @@ -1,20 +1,20 @@ {%- macro redeem_status_info(value) %} {% if value == 1 %} - 处理中 + 处理中 {% elseif value == 2 %} - 已完成 + 已完成 {% elseif value == 3 %} - 已失败 + 已失败 {% endif %} {%- endmacro %} {%- macro gift_type_info(value) %} {% if value == 1 %} - 课程 + 课程 {% elseif value == 2 %} - 商品 + 商品 {% elseif value == 3 %} - 现金 + 现金 {% endif %} {%- endmacro %} @@ -28,21 +28,21 @@ {%- macro event_type_info(value) %} {% if value == 1 %} - 订单消费 + 订单消费 {% elseif value == 2 %} - 积分兑换 + 积分兑换 {% elseif value == 3 %} - 积分退款 + 积分退款 {% elseif value == 4 %} - 帐号注册 + 帐号注册 {% elseif value == 5 %} - 站点访问 + 站点访问 {% elseif value == 6 %} - 课时学习 + 课时学习 {% elseif value == 7 %} - 课程评价 + 课程评价 {% elseif value == 8 %} - 微聊讨论 + 微聊讨论 {% endif %} {%- endmacro %} diff --git a/app/Http/Admin/Views/macros/slide.volt b/app/Http/Admin/Views/macros/slide.volt new file mode 100644 index 00000000..2901eb6a --- /dev/null +++ b/app/Http/Admin/Views/macros/slide.volt @@ -0,0 +1,21 @@ +{%- macro target_info(value) %} + {% if value == 1 %} + 课程 + {% elseif value == 2 %} + 单页 + {% elseif value == 3 %} + 链接 + {% endif %} +{%- endmacro %} + +{%- macro target_attrs_info(value) %} + {% if value.course is defined %} + {% set url = url({'for':'home.course.show','id':value.course.id}) %} + {{ value.course.title }}({{ value.course.id }}) + {% elseif value.page is defined %} + {% set url = url({'for':'home.page.show','id':value.page.id}) %} + {{ value.page.title }}({{ value.page.id }}) + {% elseif value.link is defined %} + {{ value.link.url }} + {% endif %} +{%- endmacro %} \ No newline at end of file diff --git a/app/Http/Admin/Views/nav/list.volt b/app/Http/Admin/Views/nav/list.volt index 20bf8ba2..86d3f7d6 100644 --- a/app/Http/Admin/Views/nav/list.volt +++ b/app/Http/Admin/Views/nav/list.volt @@ -77,8 +77,8 @@ {% else %} {{ item.name }} {% endif %} - {{ item.level }} - {{ item.child_count }} + {{ item.level }} + {{ item.child_count }} {{ position_info(item.position) }} {{ target_info(item.target) }} diff --git a/app/Http/Admin/Views/order/list.volt b/app/Http/Admin/Views/order/list.volt index 4ec3802f..38d5be5c 100644 --- a/app/Http/Admin/Views/order/list.volt +++ b/app/Http/Admin/Views/order/list.volt @@ -43,8 +43,13 @@ {% set show_url = url({'for':'admin.order.show','id':item.id}) %} -

商品:{{ item.subject }}

-

单号:{{ item.sn }}

+

名称:{{ item.subject }}

+

+ 单号:{{ item.sn }} + {% if item.promotion_type > 0 %} + 促销:{{ promotion_type(item.promotion_type) }} + {% endif %} +

昵称:{{ item.owner.name }}

diff --git a/app/Http/Admin/Views/order/macro.volt b/app/Http/Admin/Views/order/macro.volt index 6b6a4847..ef8de879 100644 --- a/app/Http/Admin/Views/order/macro.volt +++ b/app/Http/Admin/Views/order/macro.volt @@ -3,7 +3,7 @@ {% set course = order.item_info['course'] %}

课程名称:{{ course['title'] }}

-

优惠价格:{{ '¥%0.2f'|format(course['market_price']) }},会员价格:{{ '¥%0.2f'|format(course['vip_price']) }}

+

市场价格:{{ '¥%0.2f'|format(course['market_price']) }},会员价格:{{ '¥%0.2f'|format(course['vip_price']) }}

学习期限:{{ date('Y-m-d H:i:s',course['study_expiry_time']) }},退款期限:{% if course['refund_expiry'] > 0 %}{{ date('Y-m-d H:i:s',course['refund_expiry_time']) }}{% else %}不支持{% endif %}

{% elseif order.item_type == 2 %} @@ -11,7 +11,7 @@ {% for course in courses %}

课程名称:{{ course['title'] }}

-

优惠价格:{{ '¥%0.2f'|format(course['market_price']) }},会员价格:{{ '¥%0.2f'|format(course['vip_price']) }}

+

市场价格:{{ '¥%0.2f'|format(course['market_price']) }},会员价格:{{ '¥%0.2f'|format(course['vip_price']) }}

学习期限:{{ date('Y-m-d H:i:s',course['study_expiry_time']) }},退款期限:{% if course['refund_expiry'] > 0 %}{{ date('Y-m-d H:i:s',course['refund_expiry_time']) }}{% else %}不支持{% endif %}

{% endfor %} @@ -62,4 +62,14 @@ {% elseif value == 5 %} 已退款 {% endif %} +{%- endmacro %} + +{%- macro promotion_type(value) %} + {% if value == 0 %} + N/A + {% elseif value == 1 %} + 秒杀 + {% elseif value == 2 %} + 折扣 + {% endif %} {%- endmacro %} \ No newline at end of file diff --git a/app/Http/Admin/Views/order/order_info.volt b/app/Http/Admin/Views/order/order_info.volt index 73b9dbca..4cc52a4d 100644 --- a/app/Http/Admin/Views/order/order_info.volt +++ b/app/Http/Admin/Views/order/order_info.volt @@ -6,7 +6,10 @@ - + diff --git a/app/Http/Admin/Views/package/edit.volt b/app/Http/Admin/Views/package/edit.volt index deb2ceed..4fad5dfd 100644 --- a/app/Http/Admin/Views/package/edit.volt +++ b/app/Http/Admin/Views/package/edit.volt @@ -12,6 +12,16 @@ +
+ +
+ + +
+
+ +
+
@@ -26,14 +36,11 @@
- +
-
@@ -43,9 +50,6 @@
-
@@ -62,7 +66,7 @@ {% block include_js %} {{ js_include('lib/xm-select.js') }} - {{ js_include('admin/js/xm-course.js') }} + {{ js_include('admin/js/cover.upload.js') }} {% endblock %} @@ -70,24 +74,14 @@ {% endblock %} diff --git a/app/Http/Admin/Views/topic/list.volt b/app/Http/Admin/Views/topic/list.volt index 10290a79..fb7f0bc1 100644 --- a/app/Http/Admin/Views/topic/list.volt +++ b/app/Http/Admin/Views/topic/list.volt @@ -52,7 +52,7 @@
- + diff --git a/app/Http/Admin/Views/user/list.volt b/app/Http/Admin/Views/user/list.volt index 8d164110..20469b77 100644 --- a/app/Http/Admin/Views/user/list.volt +++ b/app/Http/Admin/Views/user/list.volt @@ -12,17 +12,17 @@ {% endif %} {%- endmacro %} - {%- macro edu_role_info(user) %} - {% if user.edu_role.id == 1 %} + {%- macro edu_role_info(role) %} + {% if role.id == 1 %} 学员 - {% elseif user.edu_role.id == 2 %} - 讲师 + {% elseif role.id == 2 %} + 讲师 {% endif %} {%- endmacro %} - {%- macro admin_role_info(user) %} - {% if user.admin_role.id > 0 %} - {{ user.admin_role.name }} + {%- macro admin_role_info(role) %} + {% if role.id > 0 %} + {{ role.name }} {% endif %} {%- endmacro %} @@ -85,8 +85,8 @@ - - + + - - @@ -34,9 +32,11 @@ {% set course_url = url({'for':'home.course.show','id':item.id}) %} {% set favorite_url = url({'for':'home.course.favorite','id':item.id}) %} - + - + + @@ -20,7 +22,8 @@ {% set owner_url = url({'for':'home.user.show','id':item.owner.id}) %} {% set delete_url = url({'for':'home.im.quit_group','id':item.id}) %} - + + + + @@ -19,7 +21,8 @@ {% set edit_url = url({'for':'home.igm.edit','id':item.id}) %} {% set users_url = url({'for':'home.igm.users','id':item.id}) %} - + +
订单编号:{{ order.sn }} + 订单编号:{{ order.sn }} + 促销类型:{{ promotion_type(order.promotion_type) }} +
商品信息
{{ item.id }} {{ item.title }}{{ item.course_count }}{{ item.course_count }} {{ date('Y-m-d H:i',item.create_time) }} {{ date('Y-m-d H:i',item.update_time) }} {{ item.id }} {{ item.name }}{{ status_info(item) }} {{ gender_info(item.gender) }}{{ edu_role_info(item) }}{{ admin_role_info(item) }}{{ edu_role_info(item.edu_role) }}{{ admin_role_info(item.admin_role) }} {{ date('Y-m-d H:i:s',item.active_time) }} {{ date('Y-m-d H:i:s',item.create_time) }} diff --git a/app/Http/Home/Controllers/FlashSaleController.php b/app/Http/Home/Controllers/FlashSaleController.php new file mode 100644 index 00000000..16e89c0c --- /dev/null +++ b/app/Http/Home/Controllers/FlashSaleController.php @@ -0,0 +1,58 @@ +authUser->id == 0) { + $this->response->redirect(['for' => 'home.account.login']); + return false; + } + + return true; + } + + /** + * @Get("/", name="home.flash_sale.index") + */ + public function indexAction() + { + $this->seo->prependTitle('秒杀'); + + $service = new SaleListService(); + + $sales = $service->handle(); + + $this->view->setVar('sales', $sales); + } + + /** + * @Post("/order", name="home.flash_sale.order") + */ + public function orderAction() + { + $service = new OrderCreateService(); + + $order = $service->handle(); + + $location = $this->url->get( + ['for' => 'home.order.pay'], + ['sn' => $order->sn] + ); + + return $this->jsonSuccess(['location' => $location]); + } + +} diff --git a/app/Http/Home/Controllers/PackageController.php b/app/Http/Home/Controllers/PackageController.php index 261cbb47..12a7f513 100644 --- a/app/Http/Home/Controllers/PackageController.php +++ b/app/Http/Home/Controllers/PackageController.php @@ -4,6 +4,7 @@ namespace App\Http\Home\Controllers; use App\Services\Logic\Package\CourseList as PackageCourseListService; use App\Services\Logic\Package\PackageInfo as PackageInfoService; +use Phalcon\Mvc\View; /** * @RoutePrefix("/package") @@ -32,7 +33,9 @@ class PackageController extends Controller $courses = $service->handle($id); - return $this->jsonSuccess(['courses' => $courses]); + $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); + + $this->view->setVar('courses', $courses); } } diff --git a/app/Http/Home/Views/flash_sale/index.volt b/app/Http/Home/Views/flash_sale/index.volt new file mode 100644 index 00000000..05becda3 --- /dev/null +++ b/app/Http/Home/Views/flash_sale/index.volt @@ -0,0 +1,144 @@ +{% extends 'templates/main.volt' %} + +{% block content %} + + {%- macro sale_status(value) %} + {% if value == 'active' %} + 进行中 + {% elseif value == 'pending' %} + 未开始 + {% elseif value == 'finished' %} + 已结束 + {% endif %} + {% endmacro %} + + {%- macro sale_info(sale,status) %} + {% if sale.item_type == 1 %} + {{ course_sale_info(sale,status) }} + {% elseif sale.item_type == 2 %} + {{ package_sale_info(sale,status) }} + {% elseif sale.item_type == 3 %} + {{ vip_sale_info(sale,status) }} + {% endif %} + {% endmacro %} + + {%- macro course_sale_info(sale,status) %} + {% set course = sale.item_info.course %} + {% set course_url = url({'for':'home.course.show','id':course.id}) %} +
+
+ + {{ course.title }} + +
+
+ +
+ {{ '¥%0.2f'|format(course.market_price) }} + {{ '¥%0.2f'|format(sale.price) }} + {% if status == 'active' %} + 立即购买 + {% else %} + 立即购买 + {% endif %} +
+
+
+ {% endmacro %} + + {%- macro package_sale_info(sale,status) %} + {% set package = sale.item_info.package %} + {% set link_url = url({'for':'home.package.courses','id':package.id}) %} +
+
+ + {{ package.title }} + +
+
+ +
+ {{ '¥%0.2f'|format(package.market_price) }} + {{ '¥%0.2f'|format(sale.price) }} + {% if status == 'active' %} + 立即购买 + {% else %} + 立即购买 + {% endif %} +
+
+
+ {% endmacro %} + + {%- macro vip_sale_info(sale,status) %} + {% set vip = sale.item_info.vip %} + {% set vip.title = "会员服务(%s)"|format(vip.title) %} +
+
+ {{ vip.title }} +
+
+ +
+ {{ '¥%0.2f'|format(vip.price) }} + {{ '¥%0.2f'|format(sale.price) }} + {% if status == 'active' %} + 立即购买 + {% else %} + 立即购买 + {% endif %} +
+
+
+ {% endmacro %} + + + + {% for date_sale in sales %} +
+
{{ date_sale.date }}
+
+
+
    + {% for item in date_sale.items %} + {% set class = item.selected == 1 ? 'layui-this' : 'none' %} +
  • {{ item.hour }}({{ sale_status(item.status) }})
  • + {% endfor %} +
+
+ {% for item in date_sale.items %} + {% set class = item.selected == 1 ? 'layui-tab-item layui-show' : 'layui-tab-item' %} +
+
+
+ {% for sale in item.items %} +
+ {{ sale_info(sale,item.status) }} +
+ {% endfor %} +
+
+
+ {% endfor %} +
+
+
+
+ {% endfor %} + +{% endblock %} + +{% block include_js %} + + {{ js_include('home/js/flashsale.js') }} + +{% endblock %} \ No newline at end of file diff --git a/app/Http/Home/Views/im/group/manage/users.volt b/app/Http/Home/Views/im/group/manage/users.volt index 69197bcf..44a4c5f0 100644 --- a/app/Http/Home/Views/im/group/manage/users.volt +++ b/app/Http/Home/Views/im/group/manage/users.volt @@ -2,30 +2,31 @@ {% block content %} -
-
-
- {% for item in pager.items %} - {% set delete_url = url({'for':'home.igm.delete_user','gid':group.id,'uid':item.id}) %} -
-
- {% if item.vip == 1 %} - 会员 - {% endif %} -
- {{ item.name }} -
-
{{ item.name }}
-
- + {% if pager.total_items > 0 %} +
+
+
+ {% for item in pager.items %} + {% set delete_url = url({'for':'home.igm.delete_user','gid':group.id,'uid':item.id}) %} +
+
+
+ + {{ item.name }} + +
+
{{ item.name }}
+
+ +
-
- {% endfor %} + {% endfor %} +
+ {{ partial('partials/pager') }}
- {{ partial('partials/pager') }} -
+ {% endif %} {% endblock %} diff --git a/app/Http/Home/Views/im/group/pager.volt b/app/Http/Home/Views/im/group/pager.volt index 9d24dfa3..86a390d1 100644 --- a/app/Http/Home/Views/im/group/pager.volt +++ b/app/Http/Home/Views/im/group/pager.volt @@ -8,7 +8,7 @@ {% set item.about = item.about ? item.about : '这家伙真懒,什么都没留下!' %}
- {{ type_info(item.type) }} + {{ type_info(item.type) }}
{{ item.name }} diff --git a/app/Http/Home/Views/im/group/users.volt b/app/Http/Home/Views/im/group/users.volt index 59485efe..e582b83d 100644 --- a/app/Http/Home/Views/im/group/users.volt +++ b/app/Http/Home/Views/im/group/users.volt @@ -3,12 +3,10 @@ {% for item in pager.items %} {% set user_url = url({'for':'home.user.show','id':item.id}) %} {% set item.title = item.title ? item.title : '暂露头角' %} + {% set avatar_class = item.vip == 1 ? 'avatar vip' : 'avatar' %}
- {% if item.vip == 1 %} - - {% endif %} -
+
{{ item.name }} diff --git a/app/Http/Home/Views/im/index_groups.volt b/app/Http/Home/Views/im/index_groups.volt index 31ccfbca..90178a1a 100644 --- a/app/Http/Home/Views/im/index_groups.volt +++ b/app/Http/Home/Views/im/index_groups.volt @@ -5,7 +5,7 @@ {% set group.about = group.about ? group.about : '这家伙真懒,什么都没留下!' %}
- {{ type_info(group.type) }} + {{ type_info(group.type) }}
{{ group.name }} diff --git a/app/Http/Home/Views/im/index_users.volt b/app/Http/Home/Views/im/index_users.volt index 7167671d..6a1a888a 100644 --- a/app/Http/Home/Views/im/index_users.volt +++ b/app/Http/Home/Views/im/index_users.volt @@ -4,10 +4,10 @@ {% set user.title = user.title ? user.title : '暂露头角' %} {% set user.about = user.about ? user.about : '这个人很懒,什么都没留下' %} {% set user_url = url({'for':'home.user.show','id':user.id}) %} -
+ {% set avatar_class = user.vip == 1 ? 'avatar vip' : 'avatar' %} +
- {{ vip_info(user.vip) }} -
+
{{ user.name }} diff --git a/app/Http/Home/Views/macros/course.volt b/app/Http/Home/Views/macros/course.volt index 82f6d237..55a4248a 100644 --- a/app/Http/Home/Views/macros/course.volt +++ b/app/Http/Home/Views/macros/course.volt @@ -1,10 +1,10 @@ {%- macro model_info(value) %} {% if value == '1' %} - 点播 + 点播 {% elseif value == '2' %} - 直播 + 直播 {% elseif value == '3' %} - 专栏 + 专栏 {% endif %} {%- endmacro %} @@ -30,6 +30,7 @@ {%- macro course_card(course) %} {% set course_url = url({'for':'home.course.show','id':course.id}) %}
+ {{ model_info(course.model) }}
{{ course.title }} diff --git a/app/Http/Home/Views/macros/group.volt b/app/Http/Home/Views/macros/group.volt index 33fa8905..4a63a95a 100644 --- a/app/Http/Home/Views/macros/group.volt +++ b/app/Http/Home/Views/macros/group.volt @@ -1,9 +1,9 @@ {%- macro type_info(value) %} {% if value == 1 %} - + 课程 {% elseif value == 2 %} - + 水吧 {% elseif value == 3 %} - + 职工 {% endif %} {%- endmacro %} \ No newline at end of file diff --git a/app/Http/Home/Views/macros/order.volt b/app/Http/Home/Views/macros/order.volt index 8cab1c94..1ae967f0 100644 --- a/app/Http/Home/Views/macros/order.volt +++ b/app/Http/Home/Views/macros/order.volt @@ -65,3 +65,13 @@ 已退款 {% endif %} {%- endmacro %} + +{%- macro promotion_type(value) %} + {% if value == 0 %} + N/A + {% elseif value == 1 %} + 秒杀 + {% elseif value == 2 %} + 折扣 + {% endif %} +{%- endmacro %} diff --git a/app/Http/Home/Views/macros/user.volt b/app/Http/Home/Views/macros/user.volt index 965d3827..34542d2e 100644 --- a/app/Http/Home/Views/macros/user.volt +++ b/app/Http/Home/Views/macros/user.volt @@ -1,9 +1,3 @@ -{%- macro vip_info(value) %} - {% if value == 1 %} - - {% endif %} -{%- endmacro %} - {%- macro gender_icon(value) %} {% if value == 1 %} diff --git a/app/Http/Home/Views/order/confirm.volt b/app/Http/Home/Views/order/confirm.volt index 290e16bc..f9c030e7 100644 --- a/app/Http/Home/Views/order/confirm.volt +++ b/app/Http/Home/Views/order/confirm.volt @@ -53,7 +53,7 @@ {% set vip = item_info.vip %}
- 会员服务 + {{ vip.title }}

会员服务

diff --git a/app/Http/Home/Views/order/pay.volt b/app/Http/Home/Views/order/pay.volt index 5e3a0a88..a150e38b 100644 --- a/app/Http/Home/Views/order/pay.volt +++ b/app/Http/Home/Views/order/pay.volt @@ -25,7 +25,11 @@ {% endif %}
diff --git a/app/Http/Home/Views/package/courses.volt b/app/Http/Home/Views/package/courses.volt new file mode 100644 index 00000000..386fd834 --- /dev/null +++ b/app/Http/Home/Views/package/courses.volt @@ -0,0 +1,32 @@ +{% extends 'templates/layer.volt' %} + +{% block content %} + +
+ + + + + + + + + + + + + + + {% for item in courses %} + {% set course_url = url({'for':'home.course.show','id':item.id}) %} + + + + + + {% endfor %} + +
标题学员数价格
{{ item.title }}{{ item.user_count }}{{ '¥%0.2f'|format(item.market_price) }}
+
+ +{% endblock %} \ No newline at end of file diff --git a/app/Http/Home/Views/user/console/courses.volt b/app/Http/Home/Views/user/console/courses.volt index df932952..4d9a7f58 100644 --- a/app/Http/Home/Views/user/console/courses.volt +++ b/app/Http/Home/Views/user/console/courses.volt @@ -33,8 +33,14 @@ {% set allow_review = item.progress > 30 and item.reviewed == 0 %}
-

标题:{{ item.course.title }} {{ model_info(item.course.model) }}

-

来源:{{ source_type_info(item.source_type) }}  期限:{{ date('Y-m-d',item.expiry_time) }}

+

标题:{{ item.course.title }}

+

+ 类型:{{ model_info(item.course.model) }} + 来源:{{ source_type_info(item.source_type) }} + {% if item.expiry_time > 0 %} + 期限:{{ date('Y-m-d',item.expiry_time) }} + {% endif %} +

用时:{{ item.duration|duration }}

diff --git a/app/Http/Home/Views/user/console/favorites.volt b/app/Http/Home/Views/user/console/favorites.volt index 768f9506..b66abc28 100644 --- a/app/Http/Home/Views/user/console/favorites.volt +++ b/app/Http/Home/Views/user/console/favorites.volt @@ -17,14 +17,12 @@
课程 学员收藏 评分 操作
{{ item.title }} {{ model_info(item.model) }} + {{ item.title }} + {{ model_info(item.model) }} + {{ item.user_count }}{{ item.favorite_count }} {{ "%0.1f"|format(item.rating) }} diff --git a/app/Http/Home/Views/user/console/groups_joined.volt b/app/Http/Home/Views/user/console/groups_joined.volt index 624da3e9..ec46c2b5 100644 --- a/app/Http/Home/Views/user/console/groups_joined.volt +++ b/app/Http/Home/Views/user/console/groups_joined.volt @@ -4,11 +4,13 @@
名称类型 组长 成员 操作
{{ item.name }} {{ type_info(item.type) }}{{ item.name }}{{ type_info(item.type) }} {{ item.owner.name }} {{ item.user_count }} diff --git a/app/Http/Home/Views/user/console/groups_owned.volt b/app/Http/Home/Views/user/console/groups_owned.volt index 373a3874..ed8b90b1 100644 --- a/app/Http/Home/Views/user/console/groups_owned.volt +++ b/app/Http/Home/Views/user/console/groups_owned.volt @@ -4,11 +4,13 @@
名称类型 成员 讨论 操作
{{ item.name }} {{ type_info(item.type) }}{{ item.name }}{{ type_info(item.type) }} {{ item.user_count }} {{ item.msg_count }} diff --git a/app/Http/Home/Views/user/console/orders.volt b/app/Http/Home/Views/user/console/orders.volt index c5c91c51..d43233e9 100644 --- a/app/Http/Home/Views/user/console/orders.volt +++ b/app/Http/Home/Views/user/console/orders.volt @@ -25,8 +25,11 @@ {% set order_info_url = url({'for':'home.order.info'},{'sn':item.sn}) %}
- 编号:{{ item.sn }} - 时间:{{ date('Y-m-d H:i:s',item.create_time) }} + 编号:{{ item.sn }} + 时间:{{ date('Y-m-d H:i:s',item.create_time) }} + {% if item.promotion_type > 0 %} + 促销:{{ promotion_type(item.promotion_type) }} + {% endif %}
{{ item.subject }}
diff --git a/app/Http/Home/Views/user/console/point_history.volt b/app/Http/Home/Views/user/console/point_history.volt index b5a3a58e..a9cc481b 100644 --- a/app/Http/Home/Views/user/console/point_history.volt +++ b/app/Http/Home/Views/user/console/point_history.volt @@ -12,7 +12,7 @@ 积分记录
{% if pager.total_pages > 0 %} - +
diff --git a/app/Http/Home/Views/user/show.volt b/app/Http/Home/Views/user/show.volt index f8c616e4..aa0eb43e 100644 --- a/app/Http/Home/Views/user/show.volt +++ b/app/Http/Home/Views/user/show.volt @@ -9,6 +9,7 @@ {% set qrcode_url = url({'for':'home.qrcode'},{'text':full_user_url}) %} {% set user.area = user.area ? user.area : '火星' %} {% set user.about = user.about ? user.about : '这个家伙很懒,什么都没留下!' %} + {% set avatar_class = user.vip == 1 ? 'avatar vip' : 'avatar' %}