<?php

/**
 * Created by PhpStorm.
 * User: tandunzhao
 * Date: 2017/12/7
 * Time: 上午10:10
 */

namespace App\Modules\Trade\Services;

use App\Modules\BaseService;
use App\Modules\Trade\Models\PayMerchant;

/**
 * @method static array getPayConfigByNameStatic(string $name) 获取微信支付配置信息
 */
class PayMerchantService
{
    use BaseService;

    public function getPayConfigByName(string $name)
    {
        $pay_merchant = PayMerchant::where('name', $name)->first();
        $pay_config = json_decode($pay_merchant->config_info);
        return [
            'appid'     => $pay_config->appid,
            'merchant_id'     => $pay_config->merchant_id,
            'key'    => $pay_config->key,
        ];
    }

    /**
     * 根据ID查找
     * @param $id
     * @return mixed
     */
    public static function getPayMerchantSingle($id)
    {
        return PayMerchant::getPayMerchantSingle($id);
    }

    /**
     * 查找所有的支付渠道通道
     * @return mixed
     */
    public static function getPayMerchantSourceList()
    {
        return PayMerchant::getPayMerchantSourceList();
    }
}
