From f5ad4a8171b20ab75eaac90c9717fe7fd801d6cd Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 08 三月 2019 16:18:25 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- fanli/src/main/java/com/yeshi/fanli/aspect/ActiveUserAspect.java | 102 +++++++++++++++++++++++---------------------------- 1 files changed, 46 insertions(+), 56 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 08f1d3e..ca1eaef 100644 --- a/fanli/src/main/java/com/yeshi/fanli/aspect/ActiveUserAspect.java +++ b/fanli/src/main/java/com/yeshi/fanli/aspect/ActiveUserAspect.java @@ -1,7 +1,5 @@ package com.yeshi.fanli.aspect; -import java.io.IOException; - import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; @@ -9,16 +7,13 @@ import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.springframework.core.annotation.Order; +import org.springframework.core.task.TaskExecutor; import org.springframework.stereotype.Component; 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.Constant; import com.yeshi.fanli.util.RedisManager; -import com.yeshi.fanli.util.ThreadUtil; /** * 娲昏穬鐢ㄦ埛澶勭悊 @@ -30,6 +25,9 @@ //@Aspect //@Order(6) public class ActiveUserAspect { + + @Resource(name = "taskExecutor") + private TaskExecutor executor; @Resource private RedisManager redisManager; @@ -37,65 +35,57 @@ @Resource private UserSystemCouponService userSystemCouponService; + public static final String EDP = "execution(* com.yeshi.fanli.controller.client.*.*(..))"; - @Around(EDP) +// @Around(EDP) public Object activeAround(ProceedingJoinPoint joinPoint) throws Throwable { - Object[] args = joinPoint.getArgs(); - if (!Constant.IS_OUTNET) { - return joinPoint.proceed(args); // 澶栫綉鐜 + Long uid = null; + + ServletRequestAttributes servletContainer = (ServletRequestAttributes) RequestContextHolder + .getRequestAttributes(); + HttpServletRequest request = servletContainer.getRequest(); + + String str_uid = request.getParameter("uid"); + if (str_uid != null && str_uid.trim().length() > 0) { + uid = Long.parseLong(str_uid); } + + + final Long uuid = uid; + + executor.execute(new Runnable() { + @Override + public void run() { + + if (uuid == null) { + return; + } + + // 缂撳瓨uid鐨凨ey + String key = "activeUid_" + uuid; + + // 缂撳瓨涓槸鍚﹀瓨鍦╱id + String cacheValue = redisManager.getCommonString(key); + if (cacheValue != null && cacheValue.trim().length() > 0) { + return; + } - try { - - System.out.println("----------娲昏穬楠岃瘉---------------"); - - ServletRequestAttributes servletContainer = (ServletRequestAttributes) RequestContextHolder - .getRequestAttributes(); - - HttpServletRequest request = servletContainer.getRequest(); - - String strUid = request.getParameter("uid"); - if (strUid == null || strUid.trim().length() == 0) { - return joinPoint.proceed(args); - } - - Long uid = Long.parseLong(strUid); - - String key = "activeUid_" + uid; - - String cacheValue = redisManager.getCommonString(key); - if (cacheValue != null && cacheValue.trim().length() > 0) { - return joinPoint.proceed(args); - } - - // 鍔犲叆缂撳瓨 - redisManager.cacheCommonString("activeUid_" + uid, strUid, 60); - - AcceptData acceptData = null; - for (Object argsobj : args) { - if (argsobj instanceof AcceptData) { - acceptData = (AcceptData) argsobj; + // 鍔犲叆缂撳瓨 20鍒嗛挓 + redisManager.cacheCommonString("activeUid_" + uuid, uuid.toString(), 60 * 20); + + + // 鎺ユ敹鍒� + try { + userSystemCouponService.receivedCoupon(uuid); + } catch (Exception e) { + e.printStackTrace(); } } - - if (acceptData == null) { - return joinPoint.proceed(args); - } - - int platformType = 0; - String platform = acceptData.getPlatform(); - if ("android".equals(platform)) { - platformType = 1; - } else if ("ios".equals(platform)) { - platformType = 2; - } - userSystemCouponService.copyLotteryPrize(uid, platformType, acceptData.getDevice()); - } catch (Exception e) { - e.printStackTrace(); - } + }); + Object[] args = joinPoint.getArgs(); return joinPoint.proceed(args); } -- Gitblit v1.8.0