1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-26 12:23:06 +08:00

Merge branch 'koogua/I399X5' into demo

# Conflicts:
#	app/Services/Auth/Api.php
#	app/Services/Auth/Home.php
This commit is contained in:
koogua 2021-03-03 18:07:51 +08:00
commit 599e54f745
109 changed files with 1020 additions and 759 deletions

View File

@ -15,7 +15,7 @@ class CleanLogTask extends Task
$this->cleanSqlLog();
$this->cleanListenLog();
$this->cleanCaptchaLog();
$this->cleanWechatLog();
$this->cleanWeChatLog();
$this->cleanMailLog();
$this->cleanSmsLog();
$this->cleanVodLog();
@ -166,7 +166,7 @@ class CleanLogTask extends Task
/**
* 清理微信服务日志
*/
protected function cleanWechatLog()
protected function cleanWeChatLog()
{
$type = 'wechat';

View File

@ -176,8 +176,6 @@ class DeliverTask extends Task
if ($groupUser->create() === false) {
throw new \RuntimeException('Create Group User Failed');
}
continue;
}
}
}

View File

@ -3,14 +3,15 @@
namespace App\Console\Tasks;
use App\Models\Task as TaskModel;
use App\Services\DingTalk\Notice\ConsultCreate as ConsultCreateNotice;
use App\Services\DingTalk\Notice\CustomService as CustomServiceNotice;
use App\Services\DingTalk\Notice\ServerMonitor as ServerMonitorNotice;
use App\Services\DingTalk\Notice\TeacherLive as TeacherLiveNotice;
use App\Services\Logic\Notice\AccountLogin as AccountLoginNotice;
use App\Services\Logic\Notice\ConsultReply as ConsultReplyNotice;
use App\Services\Logic\Notice\DingTalk\ConsultCreate as ConsultCreateNotice;
use App\Services\Logic\Notice\DingTalk\CustomService as CustomServiceNotice;
use App\Services\Logic\Notice\DingTalk\ServerMonitor as ServerMonitorNotice;
use App\Services\Logic\Notice\DingTalk\TeacherLive as TeacherLiveNotice;
use App\Services\Logic\Notice\LiveBegin as LiveBeginNotice;
use App\Services\Logic\Notice\OrderFinish as OrderFinishNotice;
use App\Services\Logic\Notice\PointGoodsDeliver as PointGoodsDeliverNotice;
use App\Services\Logic\Notice\RefundFinish as RefundFinishNotice;
use Phalcon\Mvc\Model\Resultset;
use Phalcon\Mvc\Model\ResultsetInterface;
@ -24,9 +25,7 @@ class NoticeTask extends Task
$tasks = $this->findTasks(300);
if ($tasks->count() == 0) {
return;
}
if ($tasks->count() == 0) return;
foreach ($tasks as $task) {
@ -48,6 +47,9 @@ class NoticeTask extends Task
case TaskModel::TYPE_NOTICE_CONSULT_REPLY:
$this->handleConsultReplyNotice($task);
break;
case TaskModel::TYPE_NOTICE_POINT_GOODS_DELIVER:
$this->handlePointGoodsDeliverNotice($task);
break;
case TaskModel::TYPE_NOTICE_CONSULT_CREATE:
$this->handleConsultCreateNotice($task);
break;
@ -122,6 +124,13 @@ class NoticeTask extends Task
$notice->handleTask($task);
}
protected function handlePointGoodsDeliverNotice(TaskModel $task)
{
$notice = new PointGoodsDeliverNotice();
$notice->handleTask($task);
}
protected function handleConsultCreateNotice(TaskModel $task)
{
$notice = new ConsultCreateNotice();
@ -162,6 +171,8 @@ class NoticeTask extends Task
TaskModel::TYPE_NOTICE_ORDER_FINISH,
TaskModel::TYPE_NOTICE_REFUND_FINISH,
TaskModel::TYPE_NOTICE_CONSULT_REPLY,
TaskModel::TYPE_NOTICE_POINT_GOODS_DELIVER,
TaskModel::TYPE_NOTICE_LUCKY_GOODS_DELIVER,
TaskModel::TYPE_NOTICE_CONSULT_CREATE,
TaskModel::TYPE_NOTICE_TEACHER_LIVE,
TaskModel::TYPE_NOTICE_SERVER_MONITOR,

View File

@ -5,17 +5,47 @@ namespace App\Console\Tasks;
use App\Models\ImMessage as ImMessageModel;
use App\Models\Learning as LearningModel;
use App\Models\Task as TaskModel;
use App\Models\UserSession as UserSessionModel;
use App\Models\UserToken as UserTokenModel;
class OptimizeTableTask extends Task
{
public function mainAction()
{
$this->optimizeUserSessionTable();
$this->optimizeUserTokenTable();
$this->optimizeImMessageTable();
$this->optimizeLearningTable();
$this->optimizeTaskTable();
}
protected function optimizeUserSessionTable()
{
$sessionModel = new UserSessionModel();
$tableName = $sessionModel->getSource();
$this->db->delete($tableName, "expire_time < :expire_time", [
'expire_time' => strtotime('-3 days'),
]);
$this->db->execute("OPTIMIZE TABLE {$tableName}");
}
protected function optimizeUserTokenTable()
{
$tokenModel = new UserTokenModel();
$tableName = $tokenModel->getSource();
$this->db->delete($tableName, "expire_time < :expire_time", [
'expire_time' => strtotime('-3 days'),
]);
$this->db->execute("OPTIMIZE TABLE {$tableName}");
}
protected function optimizeImMessageTable()
{
$count = ImMessageModel::count();

View File

@ -13,7 +13,7 @@ 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\DingTalk\Notice\PointRedeem as PointRedeemNotice;
use App\Services\Logic\Notice\DingTalk\PointRedeem as PointRedeemNotice;
use App\Services\Logic\Point\PointHistory as PointHistoryService;
use Phalcon\Mvc\Model\Resultset;
use Phalcon\Mvc\Model\ResultsetInterface;
@ -181,11 +181,6 @@ class PointGiftDeliverTask extends Task
$service->handlePointRefund($redeem);
}
protected function handleRedeemFinishNotice(PointRedeemModel $redeem)
{
}
/**
* @param int $limit
* @return ResultsetInterface|Resultset|TaskModel[]

View File

@ -6,7 +6,9 @@ use App\Models\Order as OrderModel;
use App\Models\Refund as RefundModel;
use App\Models\Task as TaskModel;
use App\Models\Trade as TradeModel;
use App\Repos\Course as CourseRepo;
use App\Repos\CourseUser as CourseUserRepo;
use App\Repos\ImGroupUser as ImGroupUserRepo;
use App\Repos\Order as OrderRepo;
use App\Repos\Refund as RefundRepo;
use App\Repos\Trade as TradeRepo;
@ -172,17 +174,26 @@ class RefundTask extends Task
protected function handleCourseOrderRefund(OrderModel $order)
{
$courseUserRepo = new CourseUserRepo();
$courseUser = $courseUserRepo->findCourseStudent($order->item_id, $order->owner_id);
if ($courseUser) {
$courseUser->deleted = 1;
if ($courseUser->update() === false) {
throw new \RuntimeException('Delete Course User Failed');
}
}
$courseRepo = new CourseRepo();
$group = $courseRepo->findImGroup($order->item_id);
$groupUserRepo = new ImGroupUserRepo();
$groupUser = $groupUserRepo->findGroupUser($group->id, $order->owner_id);
if ($groupUser) {
if ($groupUser->delete() === false) {
throw new \RuntimeException('Delete Group User Failed');
}
}
}
/**
@ -193,6 +204,8 @@ class RefundTask extends Task
protected function handlePackageOrderRefund(OrderModel $order)
{
$courseUserRepo = new CourseUserRepo();
$groupUserRepo = new ImGroupUserRepo();
$courseRepo = new CourseRepo();
$itemInfo = $order->item_info;
@ -201,13 +214,20 @@ class RefundTask extends Task
$courseUser = $courseUserRepo->findCourseStudent($course['id'], $order->owner_id);
if ($courseUser) {
$courseUser->deleted = 1;
if ($courseUser->update() === false) {
throw new \RuntimeException('Delete Course User Failed');
}
}
$group = $courseRepo->findImGroup($course['id']);
$groupUser = $groupUserRepo->findGroupUser($group->id, $order->owner_id);
if ($groupUser) {
if ($groupUser->delete() === false) {
throw new \RuntimeException('Delete Group User Failed');
}
}
}
}

View File

@ -4,7 +4,7 @@ namespace App\Console\Tasks;
use App\Library\Benchmark;
use App\Models\User as UserModel;
use App\Services\DingTalk\Notice\ServerMonitor as ServerMonitorNotice;
use App\Services\Logic\Notice\DingTalk\ServerMonitor as ServerMonitorNotice;
use App\Services\Search\UserSearcher;
use GatewayClient\Gateway;

View File

@ -4,7 +4,7 @@ namespace App\Console\Tasks;
use App\Models\ChapterLive as ChapterLiveModel;
use App\Repos\ChapterLive as ChapterLiveRepo;
use App\Services\DingTalk\Notice\TeacherLive as TeacherLiveNotice;
use App\Services\Logic\Notice\DingTalk\TeacherLive as TeacherLiveNotice;
use Phalcon\Mvc\Model\Resultset;
use Phalcon\Mvc\Model\ResultsetInterface;

View File

@ -365,13 +365,13 @@ class SettingController extends Controller
$data = $this->request->getPost();
$settingService->updateWechatOASettings($section, $data);
$settingService->updateWeChatOASettings($section, $data);
return $this->jsonSuccess(['msg' => '更新配置成功']);
} else {
$oa = $settingService->getWechatOASettings();
$oa = $settingService->getWeChatOASettings();
$this->view->pick('setting/wechat_oa');
$this->view->setVar('oa', $oa);

View File

@ -8,11 +8,11 @@ use App\Http\Admin\Services\WxpayTest as WxpayTestService;
use App\Services\Captcha as CaptchaService;
use App\Services\DingTalkNotice as DingTalkNoticeService;
use App\Services\Live as LiveService;
use App\Services\Mail\Test as TestMailService;
use App\Services\Logic\Notice\Mail\Test as MailTestService;
use App\Services\Logic\Notice\Sms\Test as SmsTestService;
use App\Services\MyStorage as StorageService;
use App\Services\Sms\Test as TestSmsService;
use App\Services\Vod as VodService;
use App\Services\Wechat as WechatService;
use App\Services\WeChat as WeChatService;
/**
* @RoutePrefix("/admin/test")
@ -61,7 +61,7 @@ class TestController extends Controller
*/
public function wechatOaAction()
{
$wechatService = new WechatService();
$wechatService = new WeChatService();
$oa = $wechatService->getOfficialAccount();
@ -122,7 +122,7 @@ class TestController extends Controller
{
$phone = $this->request->getPost('phone', 'string');
$smsService = new TestSmsService();
$smsService = new SmsTestService();
$response = $smsService->handle($phone);
@ -140,7 +140,7 @@ class TestController extends Controller
{
$email = $this->request->getPost('email', 'string');
$mailService = new TestMailService();
$mailService = new MailTestService();
$result = $mailService->handle($email);

View File

@ -794,6 +794,12 @@ class AuthNode extends Service
'type' => 'menu',
'route' => 'admin.setting.vip',
],
[
'id' => '5-1-14',
'title' => '积分设置',
'type' => 'menu',
'route' => 'admin.setting.point',
],
[
'id' => '5-1-11',
'title' => '微聊设置',
@ -818,12 +824,6 @@ class AuthNode extends Service
'type' => 'menu',
'route' => 'admin.setting.dingtalk_robot',
],
[
'id' => '5-1-14',
'title' => '积分设置',
'type' => 'menu',
'route' => 'admin.setting.point',
],
],
],
],

View File

@ -6,6 +6,7 @@ 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\Services\Logic\Notice\PointGoodsDeliver as PointGoodsDeliverNotice;
use App\Validators\PointRedeem as PointRedeemValidator;
class PointRedeem extends Service
@ -17,8 +18,6 @@ class PointRedeem extends Service
$params = $pagerQuery->getParams();
$params['deleted'] = $params['deleted'] ?? 0;
$sort = $pagerQuery->getSort();
$page = $pagerQuery->getPage();
$limit = $pagerQuery->getLimit();
@ -45,9 +44,18 @@ class PointRedeem extends Service
$redeem->update();
$this->handleGoodsDeliverNotice($redeem);
return $redeem;
}
protected function handleGoodsDeliverNotice(PointRedeemModel $redeem)
{
$notice = new PointGoodsDeliverNotice();
$notice->createTask($redeem);
}
protected function findOrFail($id)
{
$validator = new PointRedeemValidator();

View File

@ -5,7 +5,7 @@ namespace App\Http\Admin\Services;
use App\Caches\Setting as SettingCache;
use App\Repos\Setting as SettingRepo;
use App\Repos\Vip as VipRepo;
use App\Services\Wechat as WechatService;
use App\Services\WeChat as WeChatService;
class Setting extends Service
{
@ -58,7 +58,7 @@ class Setting extends Service
return $wxpay;
}
public function getWechatOASettings()
public function getWeChatOASettings()
{
$oa = $this->getSettings('wechat.oa');
@ -215,7 +215,7 @@ class Setting extends Service
}
}
public function updateWechatOASettings($section, $settings)
public function updateWeChatOASettings($section, $settings)
{
if (!empty($settings['notice_template'])) {
$settings['notice_template'] = kg_json_encode($settings['notice_template']);
@ -242,7 +242,7 @@ class Setting extends Service
}
if (!empty($buttons)) {
$service = new WechatService();
$service = new WeChatService();
$oa = $service->getOfficialAccount();
$oa->menu->create($buttons);
}

View File

@ -45,7 +45,6 @@ class Student extends Service
$params = $pagerQuery->getParams();
$params['role_type'] = CourseUserModel::ROLE_STUDENT;
$params['deleted'] = $params['deleted'] ?? 0;
$sort = $pagerQuery->getSort();
$page = $pagerQuery->getPage();

View File

@ -55,7 +55,7 @@
{% set restore_url = url({'for':'admin.consult.restore','id':item.id}) %}
<tr>
<td>
<p>课程:<a href="{{ list_by_course_url }}">{{ item.course.title }}</a>{{ private_info(item.private) }}</p>
<p>课程:<a href="{{ list_by_course_url }}">{{ item.course.title }}</a>{{ item.course.id }}{{ private_info(item.private) }}</p>
<p class="layui-elip kg-item-elip" title="{{ item.question }}">提问:{{ item.question }}</p>
<p class="layui-elip kg-item-elip" title="{{ item.answer }}">回复:{{ item.answer }}</p>
</td>

View File

@ -65,7 +65,8 @@
<table class="layui-table kg-table layui-form">
<colgroup>
<col width="50%">
<col width="5%">
<col width="45%">
<col>
<col>
<col>
@ -75,6 +76,7 @@
</colgroup>
<thead>
<tr>
<th>编号</th>
<th>课程</th>
<th>课时数</th>
<th>用户数</th>
@ -96,6 +98,7 @@
{% set review_url = url({'for':'admin.review.list'},{'course_id':item.id}) %}
{% set consult_url = url({'for':'admin.consult.list'},{'course_id':item.id}) %}
<tr>
<td>{{ item.id }}</td>
<td>
<p>标题:<a href="{{ catalog_url }}">{{ item.title }}</a> {{ model_info(item.model) }}</p>
<p>{{ category_info(item.category) }}&nbsp;&nbsp;{{ teacher_info(item.teacher) }}&nbsp;&nbsp;{{ level_info(item.level) }}</p>

View File

@ -21,7 +21,7 @@
<table class="layui-table" lay-size="lg">
<colgroup>
<col>
<col width="15%">
<col>
<col>
<col>

View File

@ -48,7 +48,7 @@
{% set restore_url = url({'for':'admin.review.restore','id':item.id}) %}
<tr>
<td>
<p>课程:<a href="{{ list_by_course_url }}">{{ item.course.title }}</a></p>
<p>课程:<a href="{{ list_by_course_url }}">{{ item.course.title }}</a>{{ item.course.id }}</p>
<p class="layui-elip kg-item-elip" title="{{ item.content }}">评价:{{ item.content }}</p>
<p>时间:{{ date('Y-m-d H:i:s',item.create_time) }}</p>
</td>

View File

@ -38,64 +38,64 @@
</fieldset>
<table class="layui-table kg-table layui-form" style="width:60%;">
<colgroup>
<col width="15%">
<col>
<col width="20%">
<col width="20%">
<col>
<col>
</colgroup>
<thead>
<tr>
<th>行为类型</th>
<th>启用规则</th>
<th>奖励积分</th>
<th>每日上限</th>
<th>启用规则</th>
</tr>
</thead>
<tbody>
<tr>
<td>帐号注册</td>
<td><input class="layui-input" type="text" name="event_rule[account_register][point]" value="{{ event_rule.account_register.point }}" lay-verify="required"></td>
<td>N/A</td>
<td>
<input type="radio" name="event_rule[account_register][enabled]" value="1" title="是" {% if event_rule.account_register.enabled == "1" %}checked="checked"{% endif %}>
<input type="radio" name="event_rule[account_register][enabled]" value="0" title="否" {% if event_rule.account_register.enabled == "0" %}checked="checked"{% endif %}>
</td>
<td><input class="layui-input" type="text" name="event_rule[account_register][point]" value="{{ event_rule.account_register.point }}" lay-verify="required"></td>
<td>N/A</td>
</tr>
<tr>
<td>站点访问</td>
<td><input class="layui-input" type="text" name="event_rule[site_visit][point]" value="{{ event_rule.site_visit.point }}" lay-verify="required"></td>
<td>N/A</td>
<td>
<input type="radio" name="event_rule[site_visit][enabled]" value="1" title="是" {% if event_rule.site_visit.enabled == "1" %}checked="checked"{% endif %}>
<input type="radio" name="event_rule[site_visit][enabled]" value="0" title="否" {% if event_rule.site_visit.enabled == "0" %}checked="checked"{% endif %}>
</td>
<td><input class="layui-input" type="text" name="event_rule[site_visit][point]" value="{{ event_rule.site_visit.point }}" lay-verify="required"></td>
<td>N/A</td>
</tr>
<tr>
<td>课程评价</td>
<td><input class="layui-input" type="text" name="event_rule[course_review][point]" value="{{ event_rule.course_review.point }}" lay-verify="required"></td>
<td>N/A</td>
<td>
<input type="radio" name="event_rule[course_review][enabled]" value="1" title="是" {% if event_rule.course_review.enabled == "1" %}checked="checked"{% endif %}>
<input type="radio" name="event_rule[course_review][enabled]" value="0" title="否" {% if event_rule.course_review.enabled == "0" %}checked="checked"{% endif %}>
</td>
<td><input class="layui-input" type="text" name="event_rule[course_review][point]" value="{{ event_rule.course_review.point }}" lay-verify="required"></td>
<td>N/A</td>
</tr>
<tr>
<td>课时学习</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[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>
<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>
</tr>
<tr>
<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[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>
<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>
</tr>
</tbody>
</table>

View File

@ -32,13 +32,15 @@
<table class="layui-table kg-table layui-form">
<colgroup>
<col width="12%">
<col width="15%">
<col width="12%">
<col width="12%">
<col>
<col width="10%">
</colgroup>
<thead>
<tr>
<th>名称</th>
<th>启用模板</th>
<th>模板编号</th>
<th>模板内容</th>
<th>操作</th>
@ -46,32 +48,62 @@
</thead>
<tbody>
<tr>
<td>身份验证</td>
<td><input class="layui-input" type="text" name="template[verify]" value="{{ template.verify }}" lay-verify="required"></td>
<td>用户身份验证</td>
<td>
<input type="radio" name="template[verify][enabled]" value="1" title="是" disabled="disabled" {% if template.verify.enabled == "1" %}checked="checked"{% endif %}>
<input type="radio" name="template[verify][enabled]" value="0" title="否" disabled="disabled" {% if template.verify.enabled == "0" %}checked="checked"{% endif %}>
</td>
<td><input class="layui-input" type="text" name="template[verify][id]" value="{{ template.verify.id }}" lay-verify="required"></td>
<td><input id="tc-verify" class="layui-input" type="text" value="验证码:{1}{2} 分钟内有效,如非本人操作请忽略。" readonly="readonly"></td>
<td><span class="kg-copy layui-btn" data-clipboard-target="#tc-verify">复制</span></td>
</tr>
<tr>
<td>订单通知</td>
<td><input class="layui-input" type="text" name="template[order_finish]" value="{{ template.order_finish }}" lay-verify="required"></td>
<td>购买成功通知</td>
<td>
<input type="radio" name="template[order_finish][enabled]" value="1" title="是" {% if template.order_finish.enabled == "1" %}checked="checked"{% endif %}>
<input type="radio" name="template[order_finish][enabled]" value="0" title="否" {% if template.order_finish.enabled == "0" %}checked="checked"{% endif %}>
</td>
<td><input class="layui-input" type="text" name="template[order_finish][id]" value="{{ template.order_finish.id }}" lay-verify="required"></td>
<td><input id="tc-order-finish" class="layui-input" type="text" value="下单成功,商品名称:{1},订单序号:{2},订单金额:¥{3}" readonly="readonly"></td>
<td><span class="kg-copy layui-btn" data-clipboard-target="#tc-order-finish">复制</span></td>
</tr>
<tr>
<td>退款通知</td>
<td><input class="layui-input" type="text" name="template[refund_finish]" value="{{ template.refund_finish }}" lay-verify="required"></td>
<td>商品发货通知</td>
<td>
<input type="radio" name="template[goods_deliver][enabled]" value="1" title="是" {% if template.goods_deliver.enabled == "1" %}checked="checked"{% endif %}>
<input type="radio" name="template[goods_deliver][enabled]" value="0" title="否" {% if template.goods_deliver.enabled == "0" %}checked="checked"{% endif %}>
</td>
<td><input class="layui-input" type="text" name="template[goods_deliver][id]" value="{{ template.goods_deliver.id }}" lay-verify="required"></td>
<td><input id="tc-order-finish" class="layui-input" type="text" value="发货成功,商品名称:{1},订单序号:{2},请注意查收。" readonly="readonly"></td>
<td><span class="kg-copy layui-btn" data-clipboard-target="#tc-goods-deliver">复制</span></td>
</tr>
<tr>
<td>退款成功通知</td>
<td>
<input type="radio" name="template[refund_finish][enabled]" value="1" title="是" {% if template.refund_finish.enabled == "1" %}checked="checked"{% endif %}>
<input type="radio" name="template[refund_finish][enabled]" value="0" title="否" {% if template.refund_finish.enabled == "0" %}checked="checked"{% endif %}>
</td>
<td><input class="layui-input" type="text" name="template[refund_finish][id]" value="{{ template.refund_finish.id }}" lay-verify="required"></td>
<td><input id="tc-refund-finish" class="layui-input" type="text" value="退款成功,商品名称:{1},退款序号:{2},退款金额:¥{3}" readonly="readonly"></td>
<td><span class="kg-copy layui-btn" data-clipboard-target="#tc-refund-finish">复制</span></td>
</tr>
<tr>
<td>直播提醒</td>
<td><input class="layui-input" type="text" name="template[live_begin]" value="{{ template.live_begin }}" lay-verify="required"></td>
<td>课程直播提醒</td>
<td>
<input type="radio" name="template[live_begin][enabled]" value="1" title="是" {% if template.live_begin.enabled == "1" %}checked="checked"{% endif %}>
<input type="radio" name="template[live_begin][enabled]" value="0" title="否" {% if template.live_begin.enabled == "0" %}checked="checked"{% endif %}>
</td>
<td><input class="layui-input" type="text" name="template[live_begin][id]" value="{{ template.live_begin.id }}" lay-verify="required"></td>
<td><input id="tc-live-begin" class="layui-input" type="text" value="直播预告,课程名称:{1},章节名称:{2},开播时间:{3}" readonly="readonly"></td>
<td><span class="kg-copy layui-btn" data-clipboard-target="#tc-live-begin">复制</span></td>
</tr>
<tr>
<td>咨询通知</td>
<td><input class="layui-input" type="text" name="template[consult_reply]" value="{{ template.consult_reply }}" lay-verify="required"></td>
<td>咨询回复通知</td>
<td>
<input type="radio" name="template[consult_reply][enabled]" value="1" title="是" {% if template.consult_reply.enabled == "1" %}checked="checked"{% endif %}>
<input type="radio" name="template[consult_reply][enabled]" value="0" title="否" {% if template.consult_reply.enabled == "0" %}checked="checked"{% endif %}>
</td>
<td><input class="layui-input" type="text" name="template[consult_reply][id]" value="{{ template.consult_reply.id }}" lay-verify="required"></td>
<td><input id="tc-consult-reply" class="layui-input" type="text" value="{1} 回复了你的咨询,课程名称:{2},请登录系统查看详情。" readonly="readonly"></td>
<td><span class="kg-copy layui-btn" data-clipboard-target="#tc-consult-reply">复制</span></td>
</tr>

View File

@ -3,35 +3,65 @@
<form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.setting.wechat_oa'}) }}">
<table class="layui-table kg-table layui-form">
<colgroup>
<col width="15%">
<col width="15%">
<col>
</colgroup>
<thead>
<tr>
<th>模板名称</th>
<th>启用模板</th>
<th>模板编号</th>
</tr>
</thead>
<tbody>
<tr>
<td>登录成功通知</td>
<td><input class="layui-input" type="text" name="notice_template[account_login]" value="{{ notice_template.account_login }}" lay-verify="required"></td>
<td>
<input type="radio" name="notice_template[account_login][enabled]" value="1" title="是" {% if notice_template.account_login.enabled == "1" %}checked="checked"{% endif %}>
<input type="radio" name="notice_template[account_login][enabled]" value="0" title="否" {% if notice_template.account_login.enabled == "0" %}checked="checked"{% endif %}>
</td>
<td><input class="layui-input" type="text" name="notice_template[account_login][id]" value="{{ notice_template.account_login.id }}" lay-verify="required"></td>
</tr>
<tr>
<td>购买成功提醒</td>
<td><input class="layui-input" type="text" name="notice_template[order_finish]" value="{{ notice_template.order_finish }}" lay-verify="required"></td>
<td>购买成功通知</td>
<td>
<input type="radio" name="notice_template[order_finish][enabled]" value="1" title="是" {% if notice_template.order_finish.enabled == "1" %}checked="checked"{% endif %}>
<input type="radio" name="notice_template[order_finish][enabled]" value="0" title="否" {% if notice_template.order_finish.enabled == "0" %}checked="checked"{% endif %}>
</td>
<td><input class="layui-input" type="text" name="notice_template[order_finish][id]" value="{{ notice_template.order_finish.id }}" lay-verify="required"></td>
</tr>
<tr>
<td>商品发货通知</td>
<td>
<input type="radio" name="notice_template[goods_deliver][enabled]" value="1" title="是" {% if notice_template.goods_deliver.enabled == "1" %}checked="checked"{% endif %}>
<input type="radio" name="notice_template[goods_deliver][enabled]" value="0" title="否" {% if notice_template.goods_deliver.enabled == "0" %}checked="checked"{% endif %}>
</td>
<td><input class="layui-input" type="text" name="notice_template[goods_deliver][id]" value="{{ notice_template.goods_deliver.id }}" lay-verify="required"></td>
</tr>
<tr>
<td>退款成功通知</td>
<td><input class="layui-input" type="text" name="notice_template[refund_finish]" value="{{ notice_template.refund_finish }}" lay-verify="required"></td>
<td>
<input type="radio" name="notice_template[refund_finish][enabled]" value="1" title="是" {% if notice_template.refund_finish.enabled == "1" %}checked="checked"{% endif %}>
<input type="radio" name="notice_template[refund_finish][enabled]" value="0" title="否" {% if notice_template.refund_finish.enabled == "0" %}checked="checked"{% endif %}>
</td>
<td><input class="layui-input" type="text" name="notice_template[refund_finish][id]" value="{{ notice_template.refund_finish.id }}" lay-verify="required"></td>
</tr>
<tr>
<td>课程直播提醒</td>
<td><input class="layui-input" type="text" name="notice_template[live_begin]" value="{{ notice_template.live_begin }}" lay-verify="required"></td>
<td>
<input type="radio" name="notice_template[live_begin][enabled]" value="1" title="是" {% if notice_template.live_begin.enabled == "1" %}checked="checked"{% endif %}>
<input type="radio" name="notice_template[live_begin][enabled]" value="0" title="否" {% if notice_template.live_begin.enabled == "0" %}checked="checked"{% endif %}>
</td>
<td><input class="layui-input" type="text" name="notice_template[live_begin][id]" value="{{ notice_template.live_begin.id }}" lay-verify="required"></td>
</tr>
<tr>
<td>咨询结果通知</td>
<td><input class="layui-input" type="text" name="notice_template[consult_reply]" value="{{ notice_template.consult_reply }}" lay-verify="required"></td>
<td>咨询回复通知</td>
<td>
<input type="radio" name="notice_template[consult_reply][enabled]" value="1" title="是" {% if notice_template.consult_reply.enabled == "1" %}checked="checked"{% endif %}>
<input type="radio" name="notice_template[consult_reply][enabled]" value="0" title="否" {% if notice_template.consult_reply.enabled == "0" %}checked="checked"{% endif %}>
</td>
<td><input class="layui-input" type="text" name="notice_template[consult_reply][id]" value="{{ notice_template.consult_reply.id }}" lay-verify="required"></td>
</tr>
</tbody>
</table>

View File

@ -75,8 +75,12 @@
</td>
<td>{{ source_type_info(item.source_type) }}</td>
<td>
<p>开始:{{ date('Y-m-d H:i',item.create_time) }}</p>
<p>结束:{{ date('Y-m-d H:i',item.expiry_time) }}</p>
{% if item.source_type in [1,3] %}
N/A
{% else %}
<p>开始:{{ date('Y-m-d H:i',item.create_time) }}</p>
<p>结束:{{ date('Y-m-d H:i',item.expiry_time) }}</p>
{% endif %}
</td>
<td class="center">
<div class="layui-dropdown">

View File

@ -123,7 +123,7 @@ class ConnectController extends Controller
return $this->response->redirect(['for' => 'home.uc.account']);
}
} else {
if ($connect && $connect->deleted == 0) {
if ($connect) {
$service->authLogin($connect);
return $this->response->redirect(['for' => 'home.index']);
}

View File

@ -2,7 +2,7 @@
namespace App\Http\Home\Controllers;
use App\Repos\WechatSubscribe as WechatSubscribeRepo;
use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
use App\Services\Logic\Account\OAuthProvider as OAuthProviderService;
use App\Services\Logic\User\Console\AccountInfo as AccountInfoService;
use App\Services\Logic\User\Console\ConnectDelete as ConnectDeleteService;
@ -259,7 +259,7 @@ class UserConsoleController extends Controller
*/
public function subscribeAction()
{
$subscribeRepo = new WechatSubscribeRepo();
$subscribeRepo = new WeChatSubscribeRepo();
$subscribe = $subscribeRepo->findByUserId($this->authUser->id);

View File

@ -2,13 +2,13 @@
namespace App\Http\Home\Controllers;
use App\Http\Home\Services\WechatOfficialAccount as WechatOAService;
use App\Http\Home\Services\WeChatOfficialAccount as WeChatOAService;
use App\Traits\Response as ResponseTrait;
/**
* @RoutePrefix("/wechat/oa")
*/
class WechatOfficialAccountController extends \Phalcon\Mvc\Controller
class WeChatOfficialAccountController extends \Phalcon\Mvc\Controller
{
use ResponseTrait;
@ -18,7 +18,7 @@ class WechatOfficialAccountController extends \Phalcon\Mvc\Controller
*/
public function subscribeStatusAction()
{
$service = new WechatOAService();
$service = new WeChatOAService();
$status = $service->getSubscribeStatus();
@ -30,7 +30,7 @@ class WechatOfficialAccountController extends \Phalcon\Mvc\Controller
*/
public function subscribeQrCodeAction()
{
$service = new WechatOAService();
$service = new WeChatOAService();
$qrcode = $service->createSubscribeQrCode();
@ -42,7 +42,7 @@ class WechatOfficialAccountController extends \Phalcon\Mvc\Controller
*/
public function verifyAction()
{
$service = new WechatOAService();
$service = new WeChatOAService();
$app = $service->getOfficialAccount();
@ -58,7 +58,7 @@ class WechatOfficialAccountController extends \Phalcon\Mvc\Controller
*/
public function notifyAction()
{
$service = new WechatOAService();
$service = new WeChatOAService();
$app = $service->getOfficialAccount();

View File

@ -195,10 +195,6 @@ class Connect extends Service
$connect->user_id = $user->id;
}
if ($connect->deleted == 1) {
$connect->deleted = 0;
}
$connect->update();
} else {

View File

@ -11,7 +11,7 @@ use App\Models\ImMessage as ImMessageModel;
use App\Repos\ImFriendUser as ImFriendUserRepo;
use App\Repos\ImMessage as ImMessageRepo;
use App\Repos\ImUser as ImUserRepo;
use App\Services\DingTalk\Notice\CustomService as CustomServiceNotice;
use App\Services\Logic\Notice\DingTalk\CustomService as CustomServiceNotice;
use App\Validators\ImFriendUser as ImFriendUserValidator;
use App\Validators\ImGroup as ImGroupValidator;
use App\Validators\ImGroupUser as ImGroupUserValidator;

View File

@ -2,18 +2,18 @@
namespace App\Http\Home\Services;
use App\Models\WechatSubscribe as WechatSubscribeModel;
use App\Models\WeChatSubscribe as WeChatSubscribeModel;
use App\Repos\User as UserRepo;
use App\Repos\WechatSubscribe as WechatSubscribeRepo;
use App\Services\Wechat as WechatService;
use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
use App\Services\WeChat as WeChatService;
use EasyWeChat\Kernel\Messages\Text as TextMessage;
class WechatOfficialAccount extends Service
class WeChatOfficialAccount extends Service
{
public function getOfficialAccount()
{
$service = new WechatService();
$service = new WeChatService();
return $service->getOfficialAccount();
}
@ -33,24 +33,18 @@ class WechatOfficialAccount extends Service
{
$user = $this->getLoginUser();
$subscribeRepo = new WechatSubscribeRepo();
$subscribeRepo = new WeChatSubscribeRepo();
$subscribe = $subscribeRepo->findByUserId($user->id);
$status = 0;
if ($subscribe) {
$status = $subscribe->deleted == 0 ? 1 : 0;
}
return $status;
return $subscribe ? 1 : 0;
}
public function handleNotify($message)
{
$service = new WechatService();
$service = new WeChatService();
$service->logger->info('Received Message ' . json_encode($message));
$service->logger->debug('Received Message ' . json_encode($message));
switch ($message['MsgType']) {
case 'event':
@ -107,17 +101,6 @@ class WechatOfficialAccount extends Service
protected function handleSubscribeEvent($message)
{
$openId = $message['FromUserName'] ?? '';
$subscribeRepo = new WechatSubscribeRepo();
$subscribe = $subscribeRepo->findByOpenId($openId);
if ($subscribe && $subscribe->deleted == 1) {
$subscribe->deleted = 0;
$subscribe->update();
}
return new TextMessage('开心呀,我们又多了一个小伙伴!');
}
@ -125,13 +108,12 @@ class WechatOfficialAccount extends Service
{
$openId = $message['FromUserName'] ?? '';
$subscribeRepo = new WechatSubscribeRepo();
$subscribeRepo = new WeChatSubscribeRepo();
$subscribe = $subscribeRepo->findByOpenId($openId);
if ($subscribe && $subscribe->deleted == 0) {
$subscribe->deleted = 1;
$subscribe->update();
if ($subscribe) {
$subscribe->delete();
}
return new TextMessage('伤心呀,我们又少了一个小伙伴!');
@ -150,7 +132,7 @@ class WechatOfficialAccount extends Service
if (!$user) return;
$subscribeRepo = new WechatSubscribeRepo();
$subscribeRepo = new WeChatSubscribeRepo();
$subscribe = $subscribeRepo->findByOpenId($openId);
@ -158,16 +140,15 @@ class WechatOfficialAccount extends Service
if ($subscribe->user_id != $userId) {
$subscribe->user_id = $userId;
}
if ($subscribe->deleted == 1) {
$subscribe->deleted = 0;
}
$subscribe->update();
} else {
$subscribe = new WechatSubscribeModel();
$subscribe = new WeChatSubscribeModel();
$subscribe->user_id = $userId;
$subscribe->open_id = $openId;
$subscribe->create();
}
return $this->emptyReply();
}
protected function handleClickEvent($message)

View File

@ -2,8 +2,6 @@
namespace App\Models;
use Phalcon\Mvc\Model\Behavior\SoftDelete;
class ChapterLike extends Model
{
@ -28,13 +26,6 @@ class ChapterLike extends Model
*/
public $user_id = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted = 0;
/**
* 创建时间
*
@ -54,18 +45,6 @@ class ChapterLike extends Model
return 'kg_chapter_like';
}
public function initialize()
{
parent::initialize();
$this->addBehavior(
new SoftDelete([
'field' => 'deleted',
'value' => 1,
])
);
}
public function beforeCreate()
{
$this->create_time = time();

View File

@ -2,8 +2,6 @@
namespace App\Models;
use Phalcon\Mvc\Model\Behavior\SoftDelete;
class ChapterUser extends Model
{
@ -70,13 +68,6 @@ class ChapterUser extends Model
*/
public $consumed = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted = 0;
/**
* 创建时间
*
@ -96,18 +87,6 @@ class ChapterUser extends Model
return 'kg_chapter_user';
}
public function initialize()
{
parent::initialize();
$this->addBehavior(
new SoftDelete([
'field' => 'deleted',
'value' => 1,
])
);
}
public function beforeCreate()
{
$this->create_time = time();

View File

@ -2,8 +2,6 @@
namespace App\Models;
use Phalcon\Mvc\Model\Behavior\SoftDelete;
class Connect extends Model
{
@ -53,13 +51,6 @@ class Connect extends Model
*/
public $provider = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted = 0;
/**
* 创建时间
*
@ -79,18 +70,6 @@ class Connect extends Model
return 'kg_connect';
}
public function initialize()
{
parent::initialize();
$this->addBehavior(
new SoftDelete([
'field' => 'deleted',
'value' => 1,
])
);
}
public function beforeCreate()
{
$this->create_time = time();

View File

@ -2,8 +2,6 @@
namespace App\Models;
use Phalcon\Mvc\Model\Behavior\SoftDelete;
class ConsultLike extends Model
{
@ -28,13 +26,6 @@ class ConsultLike extends Model
*/
public $user_id = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted = 0;
/**
* 创建时间
*
@ -54,18 +45,6 @@ class ConsultLike extends Model
return 'kg_consult_like';
}
public function initialize()
{
parent::initialize();
$this->addBehavior(
new SoftDelete([
'field' => 'deleted',
'value' => 1,
])
);
}
public function beforeCreate()
{
$this->create_time = time();

View File

@ -2,8 +2,6 @@
namespace App\Models;
use Phalcon\Mvc\Model\Behavior\SoftDelete;
class CourseFavorite extends Model
{
@ -28,13 +26,6 @@ class CourseFavorite extends Model
*/
public $user_id = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted = 0;
/**
* 创建时间
*
@ -54,18 +45,6 @@ class CourseFavorite extends Model
return 'kg_course_favorite';
}
public function initialize()
{
parent::initialize();
$this->addBehavior(
new SoftDelete([
'field' => 'deleted',
'value' => 1,
])
);
}
public function beforeCreate()
{
$this->create_time = time();

View File

@ -2,8 +2,6 @@
namespace App\Models;
use Phalcon\Mvc\Model\Behavior\SoftDelete;
class CourseUser extends Model
{
@ -119,18 +117,6 @@ class CourseUser extends Model
return 'kg_course_user';
}
public function initialize()
{
parent::initialize();
$this->addBehavior(
new SoftDelete([
'field' => 'deleted',
'value' => 1,
])
);
}
public function beforeCreate()
{
$this->plan_id = (int)date('Ymd');

View File

@ -2,8 +2,6 @@
namespace App\Models;
use Phalcon\Mvc\Model\Behavior\SoftDelete;
class ImNotice extends Model
{
@ -59,13 +57,6 @@ class ImNotice extends Model
*/
public $item_info = '';
/**
* 优先级
*
* @var int
*/
public $priority = 0;
/**
* 阅读标识
*
@ -73,13 +64,6 @@ class ImNotice extends Model
*/
public $viewed = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted = 0;
/**
* 创建时间
*
@ -99,18 +83,6 @@ class ImNotice extends Model
return 'kg_im_notice';
}
public function initialize()
{
parent::initialize();
$this->addBehavior(
new SoftDelete([
'field' => 'deleted',
'value' => 1,
])
);
}
public function beforeCreate()
{
if (!empty($this->item_info)) {

View File

@ -61,13 +61,6 @@ class Learning extends Model
*/
public $position = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted = 0;
/**
* 客户端类型
*

View File

@ -2,8 +2,6 @@
namespace App\Models;
use Phalcon\Mvc\Model\Behavior\SoftDelete;
class PointHistory extends Model
{
@ -68,13 +66,6 @@ class PointHistory extends Model
*/
public $event_point = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted = 0;
/**
* 创建时间
*
@ -94,18 +85,6 @@ class PointHistory extends Model
return 'kg_point_history';
}
public function initialize()
{
parent::initialize();
$this->addBehavior(
new SoftDelete([
'field' => 'deleted',
'value' => 1,
])
);
}
public function beforeCreate()
{
if (is_array($this->event_info) && !empty($this->event_info)) {

View File

@ -2,8 +2,6 @@
namespace App\Models;
use Phalcon\Mvc\Model\Behavior\SoftDelete;
class ReviewLike extends Model
{
@ -28,13 +26,6 @@ class ReviewLike extends Model
*/
public $user_id = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted = 0;
/**
* 创建时间
*
@ -54,18 +45,6 @@ class ReviewLike extends Model
return 'kg_review_like';
}
public function initialize()
{
parent::initialize();
$this->addBehavior(
new SoftDelete([
'field' => 'deleted',
'value' => 1,
])
);
}
public function beforeCreate()
{
$this->create_time = time();

View File

@ -21,6 +21,8 @@ class Task extends Model
const TYPE_NOTICE_ORDER_FINISH = 13; // 订单完成通知
const TYPE_NOTICE_REFUND_FINISH = 14; // 退款完成通知
const TYPE_NOTICE_CONSULT_REPLY = 15; // 咨询回复通知
const TYPE_NOTICE_POINT_GOODS_DELIVER = 16; // 积分商品发货通知
const TYPE_NOTICE_LUCKY_GOODS_DELIVER = 17; // 中奖商品发货通知
/**
* 针对内部人员

View File

@ -2,8 +2,6 @@
namespace App\Models;
use Phalcon\Mvc\Model\Behavior\SoftDelete;
class UserBalance extends Model
{
@ -28,13 +26,6 @@ class UserBalance extends Model
*/
public $point = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted = 0;
/**
* 创建时间
*
@ -54,18 +45,6 @@ class UserBalance extends Model
return 'kg_user_balance';
}
public function initialize()
{
parent::initialize();
$this->addBehavior(
new SoftDelete([
'field' => 'deleted',
'value' => 1,
])
);
}
public function beforeCreate()
{
$this->create_time = time();

View File

@ -2,9 +2,6 @@
namespace App\Models;
use Phalcon\Mvc\Model\Behavior\SoftDelete;
class UserContact extends Model
{
@ -57,13 +54,6 @@ class UserContact extends Model
*/
public $add_other = '';
/**
* 删除标识
*
* @var int
*/
public $deleted = 0;
/**
* 创建时间
*
@ -83,18 +73,6 @@ class UserContact extends Model
return 'kg_user_contact';
}
public function initialize()
{
parent::initialize();
$this->addBehavior(
new SoftDelete([
'field' => 'deleted',
'value' => 1,
])
);
}
public function beforeSave()
{
if (empty($this->create_time)) {

View File

@ -2,8 +2,6 @@
namespace App\Models;
use Phalcon\Mvc\Model\Behavior\SoftDelete;
class UserSession extends Model
{
@ -43,11 +41,11 @@ class UserSession extends Model
public $client_ip = '';
/**
* 删除标识
* 过期时间
*
* @var int
*/
public $deleted = 0;
public $expire_time = 0;
/**
* 创建时间
@ -68,18 +66,6 @@ class UserSession extends Model
return 'kg_user_session';
}
public function initialize()
{
parent::initialize();
$this->addBehavior(
new SoftDelete([
'field' => 'deleted',
'value' => 1,
])
);
}
public function beforeCreate()
{
$this->create_time = time();

View File

@ -2,8 +2,6 @@
namespace App\Models;
use Phalcon\Mvc\Model\Behavior\SoftDelete;
class UserToken extends Model
{
@ -43,11 +41,11 @@ class UserToken extends Model
public $client_ip = '';
/**
* 删除标识
* 过期时间
*
* @var int
*/
public $deleted = 0;
public $expire_time = 0;
/**
* 创建时间
@ -68,18 +66,6 @@ class UserToken extends Model
return 'kg_user_token';
}
public function initialize()
{
parent::initialize();
$this->addBehavior(
new SoftDelete([
'field' => 'deleted',
'value' => 1,
])
);
}
public function beforeCreate()
{
$this->create_time = time();

View File

@ -2,9 +2,7 @@
namespace App\Models;
use Phalcon\Mvc\Model\Behavior\SoftDelete;
class WechatSubscribe extends Model
class WeChatSubscribe extends Model
{
/**
@ -28,13 +26,6 @@ class WechatSubscribe extends Model
*/
public $open_id = '';
/**
* 删除标识
*
* @var int
*/
public $deleted = 0;
/**
* 创建时间
*
@ -54,18 +45,6 @@ class WechatSubscribe extends Model
return 'kg_wechat_subscribe';
}
public function initialize()
{
parent::initialize();
$this->addBehavior(
new SoftDelete([
'field' => 'deleted',
'value' => 1,
])
);
}
public function beforeCreate()
{
$this->create_time = time();

View File

@ -150,7 +150,7 @@ class Chapter extends Repository
public function countUsers($chapterId)
{
return (int)ChapterUserModel::count([
'conditions' => 'chapter_id = :chapter_id: AND deleted = 0',
'conditions' => 'chapter_id = :chapter_id:',
'bind' => ['chapter_id' => $chapterId],
]);
}
@ -158,7 +158,7 @@ class Chapter extends Repository
public function countLikes($chapterId)
{
return (int)ChapterLikeModel::count([
'conditions' => 'chapter_id = :chapter_id: AND deleted = 0',
'conditions' => 'chapter_id = :chapter_id:',
'bind' => ['chapter_id' => $chapterId],
]);
}

View File

@ -43,7 +43,7 @@ class ChapterUser extends Repository
public function findChapterUser($chapterId, $userId)
{
return ChapterUserModel::findFirst([
'conditions' => 'chapter_id = ?1 AND user_id = ?2 AND deleted = 0',
'conditions' => 'chapter_id = ?1 AND user_id = ?2',
'bind' => [1 => $chapterId, 2 => $userId],
'order' => 'id DESC',
]);
@ -58,7 +58,7 @@ class ChapterUser extends Repository
public function findPlanChapterUser($chapterId, $userId, $planId)
{
return ChapterUserModel::findFirst([
'conditions' => 'chapter_id = ?1 AND user_id = ?2 AND plan_id = ?3 AND deleted = 0',
'conditions' => 'chapter_id = ?1 AND user_id = ?2 AND plan_id = ?3',
'bind' => [1 => $chapterId, 2 => $userId, 3 => $planId],
]);
}

View File

@ -28,10 +28,6 @@ class Connect extends Repository
$query->andWhere('provider = :provider:', ['provider' => $where['provider']]);
}
if (isset($where['deleted'])) {
$query->andWhere('deleted = :deleted:', ['deleted' => $where['deleted']]);
}
$query->orderBy('id DESC');
return $query->execute();

View File

@ -317,7 +317,7 @@ class Course extends Repository
public function countFavorites($courseId)
{
return (int)CourseFavoriteModel::count([
'conditions' => 'course_id = :course_id: AND deleted = 0',
'conditions' => 'course_id = :course_id:',
'bind' => ['course_id' => $courseId],
]);
}

View File

@ -25,10 +25,6 @@ class CourseFavorite extends Repository
$builder->andWhere('user_id = :user_id:', ['user_id' => $where['user_id']]);
}
if (isset($where['deleted'])) {
$builder->andWhere('deleted = :deleted:', ['deleted' => $where['deleted']]);
}
switch ($sort) {
default:
$orderBy = 'id DESC';

View File

@ -25,10 +25,6 @@ class ImFriendUser extends Repository
$builder->andWhere('friend_id = :friend_id:', ['friend_id' => $where['friend_id']]);
}
if (isset($where['blocked'])) {
$builder->andWhere('blocked = :blocked:', ['blocked' => $where['blocked']]);
}
switch ($sort) {
case 'oldest':
$orderBy = 'id ASC';

View File

@ -27,10 +27,6 @@ class ImNotice extends Repository
$builder->andWhere('receiver_id = :receiver_id:', ['receiver_id' => $where['receiver_id']]);
}
if (isset($where['deleted'])) {
$builder->andWhere('deleted = :deleted:', ['deleted' => $where['deleted']]);
}
switch ($sort) {
case 'oldest':
$orderBy = 'id ASC';

View File

@ -17,7 +17,6 @@ class UserSession extends Repository
{
return UserSessionModel::query()
->where('user_id = :user_id:', ['user_id' => $userId])
->andWhere('deleted = 0')
->execute();
}

View File

@ -17,7 +17,6 @@ class UserToken extends Repository
{
return UserTokenModel::query()
->where('user_id = :user_id:', ['user_id' => $userId])
->andWhere('deleted = 0')
->execute();
}

View File

@ -2,20 +2,20 @@
namespace App\Repos;
use App\Models\WechatSubscribe as WechatSubscribeModel;
use App\Models\WeChatSubscribe as WeChatSubscribeModel;
use Phalcon\Mvc\Model;
class WechatSubscribe extends Repository
class WeChatSubscribe extends Repository
{
/**
* @param int $userId
* @param string $openId
* @return WechatSubscribeModel|Model|bool
* @return WeChatSubscribeModel|Model|bool
*/
public function findSubscribe($userId, $openId)
{
return WechatSubscribeModel::findFirst([
return WeChatSubscribeModel::findFirst([
'conditions' => 'user_id= ?1 AND open_id = ?2',
'bind' => [1 => $userId, 2 => $openId],
]);
@ -23,11 +23,11 @@ class WechatSubscribe extends Repository
/**
* @param int $id
* @return WechatSubscribeModel|Model|bool
* @return WeChatSubscribeModel|Model|bool
*/
public function findById($id)
{
return WechatSubscribeModel::findFirst([
return WeChatSubscribeModel::findFirst([
'conditions' => 'id = :id:',
'bind' => ['id' => $id],
]);
@ -35,7 +35,7 @@ class WechatSubscribe extends Repository
/**
* @param int $userId
* @return WechatSubscribeModel|Model|bool
* @return WeChatSubscribeModel|Model|bool
*/
public function findByUserId($userId)
{
@ -47,11 +47,11 @@ class WechatSubscribe extends Repository
/**
* @param string $openId
* @return WechatSubscribeModel|Model|bool
* @return WeChatSubscribeModel|Model|bool
*/
public function findByOpenId($openId)
{
return WechatSubscribeModel::findFirst([
return WeChatSubscribeModel::findFirst([
'conditions' => 'open_id = :open_id:',
'bind' => ['open_id' => $openId],
]);

View File

@ -17,12 +17,16 @@ class Api extends AuthService
{
$token = $this->generateToken($user->id);
$lifetime = $this->getTokenLifetime();
/**
* demo版本不限制多人登录
*/
// $this->logoutOtherClients($user->id);
$this->createUserToken($user->id, $token);
$this->logoutOtherClients($user->id);
$this->createUserToken($user->id, $token, $lifetime);
$cache = $this->getCache();
@ -33,10 +37,6 @@ class Api extends AuthService
'name' => $user->name,
];
$config = $this->getConfig();
$lifetime = $config->path('token.lifetime') ?: 7 * 86400;
$cache->save($key, $authInfo, $lifetime);
return $token;
@ -70,7 +70,7 @@ class Api extends AuthService
return $authInfo ?: null;
}
protected function createUserToken($userId, $token)
protected function createUserToken($userId, $token, $lifetime)
{
$userToken = new UserTokenModel();
@ -78,6 +78,7 @@ class Api extends AuthService
$userToken->token = $token;
$userToken->client_type = $this->getClientType();
$userToken->client_ip = $this->getClientIp();
$userToken->expire_time = time() + $lifetime;
$userToken->create();
}
@ -92,14 +93,11 @@ class Api extends AuthService
$clientType = $this->getClientType();
if ($records->count() == 0) {
return;
}
if ($records->count() == 0) return;
foreach ($records as $record) {
if ($record->client_type == $clientType) {
$record->deleted = 1;
$record->update();
$record->delete();
$key = $this->getTokenCacheKey($record->token);
$cache->delete($key);
}
@ -111,6 +109,13 @@ class Api extends AuthService
return md5(uniqid() . time() . $userId);
}
protected function getTokenLifetime()
{
$config = $this->getConfig();
return $config->path('token.lifetime') ?: 7 * 86400;
}
protected function getTokenCacheKey($token)
{
return "_PHCR_TOKEN_:{$token}";

View File

@ -17,12 +17,16 @@ class Home extends AuthService
{
$sessionId = $this->session->getId();
$lifetime = $this->getSessionLifetime();
$this->logoutOtherClients($user->id);
/**
* demo版本不限制多人登录
*/
// $this->logoutOtherClients($user->id);
$this->createUserSession($user->id, $sessionId);
$this->createUserSession($user->id, $sessionId, $lifetime);
$authKey = $this->getAuthKey();
@ -55,7 +59,7 @@ class Home extends AuthService
return 'home_auth_info';
}
protected function createUserSession($userId, $sessionId)
protected function createUserSession($userId, $sessionId, $lifetime)
{
$userSession = new UserSessionModel();
@ -63,6 +67,7 @@ class Home extends AuthService
$userSession->session_id = $sessionId;
$userSession->client_type = $this->getClientType();
$userSession->client_ip = $this->getClientIp();
$userSession->expire_time = time() + $lifetime;
$userSession->create();
}
@ -75,18 +80,22 @@ class Home extends AuthService
$records = $repo->findByUserId($userId);
if ($records->count() == 0) {
return;
}
if ($records->count() == 0) return;
foreach ($records as $record) {
$record->deleted = 1;
$record->update();
$record->delete();
$key = $this->getSessionCacheKey($record->session_id);
$cache->delete($key);
}
}
protected function getSessionLifetime()
{
$config = $this->getConfig();
return $config->path('session.lifetime') ?: 24 * 3600;
}
protected function getSessionCacheKey($sessionId)
{
return "_PHCR_SESSION_:{$sessionId}";

View File

@ -6,10 +6,12 @@ use App\Models\Chapter as ChapterModel;
use App\Models\ChapterUser as ChapterUserModel;
use App\Models\Course as CourseModel;
use App\Models\CourseUser as CourseUserModel;
use App\Models\ImGroup as ImGroupModel;
use App\Models\ImGroupUser as ImGroupUserModel;
use App\Models\User as UserModel;
use App\Repos\ChapterLike as ChapterLikeRepo;
use App\Repos\ImGroup as ImGroupRepo;
use App\Repos\ImGroupUser as ImGroupUserRepo;
use App\Services\Logic\ChapterTrait;
use App\Services\Logic\CourseTrait;
use App\Services\Logic\Service;
@ -76,7 +78,7 @@ class ChapterInfo extends Service
$like = $likeRepo->findChapterLike($chapter->id, $user->id);
if ($like && $like->deleted == 0) {
if ($like) {
$me['liked'] = 1;
}
@ -104,11 +106,17 @@ class ChapterInfo extends Service
$courseUser = new CourseUserModel();
$roleType = CourseUserModel::ROLE_STUDENT;
$sourceType = CourseUserModel::SOURCE_FREE;
if ($course->market_price > 0 && $course->vip_price == 0 && $user->vip == 1) {
$sourceType = CourseUserModel::SOURCE_VIP;
}
$courseUser->course_id = $course->id;
$courseUser->user_id = $user->id;
$courseUser->source_type = CourseUserModel::SOURCE_FREE;
$courseUser->role_type = CourseUserModel::ROLE_STUDENT;
$courseUser->expiry_time = strtotime('+3 years');
$courseUser->source_type = $sourceType;
$courseUser->role_type = $roleType;
$courseUser->create();
@ -120,12 +128,21 @@ class ChapterInfo extends Service
$group = $groupRepo->findByCourseId($course->id);
$groupUser = new ImGroupUserModel();
$groupUserRepo = new ImGroupUserRepo();
$groupUser->group_id = $group->id;
$groupUser->user_id = $user->id;
$groupUser = $groupUserRepo->findGroupUser($group->id, $user->id);
$groupUser->create();
if (!$groupUser) {
$groupUser = new ImGroupUserModel();
$groupUser->group_id = $group->id;
$groupUser->user_id = $user->id;
$groupUser->create();
$this->incrGroupUserCount($group);
}
$this->incrCourseUserCount($course);
@ -179,4 +196,11 @@ class ChapterInfo extends Service
$chapter->update();
}
protected function incrGroupUserCount(ImGroupModel $group)
{
$group->user_count += 1;
$group->update();
}
}

View File

@ -42,18 +42,9 @@ class ChapterLike extends Service
} else {
if ($chapterLike->deleted == 0) {
$chapterLike->delete();
$chapterLike->update(['deleted' => 1]);
$this->decrLikeCount($chapter);
} else {
$chapterLike->update(['deleted' => 0]);
$this->incrLikeCount($chapter);
}
$this->decrLikeCount($chapter);
}
$this->incrUserDailyChapterLikeCount($user);

View File

@ -4,6 +4,7 @@ namespace App\Services\Logic;
use App\Models\Chapter as ChapterModel;
use App\Models\ChapterUser as ChapterUserModel;
use App\Models\CourseUser as CourseUserModel;
use App\Models\User as UserModel;
use App\Repos\ChapterUser as ChapterUserRepo;
use App\Validators\Chapter as ChapterValidator;
@ -65,16 +66,19 @@ trait ChapterTrait
{
$chapterUser = null;
/**
* @var CourseUserModel $courseUser
*/
$courseUser = $this->courseUser;
if ($user->id > 0 && $courseUser) {
$chapterUserRepo = new ChapterUserRepo();
$chapterUser = $chapterUserRepo->findChapterUser($chapter->id, $user->id);
$chapterUser = $chapterUserRepo->findPlanChapterUser($chapter->id, $user->id, $courseUser->plan_id);
}
$this->chapterUser = $chapterUser;
if ($chapterUser && $chapterUser->plan_id == $courseUser->plan_id) {
if ($chapterUser) {
$this->joinedChapter = true;
}

View File

@ -6,9 +6,9 @@ use App\Models\Chapter as ChapterModel;
use App\Models\Consult as ConsultModel;
use App\Models\Course as CourseModel;
use App\Models\User as UserModel;
use App\Services\DingTalk\Notice\ConsultCreate as ConsultCreateNotice;
use App\Services\Logic\ChapterTrait;
use App\Services\Logic\CourseTrait;
use App\Services\Logic\Notice\DingTalk\ConsultCreate as ConsultCreateNotice;
use App\Services\Logic\Service;
use App\Validators\Consult as ConsultValidator;
use App\Validators\UserLimit as UserLimitValidator;

View File

@ -42,18 +42,9 @@ class ConsultLike extends Service
} else {
if ($consultLike->deleted == 0) {
$consultLike->delete();
$consultLike->update(['deleted' => 1]);
$this->decrLikeCount($consult);
} else {
$consultLike->update(['deleted' => 0]);
$this->incrLikeCount($consult);
}
$this->decrLikeCount($consult);
}
$this->incrUserDailyConsultLikeCount($user);

View File

@ -42,22 +42,11 @@ class CourseFavorite extends Service
} else {
if ($favorite->deleted == 0) {
$favorite->delete();
$favorite->update(['deleted' => 1]);
$this->decrCourseFavoriteCount($course);
$this->decrCourseFavoriteCount($course);
$this->decrUserFavoriteCount($user);
} else {
$favorite->update(['deleted' => 0]);
$this->incrCourseFavoriteCount($course);
$this->incrUserFavoriteCount($user);
}
$this->decrUserFavoriteCount($user);
}
return $favorite;

View File

@ -48,7 +48,7 @@ class CourseInfo extends Service
$favorite = $favoriteRepo->findCourseFavorite($course->id, $user->id);
if ($favorite && $favorite->deleted == 0) {
if ($favorite) {
$me['favorited'] = 1;
}

View File

@ -59,7 +59,7 @@ trait CourseTrait
$this->ownedCourse = true;
} elseif ($course->vip_price == 0 && $user->vip == 1) {
} elseif ($course->market_price > 0 && $course->vip_price == 0 && $user->vip == 1) {
$this->ownedCourse = true;
@ -72,14 +72,21 @@ trait CourseTrait
$sourceTypes = [
CourseUserModel::SOURCE_CHARGE,
CourseUserModel::SOURCE_IMPORT,
CourseUserModel::SOURCE_POINT_REDEEM,
CourseUserModel::SOURCE_LUCKY_REDEEM,
];
$case1 = $courseUser->deleted == 0;
$case2 = $courseUser->expiry_time > time();
$case3 = in_array($courseUser->source_type, $sourceTypes);
/**
* 之前参与过课程,但不再满足条件,视为未参与
*/
if ($case1 && $case2 && $case3) {
$this->ownedCourse = true;
} else {
$this->joinedCourse = false;
}
}
}

View File

@ -4,9 +4,9 @@ namespace App\Services\Logic\Notice;
use App\Models\Task as TaskModel;
use App\Models\User as UserModel;
use App\Repos\WechatSubscribe as WechatSubscribeRepo;
use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
use App\Services\Logic\Notice\WeChat\AccountLogin as WeChatAccountLoginNotice;
use App\Services\Logic\Service as LogicService;
use App\Services\Wechat\Notice\AccountLogin as WechatAccountLoginNotice;
use App\Traits\Client as ClientTrait;
class AccountLogin extends LogicService
@ -16,17 +16,24 @@ class AccountLogin extends LogicService
public function handleTask(TaskModel $task)
{
/**
* @todo 鉴于微信消息模板4.30下线,暂时下线登录通知
*/
$wechatOA = $this->getSettings('wechat.oa');
if ($wechatOA['enabled'] == 0) return;
$params = $task->item_info;
$userId = $task->item_info['user']['id'];
$subscribeRepo = new WechatSubscribeRepo();
$subscribeRepo = new WeChatSubscribeRepo();
$subscribe = $subscribeRepo->findByUserId($userId);
if ($subscribe && $subscribe->deleted == 0) {
$notice = new WechatAccountLoginNotice();
$notice = new WeChatAccountLoginNotice();
return $notice->handle($subscribe, $params);
}
@ -34,6 +41,10 @@ class AccountLogin extends LogicService
public function createTask(UserModel $user)
{
$wechatOA = $this->getSettings('wechat.oa');
if ($wechatOA['enabled'] == 0) return;
$task = new TaskModel();
$loginIp = $this->getClientIp();
@ -59,4 +70,15 @@ class AccountLogin extends LogicService
$task->create();
}
public function wechatNoticeEnabled()
{
$oa = $this->getSettings('wechat.oa');
if ($oa['enabled'] == 0) return false;
$template = json_decode($oa['notice_template'], true);
return $template['account_login']['enabled'] == 1;
}
}

View File

@ -7,16 +7,21 @@ use App\Models\Task as TaskModel;
use App\Repos\Consult as ConsultRepo;
use App\Repos\Course as CourseRepo;
use App\Repos\User as UserRepo;
use App\Repos\WechatSubscribe as WechatSubscribeRepo;
use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
use App\Services\Logic\Notice\Sms\ConsultReply as SmsConsultReplyNotice;
use App\Services\Logic\Notice\WeChat\ConsultReply as WeChatConsultReplyNotice;
use App\Services\Logic\Service as LogicService;
use App\Services\Sms\Notice\ConsultReply as SmsConsultReplyNotice;
use App\Services\Wechat\Notice\ConsultReply as WechatConsultReplyNotice;
class ConsultReply extends LogicService
{
public function handleTask(TaskModel $task)
{
$wechatNoticeEnabled = $this->wechatNoticeEnabled();
$smsNoticeEnabled = $this->smsNoticeEnabled();
if (!$wechatNoticeEnabled && !$smsNoticeEnabled) return;
$consultId = $task->item_info['consult']['id'];
$consultRepo = new ConsultRepo();
@ -55,17 +60,17 @@ class ConsultReply extends LogicService
],
];
$subscribeRepo = new WechatSubscribeRepo();
$subscribeRepo = new WeChatSubscribeRepo();
$subscribe = $subscribeRepo->findByUserId($consult->owner_id);
if ($subscribe && $subscribe->deleted == 0) {
if ($wechatNoticeEnabled && $subscribe) {
$notice = new WechatConsultReplyNotice();
$notice = new WeChatConsultReplyNotice();
return $notice->handle($subscribe, $params);
} else {
} elseif ($smsNoticeEnabled) {
$notice = new SmsConsultReplyNotice();
@ -75,6 +80,11 @@ class ConsultReply extends LogicService
public function createTask(ConsultModel $consult)
{
$wechatNoticeEnabled = $this->wechatNoticeEnabled();
$smsNoticeEnabled = $this->smsNoticeEnabled();
if (!$wechatNoticeEnabled && !$smsNoticeEnabled) return;
$task = new TaskModel();
$itemInfo = [
@ -91,4 +101,28 @@ class ConsultReply extends LogicService
$task->create();
}
public function wechatNoticeEnabled()
{
$oa = $this->getSettings('wechat.oa');
if ($oa['enabled'] == 0) return false;
$template = json_decode($oa['notice_template'], true);
$result = $template['consult_reply']['enabled'] ?? 0;
return $result == 1;
}
public function smsNoticeEnabled()
{
$sms = $this->getSettings('sms');
$template = json_decode($sms['template'], true);
$result = $template['consult_reply']['enabled'] ?? 0;
return $result == 1;
}
}

View File

@ -1,6 +1,6 @@
<?php
namespace App\Services\DingTalk\Notice;
namespace App\Services\Logic\Notice\DingTalk;
use App\Models\Consult as ConsultModel;
use App\Models\Task as TaskModel;

View File

@ -1,6 +1,6 @@
<?php
namespace App\Services\DingTalk\Notice;
namespace App\Services\Logic\Notice\DingTalk;
use App\Models\ImMessage as ImMessageModel;
use App\Models\Task as TaskModel;

View File

@ -1,6 +1,6 @@
<?php
namespace App\Services\DingTalk\Notice;
namespace App\Services\Logic\Notice\DingTalk;
use App\Models\PointGift as PointGiftModel;
use App\Models\PointRedeem as PointRedeemModel;

View File

@ -1,6 +1,6 @@
<?php
namespace App\Services\DingTalk\Notice;
namespace App\Services\Logic\Notice\DingTalk;
use App\Models\Task as TaskModel;
use App\Services\DingTalkNotice;

View File

@ -1,6 +1,6 @@
<?php
namespace App\Services\DingTalk\Notice;
namespace App\Services\Logic\Notice\DingTalk;
use App\Models\ChapterLive as ChapterLiveModel;
use App\Models\Task as TaskModel;

View File

@ -8,16 +8,21 @@ use App\Models\Task as TaskModel;
use App\Repos\Chapter as ChapterRepo;
use App\Repos\Course as CourseRepo;
use App\Repos\User as UserRepo;
use App\Repos\WechatSubscribe as WechatSubscribeRepo;
use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
use App\Services\Logic\Notice\Sms\LiveBegin as SmsLiveBeginNotice;
use App\Services\Logic\Notice\WeChat\LiveBegin as WeChatLiveBeginNotice;
use App\Services\Logic\Service as LogicService;
use App\Services\Sms\Notice\LiveBegin as SmsLiveBeginNotice;
use App\Services\Wechat\Notice\LiveBegin as WechatLiveBeginNotice;
class LiveBegin extends LogicService
{
public function handleTask(TaskModel $task)
{
$wechatNoticeEnabled = $this->wechatNoticeEnabled();
$smsNoticeEnabled = $this->smsNoticeEnabled();
if (!$wechatNoticeEnabled && !$smsNoticeEnabled) return;
$courseUser = $task->item_info['course_user'];
$chapterId = $task->item_info['chapter']['id'];
@ -53,17 +58,17 @@ class LiveBegin extends LogicService
'course_user' => $courseUser,
];
$subscribeRepo = new WechatSubscribeRepo();
$subscribeRepo = new WeChatSubscribeRepo();
$subscribe = $subscribeRepo->findByUserId($user->id);
if ($subscribe && $subscribe->deleted == 0) {
if ($wechatNoticeEnabled && $subscribe) {
$notice = new WechatLiveBeginNotice();
$notice = new WeChatLiveBeginNotice();
return $notice->handle($subscribe, $params);
} else {
} elseif ($smsNoticeEnabled) {
$notice = new SmsLiveBeginNotice();
@ -73,6 +78,11 @@ class LiveBegin extends LogicService
public function createTask(ChapterModel $chapter, CourseUserModel $courseUser)
{
$wechatNoticeEnabled = $this->wechatNoticeEnabled();
$smsNoticeEnabled = $this->smsNoticeEnabled();
if (!$wechatNoticeEnabled && !$smsNoticeEnabled) return;
$task = new TaskModel();
$itemInfo = [
@ -97,4 +107,28 @@ class LiveBegin extends LogicService
$task->create();
}
public function wechatNoticeEnabled()
{
$oa = $this->getSettings('wechat.oa');
if ($oa['enabled'] == 0) return false;
$template = json_decode($oa['notice_template'], true);
$result = $template['live_begin']['enabled'] ?? 0;
return $result == 1;
}
public function smsNoticeEnabled()
{
$sms = $this->getSettings('sms');
$template = json_decode($sms['template'], true);
$result = $template['live_begin']['enabled'] ?? 0;
return $result == 1;
}
}

View File

@ -1,6 +1,6 @@
<?php
namespace App\Services\Mail;
namespace App\Services\Logic\Notice\Mail;
use App\Services\Mailer;

View File

@ -1,6 +1,6 @@
<?php
namespace App\Services\Mail;
namespace App\Services\Logic\Notice\Mail;
use App\Services\Mailer as MailerService;
use App\Services\Verify as VerifyService;

View File

@ -6,16 +6,21 @@ use App\Models\Order as OrderModel;
use App\Models\Task as TaskModel;
use App\Repos\Order as OrderRepo;
use App\Repos\User as UserRepo;
use App\Repos\WechatSubscribe as WechatSubscribeRepo;
use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
use App\Services\Logic\Notice\Sms\OrderFinish as SmsOrderFinishNotice;
use App\Services\Logic\Notice\WeChat\OrderFinish as WeChatOrderFinishNotice;
use App\Services\Logic\Service as LogicService;
use App\Services\Sms\Notice\OrderFinish as SmsOrderFinishNotice;
use App\Services\Wechat\Notice\OrderFinish as WechatOrderFinishNotice;
class OrderFinish extends LogicService
{
public function handleTask(TaskModel $task)
{
$wechatNoticeEnabled = $this->wechatNoticeEnabled();
$smsNoticeEnabled = $this->smsNoticeEnabled();
if (!$wechatNoticeEnabled && !$smsNoticeEnabled) return;
$orderId = $task->item_info['order']['id'];
$orderRepo = new OrderRepo();
@ -40,17 +45,17 @@ class OrderFinish extends LogicService
],
];
$subscribeRepo = new WechatSubscribeRepo();
$subscribeRepo = new WeChatSubscribeRepo();
$subscribe = $subscribeRepo->findByUserId($order->owner_id);
if ($subscribe && $subscribe->deleted == 0) {
if ($wechatNoticeEnabled && $subscribe) {
$notice = new WechatOrderFinishNotice();
$notice = new WeChatOrderFinishNotice();
return $notice->handle($subscribe, $params);
} else {
} elseif ($smsNoticeEnabled) {
$notice = new SmsOrderFinishNotice();
@ -60,6 +65,11 @@ class OrderFinish extends LogicService
public function createTask(OrderModel $order)
{
$wechatNoticeEnabled = $this->wechatNoticeEnabled();
$smsNoticeEnabled = $this->smsNoticeEnabled();
if (!$wechatNoticeEnabled && !$smsNoticeEnabled) return;
$task = new TaskModel();
$itemInfo = [
@ -75,4 +85,28 @@ class OrderFinish extends LogicService
$task->create();
}
public function wechatNoticeEnabled()
{
$oa = $this->getSettings('wechat.oa');
if ($oa['enabled'] == 0) return false;
$template = json_decode($oa['notice_template'], true);
$result = $template['order_finish']['enabled'] ?? 0;
return $result == 1;
}
public function smsNoticeEnabled()
{
$sms = $this->getSettings('sms');
$template = json_decode($sms['template'], true);
$result = $template['order_finish']['enabled'] ?? 0;
return $result == 1;
}
}

View File

@ -0,0 +1,108 @@
<?php
namespace App\Services\Logic\Notice;
use App\Models\PointRedeem as PointRedeemModel;
use App\Models\Task as TaskModel;
use App\Repos\PointRedeem as PointRedeemRepo;
use App\Repos\User as UserRepo;
use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
use App\Services\Logic\Notice\Sms\GoodsDeliver as SmsGoodsDeliverNotice;
use App\Services\Logic\Notice\WeChat\GoodsDeliver as WeChatGoodsDeliverNotice;
use App\Services\Logic\Service as LogicService;
class PointGoodsDeliver extends LogicService
{
public function handleTask(TaskModel $task)
{
$wechatNoticeEnabled = $this->wechatNoticeEnabled();
$smsNoticeEnabled = $this->smsNoticeEnabled();
if (!$wechatNoticeEnabled && !$smsNoticeEnabled) return;
$redeemId = $task->item_info['point_redeem']['id'];
$redeemRepo = new PointRedeemRepo();
$redeem = $redeemRepo->findById($redeemId);
$userRepo = new UserRepo();
$user = $userRepo->findById($redeem->user_id);
$params = [
'user' => [
'id' => $user->id,
'name' => $user->name,
],
'goods_name' => $redeem->gift_name,
'order_sn' => date('YmdHis') . rand(1000, 9999),
'deliver_time' => time(),
];
$subscribeRepo = new WeChatSubscribeRepo();
$subscribe = $subscribeRepo->findByUserId($user->id);
if ($wechatNoticeEnabled && $subscribe) {
$notice = new WeChatGoodsDeliverNotice();
return $notice->handle($subscribe, $params);
} elseif ($smsNoticeEnabled) {
$notice = new SmsGoodsDeliverNotice();
return $notice->handle($user, $params);
}
}
public function createTask(PointRedeemModel $redeem)
{
$wechatNoticeEnabled = $this->wechatNoticeEnabled();
$smsNoticeEnabled = $this->smsNoticeEnabled();
if (!$wechatNoticeEnabled && !$smsNoticeEnabled) return;
$task = new TaskModel();
$itemInfo = [
'point_redeem' => ['id' => $redeem->id],
];
$task->item_id = $redeem->id;
$task->item_info = $itemInfo;
$task->item_type = TaskModel::TYPE_NOTICE_POINT_GOODS_DELIVER;
$task->priority = TaskModel::PRIORITY_MIDDLE;
$task->status = TaskModel::STATUS_PENDING;
$task->create();
}
public function wechatNoticeEnabled()
{
$oa = $this->getSettings('wechat.oa');
if ($oa['enabled'] == 0) return false;
$template = json_decode($oa['notice_template'], true);
$result = $template['goods_deliver']['enabled'] ?? 0;
return $result == 1;
}
public function smsNoticeEnabled()
{
$sms = $this->getSettings('sms');
$template = json_decode($sms['template'], true);
$result = $template['goods_deliver']['enabled'] ?? 0;
return $result == 1;
}
}

View File

@ -1,78 +0,0 @@
<?php
namespace App\Services\Logic\Notice;
use App\Models\Order as OrderModel;
use App\Models\Task as TaskModel;
use App\Repos\Order as OrderRepo;
use App\Repos\User as UserRepo;
use App\Repos\WechatSubscribe as WechatSubscribeRepo;
use App\Services\Logic\Service as LogicService;
use App\Services\Sms\Notice\OrderFinish as SmsOrderFinishNotice;
use App\Services\Wechat\Notice\OrderFinish as WechatOrderFinishNotice;
class PointRedeemFinish extends LogicService
{
public function handleTask(TaskModel $task)
{
$orderId = $task->item_info['order']['id'];
$orderRepo = new OrderRepo();
$order = $orderRepo->findById($orderId);
$userRepo = new UserRepo();
$user = $userRepo->findById($order->owner_id);
$params = [
'user' => [
'id' => $user->id,
'name' => $user->name,
],
'order' => [
'sn' => $order->sn,
'subject' => $order->subject,
'amount' => $order->amount,
'create_time' => $order->create_time,
'update_time' => $order->update_time,
],
];
$subscribeRepo = new WechatSubscribeRepo();
$subscribe = $subscribeRepo->findByUserId($order->owner_id);
if ($subscribe && $subscribe->deleted == 0) {
$notice = new WechatOrderFinishNotice();
return $notice->handle($subscribe, $params);
} else {
$notice = new SmsOrderFinishNotice();
return $notice->handle($user, $params);
}
}
public function createTask(OrderModel $order)
{
$task = new TaskModel();
$itemInfo = [
'order' => ['id' => $order->id],
];
$task->item_id = $order->id;
$task->item_info = $itemInfo;
$task->item_type = TaskModel::TYPE_NOTICE_ORDER_FINISH;
$task->priority = TaskModel::PRIORITY_HIGH;
$task->status = TaskModel::STATUS_PENDING;
$task->create();
}
}

View File

@ -6,16 +6,21 @@ use App\Models\Refund as RefundModel;
use App\Models\Task as TaskModel;
use App\Repos\Refund as RefundRepo;
use App\Repos\User as UserRepo;
use App\Repos\WechatSubscribe as WechatSubscribeRepo;
use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
use App\Services\Logic\Notice\Sms\RefundFinish as SmsRefundFinishNotice;
use App\Services\Logic\Notice\WeChat\OrderFinish as WeChatRefundFinishNotice;
use App\Services\Logic\Service as LogicService;
use App\Services\Sms\Notice\RefundFinish as SmsRefundFinishNotice;
use App\Services\Wechat\Notice\RefundFinish as WechatRefundFinishNotice;
class RefundFinish extends LogicService
{
public function handleTask(TaskModel $task)
{
$wechatNoticeEnabled = $this->wechatNoticeEnabled();
$smsNoticeEnabled = $this->smsNoticeEnabled();
if (!$wechatNoticeEnabled && !$smsNoticeEnabled) return;
$refundId = $task->item_info['refund']['id'];
$refundRepo = new RefundRepo();
@ -40,17 +45,17 @@ class RefundFinish extends LogicService
],
];
$subscribeRepo = new WechatSubscribeRepo();
$subscribeRepo = new WeChatSubscribeRepo();
$subscribe = $subscribeRepo->findByUserId($refund->owner_id);
if ($subscribe && $subscribe->deleted == 0) {
if ($wechatNoticeEnabled && $subscribe) {
$notice = new WechatRefundFinishNotice();
$notice = new WeChatRefundFinishNotice();
return $notice->handle($subscribe, $params);
} else {
} elseif ($smsNoticeEnabled) {
$notice = new SmsRefundFinishNotice();
@ -60,6 +65,11 @@ class RefundFinish extends LogicService
public function createTask(RefundModel $refund)
{
$wechatNoticeEnabled = $this->wechatNoticeEnabled();
$smsNoticeEnabled = $this->smsNoticeEnabled();
if (!$wechatNoticeEnabled && !$smsNoticeEnabled) return;
$task = new TaskModel();
$itemInfo = [
@ -75,4 +85,28 @@ class RefundFinish extends LogicService
$task->create();
}
public function wechatNoticeEnabled()
{
$oa = $this->getSettings('wechat.oa');
if ($oa['enabled'] == 0) return false;
$template = json_decode($oa['notice_template'], true);
$result = $template['refund_finish']['enabled'] ?? 0;
return $result == 1;
}
public function smsNoticeEnabled()
{
$sms = $this->getSettings('sms');
$template = json_decode($sms['template'], true);
$result = $template['refund_finish']['enabled'] ?? 0;
return $result == 1;
}
}

View File

@ -1,6 +1,6 @@
<?php
namespace App\Services\Sms\Notice;
namespace App\Services\Logic\Notice\Sms;
use App\Models\User as UserModel;
use App\Repos\Account as AccountRepo;

View File

@ -0,0 +1,38 @@
<?php
namespace App\Services\Logic\Notice\Sms;
use App\Models\User as UserModel;
use App\Repos\Account as AccountRepo;
use App\Services\Smser;
class GoodsDeliver extends Smser
{
protected $templateCode = 'goods_deliver';
/**
* @param UserModel $user
* @param array $params
* @return bool|null
*/
public function handle(UserModel $user, array $params)
{
$accountRepo = new AccountRepo();
$account = $accountRepo->findById($user->id);
if (!$account->phone) return null;
$templateId = $this->getTemplateId($this->templateCode);
$params = [
$params['order_sn'],
$params['goods_name'],
$params['deliver_time'],
];
return $this->send($account->phone, $templateId, $params);
}
}

View File

@ -1,6 +1,6 @@
<?php
namespace App\Services\Sms\Notice;
namespace App\Services\Logic\Notice\Sms;
use App\Models\User as UserModel;
use App\Repos\Account as AccountRepo;

View File

@ -1,6 +1,6 @@
<?php
namespace App\Services\Sms\Notice;
namespace App\Services\Logic\Notice\Sms;
use App\Models\User as UserModel;
use App\Repos\Account as AccountRepo;

View File

@ -1,6 +1,6 @@
<?php
namespace App\Services\Sms\Notice;
namespace App\Services\Logic\Notice\Sms;
use App\Models\User as UserModel;
use App\Repos\Account as AccountRepo;

View File

@ -1,6 +1,6 @@
<?php
namespace App\Services\Sms;
namespace App\Services\Logic\Notice\Sms;
use App\Services\Smser;

View File

@ -1,6 +1,6 @@
<?php
namespace App\Services\Sms;
namespace App\Services\Logic\Notice\Sms;
use App\Services\Smser as SmserService;
use App\Services\Verify as VerifyService;

View File

@ -1,21 +1,21 @@
<?php
namespace App\Services\Wechat\Notice;
namespace App\Services\Logic\Notice\WeChat;
use App\Models\WechatSubscribe as WechatSubscribeModel;
use App\Services\WechatNotice;
use App\Models\WeChatSubscribe as WeChatSubscribeModel;
use App\Services\WeChatNotice;
class AccountLogin extends WechatNotice
class AccountLogin extends WeChatNotice
{
protected $templateCode = 'account_login';
/**
* @param WechatSubscribeModel $subscribe
* @param WeChatSubscribeModel $subscribe
* @param array $params
* @return bool
*/
public function handle(WechatSubscribeModel $subscribe, array $params)
public function handle(WeChatSubscribeModel $subscribe, array $params)
{
$first = '你好,登录系统成功!';
$remark = '如果非本人操作,请立即修改密码哦!';

View File

@ -1,21 +1,21 @@
<?php
namespace App\Services\Wechat\Notice;
namespace App\Services\Logic\Notice\WeChat;
use App\Models\WechatSubscribe as WechatSubscribeModel;
use App\Services\WechatNotice;
use App\Models\WeChatSubscribe as WeChatSubscribeModel;
use App\Services\WeChatNotice;
class ConsultReply extends WechatNotice
class ConsultReply extends WeChatNotice
{
protected $templateCode = 'consult_reply';
/**
* @param WechatSubscribeModel $subscribe
* @param WeChatSubscribeModel $subscribe
* @param array $params
* @return bool
*/
public function handle(WechatSubscribeModel $subscribe, array $params)
public function handle(WeChatSubscribeModel $subscribe, array $params)
{
$first = sprintf('%s 回复了你的咨询!', $params['replier']['name']);

View File

@ -0,0 +1,37 @@
<?php
namespace App\Services\Logic\Notice\WeChat;
use App\Models\WeChatSubscribe as WeChatSubscribeModel;
use App\Services\WeChatNotice;
class GoodsDeliver extends WeChatNotice
{
protected $templateCode = 'goods_deliver';
/**
* @param WeChatSubscribeModel $subscribe
* @param array $params
* @return bool
*/
public function handle(WeChatSubscribeModel $subscribe, $params)
{
$first = '发货已处理完成!';
$remark = '感谢您的支持,有疑问请联系客服哦!';
$params = [
'first' => $first,
'remark' => $remark,
'keyword1' => $params['goods_name'],
'keyword2' => $params['order_sn'],
'keyword3' => date('Y-m-d H:i', $params['deliver_time']),
];
$templateId = $this->getTemplateId($this->templateCode);
return $this->send($subscribe->open_id, $templateId, $params);
}
}

View File

@ -1,21 +1,21 @@
<?php
namespace App\Services\Wechat\Notice;
namespace App\Services\Logic\Notice\WeChat;
use App\Models\WechatSubscribe as WechatSubscribeModel;
use App\Services\WechatNotice;
use App\Models\WeChatSubscribe as WeChatSubscribeModel;
use App\Services\WeChatNotice;
class LiveBegin extends WechatNotice
class LiveBegin extends WeChatNotice
{
protected $templateCode = 'live_begin';
/**
* @param WechatSubscribeModel $subscribe
* @param WeChatSubscribeModel $subscribe
* @param array $params
* @return bool
*/
public function handle(WechatSubscribeModel $subscribe, array $params)
public function handle(WeChatSubscribeModel $subscribe, array $params)
{
$first = '你参与的课程直播就要开始了!';

View File

@ -1,21 +1,21 @@
<?php
namespace App\Services\Wechat\Notice;
namespace App\Services\Logic\Notice\WeChat;
use App\Models\WechatSubscribe as WechatSubscribeModel;
use App\Services\WechatNotice;
use App\Models\WeChatSubscribe as WeChatSubscribeModel;
use App\Services\WeChatNotice;
class OrderFinish extends WechatNotice
class OrderFinish extends WeChatNotice
{
protected $templateCode = 'order_finish';
/**
* @param WechatSubscribeModel $subscribe
* @param WeChatSubscribeModel $subscribe
* @param array $params
* @return bool
*/
public function handle(WechatSubscribeModel $subscribe, $params)
public function handle(WeChatSubscribeModel $subscribe, $params)
{
$first = '订单已处理完成!';

View File

@ -1,21 +1,21 @@
<?php
namespace App\Services\Wechat\Notice;
namespace App\Services\Logic\Notice\WeChat;
use App\Models\WechatSubscribe as WechatSubscribeModel;
use App\Services\WechatNotice;
use App\Models\WeChatSubscribe as WeChatSubscribeModel;
use App\Services\WeChatNotice;
class RefundFinish extends WechatNotice
class RefundFinish extends WeChatNotice
{
protected $templateCode = 'refund_finish';
/**
* @param WechatSubscribeModel $subscribe
* @param WeChatSubscribeModel $subscribe
* @param array $params
* @return bool
*/
public function handle(WechatSubscribeModel $subscribe, array $params)
public function handle(WeChatSubscribeModel $subscribe, array $params)
{
$first = '退款已处理完成!';
$remark = '感谢您的支持,有疑问请联系客服哦!';

View File

@ -42,18 +42,9 @@ class ReviewLike extends Service
} else {
if ($reviewLike->deleted == 0) {
$reviewLike->delete();
$reviewLike->update(['deleted' => 1]);
$this->decrLikeCount($review);
} else {
$reviewLike->update(['deleted' => 0]);
$this->incrLikeCount($review);
}
$this->decrLikeCount($review);
}
$this->incrUserDailyReviewLikeCount($user);

View File

@ -18,9 +18,7 @@ class ConnectDelete extends Service
$validator->checkOwner($user->id, $connect->user_id);
$connect->deleted = 1;
$connect->update();
$connect->delete();
}
}

View File

@ -2,8 +2,8 @@
namespace App\Services\Logic\Verify;
use App\Services\Logic\Notice\Sms\Verify as SmsVerifyService;
use App\Services\Logic\Service;
use App\Services\Sms\Verify as VerifySmsService;
use App\Validators\Captcha as CaptchaValidator;
use App\Validators\Verify as VerifyValidator;
@ -22,7 +22,7 @@ class SmsCode extends Service
$validator->checkCode($post['ticket'], $post['rand']);
$service = new VerifySmsService();
$service = new SmsVerifyService();
$service->handle($post['phone']);
}

View File

@ -5,7 +5,7 @@ namespace App\Services;
use EasyWeChat\Factory;
use Phalcon\Logger\Adapter\File as FileLogger;
class Wechat extends Service
class WeChat extends Service
{
/**

View File

@ -2,10 +2,10 @@
namespace App\Services;
use App\Services\Wechat as WechatService;
use App\Services\WeChat as WeChatService;
use Phalcon\Logger\Adapter\File as FileLogger;
Abstract class WechatNotice extends Service
abstract class WeChatNotice extends Service
{
/**
@ -37,7 +37,7 @@ Abstract class WechatNotice extends Service
*/
public function send($openId, $templateId, $params, $url = null, $miniProgram = [])
{
$service = new WechatService();
$service = new WeChatService();
$app = $service->getOfficialAccount();

View File

@ -1,7 +1,5 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class InsertSettingData extends AbstractMigration
@ -368,7 +366,7 @@ final class InsertSettingData extends AbstractMigration
[
'section' => 'sms',
'item_key' => 'template',
'item_value' => '{"verify":"561282","order":"561954","refund":"561286","live":"561288"}',
'item_value' => '{"verify":"","order":"","refund":"","live":""}',
],
[
'section' => 'cos',
@ -418,7 +416,7 @@ final class InsertSettingData extends AbstractMigration
[
'section' => 'vod',
'item_key' => 'wmk_tpl_id',
'item_value' => '462027',
'item_value' => '',
],
[
'section' => 'vod',

View File

@ -1,7 +1,5 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class InsertUserData extends AbstractMigration

View File

@ -1,7 +1,5 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class InsertNavData extends AbstractMigration

View File

@ -1,7 +1,5 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class InsertVipData extends AbstractMigration

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