diff --git a/app/Console/Tasks/CleanLogTask.php b/app/Console/Tasks/CleanLogTask.php index 453b41e2..7cc0287a 100644 --- a/app/Console/Tasks/CleanLogTask.php +++ b/app/Console/Tasks/CleanLogTask.php @@ -21,6 +21,7 @@ class CleanLogTask extends Task $this->cleanStorageLog(); $this->cleanAlipayLog(); $this->cleanWxpayLog(); + $this->cleanOrderLog(); $this->cleanRefundLog(); } @@ -120,6 +121,14 @@ class CleanLogTask extends Task $this->cleanLog('wxpay', 30); } + /** + * 清理订单日志 + */ + protected function cleanOrderLog() + { + $this->cleanLog('order', 30); + } + /** * 清理退款日志 */ diff --git a/app/Console/Tasks/OrderTask.php b/app/Console/Tasks/OrderTask.php index 9f938b5b..29afa0ff 100644 --- a/app/Console/Tasks/OrderTask.php +++ b/app/Console/Tasks/OrderTask.php @@ -13,7 +13,6 @@ use App\Repos\CourseUser as CourseUserRepo; use App\Repos\Order as OrderRepo; use App\Repos\User as UserRepo; use App\Services\Smser\Order as OrderSmser; -use Phalcon\Cli\Task; use Phalcon\Mvc\Model; use Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\Model\ResultsetInterface; @@ -25,6 +24,8 @@ class OrderTask extends Task public function mainAction() { + $logger = $this->getLogger('order'); + $tasks = $this->findTasks(); if ($tasks->count() == 0) { @@ -77,6 +78,13 @@ class OrderTask extends Task } $task->update(); + + $logger->info('Order Task Exception ' . kg_json_encode([ + 'line' => $e->getLine(), + 'code' => $e->getCode(), + 'message' => $e->getMessage(), + 'task' => $task->toArray(), + ])); } /** @@ -98,7 +106,7 @@ class OrderTask extends Task $data = [ 'user_id' => $order->user_id, 'course_id' => $order->item_id, - 'expiry_time' => $itemInfo['course']['expiry_time'], + 'expiry_time' => $itemInfo['course']['study_expiry_time'], 'role_type' => CourseUserModel::ROLE_STUDENT, 'source_type' => CourseUserModel::SOURCE_CHARGE, ]; @@ -124,7 +132,7 @@ class OrderTask extends Task $data = [ 'user_id' => $order->user_id, 'course_id' => $course['id'], - 'expiry_time' => $course['expiry_time'], + 'expiry_time' => $course['study_expiry_time'], 'role_type' => CourseUserModel::ROLE_STUDENT, 'source_type' => CourseUserModel::SOURCE_CHARGE, ]; @@ -179,7 +187,7 @@ class OrderTask extends Task $refund->subject = $order->subject; $refund->amount = $order->amount; - $refund->apply_note = '开通失败,自动退款'; + $refund->apply_note = '开通服务失败,自动退款'; $refund->review_note = '自动操作'; $refund->user_id = $order->user_id; $refund->order_id = $order->id; @@ -214,7 +222,7 @@ class OrderTask extends Task /** * @param int $courseId * @param int $userId - * @return ResultsetInterface|Resultset|TaskModel[] + * @return ResultsetInterface|Resultset|CourseUserModel[] */ protected function findPlanChapterUsers($courseId, $userId) { @@ -228,7 +236,7 @@ class OrderTask extends Task /** * @param int $courseId * @param int $userId - * @return ResultsetInterface|Resultset|TaskModel[] + * @return ResultsetInterface|Resultset|CourseUserModel[] */ protected function findPlanLearnings($courseId, $userId) { @@ -267,7 +275,7 @@ class OrderTask extends Task return TaskModel::query() ->where('item_type = :item_type:', ['item_type' => $itemType]) ->andWhere('status = :status:', ['status' => $status]) - ->andWhere('try_count < :try_count:', ['try_count' => $tryCount]) + ->andWhere('try_count < :try_count:', ['try_count' => $tryCount + 1]) ->orderBy('priority ASC') ->limit($limit) ->execute(); diff --git a/app/Console/Tasks/RefundTask.php b/app/Console/Tasks/RefundTask.php index 04cd5cfb..138f118b 100644 --- a/app/Console/Tasks/RefundTask.php +++ b/app/Console/Tasks/RefundTask.php @@ -97,13 +97,15 @@ class RefundTask extends Task $task->try_count += 1; $task->priority += 1; - if ($task->try_count >= self::TRY_COUNT) { + if ($task->try_count > self::TRY_COUNT) { $task->status = TaskModel::STATUS_FAILED; } $task->update(); $logger->info('Refund Task Exception ' . kg_json_encode([ + 'line' => $e->getLine(), + 'code' => $e->getCode(), 'message' => $e->getMessage(), 'task' => $task->toArray(), ])); @@ -186,7 +188,7 @@ class RefundTask extends Task $courseUser->deleted = 1; if ($courseUser->update() === false) { - throw new \RuntimeException('Delete CourseQuery User Failed'); + throw new \RuntimeException('Delete Course User Failed'); } } } @@ -214,7 +216,7 @@ class RefundTask extends Task $courseUser->deleted = 1; if ($courseUser->update() === false) { - throw new \RuntimeException('Delete CourseQuery User Failed'); + throw new \RuntimeException('Delete Course User Failed'); } } } @@ -293,7 +295,7 @@ class RefundTask extends Task return TaskModel::query() ->where('item_type = :item_type:', ['item_type' => $itemType]) ->andWhere('status = :status:', ['status' => $status]) - ->andWhere('try_count < :try_count:', ['try_count' => $tryCount]) + ->andWhere('try_count < :try_count:', ['try_count' => $tryCount + 1]) ->orderBy('priority ASC') ->limit($limit) ->execute(); diff --git a/app/Http/Admin/Controllers/TestController.php b/app/Http/Admin/Controllers/TestController.php index 19bc59e2..ce0118fa 100644 --- a/app/Http/Admin/Controllers/TestController.php +++ b/app/Http/Admin/Controllers/TestController.php @@ -77,11 +77,11 @@ class TestController extends Controller ['text' => urlencode($pushUrl)] ); - $obs = new \stdClass(); + $obs = []; - $position = strrpos($pushUrl, '/'); - $obs->fms_url = substr($pushUrl, 0, $position + 1); - $obs->stream_code = substr($pushUrl, $position + 1); + $pos = strrpos($pushUrl, '/'); + $obs['fms_url'] = substr($pushUrl, 0, $pos + 1); + $obs['stream_code'] = substr($pushUrl, $pos + 1); $this->view->pick('setting/live_push_test'); $this->view->setVar('code_url', $codeUrl); @@ -176,29 +176,29 @@ class TestController extends Controller $order = $alipayTestService->createOrder(); $trade = $alipayTestService->createTrade($order); - $codeUrl = $alipayTestService->scan($trade); + $qrcodeUrl = $alipayTestService->scan($trade); - if ($order && $trade && $codeUrl) { + if ($order && $trade && $qrcodeUrl) { $this->db->commit(); } else { $this->db->rollback(); } $this->view->pick('setting/pay_alipay_test'); - $this->view->setVar('trade_sn', $trade->sn); - $this->view->setVar('code_url', $codeUrl); + $this->view->setVar('sn', $trade->sn); + $this->view->setVar('qrcode_url', $qrcodeUrl); } /** - * @Post("/alipay/status", name="admin.test.alipay_status") + * @Get("/alipay/status", name="admin.test.alipay_status") */ public function alipayStatusAction() { - $tradeSn = $this->request->getPost('trade_sn'); + $sn = $this->request->getQuery('sn'); $alipayTestService = new AlipayTestService(); - $status = $alipayTestService->status($tradeSn); + $status = $alipayTestService->status($sn); return $this->jsonSuccess(['status' => $status]); } @@ -208,11 +208,11 @@ class TestController extends Controller */ public function alipayCancelAction() { - $tradeSn = $this->request->getPost('trade_sn'); + $sn = $this->request->getPost('sn'); $alipayTestService = new AlipayTestService(); - $alipayTestService->cancel($tradeSn); + $alipayTestService->cancel($sn); return $this->jsonSuccess(['msg' => '取消订单成功']); } @@ -228,29 +228,29 @@ class TestController extends Controller $order = $wxpayTestService->createOrder(); $trade = $wxpayTestService->createTrade($order); - $codeUrl = $wxpayTestService->scan($trade); + $qrcodeUrl = $wxpayTestService->scan($trade); - if ($order && $trade && $codeUrl) { + if ($order && $trade && $qrcodeUrl) { $this->db->commit(); } else { $this->db->rollback(); } $this->view->pick('setting/pay_wxpay_test'); - $this->view->setVar('trade_sn', $trade->sn); - $this->view->setVar('code_url', $codeUrl); + $this->view->setVar('sn', $trade->sn); + $this->view->setVar('qrcode_url', $qrcodeUrl); } /** - * @Post("/wxpay/status", name="admin.test.wxpay_status") + * @Get("/wxpay/status", name="admin.test.wxpay_status") */ public function wxpayStatusAction() { - $tradeSn = $this->request->getPost('trade_sn'); + $sn = $this->request->getQuery('sn'); $wxpayTestService = new WxpayTestService(); - $status = $wxpayTestService->status($tradeSn); + $status = $wxpayTestService->status($sn); return $this->jsonSuccess(['status' => $status]); } @@ -260,11 +260,11 @@ class TestController extends Controller */ public function wxpayCancelAction() { - $tradeSn = $this->request->getPost('trade_sn'); + $sn = $this->request->getPost('sn'); $wxpayTestService = new WxpayTestService(); - $wxpayTestService->cancel($tradeSn); + $wxpayTestService->cancel($sn); return $this->jsonSuccess(['msg' => '取消订单成功']); } diff --git a/app/Http/Admin/Controllers/UserController.php b/app/Http/Admin/Controllers/UserController.php index 84a6ccdc..520f539b 100644 --- a/app/Http/Admin/Controllers/UserController.php +++ b/app/Http/Admin/Controllers/UserController.php @@ -104,12 +104,7 @@ class UserController extends Controller $userService->updateAccount($id); } - $location = $this->url->get(['for' => 'admin.user.list']); - - $content = [ - 'location' => $location, - 'msg' => '更新用户成功', - ]; + $content = ['msg' => '更新用户成功']; return $this->jsonSuccess($content); } diff --git a/app/Http/Admin/Views/setting/pay_alipay.volt b/app/Http/Admin/Views/setting/pay_alipay.volt index 701bb604..644d240d 100644 --- a/app/Http/Admin/Views/setting/pay_alipay.volt +++ b/app/Http/Admin/Views/setting/pay_alipay.volt @@ -90,7 +90,7 @@ type: 2, title: '支付宝 - 支付测试', resize: false, - area: ['480px', '300px'], + area: ['640px', '300px'], content: [url, 'no'] }); }); diff --git a/app/Http/Admin/Views/setting/pay_alipay_test.volt b/app/Http/Admin/Views/setting/pay_alipay_test.volt index a7ba81e3..4e5f5c64 100644 --- a/app/Http/Admin/Views/setting/pay_alipay_test.volt +++ b/app/Http/Admin/Views/setting/pay_alipay_test.volt @@ -1,12 +1,12 @@