文件
xionggeshop/addons/shopro/library/split/Config.php

91 行
2.2 KiB
PHP

<?php
namespace addons\shopro\library\split;
use addons\shopro\model\split\Config as ConfigModel;
class Config
{
protected $config = [];
public function __construct()
{
$this->config = ConfigModel::column('value', 'name');
}
public function isEnable()
{
return boolval($this->config['split_enable'] ?? 0);
}
public function getMode()
{
return $this->config['split_mode'] ?? 'wechat';
}
public function isHuifuMode()
{
if ($this->getMode() === 'huifu') {
return true;
}
$provider = $this->config['split_provider'] ?? 'auto';
if ($provider === 'huifu') {
return true;
}
if ($provider === 'auto' && class_exists('\\addons\\shopro_huifu\\library\\Bridge')) {
return \addons\shopro_huifu\library\Bridge::isHuifuMiniProgramChannel('wxMiniProgram');
}
return false;
}
public function shouldSkipWallet()
{
return in_array($this->getMode(), ['wechat', 'huifu', 'both']);
}
public function getTiming()
{
return $this->config['split_timing'] ?? 'payed';
}
public function getAmountSource()
{
return $this->config['split_amount_source'] ?? 'mixed';
}
public function getMaxRate()
{
return floatval($this->config['split_max_rate'] ?? 30);
}
public function getRetryMax()
{
return intval($this->config['split_retry_max'] ?? 5);
}
public function getRetryInterval()
{
return intval($this->config['split_retry_interval'] ?? 300);
}
public function getPlatformReceiverAccount()
{
return $this->config['platform_receiver_account'] ?? '';
}
public function getPlatformReceiverName()
{
return $this->config['platform_receiver_name'] ?? '平台';
}
public function getPlatformHuifuId()
{
return $this->config['platform_huifu_id'] ?? '';
}
public function all()
{
return $this->config;
}
}