|
|
|
@ -85,11 +85,11 @@ class Payment extends BaseModel |
|
|
|
|
$model = new static; |
|
|
|
|
// 默认的支付方式数据 |
|
|
|
|
$defaultData = $model->defaultData(); |
|
|
|
|
if (!$data = Cache::get("payment_{$storeId}_{$merchantId}")) { |
|
|
|
|
if (!$data = Cache::get("11payment_{$storeId}_{$merchantId}")) { |
|
|
|
|
// 获取所有支付方式 |
|
|
|
|
$data = $model->dataByStorage($storeId, $defaultData, $merchantId); |
|
|
|
|
// 写入缓存中 |
|
|
|
|
Cache::tag('cache')->set("payment_{$storeId}_{$merchantId}", $data); |
|
|
|
|
Cache::tag('cache')->set("11payment_{$storeId}_{$merchantId}", $data); |
|
|
|
|
} |
|
|
|
|
// 重组缓存数据 (多维) |
|
|
|
|
return static::reorganize2($defaultData, $data); |
|
|
|
@ -104,9 +104,9 @@ class Payment extends BaseModel |
|
|
|
|
* @throws \think\db\exception\DbException |
|
|
|
|
* @throws \think\db\exception\ModelNotFoundException |
|
|
|
|
*/ |
|
|
|
|
public static function getItem(string $client, int $storeId): array |
|
|
|
|
public static function getItem(string $client, int $storeId, int $merchantId = null): array |
|
|
|
|
{ |
|
|
|
|
return static::getAll($storeId)[$client]; |
|
|
|
|
return static::getAll($storeId, $merchantId)[$client]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -288,10 +288,10 @@ class Payment extends BaseModel |
|
|
|
|
* @throws \think\db\exception\ModelNotFoundException |
|
|
|
|
* @throws BaseException |
|
|
|
|
*/ |
|
|
|
|
public function getMethodsByClient(string $client, bool $balance = true, int $storeId = null): array |
|
|
|
|
public function getMethodsByClient(string $client, bool $balance = true, int $storeId = null, int $merchantId = null): array |
|
|
|
|
{ |
|
|
|
|
$storeId = $storeId ?: self::$storeId; |
|
|
|
|
$group = static::getItem($client, $storeId); |
|
|
|
|
$group = static::getItem($client, $storeId, $merchantId); |
|
|
|
|
$methods = []; |
|
|
|
|
foreach ($group['methods'] as $method) { |
|
|
|
|
if ($method['is_enable'] && ($balance || $method['method'] !== PaymentMethodEnum::BALANCE)) { |
|
|
|
@ -315,10 +315,10 @@ class Payment extends BaseModel |
|
|
|
|
* @throws \think\db\exception\DbException |
|
|
|
|
* @throws \think\db\exception\ModelNotFoundException |
|
|
|
|
*/ |
|
|
|
|
public function getPaymentInfo(string $method, string $client, int $storeId = null) |
|
|
|
|
public function getPaymentInfo(string $method, string $client, int $storeId = null, int $merchantId = null) |
|
|
|
|
{ |
|
|
|
|
// 获取当前指定的支付方式 |
|
|
|
|
$methodInfo = $this->getCurrentMethod($method, $client, $storeId); |
|
|
|
|
$methodInfo = $this->getCurrentMethod($method, $client, $storeId, $merchantId); |
|
|
|
|
// 获取支付模板信息 |
|
|
|
|
$methodInfo['template'] = !$methodInfo['is_must_template'] ? [] : $this->getTemplateInfo($methodInfo['template_id']); |
|
|
|
|
return $methodInfo; |
|
|
|
@ -346,9 +346,9 @@ class Payment extends BaseModel |
|
|
|
|
* @throws \think\db\exception\DbException |
|
|
|
|
* @throws \think\db\exception\ModelNotFoundException |
|
|
|
|
*/ |
|
|
|
|
private function getCurrentMethod(string $method, string $client, int $storeId = null) |
|
|
|
|
private function getCurrentMethod(string $method, string $client, int $storeId = null, int $merchantId = null) |
|
|
|
|
{ |
|
|
|
|
$methods = $this->getMethodsByClient($client, true, $storeId); |
|
|
|
|
$methods = $this->getMethodsByClient($client, true, $storeId, $merchantId); |
|
|
|
|
$method = helper::arraySearch($methods, 'method', $method); |
|
|
|
|
if (empty($method)) { |
|
|
|
|
throwError('很抱歉,当前未找到指定的支付方式'); |
|
|
|
|