You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
payment/app/Command/MineCommand.php

260 lines
7.9 KiB
PHTML

2 years ago
<?php
declare(strict_types=1);
namespace App\Command;
1 year ago
use App\Helper\Efps\Api;
1 year ago
use App\Helper\Efps\Signer;
1 year ago
use App\Helper\StringHelper;
1 year ago
use App\Request\BindCardRequest;
1 year ago
use App\Request\PaymentQueryRequest;
1 year ago
use App\Request\ProtocolPayConfirmRequest;
1 year ago
use App\Request\RefundQueryRequest;
1 year ago
use App\Request\UnBindCardRequest;
1 year ago
use App\Service\PaymentService;
use Hyperf\Command\Annotation\Command;
2 years ago
use Hyperf\Command\Command as HyperfCommand;
use Hyperf\Contract\ContainerInterface;
/**
* @Command
*/
1 year ago
class MineCommand extends HyperfCommand
2 years ago
{
/**
* @var ContainerInterface
*/
protected $container;
protected $admin;
public function __construct(ContainerInterface $container)
{
$this->container = $container;
1 year ago
parent::__construct('mine');
2 years ago
}
2 years ago
public function configure(): void
2 years ago
{
parent::configure();
1 year ago
$this->setDescription('我的测试');
2 years ago
}
2 years ago
public function handle(): void
2 years ago
{
1 year ago
/**
* @var PaymentService $paymentService
*/
$paymentService = $this->container->make(PaymentService::class);
$params = $this->pay();
$data = $paymentService->payment($params);
var_dump($data);
return;
return;
1 year ago
// $ret = Api::withdrawalToCard([]);
// var_dump($ret);
// return;
/**
* @var PaymentService $paymentService
*/
$paymentService = $this->container->make(PaymentService::class);
$memberId = 'T01';
$protocol = 'p202305296288304915744';
// $result = $paymentService->protocolPayPreRequest($this->prepay($memberId, $protocol, 1));
// var_dump($result);
$token = 'de83e93fc3594dab8d5c8707fcbc8f5c';
$smsCode = '454925';
$result = $paymentService->protocolPayConfirm($this->confirmPay($token, $protocol, $smsCode));
var_dump($result);
return;
1 year ago
// $this->bindCard();
// $this->comfirmBindCard();
// $this->prepay();
// $this->confirmPay();
1 year ago
// $this->refund();
// $this->refundQuery();
1 year ago
// $this->paymentQuery();
$this->unbindCard();
1 year ago
return;
2 years ago
}
1 year ago
public function bindCard()
{
$params = [
'app_id' => '202304270000004',
'timestamp' => time(),
'nonce_str' => StringHelper::getRandomString(32),
'data' => json_encode([
'mchtOrderNo' => time() . rand(1000, 9999),
1 year ago
'memberId' => 'ABC',
'userName' => '测试者',
'phoneNum' => '18888888888',
'bankCardNo' => '62122610000000000',
1 year ago
'bankCardType' => 'debit',
1 year ago
'certificatesNo' => '350000000000000000',
1 year ago
]),
];
$sign = \App\Helper\Platform\Signer::sign($params, 'lSHKbuFngCXHN8Ue1s8QHAAzPvOL3u9O');
$params['sign'] = $sign;
var_dump($params);
$request = new BindCardRequest($params);
$params = $request->getData();
var_dump($params);
}
public function comfirmBindCard()
{
$params = [
'app_id' => '202304270000004',
'timestamp' => time(),
'nonce_str' => StringHelper::getRandomString(32),
'data' => json_encode([
1 year ago
'memberId' => 'ABC',
'smsNo' => 'QY888888888888888',
'smsCode' => '123456',
1 year ago
]),
];
$sign = \App\Helper\Platform\Signer::sign($params, 'lSHKbuFngCXHN8Ue1s8QHAAzPvOL3u9O');
$params['sign'] = $sign;
var_dump($params);
$request = new BindCardRequest($params);
$params = $request->getData();
var_dump($params);
}
1 year ago
public function prepay($memberId, $protocol, $amount)
1 year ago
{
$params = [
'app_id' => '202304270000004',
'timestamp' => time(),
'nonce_str' => StringHelper::getRandomString(32),
'data' => json_encode([
1 year ago
'memberId' => $memberId,
1 year ago
'outTradeNo' => time() . rand(1000, 9999),
1 year ago
'protocol' => $protocol,
'payAmount' => $amount,
1 year ago
]),
];
$sign = \App\Helper\Platform\Signer::sign($params, 'lSHKbuFngCXHN8Ue1s8QHAAzPvOL3u9O');
$params['sign'] = $sign;
1 year ago
return $params;
1 year ago
}
1 year ago
public function confirmPay($token, $protocol, $smsCode)
1 year ago
{
$params = [
'app_id' => '202304270000004',
'timestamp' => time(),
'nonce_str' => StringHelper::getRandomString(32),
'data' => json_encode([
1 year ago
'token' => $token,
'protocol' => $protocol,
'smsCode' => $smsCode,
1 year ago
]),
];
$sign = \App\Helper\Platform\Signer::sign($params, 'lSHKbuFngCXHN8Ue1s8QHAAzPvOL3u9O');
$params['sign'] = $sign;
1 year ago
return $params;
1 year ago
}
public function refund()
{
$params = [
'app_id' => '202304270000004',
'timestamp' => time(),
'nonce_str' => StringHelper::getRandomString(32),
'data' => json_encode([
'outRefundNo' => time() . rand(1000, 9999),
1 year ago
'remark' => 'xxx',
'amount' => 88,
'refundAmount' => 88,
'outTradeNo' => '123423423532',
1 year ago
]),
];
$sign = \App\Helper\Platform\Signer::sign($params, 'lSHKbuFngCXHN8Ue1s8QHAAzPvOL3u9O');
$params['sign'] = $sign;
var_dump($params);
$request = new ProtocolPayConfirmRequest($params);
$params = $request->getData();
var_dump($params);
}
1 year ago
public function refundQuery()
{
$params = [
'app_id' => '202304270000004',
'timestamp' => time(),
'nonce_str' => StringHelper::getRandomString(32),
'data' => json_encode([
1 year ago
'outRefundNo' => '237427342388',
1 year ago
]),
];
$sign = \App\Helper\Platform\Signer::sign($params, 'lSHKbuFngCXHN8Ue1s8QHAAzPvOL3u9O');
$params['sign'] = $sign;
var_dump($params);
$request = new RefundQueryRequest($params);
$params = $request->getData();
var_dump($params);
}
public function paymentQuery()
{
$params = [
'app_id' => '202304270000004',
'timestamp' => time(),
'nonce_str' => StringHelper::getRandomString(32),
'data' => json_encode([
1 year ago
'outTradeNo' => '3423423432',
1 year ago
]),
];
$sign = \App\Helper\Platform\Signer::sign($params, 'lSHKbuFngCXHN8Ue1s8QHAAzPvOL3u9O');
$params['sign'] = $sign;
var_dump($params);
$request = new PaymentQueryRequest($params);
$params = $request->getData();
var_dump($params);
}
1 year ago
public function unbindCard()
{
$params = [
'app_id' => '202304270000004',
'timestamp' => time(),
'nonce_str' => StringHelper::getRandomString(32),
'data' => json_encode([
'protocol' => 'p88888888888888888',
'memberId' => 'ABC',
]),
];
$sign = \App\Helper\Platform\Signer::sign($params, 'lSHKbuFngCXHN8Ue1s8QHAAzPvOL3u9O');
$params['sign'] = $sign;
var_dump($params);
$request = new UnBindCardRequest($params);
$params = $request->getData();
var_dump($params);
}
1 year ago
public function pay()
{
$params = [
'app_id' => '202304270000004',
'timestamp' => time(),
'nonce_str' => StringHelper::getRandomString(32),
'data' => json_encode([
'outOrderNo' => time().rand(1000, 9999),
'outMemberId' => 'T001',
1 year ago
'amount' => 200,
1 year ago
'notifyUrl' => 'https://www.baidu.com',
]),
];
$sign = \App\Helper\Platform\Signer::sign($params, 'lSHKbuFngCXHN8Ue1s8QHAAzPvOL3u9O');
$params['sign'] = $sign;
return $params;
}
2 years ago
}