From 23305e173846cdcacbe84c185c125c40ad36809b Mon Sep 17 00:00:00 2001 From: koogua Date: Sat, 4 Jun 2022 16:12:06 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=97=B6=E9=95=BF=E8=A1=A5=E5=85=85=E6=9C=BA?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++++ app/Console/Tasks/VodEventTask.php | 29 ++++++++++++++++++++++++++--- app/Library/AppInfo.php | 2 +- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e4e1fb8..4d9bf02b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### [v1.5.4](https://gitee.com/koogua/course-tencent-cloud/releases/v1.5.4)(2022-06-30) + +- 优化章节排序初始值和步长 + ### [v1.5.3](https://gitee.com/koogua/course-tencent-cloud/releases/v1.5.3)(2022-05-30) - 优化章节排序初始值和步长 diff --git a/app/Console/Tasks/VodEventTask.php b/app/Console/Tasks/VodEventTask.php index 5dd243d5..be34f31d 100644 --- a/app/Console/Tasks/VodEventTask.php +++ b/app/Console/Tasks/VodEventTask.php @@ -56,6 +56,13 @@ class VodEventTask extends Task $attrs = $chapter->attrs; + /** + * 获取不到时长,尝试通过接口获得 + */ + if ($duration == 0) { + $duration = $this->getFileDuration($fileId); + } + /** * 获取不到时长视为失败 */ @@ -78,7 +85,7 @@ class VodEventTask extends Task $chapter->update(['attrs' => $attrs]); - $this->updateVodAttrs($chapter); + $this->updateCourseVodAttrs($chapter->course_id); } protected function handleProcedureStateChangedEvent($event) @@ -95,6 +102,13 @@ class VodEventTask extends Task $attrs = $chapter->attrs; + /** + * 获取不到时长,尝试通过接口获得 + */ + if ($attrs['duration'] == 0) { + $attrs['duration'] = $this->getFileDuration($fileId); + } + $processResult = $event['ProcedureStateChangeEvent']['MediaProcessResultSet'] ?? []; /** @@ -156,11 +170,20 @@ class VodEventTask extends Task return $vodService->confirmEvents($handles); } - protected function updateVodAttrs(ChapterModel $chapter) + protected function updateCourseVodAttrs($courseId) { $courseStats = new CourseStatService(); - $courseStats->updateVodAttrs($chapter->course_id); + $courseStats->updateVodAttrs($courseId); + } + + protected function getFileDuration($fileId) + { + $service = new VodService(); + + $metaInfo = $service->getOriginVideoInfo($fileId); + + return $metaInfo['duration'] ?? 0; } } diff --git a/app/Library/AppInfo.php b/app/Library/AppInfo.php index 036f5fac..1ead1181 100644 --- a/app/Library/AppInfo.php +++ b/app/Library/AppInfo.php @@ -16,7 +16,7 @@ class AppInfo protected $link = 'https://koogua.com'; - protected $version = '1.5.2'; + protected $version = '1.5.4'; public function __get($name) { From d86ee20ced20c026bf46cf237e0530614f897d42 Mon Sep 17 00:00:00 2001 From: koogua Date: Sat, 4 Jun 2022 16:13:33 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=AD=90=E5=88=86=E7=B1=BB=E6=9F=A5=E8=AF=A2=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Builders/CategoryTreeList.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Builders/CategoryTreeList.php b/app/Builders/CategoryTreeList.php index 6944aea8..1067c8fa 100644 --- a/app/Builders/CategoryTreeList.php +++ b/app/Builders/CategoryTreeList.php @@ -84,9 +84,9 @@ class CategoryTreeList extends Builder { $query = CategoryModel::query(); - $query->where('published = 1'); - $query->where('deleted = 0'); - $query->andWhere('parent_id = :parent_id:', ['parent_id' => $parentId]); + $query->where('parent_id = :parent_id:', ['parent_id' => $parentId]); + $query->andWhere('published = 1'); + $query->andWhere('deleted = 0'); $query->orderBy('priority ASC'); return $query->execute(); From 83a39e5648cd170886359ac3d22b8431fb2027f5 Mon Sep 17 00:00:00 2001 From: koogua Date: Tue, 7 Jun 2022 21:55:36 +0800 Subject: [PATCH 3/5] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E7=A7=AF=E5=88=86?= =?UTF-8?q?=E5=85=91=E6=8D=A2=E4=BC=9A=E5=91=98=202.=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=92=8C=E5=A5=97=E9=A4=90=E5=8F=91=E8=B4=A7?= =?UTF-8?q?=203.=E5=A2=9E=E5=8A=A0isp=E5=92=8C=E7=94=B5=E5=AD=90=E6=89=A7?= =?UTF-8?q?=E7=85=A7=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Tasks/PointGiftDeliverTask.php | 70 +++++++++---------- .../Admin/Controllers/PointGiftController.php | 2 + app/Http/Admin/Services/PointGift.php | 58 ++++++++++++++- app/Http/Admin/Views/macros/point_gift.volt | 2 +- app/Http/Admin/Views/point_gift/add.volt | 15 ++++ app/Http/Admin/Views/point_gift/edit.volt | 2 + app/Http/Admin/Views/point_gift/edit_vip.volt | 41 +++++++++++ app/Http/Admin/Views/setting/site.volt | 28 ++++++++ app/Http/Home/Views/macros/point_gift.volt | 2 +- app/Http/Home/Views/partials/footer.volt | 6 ++ app/Models/PointGift.php | 15 ++++ app/Repos/CourseUser.php | 13 ++++ app/Repos/PointGift.php | 9 +-- app/Services/Logic/Deliver/CourseDeliver.php | 33 ++++++++- app/Services/Logic/Deliver/PackageDeliver.php | 44 +----------- app/Validators/PointGift.php | 7 ++ db/migrations/20220607014823.php | 42 +++++++++++ 17 files changed, 302 insertions(+), 87 deletions(-) create mode 100644 app/Http/Admin/Views/point_gift/edit_vip.volt create mode 100644 db/migrations/20220607014823.php diff --git a/app/Console/Tasks/PointGiftDeliverTask.php b/app/Console/Tasks/PointGiftDeliverTask.php index ec93e357..b1553501 100644 --- a/app/Console/Tasks/PointGiftDeliverTask.php +++ b/app/Console/Tasks/PointGiftDeliverTask.php @@ -7,17 +7,16 @@ namespace App\Console\Tasks; -use App\Models\CourseUser as CourseUserModel; -use App\Models\ImGroupUser as ImGroupUserModel; use App\Models\PointGift as PointGiftModel; use App\Models\PointGiftRedeem as PointGiftRedeemModel; use App\Models\Task as TaskModel; use App\Repos\Course as CourseRepo; -use App\Repos\CourseUser as CourseUserRepo; -use App\Repos\ImGroup as ImGroupRepo; -use App\Repos\ImGroupUser as ImGroupUserRepo; use App\Repos\PointGift as PointGiftRepo; use App\Repos\PointGiftRedeem as PointGiftRedeemRepo; +use App\Repos\User as UserRepo; +use App\Repos\Vip as VipRepo; +use App\Services\Logic\Deliver\CourseDeliver as CourseDeliverService; +use App\Services\Logic\Deliver\VipDeliver as VipDeliverService; use App\Services\Logic\Notice\DingTalk\PointGiftRedeem as PointGiftRedeemNotice; use App\Services\Logic\Point\History\PointGiftRefund as PointGiftRefundPointHistory; use Phalcon\Mvc\Model\Resultset; @@ -52,6 +51,9 @@ class PointGiftDeliverTask extends Task case PointGiftModel::TYPE_COURSE: $this->handleCourseRedeem($redeem); break; + case PointGiftModel::TYPE_VIP: + $this->handleVipRedeem($redeem); + break; case PointGiftModel::TYPE_GOODS: $this->handleGoodsRedeem($redeem); break; @@ -112,54 +114,52 @@ class PointGiftDeliverTask extends Task throw new \RuntimeException('Course Not Found'); } - $groupRepo = new ImGroupRepo(); + $redeem->status = PointGiftRedeemModel::STATUS_FINISHED; - $group = $groupRepo->findByCourseId($course->id); - - if (!$group) { - throw new \RuntimeException('Im Group Not Found'); + if ($redeem->update() === false) { + throw new \RuntimeException('Update Point Redeem Status Failed'); } - $courseUserRepo = new CourseUserRepo(); + $userRepo = new UserRepo(); - $courseUser = $courseUserRepo->findCourseUser($course->id, $redeem->user_id); + $user = $userRepo->findById($redeem->user_id); - if (!$courseUser) { + $deliverService = new CourseDeliverService(); - $courseUser = new CourseUserModel(); + $deliverService->handle($course, $user); + } - $courseUser->user_id = $redeem->user_id; - $courseUser->course_id = $course->id; - $courseUser->expiry_time = strtotime("+{$course->study_expiry} months"); - $courseUser->role_type = CourseUserModel::ROLE_STUDENT; - $courseUser->source_type = CourseUserModel::SOURCE_POINT_REDEEM; + protected function handleVipRedeem(PointGiftRedeemModel $redeem) + { + $giftRepo = new PointGiftRepo(); - if ($courseUser->create() === false) { - throw new \RuntimeException('Create Course User Failed'); - } + $gift = $giftRepo->findById($redeem->gift_id); + + if (!$gift) { + throw new \RuntimeException('Gift Not Found'); } - $groupUserRepo = new ImGroupUserRepo(); + $vipRepo = new VipRepo(); - $groupUser = $groupUserRepo->findGroupUser($group->id, $redeem->user_id); + $vip = $vipRepo->findById($gift->attrs['id']); - if (!$groupUser) { - - $groupUser = new ImGroupUserModel(); - - $groupUser->group_id = $group->id; - $groupUser->user_id = $redeem->user_id; - - if ($groupUser->create() === false) { - throw new \RuntimeException('Create Group User Failed'); - } + if (!$vip) { + throw new \RuntimeException('Vip Not Found'); } $redeem->status = PointGiftRedeemModel::STATUS_FINISHED; if ($redeem->update() === false) { - throw new \RuntimeException('Update Redeem Status Failed'); + throw new \RuntimeException('Update Point Redeem Status Failed'); } + + $userRepo = new UserRepo(); + + $user = $userRepo->findById($redeem->user_id); + + $deliverService = new VipDeliverService(); + + $deliverService->handle($vip, $user); } protected function handleGoodsRedeem(PointGiftRedeemModel $redeem) diff --git a/app/Http/Admin/Controllers/PointGiftController.php b/app/Http/Admin/Controllers/PointGiftController.php index 433308a5..057834db 100644 --- a/app/Http/Admin/Controllers/PointGiftController.php +++ b/app/Http/Admin/Controllers/PointGiftController.php @@ -47,9 +47,11 @@ class PointGiftController extends Controller $service = new PointGiftService(); $xmCourses = $service->getXmCourses(); + $xmVips = $service->getXmVips(); $types = $service->getTypes(); $this->view->setVar('xm_courses', $xmCourses); + $this->view->setVar('xm_vips', $xmVips); $this->view->setVar('types', $types); } diff --git a/app/Http/Admin/Services/PointGift.php b/app/Http/Admin/Services/PointGift.php index 4ce0d39e..56487edf 100644 --- a/app/Http/Admin/Services/PointGift.php +++ b/app/Http/Admin/Services/PointGift.php @@ -11,6 +11,7 @@ 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\Repos\Vip as VipRepo; use App\Validators\PointGift as PointGiftValidator; class PointGift extends Service @@ -47,6 +48,29 @@ class PointGift extends Service return $result; } + public function getXmVips() + { + $vipRepo = new VipRepo(); + + $items = $vipRepo->findAll([ + 'published' => 1, + 'deleted' => 0, + ]); + + 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 getPointGifts() { $pagerQuery = new PagerQuery(); @@ -83,6 +107,9 @@ class PointGift extends Service case PointGiftModel::TYPE_COURSE: $gift = $this->createCoursePointGift($post); break; + case PointGiftModel::TYPE_VIP: + $gift = $this->createVipPointGift($post); + break; case PointGiftModel::TYPE_GOODS: $gift = $this->createGoodsPointGift($post); break; @@ -168,7 +195,7 @@ class PointGift extends Service $giftRepo = new PointGiftRepo(); - $gift = $giftRepo->findByCourseId($course->id); + $gift = $giftRepo->findItemGift($course->id, PointGiftModel::TYPE_COURSE); if ($gift) return $gift; @@ -188,6 +215,35 @@ class PointGift extends Service return $gift; } + + protected function createVipPointGift($post) + { + $validator = new PointGiftValidator(); + + $vip = $validator->checkVip($post['xm_vip_id']); + + $giftRepo = new PointGiftRepo(); + + $gift = $giftRepo->findItemGift($vip->id, PointGiftModel::TYPE_VIP); + + if ($gift) return $gift; + + $gift = new PointGiftModel(); + + $gift->type = PointGiftModel::TYPE_VIP; + $gift->name = sprintf('会员服务(%s个月)', $vip->expiry); + $gift->cover = $vip->cover; + $gift->attrs = [ + 'id' => $vip->id, + 'title' => $vip->title, + 'price' => $vip->price, + ]; + + $gift->create(); + + return $gift; + } + protected function createGoodsPointGift($post) { $validator = new PointGiftValidator(); diff --git a/app/Http/Admin/Views/macros/point_gift.volt b/app/Http/Admin/Views/macros/point_gift.volt index 3b9216ec..9f6e695a 100644 --- a/app/Http/Admin/Views/macros/point_gift.volt +++ b/app/Http/Admin/Views/macros/point_gift.volt @@ -4,7 +4,7 @@ {% elseif value == 2 %} 商品 {% elseif value == 3 %} - 现金 + 会员 {% endif %} {%- endmacro %} diff --git a/app/Http/Admin/Views/point_gift/add.volt b/app/Http/Admin/Views/point_gift/add.volt index bcd4d198..298f822d 100644 --- a/app/Http/Admin/Views/point_gift/add.volt +++ b/app/Http/Admin/Views/point_gift/add.volt @@ -22,6 +22,14 @@ + +
+
+ +
+ +
+
+
+ +
+ +
+
+
@@ -107,6 +121,20 @@
+
+
+ +
+ +
+
+
+ +
+ +
+
+
diff --git a/app/Http/Home/Views/macros/point_gift.volt b/app/Http/Home/Views/macros/point_gift.volt index 3b9216ec..9f6e695a 100644 --- a/app/Http/Home/Views/macros/point_gift.volt +++ b/app/Http/Home/Views/macros/point_gift.volt @@ -4,7 +4,7 @@ {% elseif value == 2 %} 商品 {% elseif value == 3 %} - 现金 + 会员 {% endif %} {%- endmacro %} diff --git a/app/Http/Home/Views/partials/footer.volt b/app/Http/Home/Views/partials/footer.volt index 2435a520..ada92a77 100644 --- a/app/Http/Home/Views/partials/footer.volt +++ b/app/Http/Home/Views/partials/footer.volt @@ -12,9 +12,15 @@ {% if site_info.icp_sn %} {{ site_info.icp_sn }} {% endif %} + {% if site_info.isp_sn %} + {{ site_info.isp_sn }} + {% endif %} {% if site_info.police_sn %} {{ site_info.police_sn }} {% endif %} + {% if site_info.company_sn %} + 工商网监电子标识 + {% endif %}
{% if contact_info.enabled == 1 %}
diff --git a/app/Models/PointGift.php b/app/Models/PointGift.php index 7efcce29..ae424730 100644 --- a/app/Models/PointGift.php +++ b/app/Models/PointGift.php @@ -19,6 +19,7 @@ class PointGift extends Model */ const TYPE_COURSE = 1; // 课程 const TYPE_GOODS = 2; // 商品 + const TYPE_VIP = 3; // 会员 /** * 课程扩展属性 @@ -31,6 +32,17 @@ class PointGift extends Model 'price' => 0, ]; + /** + * 会员扩展属性 + * + * @var array + */ + protected $_vip_attrs = [ + 'id' => 0, + 'title' => '', + 'price' => 0, + ]; + /** * 商品扩展属性 * @@ -162,6 +174,8 @@ class PointGift extends Model if (empty($this->attrs)) { if ($this->type == self::TYPE_COURSE) { $this->attrs = $this->_course_attrs; + } elseif ($this->type == self::TYPE_VIP) { + $this->attrs = $this->_vip_attrs; } elseif ($this->type == self::TYPE_GOODS) { $this->attrs = $this->_goods_attrs; } @@ -224,6 +238,7 @@ class PointGift extends Model return [ self::TYPE_COURSE => '课程', self::TYPE_GOODS => '商品', + self::TYPE_VIP => '会员', ]; } diff --git a/app/Repos/CourseUser.php b/app/Repos/CourseUser.php index 36b1c38f..3afa19bf 100644 --- a/app/Repos/CourseUser.php +++ b/app/Repos/CourseUser.php @@ -163,4 +163,17 @@ class CourseUser extends Repository ->execute(); } + /** + * @param int $courseId + * @param int $userId + * @return ResultsetInterface|Resultset|CourseUserModel[] + */ + public function findByCourseAndUserId($courseId, $userId) + { + return CourseUserModel::query() + ->where('course_id = :course_id:', ['course_id' => $courseId]) + ->andWhere('user_id = :user_id:', ['user_id' => $userId]) + ->execute(); + } + } diff --git a/app/Repos/PointGift.php b/app/Repos/PointGift.php index ba078a52..91669d01 100644 --- a/app/Repos/PointGift.php +++ b/app/Repos/PointGift.php @@ -77,10 +77,11 @@ class PointGift extends Repository } /** - * @param int $courseId + * @param int $itemId + * @param int $itemType * @return PointGiftModel|Model|bool */ - public function findByCourseId($courseId) + public function findItemGift($itemId, $itemType) { /** * @todo 重新设计表结构 @@ -88,13 +89,13 @@ class PointGift extends Repository * 没有预留独立的条目编号,先这么将就实现吧 */ $records = PointGiftModel::query() - ->where('type = :type:', ['type' => PointGiftModel::TYPE_COURSE]) + ->where('type = :type:', ['type' => $itemType]) ->execute(); if ($records->count() == 0) return false; foreach ($records as $record) { - if ($record->attrs['id'] == $courseId) { + if ($record->attrs['id'] == $itemId) { return $record; } } diff --git a/app/Services/Logic/Deliver/CourseDeliver.php b/app/Services/Logic/Deliver/CourseDeliver.php index 4645a5c7..4259aba4 100644 --- a/app/Services/Logic/Deliver/CourseDeliver.php +++ b/app/Services/Logic/Deliver/CourseDeliver.php @@ -11,6 +11,7 @@ use App\Models\Course as CourseModel; use App\Models\CourseUser as CourseUserModel; use App\Models\ImGroupUser as ImGroupUserModel; use App\Models\User as UserModel; +use App\Repos\CourseUser as CourseUserRepo; use App\Repos\ImGroup as ImGroupRepo; use App\Repos\ImGroupUser as ImGroupUserRepo; use App\Repos\ImUser as ImUserRepo; @@ -20,6 +21,13 @@ class CourseDeliver extends LogicService { public function handle(CourseModel $course, UserModel $user) + { + $this->revokeCourseUser($course, $user); + $this->handleCourseUser($course, $user); + $this->handleImGroupUser($course, $user); + } + + protected function handleCourseUser(CourseModel $course, UserModel $user) { if ($course->model == CourseModel::MODEL_OFFLINE) { $expiryTime = strtotime($course->attrs['end_date']); @@ -28,7 +36,6 @@ class CourseDeliver extends LogicService } $courseUser = new CourseUserModel(); - $courseUser->user_id = $user->id; $courseUser->course_id = $course->id; $courseUser->expiry_time = $expiryTime; @@ -39,6 +46,12 @@ class CourseDeliver extends LogicService $course->user_count += 1; $course->update(); + $user->course_count += 1; + $user->update(); + } + + protected function handleImGroupUser(CourseModel $course, UserModel $user) + { $groupRepo = new ImGroupRepo(); $group = $groupRepo->findByCourseId($course->id); @@ -52,9 +65,7 @@ class CourseDeliver extends LogicService $groupUser = $groupUserRepo->findGroupUser($group->id, $user->id); if (!$groupUser) { - $groupUser = new ImGroupUserModel(); - $groupUser->group_id = $group->id; $groupUser->user_id = $user->id; $groupUser->create(); @@ -67,4 +78,20 @@ class CourseDeliver extends LogicService } } + protected function revokeCourseUser(CourseModel $course, UserModel $user) + { + $courseUserRepo = new CourseUserRepo(); + + $relations = $courseUserRepo->findByCourseAndUserId($course->id, $user->id); + + if ($relations->count() == 0) return; + + foreach ($relations as $relation) { + if ($relation->deleted == 0) { + $relation->deleted = 1; + $relation->update(); + } + } + } + } diff --git a/app/Services/Logic/Deliver/PackageDeliver.php b/app/Services/Logic/Deliver/PackageDeliver.php index 36586f7a..709fdc83 100644 --- a/app/Services/Logic/Deliver/PackageDeliver.php +++ b/app/Services/Logic/Deliver/PackageDeliver.php @@ -7,13 +7,8 @@ namespace App\Services\Logic\Deliver; -use App\Models\CourseUser as CourseUserModel; -use App\Models\ImGroupUser as ImGroupUserModel; use App\Models\Package as PackageModel; use App\Models\User as UserModel; -use App\Repos\ImGroup as ImGroupRepo; -use App\Repos\ImGroupUser as ImGroupUserRepo; -use App\Repos\ImUser as ImUserRepo; use App\Repos\Package as PackageRepo; use App\Services\Logic\Service as LogicService; @@ -27,43 +22,8 @@ class PackageDeliver extends LogicService $courses = $packageRepo->findCourses($package->id); foreach ($courses as $course) { - - $courseUser = new CourseUserModel(); - - $courseUser->user_id = $user->id; - $courseUser->course_id = $course->id; - $courseUser->expiry_time = strtotime("+{$course->study_expiry} months"); - $courseUser->role_type = CourseUserModel::ROLE_STUDENT; - $courseUser->source_type = CourseUserModel::SOURCE_CHARGE; - $courseUser->create(); - - $course->user_count += 1; - $course->update(); - - $imUserRepo = new ImUserRepo(); - - $imUser = $imUserRepo->findById($user->id); - - $groupRepo = new ImGroupRepo(); - - $group = $groupRepo->findByCourseId($course->id); - - $groupUserRepo = new ImGroupUserRepo(); - - $groupUser = $groupUserRepo->findGroupUser($group->id, $user->id); - - if (!$groupUser) { - $groupUser = new ImGroupUserModel(); - $groupUser->group_id = $group->id; - $groupUser->user_id = $user->id; - $groupUser->create(); - - $imUser->group_count += 1; - $imUser->update(); - - $group->user_count += 1; - $group->update(); - } + $deliver = new CourseDeliver(); + $deliver->handle($course, $user); } } diff --git a/app/Validators/PointGift.php b/app/Validators/PointGift.php index 2a296437..5c1460ca 100644 --- a/app/Validators/PointGift.php +++ b/app/Validators/PointGift.php @@ -177,4 +177,11 @@ class PointGift extends Validator return $validator->checkCourse($id); } + public function checkVip($id) + { + $validator = new Vip(); + + return $validator->checkVip($id); + } + } diff --git a/db/migrations/20220607014823.php b/db/migrations/20220607014823.php new file mode 100644 index 00000000..a1f74762 --- /dev/null +++ b/db/migrations/20220607014823.php @@ -0,0 +1,42 @@ +handleSiteSettings(); + } + + protected function handleSiteSettings() + { + $row = + [ + [ + 'section' => 'site', + 'item_key' => 'isp_sn', + 'item_value' => '', + ], + [ + 'section' => 'site', + 'item_key' => 'isp_link', + 'item_value' => 'https://dxzhgl.miit.gov.cn', + ], + [ + 'section' => 'site', + 'item_key' => 'company_sn', + 'item_value' => '', + ], + [ + 'section' => 'site', + 'item_key' => 'company_sn_link', + 'item_value' => '', + ], + ]; + + $this->table('kg_setting')->insert($row)->save(); + } + +} \ No newline at end of file From b5ceb155f30c9f157a82978b2f2cd80b8922b256 Mon Sep 17 00:00:00 2001 From: koogua Date: Wed, 8 Jun 2022 09:22:28 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=BF=81=E7=A7=BBSetting?= =?UTF-8?q?Trait?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Admin/Services/Course.php | 1 + app/Http/Admin/Services/FlashSale.php | 6 ++++- app/Http/Admin/Services/PointGift.php | 1 - db/migrations/20220607014823.php | 13 ++++++++-- db/migrations/SettingTrait.php | 34 +++++++++++++++++++++++++++ 5 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 db/migrations/SettingTrait.php diff --git a/app/Http/Admin/Services/Course.php b/app/Http/Admin/Services/Course.php index 0c5d3298..e76d595e 100644 --- a/app/Http/Admin/Services/Course.php +++ b/app/Http/Admin/Services/Course.php @@ -274,6 +274,7 @@ class Course extends Service $allCategories = $categoryRepo->findAll([ 'type' => CategoryModel::TYPE_COURSE, 'published' => 1, + 'deleted' => 0, ]); if ($allCategories->count() == 0) return []; diff --git a/app/Http/Admin/Services/FlashSale.php b/app/Http/Admin/Services/FlashSale.php index 3a90363b..8866de9a 100644 --- a/app/Http/Admin/Services/FlashSale.php +++ b/app/Http/Admin/Services/FlashSale.php @@ -50,7 +50,11 @@ class FlashSale extends Service { $courseRepo = new CourseRepo(); - $items = $courseRepo->findAll(['free' => 0, 'published' => 1]); + $items = $courseRepo->findAll([ + 'free' => 0, + 'published' => 1, + 'deleted' => 0, + ]); if ($items->count() == 0) return []; diff --git a/app/Http/Admin/Services/PointGift.php b/app/Http/Admin/Services/PointGift.php index 56487edf..5b929c02 100644 --- a/app/Http/Admin/Services/PointGift.php +++ b/app/Http/Admin/Services/PointGift.php @@ -215,7 +215,6 @@ class PointGift extends Service return $gift; } - protected function createVipPointGift($post) { $validator = new PointGiftValidator(); diff --git a/db/migrations/20220607014823.php b/db/migrations/20220607014823.php index a1f74762..02a12daf 100644 --- a/db/migrations/20220607014823.php +++ b/db/migrations/20220607014823.php @@ -1,10 +1,19 @@ handleSiteSettings(); @@ -12,7 +21,7 @@ final class V20220607014823 extends AbstractMigration protected function handleSiteSettings() { - $row = + $rows = [ [ 'section' => 'site', @@ -36,7 +45,7 @@ final class V20220607014823 extends AbstractMigration ], ]; - $this->table('kg_setting')->insert($row)->save(); + $this->insertSettings($rows); } } \ No newline at end of file diff --git a/db/migrations/SettingTrait.php b/db/migrations/SettingTrait.php new file mode 100644 index 00000000..cff86d00 --- /dev/null +++ b/db/migrations/SettingTrait.php @@ -0,0 +1,34 @@ + $row) { + $exists = $this->settingExits($row['section'], $row['item_key']); + if ($exists) unset($rows[$key]); + } + + if (count($rows) == 0) return; + + $this->table('kg_setting')->insert($rows)->save(); + } + + protected function settingExits($section, $itemKey) + { + $row = $this->getQueryBuilder() + ->select('*') + ->from('kg_setting') + ->where(['section' => $section, 'item_key' => $itemKey]) + ->execute()->fetch(); + + return $row ? true : false; + } + +} \ No newline at end of file From 7f9314a1112efb8b15c7dd38f2cd3f4ad8f13413 Mon Sep 17 00:00:00 2001 From: koogua Date: Wed, 8 Jun 2022 21:47:47 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E8=BD=AC=E7=A0=81=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Tasks/VodEventTask.php | 3 ++- app/Http/Admin/Services/ChapterContent.php | 17 +++++++++++------ .../Admin/Views/chapter/edit_lesson_vod.volt | 2 +- public/static/admin/js/media.upload.js | 1 + 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/Console/Tasks/VodEventTask.php b/app/Console/Tasks/VodEventTask.php index be34f31d..6439bb3c 100644 --- a/app/Console/Tasks/VodEventTask.php +++ b/app/Console/Tasks/VodEventTask.php @@ -57,7 +57,7 @@ class VodEventTask extends Task $attrs = $chapter->attrs; /** - * 获取不到时长,尝试通过接口获得 + * 获取不到时长,尝试通过主动查询获取 */ if ($duration == 0) { $duration = $this->getFileDuration($fileId); @@ -68,6 +68,7 @@ class VodEventTask extends Task */ if ($duration == 0) { $attrs['file']['status'] = ChapterModel::FS_FAILED; + $attrs['duration'] = 0; $chapter->update(['attrs' => $attrs]); return; } diff --git a/app/Http/Admin/Services/ChapterContent.php b/app/Http/Admin/Services/ChapterContent.php index 5d257fc5..dec9abcd 100644 --- a/app/Http/Admin/Services/ChapterContent.php +++ b/app/Http/Admin/Services/ChapterContent.php @@ -133,14 +133,19 @@ class ChapterContent extends Service $vod = $chapterRepo->findChapterVod($chapter->id); - $vod->file_id = $fileId; - $vod->file_transcode = []; - $vod->update(); - $attrs = $chapter->attrs; - $attrs['duration'] = 0; - $attrs['file']['status'] = ChapterModel::FS_UPLOADED; + + if ($fileId != $vod->file_id) { + $vod->file_id = $fileId; + $vod->file_transcode = []; + $vod->update(); + + $attrs['file']['status'] = ChapterModel::FS_UPLOADED; + $attrs['duration'] = 0; + } + $chapter->attrs = $attrs; + $chapter->update(); $this->updateCourseVodAttrs($vod->course_id); diff --git a/app/Http/Admin/Views/chapter/edit_lesson_vod.volt b/app/Http/Admin/Views/chapter/edit_lesson_vod.volt index eff5554f..dcdc68de 100644 --- a/app/Http/Admin/Views/chapter/edit_lesson_vod.volt +++ b/app/Http/Admin/Views/chapter/edit_lesson_vod.volt @@ -70,7 +70,7 @@
- +
diff --git a/public/static/admin/js/media.upload.js b/public/static/admin/js/media.upload.js index fc303673..2bcc0656 100644 --- a/public/static/admin/js/media.upload.js +++ b/public/static/admin/js/media.upload.js @@ -46,6 +46,7 @@ layui.use(['jquery', 'element'], function () { uploader.done().then(function (result) { $('input[name=file_id]').val(result.fileId); + $('#vod-submit').removeAttr('disabled').removeClass('layui-btn-disabled'); $.ajax({ type: 'POST', url: $('#vod-form').attr('action'),