123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace Service;
- use Mall\Framework\Factory;
- class BaseController {
-
- static $webstockAndKey = 'webstockAndKey';
- public function sendOutput($data, $errorcode = 0)
- {
- $errorcode = intval($errorcode);
- if ($errorcode) {
- $sendMessage = [
- 'state' => false,
- 'data' => $data,
- 'errorcode' => $errorcode
- ];
- } else {
- $sendMessage = [
- 'state' => true,
- 'data' => $data,
- 'errorcode' => $errorcode
- ];
- }
- return json_encode($sendMessage, JSON_UNESCAPED_UNICODE);
- }
-
- public function webstockConnectInfo($fromId, $redisKey)
- {
-
- $writeCache = Factory::cache('default')->hset(self::$webstockAndKey, $fromId, $redisKey);
- }
-
- public function closeWebstock($fromId)
- {
- $data = Factory::cache('default')->hget(self::$webstockAndKey, $fromId);
- if(empty($data)){
- return false;
- }
- $data = explode('|', $data);
- $result = Factory::cache('default')->hdel($data[0], $data[1]);
- $result = Factory::cache('default')->hdel(self::$webstockAndKey, $fromId);
- return $result;
- }
- }
|