去除无效代码,规范代码
This commit is contained in:
parent
a903160305
commit
89b057dfca
@ -14,6 +14,8 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
|
||||||
<swagger-bootstrap-ui-version>1.9.6</swagger-bootstrap-ui-version>
|
<swagger-bootstrap-ui-version>1.9.6</swagger-bootstrap-ui-version>
|
||||||
<alipay-sdk-version>4.13.40.ALL</alipay-sdk-version>
|
<alipay-sdk-version>4.13.40.ALL</alipay-sdk-version>
|
||||||
<mysql-connector-version>5.1.48</mysql-connector-version>
|
<mysql-connector-version>5.1.48</mysql-connector-version>
|
||||||
@ -39,7 +41,6 @@
|
|||||||
<beetl-version>2.9.10</beetl-version>
|
<beetl-version>2.9.10</beetl-version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>1.8</java.version>
|
|
||||||
<skipTests>true</skipTests>
|
<skipTests>true</skipTests>
|
||||||
<knife4j.version>2.0.8</knife4j.version>
|
<knife4j.version>2.0.8</knife4j.version>
|
||||||
<de.codecentric>2.3.1</de.codecentric>
|
<de.codecentric>2.3.1</de.codecentric>
|
||||||
|
@ -9,6 +9,10 @@ import cn.lili.common.token.SecretKeyUtil;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import io.jsonwebtoken.Claims;
|
import io.jsonwebtoken.Claims;
|
||||||
import io.jsonwebtoken.Jwts;
|
import io.jsonwebtoken.Jwts;
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户上下文
|
* 用户上下文
|
||||||
@ -20,15 +24,15 @@ import io.jsonwebtoken.Jwts;
|
|||||||
*/
|
*/
|
||||||
public class UserContext {
|
public class UserContext {
|
||||||
|
|
||||||
private static AuthenticationHandler authenticationHandler;
|
/**
|
||||||
|
* 根据request获取用户信息
|
||||||
public static void setHolder(AuthenticationHandler authenticationHandler) {
|
*
|
||||||
UserContext.authenticationHandler = authenticationHandler;
|
* @return
|
||||||
}
|
*/
|
||||||
|
|
||||||
|
|
||||||
public static AuthUser getCurrentUser() {
|
public static AuthUser getCurrentUser() {
|
||||||
return authenticationHandler.getAuthUser();
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||||
|
String accessToken = request.getHeader(SecurityEnum.HEADER_TOKEN.getValue());
|
||||||
|
return getAuthUser(accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -44,6 +48,20 @@ public class UserContext {
|
|||||||
if (cache.keys("*" + accessToken).size() == 0) {
|
if (cache.keys("*" + accessToken).size() == 0) {
|
||||||
throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR);
|
throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR);
|
||||||
}
|
}
|
||||||
|
return getAuthUser(accessToken);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据jwt获取token重的用户信息
|
||||||
|
*
|
||||||
|
* @param accessToken token
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static AuthUser getAuthUser(String accessToken) {
|
||||||
|
try {
|
||||||
//获取token的信息
|
//获取token的信息
|
||||||
Claims claims
|
Claims claims
|
||||||
= Jwts.parser()
|
= Jwts.parser()
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
package cn.lili.common.security.context;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.ApplicationArguments;
|
|
||||||
import org.springframework.boot.ApplicationRunner;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 给予用户上下文,初始化参数
|
|
||||||
*
|
|
||||||
* @author Chopper
|
|
||||||
* @version v4.0
|
|
||||||
* @Description:
|
|
||||||
* @since 2020/11/14 20:30
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class UserContextInit implements ApplicationRunner {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户信息holder,认证信息的获取者
|
|
||||||
*/
|
|
||||||
@Autowired
|
|
||||||
private AuthenticationHandler authenticationHandler;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 在项目加载时指定认证信息获取者
|
|
||||||
* 默认是由spring 安全上下文中获取
|
|
||||||
*
|
|
||||||
* @param args
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void run(ApplicationArguments args) {
|
|
||||||
UserContext.setHolder(authenticationHandler);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,5 @@
|
|||||||
package cn.lili.common.trigger.message;
|
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.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
@ -43,10 +41,4 @@ public class PromotionMessage {
|
|||||||
*/
|
*/
|
||||||
private Date endTime;
|
private Date endTime;
|
||||||
|
|
||||||
public <T> UpdateWrapper<T> updateWrapper() {
|
|
||||||
UpdateWrapper<T> updateWrapper = new UpdateWrapper<>();
|
|
||||||
updateWrapper.eq("id", promotionId);
|
|
||||||
updateWrapper.set("promotion_status", PromotionStatusEnum.valueOf(promotionStatus));
|
|
||||||
return updateWrapper;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package cn.lili.common.utils;
|
package cn.lili.common.utils;
|
||||||
|
|
||||||
import cn.hutool.json.JSONUtil;
|
|
||||||
import cn.lili.modules.payment.kit.dto.PayParam;
|
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
@ -117,16 +115,4 @@ public class BeanUtil {
|
|||||||
return t;
|
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,18 +5,22 @@ import cn.hutool.core.date.DateUtil;
|
|||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import cn.lili.common.enums.ResultCode;
|
import cn.lili.common.enums.ResultCode;
|
||||||
import cn.lili.common.trigger.message.PromotionMessage;
|
|
||||||
import cn.lili.common.exception.ServiceException;
|
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.order.cart.entity.vo.FullDiscountVO;
|
||||||
import cn.lili.modules.promotion.entity.dos.*;
|
import cn.lili.modules.promotion.entity.dos.*;
|
||||||
import cn.lili.modules.promotion.entity.enums.*;
|
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.promotion.service.*;
|
||||||
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
||||||
import cn.lili.modules.search.service.EsGoodsIndexService;
|
import cn.lili.modules.search.service.EsGoodsIndexService;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
@ -249,7 +253,7 @@ public class PromotionServiceImpl implements PromotionService {
|
|||||||
//写入促销状态
|
//写入促销状态
|
||||||
fullDiscountVO.setPromotionStatus(promotionMessage.getPromotionStatus());
|
fullDiscountVO.setPromotionStatus(promotionMessage.getPromotionStatus());
|
||||||
//修改促销数据
|
//修改促销数据
|
||||||
result = this.fullDiscountService.update(promotionMessage.updateWrapper());
|
result = this.fullDiscountService.update(updateWrapper(promotionMessage));
|
||||||
//clone一个活动信息,用于存放与索引中
|
//clone一个活动信息,用于存放与索引中
|
||||||
FullDiscountVO clone = ObjectUtil.clone(fullDiscountVO);
|
FullDiscountVO clone = ObjectUtil.clone(fullDiscountVO);
|
||||||
clone.setPromotionGoodsList(null);
|
clone.setPromotionGoodsList(null);
|
||||||
@ -285,7 +289,7 @@ public class PromotionServiceImpl implements PromotionService {
|
|||||||
}
|
}
|
||||||
//修改优惠券
|
//修改优惠券
|
||||||
couponVO.setPromotionStatus(promotionMessage.getPromotionStatus());
|
couponVO.setPromotionStatus(promotionMessage.getPromotionStatus());
|
||||||
result = this.couponService.update(promotionMessage.updateWrapper());
|
result = this.couponService.update(updateWrapper(promotionMessage));
|
||||||
//优惠券活动结束,会员已领取未使用的优惠券状态修改为:已过期
|
//优惠券活动结束,会员已领取未使用的优惠券状态修改为:已过期
|
||||||
if(couponVO.getPromotionStatus().equals(PromotionStatusEnum.END)){
|
if(couponVO.getPromotionStatus().equals(PromotionStatusEnum.END)){
|
||||||
LambdaUpdateWrapper<MemberCoupon> updateWrapper = new LambdaUpdateWrapper<MemberCoupon>()
|
LambdaUpdateWrapper<MemberCoupon> updateWrapper = new LambdaUpdateWrapper<MemberCoupon>()
|
||||||
@ -324,7 +328,7 @@ public class PromotionServiceImpl implements PromotionService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
pintuanVO.setPromotionStatus(promotionMessage.getPromotionStatus());
|
pintuanVO.setPromotionStatus(promotionMessage.getPromotionStatus());
|
||||||
result = this.pintuanService.update(promotionMessage.updateWrapper());
|
result = this.pintuanService.update(updateWrapper(promotionMessage));
|
||||||
this.promotionGoodsService.updateBatchById(pintuanVO.getPromotionGoodsList());
|
this.promotionGoodsService.updateBatchById(pintuanVO.getPromotionGoodsList());
|
||||||
if (pintuanVO.getPromotionGoodsList() != null) {
|
if (pintuanVO.getPromotionGoodsList() != null) {
|
||||||
List<PromotionGoods> promotionGoodsList = pintuanVO.getPromotionGoodsList();
|
List<PromotionGoods> promotionGoodsList = pintuanVO.getPromotionGoodsList();
|
||||||
@ -357,7 +361,7 @@ public class PromotionServiceImpl implements PromotionService {
|
|||||||
|
|
||||||
//修改活动状态
|
//修改活动状态
|
||||||
seckill.setPromotionStatus(promotionMessage.getPromotionStatus());
|
seckill.setPromotionStatus(promotionMessage.getPromotionStatus());
|
||||||
result = this.seckillService.update(promotionMessage.updateWrapper());
|
result = this.seckillService.update(updateWrapper(promotionMessage));
|
||||||
|
|
||||||
//判断参与活动的商品是否为空,如果为空则返回
|
//判断参与活动的商品是否为空,如果为空则返回
|
||||||
if(seckill.getSeckillApplyList()==null){
|
if(seckill.getSeckillApplyList()==null){
|
||||||
@ -412,7 +416,7 @@ public class PromotionServiceImpl implements PromotionService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
pointsGoodsVO.setPromotionStatus(promotionMessage.getPromotionStatus());
|
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);
|
PointsGoods pointsGoods = JSONUtil.toBean(JSONUtil.toJsonStr(pointsGoodsVO), PointsGoods.class);
|
||||||
this.goodsIndexService.updateEsGoodsIndex(pointsGoodsVO.getSkuId(), pointsGoods, esPromotionKey, null);
|
this.goodsIndexService.updateEsGoodsIndex(pointsGoodsVO.getSkuId(), pointsGoods, esPromotionKey, null);
|
||||||
this.mongoTemplate.save(pointsGoodsVO);
|
this.mongoTemplate.save(pointsGoodsVO);
|
||||||
@ -463,4 +467,17 @@ public class PromotionServiceImpl implements PromotionService {
|
|||||||
log.error("当前" + type.name() + "活动ID为[" + id + "] 不存在,更改活动状态至[ " + status + " ]失败!");
|
log.error("当前" + type.name() + "活动ID为[" + id + "] 不存在,更改活动状态至[ " + status + " ]失败!");
|
||||||
throw new ServiceException(ResultCode.PROMOTION_STATUS_END);
|
throw new ServiceException(ResultCode.PROMOTION_STATUS_END);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据消息,获取update wrapper
|
||||||
|
* @param <T>
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private <T> UpdateWrapper<T> updateWrapper(PromotionMessage promotionMessage) {
|
||||||
|
UpdateWrapper<T> updateWrapper = new UpdateWrapper<>();
|
||||||
|
updateWrapper.eq("id", promotionMessage.getPromotionId());
|
||||||
|
updateWrapper.set("promotion_status", PromotionStatusEnum.valueOf(promotionMessage.getPromotionStatus()));
|
||||||
|
return updateWrapper;
|
||||||
|
}
|
||||||
}
|
}
|
@ -54,10 +54,12 @@ public class PageViewInterceptor {
|
|||||||
switch (pageViewEnum) {
|
switch (pageViewEnum) {
|
||||||
case SKU:
|
case SKU:
|
||||||
ResultMessage<Map<String, Object>> skuRvt = (ResultMessage<Map<String, Object>>) rvt;
|
ResultMessage<Map<String, Object>> skuRvt = (ResultMessage<Map<String, Object>>) rvt;
|
||||||
|
if (skuRvt != null && skuRvt.getResult() != null && skuRvt.getResult().containsKey("data")) {
|
||||||
GoodsSkuVO goodsSkuDetail = (GoodsSkuVO) skuRvt.getResult().get("data");
|
GoodsSkuVO goodsSkuDetail = (GoodsSkuVO) skuRvt.getResult().get("data");
|
||||||
storeId = goodsSkuDetail.getStoreId();
|
storeId = goodsSkuDetail.getStoreId();
|
||||||
goodsId = goodsSkuDetail.getGoodsId();
|
goodsId = goodsSkuDetail.getGoodsId();
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case STORE:
|
case STORE:
|
||||||
Map<String, String> map = spelFormat(point);
|
Map<String, String> map = spelFormat(point);
|
||||||
storeId = map.get("id");
|
storeId = map.get("id");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user