| | |
| | | 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;
|
| | |
|
| | | /**
|
| | |
| | | @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;
|
| | | // 缓存中是否存在uid
|
| | | String cacheValue = redisManager.getCommonString(key);
|
| | | if (cacheValue != null && cacheValue.trim().length() > 0) {
|
| | | return;
|
| | | }
|
| | | // 加入缓存 20分钟
|
| | | redisManager.cacheCommonString(key, uuid.toString(), 60 * 20);
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | 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);
|
| | |
|
| | | // 缓存中是否存在uid
|
| | | 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();
|
| | | }
|
| | | }
|
| | | |
| | | }
|
| | | |
| | | |
| | | }
|