data = [ 'uc_id' => $id, ]; switch ($type) { case self::EVENT_TYPE_FORM: $oAna->type = KafkaDotConstants::TYPE_SUBSCRIBE; $cacheKey = UcCacheConstants::getGuideWxNewCount($id); $cacheDayKey = UcCacheConstants::getGuideWxDayNewCount($id); Redis::instance()->incr($cacheKey); $update = [ 'follow' => ['exp', "(follow+1)"], ]; model("UcLandingPage")->update($update, ['id' => $id]); Redis::instance()->incr($cacheDayKey); Redis::instance()->expire($cacheDayKey, 86400); break; case self::EVENT_TYPE_PAY: $oAna->type = KafkaDotConstants::TYPE_ORDER_COMPLETE; $oAna->data['money'] = $money; $cacheKey = UcCacheConstants::getGuideWxPayCount($id); $cacheDayKey = UcCacheConstants::getGuideWxDayPayCount($id); $cacheMoney = UcCacheConstants::getGuideWxPayMoney($id); $cacheDayMoney = UcCacheConstants::getGuideWxDayPayMoney($id); $update = [ 'orders_count' => ['exp', "(orders_count+1)"], 'orders_money' => ['exp', "(orders_money+{$money})"], ]; model("UcLandingPage")->update($update, ['id' => $id]); Redis::instance()->incr($cacheKey); Redis::instance()->incr($cacheDayKey); Redis::instance()->expire($cacheDayKey, 86400); Redis::instance()->expire($cacheDayMoney, 86400); Redis::instance()->incrByFloat($cacheMoney, $money); Redis::instance()->incrByFloat($cacheDayMoney, $money); break; } KafkaDotService::instance()->sendMsg($userinfo['id'], $oAna); } LogService::info('ucreprot: channel_id:'.$userinfo['channel_id'].' user_id: ' .$userinfo['id']. ' : success' . ' type:' . $type . ' :' . $link); } else { //失败了 LogService::info('ucreprot: channel_id:'.$userinfo['channel_id'].' user_id: '.$userinfo['id'].' : error' .$get. ' type:' . $type . ' :' . $link); } return $this->setData(true)->getReturn(); } /** * 检查cache * @param $ip * @param $ua * @param $appid * @return ReturnObject */ public function checkCache($ip, $ua, $appid) { $cacheSub = UcCacheConstants::getGuideWxSubscribe($ip, $ua); $link = Redis::instance()->get($cacheSub); if ($link) { $params = explode('和', $link); if (count($params) == 2) { Redis::instance()->del($cacheSub); return $this->setData($link)->getReturn(); } else if (count($params) >= 3) { if ($params[0] == $appid) { Redis::instance()->del($cacheSub); array_shift($params); $link = implode('和', $params); return $this->setData($link)->getReturn(); } } } return $this->setData(false)->getReturn(); } }