container = $container; parent::__construct('mine'); } public function configure(): void { parent::configure(); $this->setDescription('我的测试'); } public function handle(): void { $merchant = $this->createMerchant(); $app = $this->createApp($merchant, '艺小吧'); var_dump($app->toArray()); } protected function generateToken() { return md5('1-' . microtime()); } protected function createMerchant() { /** * @var MerchantService $merchantService */ $merchantService = $this->container->make(MerchantService::class); return $merchantService->createMerchant([ 'username' => 'main', 'password' => StringHelper::getRandomString('10'), 'email' => '1427419924@qq.com', 'mobile' => '17788888525', 'ip' => '127.0.0.1' ]); } protected function createApp($merchant, $appName) { /** * @var AppService $appService */ $appService = $this->container->make(AppService::class); return $appService->createApp($merchant, $appName); } protected function createRequestLog($uri, $params) { /** * @var RequestService $requestService */ $requestService = $this->container->make(RequestService::class); return $requestService->createRequestLog('/', $params); } protected function getApp($appId = '202308040000002') { return App::where('app_id', $appId)->first(); } protected function getToken() { return md5(microtime() . '-' . rand(1000, 9999) ); } protected function getRequestData() { $app = $this->getApp(); $data = json_encode([ 'userId' => 'ELF1991' ]); $params = [ 'app_id' => $app->app_id, 'nonce_str' => StringHelper::getRandomString(16), 'timestamp' => time(), 'data' => $data, ]; $params['sign'] = Signer::sign($params, $app->app_key); echo json_encode($params); } 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; } protected function companyRegister($userId = 'COMPANY1990') { /** * @var UserService $userService */ $userService = $this->container->make(UserService::class); $url = $userService->companyRegister(['userId' => $userId, 'email' => '360197197@qq.com'], $this->getApp(), $this->getToken()); echo $url; } protected function rsyncUser() { /** * @var UserService $userService */ $userService = $this->container->make(UserService::class); $userService->rsyncUser('4673f922e30cfd2efeeb992ff6a32ece', '202308040000002', 'ELF1990'); } protected function rsyncBankCards() { /** * @var UserService $userService */ $userService = $this->container->make(UserService::class); $userService->rsyncBankCards('4673f922e30cfd2efeeb992ff6a32ece'); } protected function bindCard() { /** * @var UserService $userService */ $userService = $this->container->make(UserService::class); $url = $userService->bindCard(['userId' => 'ELF1990'], $this->getApp(), $this->getToken()); echo $url; } protected function payment() { /** * @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), ] ] ]; $result = $paymentService->payment($data, $this->getApp(), $this->getToken()); var_dump($result); } public function pwdForget() { /** * @var UserService $userService */ $userService = $this->container->make(UserService::class); $result = $userService->pwdForget(['userId' => 'ELF1990'], $this->getApp(), $this->getToken()); var_dump($result); } public function pwdModify() { /** * @var UserService $userService */ $userService = $this->container->make(UserService::class); $result = $userService->pwdModify(['userId' => 'ELF1990'], $this->getApp(), $this->getToken()); var_dump($result); } }