mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-26 20:52:44 +08:00
整理代码
This commit is contained in:
parent
0e77c07f17
commit
089db7e168
@ -57,6 +57,7 @@ class CloseTradeTask extends Task
|
||||
if (!$allowClosed) return;
|
||||
|
||||
$trade->status = TradeModel::STATUS_CLOSED;
|
||||
|
||||
$trade->update();
|
||||
}
|
||||
|
||||
@ -88,6 +89,7 @@ class CloseTradeTask extends Task
|
||||
if (!$allowClosed) return;
|
||||
|
||||
$trade->status = TradeModel::STATUS_CLOSED;
|
||||
|
||||
$trade->update();
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ class TestController extends Controller
|
||||
|
||||
$codeUrl = null;
|
||||
|
||||
if ($code) {
|
||||
if (!empty($code)) {
|
||||
$codeUrl = $this->url->get(
|
||||
['for' => 'web.qrcode_img'],
|
||||
['text' => urlencode($code)]
|
||||
|
29
app/Http/Web/Controllers/AlipayController.php
Normal file
29
app/Http/Web/Controllers/AlipayController.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Web\Controllers;
|
||||
|
||||
use App\Services\Pay\Alipay as AlipayService;
|
||||
use App\Traits\Response as ResponseTrait;
|
||||
|
||||
class AlipayController extends \Phalcon\Mvc\Controller
|
||||
{
|
||||
|
||||
use ResponseTrait;
|
||||
|
||||
/**
|
||||
* @Post("/alipay/notify", name="web.alipay.notify")
|
||||
*/
|
||||
public function notifyAction()
|
||||
{
|
||||
$alipayService = new AlipayService();
|
||||
|
||||
$response = $alipayService->notify();
|
||||
|
||||
if (!$response) exit;
|
||||
|
||||
$response->send();
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
@ -2,6 +2,11 @@
|
||||
|
||||
namespace App\Http\Web\Controllers;
|
||||
|
||||
use App\Services\Frontend\Order\OrderCancel as OrderCancelService;
|
||||
use App\Services\Frontend\Order\OrderConfirm as OrderConfirmService;
|
||||
use App\Services\Frontend\Order\OrderCreate as OrderCreateService;
|
||||
use App\Services\Frontend\Order\OrderInfo as OrderInfoService;
|
||||
|
||||
/**
|
||||
* @RoutePrefix("/order")
|
||||
*/
|
||||
@ -13,7 +18,11 @@ class OrderController extends Controller
|
||||
*/
|
||||
public function confirmAction()
|
||||
{
|
||||
$service = new OrderConfirmService();
|
||||
|
||||
$info = $service->handle();
|
||||
|
||||
$this->view->setVar('info', $info);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -21,47 +30,47 @@ class OrderController extends Controller
|
||||
*/
|
||||
public function createAction()
|
||||
{
|
||||
$service = new OrderCreateService();
|
||||
|
||||
$order = $service->handle();
|
||||
|
||||
return $this->jsonSuccess(['sn' => $order->sn]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Get("/cashier", name="web.order.cashier")
|
||||
* @Get("/{sn:[0-9]+}/pay", name="web.order.pay")
|
||||
*/
|
||||
public function cashierAction()
|
||||
public function payAction($sn)
|
||||
{
|
||||
$service = new OrderInfoService();
|
||||
|
||||
$order = $service->handle($sn);
|
||||
|
||||
$this->view->setVar('order', $order);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Post("/pay", name="web.order.pay")
|
||||
* @Get("/{sn:[0-9]+}/info", name="web.order.info")
|
||||
*/
|
||||
public function payAction()
|
||||
public function infoAction($sn)
|
||||
{
|
||||
$service = new OrderInfoService();
|
||||
|
||||
$order = $service->handle($sn);
|
||||
|
||||
return $this->jsonSuccess(['order' => $order]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Post("/notify/{channel}", name="web.order.notify")
|
||||
* @Post("/{sn:[0-9]+}/cancel", name="web.order.cancel")
|
||||
*/
|
||||
public function notifyAction($channel)
|
||||
public function cancelAction($sn)
|
||||
{
|
||||
$service = new OrderCancelService();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @Post("/status", name="web.order.status")
|
||||
*/
|
||||
public function statusAction()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @Post("/cancel", name="web.order.cancel")
|
||||
*/
|
||||
public function cancelAction()
|
||||
{
|
||||
$order = $service->handle($sn);
|
||||
|
||||
return $this->jsonSuccess(['order' => $order]);
|
||||
}
|
||||
|
||||
}
|
||||
|
41
app/Http/Web/Controllers/TradeController.php
Normal file
41
app/Http/Web/Controllers/TradeController.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Web\Controllers;
|
||||
|
||||
use App\Services\Frontend\Trade\TradeCreate as TradeCreateService;
|
||||
use App\Services\Frontend\Trade\TradeInfo as TradeInfoService;
|
||||
|
||||
/**
|
||||
* @RoutePrefix("/trade")
|
||||
*/
|
||||
class TradeController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* @Post("/create", name="web.trade.create")
|
||||
*/
|
||||
public function createAction()
|
||||
{
|
||||
$service = new TradeCreateService();
|
||||
|
||||
$result = $service->handle();
|
||||
|
||||
return $this->jsonSuccess([
|
||||
'trade_sn' => $result['trade_sn'],
|
||||
'code_url' => $result['code_url'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Get("/{sn:[0-9]+}/status", name="web.trade.status")
|
||||
*/
|
||||
public function statusAction($sn)
|
||||
{
|
||||
$service = new TradeInfoService();
|
||||
|
||||
$trade = $service->handle($sn);
|
||||
|
||||
return $this->jsonSuccess(['status' => $trade->status]);
|
||||
}
|
||||
|
||||
}
|
29
app/Http/Web/Controllers/WxpayController.php
Normal file
29
app/Http/Web/Controllers/WxpayController.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Web\Controllers;
|
||||
|
||||
use App\Services\Pay\Wxpay as WxpayService;
|
||||
use App\Traits\Response as ResponseTrait;
|
||||
|
||||
class WxpayController extends \Phalcon\Mvc\Controller
|
||||
{
|
||||
|
||||
use ResponseTrait;
|
||||
|
||||
/**
|
||||
* @Post("/wxpay/notify", name="web.wxpay.notify")
|
||||
*/
|
||||
public function notifyAction()
|
||||
{
|
||||
$wxpayService = new WxpayService();
|
||||
|
||||
$response = $wxpayService->notify();
|
||||
|
||||
if (!$response) exit;
|
||||
|
||||
$response->send();
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
9
app/Http/Web/Services/Order.php
Normal file
9
app/Http/Web/Services/Order.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Web\Services;
|
||||
|
||||
class Order extends Service
|
||||
{
|
||||
|
||||
|
||||
}
|
@ -120,6 +120,20 @@ class User extends Model
|
||||
*/
|
||||
public $lock_expiry_time;
|
||||
|
||||
/**
|
||||
* 最近登录时间
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $last_login_time;
|
||||
|
||||
/**
|
||||
* 最近登录IP
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $last_login_ip;
|
||||
|
||||
/**
|
||||
* 通知数量
|
||||
*
|
||||
|
@ -11,7 +11,7 @@ use App\Repos\Package as PackageRepo;
|
||||
use App\Services\Frontend\Service;
|
||||
use App\Validators\Order as OrderValidator;
|
||||
|
||||
class ConfirmInfo extends Service
|
||||
class OrderConfirm extends Service
|
||||
{
|
||||
|
||||
public function handle()
|
||||
@ -33,25 +33,22 @@ class ConfirmInfo extends Service
|
||||
if ($itemType == OrderModel::ITEM_COURSE) {
|
||||
|
||||
$course = $validator->checkCourse($itemId);
|
||||
$courseInfo = $this->handleCourseInfo($course);
|
||||
|
||||
$result['item_info']['course'] = $courseInfo;
|
||||
$result['item_info']['course'] = $this->handleCourse($course);
|
||||
$result['amount'] = $user->vip ? $course->vip_price : $course->market_price;
|
||||
|
||||
} elseif ($itemType == OrderModel::ITEM_PACKAGE) {
|
||||
|
||||
$package = $validator->checkPackage($itemId);
|
||||
$packageInfo = $this->handlePackageInfo($package);
|
||||
|
||||
$result['item_info']['package'] = $packageInfo;
|
||||
$result['item_info']['package'] = $this->handlePackage($package);
|
||||
$result['amount'] = $user->vip ? $package->vip_price : $package->market_price;
|
||||
|
||||
} elseif ($itemType == OrderModel::ITEM_VIP) {
|
||||
|
||||
$vip = $validator->checkVip($itemId);
|
||||
$vipInfo = $this->handleVipInfo($vip);
|
||||
|
||||
$result['item_info']['vip'] = $vipInfo;
|
||||
$result['item_info']['vip'] = $this->handleVip($vip);
|
||||
$result['amount'] = $vip->price;
|
||||
|
||||
} elseif ($itemType == OrderModel::ITEM_REWARD) {
|
||||
@ -61,11 +58,8 @@ class ConfirmInfo extends Service
|
||||
$course = $validator->checkCourse($courseId);
|
||||
$reward = $validator->checkReward($rewardId);
|
||||
|
||||
$courseInfo = $this->handleCourseInfo($course);
|
||||
$rewardInfo = $this->handleRewardInfo($reward);
|
||||
|
||||
$result['item_info']['course'] = $courseInfo;
|
||||
$result['item_info']['reward'] = $rewardInfo;
|
||||
$result['item_info']['course'] = $this->handleCourse($course);
|
||||
$result['item_info']['reward'] = $this->handleReward($reward);
|
||||
$result['amount'] = $reward->price;
|
||||
}
|
||||
|
||||
@ -74,12 +68,12 @@ class ConfirmInfo extends Service
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function handleCourseInfo(CourseModel $course)
|
||||
protected function handleCourse(CourseModel $course)
|
||||
{
|
||||
return $this->formatCourseInfo($course);
|
||||
return $this->formatCourse($course);
|
||||
}
|
||||
|
||||
protected function handlePackageInfo(PackageModel $package)
|
||||
protected function handlePackage(PackageModel $package)
|
||||
{
|
||||
$result = [
|
||||
'id' => $package->id,
|
||||
@ -93,13 +87,13 @@ class ConfirmInfo extends Service
|
||||
$courses = $packageRepo->findCourses($package->id);
|
||||
|
||||
foreach ($courses as $course) {
|
||||
$result['courses'][] = $this->formatCourseInfo($course);
|
||||
$result['courses'][] = $this->formatCourse($course);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function handleVipInfo(VipModel $vip)
|
||||
protected function handleVip(VipModel $vip)
|
||||
{
|
||||
return [
|
||||
'id' => $vip->id,
|
||||
@ -109,7 +103,7 @@ class ConfirmInfo extends Service
|
||||
];
|
||||
}
|
||||
|
||||
protected function handleRewardInfo(RewardModel $reward)
|
||||
protected function handleReward(RewardModel $reward)
|
||||
{
|
||||
return [
|
||||
'id' => $reward->id,
|
||||
@ -118,7 +112,7 @@ class ConfirmInfo extends Service
|
||||
];
|
||||
}
|
||||
|
||||
protected function formatCourseInfo(CourseModel $course)
|
||||
protected function formatCourse(CourseModel $course)
|
||||
{
|
||||
$course->cover = kg_ci_img_url($course->cover);
|
||||
|
||||
|
@ -27,6 +27,8 @@ class OrderCancel extends Service
|
||||
$order->status = OrderModel::STATUS_CLOSED;
|
||||
|
||||
$order->update();
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ class OrderCreate extends Service
|
||||
*/
|
||||
if ($order) {
|
||||
$caseA = $order->status == OrderModel::STATUS_PENDING;
|
||||
$caseB = time() - $order->create_time < 6 * 3600;
|
||||
$caseB = time() - $order->create_time < 12 * 3600;
|
||||
if ($caseA && $caseB) {
|
||||
return $order;
|
||||
}
|
||||
|
@ -7,6 +7,13 @@ use App\Validators\Order as OrderValidator;
|
||||
trait OrderTrait
|
||||
{
|
||||
|
||||
public function checkOrderById($id)
|
||||
{
|
||||
$validator = new OrderValidator();
|
||||
|
||||
return $validator->checkOrderById($id);
|
||||
}
|
||||
|
||||
public function checkOrderBySn($sn)
|
||||
{
|
||||
$validator = new OrderValidator();
|
||||
|
35
app/Services/Frontend/Pay/Alipay.php
Normal file
35
app/Services/Frontend/Pay/Alipay.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Frontend\Pay;
|
||||
|
||||
use App\Models\Trade as TradeModel;
|
||||
use App\Services\Frontend\Service;
|
||||
use App\Services\Pay\Alipay as AlipayService;
|
||||
|
||||
class Alipay extends Service
|
||||
{
|
||||
|
||||
public function scan(TradeModel $trade)
|
||||
{
|
||||
$qrCodeUrl = null;
|
||||
|
||||
$alipayService = new AlipayService();
|
||||
|
||||
$text = $alipayService->scan($trade);
|
||||
|
||||
if ($text) {
|
||||
$qrCodeUrl = $this->url->get(
|
||||
['for' => 'web.qrcode_img'],
|
||||
['text' => urlencode($text)]
|
||||
);
|
||||
}
|
||||
|
||||
return $qrCodeUrl;
|
||||
}
|
||||
|
||||
public function wap(TradeModel $trade)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
25
app/Services/Frontend/Pay/Wxpay.php
Normal file
25
app/Services/Frontend/Pay/Wxpay.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Frontend\Pay;
|
||||
|
||||
use App\Services\Frontend\Service;
|
||||
|
||||
class Wxpay extends Service
|
||||
{
|
||||
|
||||
public function scan()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function wap()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function mini()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
18
app/Services/Frontend/Trade/TradeCancel.php
Normal file
18
app/Services/Frontend/Trade/TradeCancel.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Frontend\Trade;
|
||||
|
||||
use App\Services\Frontend\OrderTrait;
|
||||
use App\Services\Frontend\Service;
|
||||
|
||||
class TradeCancel extends Service
|
||||
{
|
||||
|
||||
use OrderTrait;
|
||||
|
||||
public function handle($sn)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Frontend\Order;
|
||||
namespace App\Services\Frontend\Trade;
|
||||
|
||||
use App\Models\Trade as TradeModel;
|
||||
use App\Services\Frontend\OrderTrait;
|
||||
@ -40,38 +40,48 @@ class TradeCreate extends Service
|
||||
|
||||
$trade->create();
|
||||
|
||||
$qrCode = $this->getQrCode($trade);
|
||||
$qrCodeUrl = $this->getQrCodeUrl($trade);
|
||||
|
||||
$this->db->commit();
|
||||
|
||||
return $qrCode;
|
||||
return [
|
||||
'trade_sn' => $trade->sn,
|
||||
'code_url' => $qrCodeUrl,
|
||||
];
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
||||
$this->db->rollback();
|
||||
|
||||
return false;
|
||||
throw new \RuntimeException('trade.create_failed');
|
||||
}
|
||||
}
|
||||
|
||||
protected function getQrCode(TradeModel $trade)
|
||||
protected function getQrCodeUrl(TradeModel $trade)
|
||||
{
|
||||
$qrCode = null;
|
||||
$qrCodeUrl = null;
|
||||
|
||||
if ($trade->channel == TradeModel::CHANNEL_ALIPAY) {
|
||||
|
||||
$alipayService = new AlipayService();
|
||||
|
||||
$qrCode = $alipayService->scan($trade);
|
||||
$text = $alipayService->scan($trade);
|
||||
|
||||
if ($text) {
|
||||
$qrCodeUrl = $this->url->get(
|
||||
['for' => 'web.qrcode_img'],
|
||||
['text' => urlencode($text)]
|
||||
);
|
||||
}
|
||||
|
||||
} elseif ($trade->channel == TradeModel::CHANNEL_WXPAY) {
|
||||
|
||||
$wxpayService = new WxPayService();
|
||||
|
||||
$qrCode = $wxpayService->scan($trade);
|
||||
$qrCodeUrl = $wxpayService->scan($trade);
|
||||
}
|
||||
|
||||
return $qrCode;
|
||||
return $qrCodeUrl;
|
||||
}
|
||||
|
||||
}
|
34
app/Services/Frontend/Trade/TradeInfo.php
Normal file
34
app/Services/Frontend/Trade/TradeInfo.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Frontend\Trade;
|
||||
|
||||
use App\Models\Trade as TradeModel;
|
||||
use App\Services\Frontend\Service;
|
||||
use App\Services\Frontend\TradeTrait;
|
||||
|
||||
class TradeInfo extends Service
|
||||
{
|
||||
|
||||
use TradeTrait;
|
||||
|
||||
public function handle($sn)
|
||||
{
|
||||
$trade = $this->checkTradeBySn($sn);
|
||||
|
||||
return $this->handleTrade($trade);
|
||||
}
|
||||
|
||||
protected function handleTrade(TradeModel $trade)
|
||||
{
|
||||
return [
|
||||
'id' => $trade->id,
|
||||
'sn' => $trade->sn,
|
||||
'subject' => $trade->subject,
|
||||
'amount' => $trade->amount,
|
||||
'channel' => $trade->channel,
|
||||
'status' => $trade->status,
|
||||
'create_time' => $trade->create_time,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
24
app/Services/Frontend/TradeTrait.php
Normal file
24
app/Services/Frontend/TradeTrait.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Frontend;
|
||||
|
||||
use App\Validators\Trade as TradeValidator;
|
||||
|
||||
trait TradeTrait
|
||||
{
|
||||
|
||||
public function checkTradeById($id)
|
||||
{
|
||||
$validator = new TradeValidator();
|
||||
|
||||
return $validator->checkTrade($id);
|
||||
}
|
||||
|
||||
public function checkTradeBySn($id)
|
||||
{
|
||||
$validator = new TradeValidator();
|
||||
|
||||
return $validator->checkTradeBySn($id);
|
||||
}
|
||||
|
||||
}
|
@ -5,12 +5,13 @@ namespace App\Services\Pay;
|
||||
use App\Models\Refund as RefundModel;
|
||||
use App\Models\Trade as TradeModel;
|
||||
use App\Repos\Trade as TradeRepo;
|
||||
use App\Services\Pay as AppPay;
|
||||
use App\Services\Pay as PayService;
|
||||
use Yansongda\Pay\Gateways\Alipay as AlipayGateway;
|
||||
use Yansongda\Pay\Log;
|
||||
use Yansongda\Pay\Pay;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class Alipay extends AppPay
|
||||
class Alipay extends PayService
|
||||
{
|
||||
|
||||
/**
|
||||
@ -19,13 +20,14 @@ class Alipay extends AppPay
|
||||
protected $settings;
|
||||
|
||||
/**
|
||||
* @var \Yansongda\Pay\Gateways\Alipay
|
||||
* @var AlipayGateway
|
||||
*/
|
||||
protected $gateway;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->settings = $this->getSectionSettings('pay.alipay');
|
||||
|
||||
$this->gateway = $this->getGateway();
|
||||
}
|
||||
|
||||
@ -60,6 +62,37 @@ class Alipay extends AppPay
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 移动端支付
|
||||
*
|
||||
* @param TradeModel $trade
|
||||
* @return bool|string
|
||||
*/
|
||||
public function wap(TradeModel $trade)
|
||||
{
|
||||
try {
|
||||
|
||||
$response = $this->gateway->wap([
|
||||
'out_trade_no' => $trade->sn,
|
||||
'total_amount' => $trade->amount,
|
||||
'subject' => $trade->subject,
|
||||
]);
|
||||
|
||||
$result = $response->qr_code ?? false;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
||||
Log::error('Alipay Qrcode Exception', [
|
||||
'code' => $e->getCode(),
|
||||
'message' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
$result = false;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 异步通知
|
||||
*/
|
||||
@ -236,7 +269,7 @@ class Alipay extends AppPay
|
||||
/**
|
||||
* 获取 Gateway
|
||||
*
|
||||
* @return \Yansongda\Pay\Gateways\Alipay
|
||||
* @return AlipayGateway
|
||||
*/
|
||||
public function getGateway()
|
||||
{
|
||||
|
@ -5,13 +5,13 @@ namespace App\Services\Pay;
|
||||
use App\Models\Refund as RefundModel;
|
||||
use App\Models\Trade as TradeModel;
|
||||
use App\Repos\Trade as TradeRepo;
|
||||
use App\Services\Pay as AppPay;
|
||||
use Yansongda\Pay\Gateways\Wechat;
|
||||
use App\Services\Pay as PayService;
|
||||
use Yansongda\Pay\Gateways\Wechat as WechatGateway;
|
||||
use Yansongda\Pay\Log;
|
||||
use Yansongda\Pay\Pay;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class Wxpay extends AppPay
|
||||
class Wxpay extends PayService
|
||||
{
|
||||
|
||||
/**
|
||||
@ -20,13 +20,14 @@ class Wxpay extends AppPay
|
||||
protected $settings;
|
||||
|
||||
/**
|
||||
* @var Wechat
|
||||
* @var WechatGateway
|
||||
*/
|
||||
protected $gateway;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->settings = $this->getSectionSettings('pay.wxpay');
|
||||
|
||||
$this->gateway = $this->getGateway();
|
||||
}
|
||||
|
||||
@ -218,7 +219,7 @@ class Wxpay extends AppPay
|
||||
/**
|
||||
* 获取 Gateway
|
||||
*
|
||||
* @return Wechat
|
||||
* @return WechatGateway
|
||||
*/
|
||||
public function getGateway()
|
||||
{
|
||||
|
@ -13,6 +13,11 @@ use App\Repos\Vip as VipRepo;
|
||||
class Order extends Validator
|
||||
{
|
||||
|
||||
public function checkOrder($id)
|
||||
{
|
||||
return $this->checkOrderById($id);
|
||||
}
|
||||
|
||||
public function checkOrderById($id)
|
||||
{
|
||||
$orderRepo = new OrderRepo();
|
||||
|
@ -11,15 +11,33 @@ class Refund extends Validator
|
||||
|
||||
public function checkRefund($id)
|
||||
{
|
||||
$tradeRepo = new RefundRepo();
|
||||
return $this->checkRefundById($id);
|
||||
}
|
||||
|
||||
$trade = $tradeRepo->findById($id);
|
||||
public function checkRefundById($id)
|
||||
{
|
||||
$refundRepo = new RefundRepo();
|
||||
|
||||
if (!$trade) {
|
||||
$refund = $refundRepo->findById($id);
|
||||
|
||||
if (!$refund) {
|
||||
throw new BadRequestException('refund.not_found');
|
||||
}
|
||||
|
||||
return $trade;
|
||||
return $refund;
|
||||
}
|
||||
|
||||
public function checkRefundBySn($sn)
|
||||
{
|
||||
$refundRepo = new RefundRepo();
|
||||
|
||||
$refund = $refundRepo->findById($sn);
|
||||
|
||||
if (!$refund) {
|
||||
throw new BadRequestException('refund.not_found');
|
||||
}
|
||||
|
||||
return $refund;
|
||||
}
|
||||
|
||||
public function checkReviewStatus($status)
|
||||
|
@ -11,6 +11,11 @@ class Trade extends Validator
|
||||
{
|
||||
|
||||
public function checkTrade($id)
|
||||
{
|
||||
return $this->checkTradeById($id);
|
||||
}
|
||||
|
||||
public function checkTradeById($id)
|
||||
{
|
||||
$tradeRepo = new TradeRepo();
|
||||
|
||||
@ -23,6 +28,19 @@ class Trade extends Validator
|
||||
return $trade;
|
||||
}
|
||||
|
||||
public function checkTradeBySn($sn)
|
||||
{
|
||||
$tradeRepo = new TradeRepo();
|
||||
|
||||
$trade = $tradeRepo->findBySn($sn);
|
||||
|
||||
if (!$trade) {
|
||||
throw new BadRequestException('trade.not_found');
|
||||
}
|
||||
|
||||
return $trade;
|
||||
}
|
||||
|
||||
public function checkChannel($channel)
|
||||
{
|
||||
$list = TradeModel::channelTypes();
|
||||
|
@ -264,6 +264,7 @@ $error['order.trade_expired'] = '交易已过期';
|
||||
* 交易相关
|
||||
*/
|
||||
$error['trade.not_found'] = '交易不存在';
|
||||
$error['trade.create_failed'] = '创建交易失败';
|
||||
$error['trade.invalid_channel'] = '无效的平台类型';
|
||||
$error['trade.invalid_close_action'] = '当前不允许关闭交易';
|
||||
$error['trade.invalid_refund_action'] = '当前不允许交易退款';
|
||||
|
Loading…
x
Reference in New Issue
Block a user