From b6c37e4bc38db88a360d0f2c6099183f9bb75bdc Mon Sep 17 00:00:00 2001 From: yujian <yujian> Date: 星期一, 22 四月 2019 14:31:59 +0800 Subject: [PATCH] 券推送插入 --- fanli/src/main/java/com/yeshi/fanli/aspect/ActiveUserAspect.java | 93 ++++++++++++++++------------------------------ 1 files changed, 33 insertions(+), 60 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..71ecd98 100644 --- a/fanli/src/main/java/com/yeshi/fanli/aspect/ActiveUserAspect.java +++ b/fanli/src/main/java/com/yeshi/fanli/aspect/ActiveUserAspect.java @@ -12,9 +12,8 @@ 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; /** @@ -23,9 +22,9 @@ * @author Administrator * */ -//@Component -//@Aspect -//@Order(6) +@Component +@Aspect +@Order(6) public class ActiveUserAspect { @Resource(name = "taskExecutor") @@ -43,75 +42,49 @@ @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); + if (Constant.IS_OUTNET) { + String key = "activeUid_" + uuid; + // 缂撳瓨涓槸鍚﹀瓨鍦╱id + String cacheValue = redisManager.getCommonString(key); + if (cacheValue != null && cacheValue.trim().length() > 0) { + return; + } + // 鍔犲叆缂撳瓨 20鍒嗛挓 + redisManager.cacheCommonString(key, uuid.toString(), 60 * 20); + } + + // 鎺ユ敹鍒� + try { + userSystemCouponService.receivedCoupon(uuid); + } catch (Exception e) { + e.printStackTrace(); + } } }); - return joinPoint.proceed(args); + return joinPoint.proceed(joinPoint.getArgs()); } - - - /** - * 浣跨敤涓� 鑷姩棰嗗彇绯荤粺鎺ㄩ�佸埜 - * @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