eee
This commit is contained in:
+15
-1
@@ -3,6 +3,9 @@
|
||||
namespace wchat\common;
|
||||
|
||||
use JetBrains\PhpStorm\ArrayShape;
|
||||
use wchat\common\libs\Aliyun;
|
||||
use wchat\common\libs\Qq;
|
||||
use wchat\common\libs\Wx;
|
||||
|
||||
class AppConfig
|
||||
{
|
||||
@@ -55,6 +58,15 @@ class AppConfig
|
||||
public array $notice = ['token' => '', 'secret' => '', 'unionId' => ''];
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->pay = new PayConfig();
|
||||
$this->pay->wx = new Wx();
|
||||
$this->pay->qq = new Qq();
|
||||
$this->pay->ali = new Aliyun();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param object $app
|
||||
* @return static
|
||||
@@ -65,7 +77,9 @@ class AppConfig
|
||||
$model->appId = $app->appId;
|
||||
$model->appSecret = $app->appSecret;
|
||||
$model->type = $app->type;
|
||||
$model->pay = PayConfig::parse($app->pay);
|
||||
|
||||
PayConfig::parse($app->pay, $model->pay);
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,17 +30,24 @@ class PayConfig
|
||||
|
||||
/**
|
||||
* @param string|array $pay
|
||||
* @param PayConfig|null $model
|
||||
* @return static
|
||||
*/
|
||||
public static function parse(string|array $pay): static
|
||||
public static function parse(string|array $pay, ?PayConfig $model = null): static
|
||||
{
|
||||
if (is_string($pay)) {
|
||||
$pay = json_decode($pay, true);
|
||||
}
|
||||
if ($model === null) {
|
||||
$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']);
|
||||
} else {
|
||||
$model->ali = \Kiri::configure($model->ali, $pay['ali']);
|
||||
$model->qq = \Kiri::configure($model->qq, $pay['qq']);
|
||||
$model->wx = \Kiri::configure($model->wx, $pay['wx']);
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user