Commit 0f2c5103 by 王召彬

Merge branch 'ft-oem' into test

parents 7db2d046 ccabcdc2
...@@ -23,45 +23,36 @@ class CfgCenter ...@@ -23,45 +23,36 @@ class CfgCenter
const SELLER_DISTRIBUTION = 'seller_distribution'; //卖家分销配置 const SELLER_DISTRIBUTION = 'seller_distribution'; //卖家分销配置
/** /**
* 根据oemId读取指定的配置项 - 返回数组格式 * 根据用户token获取配置
* (所有配置项,需预先添加到数据库中)
* $cfgdata = CfgCenter::getByOemId(CfgCenter::COS, $oemId);
* var_dump($cfgdata['Weapp']['Region']); // 输出:ap-shanghai
* *
* @param string $keyName * @param string $keyName
* @param int $oemId oemId==0表示是活动啦啦 * @param \Hdll\Services\Common\Entity\User $user
* @return mixed * @return mixed
*/ */
public static function getByOemId($keyName, int $oemId) public static function getByUser($keyName, \Hdll\Services\Common\Entity\User $user)
{ {
return self::_get($keyName, $oemId); 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获取支付证书
*
* @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获取对应的支付配置 * 根据oemId读取指定的配置项 - 返回数组格式
* (所有配置项,需预先添加到数据库中)
* $cfgdata = CfgCenter::getByOemId(CfgCenter::COS, $oemId);
* var_dump($cfgdata['Weapp']['Region']); // 输出:ap-shanghai
* *
* @param string $mchId * @param string $keyName
* @param int $oemId oemId==0表示是活动啦啦
* @return mixed * @return mixed
*/ */
public static function getByMchId(int $mchId) public static function getByOemId($keyName, int $oemId)
{ {
$dbConn = self::dbConnect();//连接配置库 return self::_get($keyName, $oemId);
$result = $dbConn->get("config", ['value'], ['mchId' => $mchId]);
$resArr = json_decode($result['value'], true);
return is_array($resArr) ? $resArr : $result['value'];
} }
/** /**
...@@ -126,6 +117,33 @@ class CfgCenter ...@@ -126,6 +117,33 @@ class CfgCenter
return $result; 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='') public static function dbConnect($database='')
{ {
if($database == '') { if($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