eee
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace wchat\common;
|
||||
|
||||
use JetBrains\PhpStorm\ArrayShape;
|
||||
|
||||
class AppConfig
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected string $appId = '';
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected string $appSecret = '';
|
||||
|
||||
|
||||
/**
|
||||
* @var PayConfig
|
||||
*/
|
||||
protected PayConfig $payConfig;
|
||||
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected int $type;
|
||||
|
||||
|
||||
/**
|
||||
* @var array|string[]
|
||||
*/
|
||||
#[ArrayShape(['token' => 'string', 'secret' => 'string', 'unionId' => 'string'])]
|
||||
protected array $notice = ['token' => '', 'secret' => '', 'unionId' => ''];
|
||||
|
||||
|
||||
/**
|
||||
* @param object $app
|
||||
* @return static
|
||||
*/
|
||||
public static function instance(object $app): static
|
||||
{
|
||||
$model = new static();
|
||||
$model->appId = $app->appId;
|
||||
$model->appSecret = $app->appSecret;
|
||||
$model->type = $app->type;
|
||||
$model->payConfig = PayConfig::parse($app->pay);
|
||||
return $model;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function typeIsApp(): bool
|
||||
{
|
||||
return $this->type === 3;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,6 +22,12 @@ abstract class Multiprogramming implements Progaram
|
||||
protected string $errorMsg = '';
|
||||
|
||||
|
||||
/**
|
||||
* @var PayConfig
|
||||
*/
|
||||
protected PayConfig $payConfig;
|
||||
|
||||
|
||||
/**
|
||||
* @param $message
|
||||
* @param int $code
|
||||
@@ -74,6 +80,22 @@ abstract class Multiprogramming implements Progaram
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PayConfig
|
||||
*/
|
||||
public function getPayConfig(): PayConfig
|
||||
{
|
||||
return $this->payConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PayConfig $payConfig
|
||||
*/
|
||||
public function setPayConfig(PayConfig $payConfig): void
|
||||
{
|
||||
$this->payConfig = $payConfig;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return \wchat\common\Config
|
||||
|
||||
+13
-64
@@ -2,81 +2,30 @@
|
||||
|
||||
namespace wchat\common;
|
||||
|
||||
use JetBrains\PhpStorm\ArrayShape;
|
||||
use wchat\common\libs\Aliyun;
|
||||
use wchat\common\libs\Qq;
|
||||
use wchat\common\libs\Wx;
|
||||
|
||||
class PayConfig
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @var array|string[]
|
||||
* @var Qq
|
||||
*/
|
||||
#[ArrayShape(["appId" => "string", "mchCa" => "string", "mchId" => "string", "mchKey" => "string", "mchCert" => "string", "appSecret" => "string", "mchSecret" => "string"])]
|
||||
protected array $qq = ["appId" => "", "mchCa" => "", "mchId" => "", "mchKey" => "", "mchCert" => "", "appSecret" => "", "mchSecret" => ""];
|
||||
public Qq $qq;
|
||||
|
||||
|
||||
/**
|
||||
* @var array|string[]
|
||||
* @var Wx
|
||||
*/
|
||||
#[ArrayShape(["appId" => "string", "mchId" => "string", "schema" => "string", "mchKey" => "string", "secret" => "string", "mchCert" => "string", "appSecret" => "string", "SerialNumber" => "string"])]
|
||||
protected array $wx = ["appId" => "", "mchId" => "", "schema" => "", "mchKey" => "", "secret" => "", "mchCert" => "", "appSecret" => "", "SerialNumber" => ""];
|
||||
public Wx $wx;
|
||||
|
||||
|
||||
/**
|
||||
* @var array|string[]
|
||||
* @var Aliyun
|
||||
*/
|
||||
#[ArrayShape(["appId" => "string", "appKey" => "string", "appSecret" => "string", "aliPubSecret" => "string", "appPubSecret" => "string", "aliRootSecret" => "string", "openFileState" => "string"])]
|
||||
protected array $ali = ["appId" => "", "appKey" => "", "appSecret" => "", "aliPubSecret" => "", "appPubSecret" => "", "aliRootSecret" => "", "openFileState" => "0"];
|
||||
|
||||
|
||||
/**
|
||||
* @return array|string[]
|
||||
*/
|
||||
#[ArrayShape(["appId" => "string", "mchCa" => "string", "mchId" => "string", "mchKey" => "string", "mchCert" => "string", "appSecret" => "string", "mchSecret" => "string"])] public function getQq(): array
|
||||
{
|
||||
return $this->qq;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string[] $qq
|
||||
*/
|
||||
public function setQq(array $qq): void
|
||||
{
|
||||
$this->qq = $qq;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|string[]
|
||||
*/
|
||||
#[ArrayShape(["appId" => "string", "mchId" => "string", "schema" => "string", "mchKey" => "string", "secret" => "string", "mchCert" => "string", "appSecret" => "string", "SerialNumber" => "string"])] public function getWx(): array
|
||||
{
|
||||
return $this->wx;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string[] $wx
|
||||
*/
|
||||
public function setWx(array $wx): void
|
||||
{
|
||||
$this->wx = $wx;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|string[]
|
||||
*/
|
||||
#[ArrayShape(["appId" => "string", "appKey" => "string", "appSecret" => "string", "aliPubSecret" => "string", "appPubSecret" => "string", "aliRootSecret" => "string", "openFileState" => "string"])]
|
||||
public function getAli(): array
|
||||
{
|
||||
return $this->ali;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string[] $ali
|
||||
*/
|
||||
public function setAli(array $ali): void
|
||||
{
|
||||
$this->ali = $ali;
|
||||
}
|
||||
public Aliyun $ali;
|
||||
|
||||
|
||||
/**
|
||||
@@ -88,10 +37,10 @@ class PayConfig
|
||||
if (is_string($pay)) {
|
||||
$pay = json_decode($pay, true);
|
||||
}
|
||||
$model = new static();
|
||||
foreach ($pay as $key => $value) {
|
||||
$model->$key = $value;
|
||||
}
|
||||
$model = new static();
|
||||
$model->ali = \Kiri::configure(new Aliyun(), $pay['ali']);
|
||||
$model->qq = \Kiri::configure(new Qq(), $pay['qq']);
|
||||
$model->wx = \Kiri::configure(new Wx(), $pay['wx']);
|
||||
return $model;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace wchat\common\libs;
|
||||
|
||||
class Aliyun
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $appId;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $mchCa;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $mchId;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $mchKey;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $mchCert;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $appSecret;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $mchSecret;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace wchat\common\libs;
|
||||
|
||||
class Qq
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $appId;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $mchCa;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $mchId;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $mchKey;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $mchCert;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $appSecret;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $mchSecret;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace wchat\common\libs;
|
||||
|
||||
class Wx
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $appId;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $mchId;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $schema;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $mchKey;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $secret;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $mchCert;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $appSecret;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $serialNumber;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user