enterpriseId = $enterpriseId; $this->userCenterId = $userCenterId; $this->cache = Factory::cache('mapping'); } /**---------------------------------------------商户------------------------------------------------**/ /** * 添加 * @param $merchantId * @param $merchantData * @return bool */ public function addMerchant($merchantId, $merchantData) { $data = json_encode($merchantData); $result = $this->cache->hset($this->cacheKey, $merchantId, $data); if(!$result){ return false; } return true; } /** * 查询 * @param $merchantId * @param $key * @return array */ public function getMerchant($merchantId, $key = false) { $result = $this->cache->hget($this->cacheKey, $merchantId); if (!$result) return []; $returnData = json_decode($result, true); if($key){ return $returnData[$key]; } return $returnData; } /** * 删除 * @param $merchantId */ public function delMerchant($merchantId = false) { if($merchantId){ $this->cache->hdel($this->cacheKey, $merchantId); }else{ $this->cache->del($this->cacheKey); } } }