quanwei
2026-01-17 e1e2fe5710a5b5cd9c19bd3aa99c998a1a613ca8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?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'];
        }
    }
}