<?php
|
|
namespace app\common\model\app;
|
|
use app\common\exception\BaseException;
|
use think\facade\Cache;
|
use app\common\model\BaseModel;
|
use app\common\enum\settings\PlatformEnum;
|
|
/**
|
* 应用模型
|
*/
|
class AppPay extends BaseModel
|
{
|
protected $name = 'app_pay';
|
protected $pk = 'shop_supplier_id';
|
|
/**
|
* 获取商户支付信息
|
*/
|
public static function detail($shop_supplier_id = null)
|
{
|
$detail = (new static())->find($shop_supplier_id);
|
if (!empty($detail['pay_type'])) {
|
$detail['pay_type'] = json_decode($detail['pay_type'], true);
|
}
|
return $detail;
|
}
|
|
/**
|
* 从缓存中获取商户支付信息
|
*/
|
public static function getAppCache($shop_supplier_id = null)
|
{
|
if (!$data = Cache::get('app_pay' . $shop_supplier_id)) {
|
$data = self::detail($shop_supplier_id);
|
if (empty($data)) throw new BaseException(['msg' => '未找到当前商户支付信息']);
|
Cache::tag('cache')->set('app_pay' . $shop_supplier_id, $data);
|
}
|
return $data;
|
}
|
|
|
|
|
public static function getPayType($shop_supplier_id, $pay_source)
|
{
|
$detail = self::detail($shop_supplier_id);
|
if (empty($detail['pay_type'])) {
|
return PlatformEnum::data()[$pay_source]['pay_type'];
|
} else {
|
return $detail['pay_type'][$pay_source]['pay_type'];
|
}
|
}
|
}
|