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

197 lines
5.6 KiB
PHTML

2 years ago
<?php
declare(strict_types=1);
namespace App\Command;
1 year ago
use App\Helper\Platform\Signer;
1 year ago
use App\Helper\StringHelper;
1 year ago
use App\Model\App;
use App\Service\AppService;
use App\Service\MerchantService;
1 year ago
use App\Service\PaymentService;
1 year ago
use App\Service\UserService;
1 year ago
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
$this->register('RLX1990');
1 year ago
}
protected function generateToken() {
return md5('1-' . microtime());
}
protected function createMerchant() {
1 year ago
/**
1 year ago
* @var MerchantService $merchantService
1 year ago
*/
1 year ago
$merchantService = $this->container->make(MerchantService::class);
return $merchantService->createMerchant([
'username' => 'main',
'password' => StringHelper::getRandomString('10'),
1 year ago
'email' => '1427419924@qq.com',
'mobile' => '17788888525',
1 year ago
'ip' => '127.0.0.1'
]);
}
1 year ago
1 year ago
protected function createApp($merchant, $appName) {
1 year ago
/**
1 year ago
* @var AppService $appService
1 year ago
*/
1 year ago
$appService = $this->container->make(AppService::class);
return $appService->createApp($merchant, $appName);
}
1 year ago
1 year ago
protected function createRequestLog($uri, $params) {
/**
* @var RequestService $requestService
*/
$requestService = $this->container->make(RequestService::class);
return $requestService->createRequestLog('/', $params);
}
1 year ago
1 year ago
protected function getApp($appId = '202308040000002') {
return App::where('app_id', $appId)->first();
2 years ago
}
1 year ago
1 year ago
protected function getToken() {
return md5(microtime() . '-' . rand(1000, 9999) );
1 year ago
}
1 year ago
protected function getRequestData() {
$app = $this->getApp();
$data = json_encode([
'userId' => 'ELF1991'
]);
1 year ago
$params = [
1 year ago
'app_id' => $app->app_id,
'nonce_str' => StringHelper::getRandomString(16),
1 year ago
'timestamp' => time(),
1 year ago
'data' => $data,
1 year ago
];
1 year ago
$params['sign'] = Signer::sign($params, $app->app_key);
echo json_encode($params);
1 year ago
}
1 year ago
protected function register($userId = 'ELF1990') {
/**
* @var UserService $userService
*/
$userService = $this->container->make(UserService::class);
$url = $userService->register(['userId' => $userId], $this->getApp(), $this->getToken());
echo $url;
1 year ago
}
1 year ago
protected function companyRegister($userId = 'COMPANY1990')
1 year ago
{
1 year ago
/**
* @var UserService $userService
*/
$userService = $this->container->make(UserService::class);
$url = $userService->companyRegister(['userId' => $userId, 'email' => '360197197@qq.com'], $this->getApp(), $this->getToken());
echo $url;
1 year ago
}
1 year ago
protected function rsyncUser()
1 year ago
{
1 year ago
/**
* @var UserService $userService
*/
$userService = $this->container->make(UserService::class);
$userService->rsyncUser('4673f922e30cfd2efeeb992ff6a32ece', '202308040000002', 'ELF1990');
1 year ago
}
1 year ago
1 year ago
protected function rsyncBankCards() {
/**
* @var UserService $userService
*/
$userService = $this->container->make(UserService::class);
$userService->rsyncBankCards('4673f922e30cfd2efeeb992ff6a32ece');
1 year ago
}
1 year ago
protected function bindCard()
1 year ago
{
1 year ago
/**
* @var UserService $userService
*/
$userService = $this->container->make(UserService::class);
$url = $userService->bindCard(['userId' => 'ELF1990'], $this->getApp(), $this->getToken());
echo $url;
1 year ago
}
1 year ago
1 year ago
protected function payment()
1 year ago
{
1 year ago
/**
* @var PaymentService $paymentService
*/
$paymentService = $this->container->make(PaymentService::class);
$data = [
'userId' => '24',
'agreementNo' => '322022110300000005068',
'notifyUrl' => 'http://www.baidu.com',
'returnUrl' => 'http://www.baidu.com',
'amount' => 10,
'outOrderNo' => time() . rand(1000, 9999),
'expiresIn' => 15*60,
'splitInfoList' => [
[
'userId' => 'ELF1990',
'sellerFlag' => 1,
'amount' => 10,
'subOutOrderNo' => time() . rand(1000, 9999),
]
]
1 year ago
];
1 year ago
$result = $paymentService->payment($data, $this->getApp(), $this->getToken());
var_dump($result);
1 year ago
}
1 year ago
1 year ago
public function pwdForget()
1 year ago
{
1 year ago
/**
* @var UserService $userService
*/
$userService = $this->container->make(UserService::class);
$result = $userService->pwdForget(['userId' => 'ELF1990'], $this->getApp(), $this->getToken());
var_dump($result);
1 year ago
}
1 year ago
1 year ago
public function pwdModify()
1 year ago
{
1 year ago
/**
* @var UserService $userService
*/
$userService = $this->container->make(UserService::class);
$result = $userService->pwdModify(['userId' => 'ELF1990'], $this->getApp(), $this->getToken());
var_dump($result);
1 year ago
}
1 year ago
}