123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Bear
- * Date: 2018/12/10
- * Time: 上午11:53
- */
- namespace app\main\constants;
- use app\main\service\ToutiaoNotifyService;
- use think\Config;
- /**
- * 缓存常量配置信息
- * Class CacheConstants
- * @package app\main\constants
- */
- class CacheConstants
- {
- //推广链接缓存前缀
- const REFERRAL_PREFIX = 'REFE:';
- //用户缓存前缀
- const USER_PREFIX = 'UN:';
- //今日关注
- const SUBSCRIBE_OF_REFERRAL_ID_TODAY = 'RCT:';
- //今日阅读
- const READ_OF_REFERRAL_ID_TODAY = 'RUV_T:';
- //今日净关注
- const SUBSCRIBE_OF_PURE_REFERRAL_ID_TODAY = 'PCT:';
- //今日模糊关注
- const SUBSCRIBE_OF_DIM_REFERRAL_ID_TODAY = 'DCT:';
- //今日取关人数
- const UNSUBSCRIBE_OF_REFERRAL_ID_TODAY = 'UCT:';
- //书籍章节列表新的缓存key
- const BOOK_CHAPTER_LIST_CACHE_CHANGED = 'A04';
- //书籍章节列表老的缓存key
- const BOOK_CHAPTER_LIST_CACHE = 'basedata_chapter_owchcp_';
- //单章节缓存
- const BOOK_CHAPTER_SINGLE = 'BCCT:';
- //是否更新了书籍的redis缓存
- const BOOK_CHAPTER_CACHE_CHANGED_YES = true;
- const BOOK_CHAPTER_CACHE_CHANGED_NO = false;
- //用户代理商ID缓存key
- const USER_AGENT_ID_PREFIX = 'UA:';
- //用户IP缓存key
- const USER_IP_PREFIX = 'UIP:';
- //检测用户今天有没有在这本书扣过费的缓存key
- const BOOK_USER_IS_CONSUME_BOOK_BY_DAY = 'HC:';
- const BOOK_EDITED_CHAPTER = 'edited_chapter:';
- //Book 阅读数 UV过滤
- const BOOK_USER_READ_COUNT = 'BURC:';
- //头条关注窗口时间
- const TOUTIAO_SUB_WINDOW = 3600;
- const GDT_CLICLK_CACHE_EXPIRE_TIME = 86400;
- //清水规则缓存
- const LIGHT_RULE = 'LR';
- /**
- * 用户代理商缓存key
- * @param $user_id
- * @return string
- */
- public static function getAgentCacheKey($user_id)
- {
- return self::USER_AGENT_ID_PREFIX . $user_id;
- }
- //检测用户今天有没有在这本书扣过费
- public static function getUserIsConsumeBookByDayKey($book_id, $user_id)
- {
- return self::BOOK_USER_IS_CONSUME_BOOK_BY_DAY . $user_id . ':' . $book_id . ':' . date("d");
- }
- /**
- * 单章节缓存
- * @param $chapter_id
- * @return string
- */
- public static function getBookSingleChapterCacheKey($chapter_id)
- {
- return self::BOOK_CHAPTER_SINGLE . $chapter_id;
- }
- /**
- * 书籍章节列表新的缓存key
- * @param $book_id
- * @return string
- */
- public static function getBookChapterCacheKeyNew($book_id)
- {
- return self::BOOK_CHAPTER_LIST_CACHE_CHANGED . $book_id;
- }
- /**
- * 书籍章节列表老的缓存key
- * @param $book_id
- * @return string
- */
- public static function getBookChapterCacheKey($book_id)
- {
- return self::BOOK_CHAPTER_LIST_CACHE . $book_id;
- }
- /**
- * 推广链接缓存key
- * @param $user_id
- * @return string
- */
- public static function getReferralCacheKey($user_id)
- {
- return self::REFERRAL_PREFIX . $user_id;
- }
- /**
- * 获取用户缓存key
- * @param $user_id
- * @return string
- */
- public static function getUserCacheKey($user_id)
- {
- return self::USER_PREFIX . $user_id;
- }
- /**
- * 今日关注人数
- * @param $referral_id
- * @return string
- */
- public static function getSubscribeOfReferralIdKey($referral_id)
- {
- return self::SUBSCRIBE_OF_REFERRAL_ID_TODAY . date('Ymd') . ':' . $referral_id;
- }
- /**
- * 今日净关注人数
- * @param $referral_id
- * @return string
- */
- public static function getSubscribeOfPureReferralIdKey($referral_id)
- {
- return self::SUBSCRIBE_OF_PURE_REFERRAL_ID_TODAY . date('Ymd') . ':' . $referral_id;
- }
- /**
- * 今日模糊关注人数
- * @param $referral_id
- * @return string
- */
- public static function getSubscribeOfDimReferralIdKey($referral_id)
- {
- return self::SUBSCRIBE_OF_DIM_REFERRAL_ID_TODAY . date('Ymd') . ':' . $referral_id;
- }
- /**
- * 今日取消关注人数
- * @param $referral_id
- * @return string
- */
- public static function getUnsubscribeOfReferralIdKey($referral_id)
- {
- return self::UNSUBSCRIBE_OF_REFERRAL_ID_TODAY . date('Ymd') . ':' . $referral_id;
- }
- /**
- * 今日阅读人数
- * @param $referral_id
- * @return string
- */
- public static function getReadOfReferralIdKey($referral_id)
- {
- return self::READ_OF_REFERRAL_ID_TODAY . date('Ymd') . ':' . $referral_id;
- }
- /**
- * 获取单个商品信息
- * @param $goods_id
- * @return string
- */
- public static function getGoodsInfoKey($goods_id){
- return "GOODS_ID:{$goods_id}";
- }
- public static function getGoodsAllKey(){
- return 'GOODS_ALL';
- }
- /**
- * 商品列表
- * @param null $business
- * @param null $category
- * @param null $goods_type
- * @param null $is_test
- * @return string
- */
- public static function getGoodsListKey($business = null,$category = null,$goods_type = null,$is_test = null){
- $goods_list_key = 'GOODS_LS';
- if($business !== null){
- $goods_list_key .= ":{$business}";
- }
- if($category !== null){
- $goods_list_key .= ":{$category}";
- }
- if($goods_type !== null){
- $goods_list_key .= ":{$goods_type}";
- }
- if($is_test !== null){
- $goods_list_key .= ":{$is_test}";
- }
- return $goods_list_key;
- }
- /**
- * 商品列表
- * @param null $business
- * @return string
- */
- public static function getGoodsListAppKey($business = null){
- $goods_list_key = 'GOODS_LS_APP';
- if($business !== null){
- $goods_list_key .= ":{$business}";
- }
- return $goods_list_key;
- }
- /**
- * 渠道维度,配号代理商计算到渠道上边,新用户人数
- * @param $channel_id
- * @return string
- */
- public static function getNewUserCacheKey($channel_id)
- {
- return 'KL_C_USER_NEW:' . date('d') .':'. $channel_id;
- }
- /**
- * 起充人数
- * @param $channel_id
- * @return string
- */
- public static function getPayUserLimitCacheKey($channel_id)
- {
- return 'KL_C_USER_LIMIT:' . date('d') .':'. $channel_id;
- }
- /**
- * 老用户活跃人数
- * @param $channel_id
- * @return string
- */
- public static function getOldUserActiveCacheKey($channel_id)
- {
- return 'KL_C_USER_OLD_A:' . date('d') . ':' . $channel_id;
- }
- /**
- * 用户充值完成时间
- * @param $user_id
- * @return string
- */
- public static function getUserPayTimeCacheKey($user_id)
- {
- return 'KL_U_ORDER_T:' . $user_id;
- }
- /**
- * 用户订单完成数
- * @param $user_id
- * @return string
- */
- public static function getUserOrderCompletedCountCacheKey($user_id)
- {
- return 'KL_U_ORDER_C:' . $user_id;
- }
- /**
- * 渠道城市白名单
- * @param $channel_id
- * @return string
- */
- public static function getChannelWhiteCityCacheKey($channel_id)
- {
- return 'KL_C_CITY:' . $channel_id;
- }
- /**
- * 用户阅读章节
- * @param $user_id
- * @return string
- */
- public static function getUserChapterCacheKey($user_id)
- {
- return 'KL_U_CHAPTER:' . $user_id;
- }
- /**
- * 免费看点充值索引
- * @param $user_id
- * @return string
- */
- public static function getFreeKandianUserRechargeListCacheKey($user_id)
- {
- return 'ZR:'.$user_id;
- }
- /**
- * 免费看点充值信息
- * @param $user_id
- * @return string
- */
- public static function getFreeKandianUserRechargeCacheKey($user_id, $recharge_id)
- {
- return 'UR:' . $user_id . ':' . $recharge_id;
- }
- /**
- * 永久看点充值索引
- * @param $user_id
- * @return string
- */
- public static function getKandianUserRechargeListCacheKey($user_id)
- {
- return 'ZRP:'.$user_id;
- }
- /**
- * 永久看点充值信息
- * @param $user_id
- * @param $recharge_id
- * @return string
- */
- public static function getKandianUserRechargeCacheKey($user_id, $recharge_id)
- {
- return 'URP:' . $user_id . ':' . $recharge_id;
- }
- /**
- * 增购缓存限免书籍
- * @param $user_id
- * @return string
- */
- public static function getBuyMoreFreeLimitBookCache($user_id)
- {
- return 'BUYMFL:' . $user_id;
- }
- /**
- * 增购全本免费书籍
- * @param $user_id
- * @param $index
- * @return string
- */
- public static function getBuyMoreFreeBookCache($user_id, $index)
- {
- return 'BUYMF:' . $user_id . ':' . $index;
- }
- /**
- * 增购缓存限免书籍
- * @param $user_id
- * @return string
- */
- public static function getBuyMoreDiscountCache($user_id)
- {
- return 'BUYMD:' . $user_id;
- }
- /**
- * 增购缓存订单
- * @param $out_trade_no
- * @return string
- */
- public static function getBuyMoreOrderCache($out_trade_no)
- {
- return 'BUYMO:' . $out_trade_no;
- }
- /**
- * 内推单页缓存订单
- * @param $out_trade_no
- * @return string
- */
- public static function getSinglePushOrderCache($out_trade_no)
- {
- return 'SINGPO:' . $out_trade_no;
- }
- /**
- * 内推单页资源缓存
- * @param $out_trade_no
- * @return string
- */
- public static function getSinglePushResourceCache($id)
- {
- return 'SGRS:' . $id;
- }
- /**
- * 用户已购买的书籍缓存
- * @param $out_trade_no
- * @return string
- */
- public static function getSinglePushBuyBookCache($userId)
- {
- return 'SINGPB:' . $userId;
- }
- /**
- * 书籍入口追踪
- * @param $user_id
- * @param $book_id
- * @return string
- */
- public static function getTrackCacheKey($user_id, $book_id)
- {
- return 'UTK:' . $user_id . ':' . $book_id;
- }
- /**
- * 书籍入口追踪的过期时间,默认为3天
- * @return int
- */
- public static function getTrackCacheTime()
- {
- $time = (int)Config::get('book_click_expire');
- return $time ? $time : 259200;
- }
- public static function getKlRuleModifyInfo($ruleId)
- {
- return 'KL_C_ADMIN:' . $ruleId;
- }
- /**
- * 章节阅读消费缓存
- * @param $user_id
- * @param $chapter_id
- * @return string
- */
- public static function getConsumeCacheChapter($user_id, $chapter_id)
- {
- return 'CHCACHE:' . $user_id . ':' . $chapter_id;
- }
- /**
- * 头条引导微信关注
- * @param $ip
- * @param $ua
- * @return string
- */
- public static function getGuideWxSubscribe($ip, $ua)
- {
- $ua = ToutiaoNotifyService::instance()->getUaInfo($ua)->data;
- return 'GWS:' . $ip . ':' . $ua;
- }
- /**
- * gdt click_id缓存key
- * @param $ip
- * @param $ua
- * @return string
- */
- public static function gdtClickKey($ip, $ua)
- {
- $ua = ToutiaoNotifyService::instance()->getUaInfo($ua)->data;
- return 'GDTCLC:' . $ip . ':' . $ua;
- }
- /**
- * 用户的gdt click_id
- * @param $user_id
- * @return string
- */
- public static function gdtUserClickKey($user_id)
- {
- return 'UCCID:' . $user_id;
- }
- /**
- * 支付缓存
- * @param $user_id
- * @return string
- */
- public static function getGuideWxPay($user_id)
- {
- return 'GWSPAY:' . $user_id;
- }
- /**
- * 新增获客
- * @param $id
- * @return string
- */
- public static function getGuideWxNewCount($id)
- {
- return 'GWSNC:' . $id;
- }
- /**
- * 新增当日获客
- * @param $id
- * @return string
- */
- public static function getGuideWxDayNewCount($id)
- {
- return 'GWSNC:' .date('d'). $id;
- }
- /**
- * 支付次数累计
- * @param $id
- * @return string
- */
- public static function getGuideWxPayCount($id)
- {
- return 'GWSPC:' . $id;
- }
- /**
- * 支付次数累计
- * @param $id
- * @return string
- */
- public static function getGuideWxDayPayCount($id)
- {
- return 'GWSPC:' .date('d'). $id;
- }
- /**
- * 支付次数累计
- * @param $id
- * @return string
- */
- public static function getGuideWxPayMoney($id)
- {
- return 'GWSPM:' . $id;
- }
- /**
- * 支付次数累计
- * @param $id
- * @return string
- */
- public static function getGuideWxDayPayMoney($id)
- {
- return 'GWSPM:' .date('d'). $id;
- }
- /**
- * 头条落地页渠道配置信息
- * @param $channel_id
- * @return string
- */
- public static function getGuideWxSetting($channel_id)
- {
- return 'GWSS:' . $channel_id;
- }
- /**
- * 小额支付缓存添加
- * @param $userId
- * @return string
- */
- public static function getSmallPayCache($userId)
- {
- return 'SMALLP:'.$userId;
- }
- /**
- * 复粉使用
- * @param $user_id
- * @return string
- */
- public static function getWxpayFunfen($user_id)
- {
- return 'FuFen:' . $user_id;
- }
- /**
- * 复粉使用
- * @param $channel_id
- * @return string
- */
- public static function getChannelWxpayIds($channel_id)
- {
- return 'FuFenChWxId:' . $channel_id;
- }
- /**
- * 浮动条
- * @param $user_id
- * @return string
- */
- public static function getFloatTipsIdsByUserIds($user_id)
- {
- return 'FloatTipIdsUs:' . $user_id;
- }
- /**
- * 浮动条
- * @param $id
- * @return string
- */
- public static function getFloatTipsInfo($id)
- {
- return 'FloatTipsInfo:' . $id;
- }
- /**
- * 浮动条
- * @param $order_id
- * @return string
- */
- public static function getFloatTipsOrderId($order_id)
- {
- return 'FloatTipsOr:' . $order_id;
- }
- /**
- * 浮动条,下单人数
- * @param $float_id
- * @return string
- */
- public static function getFloatTipsOrderUser($float_id)
- {
- return 'FloatTipsOrUser:' . $float_id;
- }
- /**
- * 浮动条,下单人数,当日
- * @param $float_id
- * @return string
- */
- public static function getFloatTipsOrderUserDay($float_id)
- {
- return 'FloatTipsOrUser:' . date('d') . ':' . $float_id;
- }
- /**
- * 浮动条,充值金额
- * @param $float_id
- * @return string
- */
- public static function getFloatTipsOrderMoney($float_id)
- {
- return 'FloatTipsOrMo:' . $float_id;
- }
- /**
- * 浮动条,充值金额,当日
- * @param $float_id
- * @return string
- */
- public static function getFloatTipsOrderMoneyDay($float_id)
- {
- return 'FloatTipsOrMo:' . date('d') . ':' . $float_id;
- }
- /**
- * 章末推荐
- * @param $book_id
- * @return string
- */
- public static function getChapterEndRecommendIds($book_id)
- {
- return 'ChEndBookIds:' . $book_id;
- }
- public static function getCallbackLimitTout($user_id)
- {
- return 'CALLLIMIT:tout:'.$user_id;
- }
- public static function getCallbackLimitUc($user_id)
- {
- return 'CALLLIMIT:uc:'.$user_id;
- }
- public static function getCallbackLimitGdt($user_id)
- {
- return 'CALLLIMIT:gdt:'.$user_id;
- }
- public static function getCallbackLimitMp($user_id)
- {
- return 'CALLLIMIT:mp:'.$user_id;
- }
- public static function getCallbackLimitToutOnce($user_id)
- {
- return 'CALLLIMIT:tout:once:'.$user_id;
- }
- public static function getCallbackLimitUcOnce($user_id)
- {
- return 'CALLLIMIT:uc:once:'.$user_id;
- }
- public static function getCallbackLimitGdtOnce($user_id)
- {
- return 'CALLLIMIT:gdt:once:'.$user_id;
- }
- public static function getCallbackLimitMpOnce($user_id)
- {
- return 'CALLLIMIT:mp:once:'.$user_id;
- }
- public static function getSignReplyCache($channel_id)
- {
- return 'SIGN:'.$channel_id;
- }
- public static function getBookSubCache($user_id)
- {
- return 'UBC:' . $user_id;
- }
- /**
- * 获取高级群发消息当天UV
- * @param $send_channel_message_id
- * @param $time
- * @return string
- */
- public static function getHighMessageUvToDayKey($send_channel_message_id, $time = null)
- {
- $date_time = $time ? date('Ymd', $time) : date('Ymd');
- return "HM_UV_T:{$date_time}:{$send_channel_message_id}";
- }
- /**
- * 获取高级群发消息当天累计充值金额
- * @param $send_channel_message_id
- * @param null $time
- * @return string
- */
- public static function getHighMsgAmountToDayKey($send_channel_message_id)
- {
- $date_time = date('Ymd');
- return "HM_AMOUNT_D:{$date_time}:{$send_channel_message_id}";
- }
- public static function getExportFansUserCache($user_id)
- {
- return 'EFU:'.$user_id;
- }
- public static function getExportFansRow($id)
- {
- return 'EFR:'.$id;
- }
- public static function getChannelKlRuleManageCacheList(){
- return 'CKRML';
- }
- /**
- * 二期导量用户缓存
- * @param $user_id
- * @return string
- */
- public static function getLeadUser($user_id)
- {
- return 'EFC:SC:'.$user_id;
- }
- /**
- * 未充值的缓存
- * @param $user_id
- * @return string
- */
- public static function getFansUnrecharge($user_id)
- {
- return 'EFC:UR:'.$user_id;
- }
- /**
- * 获取用户的客服端缓存
- * @param $user_id
- * @return string
- */
- public static function getUserClientCache($user_id)
- {
- return 'UCC:'.$user_id;
- }
- public static function getChapterFeeCache($channel_id, $book_id)
- {
- return 'CFC:' . $channel_id . ':' . $book_id;
- }
- /**
- * 导量书币赠送次数缓存
- * @param $user_id
- * @return string
- */
- public static function getExportFansGiveKandianCount($user_id)
- {
- return 'EFC:GKC:' . date('d') . ':' . $user_id;
- }
- public static function getQrcodeVisitCache($fromUserName)
- {
- return 'QR_VISIT:'.$fromUserName;
- }
- }
|