Commit 0f2c5103 by 王召彬

Merge branch 'ft-oem' into test

parents 7db2d046 ccabcdc2
......@@ -23,6 +23,24 @@ class CfgCenter
const SELLER_DISTRIBUTION = 'seller_distribution'; //卖家分销配置
/**
* 根据用户token获取配置
*
* @param string $keyName
* @param \Hdll\Services\Common\Entity\User $user
* @return mixed
*/
public static function getByUser($keyName, \Hdll\Services\Common\Entity\User $user)
{
if($user->getOemId() !== null) { // oemId有可能等于0
return self::getByOemId($keyName, $user->getOemId());
} else if($user->getStoreId()) {
return self::getByStoreId($keyName, $user->getStoreId());
} else if($user->getUnionid()) {
return self::getByUnionId($keyName, $user->getUnionid());
}
}
/**
* 根据oemId读取指定的配置项 - 返回数组格式
* (所有配置项,需预先添加到数据库中)
* $cfgdata = CfgCenter::getByOemId(CfgCenter::COS, $oemId);
......@@ -38,33 +56,6 @@ class CfgCenter
}
/**
* 根据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平台的配置
*
......@@ -125,6 +116,33 @@ class CfgCenter
$result = $dbConn->get("config", ['oemId', 'certPem', 'keyPem'], ['oemId' => $oemId, 'name' => $keyName]);
return $result;
}
/**
* 根据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'];
}
public static function dbConnect($database='')
{
......
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