diff --git a/.phalcon/.gitkeep b/.phalcon/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/app/Builders/CourseList.php b/app/Builders/CourseList.php
index b729bcc3..4cf907c6 100644
--- a/app/Builders/CourseList.php
+++ b/app/Builders/CourseList.php
@@ -23,17 +23,19 @@ class CourseList extends Builder
$result[] = [
'id' => $course['id'],
- 'model' => $course['model'],
'title' => $course['title'],
- 'summary' => $course['summary'],
'cover' => $course['cover'],
+ 'summary' => $course['summary'],
+ 'categories' => $course['categories'],
'market_price' => (float)$course['market_price'],
'vip_price' => (float)$course['vip_price'],
- 'expiry' => $course['expiry'],
+ 'study_expiry' => $course->study_expiry,
+ 'refund_expiry' => $course->refund_expiry,
+ 'rating' => (float)$course['rating'],
+ 'score' => (float)$course['score'],
+ 'model' => $course['model'],
'level' => $course['level'],
- 'score' => $course['score'],
'attrs' => $course['attrs'],
- 'categories' => $course['categories'],
'user_count' => $course['user_count'],
'lesson_count' => $course['lesson_count'],
'comment_count' => $course['comment_count'],
diff --git a/app/Caches/Category.php b/app/Caches/Category.php
index a53e17ac..d56c2514 100644
--- a/app/Caches/Category.php
+++ b/app/Caches/Category.php
@@ -25,11 +25,7 @@ class Category extends Cache
$category = $categoryRepo->findById($id);
- if (!$category) {
- return new \stdClass();
- }
-
- return $category;
+ return $category ?: null;
}
}
diff --git a/app/Caches/ChapterTreeList.php b/app/Caches/CourseChapterList.php
similarity index 86%
rename from app/Caches/ChapterTreeList.php
rename to app/Caches/CourseChapterList.php
index 2cc7bd79..21203677 100644
--- a/app/Caches/ChapterTreeList.php
+++ b/app/Caches/CourseChapterList.php
@@ -6,7 +6,7 @@ use App\Builders\ChapterTreeList as ChapterTreeListBuilder;
use App\Repos\Course as CourseRepo;
use Phalcon\Mvc\Model\Resultset;
-class ChapterTreeList extends Cache
+class CourseChapterList extends Cache
{
protected $lifetime = 7 * 86400;
@@ -18,16 +18,13 @@ class ChapterTreeList extends Cache
public function getKey($id = null)
{
- return "chapter_tree_list:{$id}";
+ return "course_chapter_list:{$id}";
}
public function getContent($id = null)
{
$courseRepo = new CourseRepo();
- /**
- * @var Resultset $chapters
- */
$chapters = $courseRepo->findChapters($id);
if ($chapters->count() == 0) {
diff --git a/app/Caches/CoursePackageList.php b/app/Caches/CoursePackageList.php
index 5fbe83ce..2767cca2 100644
--- a/app/Caches/CoursePackageList.php
+++ b/app/Caches/CoursePackageList.php
@@ -81,6 +81,10 @@ class CoursePackageList extends Cache
'vip_price' => $course->vip_price,
'model' => $course->model,
'level' => $course->level,
+ 'user_count' => $course->user_count,
+ 'lesson_count' => $course->lesson_count,
+ 'review_count' => $course->review_count,
+ 'favorite_count' => $course->favorite_count,
];
}
diff --git a/app/Caches/CourseRelatedList.php b/app/Caches/CourseRelatedList.php
index 572dd61f..dd85a83c 100644
--- a/app/Caches/CourseRelatedList.php
+++ b/app/Caches/CourseRelatedList.php
@@ -54,8 +54,14 @@ class CourseRelatedList extends Cache
'summary' => $course->summary,
'market_price' => (float)$course->market_price,
'vip_price' => (float)$course->vip_price,
+ 'rating' => (float)$course['rating'],
+ 'score' => (float)$course['score'],
'model' => $course->model,
'level' => $course->level,
+ 'user_count' => $course->user_count,
+ 'lesson_count' => $course->lesson_count,
+ 'review_count' => $course->review_count,
+ 'favorite_count' => $course->favorite_count,
];
}
diff --git a/app/Console/Tasks/CloseTradeTask.php b/app/Console/Tasks/CloseTradeTask.php
index 3d634679..7ec1bef3 100644
--- a/app/Console/Tasks/CloseTradeTask.php
+++ b/app/Console/Tasks/CloseTradeTask.php
@@ -22,45 +22,73 @@ class CloseTradeTask extends Task
foreach ($trades as $trade) {
if ($trade->channel == TradeModel::CHANNEL_ALIPAY) {
- $this->closeAlipayTrade($trade);
+ $this->handleAlipayTrade($trade);
} elseif ($trade->channel == TradeModel::CHANNEL_WXPAY) {
- $this->closeWxpayTrade($trade);
+ $this->handleWxpayTrade($trade);
}
}
}
/**
- * 关闭支付宝交易
+ * 处理支付宝交易
*
* @param TradeModel $trade
*/
- protected function closeAlipayTrade($trade)
+ protected function handleAlipayTrade($trade)
{
+ $allowClosed = true;
+
$alipay = new AlipayService();
- $success = $alipay->close($trade->sn);
+ $alipayTrade = $alipay->find($trade->sn);
- if ($success) {
- $trade->status = TradeModel::STATUS_CLOSED;
- $trade->update();
+ if ($alipayTrade) {
+ /**
+ * 异步通知接收异常,补救漏网
+ */
+ if ($alipayTrade->trade_status == 'TRADE_SUCCESS') {
+ $this->eventsManager->fire('pay:afterPay', $this, $trade);
+ $allowClosed = false;
+ } elseif ($alipayTrade->trade_status == 'WAIT_BUYER_PAY') {
+ $alipay->close($trade->sn);
+ }
}
+
+ if (!$allowClosed) return;
+
+ $trade->status = TradeModel::STATUS_CLOSED;
+ $trade->update();
}
/**
- * 关闭微信交易
+ * 处理微信交易
*
* @param TradeModel $trade
*/
- protected function closeWxpayTrade($trade)
+ protected function handleWxpayTrade($trade)
{
+ $allowClosed = true;
+
$wxpay = new WxpayService();
- $success = $wxpay->close($trade->sn);
+ $wxpayTrade = $wxpay->find($trade->sn);
- if ($success) {
- $trade->status = TradeModel::STATUS_CLOSED;
- $trade->update();
+ if ($wxpayTrade) {
+ /**
+ * 异步通知接收异常,补救漏网
+ */
+ if ($wxpayTrade->trade_state == 'SUCCESS') {
+ $this->eventsManager->fire('pay:afterPay', $this, $trade);
+ $allowClosed = false;
+ } elseif ($wxpayTrade->trade_state == 'NOTPAY') {
+ $wxpay->close($trade->sn);
+ }
}
+
+ if (!$allowClosed) return;
+
+ $trade->status = TradeModel::STATUS_CLOSED;
+ $trade->update();
}
/**
diff --git a/app/Http/Admin/Controllers/SessionController.php b/app/Http/Admin/Controllers/SessionController.php
index 63d54311..e3262173 100644
--- a/app/Http/Admin/Controllers/SessionController.php
+++ b/app/Http/Admin/Controllers/SessionController.php
@@ -4,6 +4,7 @@ namespace App\Http\Admin\Controllers;
use App\Http\Admin\Services\Session as SessionService;
use App\Http\Admin\Services\Setting as SettingService;
+use App\Traits\Auth as AuthTrait;
use App\Traits\Response as ResponseTrait;
use App\Traits\Security as SecurityTrait;
@@ -13,13 +14,19 @@ use App\Traits\Security as SecurityTrait;
class SessionController extends \Phalcon\Mvc\Controller
{
- use ResponseTrait, SecurityTrait;
+ use AuthTrait, ResponseTrait, SecurityTrait;
/**
* @Route("/login", name="admin.login")
*/
public function loginAction()
{
+ $currentUser = $this->getCurrentUser();
+
+ if ($currentUser->id > 0) {
+ $this->response->redirect(['for' => 'admin.index']);
+ }
+
if ($this->request->isPost()) {
$this->checkHttpReferer();
diff --git a/app/Http/Admin/Controllers/SettingController.php b/app/Http/Admin/Controllers/SettingController.php
index c05e2673..fb960f3f 100644
--- a/app/Http/Admin/Controllers/SettingController.php
+++ b/app/Http/Admin/Controllers/SettingController.php
@@ -165,35 +165,6 @@ class SettingController extends Controller
}
}
- /**
- * @Route("/oauth", name="admin.setting.oauth")
- */
- public function oauthAction()
- {
- $settingService = new SettingService();
-
- if ($this->request->isPost()) {
-
- $section = $this->request->getPost('section');
-
- $data = $this->request->getPost();
-
- $settingService->updateSectionSettings($section, $data);
-
- return $this->jsonSuccess(['msg' => '更新配置成功']);
-
- } else {
-
- $qq = $settingService->getSectionSettings('oauth.qq');
- $weibo = $settingService->getSectionSettings('oauth.weibo');
- $weixin = $settingService->getSectionSettings('oauth.weixin');
-
- $this->view->setVar('qq', $qq);
- $this->view->setVar('weibo', $weibo);
- $this->view->setVar('weixin', $weixin);
- }
- }
-
/**
* @Route("/smser", name="admin.setting.smser")
*/
diff --git a/app/Http/Admin/Services/AuthNode.php b/app/Http/Admin/Services/AuthNode.php
index 65dcd281..f543cc7d 100644
--- a/app/Http/Admin/Services/AuthNode.php
+++ b/app/Http/Admin/Services/AuthNode.php
@@ -683,12 +683,6 @@ class AuthNode extends Service
],
[
'id' => '5-1-10',
- 'label' => '登录设置',
- 'type' => 'menu',
- 'route' => 'admin.setting.oauth',
- ],
- [
- 'id' => '5-1-11',
'label' => '会员设置',
'type' => 'menu',
'route' => 'admin.setting.vip',
diff --git a/app/Http/Admin/Views/setting/oauth.volt b/app/Http/Admin/Views/setting/oauth.volt
deleted file mode 100644
index 7cae574f..00000000
--- a/app/Http/Admin/Views/setting/oauth.volt
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
- {{ partial('setting/oauth_qq') }}
-
-
- {{ partial('setting/oauth_weibo') }}
-
-
- {{ partial('setting/oauth_weixin') }}
-
-
-
\ No newline at end of file
diff --git a/app/Http/Admin/Views/setting/oauth_qq.volt b/app/Http/Admin/Views/setting/oauth_qq.volt
deleted file mode 100644
index 35619f08..00000000
--- a/app/Http/Admin/Views/setting/oauth_qq.volt
+++ /dev/null
@@ -1,67 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/app/Http/Admin/Views/setting/oauth_weibo.volt b/app/Http/Admin/Views/setting/oauth_weibo.volt
deleted file mode 100644
index 2415d605..00000000
--- a/app/Http/Admin/Views/setting/oauth_weibo.volt
+++ /dev/null
@@ -1,67 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/app/Http/Admin/Views/setting/oauth_weixin.volt b/app/Http/Admin/Views/setting/oauth_weixin.volt
deleted file mode 100644
index a174498f..00000000
--- a/app/Http/Admin/Views/setting/oauth_weixin.volt
+++ /dev/null
@@ -1,67 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/app/Http/Web/Controllers/OAuthController.php b/app/Http/Web/Controllers/OAuthController.php
deleted file mode 100644
index 9df34aed..00000000
--- a/app/Http/Web/Controllers/OAuthController.php
+++ /dev/null
@@ -1,63 +0,0 @@
-addBehavior(
- new SoftDelete([
- 'field' => 'deleted',
- 'value' => 1,
- ])
- );
- }
-
- public function beforeCreate()
- {
- $this->create_time = time();
- }
-
- public function beforeUpdate()
- {
- $this->update_time = time();
- }
-
-}
diff --git a/app/Models/Course.php b/app/Models/Course.php
index 316d3b1b..92515895 100644
--- a/app/Models/Course.php
+++ b/app/Models/Course.php
@@ -86,6 +86,13 @@ class Course extends Model
*/
public $details;
+ /**
+ * 主分类编号
+ *
+ * @var int
+ */
+ public $category_id;
+
/**
* 市场价格
*
diff --git a/app/Repos/Account.php b/app/Repos/Account.php
index fb1cf58d..680ab79c 100644
--- a/app/Repos/Account.php
+++ b/app/Repos/Account.php
@@ -3,7 +3,6 @@
namespace App\Repos;
use App\Models\Account as AccountModel;
-use App\Models\AccountBind as AccountBindModel;
use Phalcon\Mvc\Model;
use Phalcon\Mvc\Model\Resultset;
use Phalcon\Mvc\Model\ResultsetInterface;
@@ -44,23 +43,6 @@ class Account extends Repository
]);
}
- /**
- * @param string $provider
- * @param string $openId
- * @return AccountModel|Model|bool
- */
- public function findByOpenId($provider, $openId)
- {
- $bind = AccountBindModel::findFirst([
- 'conditions' => 'provider = ?1 AND open_id = ?2',
- 'bind' => [1 => $provider, 2 => $openId],
- ]);
-
- if (!$bind) return false;
-
- return AccountModel::findFirst($bind->user_id);
- }
-
/**
* @param array $ids
* @param array|string $columns
diff --git a/app/Services/Frontend/Account/PasswordReset.php b/app/Services/Frontend/Account/PasswordReset.php
index 388541e4..ffe5f835 100644
--- a/app/Services/Frontend/Account/PasswordReset.php
+++ b/app/Services/Frontend/Account/PasswordReset.php
@@ -15,13 +15,13 @@ class PasswordReset extends Service
$accountValidator = new AccountValidator();
- $account = $accountValidator->checkLoginName($post['account']);
+ $account = $accountValidator->checkLoginName($post['name']);
$accountValidator->checkPassword($post['new_password']);
$securityValidator = new SecurityValidator();
- $securityValidator->checkVerifyCode($post['account'], $post['verify_code']);
+ $securityValidator->checkVerifyCode($post['name'], $post['verify_code']);
$account->password = $post['new_password'];
diff --git a/app/Services/Frontend/Chapter/CommentList.php b/app/Services/Frontend/Chapter/CommentList.php
index af7d1ee8..e33f82c1 100644
--- a/app/Services/Frontend/Chapter/CommentList.php
+++ b/app/Services/Frontend/Chapter/CommentList.php
@@ -75,8 +75,8 @@ class CommentList extends Service
$comment['mentions'] = $comment['mentions'] ? json_decode($comment['mentions']) : [];
$me = [
- 'agreed' => $votes[$comment['id']]['agreed'] ?? false,
- 'opposed' => $votes[$comment['id']]['opposed'] ?? false,
+ 'agreed' => $votes[$comment['id']]['agreed'] ?? 0,
+ 'opposed' => $votes[$comment['id']]['opposed'] ?? 0,
];
$items[] = [
@@ -115,8 +115,8 @@ class CommentList extends Service
foreach ($votes as $vote) {
$result[$vote->comment_id] = [
- 'agreed' => $vote->type == CommentVoteModel::TYPE_AGREE,
- 'opposed' => $vote->type == CommentVoteModel::TYPE_OPPOSE,
+ 'agreed' => $vote->type == CommentVoteModel::TYPE_AGREE ? 1 : 0,
+ 'opposed' => $vote->type == CommentVoteModel::TYPE_OPPOSE ? 1 : 0,
];
}
diff --git a/app/Services/Frontend/ChapterTrait.php b/app/Services/Frontend/ChapterTrait.php
index 3a80464b..2c9e6a70 100644
--- a/app/Services/Frontend/ChapterTrait.php
+++ b/app/Services/Frontend/ChapterTrait.php
@@ -27,11 +27,7 @@ trait ChapterTrait
return $validator->checkChapter($id);
}
- /**
- * @param ChapterModel $chapter
- * @param UserModel $user
- */
- public function setChapterUser($chapter, $user)
+ public function setChapterUser(ChapterModel $chapter, UserModel $user)
{
$chapterUserRepo = new ChapterUserRepo();
diff --git a/app/Services/Frontend/Course/ChapterList.php b/app/Services/Frontend/Course/ChapterList.php
index b4103757..b94fa56e 100644
--- a/app/Services/Frontend/Course/ChapterList.php
+++ b/app/Services/Frontend/Course/ChapterList.php
@@ -40,11 +40,7 @@ class ChapterList extends Service
return $this->handleChapters($chapters);
}
- /**
- * @param Resultset $chapters
- * @return array
- */
- protected function handleChapters($chapters)
+ protected function handleChapters(Resultset $chapters)
{
if ($chapters->count() == 0) {
return [];
@@ -60,7 +56,7 @@ class ChapterList extends Service
foreach ($treeList as &$chapter) {
foreach ($chapter['children'] as &$lesson) {
- $owned = $this->ownedCourse || $lesson['free'];
+ $owned = ($this->ownedCourse || $lesson['free']) ? 1 : 0;
$progress = $learningMapping[$lesson['id']]['progress'] ?? 0;
$lesson['me'] = [
'owned' => $owned,
@@ -72,12 +68,7 @@ class ChapterList extends Service
return $treeList;
}
- /**
- * @param CourseModel
- * @param UserModel
- * @return array
- */
- protected function getLearningMapping($course, $user)
+ protected function getLearningMapping(CourseModel $course, UserModel $user)
{
if ($user->id == 0) {
return [];
diff --git a/app/Services/Frontend/Course/CourseInfo.php b/app/Services/Frontend/Course/CourseInfo.php
index 3b34d3c0..50ea3113 100644
--- a/app/Services/Frontend/Course/CourseInfo.php
+++ b/app/Services/Frontend/Course/CourseInfo.php
@@ -2,9 +2,13 @@
namespace App\Services\Frontend\Course;
+use App\Caches\CourseChapterList as CourseChapterListCache;
+use App\Caches\CourseTeacherList as CourseTeacherListCache;
use App\Models\Course as CourseModel;
use App\Models\User as UserModel;
+use App\Repos\Course as CourseRepo;
use App\Repos\CourseFavorite as CourseFavoriteRepo;
+use App\Services\Category as CategoryService;
use App\Services\Frontend\CourseTrait;
use App\Services\Frontend\Service;
@@ -26,7 +30,27 @@ class CourseInfo extends Service
protected function handleCourse(CourseModel $course, UserModel $user)
{
- $result = $this->formatCourse($course);
+ $result = [
+ 'id' => $course->id,
+ 'title' => $course->title,
+ 'cover' => kg_ci_img_url($course->cover),
+ 'summary' => $course->summary,
+ 'details' => $course->details,
+ 'keywords' => $course->keywords,
+ 'market_price' => (float)$course->market_price,
+ 'vip_price' => (float)$course->vip_price,
+ 'study_expiry' => $course->study_expiry,
+ 'refund_expiry' => $course->refund_expiry,
+ 'rating' => (float)$course->rating,
+ 'score' => (float)$course->score,
+ 'model' => $course->model,
+ 'level' => $course->level,
+ 'attrs' => $course->attrs,
+ 'user_count' => $course->user_count,
+ 'lesson_count' => $course->lesson_count,
+ 'review_count' => $course->review_count,
+ 'favorite_count' => $course->favorite_count,
+ ];
$me = [
'joined' => 0,
@@ -55,34 +79,73 @@ class CourseInfo extends Service
$me['owned'] = $this->ownedCourse ? 1 : 0;
}
+ $result['category_paths'] = $this->getCategoryPaths($course);
+ $result['teachers'] = $this->getTeachers($course);
+ $result['chapters'] = $this->getChapters($course, $user);
$result['me'] = $me;
return $result;
}
- protected function formatCourse($course)
+ protected function getCategoryPaths(CourseModel $course)
{
- return [
- 'id' => $course->id,
- 'title' => $course->title,
- 'cover' => kg_ci_img_url($course->cover),
- 'summary' => $course->summary,
- 'details' => $course->details,
- 'keywords' => $course->keywords,
- 'market_price' => (float)$course->market_price,
- 'vip_price' => (float)$course->vip_price,
- 'study_expiry' => $course->study_expiry,
- 'refund_expiry' => $course->refund_expiry,
- 'rating' => (float)$course->rating,
- 'score' => (float)$course->score,
- 'model' => $course->model,
- 'level' => $course->level,
- 'attrs' => $course->attrs,
- 'user_count' => $course->user_count,
- 'lesson_count' => $course->lesson_count,
- 'review_count' => $course->review_count,
- 'favorite_count' => $course->favorite_count,
- ];
+ $categoryService = new CategoryService();
+
+ return $categoryService->getNodePaths($course->category_id);
+ }
+
+ protected function getTeachers(CourseModel $course)
+ {
+ $cache = new CourseTeacherListCache();
+
+ return $cache->get($course->id);
+ }
+
+ protected function getChapters(CourseModel $course, UserModel $user)
+ {
+ $cache = new CourseChapterListCache();
+
+ $chapters = $cache->get($course->id);
+
+ $learningMapping = $this->getLearningMapping($course, $user);
+
+ foreach ($chapters as &$chapter) {
+ foreach ($chapter['children'] as &$lesson) {
+ $owned = ($this->ownedCourse || $lesson['free']) ? 1 : 0;
+ $progress = $learningMapping[$lesson['id']]['progress'] ?? 0;
+ $lesson['me'] = [
+ 'owned' => $owned,
+ 'progress' => $progress,
+ ];
+ }
+ }
+
+ return $chapters;
+ }
+
+ protected function getLearningMapping(CourseModel $course, UserModel $user)
+ {
+ if ($user->id == 0) {
+ return [];
+ }
+
+ $courseRepo = new CourseRepo();
+
+ $userLearnings = $courseRepo->findUserLearnings($course->id, $user->id);
+
+ if ($userLearnings->count() == 0) {
+ return [];
+ }
+
+ $mapping = [];
+
+ foreach ($userLearnings as $learning) {
+ $mapping[$learning['chapter_id']] = [
+ 'progress' => $learning['progress'],
+ ];
+ }
+
+ return $mapping;
}
}
diff --git a/app/Services/Frontend/Course/CourseList.php b/app/Services/Frontend/Course/CourseList.php
index ff231dd5..4d69cb1e 100644
--- a/app/Services/Frontend/Course/CourseList.php
+++ b/app/Services/Frontend/Course/CourseList.php
@@ -62,6 +62,8 @@ class CourseList extends Service
'summary' => $course['summary'],
'market_price' => (float)$course['market_price'],
'vip_price' => (float)$course['vip_price'],
+ 'rating' => (float)$course['rating'],
+ 'score' => (float)$course['score'],
'model' => $course['model'],
'level' => $course['level'],
'user_count' => $course['user_count'],
diff --git a/app/Services/Frontend/Course/CourseRelated.php b/app/Services/Frontend/Course/CourseRelated.php
index edda6a05..71f1109b 100644
--- a/app/Services/Frontend/Course/CourseRelated.php
+++ b/app/Services/Frontend/Course/CourseRelated.php
@@ -17,19 +17,7 @@ class CourseRelated extends Service
$listCache = new CourseRelatedListCache();
- $courses = $listCache->get($course->id);
-
- if (!$courses) {
- return [];
- }
-
- $baseUrl = kg_ci_base_url();
-
- foreach ($courses as &$course) {
- $course['cover'] = $baseUrl . $course['cover'];
- }
-
- return $courses;
+ return $listCache->get($course->id);
}
}
diff --git a/app/Services/Frontend/Course/PackageList.php b/app/Services/Frontend/Course/PackageList.php
index 9837e74a..f3e4624b 100644
--- a/app/Services/Frontend/Course/PackageList.php
+++ b/app/Services/Frontend/Course/PackageList.php
@@ -73,8 +73,14 @@ class PackageList extends Service
'summary' => $course->summary,
'market_price' => (float)$course->market_price,
'vip_price' => (float)$course->vip_price,
+ 'rating' => (float)$course['rating'],
+ 'score' => (float)$course['score'],
'model' => $course->model,
'level' => $course->level,
+ 'user_count' => $course->user_count,
+ 'lesson_count' => $course->lesson_count,
+ 'review_count' => $course->review_count,
+ 'favorite_count' => $course->favorite_count,
];
}
diff --git a/app/Services/Frontend/Course/TeacherList.php b/app/Services/Frontend/Course/TeacherList.php
index 45c8f702..c737245b 100644
--- a/app/Services/Frontend/Course/TeacherList.php
+++ b/app/Services/Frontend/Course/TeacherList.php
@@ -17,17 +17,7 @@ class TeacherList extends Service
$listCache = new CourseTeacherListCache();
- $teachers = $listCache->get($course->id);
-
- if (!$teachers) return [];
-
- $baseUrl = kg_ci_base_url();
-
- foreach ($teachers as &$teacher) {
- $teacher['avatar'] = $baseUrl . $teacher['avatar'];
- }
-
- return $teachers;
+ return $listCache->get($course->id);
}
}
diff --git a/app/Services/Frontend/CourseTrait.php b/app/Services/Frontend/CourseTrait.php
index 1e71d9a6..38687fe3 100644
--- a/app/Services/Frontend/CourseTrait.php
+++ b/app/Services/Frontend/CourseTrait.php
@@ -33,11 +33,7 @@ trait CourseTrait
return $validator->checkCourse($id);
}
- /**
- * @param CourseModel $course
- * @param UserModel $user
- */
- public function setCourseUser($course, $user)
+ public function setCourseUser(CourseModel $course, UserModel $user)
{
$courseUserRepo = new CourseUserRepo();
diff --git a/app/Services/Pay.php b/app/Services/Pay.php
index 79184638..ead0f515 100644
--- a/app/Services/Pay.php
+++ b/app/Services/Pay.php
@@ -40,8 +40,9 @@ abstract class Pay extends Service
* 查找交易
*
* @param string $tradeNo
+ * @param string $type
*/
- abstract public function find($tradeNo);
+ abstract public function find($tradeNo, $type);
/**
* 关闭交易
diff --git a/app/Services/Pay/Alipay.php b/app/Services/Pay/Alipay.php
index 14af8803..2c228ea1 100644
--- a/app/Services/Pay/Alipay.php
+++ b/app/Services/Pay/Alipay.php
@@ -116,15 +116,16 @@ class Alipay extends AppPay
* 查询交易(扫码生成订单后可执行)
*
* @param string $outTradeNo
+ * @param string $type
* @return Collection|bool
*/
- public function find($outTradeNo)
+ public function find($outTradeNo, $type = 'wap')
{
try {
- $result = $this->gateway->find([
- 'out_trade_no' => $outTradeNo,
- ]);
+ $order = ['out_trade_no' => $outTradeNo];
+
+ $result = $this->gateway->find($order, $type);
} catch (\Exception $e) {
diff --git a/app/Services/Pay/Wxpay.php b/app/Services/Pay/Wxpay.php
index d7d2aa7b..610f036b 100644
--- a/app/Services/Pay/Wxpay.php
+++ b/app/Services/Pay/Wxpay.php
@@ -115,15 +115,16 @@ class Wxpay extends AppPay
* 查询交易(扫码生成订单后可执行)
*
* @param string $outTradeNo
+ * @param string $type
* @return Collection|bool
*/
- public function find($outTradeNo)
+ public function find($outTradeNo, $type = 'wap')
{
try {
- $result = $this->gateway->find([
- 'out_trade_no' => $outTradeNo,
- ]);
+ $order = ['out_trade_no' => $outTradeNo];
+
+ $result = $this->gateway->find($order, $type);
} catch (\Exception $e) {