1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-17 15:55:31 +08:00

阶段性提交积分机制-0213

This commit is contained in:
winzer 2021-02-13 18:21:42 +08:00
parent f47091991d
commit 8eef6035a8
141 changed files with 2469 additions and 17464 deletions

1
.gitignore vendored
View File

@ -6,6 +6,7 @@
/config/xs.user.ini
/config/alipay/*.crt
/config/wxpay/*.pem
/db/migrations/schema.php
/public/robots.txt
/public/sitemap.xml
/public/h5

View File

@ -48,7 +48,7 @@ class CloseTradeTask extends Task
*/
if ($alipayTrade->trade_status == 'TRADE_SUCCESS') {
$this->eventsManager->fire('pay:afterPay', $this, $trade);
$this->eventsManager->fire('Trade:afterPay', $this, $trade);
$allowClosed = false;
@ -85,7 +85,7 @@ class CloseTradeTask extends Task
*/
if ($wxpayTrade->trade_state == 'SUCCESS') {
$this->eventsManager->fire('pay:afterPay', $this, $trade);
$this->eventsManager->fire('Trade:afterPay', $this, $trade);
$allowClosed = false;

View File

@ -13,6 +13,7 @@ use App\Repos\ImGroupUser as ImGroupUserRepo;
use App\Repos\Order as OrderRepo;
use App\Repos\User as UserRepo;
use App\Services\Logic\Notice\OrderFinish as OrderFinishNotice;
use App\Services\Logic\Point\PointHistory as PointHistoryService;
use Phalcon\Mvc\Model;
use Phalcon\Mvc\Model\Resultset;
use Phalcon\Mvc\Model\ResultsetInterface;
@ -36,17 +37,20 @@ class DeliverTask extends Task
foreach ($tasks as $task) {
/**
* @var array $itemInfo
*/
$itemInfo = $task->item_info;
$orderId = $task->item_info['order']['id'] ?? 0;
$order = $orderRepo->findById($itemInfo['order']['id']);
$order = $orderRepo->findById($orderId);
if (!$order) continue;
if (!$order) {
$task->status = TaskModel::STATUS_FAILED;
$task->update();
continue;
}
try {
$this->db->begin();
switch ($order->item_type) {
case OrderModel::ITEM_COURSE:
$this->handleCourseOrder($order);
@ -59,14 +63,24 @@ class DeliverTask extends Task
break;
}
$this->finishOrder($order);
$order->status = OrderModel::STATUS_FINISHED;
if ($order->update() === false) {
throw new \RuntimeException('Update Order Status Failed');
}
$task->status = TaskModel::STATUS_FINISHED;
$task->update();
if ($task->update() === false) {
throw new \RuntimeException('Update Task Status Failed');
}
$this->db->commit();
} catch (\Exception $e) {
$this->db->rollback();
$task->try_count += 1;
$task->priority += 1;
@ -76,14 +90,16 @@ class DeliverTask extends Task
$task->update();
$logger->info('Order Process Exception ' . kg_json_encode([
'code' => $e->getCode(),
$logger->error('Order Process Exception ' . kg_json_encode([
'file' => $e->getFile(),
'line' => $e->getLine(),
'message' => $e->getMessage(),
'task' => $task->toArray(),
]));
}
if ($task->status == TaskModel::STATUS_FINISHED) {
$this->handleOrderConsumePoint($order);
$this->handleOrderFinishNotice($order);
} elseif ($task->status == TaskModel::STATUS_FAILED) {
$this->handleOrderRefund($order);
@ -91,20 +107,8 @@ class DeliverTask extends Task
}
}
protected function finishOrder(OrderModel $order)
{
$order->status = OrderModel::STATUS_FINISHED;
if ($order->update() === false) {
throw new \RuntimeException('Finish Order Failed');
}
}
protected function handleCourseOrder(OrderModel $order)
{
/**
* @var array $itemInfo
*/
$itemInfo = $order->item_info;
$courseUser = new CourseUserModel();
@ -127,23 +131,21 @@ class DeliverTask extends Task
$groupUser = $groupUserRepo->findGroupUser($group->id, $order->owner_id);
if ($groupUser) return;
if (!$groupUser) {
$groupUser = new ImGroupUserModel();
$groupUser = new ImGroupUserModel();
$groupUser->group_id = $group->id;
$groupUser->user_id = $order->owner_id;
$groupUser->group_id = $group->id;
$groupUser->user_id = $order->owner_id;
if ($groupUser->create() === false) {
throw new \RuntimeException('Create Group User Failed');
if ($groupUser->create() === false) {
throw new \RuntimeException('Create Group User Failed');
}
}
}
protected function handlePackageOrder(OrderModel $order)
{
/**
* @var array $itemInfo
*/
$itemInfo = $order->item_info;
foreach ($itemInfo['courses'] as $course) {
@ -168,24 +170,24 @@ class DeliverTask extends Task
$groupUser = $groupUserRepo->findGroupUser($group->id, $order->owner_id);
if ($groupUser) continue;
if (!$groupUser) {
$groupUser = new ImGroupUserModel();
$groupUser = new ImGroupUserModel();
$groupUser->group_id = $group->id;
$groupUser->user_id = $order->owner_id;
$groupUser->group_id = $group->id;
$groupUser->user_id = $order->owner_id;
if ($groupUser->create() === false) {
throw new \RuntimeException('Create Group User Failed');
if ($groupUser->create() === false) {
throw new \RuntimeException('Create Group User Failed');
}
continue;
}
}
}
protected function handleVipOrder(OrderModel $order)
{
/**
* @var array $itemInfo
*/
$itemInfo = $order->item_info;
$userRepo = new UserRepo();
@ -199,6 +201,13 @@ class DeliverTask extends Task
}
}
protected function handleOrderConsumePoint(OrderModel $order)
{
$service = new PointHistoryService();
$service->handleOrderConsume($order);
}
protected function handleOrderFinishNotice(OrderModel $order)
{
$notice = new OrderFinishNotice();

View File

@ -66,7 +66,6 @@ class NoticeTask extends Task
$logger->info('Notice Process Exception ' . kg_json_encode([
'file' => $e->getFile(),
'line' => $e->getLine(),
'code' => $e->getCode(),
'message' => $e->getMessage(),
'task' => $task->toArray(),
]));

View File

@ -1,213 +0,0 @@
<?php
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\PointHistory as PointHistoryModel;
use App\Models\PointRedeem as PointRedeemModel;
use App\Models\Task as TaskModel;
use App\Repos\Course as CourseRepo;
use App\Repos\ImGroupUser as ImGroupUserRepo;
use App\Repos\PointGift as PointGiftRepo;
use App\Repos\PointRedeem as PointRedeemRepo;
use App\Repos\User as UserRepo;
use Phalcon\Mvc\Model\Resultset;
use Phalcon\Mvc\Model\ResultsetInterface;
class PointGiftAwardTask extends Task
{
const TRY_COUNT = 3;
public function mainAction()
{
$logger = $this->getLogger('point');
$tasks = $this->findTasks();
if ($tasks->count() == 0) {
return;
}
$redeemRepo = new PointRedeemRepo();
foreach ($tasks as $task) {
$redeem = $redeemRepo->findById($task->item_id);
if (!$redeem) continue;
try {
switch ($redeem->gift_type) {
case PointGiftModel::TYPE_COURSE:
$this->handleCourseAward($redeem);
break;
case PointGiftModel::TYPE_GOODS:
$this->handleCommodityAward($redeem);
break;
}
$this->finishRedeem($redeem);
$task->status = TaskModel::STATUS_FINISHED;
$task->update();
} catch (\Exception $e) {
$task->try_count += 1;
$task->priority += 1;
if ($task->try_count > self::TRY_COUNT) {
$task->status = TaskModel::STATUS_FAILED;
}
$task->update();
$logger->info('Point Gift Award Exception ' . kg_json_encode([
'code' => $e->getCode(),
'message' => $e->getMessage(),
]));
}
if ($task->status == TaskModel::STATUS_FINISHED) {
$this->handleFinishNotice();
} elseif ($task->status == TaskModel::STATUS_FAILED) {
$this->handlePointRefund($redeem);
}
}
}
protected function finishRedeem(PointRedeemModel $redeem)
{
$redeem->status = PointRedeemModel::STATUS_FINISHED;
if ($redeem->update() === false) {
throw new \RuntimeException('Finish Point Redeem Failed');
}
}
protected function handleCourseAward(PointRedeemModel $redeem)
{
$giftRepo = new PointGiftRepo();
$gift = $giftRepo->findById($redeem->gift_id);
$courseUser = new CourseUserModel();
$courseUser->user_id = $redeem->user_id;
$courseUser->course_id = $gift->attrs['id'];
$courseUser->expiry_time = $gift->attrs['study_expiry_time'];
$courseUser->role_type = CourseUserModel::ROLE_STUDENT;
$courseUser->source_type = CourseUserModel::SOURCE_POINT_REDEEM;
if ($courseUser->create() === false) {
throw new \RuntimeException('Create Course User Failed');
}
$courseRepo = new CourseRepo();
$group = $courseRepo->findImGroup($gift->attrs['id']);
$groupUserRepo = new ImGroupUserRepo();
$groupUser = $groupUserRepo->findGroupUser($group->id, $redeem->user_id);
if ($groupUser) return;
$groupUser = new ImGroupUserModel();
$groupUser->group_id = $group->id;
$groupUser->user_id = $redeem->user_id;
if ($groupUser->create() === false) {
throw new \RuntimeException('Create Im Group User Failed');
}
}
protected function handleCommodityAward(PointRedeemModel $redeem)
{
}
protected function handleFinishNotice()
{
}
protected function handlePointRefund(PointRedeemModel $redeem)
{
$logger = $this->getLogger('point');
$userRepo = new UserRepo();
$balance = $userRepo->findUserBalance($redeem->user_id);
try {
$this->db->begin();
$history = new PointHistoryModel();
$eventInfo = [
'gift' => [
'id' => $redeem->gift_id,
'name' => $redeem->gift_name,
]
];
$history->user_id = $redeem->user_id;
$history->event_id = $redeem->id;
$history->event_type = PointHistoryModel::EVENT_POINT_REFUND;
$history->event_info = $eventInfo;
$result = $history->create();
if ($result === false) {
throw new \RuntimeException('Create Point History Failed');
}
$balance->point += $redeem->gift_point;
$result = $balance->update();
if ($result === false) {
throw new \RuntimeException('Update User Balance Failed');
}
$this->db->commit();
} catch (\Exception $e) {
$this->db->rollback();
$logger->error('Point Refund Exception ' . kg_json_encode([
'code' => $e->getCode(),
'message' => $e->getMessage(),
]));
}
}
/**
* @param int $limit
* @return ResultsetInterface|Resultset|TaskModel[]
*/
protected function findTasks($limit = 30)
{
$itemType = TaskModel::TYPE_POINT_GIFT_AWARD;
$status = TaskModel::STATUS_PENDING;
$createTime = strtotime('-3 days');
return TaskModel::query()
->where('item_type = :item_type:', ['item_type' => $itemType])
->andWhere('status = :status:', ['status' => $status])
->andWhere('create_time > :create_time:', ['create_time' => $createTime])
->orderBy('priority ASC')
->limit($limit)
->execute();
}
}

View File

@ -0,0 +1,209 @@
<?php
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\PointRedeem as PointRedeemModel;
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\PointRedeem as PointRedeemRepo;
use App\Services\Logic\Point\PointHistory as PointHistoryService;
use Phalcon\Mvc\Model\Resultset;
use Phalcon\Mvc\Model\ResultsetInterface;
class PointGiftDeliverTask extends Task
{
const TRY_COUNT = 3;
public function mainAction()
{
$logger = $this->getLogger('point');
$tasks = $this->findTasks(30);
if ($tasks->count() == 0) {
return;
}
$redeemRepo = new PointRedeemRepo();
foreach ($tasks as $task) {
$redeemId = $task->item_info['point_redeem']['id'] ?? 0;
$redeem = $redeemRepo->findById($redeemId);
if (!$redeem) {
$task->status = TaskModel::STATUS_FAILED;
$task->update();
break;
}
try {
$this->db->begin();
switch ($redeem->gift_type) {
case PointGiftModel::TYPE_COURSE:
$this->handleCourseRedeem($redeem);
break;
case PointGiftModel::TYPE_GOODS:
$this->handleGoodsRedeem($redeem);
break;
case PointGiftModel::TYPE_CASH:
$this->handleCashRedeem($redeem);
break;
}
$task->status = TaskModel::STATUS_FINISHED;
if ($task->update() === false) {
throw new \RuntimeException('Update Task Status Failed');
}
$this->db->commit();
} catch (\Exception $e) {
$this->db->rollback();
$task->try_count += 1;
$task->priority += 1;
if ($task->try_count > self::TRY_COUNT) {
$task->status = TaskModel::STATUS_FAILED;
}
$task->update();
$logger->error('Point Gift Deliver Exception ' . kg_json_encode([
'file' => $e->getFile(),
'line' => $e->getLine(),
'message' => $e->getMessage(),
'task' => $task->toArray(),
]));
}
if ($task->status == TaskModel::STATUS_FAILED) {
$this->handlePointRefund($redeem);
}
}
}
protected function handleCourseRedeem(PointRedeemModel $redeem)
{
$giftRepo = new PointGiftRepo();
$gift = $giftRepo->findById($redeem->gift_id);
if (!$gift) {
throw new \RuntimeException('Gift Not Found');
}
$courseRepo = new CourseRepo();
$course = $courseRepo->findById($gift->attrs['id']);
if (!$course) {
throw new \RuntimeException('Course Not Found');
}
$groupRepo = new ImGroupRepo();
$group = $groupRepo->findByCourseId($course->id);
if (!$group) {
throw new \RuntimeException('Im Group Not Found');
}
$courseUserRepo = new CourseUserRepo();
$courseUser = $courseUserRepo->findCourseUser($course->id, $redeem->user_id);
if (!$courseUser) {
$courseUser = new CourseUserModel();
$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;
if ($courseUser->create() === false) {
throw new \RuntimeException('Create Course User Failed');
}
}
$groupUserRepo = new ImGroupUserRepo();
$groupUser = $groupUserRepo->findGroupUser($group->id, $redeem->user_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');
}
}
$redeem->status = PointRedeemModel::STATUS_FINISHED;
if ($redeem->update() === false) {
throw new \RuntimeException('Update Redeem Status Failed');
}
}
protected function handleGoodsRedeem(PointRedeemModel $redeem)
{
}
protected function handleCashRedeem(PointRedeemModel $redeem)
{
}
protected function handlePointRefund(PointRedeemModel $redeem)
{
$service = new PointHistoryService();
$service->handlePointRefund($redeem);
}
protected function handleRedeemFinishNotice(PointRedeemModel $redeem)
{
}
/**
* @param int $limit
* @return ResultsetInterface|Resultset|TaskModel[]
*/
protected function findTasks($limit = 30)
{
$itemType = TaskModel::TYPE_POINT_GIFT_DELIVER;
$status = TaskModel::STATUS_PENDING;
$createTime = strtotime('-3 days');
return TaskModel::query()
->where('item_type = :item_type:', ['item_type' => $itemType])
->andWhere('status = :status:', ['status' => $status])
->andWhere('create_time > :create_time:', ['create_time' => $createTime])
->orderBy('priority ASC')
->limit($limit)
->execute();
}
}

View File

@ -41,9 +41,6 @@ class RefundTask extends Task
foreach ($tasks as $task) {
/**
* @var array $itemInfo
*/
$itemInfo = $task->item_info;
$refund = $refundRepo->findById($itemInfo['refund']['id']);
@ -51,6 +48,8 @@ class RefundTask extends Task
$order = $orderRepo->findById($itemInfo['refund']['order_id']);
if (!$refund || !$trade || !$order) {
$task->status = TaskModel::STATUS_FAILED;
$task->update();
continue;
}
@ -111,7 +110,8 @@ class RefundTask extends Task
$task->update();
$logger->info('Refund Task Exception ' . kg_json_encode([
'code' => $e->getCode(),
'file' => $e->getFile(),
'line' => $e->getLine(),
'message' => $e->getMessage(),
'task' => $task->toArray(),
]));
@ -148,7 +148,7 @@ class RefundTask extends Task
}
if (!$response) {
throw new \RuntimeException('Pay Refund Failed');
throw new \RuntimeException('Trade Refund Failed');
}
}
@ -208,9 +208,6 @@ class RefundTask extends Task
{
$courseUserRepo = new CourseUserRepo();
/**
* @var array $itemInfo
*/
$itemInfo = $order->item_info;
foreach ($itemInfo['courses'] as $course) {
@ -239,9 +236,6 @@ class RefundTask extends Task
$user = $userRepo->findById($order->owner_id);
/**
* @var array $itemInfo
*/
$itemInfo = $order->item_info;
$diffTime = "-{$itemInfo['vip']['expiry']} months";

View File

@ -125,7 +125,7 @@ class SyncLearningTask extends Task
$this->updateCourseUser($learning);
$this->handleLearningPoint($chapterUser);
$this->handleStudyPoint($chapterUser);
}
}
@ -182,11 +182,11 @@ class SyncLearningTask extends Task
/**
* @param ChapterUserModel $chapterUser
*/
protected function handleLearningPoint(ChapterUserModel $chapterUser)
protected function handleStudyPoint(ChapterUserModel $chapterUser)
{
$service = new PointHistoryService();
$service->handleChapterLearning($chapterUser);
$service->handleChapterStudy($chapterUser);
}
}

View File

@ -2,7 +2,7 @@
namespace App\Http\Admin\Controllers;
use App\Http\Admin\Services\PointGift as PointGiftService;
use App\Http\Admin\Services\PointRedeem as PointRedeemService;
/**
* @RoutePrefix("/admin/point/redeem")
@ -10,14 +10,22 @@ use App\Http\Admin\Services\PointGift as PointGiftService;
class PointRedeemController extends Controller
{
/**
* @Get("/search", name="admin.point_redeem.search")
*/
public function searchAction()
{
$this->view->pick('point/redeem/search');
}
/**
* @Get("/list", name="admin.point_redeem.list")
*/
public function listAction()
{
$groupService = new PointGiftService();
$redeemService = new PointRedeemService();
$pager = $groupService->getGroups();
$pager = $redeemService->getRedeems();
$this->view->pick('point/redeem/list');
@ -25,36 +33,15 @@ class PointRedeemController extends Controller
}
/**
* @Get("/{id:[0-9]+}/edit", name="admin.point_redeem.edit")
* @Post("/{id:[0-9]+}/deliver", name="admin.point_redeem.deliver")
*/
public function editAction($id)
public function deliverAction($id)
{
$groupService = new PointGiftService();
$redeemService = new PointRedeemService();
$group = $groupService->getGroup($id);
$redeemService->deliver($id);
$this->view->pick('point/redeem/edit');
$this->view->setVar('group', $group);
}
/**
* @Post("/{id:[0-9]+}/update", name="admin.point_redeem.update")
*/
public function updateAction($id)
{
$groupService = new PointGiftService();
$groupService->updateGroup($id);
$location = $this->url->get(['for' => 'admin.point_redeem.list']);
$content = [
'location' => $location,
'msg' => '更新群组成功',
];
return $this->jsonSuccess($content);
return $this->jsonSuccess(['msg' => '发货成功']);
}
}

View File

@ -84,6 +84,10 @@ class PointGift extends Service
$data['stock'] = $validator->checkStock($post['stock']);
}
if (isset($post['redeem_limit'])) {
$data['redeem_limit'] = $validator->checkRedeemLimit($post['redeem_limit']);
}
if (isset($post['published'])) {
$data['published'] = $validator->checkPublishStatus($post['published']);
}

View File

@ -0,0 +1,58 @@
<?php
namespace App\Http\Admin\Services;
use App\Library\Paginator\Query as PagerQuery;
use App\Models\PointGift as PointGiftModel;
use App\Models\PointRedeem as PointRedeemModel;
use App\Repos\PointRedeem as PointRedeemRepo;
use App\Validators\PointRedeem as PointRedeemValidator;
class PointRedeem extends Service
{
public function getRedeems()
{
$pagerQuery = new PagerQuery();
$params = $pagerQuery->getParams();
$params['deleted'] = $params['deleted'] ?? 0;
$sort = $pagerQuery->getSort();
$page = $pagerQuery->getPage();
$limit = $pagerQuery->getLimit();
$redeemRepo = new PointRedeemRepo();
return $redeemRepo->paginate($params, $sort, $page, $limit);
}
public function getRedeem($id)
{
return $this->findOrFail($id);
}
public function deliver($id)
{
$redeem = $this->findOrFail($id);
if ($redeem->gift_type != PointGiftModel::TYPE_GOODS) {
return $redeem;
}
$redeem->status = PointRedeemModel::STATUS_FINISHED;
$redeem->update();
return $redeem;
}
protected function findOrFail($id)
{
$validator = new PointRedeemValidator();
return $validator->checkRedeem($id);
}
}

View File

@ -2,12 +2,9 @@
namespace App\Http\Admin\Services;
use App\Models\User as UserModel;
use App\Services\Auth\Admin as AdminAuth;
use App\Validators\Account as AccountValidator;
use App\Validators\Captcha as CaptchaValidator;
use Phalcon\Di as Di;
use Phalcon\Events\Manager as EventsManager;
class Session extends Service
{
@ -50,7 +47,7 @@ class Session extends Service
$this->auth->saveAuthInfo($user);
$this->fireAfterLoginEvent($user);
$this->eventsManager->fire('Account:afterLogin', $this, $user);
}
public function logout()
@ -59,27 +56,7 @@ class Session extends Service
$this->auth->clearAuthInfo();
$this->fireAfterLogoutEvent($user);
}
protected function fireAfterLoginEvent(UserModel $user)
{
/**
* @var EventsManager $eventsManager
*/
$eventsManager = Di::getDefault()->getShared('eventsManager');
$eventsManager->fire('account:afterLogin', $this, $user);
}
protected function fireAfterLogoutEvent(UserModel $user)
{
/**
* @var EventsManager $eventsManager
*/
$eventsManager = Di::getDefault()->getShared('eventsManager');
$eventsManager->fire('account:afterLogout', $this, $user);
$this->eventsManager->fire('Account:afterLogout', $this, $user);
}
}

View File

@ -3,7 +3,6 @@
namespace App\Http\Admin\Services;
use App\Caches\Topic as TopicCache;
use App\Caches\TopicCourseList as TopicCourseListCache;
use App\Library\Paginator\Query as PagerQuery;
use App\Models\CourseTopic as CourseTopicModel;
use App\Models\Topic as TopicModel;
@ -66,8 +65,8 @@ class Topic extends Service
$data = [];
if (isset($post['name'])) {
$data['name'] = $validator->checkName($post['name']);
if (isset($post['title'])) {
$data['title'] = $validator->checkTitle($post['title']);
}
if (isset($post['summary'])) {
@ -194,10 +193,6 @@ class Topic extends Service
$cache = new TopicCache();
$cache->rebuild($topic->id);
$cache = new TopicCourseListCache();
$cache->rebuild($topic->id);
}
protected function findOrFail($id)

View File

@ -0,0 +1,61 @@
{%- macro redeem_status_info(value) %}
{% if value == 1 %}
<span class="status">处理中</span>
{% elseif value == 2 %}
<span class="status">已完成</span>
{% elseif value == 3 %}
<span class="status">已失败</span>
{% endif %}
{%- endmacro %}
{%- macro gift_type_info(value) %}
{% if value == 1 %}
<span class="layui-badge layui-bg-green type">课程</span>
{% elseif value == 2 %}
<span class="layui-badge layui-bg-blue type">商品</span>
{% elseif value == 3 %}
<span class="layui-badge layui-bg-cyan type">现金</span>
{% endif %}
{%- endmacro %}
{%- macro event_type_info(value) %}
{% if value == 1 %}
<span class="type">订单消费</span>
{% elseif value == 2 %}
<span class="type">积分兑换</span>
{% elseif value == 3 %}
<span class="type">积分退款</span>
{% elseif value == 4 %}
<span class="type">帐号注册</span>
{% elseif value == 5 %}
<span class="type">站点访问</span>
{% elseif value == 6 %}
<span class="type">课时学习</span>
{% elseif value == 7 %}
<span class="type">课程评价</span>
{% elseif value == 8 %}
<span class="type">微聊讨论</span>
{% endif %}
{%- endmacro %}
{%- macro event_detail_info(history) %}
{% set event_info = history.event_info %}
{% if history.event_type == 1 %}
<p class="order">{{ event_info.order.subject }}</p>
{% elseif history.event_type == 2 %}
<p class="gift">{{ event_info.point_redeem.gift_name }}</p>
{% elseif history.event_type == 3 %}
<span class="none">{{ event_info.point_redeem.gift_name }}</span>
{% elseif history.event_type == 4 %}
<span class="none">N/A</span>
{% elseif history.event_type == 5 %}
<span class="none">N/A</span>
{% elseif history.event_type == 6 %}
<p class="course">课程:{{ event_info.course.title }}</p>
<p class="chapter">章节:{{ event_info.chapter.title }}</p>
{% elseif history.event_type == 7 %}
<p class="course">{{ event_info.course.title }}</p>
{% elseif history.event_type == 8 %}
<span class="none">N/A</span>
{% endif %}
{%- endmacro %}

View File

@ -81,6 +81,12 @@
<input class="layui-input" type="text" name="stock" value="{{ gift.stock }}" lay-verify="number">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">兑换限额</label>
<div class="layui-input-block">
<input class="layui-input" type="text" name="redeem_limit" value="{{ gift.redeem_limit }}" lay-verify="number">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label"></label>
<div class="layui-input-block">

View File

@ -2,17 +2,9 @@
{% block content %}
{%- macro type_info(value) %}
{% if value == 1 %}
<span class="layui-badge layui-bg-green">课程</span>
{% elseif value == 2 %}
<span class="layui-badge layui-bg-blue">商品</span>
{% elseif value == 3 %}
<span class="layui-badge layui-bg-cyan">现金</span>
{% else %}
<span class="layui-badge layui-bg-gray">未知</span>
{% endif %}
{%- endmacro %}
{{ partial('macros/point') }}
{% set add_url = url({'for':'admin.point_gift.add'}) %}
<div class="kg-nav">
<div class="kg-nav-left">
@ -20,6 +12,11 @@
<a><cite>礼品管理</cite></a>
</span>
</div>
<div class="kg-nav-right">
<a class="layui-btn layui-btn-sm" href="{{ add_url }}">
<i class="layui-icon layui-icon-add-1"></i>添加礼品
</a>
</div>
</div>
<table class="kg-table layui-table layui-form">
@ -30,14 +27,16 @@
<col>
<col>
<col>
<col>
<col width="12%">
</group>
<thead>
<tr>
<th>编号</th>
<th>品名称</th>
<th>品名称</th>
<th>所需积分</th>
<th>库存数量</th>
<th>兑换限额</th>
<th>兑换人次</th>
<th>发布</th>
<th>操作</th>
@ -53,9 +52,10 @@
{% set restore_url = url({'for':'admin.point_gift.restore','id':item.id}) %}
<tr>
<td>{{ item.id }}</td>
<td><a href="{{ edit_url }}">{{ item.name }}</a> {{ type_info(item.type) }}</td>
<td><a href="{{ edit_url }}">{{ item.name }}</a> {{ gift_type_info(item.type) }}</td>
<td>{{ item.point }}</td>
<td>{{ item.stock }}</td>
<td>{{ item.redeem_limit }}</td>
<td><a class="layui-badge layui-bg-green" href="{{ redeem_url }}">{{ item.redeem_count }}</a></td>
<td><input type="checkbox" name="published" value="1" lay-filter="published" lay-skin="switch" lay-text="是|否" data-url="{{ update_url }}" {% if item.published == 1 %}checked="checked"{% endif %}></td>
<td class="center">

View File

@ -2,79 +2,61 @@
{% block content %}
{%- macro type_info(value) %}
{% if value == 1 %}
<span class="layui-badge layui-bg-green">课</span>
{% elseif value == 2 %}
<span class="layui-badge layui-bg-blue">聊</span>
{% elseif value == 3 %}
<span class="layui-badge layui-bg-cyan">职</span>
{% else %}
<span class="layui-badge layui-bg-gray">未知</span>
{% endif %}
{%- endmacro %}
{{ partial('macros/point') }}
{%- macro owner_info(owner) %}
{% if owner.id is defined %}
{{ owner.name }}{{ owner.id }}
{% else %}
未设置
{% endif %}
{%- endmacro %}
{% set search_url = url({'for':'admin.point_redeem.search'}) %}
<div class="kg-nav">
<div class="kg-nav-left">
<span class="layui-breadcrumb">
<a><cite>群组管理</cite></a>
<a><cite>兑换记录</cite></a>
</span>
</div>
<div class="kg-nav-right">
<a class="layui-btn layui-btn-sm" href="{{ search_url }}">
<i class="layui-icon layui-icon-search"></i>搜索兑换
</a>
</div>
</div>
<table class="kg-table layui-table layui-form">
<table class="kg-table layui-table">
<colgroup>
<col>
<col>
<col>
<col>
<col>
<col width="12%">
</colgroup>
<thead>
<tr>
<th>编号</th>
<th>名称</th>
<th>群主</th>
<th>成员</th>
<th>发布</th>
<th>物品名称</th>
<th>消耗积分</th>
<th>兑换状态</th>
<th>兑换时间</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{% for item in pager.items %}
{% set preview_url = url({'for':'home.group.show','id':item.id}) %}
{% set edit_url = url({'for':'admin.group.edit','id':item.id}) %}
{% set update_url = url({'for':'admin.group.update','id':item.id}) %}
{% set delete_url = url({'for':'admin.group.delete','id':item.id}) %}
{% set restore_url = url({'for':'admin.group.restore','id':item.id}) %}
{% set user_filter_url = url({'for':'admin.point_redeem.list'},{'user_id':item.user_id}) %}
{% set deliver_url = url({'for':'admin.point_redeem.deliver','id':item.id}) %}
{% set gift_url = url({'for':'home.point_gift.show','id':item.gift_id}) %}
<tr>
<td>{{ item.id }}</td>
<td><a href="{{ edit_url }}">{{ item.name }}</a> {{ type_info(item.type) }}</td>
<td>{{ owner_info(item.owner) }}</td>
<td><span class="layui-badge layui-bg-gray">{{ item.user_count }}</span></td>
<td><input type="checkbox" name="published" value="1" lay-filter="published" lay-skin="switch" lay-text="是|否" data-url="{{ update_url }}" {% if item.published == 1 %}checked="checked"{% endif %}></td>
<td>
<p><a href="{{ gift_url }}" target="_blank">{{ item.gift_name }}{{ item.gift_id }}</a>{{ gift_type_info(item.gift_type) }}</p>
<p>用户名称:<a href="{{ user_filter_url }}">{{ item.user_name }}</a> {{ item.user_id }} 联系方式:
<button class="layui-btn layui-btn-xs kg-contact" data-name="{{ item.contact_name }}" data-phone="{{ item.contact_phone }}" data-address="{{ item.contact_address }}">查看</button>
</p>
</td>
<td>{{ item.gift_point }}</td>
<td>{{ redeem_status_info(item.status) }}</td>
<td>{{ date('Y-m-d H:i',item.create_time) }}</td>
<td class="center">
<div class="layui-dropdown">
<button class="layui-btn layui-btn-sm">操作 <i class="layui-icon layui-icon-triangle-d"></i></button>
<ul>
<li><a href="{{ preview_url }}" target="_blank">预览</a></li>
<li><a href="{{ edit_url }}">编辑</a></li>
{% if item.deleted == 0 %}
<li><a href="javascript:" class="kg-delete" data-url="{{ delete_url }}">删除</a></li>
{% else %}
<li><a href="javascript:" class="kg-restore" data-url="{{ restore_url }}">还原</a></li>
{% endif %}
</ul>
</div>
{% if item.gift_type == 2 %}
<button class="layui-btn layui-btn-sm kg-deliver" data-url="{{ deliver_url }}">发货</button>
{% else %}
N/A
{% endif %}
</td>
</tr>
{% endfor %}
@ -83,4 +65,36 @@
{{ partial('partials/pager') }}
{% endblock %}
{% block inline_js %}
<script>
layui.use(['jquery', 'layer'], function () {
var $ = layui.jquery;
var layer = layui.layer;
$('.kg-deliver').on('click', function () {
var url = $(this).data('url');
layer.confirm('确定要发货吗?', function () {
$.post(url, function (res) {
layer.msg(res.msg, {icon: 1});
setTimeout(function () {
window.location.reload();
}, 1500);
});
});
});
});
</script>
{% endblock %}
{% block include_js %}
{{ js_include('admin/js/contact.js') }}
{% endblock %}

View File

@ -0,0 +1,46 @@
{% extends 'templates/main.volt' %}
{% block content %}
<form class="layui-form kg-form" method="GET" action="{{ url({'for':'admin.point_redeem.list'}) }}">
<fieldset class="layui-elem-field layui-field-title">
<legend>搜索兑换</legend>
</fieldset>
<div class="layui-form-item">
<label class="layui-form-label">用户编号</label>
<div class="layui-input-block">
<input class="layui-input" type="text" name="user_id" placeholder="用户编号精确匹配">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">礼物编号</label>
<div class="layui-input-block">
<input class="layui-input" type="text" name="gift_id" placeholder="礼物编号精确匹配">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">礼物类型</label>
<div class="layui-input-block">
<input type="radio" name="gift_type" value="1" title="课程">
<input type="radio" name="gift_type" value="2" title="商品">
<input type="radio" name="gift_type" value="3" title="现金">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">兑换状态</label>
<div class="layui-input-block">
<input type="radio" name="status" value="1" title="处理中">
<input type="radio" name="status" value="2" title="已完成">
<input type="radio" name="status" value="3" title="已失败">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label"></label>
<div class="layui-input-block">
<button class="layui-btn" lay-submit="true">提交</button>
<button type="button" class="kg-back layui-btn layui-btn-primary">返回</button>
</div>
</div>
</form>
{% endblock %}

View File

@ -81,20 +81,20 @@
</tr>
<tr>
<td>课时学习</td>
<td><input class="layui-input" type="text" name="event_rule[lesson_learning][point]" value="{{ event_rule.lesson_learning.point }}" lay-verify="required"></td>
<td><input class="layui-input" type="text" name="event_rule[chapter_study][point]" value="{{ event_rule.chapter_study.point }}" lay-verify="required"></td>
<td>N/A</td>
<td>
<input type="radio" name="event_rule[lesson_learning][enabled]" value="1" title="是" {% if event_rule.lesson_learning.enabled == "1" %}checked="checked"{% endif %}>
<input type="radio" name="event_rule[lesson_learning][enabled]" value="0" title="否" {% if event_rule.lesson_learning.enabled == "0" %}checked="checked"{% endif %}>
<input type="radio" name="event_rule[chapter_study][enabled]" value="1" title="是" {% if event_rule.chapter_study.enabled == "1" %}checked="checked"{% endif %}>
<input type="radio" name="event_rule[chapter_study][enabled]" value="0" title="否" {% if event_rule.chapter_study.enabled == "0" %}checked="checked"{% endif %}>
</td>
</tr>
<tr>
<td>群组讨论</td>
<td><input class="layui-input" type="text" name="event_rule[group_discuss][point]" value="{{ event_rule.group_discuss.point }}" lay-verify="required"></td>
<td>微聊讨论</td>
<td><input class="layui-input" type="text" name="event_rule[im_discuss][point]" value="{{ event_rule.im_discuss.point }}" lay-verify="required"></td>
<td>N/A</td>
<td>
<input type="radio" name="event_rule[group_discuss][enabled]" value="1" title="是" {% if event_rule.group_discuss.enabled == "1" %}checked="checked"{% endif %}>
<input type="radio" name="event_rule[group_discuss][enabled]" value="0" title="否" {% if event_rule.group_discuss.enabled == "0" %}checked="checked"{% endif %}>
<input type="radio" name="event_rule[im_discuss][enabled]" value="1" title="是" {% if event_rule.im_discuss.enabled == "1" %}checked="checked"{% endif %}>
<input type="radio" name="event_rule[im_discuss][enabled]" value="0" title="否" {% if event_rule.im_discuss.enabled == "0" %}checked="checked"{% endif %}>
</td>
</tr>
</tbody>

View File

@ -6,9 +6,15 @@
{% if value == 1 %}
免费
{% elseif value == 2 %}
<span class="layui-badge layui-bg-orange">付费</span>
付费
{% elseif value == 3 %}
导入
{% elseif value == 4 %}
会员
{% elseif value == 5 %}
积分
{% elseif value == 6 %}
抽奖
{% endif %}
{%- endmacro %}
@ -58,8 +64,8 @@
</td>
<td>{{ source_type_info(item.source_type) }}</td>
<td>
<p>开始:{{ date('Y-m-d H:i:s',item.create_time) }}</p>
<p>结束:{{ date('Y-m-d H:i:s',item.expiry_time) }}</p>
<p>开始:{{ date('Y-m-d H:i',item.create_time) }}</p>
<p>结束:{{ date('Y-m-d H:i',item.expiry_time) }}</p>
</td>
<td class="center">
<div class="layui-dropdown">

View File

@ -6,8 +6,6 @@ use App\Models\User as UserModel;
use App\Services\Auth\Api as ApiAuth;
use App\Traits\Response as ResponseTrait;
use App\Traits\Security as SecurityTrait;
use Phalcon\Di as Di;
use Phalcon\Events\Manager as EventsManager;
use Phalcon\Mvc\Dispatcher;
class Controller extends \Phalcon\Mvc\Controller
@ -36,7 +34,7 @@ class Controller extends \Phalcon\Mvc\Controller
{
$this->authUser = $this->getAuthUser();
$this->fireSiteViewEvent($this->authUser);
$this->eventsManager->fire('Site:afterView', $this, $this->authUser);
}
protected function getAuthUser()
@ -49,14 +47,4 @@ class Controller extends \Phalcon\Mvc\Controller
return $auth->getCurrentUser();
}
protected function fireSiteViewEvent(UserModel $user)
{
/**
* @var EventsManager $eventsManager
*/
$eventsManager = Di::getDefault()->getShared('eventsManager');
$eventsManager->fire('site:view', $this, $user);
}
}

View File

@ -104,7 +104,7 @@ class Account extends Service
*/
$eventsManager = Di::getDefault()->getShared('eventsManager');
$eventsManager->fire('account:afterRegister', $this, $user);
$eventsManager->fire('Account:afterRegister', $this, $user);
}
protected function fireAfterLoginEvent(UserModel $user)
@ -114,7 +114,7 @@ class Account extends Service
*/
$eventsManager = Di::getDefault()->getShared('eventsManager');
$eventsManager->fire('account:afterLogin', $this, $user);
$eventsManager->fire('Account:afterLogin', $this, $user);
}
protected function fireAfterLogoutEvent(UserModel $user)
@ -124,7 +124,7 @@ class Account extends Service
*/
$eventsManager = Di::getDefault()->getShared('eventsManager');
$eventsManager->fire('account:afterLogout', $this, $user);
$eventsManager->fire('Account:afterLogout', $this, $user);
}
}

View File

@ -9,6 +9,7 @@ use App\Services\Logic\Chapter\ChapterLike as ChapterLikeService;
use App\Services\Logic\Chapter\DanmuList as ChapterDanmuListService;
use App\Services\Logic\Chapter\Learning as ChapterLearningService;
use App\Services\Logic\Chapter\ResourceList as ChapterResourceListService;
use App\Services\Logic\Course\BasicInfo as CourseInfoService;
use App\Services\Logic\Course\ChapterList as CourseChapterListService;
/**
@ -50,20 +51,24 @@ class ChapterController extends Controller
$chapter = $service->handle($id);
$service = new CourseInfoService();
$course = $service->handle($chapter['course']['id']);
$owned = $chapter['me']['owned'] ?? false;
if (!$owned) {
$this->response->redirect([
'for' => 'home.course.show',
'id' => $chapter['course']['id'],
'id' => $course['id'],
]);
}
$service = new CourseChapterListService();
$catalog = $service->handle($chapter['course']['id']);
$catalog = $service->handle($course['id']);
$this->seo->prependTitle(['章节', $chapter['title'], $chapter['course']['title']]);
$this->seo->prependTitle(['章节', $chapter['title'], $course['title']]);
if (!empty($chapter['summary'])) {
$this->seo->setDescription($chapter['summary']);
@ -83,6 +88,7 @@ class ChapterController extends Controller
}
}
$this->view->setVar('course', $course);
$this->view->setVar('chapter', $chapter);
$this->view->setVar('catalog', $catalog);
}

View File

@ -10,8 +10,6 @@ use App\Services\Auth\Home as HomeAuth;
use App\Services\Service as AppService;
use App\Traits\Response as ResponseTrait;
use App\Traits\Security as SecurityTrait;
use Phalcon\Di as Di;
use Phalcon\Events\Manager as EventsManager;
use Phalcon\Mvc\Dispatcher;
class Controller extends \Phalcon\Mvc\Controller
@ -75,16 +73,13 @@ class Controller extends \Phalcon\Mvc\Controller
public function initialize()
{
$this->eventsManager->fire('Site:afterView', $this, $this->authUser);
$this->seo = $this->getSeo();
$this->navs = $this->getNavs();
$this->appInfo = $this->getAppInfo();
$this->imInfo = $this->getImInfo();
/**
* @todo 内部操作会改变afterFetch()
*/
$this->fireSiteViewEvent($this->authUser);
$this->seo->setTitle($this->siteInfo['title']);
$this->view->setVar('seo', $this->seo);
@ -161,14 +156,4 @@ class Controller extends \Phalcon\Mvc\Controller
return $appService->getSettings($section);
}
protected function fireSiteViewEvent(UserModel $user)
{
/**
* @var EventsManager $eventsManager
*/
$eventsManager = Di::getDefault()->getShared('eventsManager');
$eventsManager->fire('site:view', $this, $user);
}
}

View File

@ -6,6 +6,8 @@ use App\Services\Logic\Point\GiftInfo as GiftInfoService;
use App\Services\Logic\Point\GiftList as GiftListService;
use App\Services\Logic\Point\HotGiftList as HotGiftListService;
use App\Services\Logic\Point\PointRedeem as GiftRedeemService;
use App\Services\Logic\User\Console\BalanceInfo as BalanceInfoService;
use Phalcon\Mvc\Dispatcher;
use Phalcon\Mvc\View;
/**
@ -14,6 +16,18 @@ use Phalcon\Mvc\View;
class PointGiftController extends Controller
{
public function beforeExecuteRoute(Dispatcher $dispatcher)
{
parent::beforeExecuteRoute($dispatcher);
if ($this->authUser->id == 0) {
$this->response->redirect(['for' => 'home.account.login']);
return false;
}
return true;
}
/**
* @Get("/list", name="home.point_gift.list")
*/
@ -50,12 +64,14 @@ class PointGiftController extends Controller
$gift = $service->handle($id);
$hotGifts = $this->getHotGifts();
$userBalance = $this->getUserBalance();
$this->seo->prependTitle(['积分兑换', $gift['name']]);
$this->view->pick('point/gift/show');
$this->view->setVar('gift', $gift);
$this->view->setVar('hot_gifts', $hotGifts);
$this->view->setVar('user_balance', $userBalance);
}
/**
@ -77,4 +93,11 @@ class PointGiftController extends Controller
return $service->handle();
}
protected function getUserBalance()
{
$service = new BalanceInfoService();
return $service->handle();
}
}

View File

@ -2,7 +2,7 @@
namespace App\Http\Home\Controllers;
use App\Services\Logic\Point\PointRedeem as GiftRedeemService;
use App\Services\Logic\Point\PointRedeem as PointRedeemService;
/**
* @RoutePrefix("/point/redeem")
@ -15,21 +15,11 @@ class PointRedeemController extends Controller
*/
public function createAction()
{
$service = new GiftRedeemService();
$service = new PointRedeemService();
$service->handle();
return $this->jsonSuccess(['msg' => '兑换成功']);
}
/**
* @Get("/list", name="home.point_gift.list")
*/
public function listAction()
{
$this->seo->prependTitle('积分兑换');
$this->view->pick('point/gift/list');
}
}

View File

@ -15,6 +15,7 @@ use App\Services\Logic\User\Console\FavoriteList as FavoriteListService;
use App\Services\Logic\User\Console\FriendList as FriendListService;
use App\Services\Logic\User\Console\GroupList as GroupListService;
use App\Services\Logic\User\Console\OrderList as OrderListService;
use App\Services\Logic\User\Console\PointHistory as PointHistoryService;
use App\Services\Logic\User\Console\PointRedeemList as PointRedeemListService;
use App\Services\Logic\User\Console\ProfileInfo as ProfileInfoService;
use App\Services\Logic\User\Console\ProfileUpdate as ProfileUpdateService;
@ -199,7 +200,20 @@ class UserConsoleController extends Controller
}
/**
* @Get("/point_redeems", name="home.uc.point_redeems")
* @Get("/point/history", name="home.uc.point_history")
*/
public function pointHistoryAction()
{
$service = new PointHistoryService();
$pager = $service->handle();
$this->view->pick('user/console/point_history');
$this->view->setVar('pager', $pager);
}
/**
* @Get("/point/redeems", name="home.uc.point_redeems")
*/
public function pointRedeemsAction()
{

View File

@ -87,7 +87,7 @@ class Account extends Service
*/
$eventsManager = Di::getDefault()->getShared('eventsManager');
$eventsManager->fire('account:afterRegister', $this, $user);
$eventsManager->fire('Account:afterRegister', $this, $user);
}
protected function fireAfterLoginEvent(UserModel $user)
@ -97,7 +97,7 @@ class Account extends Service
*/
$eventsManager = Di::getDefault()->getShared('eventsManager');
$eventsManager->fire('account:afterLogin', $this, $user);
$eventsManager->fire('Account:afterLogin', $this, $user);
}
protected function fireAfterLogoutEvent(UserModel $user)
@ -107,7 +107,7 @@ class Account extends Service
*/
$eventsManager = Di::getDefault()->getShared('eventsManager');
$eventsManager->fire('account:afterLogout', $this, $user);
$eventsManager->fire('Account:afterLogout', $this, $user);
}
}

View File

@ -98,6 +98,8 @@ Trait ImMessageTrait
Gateway::$registerAddress = $this->getRegisterAddress();
$imMessage = new ImMessageModel();
if ($to['type'] == 'friend') {
$validator = new ImFriendUserValidator();
@ -106,9 +108,9 @@ Trait ImMessageTrait
$online = Gateway::isUidOnline($to['id']);
$messageModel = new ImMessageModel();
$imMessage = new ImMessageModel();
$messageModel->create([
$imMessage->create([
'sender_id' => $from['id'],
'receiver_id' => $to['id'],
'receiver_type' => ImMessageModel::TYPE_FRIEND,
@ -136,9 +138,9 @@ Trait ImMessageTrait
$relation = $validator->checkGroupUser($group->id, $user->id);
$messageModel = new ImMessageModel();
$imMessage = new ImMessageModel();
$messageModel->create([
$imMessage->create([
'sender_id' => $from['id'],
'receiver_id' => $to['id'],
'receiver_type' => ImMessageModel::TYPE_GROUP,
@ -162,6 +164,8 @@ Trait ImMessageTrait
Gateway::sendToGroup($groupName, $content, $excludeClientId);
}
$this->eventsManager->fire('ImMessage:afterCreate', $this, $imMessage);
}
public function sendCsMessage($from, $to)

View File

@ -18,7 +18,9 @@
<span class="share">
<a href="javascript:" title="我要点赞" data-url="{{ like_url }}"><i class="layui-icon layui-icon-praise icon-praise"></i><em class="like-count">{{ chapter.like_count }}</em></a>
<a href="javascript:" title="学习人次"><i class="layui-icon layui-icon-user"></i><em>{{ chapter.user_count }}</em></a>
<a href="javascript:" title="我要提问" data-url="{{ consult_url }}"><i class="layui-icon layui-icon-help icon-help"></i></a>
{% if course.market_price > 0 %}
<a href="javascript:" title="我要提问" data-url="{{ consult_url }}"><i class="layui-icon layui-icon-help icon-help"></i></a>
{% endif %}
{% if chapter.resource_count > 0 and chapter.me.owned == 1 %}
<a href="javascript:" title="资料下载" data-url="{{ resources_url }}"><i class="layui-icon layui-icon-download-circle icon-resource"></i></a>
{% endif %}

View File

@ -19,7 +19,9 @@
<span class="share">
<a href="javascript:" title="我要点赞" data-url="{{ like_url }}"><i class="layui-icon layui-icon-praise icon-praise {{ liked_class }}"></i><em class="like-count">{{ chapter.like_count }}</em></a>
<a href="javascript:" title="学习人次"><i class="layui-icon layui-icon-user"></i><em>{{ chapter.user_count }}</em></a>
<a href="javascript:" title="我要提问" data-url="{{ consult_url }}"><i class="layui-icon layui-icon-help icon-help"></i></a>
{% if course.market_price > 0 %}
<a href="javascript:" title="我要提问" data-url="{{ consult_url }}"><i class="layui-icon layui-icon-help icon-help"></i></a>
{% endif %}
{% if chapter.resource_count > 0 and chapter.me.owned == 1 %}
<a href="javascript:" title="资料下载" data-url="{{ resources_url }}"><i class="layui-icon layui-icon-download-circle icon-resource"></i></a>
{% endif %}

View File

@ -6,7 +6,7 @@
{% for teacher in course.teachers %}
{% set teacher_url = url({'for':'home.user.show','id':teacher.id}) %}
{% set teacher.title = teacher.title ? teacher.title : '小小教书匠' %}
<div class="sidebar-teacher-card clearfix">
<div class="sidebar-user-card clearfix">
<div class="avatar">
<img src="{{ teacher.avatar }}!avatar_160" alt="{{ teacher.name }}">
</div>

View File

@ -1,3 +1,13 @@
{%- macro redeem_status_info(value) %}
{% if value == 1 %}
<span class="status">处理中</span>
{% elseif value == 2 %}
<span class="status">已完成</span>
{% elseif value == 3 %}
<span class="status">已失败</span>
{% endif %}
{%- endmacro %}
{%- macro gift_type_info(value) %}
{% if value == 1 %}
<span class="layui-badge layui-bg-green type">课程</span>
@ -6,4 +16,59 @@
{% elseif value == 3 %}
<span class="layui-badge layui-bg-cyan type">现金</span>
{% endif %}
{%- endmacro %}
{%- macro event_point_info(value) %}
{% if value > 0 %}
<span class="layui-badge layui-bg-green point">+{{ value }}</span>
{% else %}
<span class="layui-badge layui-bg-red point">{{ value }}</span>
{% endif %}
{%- endmacro %}
{%- macro event_type_info(value) %}
{% if value == 1 %}
<span class="type">订单消费</span>
{% elseif value == 2 %}
<span class="type">积分兑换</span>
{% elseif value == 3 %}
<span class="type">积分退款</span>
{% elseif value == 4 %}
<span class="type">帐号注册</span>
{% elseif value == 5 %}
<span class="type">站点访问</span>
{% elseif value == 6 %}
<span class="type">课时学习</span>
{% elseif value == 7 %}
<span class="type">课程评价</span>
{% elseif value == 8 %}
<span class="type">微聊讨论</span>
{% endif %}
{%- endmacro %}
{%- macro event_detail_info(history) %}
{% set event_info = history.event_info %}
{% if history.event_type == 1 %}
<p class="order">{{ event_info.order.subject }}</p>
{% elseif history.event_type == 2 %}
{% set gift_url = url({'for':'home.point_gift.show','id':event_info.point_redeem.gift_id}) %}
<p class="gift"><a href="{{ gift_url }}">{{ event_info.point_redeem.gift_name }}</a></p>
{% elseif history.event_type == 3 %}
{% set gift_url = url({'for':'home.point_gift.show','id':event_info.point_redeem.gift_id}) %}
<p class="gift"><a href="{{ gift_url }}">{{ event_info.point_redeem.gift_name }}</a></p>
{% elseif history.event_type == 4 %}
<span class="none">N/A</span>
{% elseif history.event_type == 5 %}
<span class="none">N/A</span>
{% elseif history.event_type == 6 %}
{% set course_url = url({'for':'home.course.show','id':event_info.course.id}) %}
{% set chapter_url = url({'for':'home.chapter.show','id':event_info.chapter.id}) %}
<p class="course">课程:<a href="{{ course_url }}">{{ event_info.course.title }}</a></p>
<p class="chapter">章节:<a href="{{ chapter_url }}">{{ event_info.chapter.title }}</a></p>
{% elseif history.event_type == 7 %}
{% set course_url = url({'for':'home.course.show','id':event_info.course.id}) %}
<p class="course"><a href="{{ course_url }}">{{ event_info.course.title }}</a></p>
{% elseif history.event_type == 8 %}
<span class="none">N/A</span>
{% endif %}
{%- endmacro %}

View File

@ -2,7 +2,9 @@
{% block content %}
{% set gift_redeem_url = url({'for':'home.point_redeem.create'}) %}
{{ partial('macros/point') }}
{% set redeem_create_url = url({'for':'home.point_redeem.create'}) %}
{% set gift_list_url = url({'for':'home.point_gift.list'}) %}
<div class="breadcrumb">
@ -16,29 +18,45 @@
<div class="layout-main clearfix">
<div class="layout-content">
<div class="layui-card">
<div class="layui-card-header">品信息</div>
<div class="layui-card-header">品信息</div>
<div class="layui-card-body">
<div class="gift-meta clearfix">
<div class="cover">
<img src="{{ gift.cover }}!cover_270" alt="{{ gift.name }}">
</div>
<div class="info">
<p class="item">{{ gift.name }}</p>
{% if gift.type == 1 %}
{% set course_url = url({'for':'home.course.show','id':gift.attrs.id}) %}
<p class="item">
<a href="{{ course_url }}">{{ gift.name }}</a>
{{ gift_type_info(gift.type) }}
</p>
{% else %}
<p class="item">{{ gift.name }} {{ gift_type_info(gift.type) }}</p>
{% endif %}
<p class="item stats">
<span class="key">兑换库存</span>
<span class="value">{{ gift.stock }}</span>
<span class="key">兑换价格</span>
<span class="price">{{ gift.point }} 积分</span>
<span class="key">兑换限额</span>
<span class="value">{{ gift.redeem_limit }}</span>
<span class="key">兑换人次</span>
<span class="value">{{ gift.redeem_count }}</span>
</p>
<p class="item">
<button class="layui-btn layui-bg-red btn-redeem" data-id="{{ gift.id }}" data-url="{{ gift_redeem_url }}">立即兑换</button>
{% if gift.stock > 0 and user_balance.point > gift.point %}
<button class="layui-btn layui-bg-red btn-redeem" data-id="{{ gift.id }}" data-url="{{ redeem_create_url }}">立即兑换</button>
{% else %}
<button class="layui-btn layui-btn-disabled">立即兑换</button>
{% endif %}
</p>
</div>
</div>
</div>
</div>
<div class="layui-card">
<div class="layui-card-header">品详情</div>
<div class="layui-card-header">品详情</div>
<div class="layui-card-body">
<div class="gift-details markdown-body">{{ gift.details }}</div>
</div>
@ -47,7 +65,23 @@
<div class="layout-sidebar">
<div class="sidebar">
<div class="layui-card">
<div class="layui-card-header">热门商品</div>
<div class="layui-card-header">我的信息</div>
<div class="layui-card-body">
<div class="sidebar-user-card clearfix">
<div class="avatar">
<img src="{{ auth_user.avatar }}!avatar_160" alt="{{ auth_user.name }}">
</div>
<div class="info">
<div class="name">{{ auth_user.name }}</div>
<div class="meta"><span>当前积分</span><span class="point">{{ user_balance.point }}</span></div>
</div>
</div>
</div>
</div>
</div>
<div class="sidebar">
<div class="layui-card">
<div class="layui-card-header">热门兑换</div>
<div class="layui-card-body">
{% for gift in hot_gifts %}
{% set gift_url = url({'for':'home.point_gift.show','id':gift.id}) %}

View File

@ -34,7 +34,7 @@
<div class="layui-input-block">
<button class="layui-btn" lay-submit="true" lay-filter="go">提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
<input type="hidden" name="course_id" value="{{ request.get('course.id') }}">
<input type="hidden" name="course_id" value="{{ request.get('course_id') }}">
<input type="hidden" name="rating1" value="5">
<input type="hidden" name="rating2" value="5">
<input type="hidden" name="rating3" value="5">

View File

@ -41,7 +41,9 @@
{% block inline_js %}{% endblock %}
{% if site_info.analytics_enabled == 1 %}
{{ site_info.analytics_script }}
<div class="layui-hide">
{{ site_info.analytics_script }}
</div>
{% endif %}
</body>

View File

@ -28,7 +28,7 @@
<tbody>
{% for item in pager.items %}
{% set course_url = url({'for':'home.course.show','id':item.course.id}) %}
{% set review_url = url({'for':'home.review.add'},{'id':item.course.id}) %}
{% set review_url = url({'for':'home.review.add'},{'course_id':item.course.id}) %}
{% set allow_review = item.progress > 30 and item.reviewed == 0 %}
<tr>
<td>

View File

@ -36,6 +36,17 @@
</div>
</div>
<div class="layui-card">
<div class="layui-card-header">积分中心</div>
<div class="layui-card-body">
<ul class="my-menu">
<li><a href="{{ url({'for':'home.point_gift.list'}) }}">积分商城</a></li>
<li><a href="{{ url({'for':'home.uc.point_history'}) }}">积分记录</a></li>
<li><a href="{{ url({'for':'home.uc.point_redeems'}) }}">兑换记录</a></li>
</ul>
</div>
</div>
<div class="layui-card">
<div class="layui-card-header">聊天设置</div>
<div class="layui-card-body">

View File

@ -0,0 +1,47 @@
{% extends 'templates/main.volt' %}
{% block content %}
{{ partial('macros/point') }}
<div class="layout-main clearfix">
<div class="my-sidebar">{{ partial('user/console/menu') }}</div>
<div class="my-content">
<div class="my-nav">
<span class="title">积分记录</span>
</div>
<div class="history-wrap wrap">
{% if pager.total_pages > 0 %}
<table class="layui-table history-table" lay-size="lg">
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th>来源</th>
<th>积分</th>
<th>详情</th>
<th>时间</th>
</tr>
</thead>
<tbody>
{% for item in pager.items %}
<tr>
<td>{{ event_type_info(item.event_type) }}</td>
<td>{{ event_point_info(item.event_point) }}</td>
<td>{{ event_detail_info(item) }}</td>
<td>{{ date('Y-m-d H:i',item.create_time) }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{{ partial('partials/pager') }}
{% endif %}
</div>
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,48 @@
{% extends 'templates/main.volt' %}
{% block content %}
{{ partial('macros/point') }}
<div class="layout-main clearfix">
<div class="my-sidebar">{{ partial('user/console/menu') }}</div>
<div class="my-content">
<div class="my-nav">
<span class="title">兑换记录</span>
</div>
<div class="history-wrap wrap">
{% if pager.total_pages > 0 %}
<table class="layui-table" lay-size="lg">
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th>物品名称</th>
<th>消耗积分</th>
<th>兑换状态</th>
<th>兑换时间</th>
</tr>
</thead>
<tbody>
{% for item in pager.items %}
{% set gift_url = url({'for':'home.point_gift.show','id':item.gift.id}) %}
<tr>
<td><a href="{{ gift_url }}">{{ item.gift.name }}</a> {{ gift_type_info(item.gift.type) }}</td>
<td>{{ item.gift.point }}</td>
<td>{{ redeem_status_info(item.status) }}</td>
<td>{{ date('Y-m-d H:i',item.create_time) }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{{ partial('partials/pager') }}
{% endif %}
</div>
</div>
</div>
{% endblock %}

View File

@ -16,7 +16,7 @@ class Lock
*/
public static function addLock($itemId, $expire = 600)
{
if (!$itemId || $expire <= 0) {
if (empty($itemId) || $expire <= 0) {
return false;
}
@ -43,7 +43,7 @@ class Lock
*/
public static function releaseLock($itemId, $lockId)
{
if (!$itemId || !$lockId) {
if (empty($itemId) || empty($lockId)) {
return false;
}
@ -73,7 +73,7 @@ class Lock
public static function getLockKey($itemId)
{
return sprintf('kg_lock:%s', $itemId);
return sprintf('_LOCK_:%s', $itemId);
}
}

View File

@ -5,22 +5,22 @@ namespace App\Listeners;
use App\Models\User as UserModel;
use App\Services\Logic\Notice\AccountLogin as AccountLoginNoticeService;
use App\Services\Logic\Point\PointHistory as PointHistoryService;
use Phalcon\Events\Event;
use Phalcon\Events\Event as PhEvent;
class Account extends Listener
{
public function afterRegister(Event $event, $source, UserModel $user)
public function afterRegister(PhEvent $event, $source, UserModel $user)
{
$this->handleRegisterPoint($user);
}
public function afterLogin(Event $event, $source, UserModel $user)
public function afterLogin(PhEvent $event, $source, UserModel $user)
{
$this->handleLoginNotice($user);
}
public function afterLogout(Event $event, $source, UserModel $user)
public function afterLogout(PhEvent $event, $source, UserModel $user)
{
}

View File

@ -0,0 +1,40 @@
<?php
namespace App\Listeners;
use App\Models\ImMessage as ImMessageModel;
use App\Services\Logic\Point\PointHistory as PointHistoryService;
use Phalcon\Events\Event as PhEvent;
class ImMessage extends Listener
{
public function afterCreate(PhEvent $event, $source, ImMessageModel $message)
{
$this->handleDiscussPoint($message);
}
protected function handleDiscussPoint(ImMessageModel $message)
{
$todayDate = date('Ymd');
$keyName = sprintf('im_discuss:%s:%s', $message->sender_id, $todayDate);
$cache = $this->getCache();
$content = $cache->get($keyName);
if ($content) return;
$service = new PointHistoryService();
$service->handleImDiscuss($message);
$tomorrow = strtotime($todayDate) + 86400;
$lifetime = $tomorrow - time();
$cache->save($keyName, 1, $lifetime);
}
}

24
app/Listeners/Review.php Normal file
View File

@ -0,0 +1,24 @@
<?php
namespace App\Listeners;
use App\Models\Review as ReviewModel;
use App\Services\Logic\Point\PointHistory as PointHistoryService;
use Phalcon\Events\Event as PhEvent;
class Review extends Listener
{
public function afterCreate(PhEvent $event, $source, ReviewModel $review)
{
$this->handleReviewPoint($review);
}
protected function handleReviewPoint(ReviewModel $review)
{
$service = new PointHistoryService();
$service->handleCourseReview($review);
}
}

View File

@ -8,25 +8,25 @@ use App\Models\User as UserModel;
use App\Repos\Online as OnlineRepo;
use App\Services\Logic\Point\PointHistory as PointHistoryService;
use App\Traits\Client as ClientTrait;
use Phalcon\Events\Event;
use Phalcon\Events\Event as PhEvent;
class Site extends Listener
{
use ClientTrait;
/**
* 访问站点
*
* @param Event $event
* @param $source
* @param UserModel $user
*/
public function view(Event $event, $source, UserModel $user)
public function afterView(PhEvent $event, $source, UserModel $user)
{
if ($user->id > 0) {
$this->handleOnline($user);
$this->handleVisitPoint($user);
/**
* 更新会重置afterFetch重新执行
*/
$user->afterFetch();
}
}
@ -45,13 +45,15 @@ class Site extends Listener
$lockId = LockUtil::addLock($itemId);
if ($lockId === false) return;
$user->active_time = $now;
$user->update();
$onlineRepo = new OnlineRepo();
$records = $onlineRepo->findByUserDate($user->id, date('Y-m-d'));
$records = $onlineRepo->findByUserDate($user->id, date('Ymd'));
if ($records->count() > 0) {
$online = null;

View File

@ -9,7 +9,7 @@ use App\Repos\Order as OrderRepo;
use Phalcon\Events\Event as PhEvent;
use Phalcon\Logger\Adapter\File as FileLogger;
class Pay extends Listener
class Trade extends Listener
{
/**
@ -73,12 +73,6 @@ class Pay extends Listener
'message' => $e->getMessage(),
]));
$this->logger->debug('After Pay Event Info ' . kg_json_encode([
'event' => $event->getType(),
'source' => get_class($source),
'data' => kg_json_encode($trade),
]));
throw new \RuntimeException('sys.trans_rollback');
}
}

View File

@ -1,19 +0,0 @@
<?php
namespace App\Listeners;
use App\Models\User as UserModel;
use App\Traits\Client as ClientTrait;
use Phalcon\Events\Event;
class User extends Listener
{
use ClientTrait;
public function view(Event $event, $source, UserModel $user)
{
}
}

View File

@ -4,7 +4,7 @@ namespace App\Listeners;
use App\Caches\UserDailyCounter as CacheUserDailyCounter;
use App\Models\User as UserModel;
use Phalcon\Events\Event;
use Phalcon\Events\Event as PhEvent;
class UserDailyCounter extends Listener
{
@ -16,42 +16,42 @@ class UserDailyCounter extends Listener
$this->counter = new CacheUserDailyCounter();
}
public function incrFavoriteCount(Event $event, $source, UserModel $user)
public function incrFavoriteCount(PhEvent $event, $source, UserModel $user)
{
$this->counter->hIncrBy($user->id, 'favorite_count');
}
public function incrDanmuCount(Event $event, $source, UserModel $user)
public function incrDanmuCount(PhEvent $event, $source, UserModel $user)
{
$this->counter->hIncrBy($user->id, 'danmu_count');
}
public function incrConsultCount(Event $event, $source, UserModel $user)
public function incrConsultCount(PhEvent $event, $source, UserModel $user)
{
$this->counter->hIncrBy($user->id, 'consult_count');
}
public function incrReviewCount(Event $event, $source, UserModel $user)
public function incrReviewCount(PhEvent $event, $source, UserModel $user)
{
$this->counter->hIncrBy($user->id, 'review_count');
}
public function incrOrderCount(Event $event, $source, UserModel $user)
public function incrOrderCount(PhEvent $event, $source, UserModel $user)
{
$this->counter->hIncrBy($user->id, 'order_count');
}
public function incrConsultLikeCount(Event $event, $source, UserModel $user)
public function incrConsultLikeCount(PhEvent $event, $source, UserModel $user)
{
$this->counter->hIncrBy($user->id, 'consult_like_count');
}
public function incrChapterLikeCount(Event $event, $source, UserModel $user)
public function incrChapterLikeCount(PhEvent $event, $source, UserModel $user)
{
$this->counter->hIncrBy($user->id, 'chapter_like_count');
}
public function incrReviewLikeCount(Event $event, $source, UserModel $user)
public function incrReviewLikeCount(PhEvent $event, $source, UserModel $user)
{
$this->counter->hIncrBy($user->id, 'review_like_count');
}

View File

@ -12,56 +12,56 @@ class Account extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 邮箱
*
* @var string
*/
public $email;
public $email = '';
/**
* 手机
*
* @var string
*/
public $phone;
public $phone = '';
/**
* 密码
*
* @var string
*/
public $password;
public $password = '';
/**
* 密盐
*
* @var string
*/
public $salt;
public $salt = '';
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -90,4 +90,4 @@ class Account extends Model
$this->update_time = time();
}
}
}

View File

@ -17,32 +17,32 @@ class Area extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 类型
*
* @var int
*/
public $type;
public $type = 0;
/**
* 编码
*
* @var string
*/
public $code;
public $code = '';
/**
* 名称
*
* @var string
*/
public $name;
public $name = '';
public function getSource(): string
{
return 'kg_area';
}
}
}

View File

@ -10,49 +10,49 @@ class Audit extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 用户编号
*
* @var int
*/
public $user_id;
public $user_id = 0;
/**
* 用户名称
*
* @var int
* @var string
*/
public $user_name;
public $user_name = '';
/**
* 用户IP
*
* @var int
* @var string
*/
public $user_ip;
public $user_ip = '';
/**
* 请求路由
*
* @var string
*/
public $req_route;
public $req_route = '';
/**
* 请求路径
*
* @var string
*/
public $req_path;
public $req_path = '';
/**
* 请求参数
*
* @var string
* @var array|string
*/
public $req_data;
public $req_data = '';
/**
* 创建时间
@ -80,9 +80,7 @@ class Audit extends Model
}
}
$this->req_data = kg_json_encode($this->req_data);
} else {
$this->req_data = '';
}
}
}
}

View File

@ -19,84 +19,84 @@ class Category extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 上级编号
*
* @var int
*/
public $parent_id;
public $parent_id = 0;
/**
* 层级
*
* @var int
*/
public $level;
public $level = 0;
/**
* 类型
*
* @var int
*/
public $type;
public $type = 0;
/**
* 名称
*
* @var string
*/
public $name;
public $name = '';
/**
* 路径
*
* @var string
*/
public $path;
public $path = '';
/**
* 优先级
*
* @var int
*/
public $priority;
public $priority = 0;
/**
* 发布标识
*
* @var int
*/
public $published;
public $published = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 节点数
*
* @var int
*/
public $child_count;
public $child_count = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -144,4 +144,4 @@ class Category extends Model
];
}
}
}

View File

@ -60,126 +60,126 @@ class Chapter extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 父级编号
*
* @var int
*/
public $parent_id;
public $parent_id = 0;
/**
* 课程编号
*
* @var int
*/
public $course_id;
public $course_id = 0;
/**
* 标题
*
* @var string
*/
public $title;
public $title = '';
/**
* 摘要
*
* @var string
*/
public $summary;
public $summary = '';
/**
* 优先级
*
* @var int
*/
public $priority;
public $priority = 0;
/**
* 免费标识
*
* @var int
*/
public $free;
public $free = 0;
/**
* 模式类型
*
* @var int
*/
public $model;
public $model = 0;
/**
* 扩展属性
*
* @var string|array
*/
public $attrs;
public $attrs = '';
/**
* 发布标识
*
* @var int
*/
public $published;
public $published = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 资源数
*
* @var int
*/
public $resource_count;
public $resource_count = 0;
/**
* 课时数
*
* @var int
*/
public $lesson_count;
public $lesson_count = 0;
/**
* 学员数
*
* @var int
*/
public $user_count;
public $user_count = 0;
/**
* 咨询数
*
* @var int
*/
public $consult_count;
public $consult_count = 0;
/**
* 点赞数
*
* @var int
*/
public $like_count;
public $like_count = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -249,4 +249,4 @@ class Chapter extends Model
}
}
}
}

View File

@ -12,42 +12,42 @@ class ChapterLike extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 章节编号
*
* @var int
*/
public $chapter_id;
public $chapter_id = 0;
/**
* 用户编号
*
* @var int
*/
public $user_id;
public $user_id = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -76,4 +76,4 @@ class ChapterLike extends Model
$this->update_time = time();
}
}
}

View File

@ -17,63 +17,63 @@ class ChapterLive extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 课程编号
*
* @var int
*/
public $course_id;
public $course_id = 0;
/**
* 章节编号
*
* @var int
*/
public $chapter_id;
public $chapter_id = 0;
/**
* 开始时间
*
* @var int
*/
public $start_time;
public $start_time = 0;
/**
* 结束时间
*
* @var int
*/
public $end_time;
public $end_time = 0;
/**
* 用户限额
*
* @var int
*/
public $user_limit;
public $user_limit = 0;
/**
* 直播状态
*
* @var int
*/
public $status;
public $status = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -102,4 +102,4 @@ class ChapterLive extends Model
return str_replace('chapter_', '', $streamName);
}
}
}

View File

@ -10,42 +10,42 @@ class ChapterRead extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 课程编号
*
* @var int
*/
public $course_id;
public $course_id = 0;
/**
* 章节编号
*
* @var int
*/
public $chapter_id;
public $chapter_id = 0;
/**
* 内容
*
* @var string
*/
public $content;
public $content = '';
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -55,13 +55,6 @@ class ChapterRead extends Model
public function beforeCreate()
{
$this->create_time = time();
/**
* text类型不能自动填充默认值
*/
if (is_null($this->content)) {
$this->content = '';
}
}
public function beforeUpdate()
@ -69,4 +62,4 @@ class ChapterRead extends Model
$this->update_time = time();
}
}
}

View File

@ -12,84 +12,84 @@ class ChapterUser extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 课程编号
*
* @var int
*/
public $course_id;
public $course_id = 0;
/**
* 章节编号
*
* @var int
*/
public $chapter_id;
public $chapter_id = 0;
/**
* 用户编号
*
* @var int
*/
public $user_id;
public $user_id = 0;
/**
* 计划编号
*
* @var int
*/
public $plan_id;
public $plan_id = 0;
/**
* 学习时长
* 学习时长(秒)
*
* @var int
*/
public $duration;
public $duration = 0;
/**
* 播放位置
* 播放位置(秒)
*
* @var int
*/
public $position;
public $position = 0;
/**
* 学习进度
* 学习进度
*
* @var int
*/
public $progress;
public $progress = 0;
/**
* 消费标识
*
* @var int
*/
public $consumed;
public $consumed = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -118,4 +118,4 @@ class ChapterUser extends Model
$this->update_time = time();
}
}
}

View File

@ -12,49 +12,49 @@ class ChapterVod extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 课程编号
*
* @var int
*/
public $course_id;
public $course_id = 0;
/**
* 章节编号
*
* @var int
*/
public $chapter_id;
public $chapter_id = 0;
/**
* 文件编号
*
* @var string
*/
public $file_id;
public $file_id = '';
/**
* 文件转码
*
* @var string
* @var array|string
*/
public $file_transcode;
public $file_transcode = '';
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -104,4 +104,4 @@ class ChapterVod extends Model
return $transcode;
}
}
}

View File

@ -16,63 +16,63 @@ class Connect extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 用户编号
*
* @var int
*/
public $user_id;
public $user_id = 0;
/**
* 开放ID
*
* @var string
*/
public $open_id;
public $open_id = '';
/**
* 开放名称
*
* @var string
*/
public $open_name;
public $open_name = '';
/**
* 开放头像
*
* @var string
*/
public $open_avatar;
public $open_avatar = '';
/**
* 提供商
*
* @var int
*/
public $provider;
public $provider = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -101,4 +101,4 @@ class Connect extends Model
$this->update_time = time();
}
}
}

View File

@ -19,112 +19,112 @@ class Consult extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 课程编号
*
* @var int
*/
public $course_id;
public $course_id = 0;
/**
* 章节编号
*
* @var int
*/
public $chapter_id;
public $chapter_id = 0;
/**
* 提主编号
*
* @var int
*/
public $owner_id;
public $owner_id = 0;
/**
* 答主编号
*
* @var int
*/
public $replier_id;
public $replier_id = 0;
/**
* 提问
*
* @var string
*/
public $question;
public $question = '';
/**
* 回答
*
* @var string
*/
public $answer;
public $answer = '';
/**
* 评分
*
* @var int
*/
public $rating;
public $rating = 0;
/**
* 优先级
*
* @var int
*/
public $priority;
public $priority = 0;
/**
* 私密标识
*
* @var int
*/
public $private;
public $private = 0;
/**
* 发布标识
*
* @var int
*/
public $published;
public $published = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 赞成数
*
* @var int
*/
public $like_count;
public $like_count = 0;
/**
* 回复时间
*
* @var int
*/
public $reply_time;
public $reply_time = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -157,4 +157,4 @@ class Consult extends Model
$this->update_time = time();
}
}
}

View File

@ -12,42 +12,42 @@ class ConsultLike extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 咨询编号
*
* @var int
*/
public $consult_id;
public $consult_id = 0;
/**
* 用户编号
*
* @var int
*/
public $user_id;
public $user_id = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -76,4 +76,4 @@ class ConsultLike extends Model
$this->update_time = time();
}
}
}

View File

@ -52,203 +52,203 @@ class Course extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 标题
*
* @var string
*/
public $title;
public $title = '';
/**
* 封面
*
* @var string
*/
public $cover;
public $cover = '';
/**
* 简介
*
* @var string
*/
public $summary;
public $summary = '';
/**
* 关键字
*
* @var string
*/
public $keywords;
public $keywords = '';
/**
* 详情
*
* @var string
*/
public $details;
public $details = '';
/**
* 主分类编号
*
* @var int
*/
public $category_id;
public $category_id = 0;
/**
* 主教师编号
*
* @var int
*/
public $teacher_id;
public $teacher_id = 0;
/**
* 市场价格
*
* @var float
*/
public $market_price;
public $market_price = 0.00;
/**
* 会员价格
*
* @var float
*/
public $vip_price;
public $vip_price = 0.00;
/**
* 学习期限(月)
*
* @var int
*/
public $study_expiry;
public $study_expiry = 0;
/**
* 退款期限(天)
*
* @var int
*/
public $refund_expiry;
public $refund_expiry = 0;
/**
* 用户评价
*
* @var float
*/
public $rating;
public $rating = 0.00;
/**
* 综合得分
*
* @var float
*/
public $score;
public $score = 0.00;
/**
* 模式类型
*
* @var int
*/
public $model;
public $model = 0;
/**
* 难度级别
*
* @var int
*/
public $level;
public $level = 0;
/**
* 扩展属性
*
* @var string|array
*/
public $attrs;
public $attrs = '';
/**
* 推荐标识
*
* @var int
*/
public $featured;
public $featured = 0;
/**
* 发布标识
*
* @var int
*/
public $published;
public $published = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 资源数
*
* @var int
*/
public $resource_count;
public $resource_count = 0;
/**
* 学员数
*
* @var int
*/
public $user_count;
public $user_count = 0;
/**
* 课时数
*
* @var int
*/
public $lesson_count;
public $lesson_count = 0;
/**
* 套餐数
*
* @var int
*/
public $package_count;
public $package_count = 0;
/**
* 咨询数
*
* @var int
*/
public $consult_count;
public $consult_count = 0;
/**
* 评价数
*
* @var int
*/
public $review_count;
public $review_count = 0;
/**
* 收藏数
*
* @var int
*/
public $favorite_count;
public $favorite_count = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -291,13 +291,6 @@ class Course extends Model
$this->cover = self::getCoverPath($this->cover);
}
/**
* text类型不会自动填充默认值
*/
if (is_null($this->details)) {
$this->details = '';
}
$this->create_time = time();
}
@ -411,4 +404,4 @@ class Course extends Model
];
}
}
}

View File

@ -10,28 +10,28 @@ class CourseCategory extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 课程编号
*
* @var int
*/
public $course_id;
public $course_id = 0;
/**
* 分类编号
*
* @var int
*/
public $category_id;
public $category_id = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
public function getSource(): string
{
@ -43,4 +43,4 @@ class CourseCategory extends Model
$this->create_time = time();
}
}
}

View File

@ -12,42 +12,42 @@ class CourseFavorite extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 课程编号
*
* @var int
*/
public $course_id;
public $course_id = 0;
/**
* 用户编号
*
* @var int
*/
public $user_id;
public $user_id = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -76,4 +76,4 @@ class CourseFavorite extends Model
$this->update_time = time();
}
}
}

View File

@ -10,28 +10,28 @@ class CoursePackage extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 课程编号
*
* @var int
*/
public $course_id;
public $course_id = 0;
/**
* 套餐编号
*
* @var int
*/
public $package_id;
public $package_id = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
public function getSource(): string
{
@ -43,4 +43,4 @@ class CoursePackage extends Model
$this->create_time = time();
}
}
}

View File

@ -10,49 +10,49 @@ class CourseRating extends Model
*
* @var int
*/
public $course_id;
public $course_id = 0;
/**
* 综合评分
*
* @var float
*/
public $rating;
public $rating = 0.00;
/**
* 维度1评分
*
* @var float
*/
public $rating1;
public $rating1 = 0.00;
/**
* 维度2评分
*
* @var float
*/
public $rating2;
public $rating2 = 0.00;
/**
* 维度3评分
*
* @var float
*/
public $rating3;
public $rating3 = 0.00;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -69,4 +69,4 @@ class CourseRating extends Model
$this->update_time = time();
}
}
}

View File

@ -10,28 +10,28 @@ class CourseRelated extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 课程编号
*
* @var int
*/
public $course_id;
public $course_id = 0;
/**
* 相关编号
*
* @var int
*/
public $related_id;
public $related_id = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
public function getSource(): string
{
@ -43,4 +43,4 @@ class CourseRelated extends Model
$this->create_time = time();
}
}
}

View File

@ -10,28 +10,28 @@ class CourseTopic extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 课程编号
*
* @var int
*/
public $course_id;
public $course_id = 0;
/**
* 话题编号
*
* @var int
*/
public $topic_id;
public $topic_id = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
public function getSource(): string
{
@ -43,4 +43,4 @@ class CourseTopic extends Model
$this->create_time = time();
}
}
}

View File

@ -28,91 +28,91 @@ class CourseUser extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 课程编号
*
* @var int
*/
public $course_id;
public $course_id = 0;
/**
* 用户编号
*
* @var int
*/
public $user_id;
public $user_id = 0;
/**
* 计划编号
*
* @var int
*/
public $plan_id;
public $plan_id = 0;
/**
* 角色类型
*
* @var int
*/
public $role_type;
public $role_type = 0;
/**
* 来源类型
*
* @var int
*/
public $source_type;
public $source_type = 0;
/**
* 过期时间
*
* @var int
*/
public $expiry_time;
public $expiry_time = 0;
/**
* 学习时长
* 学习时长(秒)
*
* @var int
*/
public $duration;
public $duration = 0;
/**
* 学习进度
* 学习进度
*
* @var int
*/
public $progress;
public $progress = 0;
/**
* 评价标识
*
* @var int
*/
public $reviewed;
public $reviewed = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -158,7 +158,9 @@ class CourseUser extends Model
self::SOURCE_CHARGE => '付费',
self::SOURCE_VIP => '会员',
self::SOURCE_IMPORT => '导入',
self::SOURCE_POINT_REDEEM => '积分兑换',
self::SOURCE_LUCKY_REDEEM => '抽奖兑换',
];
}
}
}

View File

@ -34,91 +34,91 @@ class Danmu extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 课程编号
*
* @var int
*/
public $course_id;
public $course_id = 0;
/**
* 章节编号
*
* @var int
*/
public $chapter_id;
public $chapter_id = 0;
/**
* 用户编号
*
* @var int
*/
public $owner_id;
public $owner_id = 0;
/**
* 内容
*
* @var string
*/
public $text;
public $text = '';
/**
* 颜色
*
* @var string
*/
public $color;
public $color = 'white';
/**
* 字号
*
* @var int
*/
public $size;
public $size = 0;
/**
* 位置
*
* @var int
*/
public $position;
public $position = 0;
/**
* 时间轴
*
* @var int
*/
public $time;
public $time = 0;
/**
* 发布标识
*
* @var int
*/
public $published;
public $published = 1;
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -199,4 +199,4 @@ class Danmu extends Model
return $keys[$index];
}
}
}

View File

@ -13,63 +13,63 @@ class Help extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 分类编号
*
* @var int
*/
public $category_id;
public $category_id = 0;
/**
* 标题
*
* @var string
*/
public $title;
public $title = '';
/**
* 内容
*
* @var string
*/
public $content;
public $content = '';
/**
* 优先级
*
* @var int
*/
public $priority;
public $priority = 0;
/**
* 发布标识
*
* @var int
*/
public $published;
public $published = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -90,13 +90,6 @@ class Help extends Model
public function beforeCreate()
{
/**
* text类型不会自动填充默认值
*/
if (is_null($this->content)) {
$this->content = '';
}
$this->create_time = time();
}
@ -116,4 +109,4 @@ class Help extends Model
$cache->rebuild();
}
}
}

View File

@ -12,49 +12,49 @@ class ImFriendGroup extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 名称
*
* @var string
*/
public $name;
public $name = '';
/**
* 优先级
*
* @var int
*/
public $priority;
public $priority = 0;
/**
* 状态
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 成员数
*
* @var int
*/
public $user_count;
public $user_count = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -83,5 +83,4 @@ class ImFriendGroup extends Model
$this->update_time = time();
}
}
}

View File

@ -10,49 +10,49 @@ class ImFriendUser extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 用户编号
*
* @var int
*/
public $user_id;
public $user_id = 0;
/**
* 好友编号
*
* @var int
*/
public $friend_id;
public $friend_id = 0;
/**
* 分组编号
*
* @var int
*/
public $group_id;
public $group_id = 0;
/**
* 消息数量
*
* @var int
*/
public $msg_count;
public $msg_count = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -69,4 +69,4 @@ class ImFriendUser extends Model
$this->update_time = time();
}
}
}

View File

@ -22,91 +22,91 @@ class ImGroup extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 群主编号
*
* @var int
*/
public $owner_id;
public $owner_id = 0;
/**
* 课程编号
*
* @var int
*/
public $course_id;
public $course_id = 0;
/**
* 群组类型
*
* @var int
*/
public $type;
public $type = 0;
/**
* 名称
*
* @var string
*/
public $name;
public $name = '';
/**
* 图标
*
* @var string
*/
public $avatar;
public $avatar = '';
/**
* 简介
*
* @var string
*/
public $about;
public $about = '';
/**
* 发布状态
*
* @var int
*/
public $published;
public $published = 0;
/**
* 删除状态
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 成员数
*
* @var int
*/
public $user_count;
public $user_count = 0;
/**
* 消息数
*
* @var int
*/
public $msg_count;
public $msg_count = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -186,5 +186,4 @@ class ImGroup extends Model
];
}
}
}

View File

@ -10,42 +10,42 @@ class ImGroupUser extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 群组编号
*
* @var int
*/
public $group_id;
public $group_id = 0;
/**
* 用户编号
*
* @var int
*/
public $user_id;
public $user_id = 0;
/**
* 优先级
*
* @var int
*/
public $priority;
public $priority = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -62,5 +62,4 @@ class ImGroupUser extends Model
$this->update_time = time();
}
}
}

View File

@ -18,70 +18,70 @@ class ImMessage extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 对话编号
*
* @var string
*/
public $chat_id;
public $chat_id = '';
/**
* 发送方编号
*
* @var int
*/
public $sender_id;
public $sender_id = 0;
/**
* 接收方编号
*
* @var int
*/
public $receiver_id;
public $receiver_id = 0;
/**
* 接收方类型
*
* @var int
*/
public $receiver_type;
public $receiver_type = 0;
/**
* 内容
*
* @var string
*/
public $content;
public $content = '';
/**
* 阅读标识
*
* @var int
*/
public $viewed;
public $viewed = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -123,4 +123,4 @@ class ImMessage extends Model
return implode('-', $list);
}
}
}

View File

@ -29,70 +29,70 @@ class ImNotice extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 发送方编号
*
* @var int
*/
public $sender_id;
public $sender_id = 0;
/**
* 接收方编号
*
* @var int
*/
public $receiver_id;
public $receiver_id = 0;
/**
* 条目类型
*
* @var int
*/
public $item_type;
public $item_type = 0;
/**
* 条目内容
*
* @var string
*/
public $item_info;
public $item_info = '';
/**
* 优先级
*
* @var int
*/
public $priority;
public $priority = 0;
/**
* 阅读标识
*
* @var int
*/
public $viewed;
public $viewed = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -136,4 +136,4 @@ class ImNotice extends Model
}
}
}
}

View File

@ -21,77 +21,77 @@ class ImUser extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 名称
*
* @var string
*/
public $name;
public $name = '';
/**
* 头像
*
* @var string
*/
public $avatar;
public $avatar = '';
/**
* 签名
*
* @var string
*/
public $sign;
public $sign = '';
/**
* 皮肤
*
* @var string
*/
public $skin;
public $skin = '';
/**
* 状态
*
* @var string
*/
public $status;
public $status = 'none';
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 好友数
*
* @var int
*/
public $friend_count;
public $friend_count = 0;
/**
* 群组数
*
* @var int
*/
public $group_count;
public $group_count = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -146,4 +146,4 @@ class ImUser extends Model
return $url;
}
}
}

View File

@ -10,98 +10,98 @@ class Learning extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 请求编号
*
* @var string
*/
public $request_id;
public $request_id = '';
/**
* 课程编号
*
* @var int
*/
public $course_id;
public $course_id = 0;
/**
* 章节编号
*
* @var int
*/
public $chapter_id;
public $chapter_id = 0;
/**
* 用户编号
*
* @var int
*/
public $user_id;
public $user_id = 0;
/**
* 计划编号
*
* @var int
*/
public $plan_id;
public $plan_id = 0;
/**
* 持续时长
* 持续时长(秒)
*
* @var int
*/
public $duration;
public $duration = 0;
/**
* 播放位置
* 播放位置(秒)
*
* @var int
*/
public $position;
public $position = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 客户端类型
*
* @var int
*/
public $client_type;
public $client_type = 0;
/**
* 客户端IP
*
* @var string
*/
public $client_ip;
public $client_ip = '';
/**
* 活跃时间
*
* @var int
*/
public $active_time;
public $active_time = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -118,4 +118,4 @@ class Learning extends Model
$this->update_time = time();
}
}
}

View File

@ -24,98 +24,98 @@ class Nav extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 上级编号
*
* @var int
*/
public $parent_id;
public $parent_id = 0;
/**
* 层级
*
* @var int
*/
public $level;
public $level = 0;
/**
* 名称
*
* @var string
*/
public $name;
public $name = '';
/**
* 路径
*
* @var string
*/
public $path;
public $path = '';
/**
* 打开方式
*
* @var string
*/
public $target;
public $target = '';
/**
* 链接地址
*
* @var string
*/
public $url;
public $url = '';
/**
* 位置
*
* @var int
*/
public $position;
public $position = 1;
/**
* 优先级
*
* @var int
*/
public $priority;
public $priority = 0;
/**
* 发布标识
*
* @var int
*/
public $published;
public $published = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 节点数
*
* @var int
*/
public $child_count;
public $child_count = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -164,4 +164,4 @@ class Nav extends Model
];
}
}
}

View File

@ -10,49 +10,49 @@ class Online extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 用户编号
*
* @var int
*/
public $user_id;
public $user_id = 0;
/**
* 客户端类型
*
* @var int
*/
public $client_type;
public $client_type = 0;
/**
* 客户端IP
*
* @var string
*/
public $client_ip;
public $client_ip = '';
/**
* 活跃时间
*
* @var int
*/
public $active_time;
public $active_time = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -69,4 +69,4 @@ class Online extends Model
$this->update_time = time();
}
}
}

View File

@ -30,98 +30,98 @@ class Order extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 序号
*
* @var string
*/
public $sn;
public $sn = '';
/**
* 主题
*
* @var string
*/
public $subject;
public $subject = '';
/**
* 金额
*
* @var float
*/
public $amount;
public $amount = 0.00;
/**
* 用户编号
*
* @var int
*/
public $owner_id;
public $owner_id = 0;
/**
* 条目编号
*
* @var int
*/
public $item_id;
public $item_id = 0;
/**
* 条目类型
*
* @var int
*/
public $item_type;
public $item_type = 0;
/**
* 条目信息
*
* @var string|array
*/
public $item_info;
public $item_info = '';
/**
* 终端类型
*
* @var int
*/
public $client_type;
public $client_type = 0;
/**
* 终端IP
*
* @var string
*/
public $client_ip;
public $client_ip = '';
/**
* 状态类型
*
* @var int
*/
public $status;
public $status = self::STATUS_PENDING;
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -205,4 +205,4 @@ class Order extends Model
];
}
}
}

View File

@ -10,28 +10,28 @@ class OrderStatus extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 订单编号
*
* @var int
*/
public $order_id;
public $order_id = 0;
/**
* 状态类型
*
* @var int
*/
public $status;
public $status = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
public function getSource(): string
{
@ -43,4 +43,4 @@ class OrderStatus extends Model
$this->create_time = time();
}
}
}

View File

@ -13,70 +13,70 @@ class Package extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 标题
*
* @var string
*/
public $title;
public $title = '';
/**
* 简介
*
* @var string
*/
public $summary;
public $summary = '';
/**
* 市场价格
*
* @var float
*/
public $market_price;
public $market_price = 0.00;
/**
* 会员价格
*
* @var float
*/
public $vip_price;
public $vip_price = 0.00;
/**
* 课程数量
*
* @var int
*/
public $course_count;
public $course_count = 0;
/**
* 发布标识
*
* @var int
*/
public $published;
public $published = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -122,4 +122,4 @@ class Package extends Model
$this->vip_price = (float)$this->vip_price;
}
}
}

View File

@ -13,49 +13,49 @@ class Page extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 标题
*
* @var string
*/
public $title;
public $title = '';
/**
* 内容
*
* @var string
*/
public $content;
public $content = '';
/**
* 发布标识
*
* @var int
*/
public $published;
public $published = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -76,13 +76,6 @@ class Page extends Model
public function beforeCreate()
{
/**
* text类型不会自动填充默认值
*/
if (is_null($this->content)) {
$this->content = '';
}
$this->create_time = time();
}
@ -102,4 +95,4 @@ class Page extends Model
$cache->rebuild();
}
}
}

View File

@ -117,7 +117,14 @@ class PointGift extends Model
public $deleted = 0;
/**
* 兑换数
* 兑换限额
*
* @var int
*/
public $redeem_limit = 1;
/**
* 兑换数量
*
* @var int
*/
@ -232,4 +239,4 @@ class PointGift extends Model
];
}
}
}

View File

@ -15,9 +15,9 @@ class PointHistory extends Model
const EVENT_POINT_REFUND = 3; // 积分退款
const EVENT_ACCOUNT_REGISTER = 4; // 帐号注册
const EVENT_SITE_VISIT = 5; // 站点访问
const EVENT_LESSON_LEARNING = 6; // 课时学习
const EVENT_CHAPTER_STUDY = 6; // 课时学习
const EVENT_COURSE_REVIEW = 7; // 课程评价
const EVENT_GROUP_DISCUSS = 8; // 群组讨论
const EVENT_IM_DISCUSS = 8; // 微聊讨论
/**
* 主键编号
@ -108,6 +108,10 @@ class PointHistory extends Model
public function beforeCreate()
{
if (is_array($this->event_info) && !empty($this->event_info)) {
$this->event_info = kg_json_encode($this->event_info);
}
$this->create_time = time();
}
@ -116,6 +120,13 @@ class PointHistory extends Model
$this->update_time = time();
}
public function afterFetch()
{
if (is_string($this->event_info) && !empty($this->event_info)) {
$this->event_info = json_decode($this->event_info, true);
}
}
public static function eventTypes()
{
return [
@ -124,10 +135,10 @@ class PointHistory extends Model
self::EVENT_POINT_REFUND => '积分退款',
self::EVENT_ACCOUNT_REGISTER => '用户注册',
self::EVENT_SITE_VISIT => '用户登录',
self::EVENT_LESSON_LEARNING => '课时学习',
self::EVENT_CHAPTER_STUDY => '课时学习',
self::EVENT_COURSE_REVIEW => '课程评价',
self::EVENT_GROUP_DISCUSS => '群组讨论',
self::EVENT_IM_DISCUSS => '微聊讨论',
];
}
}
}

View File

@ -127,4 +127,4 @@ class PointRedeem extends Model
$this->update_time = time();
}
}
}

View File

@ -22,91 +22,91 @@ class Refund extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 用户编号
*
* @var int
*/
public $owner_id;
public $owner_id = 0;
/**
* 订单编号
*
* @var int
*/
public $order_id;
public $order_id = 0;
/**
* 交易编号
*
* @var int
*/
public $trade_id;
public $trade_id = 0;
/**
* 序号
*
* @var string
*/
public $sn;
public $sn = '';
/**
* 主题
*
* @var string
*/
public $subject;
public $subject = '';
/**
* 金额
*
* @var float
*/
public $amount;
public $amount = 0.00;
/**
* 状态类型
*
* @var int
*/
public $status;
public $status = self::STATUS_PENDING;
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 申请备注
*
* @var string
*/
public $apply_note;
public $apply_note = '';
/**
* 审核备注
*
* @var string
*/
public $review_note;
public $review_note = '';
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -129,6 +129,8 @@ class Refund extends Model
public function beforeCreate()
{
$this->status = self::STATUS_PENDING;
$this->sn = date('YmdHis') . rand(1000, 9999);
$this->create_time = time();
@ -166,4 +168,4 @@ class Refund extends Model
];
}
}
}

View File

@ -10,28 +10,28 @@ class RefundStatus extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 退款编号
*
* @var int
*/
public $refund_id;
public $refund_id = 0;
/**
* 状态类型
*
* @var int
*/
public $status;
public $status = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
public function getSource(): string
{
@ -43,4 +43,4 @@ class RefundStatus extends Model
$this->create_time = time();
}
}
}

View File

@ -10,42 +10,42 @@ class Resource extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 课程编号
*
* @var int
*/
public $course_id;
public $course_id = 0;
/**
* 章节编号
*
* @var int
*/
public $chapter_id;
public $chapter_id = 0;
/**
* 上传编号
*
* @var int
*/
public $upload_id;
public $upload_id = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -62,4 +62,4 @@ class Resource extends Model
$this->update_time = time();
}
}
}

View File

@ -12,105 +12,105 @@ class Review extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 课程编号
*
* @var int
*/
public $course_id;
public $course_id = 0;
/**
* 用户编号
*
* @var int
*/
public $owner_id;
public $owner_id = 0;
/**
* 评价内容
*
* @var string
*/
public $content;
public $content = '';
/**
* 回复内容
*
* @var string
*/
public $reply;
public $reply = '';
/**
* 综合评分
*
* @var float
*/
public $rating;
public $rating = 0.00;
/**
* 维度1评分
*
* @var float
*/
public $rating1;
public $rating1 = 0.00;
/**
* 维度2评分
*
* @var float
*/
public $rating2;
public $rating2 = 0.00;
/**
* 维度3评分
*
* @var float
*/
public $rating3;
public $rating3 = 0.00;
/**
* 匿名标识
*
* @var int
*/
public $anonymous;
public $anonymous = 0;
/**
* 发布标识
*
* @var int
*/
public $published;
public $published = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 点赞数量
*
* @var int
*/
public $like_count;
public $like_count = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -154,4 +154,4 @@ class Review extends Model
return round($sumRating / 3, 2);
}
}
}

View File

@ -12,42 +12,42 @@ class ReviewLike extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 评价编号
*
* @var int
*/
public $review_id;
public $review_id = 0;
/**
* 用户编号
*
* @var int
*/
public $user_id;
public $user_id = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -76,4 +76,4 @@ class ReviewLike extends Model
$this->update_time = time();
}
}
}

View File

@ -12,42 +12,42 @@ class Reward extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 标题
*
* @var string
*/
public $title;
public $title = '';
/**
* 价格
*
* @var float
*/
public $price;
public $price = 0.00;
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -81,4 +81,4 @@ class Reward extends Model
$this->price = (float)$this->price;
}
}
}

View File

@ -26,63 +26,63 @@ class Role extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 类型
*
* @var string
* @var int
*/
public $type;
public $type = self::TYPE_CUSTOM;
/**
* 名称
*
* @var string
*/
public $name;
public $name = '';
/**
* 简介
*
* @var string
*/
public $summary;
public $summary = '';
/**
* 权限路由
*
* @var string
* @var array|string
*/
public $routes;
public $routes = '';
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 成员数
*
* @var int
*/
public $user_count;
public $user_count = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -105,8 +105,6 @@ class Role extends Model
{
if (is_array($this->routes) && !empty($this->routes)) {
$this->routes = kg_json_encode($this->routes);
} else {
$this->routes = '';
}
$this->create_time = time();
@ -146,4 +144,4 @@ class Role extends Model
];
}
}
}

View File

@ -10,32 +10,32 @@ class Setting extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 配置块
*
* @var string
*/
public $section;
public $section = '';
/**
* 配置键
*
* @var string
*/
public $item_key;
public $item_key = '';
/**
* 配置值
*
* @var string
*/
public $item_value;
public $item_value = '';
public function getSource(): string
{
return 'kg_setting';
}
}
}

View File

@ -20,84 +20,84 @@ class Slide extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 标题
*
* @var string
*/
public $title;
public $title = '';
/**
* 封面
*
* @var string
*/
public $cover;
public $cover = '';
/**
* 摘要
*
* @var string
*/
public $summary;
public $summary = '';
/**
* 内容
*
* @var string
*/
public $content;
public $content = '';
/**
* 平台
*
* @var int
*/
public $platform;
public $platform = 0;
/**
* 目标
*
* @var int
*/
public $target;
public $target = 0;
/**
* 优先级
*
* @var int
*/
public $priority;
public $priority = 0;
/**
* 发布标识
*
* @var int
*/
public $published;
public $published = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -165,4 +165,4 @@ class Slide extends Model
];
}
}
}

View File

@ -10,8 +10,8 @@ class Task extends Model
*/
const TYPE_DELIVER = 1; // 发货
const TYPE_REFUND = 2; // 退款
const TYPE_POINT_GIFT_AWARD = 3; // 积分礼品派发
const TYPE_LUCKY_GIFT_AWARD = 4; // 抽奖礼品派发
const TYPE_POINT_GIFT_DELIVER = 3; // 积分礼品派发
const TYPE_LUCKY_GIFT_DELIVER = 4; // 抽奖礼品派发
const TYPE_NOTICE_ACCOUNT_LOGIN = 11; // 帐号登录通知
const TYPE_NOTICE_LIVE_BEGIN = 12; // 直播开始通知
@ -39,63 +39,63 @@ class Task extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 条目编号
*
* @var int
*/
public $item_id;
public $item_id = 0;
/**
* 条目类型
*
* @var int
*/
public $item_type;
public $item_type = 0;
/**
* 条目内容
*
* @var string|array
*/
public $item_info;
public $item_info = '';
/**
* 优先级
*
* @var int
*/
public $priority;
public $priority = self::PRIORITY_LOW;
/**
* 状态标识
*
* @var int
*/
public $status;
public $status = self::STATUS_PENDING;
/**
* 重试次数
*
* @var int
*/
public $try_count;
public $try_count = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -129,4 +129,4 @@ class Task extends Model
}
}
}
}

View File

@ -13,56 +13,56 @@ class Topic extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 标题
*
* @var string
*/
public $title;
public $title = '';
/**
* 简介
*
* @var string
*/
public $summary;
public $summary = '';
/**
* 课程数量
*
* @var int
*/
public $course_count;
public $course_count = 0;
/**
* 发布标识
*
* @var int
*/
public $published;
public $published = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -102,4 +102,4 @@ class Topic extends Model
$cache->rebuild();
}
}
}

View File

@ -26,84 +26,84 @@ class Trade extends Model
*
* @var int
*/
public $id;
public $id = 0;
/**
* 用户编号
*
* @var int
*/
public $owner_id;
public $owner_id = 0;
/**
* 订单编号
*
* @var int
*/
public $order_id;
public $order_id = 0;
/**
* 商户流水号
*
* @var string
*/
public $sn;
public $sn = '';
/**
* 主题
*
* @var string
*/
public $subject;
public $subject = '';
/**
* 金额
*
* @var float
*/
public $amount;
public $amount = 0.00;
/**
* 平台类型
*
* @var int
*/
public $channel;
public $channel = 0;
/**
* 平台流水号
*
* @var string
*/
public $channel_sn;
public $channel_sn = '';
/**
* 状态类型
*
* @var int
*/
public $status;
public $status = self::STATUS_PENDING;
/**
* 删除标识
*
* @var int
*/
public $deleted;
public $deleted = 0;
/**
* 创建时间
*
* @var int
*/
public $create_time;
public $create_time = 0;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public $update_time = 0;
public function getSource(): string
{
@ -171,4 +171,4 @@ class Trade extends Model
];
}
}
}

Some files were not shown because too many files have changed in this diff Show More