From 69bee82b81626b82b7f39f0e459e4f56b1699b51 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期三, 13 三月 2019 12:02:16 +0800 Subject: [PATCH] 正式数据库修改 --- fanli/src/main/java/com/yeshi/fanli/aspect/ActiveUserAspect.java | 89 ++++++++++++++++---------------------------- 1 files changed, 32 insertions(+), 57 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/aspect/ActiveUserAspect.java b/fanli/src/main/java/com/yeshi/fanli/aspect/ActiveUserAspect.java index 2667956..ca1eaef 100644 --- a/fanli/src/main/java/com/yeshi/fanli/aspect/ActiveUserAspect.java +++ b/fanli/src/main/java/com/yeshi/fanli/aspect/ActiveUserAspect.java @@ -12,8 +12,6 @@ import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; -import com.yeshi.fanli.entity.accept.AcceptData; -import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.user.UserSystemCouponService; import com.yeshi.fanli.util.RedisManager; @@ -40,78 +38,55 @@ public static final String EDP = "execution(* com.yeshi.fanli.controller.client.*.*(..))"; - @Around(EDP) +// @Around(EDP) public Object activeAround(ProceedingJoinPoint joinPoint) throws Throwable { + Long uid = null; + ServletRequestAttributes servletContainer = (ServletRequestAttributes) RequestContextHolder .getRequestAttributes(); + HttpServletRequest request = servletContainer.getRequest(); - final Object[] args = joinPoint.getArgs(); + String str_uid = request.getParameter("uid"); + if (str_uid != null && str_uid.trim().length() > 0) { + uid = Long.parseLong(str_uid); + } - final HttpServletRequest request = servletContainer.getRequest(); + + final Long uuid = uid; executor.execute(new Runnable() { @Override public void run() { - AcceptData acceptData = null; - for (Object argsobj : args) { - if (argsobj instanceof AcceptData) { - acceptData = (AcceptData) argsobj; - } + if (uuid == null) { + return; } - // 鑷姩棰嗗彇鍒�-绯荤粺鍙戞斁 - receivedPushCoupon(acceptData, request); + // 缂撳瓨uid鐨凨ey + String key = "activeUid_" + uuid; + + // 缂撳瓨涓槸鍚﹀瓨鍦╱id + String cacheValue = redisManager.getCommonString(key); + if (cacheValue != null && cacheValue.trim().length() > 0) { + return; + } + + // 鍔犲叆缂撳瓨 20鍒嗛挓 + redisManager.cacheCommonString("activeUid_" + uuid, uuid.toString(), 60 * 20); + + + // 鎺ユ敹鍒� + try { + userSystemCouponService.receivedCoupon(uuid); + } catch (Exception e) { + e.printStackTrace(); + } } }); + Object[] args = joinPoint.getArgs(); return joinPoint.proceed(args); } - - - /** - * 浣跨敤涓� 鑷姩棰嗗彇绯荤粺鎺ㄩ�佸埜 - * @param acceptData - * @param request - */ - public void receivedPushCoupon(AcceptData acceptData, HttpServletRequest request) { - - if (acceptData == null) { - return; - } - - String strUid = request.getParameter("uid"); - if (strUid == null || strUid.trim().length() == 0) { - return; - } - - try { - Long uid = Long.parseLong(strUid); - - // 缂撳瓨涓槸鍚﹀瓨鍦╱id - String key = "activeUid_" + uid; - String cacheValue = redisManager.getCommonString(key); - if (cacheValue != null && cacheValue.trim().length() > 0) { - return; - } - - // 鍔犲叆缂撳瓨 20鍒嗛挓 - redisManager.cacheCommonString("activeUid_" + uid, strUid, 60 * 20); - - // 鎺ユ敹鍒� - userSystemCouponService.receivedCoupon(uid); - - } catch (Exception e) { - try { - LogHelper.errorDetailInfo(e); - } catch (Exception e1) { - e1.printStackTrace(); - } - } - - } - - } -- Gitblit v1.8.0