1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-22 03:32:47 +08:00
2020-09-23 21:41:21 +08:00

118 lines
2.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Http\Admin\Services;
use App\Models\Order as OrderModel;
use App\Models\Trade as TradeModel;
use App\Services\Auth\Admin as AdminAuth;
abstract class PayTest extends Service
{
/**
* @var string 支付平台
*/
protected $channel;
/**
* 创建支付宝订单
*
* @return OrderModel
*/
public function createAlipayOrder()
{
/**
* @var AdminAuth $auth
*/
$auth = $this->getDI()->get('auth');
$authUser = $auth->getAuthInfo();
$order = new OrderModel();
$order->subject = '测试 - 支付测试0.01元';
$order->amount = 0.01;
$order->owner_id = $authUser['id'];
$order->item_type = OrderModel::ITEM_TEST;
$order->create();
return $order;
}
/**
* 创建微信订单
*
* @return OrderModel
*/
public function createWxpayOrder()
{
/**
* @var AdminAuth $auth
*/
$auth = $this->getDI()->get('auth');
$authUser = $auth->getAuthInfo();
$config = $this->getConfig();
$order = new OrderModel();
/**
* 微信沙箱环境金额不能自定义只能是固定测试用例值SB的不行
*/
if ($config->get('env') == ENV_DEV) {
$order->subject = '测试 - 支付测试3.01元';
$order->amount = 3.01;
} else {
$order->subject = '测试 - 支付测试0.01元';
$order->amount = 0.01;
}
$order->owner_id = $authUser['id'];
$order->item_type = OrderModel::ITEM_TEST;
$order->create();
return $order;
}
/**
* 创建交易
*
* @param OrderModel $order
* @return TradeModel $trade
*/
public function createTrade(OrderModel $order)
{
$trade = new TradeModel();
$trade->owner_id = $order->owner_id;
$trade->order_id = $order->id;
$trade->subject = $order->subject;
$trade->amount = $order->amount;
$trade->channel = $this->channel;
$trade->create();
return $trade;
}
/**
* 交易状态
*
* @param string $tradeNo
* @return string
*/
abstract public function status($tradeNo);
/**
* 扫码下单
*
* @param TradeModel $trade
* @return string|bool
*/
abstract public function scan(TradeModel $trade);
}