Commit 16e8293b by xmy

Merge remote-tracking branch 'origin/test' into test

parents 81e9feda 7db2d046
...@@ -16,35 +16,63 @@ class CfgCenter ...@@ -16,35 +16,63 @@ class CfgCenter
const ALIYUN_SMS = 'aliyun_sms'; //阿里云短信 const ALIYUN_SMS = 'aliyun_sms'; //阿里云短信
const TENCENT_SMS = 'tencent_sms'; //腾讯云短信 const TENCENT_SMS = 'tencent_sms'; //腾讯云短信
const MP = 'mp'; //公众号-用于H5公众号登录和发送公众号通知 const MP = 'mp'; //公众号-用于H5公众号登录和发送公众号通知
const PAY = 'pay'; //默认的支付平台配置 const PAY = 'pay'; //支付配置
const PAY_YUNMAI = 'pay_yunmai'; //云脉的支付平台配置 const PAY_KUANYUAN = 'pay_kuanyuan'; //宽元的支付平台配置
const PAY_YUNMAI_ISP = 'pay_yunmai_isp'; //云脉的支付服务商配置,用于托管子商户 const PAY_YUNMAI_ISP = 'pay_yunmai_isp'; //云脉的支付服务商配置,用于托管子商户
const PAY_ZHIMEI = 'pay_zhimei'; //致美的支付配置 const PAY_ZHIMEI = 'pay_zhimei'; //致美的支付配置
const SELLER_DISTRIBUTION = 'seller_distribution'; //卖家分销配置 const SELLER_DISTRIBUTION = 'seller_distribution'; //卖家分销配置
/** /**
* 读取指定的配置项 - 返回数组格式 * 根据oemId读取指定的配置项 - 返回数组格式
* (所有配置项,需预先添加到数据库中) * (所有配置项,需预先添加到数据库中)
* $cfgdata = CfgCenter::getArray(CfgCenter::COS); * $cfgdata = CfgCenter::getByOemId(CfgCenter::COS, $oemId);
* var_dump($cfgdata['Weapp']['Region']); // 输出:ap-shanghai * var_dump($cfgdata['Weapp']['Region']); // 输出:ap-shanghai
* *
* @param string $keyName * @param string $keyName
* @param int $oemId oemId==0表示是活动啦啦 * @param int $oemId oemId==0表示是活动啦啦
* @return mixed * @return mixed
*/ */
public static function getArray($keyName, $oemId = 0) public static function getByOemId($keyName, int $oemId)
{ {
return self::_get($keyName, $oemId); return self::_get($keyName, $oemId);
} }
/** /**
* 根据oemId获取支付证书
*
* @param integer $oemId
* @return array
*/
public static function getCertByOemId($keyName, int $oemId) {
$dbConn = self::dbConnect();//连接配置库
// 注意,需要返回oemId字段
$result = $dbConn->get("config", ['oemId', 'certPem', 'keyPem'], ['oemId' => $oemId, 'name' => $keyName]);
return $result;
}
/**
* 根据mchId获取对应的支付配置
*
* @param string $mchId
* @return mixed
*/
public static function getByMchId(int $mchId)
{
$dbConn = self::dbConnect();//连接配置库
$result = $dbConn->get("config", ['value'], ['mchId' => $mchId]);
$resArr = json_decode($result['value'], true);
return is_array($resArr) ? $resArr : $result['value'];
}
/**
* 如果有oemId,尽量使用方法getByOemId()读取配置
* 根据storeId获取所属OEM平台的配置 * 根据storeId获取所属OEM平台的配置
* *
* @param string $keyName * @param string $keyName
* @param string $storeId * @param string $storeId
* @return mixed * @return mixed
*/ */
public static function getByStoreId($keyName, $storeId) public static function getByStoreId($keyName, int $storeId)
{ {
$dbConn = self::dbConnect('seller'); $dbConn = self::dbConnect('seller');
$result = $dbConn->get("seller", ['oemId'], ['storeId' => $storeId]); $result = $dbConn->get("seller", ['oemId'], ['storeId' => $storeId]);
...@@ -52,13 +80,14 @@ class CfgCenter ...@@ -52,13 +80,14 @@ class CfgCenter
} }
/** /**
* 如果有oemId,尽量使用方法getByOemId()读取配置
* 根据sellerId获取所属OEM平台的配置 * 根据sellerId获取所属OEM平台的配置
* *
* @param string $keyName * @param string $keyName
* @param string $sellerId * @param string $sellerId
* @return mixed * @return mixed
*/ */
public static function getBySellerId($keyName, $sellerId) public static function getBySellerId($keyName, int $sellerId)
{ {
$dbConn = self::dbConnect('seller'); $dbConn = self::dbConnect('seller');
$result = $dbConn->get("seller", ['oemId'], ['sellerId' => $sellerId]); $result = $dbConn->get("seller", ['oemId'], ['sellerId' => $sellerId]);
...@@ -66,13 +95,14 @@ class CfgCenter ...@@ -66,13 +95,14 @@ class CfgCenter
} }
/** /**
* 如果有oemId,尽量使用方法getByOemId()读取配置
* 根据unionId获取所属OEM平台的配置 * 根据unionId获取所属OEM平台的配置
* *
* @param string $keyName * @param string $keyName
* @param string $unionId * @param string $unionId
* @return mixed * @return mixed
*/ */
public static function getByUnionId($keyName, $unionId) public static function getByUnionId($keyName, string $unionId)
{ {
$dbConn = self::dbConnect('seller'); $dbConn = self::dbConnect('seller');
$result = $dbConn->get("seller", ['oemId'], ['unionId' => $unionId]); $result = $dbConn->get("seller", ['oemId'], ['unionId' => $unionId]);
...@@ -80,20 +110,7 @@ class CfgCenter ...@@ -80,20 +110,7 @@ class CfgCenter
} }
/** /**
* 根据mchId获取对应的支付配置 * 如果有oemId,尽量使用方法getCertByOemId()读取证书
*
* @param string $mchId
* @return mixed
*/
public static function getByMchId(int $mchId)
{
$dbConn = self::dbConnect();//连接配置库
$result = $dbConn->get("config", ['value'], ['mchId' => $mchId]);
$resArr = json_decode($result['value'], true);
return is_array($resArr) ? $resArr : $result['value'];
}
/**
* 根据店铺id获取支付证书 * 根据店铺id获取支付证书
* *
* @param integer $storeId * @param integer $storeId
...@@ -161,9 +178,17 @@ class CfgCenter ...@@ -161,9 +178,17 @@ class CfgCenter
private static function _getConfigFromDb($keyName, $oemId) private static function _getConfigFromDb($keyName, $oemId)
{ {
$dbConn = self::dbConnect(); $dbConn = self::dbConnect();
$result = $dbConn->select("config", ['name', 'value'], ['oemId' => $oemId, 'name' => $keyName]); $result = $dbConn->select("config", ['value'], ['oemId' => $oemId, 'name' => $keyName]);
if (!isset($result[0]['value'])) { if (!isset($result[0]['value'])) {
return; if($oemId > 0) {
// 如果指定的oemId查找不到,则使用活动啦啦(oemId==0)的配置
$result = $dbConn->select("config", ['value'], ['oemId' => 0, 'name' => $keyName]);
if (!isset($result[0]['value'])) {
return;
}
} else {
return;
}
} }
$valArr = json_decode($result[0]['value'], true); $valArr = json_decode($result[0]['value'], true);
if (!is_array($valArr)) { if (!is_array($valArr)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment