diff --git a/framework/pom.xml b/framework/pom.xml index ba3991db..de8a3431 100644 --- a/framework/pom.xml +++ b/framework/pom.xml @@ -14,6 +14,8 @@ jar + 1.8 + 1.9.6 4.13.40.ALL 5.1.48 @@ -39,7 +41,6 @@ 2.9.10 UTF-8 UTF-8 - 1.8 true 2.0.8 2.3.1 diff --git a/framework/src/main/java/cn/lili/common/security/context/UserContext.java b/framework/src/main/java/cn/lili/common/security/context/UserContext.java index d88e5c2c..01c29910 100644 --- a/framework/src/main/java/cn/lili/common/security/context/UserContext.java +++ b/framework/src/main/java/cn/lili/common/security/context/UserContext.java @@ -24,15 +24,14 @@ import javax.servlet.http.HttpServletRequest; */ public class UserContext { - private static RequestContextHolder requestContextHolder; - - public static void setRequestContextHolder(RequestContextHolder requestContextHolder) { - UserContext.requestContextHolder = requestContextHolder; - } - + /** + * 根据request获取用户信息 + * + * @return + */ public static AuthUser getCurrentUser() { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); - String accessToken = request.getHeader("accessToken"); + String accessToken = request.getHeader(SecurityEnum.HEADER_TOKEN.getValue()); return getAuthUser(accessToken); } @@ -54,8 +53,10 @@ public class UserContext { return null; } } + /** * 根据jwt获取token重的用户信息 + * * @param accessToken token * @return */ diff --git a/framework/src/main/java/cn/lili/common/trigger/message/PromotionMessage.java b/framework/src/main/java/cn/lili/common/trigger/message/PromotionMessage.java index 7290b974..1ec5c1ae 100644 --- a/framework/src/main/java/cn/lili/common/trigger/message/PromotionMessage.java +++ b/framework/src/main/java/cn/lili/common/trigger/message/PromotionMessage.java @@ -1,7 +1,5 @@ package cn.lili.common.trigger.message; -import cn.lili.modules.promotion.entity.enums.PromotionStatusEnum; -import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -43,10 +41,4 @@ public class PromotionMessage { */ private Date endTime; - public UpdateWrapper updateWrapper() { - UpdateWrapper updateWrapper = new UpdateWrapper<>(); - updateWrapper.eq("id", promotionId); - updateWrapper.set("promotion_status", PromotionStatusEnum.valueOf(promotionStatus)); - return updateWrapper; - } } diff --git a/framework/src/main/java/cn/lili/common/utils/BeanUtil.java b/framework/src/main/java/cn/lili/common/utils/BeanUtil.java index 2452a80a..849f89d3 100644 --- a/framework/src/main/java/cn/lili/common/utils/BeanUtil.java +++ b/framework/src/main/java/cn/lili/common/utils/BeanUtil.java @@ -1,7 +1,5 @@ package cn.lili.common.utils; -import cn.hutool.json.JSONUtil; -import cn.lili.modules.payment.kit.dto.PayParam; import org.springframework.beans.BeanUtils; import java.lang.reflect.Field; @@ -123,16 +121,4 @@ public class BeanUtil { return t; } - public static void main(String[] args) throws IllegalAccessException { - PayParam payParam = new PayParam(); - payParam.setClientType("client"); - payParam.setOrderType(""); - payParam.setSn("sn"); - String val = formatKeyValuePair(payParam); - System.out.println(val); - - PayParam param = formatKeyValuePair(val, new PayParam()); - System.out.println(JSONUtil.toJsonStr(param)); - } - } diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionServiceImpl.java index 918c7b90..d993797b 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionServiceImpl.java @@ -5,18 +5,22 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.json.JSONUtil; import cn.lili.common.enums.ResultCode; -import cn.lili.common.trigger.message.PromotionMessage; import cn.lili.common.exception.ServiceException; +import cn.lili.common.trigger.message.PromotionMessage; import cn.lili.modules.order.cart.entity.vo.FullDiscountVO; import cn.lili.modules.promotion.entity.dos.*; import cn.lili.modules.promotion.entity.enums.*; -import cn.lili.modules.promotion.entity.vos.*; +import cn.lili.modules.promotion.entity.vos.CouponVO; +import cn.lili.modules.promotion.entity.vos.PintuanVO; +import cn.lili.modules.promotion.entity.vos.PointsGoodsVO; +import cn.lili.modules.promotion.entity.vos.SeckillVO; import cn.lili.modules.promotion.service.*; import cn.lili.modules.search.entity.dos.EsGoodsIndex; import cn.lili.modules.search.service.EsGoodsIndexService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.mongodb.core.MongoTemplate; @@ -272,7 +276,7 @@ public class PromotionServiceImpl implements PromotionService { //写入促销状态 fullDiscountVO.setPromotionStatus(promotionMessage.getPromotionStatus()); //修改促销数据 - result = this.fullDiscountService.update(promotionMessage.updateWrapper()); + result = this.fullDiscountService.update(updateWrapper(promotionMessage)); //clone一个活动信息,用于存放与索引中 FullDiscountVO clone = ObjectUtil.clone(fullDiscountVO); clone.setPromotionGoodsList(null); @@ -309,7 +313,7 @@ public class PromotionServiceImpl implements PromotionService { } //修改优惠券 couponVO.setPromotionStatus(promotionMessage.getPromotionStatus()); - result = this.couponService.update(promotionMessage.updateWrapper()); + result = this.couponService.update(updateWrapper(promotionMessage)); //优惠券活动结束,会员已领取未使用的优惠券状态修改为:已过期 if (couponVO.getPromotionStatus().equals(PromotionStatusEnum.END)) { LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper() @@ -349,7 +353,7 @@ public class PromotionServiceImpl implements PromotionService { return false; } pintuanVO.setPromotionStatus(promotionMessage.getPromotionStatus()); - result = this.pintuanService.update(promotionMessage.updateWrapper()); + result = this.pintuanService.update(updateWrapper(promotionMessage)); this.promotionGoodsService.updateBatchById(pintuanVO.getPromotionGoodsList()); if (pintuanVO.getPromotionGoodsList() != null) { List promotionGoodsList = pintuanVO.getPromotionGoodsList(); @@ -383,7 +387,7 @@ public class PromotionServiceImpl implements PromotionService { //修改活动状态 seckill.setPromotionStatus(promotionMessage.getPromotionStatus()); - result = this.seckillService.update(promotionMessage.updateWrapper()); + result = this.seckillService.update(updateWrapper(promotionMessage)); //判断参与活动的商品是否为空,如果为空则返回 if (seckill.getSeckillApplyList() == null) { @@ -439,7 +443,7 @@ public class PromotionServiceImpl implements PromotionService { return false; } pointsGoodsVO.setPromotionStatus(promotionMessage.getPromotionStatus()); - result = this.pointsGoodsService.update(promotionMessage.updateWrapper()); + result = this.pointsGoodsService.update(updateWrapper(promotionMessage)); PointsGoods pointsGoods = JSONUtil.toBean(JSONUtil.toJsonStr(pointsGoodsVO), PointsGoods.class); this.goodsIndexService.updateEsGoodsIndex(pointsGoodsVO.getSkuId(), pointsGoods, esPromotionKey, null); this.mongoTemplate.save(pointsGoodsVO); @@ -491,4 +495,17 @@ public class PromotionServiceImpl implements PromotionService { log.error("当前" + type.name() + "活动ID为[" + id + "] 不存在,更改活动状态至[ " + status + " ]失败!"); throw new ServiceException(ResultCode.PROMOTION_STATUS_END); } + + + /** + * 根据消息,获取update wrapper + * @param + * @return + */ + private UpdateWrapper updateWrapper(PromotionMessage promotionMessage) { + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.eq("id", promotionMessage.getPromotionId()); + updateWrapper.set("promotion_status", PromotionStatusEnum.valueOf(promotionMessage.getPromotionStatus())); + return updateWrapper; + } } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/statistics/aop/aspect/PageViewInterceptor.java b/framework/src/main/java/cn/lili/modules/statistics/aop/aspect/PageViewInterceptor.java index 1d200b34..c72d0a37 100644 --- a/framework/src/main/java/cn/lili/modules/statistics/aop/aspect/PageViewInterceptor.java +++ b/framework/src/main/java/cn/lili/modules/statistics/aop/aspect/PageViewInterceptor.java @@ -54,10 +54,12 @@ public class PageViewInterceptor { switch (pageViewEnum) { case SKU: ResultMessage> skuRvt = (ResultMessage>) rvt; - GoodsSkuVO goodsSkuDetail = (GoodsSkuVO) skuRvt.getResult().get("data"); - storeId = goodsSkuDetail.getStoreId(); - goodsId = goodsSkuDetail.getGoodsId(); - break; + if (skuRvt != null && skuRvt.getResult() != null && skuRvt.getResult().containsKey("data")) { + GoodsSkuVO goodsSkuDetail = (GoodsSkuVO) skuRvt.getResult().get("data"); + storeId = goodsSkuDetail.getStoreId(); + goodsId = goodsSkuDetail.getGoodsId(); + break; + } case STORE: Map map = spelFormat(point); storeId = map.get("id"); @@ -79,7 +81,7 @@ public class PageViewInterceptor { //店铺UV 统计,则需要对id去重复,所以如下处理 cache.cumulative(CachePrefix.STORE_UV.getPrefix() + StatisticsSuffix.suffix(storeId), ip); } catch (Exception e) { - log.error("页面出错",e); + log.error("页面出错", e); } }