123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- <?php
- namespace JinDouYun\Cache;
- use Mall\Framework\Cache\Redis;
- use Mall\Framework\Core\ResultWrapper;
- use Mall\Framework\Factory;
- class SystemCache
- {
- private static $enterpriseRelationWxAppIdKey = 'enterpriseRelationWxAppIdMapping';
- private static $paymentKey = 'paymentMapping';
- private static $byteDanceSettingKey = 'byteDanceSettingMapping';
- private static $printNumKey = 'printNum';
- private static $uriRelNameKey = 'uriRelName';
-
- public $cache;
-
- public function __construct()
- {
- $this->cache = Factory::cache('mapping');
- }
-
- public function cacheEnterpriseRelationWxAppId($data, $enterpriseId)
- {
- $result = $this->cache->hset(self::$enterpriseRelationWxAppIdKey, $enterpriseId, $data);
- return $result;
- }
-
- public function getAppIdByEnterpriseId($enterpriseId)
- {
- $result = $this->cache->hget(self::$enterpriseRelationWxAppIdKey, $enterpriseId);
- if (!$result) {
- return '';
- }
- return $result;
- }
-
- public function cachePayment($data, $enterpriseId)
- {
- if (is_array($data)) {
- $data = json_encode($data);
- }
- $result = $this->cache->hset(self::$paymentKey, $enterpriseId, $data);
- return $result;
- }
-
- public function getPayment($enterpriseId)
- {
- $result = $this->cache->hget(self::$paymentKey, $enterpriseId);
- if (!$result) {
- return [];
- }
- if (!empty($result)) {
- $result = json_decode($result, true);
- }
- return $result;
- }
-
- public function cacheByteDanceSetting(string $data, int $enterpriseId)
- {
- return $this->cache->hset(self::$byteDanceSettingKey, $enterpriseId, $data);
- }
-
- public function getByteDanceSetting(int $enterpriseId)
- {
- $result = $this->cache->hget(self::$byteDanceSettingKey, $enterpriseId);
- if (!$result) {
- return '';
- }
- return $result;
- }
-
- public function getObjectPrintNum(int $enterpriseId,$no)
- {
- return $this->cache->zscore(self::$printNumKey.'::'.$enterpriseId,$no);
- }
-
- public function delObjectPrintNum(int $enterpriseId,$no)
- {
- return $this->cache->zrem(self::$printNumKey.'::'.$enterpriseId,$no);
- }
-
- public function setObjectPrintNum(int $enterpriseId,$no,$value)
- {
- return $this->cache->zadd(self::$printNumKey.'::'.$enterpriseId,$value,$no);
- }
-
- public function setUriRelName(string $uri,string $name)
- {
- return $this->cache->hset(self::$uriRelNameKey,strtolower($uri),$name);
- }
-
- public function delUriRelName(string $uri)
- {
- return $this->cache->hdel(self::$uriRelNameKey,strtolower($uri));
- }
-
- public function getUriRelName(string $uri)
- {
- $name = $this->cache->hget(self::$uriRelNameKey,strtolower($uri));
- if ($name == false){
- return '';
- }
- return $name;
- }
- }
|