注释规范
This commit is contained in:
parent
8403db9e75
commit
c7e4af6175
@ -37,11 +37,11 @@ public class AdminApplication {
|
||||
successHandler.setDefaultTargetUrl(this.adminServer.path("/"));
|
||||
http.authorizeRequests().antMatchers("/instances**").permitAll();
|
||||
http.authorizeRequests(
|
||||
(authorizeRequests) -> authorizeRequests.antMatchers(this.adminServer.path("/assets/**")).permitAll() // 授予公众对所有静态资产和登录页面的访问权限。
|
||||
(authorizeRequests) -> authorizeRequests.antMatchers(this.adminServer.path("/assets/**")).permitAll() //授予公众对所有静态资产和登录页面的访问权限。
|
||||
.antMatchers(this.adminServer.path("/login")).permitAll().anyRequest().authenticated() //其他所有请求都必须经过验证。
|
||||
).formLogin(
|
||||
(formLogin) -> formLogin.loginPage(this.adminServer.path("/login")).successHandler(successHandler).and() // 配置登录和注销。
|
||||
).logout((logout) -> logout.logoutUrl(this.adminServer.path("/logout"))).httpBasic(Customizer.withDefaults()) // 启用HTTP基本支持。这是Spring Boot Admin Client注册所必需的。
|
||||
(formLogin) -> formLogin.loginPage(this.adminServer.path("/login")).successHandler(successHandler).and() //配置登录和注销。
|
||||
).logout((logout) -> logout.logoutUrl(this.adminServer.path("/logout"))).httpBasic(Customizer.withDefaults()) //启用HTTP基本支持。这是Spring Boot Admin Client注册所必需的。
|
||||
.csrf().disable()
|
||||
.rememberMe((rememberMe) -> rememberMe.key(UUID.randomUUID().toString()).tokenValiditySeconds(1209600));
|
||||
}
|
||||
|
@ -51,11 +51,11 @@ public class CartController {
|
||||
@NotNull(message = "购买数量不能为空") @Min(value = 1, message = "加入购物车数量必须大于0") Integer num,
|
||||
String cartType) {
|
||||
try {
|
||||
// 读取选中的列表
|
||||
//读取选中的列表
|
||||
cartService.add(skuId, num, cartType);
|
||||
return ResultUtil.success();
|
||||
} catch (ServiceException se) {
|
||||
log.error(se.getMsg(), se);
|
||||
log.info(se.getMsg(), se);
|
||||
return ResultUtil.error(se.getResultCode().code(), se.getResultCode().message());
|
||||
} catch (Exception e) {
|
||||
log.error(ResultCode.CART_ERROR.message(), e);
|
||||
@ -157,7 +157,7 @@ public class CartController {
|
||||
@GetMapping("/checked")
|
||||
public ResultMessage<TradeDTO> cartChecked(@NotNull(message = "读取选中列表") String way) {
|
||||
try {
|
||||
// 读取选中的列表
|
||||
//读取选中的列表
|
||||
return ResultUtil.data(this.cartService.getCheckedTradeDTO(CartTypeEnum.valueOf(way)));
|
||||
} catch (ServiceException se) {
|
||||
log.error(se.getMsg(), se);
|
||||
@ -239,7 +239,7 @@ public class CartController {
|
||||
@PostMapping(value = "/create/trade", consumes = "application/json", produces = "application/json")
|
||||
public ResultMessage<Object> crateTrade(@RequestBody TradeParams tradeParams) {
|
||||
try {
|
||||
// 读取选中的列表
|
||||
//读取选中的列表
|
||||
return ResultUtil.data(this.cartService.createTrade(tradeParams));
|
||||
} catch (ServiceException se) {
|
||||
log.error(se.getMsg(), se);
|
||||
|
@ -67,7 +67,7 @@ public class BuyerAuthenticationFilter extends BasicAuthenticationFilter {
|
||||
//从header中获取jwt
|
||||
String jwt = request.getHeader(SecurityEnum.HEADER_TOKEN.getValue());
|
||||
try {
|
||||
// 如果没有token 则return
|
||||
//如果没有token 则return
|
||||
if (StrUtil.isBlank(jwt)) {
|
||||
chain.doFilter(request, response);
|
||||
return;
|
||||
@ -99,7 +99,7 @@ public class BuyerAuthenticationFilter extends BasicAuthenticationFilter {
|
||||
String json = claims.get(SecurityEnum.USER_CONTEXT.getValue()).toString();
|
||||
AuthUser authUser = new Gson().fromJson(json, AuthUser.class);
|
||||
|
||||
// 校验redis中是否有权限
|
||||
//校验redis中是否有权限
|
||||
if (cache.hasKey(CachePrefix.ACCESS_TOKEN.getPrefix(UserEnums.MEMBER) + jwt)) {
|
||||
//构造返回信息
|
||||
List<GrantedAuthority> auths = new ArrayList<>();
|
||||
|
@ -48,35 +48,35 @@ public class BuyerSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry = http
|
||||
.authorizeRequests();
|
||||
// 配置的url 不需要授权
|
||||
//配置的url 不需要授权
|
||||
for (String url : ignoredUrlsProperties.getUrls()) {
|
||||
registry.antMatchers(url).permitAll();
|
||||
}
|
||||
registry
|
||||
.and()
|
||||
// 禁止网页iframe
|
||||
//禁止网页iframe
|
||||
.headers().frameOptions().disable()
|
||||
.and()
|
||||
.logout()
|
||||
.permitAll()
|
||||
.and()
|
||||
.authorizeRequests()
|
||||
// 任何请求
|
||||
//任何请求
|
||||
.anyRequest()
|
||||
// 需要身份认证
|
||||
//需要身份认证
|
||||
.authenticated()
|
||||
.and()
|
||||
// 允许跨域
|
||||
//允许跨域
|
||||
.cors().configurationSource((CorsConfigurationSource) SpringContextUtil.getBean("corsConfigurationSource")).and()
|
||||
// 关闭跨站请求防护
|
||||
//关闭跨站请求防护
|
||||
.csrf().disable()
|
||||
// 前后端分离采用JWT 不需要session
|
||||
//前后端分离采用JWT 不需要session
|
||||
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
|
||||
.and()
|
||||
// 自定义权限拒绝处理类
|
||||
//自定义权限拒绝处理类
|
||||
.exceptionHandling().accessDeniedHandler(accessDeniedHandler)
|
||||
.and()
|
||||
// 添加JWT认证过滤器
|
||||
//添加JWT认证过滤器
|
||||
.addFilter(new BuyerAuthenticationFilter(authenticationManager(), cache));
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ class FileTest {
|
||||
}
|
||||
URL url = new URL(brand.getLogo());
|
||||
InputStream inputStream = url.openStream();
|
||||
// 上传至第三方云服务或服务器
|
||||
//上传至第三方云服务或服务器
|
||||
brand.setLogo(fileManagerPlugin.inputStreamUpload(inputStream, brand.getId() + ".png"));
|
||||
} catch (IOException e) {
|
||||
log.error("上传你文件出错",e);
|
||||
|
@ -73,7 +73,7 @@ public class UploadController {
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(base64)) {
|
||||
// base64上传
|
||||
//base64上传
|
||||
file = Base64DecodeMultipartFile.base64Convert(base64);
|
||||
}
|
||||
String result = "";
|
||||
@ -81,9 +81,9 @@ public class UploadController {
|
||||
File newFile = new File();
|
||||
try {
|
||||
InputStream inputStream = file.getInputStream();
|
||||
// 上传至第三方云服务或服务器
|
||||
//上传至第三方云服务或服务器
|
||||
result = fileManagerPlugin.inputStreamUpload(inputStream, fileKey);
|
||||
// 保存数据信息至数据库
|
||||
//保存数据信息至数据库
|
||||
newFile.setName(file.getOriginalFilename());
|
||||
newFile.setFileSize(file.getSize());
|
||||
newFile.setFileType(file.getContentType());
|
||||
|
@ -48,18 +48,18 @@ public class CommonSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.authorizeRequests();
|
||||
registry
|
||||
.and()
|
||||
// 禁止网页iframe
|
||||
//禁止网页iframe
|
||||
.headers().frameOptions().disable()
|
||||
.and()
|
||||
.authorizeRequests()
|
||||
// 任何请求
|
||||
//任何请求
|
||||
.anyRequest()
|
||||
// 需要身份认证
|
||||
//需要身份认证
|
||||
.permitAll()
|
||||
.and()
|
||||
// 允许跨域
|
||||
//允许跨域
|
||||
.cors().configurationSource(corsConfigurationSource).and()
|
||||
// 关闭跨站请求防护
|
||||
//关闭跨站请求防护
|
||||
.csrf().disable();
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ public class StockUpdateExecute implements OrderStatusChangeEvent {
|
||||
//促销库存key 集合
|
||||
List<String> promotionKey = new ArrayList<>();
|
||||
|
||||
// 循环订单
|
||||
//循环订单
|
||||
for (OrderItem orderItem : order.getOrderItems()) {
|
||||
skuKeys.add(GoodsSkuService.getStockCacheKey(orderItem.getSkuId()));
|
||||
GoodsSku goodsSku = new GoodsSku();
|
||||
@ -221,7 +221,7 @@ public class StockUpdateExecute implements OrderStatusChangeEvent {
|
||||
List<GoodsSku> goodsSkus = new ArrayList<>();
|
||||
//sku库存key 集合
|
||||
List<String> skuKeys = new ArrayList<>();
|
||||
// 循环订单
|
||||
//循环订单
|
||||
for (OrderItem orderItem : order.getOrderItems()) {
|
||||
skuKeys.add(GoodsSkuService.getStockCacheKey(orderItem.getSkuId()));
|
||||
GoodsSku goodsSku = new GoodsSku();
|
||||
|
@ -112,7 +112,7 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
for (GoodsCompleteMessage goodsCompleteMessage : goodsCompleteMessageList) {
|
||||
Goods goods = goodsService.getById(goodsCompleteMessage.getGoodsId());
|
||||
if (goods != null) {
|
||||
// 更新商品购买数量
|
||||
//更新商品购买数量
|
||||
if (goods.getBuyCount() == null) {
|
||||
goods.setBuyCount(0);
|
||||
}
|
||||
@ -126,7 +126,7 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
}
|
||||
GoodsSku goodsSku = goodsSkuService.getById(goodsCompleteMessage.getSkuId());
|
||||
if (goodsSku != null) {
|
||||
// 更新商品购买数量
|
||||
//更新商品购买数量
|
||||
if (goodsSku.getBuyCount() == null) {
|
||||
goodsSku.setBuyCount(0);
|
||||
}
|
||||
|
@ -56,9 +56,9 @@ public class OrderMessageListener implements RocketMQListener<MessageExt> {
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
// 如所有步骤顺利完成
|
||||
//如所有步骤顺利完成
|
||||
if (Boolean.TRUE.equals(result)) {
|
||||
// 清除记录信息的trade cache key
|
||||
//清除记录信息的trade cache key
|
||||
cache.remove(key);
|
||||
}
|
||||
break;
|
||||
|
@ -43,11 +43,11 @@ public class CancelOrderTaskExecute implements EveryMinuteExecute {
|
||||
Setting setting = settingService.get(SettingEnum.ORDER_SETTING.name());
|
||||
OrderSetting orderSetting = JSONUtil.toBean(setting.getSettingValue(), OrderSetting.class);
|
||||
if (orderSetting != null && orderSetting.getAutoCancel() != null) {
|
||||
// 订单自动取消时间 = 当前时间 - 自动取消时间分钟数
|
||||
//订单自动取消时间 = 当前时间 - 自动取消时间分钟数
|
||||
DateTime cancelTime = DateUtil.offsetMinute(DateUtil.date(), -orderSetting.getAutoCancel());
|
||||
LambdaQueryWrapper<Order> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(Order::getOrderStatus, OrderStatusEnum.UNPAID.name());
|
||||
// 订单创建时间 <= 订单自动取消时间
|
||||
//订单创建时间 <= 订单自动取消时间
|
||||
queryWrapper.le(Order::getCreateTime, cancelTime);
|
||||
List<Order> list = orderService.list(queryWrapper);
|
||||
List<String> cancelSnList = list.stream().map(Order::getSn).collect(Collectors.toList());
|
||||
|
@ -73,11 +73,11 @@ public class OrderEveryDayTaskExecute implements EveryDayExecute {
|
||||
* @param orderSetting 订单设置
|
||||
*/
|
||||
private void completedOrder(OrderSetting orderSetting) {
|
||||
// 订单自动收货时间 = 当前时间 - 自动收货时间天数
|
||||
//订单自动收货时间 = 当前时间 - 自动收货时间天数
|
||||
DateTime receiveTime = DateUtil.offsetDay(DateUtil.date(), -orderSetting.getAutoEvaluation());
|
||||
LambdaQueryWrapper<Order> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(Order::getOrderStatus, OrderStatusEnum.DELIVERED.name());
|
||||
// 订单发货时间 >= 订单自动收货时间
|
||||
//订单发货时间 >= 订单自动收货时间
|
||||
queryWrapper.ge(Order::getLogisticsTime, receiveTime);
|
||||
List<Order> list = orderService.list(queryWrapper);
|
||||
List<String> receiveSnList = list.stream().map(Order::getSn).collect(Collectors.toList());
|
||||
@ -98,9 +98,9 @@ public class OrderEveryDayTaskExecute implements EveryDayExecute {
|
||||
* @param orderSetting 订单设置
|
||||
*/
|
||||
private void memberEvaluation(OrderSetting orderSetting) {
|
||||
// 订单自动收货时间 = 当前时间 - 自动收货时间天数
|
||||
//订单自动收货时间 = 当前时间 - 自动收货时间天数
|
||||
DateTime receiveTime = DateUtil.offsetDay(DateUtil.date(), -orderSetting.getAutoReceive());
|
||||
// 订单完成时间 <= 订单自动好评时间
|
||||
//订单完成时间 <= 订单自动好评时间
|
||||
List<OrderItem> orderItems = orderItemService.waitEvaluate(receiveTime);
|
||||
|
||||
for (OrderItem orderItem : orderItems) {
|
||||
|
@ -61,7 +61,7 @@ public class PromotionEverydayExecute implements EveryDayExecute {
|
||||
@Autowired
|
||||
private PromotionGoodsService promotionGoodsService;
|
||||
|
||||
// 系统设置
|
||||
//系统设置
|
||||
@Autowired
|
||||
private SettingService settingService;
|
||||
|
||||
@ -108,7 +108,7 @@ public class PromotionEverydayExecute implements EveryDayExecute {
|
||||
List<CouponVO> couponVOS = mongoTemplate.find(query, CouponVO.class);
|
||||
if (!couponVOS.isEmpty()) {
|
||||
List<String> ids = new ArrayList<>();
|
||||
// // 关闭的优惠券活动
|
||||
// //关闭的优惠券活动
|
||||
for (CouponVO vo : couponVOS) {
|
||||
vo.setPromotionStatus(PromotionStatusEnum.END.name());
|
||||
if (vo.getPromotionGoodsList() != null && !vo.getPromotionGoodsList().isEmpty()) {
|
||||
|
@ -31,23 +31,23 @@ public abstract class AbstractDelayQueueListen {
|
||||
private void startDelayQueueMachine() {
|
||||
log.info("延时队列机器{}开始运作", setDelayQueueName());
|
||||
|
||||
// 监听redis队列
|
||||
//监听redis队列
|
||||
while (true) {
|
||||
try {
|
||||
// 获取当前时间的时间戳
|
||||
//获取当前时间的时间戳
|
||||
long now = System.currentTimeMillis() / 1000;
|
||||
// 获取当前时间前需要执行的任务列表
|
||||
//获取当前时间前需要执行的任务列表
|
||||
Set<DefaultTypedTuple> tuples = cache.zRangeByScore(setDelayQueueName(), 0, now);
|
||||
|
||||
// 如果任务不为空
|
||||
//如果任务不为空
|
||||
if (!CollectionUtils.isEmpty(tuples)) {
|
||||
log.info("执行任务:{}", JSONUtil.toJsonStr(tuples));
|
||||
|
||||
for (DefaultTypedTuple tuple : tuples) {
|
||||
String jobId = (String) tuple.getValue();
|
||||
// 移除缓存,如果移除成功则表示当前线程处理了延时任务,则执行延时任务
|
||||
//移除缓存,如果移除成功则表示当前线程处理了延时任务,则执行延时任务
|
||||
Long num = cache.zRemove(setDelayQueueName(), jobId);
|
||||
// 如果移除成功, 则执行
|
||||
//如果移除成功, 则执行
|
||||
if (num > 0) {
|
||||
ThreadPoolUtil.execute(() -> invoke(jobId));
|
||||
}
|
||||
@ -57,7 +57,7 @@ public abstract class AbstractDelayQueueListen {
|
||||
} catch (Exception e) {
|
||||
log.error("处理延时任务发生异常,异常原因为{}", e.getMessage(), e);
|
||||
} finally {
|
||||
// 间隔一秒钟搞一次
|
||||
//间隔一秒钟搞一次
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(5L);
|
||||
} catch (InterruptedException e) {
|
||||
|
@ -29,7 +29,7 @@ public class BroadcastTimeTriggerExecutor implements TimeTriggerExecutor {
|
||||
BroadcastMessage broadcastMessage = JSONUtil.toBean(JSONUtil.parseObj(object), BroadcastMessage.class);
|
||||
if (broadcastMessage != null && broadcastMessage.getStudioId() != null) {
|
||||
log.info("直播间消费:{}", broadcastMessage);
|
||||
// 修改直播间状态
|
||||
//修改直播间状态
|
||||
studioService.updateStudioStatus(broadcastMessage);
|
||||
}
|
||||
}
|
||||
|
@ -42,19 +42,19 @@ public class PromotionTimeTriggerExecutor implements TimeTriggerExecutor {
|
||||
@Override
|
||||
public void execute(Object object) {
|
||||
PromotionMessage promotionMessage = JSONUtil.toBean(JSONUtil.parseObj(object), PromotionMessage.class);
|
||||
// 促销延时信息
|
||||
//促销延时信息
|
||||
if (promotionMessage != null && promotionMessage.getPromotionId() != null) {
|
||||
log.info("促销活动信息消费:{}", promotionMessage);
|
||||
// 如果为促销活动开始,则需要发布促销活动结束的定时任务
|
||||
//如果为促销活动开始,则需要发布促销活动结束的定时任务
|
||||
if (PromotionStatusEnum.START.name().equals(promotionMessage.getPromotionStatus())) {
|
||||
if (!promotionService.updatePromotionStatus(promotionMessage)) {
|
||||
log.error("开始促销活动失败: {}", promotionMessage);
|
||||
return;
|
||||
}
|
||||
// 促销活动开始后,设置促销活动结束的定时任务
|
||||
//促销活动开始后,设置促销活动结束的定时任务
|
||||
promotionMessage.setPromotionStatus(PromotionStatusEnum.END.name());
|
||||
String uniqueKey = "{TIME_TRIGGER_" + promotionMessage.getPromotionType() + "}_" + promotionMessage.getPromotionId();
|
||||
// 结束时间(延时一分钟)
|
||||
//结束时间(延时一分钟)
|
||||
long closeTime = promotionMessage.getEndTime().getTime() + 60000;
|
||||
TimeTriggerMsg timeTriggerMsg = new TimeTriggerMsg(TimeExecuteConstant.PROMOTION_EXECUTOR, closeTime, promotionMessage, uniqueKey, rocketmqCustomProperties.getPromotionTopic());
|
||||
//添加延时任务
|
||||
@ -69,7 +69,7 @@ public class PromotionTimeTriggerExecutor implements TimeTriggerExecutor {
|
||||
PintuanOrderMessage pintuanOrderMessage = JSONUtil.toBean(JSONUtil.parseObj(object), PintuanOrderMessage.class);
|
||||
if (pintuanOrderMessage != null && pintuanOrderMessage.getPintuanId() != null) {
|
||||
log.info("拼团订单信息消费:{}", pintuanOrderMessage);
|
||||
// 拼团订单自动处理
|
||||
//拼团订单自动处理
|
||||
orderService.agglomeratePintuanOrder(pintuanOrderMessage.getPintuanId(), pintuanOrderMessage.getOrderSn());
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class MybatisPlusConfig {
|
||||
// PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
|
||||
//
|
||||
// List<ISqlParser> sqlParserList = new ArrayList<>();
|
||||
// // 攻击 SQL 阻断解析器、加入解析链
|
||||
// //攻击 SQL 阻断解析器、加入解析链
|
||||
// sqlParserList.add(new BlockAttackSqlParser());
|
||||
// paginationInterceptor.setSqlParserList(sqlParserList);
|
||||
// return paginationInterceptor;
|
||||
|
@ -67,7 +67,7 @@ public class LimitInterceptor {
|
||||
try {
|
||||
Number count = redisTemplate.execute(limitScript, keys, limitCount, limitPeriod);
|
||||
log.info("Access try count is {} for name={} and key = {}", count, name, key);
|
||||
// 如果缓存里没有值,或者他的值小于限制频率
|
||||
//如果缓存里没有值,或者他的值小于限制频率
|
||||
if (count.intValue() <= limitCount) {
|
||||
return pjp.proceed();
|
||||
} else {
|
||||
|
@ -170,7 +170,7 @@ public class RedisCache implements Cache {
|
||||
@Override
|
||||
public Long cumulative(Object key, Object value) {
|
||||
HyperLogLogOperations<Object, Object> operations = redisTemplate.opsForHyperLogLog();
|
||||
// add 方法对应 PFADD 命令
|
||||
//add 方法对应 PFADD 命令
|
||||
return operations.add(key, value);
|
||||
|
||||
}
|
||||
@ -179,7 +179,7 @@ public class RedisCache implements Cache {
|
||||
public Long counter(Object key) {
|
||||
HyperLogLogOperations<Object, Object> operations = redisTemplate.opsForHyperLogLog();
|
||||
|
||||
// add 方法对应 PFADD 命令
|
||||
//add 方法对应 PFADD 命令
|
||||
return operations.size(key);
|
||||
}
|
||||
|
||||
@ -198,7 +198,7 @@ public class RedisCache implements Cache {
|
||||
@Override
|
||||
public Long mergeCounter(Object... key) {
|
||||
HyperLogLogOperations<Object, Object> operations = redisTemplate.opsForHyperLogLog();
|
||||
// 计数器合并累加
|
||||
//计数器合并累加
|
||||
return operations.union(key[0], key);
|
||||
}
|
||||
|
||||
@ -223,7 +223,7 @@ public class RedisCache implements Cache {
|
||||
*/
|
||||
@Override
|
||||
public void incrementScore(String sortedSetName, String keyword) {
|
||||
// x 的含义请见本方法的注释
|
||||
//x 的含义请见本方法的注释
|
||||
double x = 1.0;
|
||||
this.redisTemplate.opsForZSet().incrementScore(sortedSetName, keyword, x);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public abstract class BaseElasticsearchService {
|
||||
static {
|
||||
RequestOptions.Builder builder = RequestOptions.DEFAULT.toBuilder();
|
||||
|
||||
// 默认缓冲限制为100MB,此处修改为30MB。
|
||||
//默认缓冲限制为100MB,此处修改为30MB。
|
||||
builder.setHttpAsyncResponseConsumerFactory(new HttpAsyncResponseConsumerFactory.HeapBufferedResponseConsumerFactory(30 * 1024 * 1024));
|
||||
COMMON_OPTIONS = builder.build();
|
||||
}
|
||||
@ -88,7 +88,7 @@ public abstract class BaseElasticsearchService {
|
||||
protected void createIndexRequest(String index) {
|
||||
try {
|
||||
CreateIndexRequest request = new CreateIndexRequest(index);
|
||||
// Settings for this index
|
||||
//Settings for this index
|
||||
request.settings(Settings.builder().put("index.number_of_shards", elasticsearchProperties.getIndex().getNumberOfShards()).put("index.number_of_replicas", elasticsearchProperties.getIndex().getNumberOfReplicas()));
|
||||
|
||||
//创建索引
|
||||
|
@ -80,7 +80,7 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
* @return
|
||||
*/
|
||||
private String cleanXSS2(String value) {
|
||||
// 移除特殊标签
|
||||
//移除特殊标签
|
||||
value = value.replaceAll("<", "<").replaceAll(">", ">");
|
||||
value = value.replaceAll("\\(", "(").replaceAll("\\)", ")");
|
||||
value = value.replaceAll("'", "'");
|
||||
@ -93,40 +93,40 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
private String cleanXSS(String value) {
|
||||
if (value != null) {
|
||||
//推荐使用ESAPI库来避免脚本攻击,value = ESAPI.encoder().canonicalize(value);
|
||||
// // 避免空字符串
|
||||
// //避免空字符串
|
||||
// value = value.replaceAll(" ", "");
|
||||
// 避免script 标签
|
||||
//避免script 标签
|
||||
Pattern scriptPattern = Pattern.compile("<script>(.*?)</script>", Pattern.CASE_INSENSITIVE);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
// 避免src形式的表达式
|
||||
//避免src形式的表达式
|
||||
scriptPattern = Pattern.compile("src[\r\n]*=[\r\n]*\\\'(.*?)\\\'",
|
||||
Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
scriptPattern = Pattern.compile("src[\r\n]*=[\r\n]*\\\"(.*?)\\\"",
|
||||
Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
// 删除单个的 </script> 标签
|
||||
//删除单个的 </script> 标签
|
||||
scriptPattern = Pattern.compile("</script>", Pattern.CASE_INSENSITIVE);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
// 删除单个的<script ...> 标签
|
||||
//删除单个的<script ...> 标签
|
||||
scriptPattern = Pattern.compile("<script(.*?)>",
|
||||
Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
// 避免 eval(...) 形式表达式
|
||||
//避免 eval(...) 形式表达式
|
||||
scriptPattern = Pattern.compile("eval\\((.*?)\\)",
|
||||
Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
// 避免 expression(...) 表达式
|
||||
//避免 expression(...) 表达式
|
||||
scriptPattern = Pattern.compile("expression\\((.*?)\\)",
|
||||
Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
// 避免 javascript: 表达式
|
||||
//避免 javascript: 表达式
|
||||
scriptPattern = Pattern.compile("javascript:", Pattern.CASE_INSENSITIVE);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
// 避免 vbscript:表达式
|
||||
//避免 vbscript:表达式
|
||||
scriptPattern = Pattern.compile("vbscript:", Pattern.CASE_INSENSITIVE);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
// 避免 onload= 表达式
|
||||
//避免 onload= 表达式
|
||||
scriptPattern = Pattern.compile("onload(.*?)=",
|
||||
Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
|
@ -73,7 +73,7 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil {
|
||||
|
||||
//准备发送短信参数
|
||||
Map<String, String> params = new HashMap<>();
|
||||
// 验证码内容
|
||||
//验证码内容
|
||||
params.put("code", code);
|
||||
|
||||
//模版 默认为登录验证
|
||||
@ -356,11 +356,11 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil {
|
||||
SmsSetting smsSetting = new Gson().fromJson(setting.getSettingValue(), SmsSetting.class);
|
||||
|
||||
Config config = new Config();
|
||||
// 您的AccessKey ID
|
||||
//您的AccessKey ID
|
||||
config.accessKeyId = smsSetting.getAccessKeyId();
|
||||
// 您的AccessKey Secret
|
||||
//您的AccessKey Secret
|
||||
config.accessKeySecret = smsSetting.getAccessSecret();
|
||||
// 访问的域名
|
||||
//访问的域名
|
||||
config.endpoint = "dysmsapi.aliyuncs.com";
|
||||
return new com.aliyun.dysmsapi20170525.Client(config);
|
||||
} catch (Exception e) {
|
||||
|
@ -121,15 +121,15 @@ public class TokenUtil {
|
||||
* @return
|
||||
*/
|
||||
private String createToken(String username, Object claim, Long expirationTime) {
|
||||
// JWT 生成
|
||||
//JWT 生成
|
||||
return Jwts.builder()
|
||||
// jwt 私有声明
|
||||
//jwt 私有声明
|
||||
.claim(SecurityEnum.USER_CONTEXT.getValue(), new Gson().toJson(claim))
|
||||
// JWT的主体
|
||||
//JWT的主体
|
||||
.setSubject(username)
|
||||
// 失效时间 当前时间+过期分钟
|
||||
//失效时间 当前时间+过期分钟
|
||||
.setExpiration(new Date(System.currentTimeMillis() + expirationTime * 60 * 1000))
|
||||
// 签名算法和密钥
|
||||
//签名算法和密钥
|
||||
.signWith(SecretKeyUtil.generalKey())
|
||||
.compact();
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class ManagerTokenGenerate extends AbstractTokenGenerate {
|
||||
|
||||
@Override
|
||||
public Token createToken(String username, Boolean longTerm) {
|
||||
// 生成token
|
||||
//生成token
|
||||
AdminUser adminUser = adminUserService.findByUsername(username);
|
||||
AuthUser user = new AuthUser(adminUser.getUsername(), adminUser.getId(), UserEnums.MANAGER, adminUser.getNickName(), adminUser.getIsSuper());
|
||||
|
||||
|
@ -54,7 +54,7 @@ public class MemberTokenGenerate extends AbstractTokenGenerate {
|
||||
memberService.updateById(member);
|
||||
|
||||
AuthUser authUser = new AuthUser(member.getUsername(), member.getId(),member.getNickName(), UserEnums.MEMBER);
|
||||
// 登陆成功生成token
|
||||
//登陆成功生成token
|
||||
return tokenUtil.createToken(username, authUser, longTerm, UserEnums.MEMBER);
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class StoreTokenGenerate extends AbstractTokenGenerate {
|
||||
|
||||
@Override
|
||||
public Token createToken(String username, Boolean longTerm) {
|
||||
// 生成token
|
||||
//生成token
|
||||
Member member = memberService.findByUsername(username);
|
||||
if (!member.getHaveStore()) {
|
||||
throw new ServiceException("该会员未开通店铺");
|
||||
|
@ -101,7 +101,7 @@ public class Base64DecodeMultipartFile implements MultipartFile {
|
||||
|
||||
public static String inputStreamToStream(InputStream in) {
|
||||
byte[] data = null;
|
||||
// 读取图片字节数组
|
||||
//读取图片字节数组
|
||||
try {
|
||||
ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
|
||||
byte[] buff = new byte[100];
|
||||
|
@ -14,9 +14,9 @@ import java.util.regex.Pattern;
|
||||
public class CheckMobileUtil {
|
||||
|
||||
|
||||
// \b 是单词边界(连着的两个(字母字符 与 非字母字符) 之间的逻辑上的间隔),
|
||||
// 字符串在编译时会被转码一次,所以是 "\\b"
|
||||
// \B 是单词内部逻辑间隔(连着的两个字母字符之间的逻辑上的间隔)
|
||||
//\b 是单词边界(连着的两个(字母字符 与 非字母字符) 之间的逻辑上的间隔),
|
||||
//字符串在编译时会被转码一次,所以是 "\\b"
|
||||
//\B 是单词内部逻辑间隔(连着的两个字母字符之间的逻辑上的间隔)
|
||||
static String phoneReg = "\\b(ip(hone|od)|android|opera m(ob|in)i"
|
||||
+ "|windows (phone|ce)|blackberry"
|
||||
+ "|s(ymbian|eries60|amsung)|p(laybook|alm|rofile/midp"
|
||||
@ -41,7 +41,7 @@ public class CheckMobileUtil {
|
||||
if (null == userAgent) {
|
||||
userAgent = "";
|
||||
}
|
||||
// 匹配
|
||||
//匹配
|
||||
Matcher matcherPhone = phonePat.matcher(userAgent);
|
||||
Matcher matcherTable = tablePat.matcher(userAgent);
|
||||
if (matcherPhone.find() || matcherTable.find()) {
|
||||
|
@ -148,18 +148,18 @@ public class DateUtil {
|
||||
* @return
|
||||
*/
|
||||
public static Long[] getLastMonth() {
|
||||
// 取得系统当前时间
|
||||
//取得系统当前时间
|
||||
Calendar cal = Calendar.getInstance();
|
||||
int year = cal.get(Calendar.YEAR);
|
||||
int month = cal.get(Calendar.MONTH) + 1;
|
||||
|
||||
// 取得系统当前时间所在月第一天时间对象
|
||||
//取得系统当前时间所在月第一天时间对象
|
||||
cal.set(Calendar.DAY_OF_MONTH, 1);
|
||||
|
||||
// 日期减一,取得上月最后一天时间对象
|
||||
//日期减一,取得上月最后一天时间对象
|
||||
cal.add(Calendar.DAY_OF_MONTH, -1);
|
||||
|
||||
// 输出上月最后一天日期
|
||||
//输出上月最后一天日期
|
||||
int day = cal.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
String months = "";
|
||||
@ -355,7 +355,7 @@ public class DateUtil {
|
||||
*/
|
||||
public static Integer getDelayTime(Long startTime) {
|
||||
int time = Math.toIntExact((startTime - System.currentTimeMillis()) / 1000);
|
||||
// 如果时间为负数则改为一秒后执行
|
||||
//如果时间为负数则改为一秒后执行
|
||||
if (time <= 0) {
|
||||
time = 1;
|
||||
}
|
||||
|
@ -43,14 +43,14 @@ public class HibernateProxyTypeAdapter extends TypeAdapter<HibernateProxy> {
|
||||
out.nullValue();
|
||||
return;
|
||||
}
|
||||
// Retrieve the original (not proxy) class
|
||||
//Retrieve the original (not proxy) class
|
||||
Class<?> baseType = Hibernate.getClass(value);
|
||||
// Get the TypeAdapter of the original class, to delegate the serialization
|
||||
//Get the TypeAdapter of the original class, to delegate the serialization
|
||||
TypeAdapter delegate = context.getAdapter(TypeToken.get(baseType));
|
||||
// Get a filled instance of the original class
|
||||
//Get a filled instance of the original class
|
||||
Object unproxiedValue = ((HibernateProxy) value).getHibernateLazyInitializer()
|
||||
.getImplementation();
|
||||
// Serialize the value
|
||||
//Serialize the value
|
||||
delegate.write(out, unproxiedValue);
|
||||
}
|
||||
}
|
@ -37,25 +37,25 @@ import java.util.Map;
|
||||
@Slf4j
|
||||
public class HttpClientUtils {
|
||||
|
||||
// org.apache.http.impl.client.CloseableHttpClient
|
||||
//org.apache.http.impl.client.CloseableHttpClient
|
||||
private static CloseableHttpClient httpClient = null;
|
||||
|
||||
// 这里就直接默认固定了,因为以下三个参数在新建的method中仍然可以重新配置并被覆盖.
|
||||
static final int connectionRequestTimeout = 30000;// ms毫秒,从池中获取链接超时时间
|
||||
static final int connectTimeout = 60000;// ms毫秒,建立链接超时时间
|
||||
static final int socketTimeout = 60000;// ms毫秒,读取超时时间
|
||||
//这里就直接默认固定了,因为以下三个参数在新建的method中仍然可以重新配置并被覆盖.
|
||||
static final int connectionRequestTimeout = 30000;//ms毫秒,从池中获取链接超时时间
|
||||
static final int connectTimeout = 60000;//ms毫秒,建立链接超时时间
|
||||
static final int socketTimeout = 60000;//ms毫秒,读取超时时间
|
||||
|
||||
// 总配置,主要涉及是以下两个参数,如果要作调整没有用到properties会比较后麻烦,但鉴于一经粘贴,随处可用的特点,就不再做依赖性配置化处理了.
|
||||
// 而且这个参数同一家公司基本不会变动.
|
||||
static final int maxTotal = 500;// 最大总并发,很重要的参数
|
||||
static final int maxPerRoute = 100;// 每路并发,很重要的参数
|
||||
//总配置,主要涉及是以下两个参数,如果要作调整没有用到properties会比较后麻烦,但鉴于一经粘贴,随处可用的特点,就不再做依赖性配置化处理了.
|
||||
//而且这个参数同一家公司基本不会变动.
|
||||
static final int maxTotal = 500;//最大总并发,很重要的参数
|
||||
static final int maxPerRoute = 100;//每路并发,很重要的参数
|
||||
|
||||
// 正常情况这里应该配成MAP或LIST
|
||||
// 细化配置参数,用来对每路参数做精细化处理,可以管控各ip的流量,比如默认配置请求baidu:80端口最大100个并发链接,
|
||||
static final String detailHostName = "http://www.baidu.com";// 每个细化配置之ip(不重要,在特殊场景很有用)
|
||||
// 每个细化配置之port(不重要,在特殊场景很有用)
|
||||
//正常情况这里应该配成MAP或LIST
|
||||
//细化配置参数,用来对每路参数做精细化处理,可以管控各ip的流量,比如默认配置请求baidu:80端口最大100个并发链接,
|
||||
static final String detailHostName = "http://www.baidu.com";//每个细化配置之ip(不重要,在特殊场景很有用)
|
||||
//每个细化配置之port(不重要,在特殊场景很有用)
|
||||
static final int detailPort = 80;
|
||||
// 每个细化配置之最大并发数(不重要,在特殊场景很有用)
|
||||
//每个细化配置之最大并发数(不重要,在特殊场景很有用)
|
||||
static final int detailMaxPerRoute = 100;
|
||||
|
||||
private synchronized static CloseableHttpClient getHttpClient() {
|
||||
@ -72,51 +72,51 @@ public class HttpClientUtils {
|
||||
private static CloseableHttpClient init() {
|
||||
CloseableHttpClient newHotpoint;
|
||||
|
||||
// 设置连接池
|
||||
//设置连接池
|
||||
ConnectionSocketFactory plainsf = PlainConnectionSocketFactory.getSocketFactory();
|
||||
LayeredConnectionSocketFactory sslsf = SSLConnectionSocketFactory.getSocketFactory();
|
||||
Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create().register("http", plainsf).register("https", sslsf).build();
|
||||
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(registry);
|
||||
// 将最大连接数增加
|
||||
//将最大连接数增加
|
||||
cm.setMaxTotal(maxTotal);
|
||||
// 将每个路由基础的连接增加
|
||||
//将每个路由基础的连接增加
|
||||
cm.setDefaultMaxPerRoute(maxPerRoute);
|
||||
|
||||
// 细化配置开始,其实这里用Map或List的for循环来配置每个链接,在特殊场景很有用.
|
||||
// 将每个路由基础的连接做特殊化配置,一般用不着
|
||||
//细化配置开始,其实这里用Map或List的for循环来配置每个链接,在特殊场景很有用.
|
||||
//将每个路由基础的连接做特殊化配置,一般用不着
|
||||
HttpHost httpHost = new HttpHost(detailHostName, detailPort);
|
||||
// 将目标主机的最大连接数增加
|
||||
//将目标主机的最大连接数增加
|
||||
cm.setMaxPerRoute(new HttpRoute(httpHost), detailMaxPerRoute);
|
||||
// 细化配置结束
|
||||
//细化配置结束
|
||||
|
||||
// 请求重试处理
|
||||
//请求重试处理
|
||||
HttpRequestRetryHandler httpRequestRetryHandler = (exception, executionCount, context) -> {
|
||||
if (executionCount >= 2) {// 如果已经重试了2次,就放弃
|
||||
if (executionCount >= 2) {//如果已经重试了2次,就放弃
|
||||
return false;
|
||||
}
|
||||
if (exception instanceof NoHttpResponseException) {// 如果服务器丢掉了连接,那么就重试
|
||||
if (exception instanceof NoHttpResponseException) {//如果服务器丢掉了连接,那么就重试
|
||||
return true;
|
||||
}
|
||||
if (exception instanceof SSLHandshakeException) {// 不要重试SSL握手异常
|
||||
if (exception instanceof SSLHandshakeException) {//不要重试SSL握手异常
|
||||
return false;
|
||||
}
|
||||
if (exception instanceof InterruptedIOException) {// 超时
|
||||
if (exception instanceof InterruptedIOException) {//超时
|
||||
return false;
|
||||
}
|
||||
if (exception instanceof UnknownHostException) {// 目标服务器不可达
|
||||
if (exception instanceof UnknownHostException) {//目标服务器不可达
|
||||
return false;
|
||||
}
|
||||
if (exception instanceof SSLException) {// SSL握手异常
|
||||
if (exception instanceof SSLException) {//SSL握手异常
|
||||
return false;
|
||||
}
|
||||
|
||||
HttpClientContext clientContext = HttpClientContext.adapt(context);
|
||||
HttpRequest request = clientContext.getRequest();
|
||||
// 如果请求是幂等的,就再次尝试
|
||||
//如果请求是幂等的,就再次尝试
|
||||
return !(request instanceof HttpEntityEnclosingRequest);
|
||||
};
|
||||
|
||||
// 配置请求的超时设置
|
||||
//配置请求的超时设置
|
||||
RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(connectionRequestTimeout).setConnectTimeout(connectTimeout).setSocketTimeout(socketTimeout).build();
|
||||
newHotpoint = HttpClients.custom().setConnectionManager(cm).setDefaultRequestConfig(requestConfig).setRetryHandler(httpRequestRetryHandler).build();
|
||||
return newHotpoint;
|
||||
@ -124,13 +124,13 @@ public class HttpClientUtils {
|
||||
|
||||
public static String doGet(String url, Map<String, String> param) {
|
||||
|
||||
// httpClient
|
||||
//httpClient
|
||||
CloseableHttpClient httpClient = getHttpClient();
|
||||
|
||||
String resultString = "";
|
||||
CloseableHttpResponse response = null;
|
||||
try {
|
||||
// 创建uri
|
||||
//创建uri
|
||||
URIBuilder builder = new URIBuilder(url);
|
||||
if (param != null) {
|
||||
for (String key : param.keySet()) {
|
||||
@ -139,12 +139,12 @@ public class HttpClientUtils {
|
||||
}
|
||||
URI uri = builder.build();
|
||||
|
||||
// 创建http GET请求
|
||||
//创建http GET请求
|
||||
HttpGet httpGet = new HttpGet(uri);
|
||||
|
||||
// 执行请求
|
||||
//执行请求
|
||||
response = httpClient.execute(httpGet);
|
||||
// 判断返回状态是否为200
|
||||
//判断返回状态是否为200
|
||||
if (response.getStatusLine().getStatusCode() == 200) {
|
||||
resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ public class PageUtil {
|
||||
*/
|
||||
public static <T> QueryWrapper<T> initWrapper(Object object, SearchVO searchVo) {
|
||||
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
||||
// 创建时间区间判定
|
||||
//创建时间区间判定
|
||||
if (searchVo != null && StrUtil.isNotBlank(searchVo.getStartDate()) && StrUtil.isNotBlank(searchVo.getEndDate())) {
|
||||
Date start = cn.hutool.core.date.DateUtil.parse(searchVo.getStartDate());
|
||||
Date end = cn.hutool.core.date.DateUtil.parse(searchVo.getEndDate());
|
||||
|
@ -50,11 +50,11 @@ public class PasswordUtil {
|
||||
* @return Key PBE算法密钥
|
||||
*/
|
||||
private static Key getPBEKey(String password) throws Exception {
|
||||
// 实例化使用的算法
|
||||
//实例化使用的算法
|
||||
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(ALGORITHM);
|
||||
// 设置PBE密钥参数
|
||||
//设置PBE密钥参数
|
||||
PBEKeySpec keySpec = new PBEKeySpec(password.toCharArray());
|
||||
// 生成密钥
|
||||
//生成密钥
|
||||
SecretKey secretKey = keyFactory.generateSecret(keySpec);
|
||||
|
||||
return secretKey;
|
||||
|
@ -17,10 +17,10 @@ import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
public class SpelUtil {
|
||||
|
||||
|
||||
// spel表达式解析器
|
||||
//spel表达式解析器
|
||||
private static SpelExpressionParser spelExpressionParser = new SpelExpressionParser();
|
||||
|
||||
// 参数名发现器
|
||||
//参数名发现器
|
||||
private static DefaultParameterNameDiscoverer parameterNameDiscoverer = new DefaultParameterNameDiscoverer();
|
||||
|
||||
/**
|
||||
@ -30,8 +30,8 @@ public class SpelUtil {
|
||||
* @param spel
|
||||
* @return
|
||||
*/
|
||||
public static String compileParams(JoinPoint joinPoint, String spel) { // Spel表达式解析日志信息
|
||||
// 获得方法参数名数组
|
||||
public static String compileParams(JoinPoint joinPoint, String spel) { //Spel表达式解析日志信息
|
||||
//获得方法参数名数组
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
|
||||
String[] parameterNames = parameterNameDiscoverer.getParameterNames(signature.getMethod());
|
||||
@ -41,7 +41,7 @@ public class SpelUtil {
|
||||
//获取方法参数值
|
||||
Object[] args = joinPoint.getArgs();
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
context.setVariable(parameterNames[i], args[i]); // 替换spel里的变量值为实际值, 比如 #user --> user对象
|
||||
context.setVariable(parameterNames[i], args[i]); //替换spel里的变量值为实际值, 比如 #user --> user对象
|
||||
}
|
||||
return spelExpressionParser.parseExpression(spel).getValue(context).toString();
|
||||
}
|
||||
@ -55,8 +55,8 @@ public class SpelUtil {
|
||||
* @param spel
|
||||
* @return
|
||||
*/
|
||||
public static String compileParams(JoinPoint joinPoint, Object rvt, String spel) { // Spel表达式解析日志信息
|
||||
// 获得方法参数名数组
|
||||
public static String compileParams(JoinPoint joinPoint, Object rvt, String spel) { //Spel表达式解析日志信息
|
||||
//获得方法参数名数组
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
|
||||
String[] parameterNames = parameterNameDiscoverer.getParameterNames(signature.getMethod());
|
||||
@ -66,7 +66,7 @@ public class SpelUtil {
|
||||
//获取方法参数值
|
||||
Object[] args = joinPoint.getArgs();
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
context.setVariable(parameterNames[i], args[i]); // 替换spel里的变量值为实际值, 比如 #user --> user对象
|
||||
context.setVariable(parameterNames[i], args[i]); //替换spel里的变量值为实际值, 比如 #user --> user对象
|
||||
}
|
||||
context.setVariable("rvt", rvt);
|
||||
return spelExpressionParser.parseExpression(spel).getValue(context).toString();
|
||||
|
@ -22,13 +22,13 @@ public class ImageUtil {
|
||||
*/
|
||||
public static void addWatermark(BufferedImage oriImage, String text) {
|
||||
Graphics2D graphics2D = oriImage.createGraphics();
|
||||
// 设置水印文字颜色
|
||||
//设置水印文字颜色
|
||||
graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||
// 设置水印文字Font
|
||||
//设置水印文字Font
|
||||
graphics2D.setColor(Color.black);
|
||||
// 设置水印文字透明度
|
||||
//设置水印文字透明度
|
||||
graphics2D.setFont(new Font("宋体", Font.BOLD, 30));
|
||||
// 第一参数->设置的内容,后面两个参数->文字在图片上的坐标位置(x,y)
|
||||
//第一参数->设置的内容,后面两个参数->文字在图片上的坐标位置(x,y)
|
||||
graphics2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.4f));
|
||||
graphics2D.drawString(text, 10, 40);
|
||||
graphics2D.dispose();
|
||||
@ -44,34 +44,34 @@ public class ImageUtil {
|
||||
*/
|
||||
public static void cutByTemplate(BufferedImage oriImage, BufferedImage templateImage, BufferedImage newImage,
|
||||
int x, int y) {
|
||||
// 临时数组遍历用于高斯模糊存周边像素值
|
||||
//临时数组遍历用于高斯模糊存周边像素值
|
||||
int[][] matrix = new int[3][3];
|
||||
int[] values = new int[9];
|
||||
|
||||
int xLength = templateImage.getWidth();
|
||||
int yLength = templateImage.getHeight();
|
||||
// 模板图像宽度
|
||||
//模板图像宽度
|
||||
for (int i = 0; i < xLength; i++) {
|
||||
// 模板图片高度
|
||||
//模板图片高度
|
||||
for (int j = 0; j < yLength; j++) {
|
||||
// 如果模板图像当前像素点不是透明色 copy源文件信息到目标图片中
|
||||
//如果模板图像当前像素点不是透明色 copy源文件信息到目标图片中
|
||||
int rgb = templateImage.getRGB(i, j);
|
||||
if (rgb < 0) {
|
||||
newImage.setRGB(i, j, oriImage.getRGB(x + i, y + j));
|
||||
|
||||
// 抠图区域高斯模糊
|
||||
//抠图区域高斯模糊
|
||||
readPixel(oriImage, x + i, y + j, values);
|
||||
fillMatrix(matrix, values);
|
||||
oriImage.setRGB(x + i, y + j, avgMatrix(matrix));
|
||||
}
|
||||
|
||||
// 防止数组越界判断
|
||||
//防止数组越界判断
|
||||
if (i == (xLength - 1) || j == (yLength - 1)) {
|
||||
continue;
|
||||
}
|
||||
int rightRgb = templateImage.getRGB(i + 1, j);
|
||||
int downRgb = templateImage.getRGB(i, j + 1);
|
||||
// 描边处理,,取带像素和无像素的界点,判断该点是不是临界轮廓点,如果是设置该坐标像素是白色
|
||||
//描边处理,,取带像素和无像素的界点,判断该点是不是临界轮廓点,如果是设置该坐标像素是白色
|
||||
if ((rgb >= 0 && rightRgb < 0) || (rgb < 0 && rightRgb >= 0) || (rgb >= 0 && downRgb < 0)
|
||||
|| (rgb < 0 && downRgb >= 0)) {
|
||||
|
||||
|
@ -44,34 +44,34 @@ public class SliderImageUtil {
|
||||
|
||||
Random random = new Random();
|
||||
Map<String, Object> pictureMap = new HashMap<>();
|
||||
// 拼图
|
||||
//拼图
|
||||
BufferedImage sliderImage = ImageIO.read(Base64DecodeMultipartFile.base64ToInputStream(sliderFile.getBase64()));
|
||||
int sliderWidth = sliderImage.getWidth();
|
||||
int sliderHeight = sliderImage.getHeight();
|
||||
|
||||
// 原图
|
||||
//原图
|
||||
BufferedImage originalImage = ImageIO.read(Base64DecodeMultipartFile.base64ToInputStream(originalFile.getBase64()));
|
||||
int originalWidth = originalImage.getWidth();
|
||||
int originalHeight = originalImage.getHeight();
|
||||
|
||||
// 随机生成抠图坐标X,Y
|
||||
// X轴距离右端targetWidth Y轴距离底部targetHeight以上
|
||||
//随机生成抠图坐标X,Y
|
||||
//X轴距离右端targetWidth Y轴距离底部targetHeight以上
|
||||
int randomX = random.nextInt(originalWidth - 3 * sliderWidth) + 2 * sliderWidth;
|
||||
int randomY = random.nextInt(originalHeight - sliderHeight);
|
||||
log.info("原图大小{} x {},随机生成的坐标 X,Y 为({},{})", originalWidth, originalHeight, randomX, randomY);
|
||||
|
||||
// 新建一个和模板一样大小的图像,TYPE_4BYTE_ABGR表示具有8位RGBA颜色分量的图像,正常取imageTemplate.getType()
|
||||
//新建一个和模板一样大小的图像,TYPE_4BYTE_ABGR表示具有8位RGBA颜色分量的图像,正常取imageTemplate.getType()
|
||||
BufferedImage newImage = new BufferedImage(sliderWidth, sliderHeight, sliderImage.getType());
|
||||
// 得到画笔对象
|
||||
//得到画笔对象
|
||||
Graphics2D graphics = newImage.createGraphics();
|
||||
// 如果需要生成RGB格式,需要做如下配置,Transparency 设置透明
|
||||
//如果需要生成RGB格式,需要做如下配置,Transparency 设置透明
|
||||
newImage = graphics.getDeviceConfiguration().createCompatibleImage(sliderWidth, sliderHeight,
|
||||
Transparency.TRANSLUCENT);
|
||||
|
||||
// 新建的图像根据模板颜色赋值,源图生成遮罩
|
||||
//新建的图像根据模板颜色赋值,源图生成遮罩
|
||||
ImageUtil.cutByTemplate(originalImage, sliderImage, newImage, randomX, randomY);
|
||||
|
||||
// 设置“抗锯齿”的属性
|
||||
//设置“抗锯齿”的属性
|
||||
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
graphics.setStroke(new BasicStroke(BOLD, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
|
||||
graphics.drawImage(newImage, 0, 0, null);
|
||||
@ -79,12 +79,12 @@ public class SliderImageUtil {
|
||||
|
||||
//添加水印
|
||||
ImageUtil.addWatermark(originalImage, "请滑动拼图");
|
||||
ByteArrayOutputStream newImageOs = new ByteArrayOutputStream();// 新建流。
|
||||
ImageIO.write(newImage, TEMP_IMG_FILE_TYPE, newImageOs);// 利用ImageIO类提供的write方法,将bi以png图片的数据模式写入流。
|
||||
ByteArrayOutputStream newImageOs = new ByteArrayOutputStream();//新建流。
|
||||
ImageIO.write(newImage, TEMP_IMG_FILE_TYPE, newImageOs);//利用ImageIO类提供的write方法,将bi以png图片的数据模式写入流。
|
||||
byte[] newImagery = newImageOs.toByteArray();
|
||||
|
||||
ByteArrayOutputStream oriImagesOs = new ByteArrayOutputStream();// 新建流。
|
||||
ImageIO.write(originalImage, IMG_FILE_TYPE, oriImagesOs);// 利用ImageIO类提供的write方法,将bi以jpg图片的数据模式写入流。
|
||||
ByteArrayOutputStream oriImagesOs = new ByteArrayOutputStream();//新建流。
|
||||
ImageIO.write(originalImage, IMG_FILE_TYPE, oriImagesOs);//利用ImageIO类提供的write方法,将bi以jpg图片的数据模式写入流。
|
||||
byte[] oriImageByte = oriImagesOs.toByteArray();
|
||||
|
||||
pictureMap.put("slidingImage", "data:image/png;base64," + Base64Utils.encodeToString(newImagery));
|
||||
|
@ -58,14 +58,14 @@ public class VerificationServiceImpl implements VerificationService {
|
||||
|
||||
|
||||
Random random = new Random();
|
||||
// 随机选择需要切的图下标
|
||||
//随机选择需要切的图下标
|
||||
int resourceNum = random.nextInt(verificationResources.size());
|
||||
// 随机选择剪切模版下标
|
||||
//随机选择剪切模版下标
|
||||
int sliderNum = random.nextInt(verificationSlider.size());
|
||||
|
||||
// 随机选择需要切的图片地址
|
||||
//随机选择需要切的图片地址
|
||||
String originalResource = verificationResources.get(resourceNum).getResource();
|
||||
// 随机选择剪切模版图片地址
|
||||
//随机选择剪切模版图片地址
|
||||
String sliderResource = verificationSlider.get(sliderNum).getResource();
|
||||
|
||||
try {
|
||||
@ -73,10 +73,10 @@ public class VerificationServiceImpl implements VerificationService {
|
||||
SerializableStream originalFile = getInputStream(originalResource);
|
||||
SerializableStream sliderFile = getInputStream(sliderResource);
|
||||
Map<String, Object> resultMap = SliderImageUtil.pictureTemplatesCut(sliderFile, originalFile);
|
||||
// 生成验证参数 120可以验证 无需手动清除,120秒有效时间自动清除
|
||||
//生成验证参数 120可以验证 无需手动清除,120秒有效时间自动清除
|
||||
cache.put(cacheKey(verificationEnums, uuid), resultMap.get("randomX"), 120L);
|
||||
resultMap.put("key", cacheKey(verificationEnums, uuid));
|
||||
// 移除横坐标移动距离
|
||||
//移除横坐标移动距离
|
||||
resultMap.remove("randomX");
|
||||
return resultMap;
|
||||
} catch (ServiceException e) {
|
||||
|
@ -83,10 +83,10 @@ public class RedisConfig extends CachingConfigurerSupport {
|
||||
RedisTemplate<Object, Object> template = new RedisTemplate<>();
|
||||
//使用fastjson序列化
|
||||
FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer(Object.class);
|
||||
// value值的序列化采用fastJsonRedisSerializer
|
||||
//value值的序列化采用fastJsonRedisSerializer
|
||||
template.setValueSerializer(fastJsonRedisSerializer);
|
||||
template.setHashValueSerializer(fastJsonRedisSerializer);
|
||||
// key的序列化采用StringRedisSerializer
|
||||
//key的序列化采用StringRedisSerializer
|
||||
template.setKeySerializer(new StringRedisSerializer());
|
||||
template.setHashKeySerializer(new StringRedisSerializer());
|
||||
template.setConnectionFactory(lettuceConnectionFactory);
|
||||
@ -102,19 +102,19 @@ public class RedisConfig extends CachingConfigurerSupport {
|
||||
return (target, method, params) -> {
|
||||
Map<String, Object> container = new HashMap<>(3);
|
||||
Class<?> targetClassClass = target.getClass();
|
||||
// 类地址
|
||||
//类地址
|
||||
container.put("class", targetClassClass.toGenericString());
|
||||
// 方法名称
|
||||
//方法名称
|
||||
container.put("methodName", method.getName());
|
||||
// 包名称
|
||||
//包名称
|
||||
container.put("package", targetClassClass.getPackage());
|
||||
// 参数列表
|
||||
//参数列表
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
container.put(String.valueOf(i), params[i]);
|
||||
}
|
||||
// 转为JSON字符串
|
||||
//转为JSON字符串
|
||||
String jsonString = JSON.toJSONString(container);
|
||||
// 做SHA256 Hash计算,得到一个SHA256摘要作为Key
|
||||
//做SHA256 Hash计算,得到一个SHA256摘要作为Key
|
||||
return DigestUtils.sha256Hex(jsonString);
|
||||
};
|
||||
}
|
||||
@ -122,7 +122,7 @@ public class RedisConfig extends CachingConfigurerSupport {
|
||||
@Bean
|
||||
@Override
|
||||
public CacheErrorHandler errorHandler() {
|
||||
// 异常处理,当Redis发生异常时,打印日志,但是程序正常走
|
||||
//异常处理,当Redis发生异常时,打印日志,但是程序正常走
|
||||
log.info("初始化 -> [{}]", "Redis CacheErrorHandler");
|
||||
return new CacheErrorHandler() {
|
||||
@Override
|
||||
|
@ -62,9 +62,9 @@ public class ElasticsearchConfig extends AbstractElasticsearchConfiguration {
|
||||
}
|
||||
|
||||
restBuilder.setRequestConfigCallback(requestConfigBuilder ->
|
||||
requestConfigBuilder.setConnectTimeout(1000) // time until a connection with the server is established.
|
||||
.setSocketTimeout(12 * 1000) // time of inactivity to wait for packets[data] to receive.
|
||||
.setConnectionRequestTimeout(2 * 1000)); // time to fetch a connection from the connection pool 0 for infinite.
|
||||
requestConfigBuilder.setConnectTimeout(1000) //time until a connection with the server is established.
|
||||
.setSocketTimeout(12 * 1000) //time of inactivity to wait for packets[data] to receive.
|
||||
.setConnectionRequestTimeout(2 * 1000)); //time to fetch a connection from the connection pool 0 for infinite.
|
||||
|
||||
client = new RestHighLevelClient(restBuilder);
|
||||
return client;
|
||||
|
@ -23,11 +23,11 @@ public class UrlConfiguration implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
// 注册拦截器
|
||||
//注册拦截器
|
||||
InterceptorRegistration ir = registry.addInterceptor(requestInterceptorAdapter);
|
||||
// 配置拦截的路径
|
||||
//配置拦截的路径
|
||||
ir.addPathPatterns("/**");
|
||||
// 配置不拦截的路径
|
||||
//配置不拦截的路径
|
||||
ir.excludePathPatterns(ignoredUrlsProperties.getUrls());
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ public class UrlConfiguration implements WebMvcConfigurer {
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("/statics/**").addResourceLocations("classpath:/statics/");
|
||||
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||
// 解决 SWAGGER 404报错
|
||||
//解决 SWAGGER 404报错
|
||||
registry.addResourceHandler("/swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
|
||||
}
|
||||
|
||||
|
@ -37,9 +37,9 @@ public class CreateTimeShardingTableAlgorithmBak implements PreciseShardingAlgor
|
||||
//循环增加区间的查询条件
|
||||
|
||||
|
||||
// 因为考虑到 假设2019-05~2020-05
|
||||
// 这快是没办法处理的,因为分库分表之后,每个库都要进行查询,如果操作为,1-4月,那么2020年数据查询正确了,可是2019年到5-12月数据就查询不到了
|
||||
// 这里需要做一些性能的浪费,现在看来是没办法处理到
|
||||
//因为考虑到 假设2019-05~2020-05
|
||||
//这快是没办法处理的,因为分库分表之后,每个库都要进行查询,如果操作为,1-4月,那么2020年数据查询正确了,可是2019年到5-12月数据就查询不到了
|
||||
//这里需要做一些性能的浪费,现在看来是没办法处理到
|
||||
|
||||
for (Integer i = 1; i <= 12; i++) {
|
||||
collect.add("li_order_" + i);
|
||||
|
@ -73,7 +73,7 @@ public class Swagger2Config {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.groupName("商品")
|
||||
.apiInfo(apiInfo()).select()
|
||||
// 扫描所有有注解的api,用这种方式更灵活
|
||||
//扫描所有有注解的api,用这种方式更灵活
|
||||
// .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
||||
.apis(RequestHandlerSelectors.basePackage("cn.lili.controller.goods"))
|
||||
.paths(PathSelectors.any())
|
||||
@ -87,7 +87,7 @@ public class Swagger2Config {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.groupName("会员")
|
||||
.apiInfo(apiInfo()).select()
|
||||
// 扫描所有有注解的api,用这种方式更灵活
|
||||
//扫描所有有注解的api,用这种方式更灵活
|
||||
.apis(RequestHandlerSelectors.basePackage("cn.lili.controller.member"))
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
@ -100,7 +100,7 @@ public class Swagger2Config {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.groupName("促销")
|
||||
.apiInfo(apiInfo()).select()
|
||||
// 扫描所有有注解的api,用这种方式更灵活
|
||||
//扫描所有有注解的api,用这种方式更灵活
|
||||
.apis(RequestHandlerSelectors.basePackage("cn.lili.controller.promotion"))
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
@ -113,7 +113,7 @@ public class Swagger2Config {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.groupName("店铺")
|
||||
.apiInfo(apiInfo()).select()
|
||||
// 扫描所有有注解的api,用这种方式更灵活
|
||||
//扫描所有有注解的api,用这种方式更灵活
|
||||
.apis(RequestHandlerSelectors.basePackage("cn.lili.controller.store"))
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
@ -126,7 +126,7 @@ public class Swagger2Config {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.groupName("交易")
|
||||
.apiInfo(apiInfo()).select()
|
||||
// 扫描所有有注解的api,用这种方式更灵活
|
||||
//扫描所有有注解的api,用这种方式更灵活
|
||||
.apis(RequestHandlerSelectors.basePackage("cn.lili.controller.trade"))
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
@ -140,7 +140,7 @@ public class Swagger2Config {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.groupName("设置")
|
||||
.apiInfo(apiInfo()).select()
|
||||
// 扫描所有有注解的api,用这种方式更灵活
|
||||
//扫描所有有注解的api,用这种方式更灵活
|
||||
.apis(RequestHandlerSelectors.basePackage("cn.lili.controller.setting"))
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
@ -153,7 +153,7 @@ public class Swagger2Config {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.groupName("权限")
|
||||
.apiInfo(apiInfo()).select()
|
||||
// 扫描所有有注解的api,用这种方式更灵活
|
||||
//扫描所有有注解的api,用这种方式更灵活
|
||||
.apis(RequestHandlerSelectors.basePackage("cn.lili.controller.permission"))
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
@ -166,7 +166,7 @@ public class Swagger2Config {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.groupName("其他")
|
||||
.apiInfo(apiInfo()).select()
|
||||
// 扫描所有有注解的api,用这种方式更灵活
|
||||
//扫描所有有注解的api,用这种方式更灵活
|
||||
.apis(RequestHandlerSelectors.basePackage("cn.lili.controller.other"))
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
@ -179,7 +179,7 @@ public class Swagger2Config {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.groupName("通用")
|
||||
.apiInfo(apiInfo()).select()
|
||||
// 扫描所有有注解的api,用这种方式更灵活
|
||||
//扫描所有有注解的api,用这种方式更灵活
|
||||
.apis(RequestHandlerSelectors.basePackage("cn.lili.controller.common"))
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
@ -191,7 +191,7 @@ public class Swagger2Config {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.groupName("分销")
|
||||
.apiInfo(apiInfo()).select()
|
||||
// 扫描所有有注解的api,用这种方式更灵活
|
||||
//扫描所有有注解的api,用这种方式更灵活
|
||||
.apis(RequestHandlerSelectors.basePackage("cn.lili.controller.distribution"))
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
@ -204,7 +204,7 @@ public class Swagger2Config {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.groupName("统计")
|
||||
.apiInfo(apiInfo()).select()
|
||||
// 扫描所有有注解的api,用这种方式更灵活
|
||||
//扫描所有有注解的api,用这种方式更灵活
|
||||
.apis(RequestHandlerSelectors.basePackage("cn.lili.controller.statistics"))
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
@ -217,7 +217,7 @@ public class Swagger2Config {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.groupName("支付")
|
||||
.apiInfo(apiInfo()).select()
|
||||
// 扫描所有有注解的api,用这种方式更灵活
|
||||
//扫描所有有注解的api,用这种方式更灵活
|
||||
.apis(RequestHandlerSelectors.basePackage("cn.lili.controller.payment"))
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
@ -230,7 +230,7 @@ public class Swagger2Config {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.groupName("登录")
|
||||
.apiInfo(apiInfo()).select()
|
||||
// 扫描所有有注解的api,用这种方式更灵活
|
||||
//扫描所有有注解的api,用这种方式更灵活
|
||||
.apis(RequestHandlerSelectors.basePackage("cn.lili.controller.passport"))
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
|
@ -20,7 +20,7 @@ public class WebSocketStompConfig implements WebSocketMessageBrokerConfigurer {
|
||||
@Override
|
||||
public void registerStompEndpoints(StompEndpointRegistry registry) {
|
||||
|
||||
// 允许使用socketJs方式访问 即可通过http://IP:PORT/manager/ws来和服务端websocket连接
|
||||
//允许使用socketJs方式访问 即可通过http://IP:PORT/manager/ws来和服务端websocket连接
|
||||
registry.addEndpoint("/ws").setAllowedOrigins("*").withSockJS();
|
||||
}
|
||||
|
||||
@ -31,11 +31,11 @@ public class WebSocketStompConfig implements WebSocketMessageBrokerConfigurer {
|
||||
@Override
|
||||
public void configureMessageBroker(MessageBrokerRegistry registry) {
|
||||
|
||||
// 订阅Broker名称 user点对点 topic广播即群发
|
||||
//订阅Broker名称 user点对点 topic广播即群发
|
||||
registry.enableSimpleBroker("/user","/topic");
|
||||
// 全局(客户端)使用的消息前缀
|
||||
//全局(客户端)使用的消息前缀
|
||||
registry.setApplicationDestinationPrefixes("/app");
|
||||
// 点对点使用的前缀 无需配置 默认/user
|
||||
//点对点使用的前缀 无需配置 默认/user
|
||||
registry.setUserDestinationPrefix("/user");
|
||||
}
|
||||
}
|
||||
|
@ -100,11 +100,11 @@ public class CodeGenerator {
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void main(String[] args) throws IOException {
|
||||
// 模板路径
|
||||
//模板路径
|
||||
ClasspathResourceLoader resourceLoader = new ClasspathResourceLoader("/templates/");
|
||||
Configuration cfg = Configuration.defaultConfiguration();
|
||||
GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
|
||||
// 生成代码
|
||||
//生成代码
|
||||
generateCode(gt);
|
||||
//根据类名删除生成的代码
|
||||
// deleteCode(className);
|
||||
@ -152,7 +152,7 @@ public class CodeGenerator {
|
||||
entityDir.mkdirs();
|
||||
}
|
||||
if (!entityFile.exists()) {
|
||||
// 若文件存在则不重新生成
|
||||
//若文件存在则不重新生成
|
||||
entityFile.createNewFile();
|
||||
out = new FileOutputStream(entityFile);
|
||||
entityTemplate.renderTo(out);
|
||||
@ -170,7 +170,7 @@ public class CodeGenerator {
|
||||
daoDir.mkdirs();
|
||||
}
|
||||
if (!daoFile.exists()) {
|
||||
// 若文件存在则不重新生成
|
||||
//若文件存在则不重新生成
|
||||
daoFile.createNewFile();
|
||||
out = new FileOutputStream(daoFile);
|
||||
daoTemplate.renderTo(out);
|
||||
@ -188,7 +188,7 @@ public class CodeGenerator {
|
||||
serviceDir.mkdirs();
|
||||
}
|
||||
if (!serviceFile.exists()) {
|
||||
// 若文件存在则不重新生成
|
||||
//若文件存在则不重新生成
|
||||
serviceFile.createNewFile();
|
||||
out = new FileOutputStream(serviceFile);
|
||||
serviceTemplate.renderTo(out);
|
||||
@ -207,7 +207,7 @@ public class CodeGenerator {
|
||||
serviceImplDir.mkdirs();
|
||||
}
|
||||
if (!serviceImplFile.exists()) {
|
||||
// 若文件存在则不重新生成
|
||||
//若文件存在则不重新生成
|
||||
serviceImplFile.createNewFile();
|
||||
out = new FileOutputStream(serviceImplFile);
|
||||
serviceImplTemplate.renderTo(out);
|
||||
@ -225,7 +225,7 @@ public class CodeGenerator {
|
||||
controllerDir.mkdirs();
|
||||
}
|
||||
if (!controllerFile.exists()) {
|
||||
// 若文件存在则不重新生成
|
||||
//若文件存在则不重新生成
|
||||
controllerFile.createNewFile();
|
||||
out = new FileOutputStream(controllerFile);
|
||||
controllerTemplate.renderTo(out);
|
||||
@ -243,7 +243,7 @@ public class CodeGenerator {
|
||||
mapperXmlDir.mkdirs();
|
||||
}
|
||||
if (!mapperXmlFile.exists()) {
|
||||
// 若文件存在则不重新生成
|
||||
//若文件存在则不重新生成
|
||||
mapperXmlFile.createNewFile();
|
||||
out = new FileOutputStream(mapperXmlFile);
|
||||
mapperXmlTemplate.renderTo(out);
|
||||
|
@ -141,7 +141,7 @@ public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> impleme
|
||||
*/
|
||||
private List<Region> initData(String jsonString) {
|
||||
|
||||
// 最终数据承载对象
|
||||
//最终数据承载对象
|
||||
List<Region> regions = new ArrayList<>();
|
||||
JSONObject jsonObject = JSONObject.parseObject(jsonString);
|
||||
//获取到国家及下面所有的信息 开始循环插入,这里可以写成递归调用,但是不如这样方便查看、理解
|
||||
|
@ -29,8 +29,8 @@ public class Commodity extends BaseEntity {
|
||||
private String name;
|
||||
|
||||
//1:一口价(只需要传入price,price2不传)
|
||||
// 2:价格区间(price字段为左边界,price2字段为右边界,price和price2必传)
|
||||
// 3:显示折扣价(price字段为原价,price2字段为现价, price和price2必传
|
||||
//2:价格区间(price字段为左边界,price2字段为右边界,price和price2必传)
|
||||
//3:显示折扣价(price字段为原价,price2字段为现价, price和price2必传
|
||||
@ApiModelProperty(value = "价格类型")
|
||||
private Integer priceType;
|
||||
|
||||
|
@ -23,8 +23,8 @@ public class GoodsInfo {
|
||||
private String name;
|
||||
|
||||
//1:一口价(只需要传入price,price2不传)
|
||||
// 2:价格区间(price字段为左边界,price2字段为右边界,price和price2必传)
|
||||
// 3:显示折扣价(price字段为原价,price2字段为现价, price和price2必传
|
||||
//2:价格区间(price字段为左边界,price2字段为右边界,price和price2必传)
|
||||
//3:显示折扣价(price字段为原价,price2字段为现价, price和price2必传
|
||||
@ApiModelProperty(value = "价格类型")
|
||||
private Integer priceType;
|
||||
|
||||
|
@ -75,7 +75,7 @@ public class StudioServiceImpl extends ServiceImpl<StudioMapper, Studio> impleme
|
||||
DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.BROADCAST, studio.getId()),
|
||||
rocketmqCustomProperties.getPromotionTopic());
|
||||
|
||||
// 发送促销活动开始的延时任务
|
||||
//发送促销活动开始的延时任务
|
||||
this.timeTrigger.addDelay(timeTriggerMsg);
|
||||
|
||||
//直播结束延时任务
|
||||
@ -84,7 +84,7 @@ public class StudioServiceImpl extends ServiceImpl<StudioMapper, Studio> impleme
|
||||
Long.parseLong(studio.getEndTime()) * 1000L, broadcastMessage,
|
||||
DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.BROADCAST, studio.getId()),
|
||||
rocketmqCustomProperties.getPromotionTopic());
|
||||
// 发送促销活动开始的延时任务
|
||||
//发送促销活动开始的延时任务
|
||||
this.timeTrigger.addDelay(timeTriggerMsg);
|
||||
}
|
||||
return true;
|
||||
@ -100,7 +100,7 @@ public class StudioServiceImpl extends ServiceImpl<StudioMapper, Studio> impleme
|
||||
Studio oldStudio = this.getById(studio.getId());
|
||||
wechatLivePlayerUtil.editRoom(studio);
|
||||
if (this.updateById(studio)) {
|
||||
// 发送更新延时任务
|
||||
//发送更新延时任务
|
||||
//直播间开始
|
||||
BroadcastMessage broadcastMessage = new BroadcastMessage(studio.getId(), StudioStatusEnum.START.name());
|
||||
this.timeTrigger.edit(
|
||||
|
@ -93,13 +93,13 @@ public class WechatLivePlayerUtil {
|
||||
//发送url
|
||||
String url = "https://api.weixin.qq.com/wxa/business/getliveinfo?access_token=" + token;
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
// 获取回放
|
||||
//获取回放
|
||||
map.put("action", "get_replay");
|
||||
// 直播间ID
|
||||
//直播间ID
|
||||
map.put("room_id", roomId);
|
||||
// 起始拉取视频,0表示从第一个视频片段开始拉取
|
||||
//起始拉取视频,0表示从第一个视频片段开始拉取
|
||||
map.put("start", "0");
|
||||
// 每次拉取的数量,建议100以内
|
||||
//每次拉取的数量,建议100以内
|
||||
map.put("limit", "1");
|
||||
|
||||
String content = HttpUtils.doPostWithJson(url, map);
|
||||
@ -122,10 +122,10 @@ public class WechatLivePlayerUtil {
|
||||
//发送url
|
||||
String url = "https://api.weixin.qq.com/wxaapi/broadcast/room/addgoods?access_token=" + token;
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
// 直播间回放
|
||||
//直播间回放
|
||||
Integer[] ids = {goodsId};
|
||||
map.put("ids", ids);
|
||||
// 商品ID
|
||||
//商品ID
|
||||
map.put("roomId", roomId);
|
||||
String content = HttpUtils.doPostWithJson(url, map);
|
||||
JSONObject json = new JSONObject(content);
|
||||
@ -149,9 +149,9 @@ public class WechatLivePlayerUtil {
|
||||
//发送url
|
||||
String url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/deleteInRoom?access_token=" + token;
|
||||
Map<String, Integer> map = new HashMap<>();
|
||||
// 直播间回放
|
||||
//直播间回放
|
||||
map.put("goodsId", goodsId);
|
||||
// 商品ID
|
||||
//商品ID
|
||||
map.put("roomId", roomId);
|
||||
String content = HttpUtils.doPostWithJson(url, map);
|
||||
JSONObject json = new JSONObject(content);
|
||||
@ -229,31 +229,31 @@ public class WechatLivePlayerUtil {
|
||||
|
||||
private Map<String, String> mockRoom(String token, Studio studio) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
// 背景图
|
||||
//背景图
|
||||
map.put("coverImg", wechatMediaUtil.uploadMedia(token, "image", studio.getCoverImg()));
|
||||
// 分享图
|
||||
//分享图
|
||||
map.put("shareImg", wechatMediaUtil.uploadMedia(token, "image", studio.getShareImg()));
|
||||
// 购物直播频道封面图
|
||||
//购物直播频道封面图
|
||||
map.put("feedsImg", wechatMediaUtil.uploadMedia(token, "image", studio.getFeedsImg()));
|
||||
// 直播间名字
|
||||
//直播间名字
|
||||
map.put("name", studio.getName());
|
||||
// 直播计划开始时间
|
||||
//直播计划开始时间
|
||||
map.put("startTime", studio.getStartTime());
|
||||
// 直播计划结束时间
|
||||
//直播计划结束时间
|
||||
map.put("endTime", studio.getEndTime());
|
||||
// 主播昵称
|
||||
//主播昵称
|
||||
map.put("anchorName", studio.getAnchorName());
|
||||
// 主播微信号
|
||||
//主播微信号
|
||||
map.put("anchorWechat", studio.getAnchorWechat());
|
||||
// 直播间类型
|
||||
//直播间类型
|
||||
map.put("type", "0");
|
||||
// 是否关闭点赞
|
||||
//是否关闭点赞
|
||||
map.put("closeLike", "0");
|
||||
// 是否关闭货架
|
||||
//是否关闭货架
|
||||
map.put("closeGoods", "0");
|
||||
// 是否关闭评论
|
||||
//是否关闭评论
|
||||
map.put("closeComment", "0");
|
||||
// 直播间名字
|
||||
//直播间名字
|
||||
map.put("closeReplay", "0");
|
||||
|
||||
return map;
|
||||
|
@ -40,7 +40,7 @@ public abstract class AuthDefaultRequest implements AuthRequest {
|
||||
if (!AuthChecker.isSupportedAuth(config, source)) {
|
||||
throw new AuthException(AuthResponseStatus.PARAMETER_INCOMPLETE, source);
|
||||
}
|
||||
// 校验配置合法性
|
||||
//校验配置合法性
|
||||
AuthChecker.checkConfig(config, source);
|
||||
}
|
||||
|
||||
@ -268,7 +268,7 @@ public abstract class AuthDefaultRequest implements AuthRequest {
|
||||
scopes = defaultScopes;
|
||||
}
|
||||
if (null == separator) {
|
||||
// 默认为空格
|
||||
//默认为空格
|
||||
separator = " ";
|
||||
}
|
||||
String scopeStr = String.join(separator, scopes);
|
||||
|
@ -107,7 +107,7 @@ public class AuthWeiboRequest extends AuthDefaultRequest {
|
||||
.msg(object.getString("error"))
|
||||
.build();
|
||||
}
|
||||
// 返回 result = true 表示取消授权成功,否则失败
|
||||
//返回 result = true 表示取消授权成功,否则失败
|
||||
AuthResponseStatus status = object.getBooleanValue("result") ? AuthResponseStatus.SUCCESS : AuthResponseStatus.FAILURE;
|
||||
return AuthResponse.builder().code(status.getCode()).msg(status.getMsg()).build();
|
||||
}
|
||||
|
@ -309,14 +309,14 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
|
||||
* @return 用户信息
|
||||
*/
|
||||
public JSONObject getUserInfo(String encryptedData, String sessionKey, String iv) {
|
||||
// 被加密的数据
|
||||
//被加密的数据
|
||||
byte[] dataByte = Base64.getDecoder().decode(encryptedData);
|
||||
// 加密秘钥
|
||||
//加密秘钥
|
||||
byte[] keyByte = Base64.getDecoder().decode(sessionKey);
|
||||
// 偏移量
|
||||
//偏移量
|
||||
byte[] ivByte = Base64.getDecoder().decode(iv);
|
||||
try {
|
||||
// 如果密钥不足16位,那么就补足. 这个if 中的内容很重要
|
||||
//如果密钥不足16位,那么就补足. 这个if 中的内容很重要
|
||||
int base = 16;
|
||||
if (keyByte.length % base != 0) {
|
||||
int groups = keyByte.length / base + (keyByte.length % base != 0 ? 1 : 0);
|
||||
@ -325,13 +325,13 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
|
||||
System.arraycopy(keyByte, 0, temp, 0, keyByte.length);
|
||||
keyByte = temp;
|
||||
}
|
||||
// 初始化
|
||||
//初始化
|
||||
Security.addProvider(new BouncyCastleProvider());
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding", "BC");
|
||||
SecretKeySpec spec = new SecretKeySpec(keyByte, "AES");
|
||||
AlgorithmParameters parameters = AlgorithmParameters.getInstance("AES");
|
||||
parameters.init(new IvParameterSpec(ivByte));
|
||||
// 初始化
|
||||
//初始化
|
||||
cipher.init(Cipher.DECRYPT_MODE, spec, parameters);
|
||||
byte[] resultByte = cipher.doFinal(dataByte);
|
||||
if (null != resultByte && resultByte.length > 0) {
|
||||
|
@ -47,9 +47,9 @@ public class AuthChecker {
|
||||
if (!GlobalAuthUtils.isHttpProtocol(redirectUri) && !GlobalAuthUtils.isHttpsProtocol(redirectUri)) {
|
||||
throw new AuthException(AuthResponseStatus.ILLEGAL_REDIRECT_URI, connectAuth);
|
||||
}
|
||||
// 支付宝在创建回调地址时,不允许使用localhost或者127.0.0.1
|
||||
//支付宝在创建回调地址时,不允许使用localhost或者127.0.0.1
|
||||
if (ConnectAuthEnum.ALIPAY == connectAuth && GlobalAuthUtils.isLocalHost(redirectUri)) {
|
||||
// The redirect uri of alipay is forbidden to use localhost or 127.0.0.1
|
||||
//The redirect uri of alipay is forbidden to use localhost or 127.0.0.1
|
||||
throw new AuthException(AuthResponseStatus.ILLEGAL_REDIRECT_URI, connectAuth);
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class Base64Utils {
|
||||
'4', '5', '6', '7', '8', '9', '-', '_' //
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------- encode
|
||||
//-------------------------------------------------------------------- encode
|
||||
|
||||
/**
|
||||
* 编码为Base64,非URL安全的
|
||||
@ -174,7 +174,7 @@ public class Base64Utils {
|
||||
}
|
||||
}
|
||||
|
||||
int left = len - evenlen;// 剩余位数
|
||||
int left = len - evenlen;//剩余位数
|
||||
if (left > 0) {
|
||||
int i = ((arr[evenlen] & 0xff) << 10) | (left == 2 ? ((arr[len - 1] & 0xff) << 2) : 0);
|
||||
|
||||
@ -182,7 +182,7 @@ public class Base64Utils {
|
||||
dest[destlen - 3] = encodeTable[(i >>> 6) & 0x3f];
|
||||
|
||||
if (isUrlSafe) {
|
||||
// 在URL Safe模式下,=为URL中的关键字符,不需要补充。空余的byte位要去掉。
|
||||
//在URL Safe模式下,=为URL中的关键字符,不需要补充。空余的byte位要去掉。
|
||||
int urlSafeLen = destlen - 2;
|
||||
if (2 == left) {
|
||||
dest[destlen - 2] = encodeTable[i & 0x3f];
|
||||
|
@ -190,7 +190,7 @@ public class ConnectUtil {
|
||||
|
||||
break;
|
||||
// case ALIPAY:
|
||||
// // 支付宝在创建回调地址时,不允许使用localhost或者127.0.0.1,所以这儿的回调地址使用的局域网内的ip
|
||||
// //支付宝在创建回调地址时,不允许使用localhost或者127.0.0.1,所以这儿的回调地址使用的局域网内的ip
|
||||
// authRequest = new AuthAlipayRequest(AuthConfig.builder()
|
||||
// .clientId("")
|
||||
// .clientSecret("")
|
||||
@ -231,9 +231,9 @@ public class ConnectUtil {
|
||||
return authRequest;
|
||||
}
|
||||
|
||||
// \b 是单词边界(连着的两个(字母字符 与 非字母字符) 之间的逻辑上的间隔),
|
||||
// 字符串在编译时会被转码一次,所以是 "\\b"
|
||||
// \B 是单词内部逻辑间隔(连着的两个字母字符之间的逻辑上的间隔)
|
||||
//\b 是单词边界(连着的两个(字母字符 与 非字母字符) 之间的逻辑上的间隔),
|
||||
//字符串在编译时会被转码一次,所以是 "\\b"
|
||||
//\B 是单词内部逻辑间隔(连着的两个字母字符之间的逻辑上的间隔)
|
||||
static String phoneReg = "\\b(ip(hone|od)|android|opera m(ob|in)i"
|
||||
+ "|windows (phone|ce)|blackberry"
|
||||
+ "|s(ymbian|eries60|amsung)|p(laybook|alm|rofile/midp"
|
||||
@ -257,7 +257,7 @@ public class ConnectUtil {
|
||||
if (null == userAgent) {
|
||||
userAgent = "";
|
||||
}
|
||||
// 匹配
|
||||
//匹配
|
||||
Matcher matcherPhone = phonePat.matcher(userAgent);
|
||||
Matcher matcherTable = tablePat.matcher(userAgent);
|
||||
if (matcherPhone.find() || matcherTable.find()) {
|
||||
|
@ -48,7 +48,7 @@ public class IpUtils {
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getRemoteAddr();
|
||||
}
|
||||
// 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
|
||||
//对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
|
||||
if (ip != null && ip.length() > 15) {
|
||||
if (ip.indexOf(",") > 0) {
|
||||
ip = ip.substring(0, ip.indexOf(","));
|
||||
|
@ -186,8 +186,8 @@ public class AliFileManagerPlugin implements FileManagerPlugin {
|
||||
|
||||
@Override
|
||||
public String getUrl(String url, Integer width, Integer height) {
|
||||
// 缩略图全路径
|
||||
// 返回缩略图全路径
|
||||
//缩略图全路径
|
||||
//返回缩略图全路径
|
||||
return url + "?x-oss-process=style/" + width + "X" + height;
|
||||
}
|
||||
}
|
||||
|
@ -51,12 +51,12 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
|
||||
return (List<CategoryVO>) cache.get(CachePrefix.CATEGORY.getPrefix() + "tree");
|
||||
}
|
||||
|
||||
// 获取全部分类
|
||||
//获取全部分类
|
||||
LambdaQueryWrapper<Category> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(Category::getDeleteFlag, false);
|
||||
List<Category> list = this.list(queryWrapper);
|
||||
|
||||
// 构造分类树
|
||||
//构造分类树
|
||||
List<CategoryVO> categoryVOList = new ArrayList<>();
|
||||
for (Category category : list) {
|
||||
if (category.getParentId().equals("0")) {
|
||||
@ -112,10 +112,10 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
|
||||
@Override
|
||||
public List<CategoryVO> listAllChildrenDB() {
|
||||
|
||||
// 获取全部分类
|
||||
//获取全部分类
|
||||
List<Category> list = this.list();
|
||||
|
||||
// 构造分类树
|
||||
//构造分类树
|
||||
List<CategoryVO> categoryVOList = new ArrayList<>();
|
||||
for (Category category : list) {
|
||||
if (category.getParentId().equals("0")) {
|
||||
@ -197,7 +197,7 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
|
||||
|
||||
@Override
|
||||
public void updateCategoryStatus(String categoryId, Boolean enableOperations) {
|
||||
// 禁用子分类
|
||||
//禁用子分类
|
||||
CategoryVO categoryVO = new CategoryVO(this.getById(categoryId));
|
||||
List<String> ids = new ArrayList<>();
|
||||
ids.add(categoryVO.getId());
|
||||
|
@ -45,10 +45,10 @@ public class GoodsGalleryServiceImpl extends ServiceImpl<GoodsGalleryMapper, Goo
|
||||
//确定好图片选择器后进行处理
|
||||
int i = 0;
|
||||
for (String origin : goodsGalleryList) {
|
||||
// 获取带所有缩略的相册
|
||||
//获取带所有缩略的相册
|
||||
GoodsGallery galley = this.getGoodsGallery(origin);
|
||||
galley.setGoodsId(goodsId);
|
||||
// 默认第一个为默认图片
|
||||
//默认第一个为默认图片
|
||||
galley.setIsDefault(i == 0 ? 1 : 0);
|
||||
i++;
|
||||
this.baseMapper.insert(galley);
|
||||
|
@ -105,17 +105,17 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
Goods goods = new Goods(goodsOperationDTO);
|
||||
//检查商品
|
||||
this.checkGoods(goods);
|
||||
// 向goods加入图片
|
||||
//向goods加入图片
|
||||
this.setGoodsGalleryParam(goodsOperationDTO.getGoodsGalleryList().get(0), goods);
|
||||
//添加商品
|
||||
this.save(goods);
|
||||
// 添加商品参数
|
||||
//添加商品参数
|
||||
if (goodsOperationDTO.getGoodsParamsList() != null && !goodsOperationDTO.getGoodsParamsList().isEmpty()) {
|
||||
this.goodsParamsService.addParams(goodsOperationDTO.getGoodsParamsList(), goods.getId());
|
||||
}
|
||||
// 添加商品sku信息
|
||||
//添加商品sku信息
|
||||
this.goodsSkuService.add(goodsOperationDTO.getSkuList(), goods);
|
||||
// 添加相册
|
||||
//添加相册
|
||||
if (goodsOperationDTO.getGoodsGalleryList() != null && !goodsOperationDTO.getGoodsGalleryList().isEmpty()) {
|
||||
this.goodsGalleryService.add(goodsOperationDTO.getGoodsGalleryList(), goods.getId());
|
||||
}
|
||||
@ -128,17 +128,17 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
goods.setId(goodsId);
|
||||
//检查商品信息
|
||||
this.checkGoods(goods);
|
||||
// 向goods加入图片
|
||||
//向goods加入图片
|
||||
this.setGoodsGalleryParam(goodsOperationDTO.getGoodsGalleryList().get(0), goods);
|
||||
//修改商品
|
||||
this.updateById(goods);
|
||||
// 添加商品参数
|
||||
//添加商品参数
|
||||
if (goodsOperationDTO.getGoodsParamsList() != null && !goodsOperationDTO.getGoodsParamsList().isEmpty()) {
|
||||
this.goodsParamsService.addParams(goodsOperationDTO.getGoodsParamsList(), goods.getId());
|
||||
}
|
||||
//修改商品sku信息
|
||||
this.goodsSkuService.update(goodsOperationDTO.getSkuList(), goods, goodsOperationDTO.getRegeneratorSkuFlag());
|
||||
// 添加相册
|
||||
//添加相册
|
||||
if (goodsOperationDTO.getGoodsGalleryList() != null && !goodsOperationDTO.getGoodsGalleryList().isEmpty()) {
|
||||
this.goodsGalleryService.add(goodsOperationDTO.getGoodsGalleryList(), goods.getId());
|
||||
}
|
||||
@ -165,7 +165,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
images.add(goodsGallery.getOriginal());
|
||||
}
|
||||
goodsVO.setGoodsGalleryList(images);
|
||||
// 商品sku赋值
|
||||
//商品sku赋值
|
||||
List<GoodsSkuVO> goodsListByGoodsId = goodsSkuService.getGoodsListByGoodsId(goodsId);
|
||||
if (goodsListByGoodsId != null && !goodsListByGoodsId.isEmpty()) {
|
||||
goodsVO.setSkuList(goodsListByGoodsId);
|
||||
@ -300,9 +300,9 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
LambdaQueryWrapper<MemberEvaluation> goodEvaluationQueryWrapper = new LambdaQueryWrapper<>();
|
||||
goodEvaluationQueryWrapper.eq(MemberEvaluation::getId, goodsId);
|
||||
goodEvaluationQueryWrapper.eq(MemberEvaluation::getGrade, EvaluationGradeEnum.GOOD.name());
|
||||
// 好评数量
|
||||
//好评数量
|
||||
int highPraiseNum = memberEvaluationService.count(goodEvaluationQueryWrapper);
|
||||
// 好评率
|
||||
//好评率
|
||||
double grade = NumberUtil.mul(NumberUtil.div(highPraiseNum, goods.getCommentNum().doubleValue(), 2), 100);
|
||||
goods.setGrade(grade);
|
||||
this.updateById(goods);
|
||||
@ -351,13 +351,13 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
if (goods.getId() != null) {
|
||||
this.checkExist(goods.getId());
|
||||
} else {
|
||||
// 评论次数
|
||||
//评论次数
|
||||
goods.setCommentNum(0);
|
||||
// 购买次数
|
||||
//购买次数
|
||||
goods.setBuyCount(0);
|
||||
// 购买次数
|
||||
//购买次数
|
||||
goods.setQuantity(0);
|
||||
// 商品评分
|
||||
//商品评分
|
||||
goods.setGrade(100.0);
|
||||
}
|
||||
|
||||
|
@ -88,12 +88,12 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
|
||||
@Override
|
||||
public void add(List<Map<String, Object>> skuList, Goods goods) {
|
||||
// 检查是否需要生成索引
|
||||
//检查是否需要生成索引
|
||||
boolean needIndex = checkNeedIndex(goods);
|
||||
List<GoodsSku> newSkuList;
|
||||
// 如果有规格
|
||||
//如果有规格
|
||||
if (skuList != null && !skuList.isEmpty()) {
|
||||
// 添加商品sku
|
||||
//添加商品sku
|
||||
newSkuList = this.addGoodsSku(skuList, goods, needIndex);
|
||||
} else {
|
||||
throw new ServiceException("规格必须要有一个!");
|
||||
@ -118,9 +118,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
|
||||
@Override
|
||||
public void update(List<Map<String, Object>> skuList, Goods goods, Boolean regeneratorSkuFlag) {
|
||||
// 检查是否需要生成索引
|
||||
//检查是否需要生成索引
|
||||
boolean needIndex = checkNeedIndex(goods);
|
||||
// 是否存在规格
|
||||
//是否存在规格
|
||||
if (skuList == null || skuList.isEmpty()) {
|
||||
throw new ServiceException("规格必须要有一个!");
|
||||
}
|
||||
@ -138,7 +138,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
this.removeByIds(oldSkuIds);
|
||||
//删除sku相册
|
||||
goodsGalleryService.removeByIds(oldSkuIds);
|
||||
// 添加商品sku
|
||||
//添加商品sku
|
||||
newSkuList = this.addGoodsSku(skuList, goods, needIndex);
|
||||
|
||||
//发送mq消息
|
||||
@ -216,7 +216,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
throw new ServiceException("商品已下架");
|
||||
}
|
||||
}
|
||||
// 获取当前商品的索引信息
|
||||
//获取当前商品的索引信息
|
||||
EsGoodsIndex goodsIndex = goodsIndexService.findById(skuId);
|
||||
if (goodsIndex == null) {
|
||||
goodsIndex = new EsGoodsIndex(goodsSku);
|
||||
@ -225,7 +225,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
//商品规格
|
||||
GoodsSkuVO goodsSkuDetail = this.getGoodsSkuVO(goodsSku);
|
||||
|
||||
// 设置当前商品的促销价格
|
||||
//设置当前商品的促销价格
|
||||
if (goodsIndex.getPromotionMap() != null && !goodsIndex.getPromotionMap().isEmpty() && goodsIndex.getPromotionPrice() != null) {
|
||||
goodsSkuDetail.setPromotionPrice(goodsIndex.getPromotionPrice());
|
||||
}
|
||||
@ -426,13 +426,13 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
goodEvaluationQueryWrapper.eq(MemberEvaluation::getSkuId, goodsSku.getId());
|
||||
goodEvaluationQueryWrapper.eq(MemberEvaluation::getGrade, EvaluationGradeEnum.GOOD.name());
|
||||
|
||||
// 好评数量
|
||||
//好评数量
|
||||
int highPraiseNum = memberEvaluationService.count(goodEvaluationQueryWrapper);
|
||||
|
||||
// 更新商品评价数量
|
||||
//更新商品评价数量
|
||||
goodsSku.setCommentNum(goodsSku.getCommentNum() != null ? goodsSku.getCommentNum() + 1 : 1);
|
||||
|
||||
// 好评率
|
||||
//好评率
|
||||
double grade = NumberUtil.mul(NumberUtil.div(highPraiseNum, goodsSku.getCommentNum().doubleValue(), 2), 100);
|
||||
goodsSku.setGrade(grade);
|
||||
//修改规格
|
||||
|
@ -59,7 +59,7 @@ public class MemberNoticeSenterServiceImpl extends ServiceImpl<MemberNoticeSente
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} // 否则是全部会员发送
|
||||
} //否则是全部会员发送
|
||||
else {
|
||||
List<Member> members = memberService.list();
|
||||
MemberNotice memberNotice;
|
||||
|
@ -100,7 +100,7 @@ public class WechatMessageUtil {
|
||||
String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + token;
|
||||
|
||||
Map<String, String> map = new HashMap<>();
|
||||
// 用户id
|
||||
//用户id
|
||||
map.put("touser", connect.getUnionId());
|
||||
//模版id
|
||||
map.put("template_id", wechatMessage.getCode());
|
||||
@ -157,7 +157,7 @@ public class WechatMessageUtil {
|
||||
String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + token;
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
// 用户id
|
||||
//用户id
|
||||
map.put("touser", connect.getUnionId());
|
||||
//模版id
|
||||
map.put("template_id", wechatMPMessage.getCode());
|
||||
|
@ -60,26 +60,26 @@ public class WechatMpCodeUtil {
|
||||
params.put("path", path);
|
||||
params.put("width", "280");
|
||||
|
||||
// ======================================================================//
|
||||
// 执行URL Post调用
|
||||
// ======================================================================//
|
||||
//======================================================================//
|
||||
//执行URL Post调用
|
||||
//======================================================================//
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
HttpPost httpPost = new HttpPost(CREATE_QR_CODE + accessToken);
|
||||
httpPost.addHeader(HTTP.CONTENT_TYPE, "application/json");
|
||||
// 必须是json模式的 post
|
||||
//必须是json模式的 post
|
||||
String body = JSON.toJSONString(params);
|
||||
StringEntity entity = new StringEntity(body);
|
||||
entity.setContentType("image/png");
|
||||
httpPost.setEntity(entity);
|
||||
HttpResponse httpResponse = httpClient.execute(httpPost);
|
||||
HttpEntity httpEntity = httpResponse.getEntity();
|
||||
// ======================================================================//
|
||||
// 处理HTTP返回结果
|
||||
// ======================================================================//
|
||||
//======================================================================//
|
||||
//处理HTTP返回结果
|
||||
//======================================================================//
|
||||
InputStream contentStream = httpEntity.getContent();
|
||||
byte[] bytes = toByteArray(contentStream);
|
||||
contentStream.read(bytes);
|
||||
// 返回内容
|
||||
//返回内容
|
||||
return Base64.getEncoder().encodeToString(bytes);
|
||||
} catch (Exception e) {
|
||||
log.error("生成二维码错误:", e);
|
||||
@ -117,26 +117,26 @@ public class WechatMpCodeUtil {
|
||||
params.put("scene", shortLink.getId());
|
||||
params.put("width", "280");
|
||||
|
||||
// ======================================================================//
|
||||
// 执行URL Post调用
|
||||
// ======================================================================//
|
||||
//======================================================================//
|
||||
//执行URL Post调用
|
||||
//======================================================================//
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
HttpPost httpPost = new HttpPost(UN_LIMIT_API + accessToken);
|
||||
httpPost.addHeader(HTTP.CONTENT_TYPE, "application/json");
|
||||
// 必须是json模式的 post
|
||||
//必须是json模式的 post
|
||||
String body = JSON.toJSONString(params);
|
||||
StringEntity entity = new StringEntity(body);
|
||||
entity.setContentType("image/png");
|
||||
httpPost.setEntity(entity);
|
||||
HttpResponse httpResponse = httpClient.execute(httpPost);
|
||||
HttpEntity httpEntity = httpResponse.getEntity();
|
||||
// ======================================================================//
|
||||
// 处理HTTP返回结果
|
||||
// ======================================================================//
|
||||
//======================================================================//
|
||||
//处理HTTP返回结果
|
||||
//======================================================================//
|
||||
InputStream contentStream = httpEntity.getContent();
|
||||
byte[] bytes = toByteArray(contentStream);
|
||||
contentStream.read(bytes);
|
||||
// 返回内容
|
||||
//返回内容
|
||||
return Base64.getEncoder().encodeToString(bytes);
|
||||
} catch (Exception e) {
|
||||
log.error("生成二维码错误:", e);
|
||||
|
@ -34,7 +34,7 @@ public class CartPriceRender implements CartRenderStep {
|
||||
|
||||
@Override
|
||||
public void render(TradeDTO tradeDTO) {
|
||||
// 构造cartVO
|
||||
//构造cartVO
|
||||
this.buildCart(tradeDTO);
|
||||
this.buildCartPrice(tradeDTO);
|
||||
this.buildTradePrice(tradeDTO);
|
||||
@ -70,11 +70,11 @@ public class CartPriceRender implements CartRenderStep {
|
||||
//购物车列表
|
||||
List<CartVO> cartVOS = tradeDTO.getCartList();
|
||||
|
||||
// key store id
|
||||
// value 商品列表
|
||||
//key store id
|
||||
//value 商品列表
|
||||
Map<String, List<CartSkuVO>> map = new HashMap<>();
|
||||
for (CartSkuVO cartSkuVO : cartSkuVOList) {
|
||||
// 如果存在商家id
|
||||
//如果存在商家id
|
||||
if (map.containsKey(cartSkuVO.getGoodsSku().getStoreId())) {
|
||||
List<CartSkuVO> list = map.get(cartSkuVO.getGoodsSku().getStoreId());
|
||||
list.add(cartSkuVO);
|
||||
@ -94,15 +94,15 @@ public class CartPriceRender implements CartRenderStep {
|
||||
for (CartSkuVO cartSkuVO : cartSkuVOS) {
|
||||
if (Boolean.TRUE.equals(cartSkuVO.getChecked())) {
|
||||
PriceDetailDTO priceDetailDTO = cartSkuVO.getPriceDetailDTO();
|
||||
// 流水金额(入账 出帐金额) = goodsPrice + freight - discountPrice - couponPrice
|
||||
//流水金额(入账 出帐金额) = goodsPrice + freight - discountPrice - couponPrice
|
||||
double flowPrice = CurrencyUtil.sub(CurrencyUtil.add(priceDetailDTO.getGoodsPrice(), priceDetailDTO.getFreightPrice()), CurrencyUtil.add(priceDetailDTO.getDiscountPrice(), priceDetailDTO.getCouponPrice() != null ? priceDetailDTO.getCouponPrice() : 0));
|
||||
priceDetailDTO.setFlowPrice(flowPrice);
|
||||
|
||||
// 最终结算金额 = flowPrice - platFormCommission - distributionCommission
|
||||
//最终结算金额 = flowPrice - platFormCommission - distributionCommission
|
||||
double billPrice = CurrencyUtil.sub(CurrencyUtil.sub(flowPrice, priceDetailDTO.getPlatFormCommission()), priceDetailDTO.getDistributionCommission());
|
||||
priceDetailDTO.setBillPrice(billPrice);
|
||||
|
||||
// 平台佣金
|
||||
//平台佣金
|
||||
String categoryId = cartSkuVO.getGoodsSku().getCategoryPath().substring(
|
||||
cartSkuVO.getGoodsSku().getCategoryPath().lastIndexOf(",") + 1
|
||||
);
|
||||
|
@ -70,7 +70,7 @@ public class CheckDataRender implements CartRenderStep {
|
||||
cartSkuVO.setErrorMessage("商品信息发生变化,已失效");
|
||||
continue;
|
||||
}
|
||||
// 商品上架状态判定
|
||||
//商品上架状态判定
|
||||
if (!GoodsAuthEnum.PASS.name().equals(dataSku.getIsAuth()) || !GoodsStatusEnum.UPPER.name().equals(dataSku.getMarketEnable())) {
|
||||
//设置购物车未选中
|
||||
cartSkuVO.setChecked(false);
|
||||
@ -80,7 +80,7 @@ public class CheckDataRender implements CartRenderStep {
|
||||
cartSkuVO.setErrorMessage("商品已下架");
|
||||
continue;
|
||||
}
|
||||
// 商品库存判定
|
||||
//商品库存判定
|
||||
if (dataSku.getQuantity() < cartSkuVO.getNum()) {
|
||||
//设置购物车未选中
|
||||
cartSkuVO.setChecked(false);
|
||||
@ -98,10 +98,10 @@ public class CheckDataRender implements CartRenderStep {
|
||||
* @param tradeDTO
|
||||
*/
|
||||
private void groupStore(TradeDTO tradeDTO) {
|
||||
// 渲染的购物车
|
||||
//渲染的购物车
|
||||
List<CartVO> cartList = new ArrayList<>();
|
||||
|
||||
// 根据店铺分组
|
||||
//根据店铺分组
|
||||
Map<String, List<CartSkuVO>> storeCollect = tradeDTO.getSkuList().parallelStream().collect(Collectors.groupingBy(CartSkuVO::getStoreId));
|
||||
for (Map.Entry<String, List<CartSkuVO>> storeCart : storeCollect.entrySet()) {
|
||||
if (!storeCart.getValue().isEmpty()) {
|
||||
|
@ -25,7 +25,7 @@ public class CouponRender implements CartRenderStep {
|
||||
public void render(TradeDTO tradeDTO) {
|
||||
|
||||
//主要渲染各个优惠的价格
|
||||
// this.renderCoupon(tradeDTO);
|
||||
//this.renderCoupon(tradeDTO);
|
||||
|
||||
}
|
||||
|
||||
|
@ -32,17 +32,17 @@ public class FullDiscountRender implements CartRenderStep {
|
||||
@Override
|
||||
public void render(TradeDTO tradeDTO) {
|
||||
|
||||
// 获取购物车中所有的商品
|
||||
//获取购物车中所有的商品
|
||||
List<CartSkuVO> cartSkuList = tradeDTO.getSkuList();
|
||||
|
||||
// 店铺id集合
|
||||
//店铺id集合
|
||||
List<String> storeIds = new ArrayList<>();
|
||||
|
||||
// 店铺集合
|
||||
//店铺集合
|
||||
List<CartVO> cartList = tradeDTO.getCartList();
|
||||
|
||||
|
||||
// 获取店铺id
|
||||
//获取店铺id
|
||||
Map<String, List<CartSkuVO>> storeCollect = tradeDTO.getSkuList().parallelStream().collect(Collectors.groupingBy(CartSkuVO::getStoreId));
|
||||
for (Map.Entry<String, List<CartSkuVO>> storeCart : storeCollect.entrySet()) {
|
||||
if (!storeCart.getValue().isEmpty()) {
|
||||
@ -50,7 +50,7 @@ public class FullDiscountRender implements CartRenderStep {
|
||||
}
|
||||
}
|
||||
|
||||
// 获取当前店铺进行到满减活动
|
||||
//获取当前店铺进行到满减活动
|
||||
List<FullDiscountVO> fullDiscounts = fullDiscountService.currentPromotion(storeIds);
|
||||
//循环满减信息
|
||||
for (FullDiscountVO fullDiscount : fullDiscounts) {
|
||||
@ -63,7 +63,7 @@ public class FullDiscountRender implements CartRenderStep {
|
||||
//写入满减活动
|
||||
cart.setFullDiscount(fullDiscount);
|
||||
List<String> skuIds;
|
||||
// 参与活动的sku判定
|
||||
//参与活动的sku判定
|
||||
if (fullDiscount.getNumber() != -1) {
|
||||
skuIds = initFullDiscountGoods(fullDiscount, cartSkuList);
|
||||
} else {
|
||||
|
@ -118,7 +118,7 @@ public class SkuFreightRender implements CartRenderStep {
|
||||
return finalFreight;
|
||||
}
|
||||
Double continuedCount = count - template.getFirstCompany();
|
||||
// 计算续重价格
|
||||
//计算续重价格
|
||||
return CurrencyUtil.add(finalFreight,
|
||||
CurrencyUtil.mul(NumberUtil.parseInt(String.valueOf((continuedCount / template.getContinuedCompany()))), template.getContinuedPrice()));
|
||||
} catch (Exception e) {
|
||||
|
@ -70,7 +70,7 @@ public class SkuPromotionRender implements CartRenderStep {
|
||||
*/
|
||||
private void renderSkuPromotion(TradeDTO tradeDTO) {
|
||||
|
||||
// 渲染促销价格
|
||||
//渲染促销价格
|
||||
this.renderPromotionPrice(tradeDTO);
|
||||
|
||||
//拼团和积分购买需要特殊处理,这里优先特殊处理
|
||||
@ -110,12 +110,12 @@ public class SkuPromotionRender implements CartRenderStep {
|
||||
for (CartVO cartVO : cartList) {
|
||||
if (Boolean.TRUE.equals(cartVO.getChecked())) {
|
||||
for (CartSkuVO cartSkuVO : cartVO.getSkuList()) {
|
||||
// 检查当前购物车商品是否有效且为选中
|
||||
//检查当前购物车商品是否有效且为选中
|
||||
if (Boolean.TRUE.equals(cartSkuVO.getChecked()) && Boolean.FALSE.equals(cartSkuVO.getInvalid())) {
|
||||
PromotionPriceParamDTO param = new PromotionPriceParamDTO();
|
||||
param.setSkuId(cartSkuVO.getGoodsSku().getId());
|
||||
param.setNum(cartSkuVO.getNum());
|
||||
// 是否为拼团商品计算
|
||||
//是否为拼团商品计算
|
||||
if (cartSkuVO.getPintuanId() != null) {
|
||||
param.setPintuanId(cartSkuVO.getPintuanId());
|
||||
}
|
||||
@ -126,19 +126,19 @@ public class SkuPromotionRender implements CartRenderStep {
|
||||
}
|
||||
//如果包含促销规则
|
||||
if (!promotionPriceParamList.isEmpty()) {
|
||||
// 店铺优惠券集合
|
||||
//店铺优惠券集合
|
||||
List<MemberCoupon> memberCoupons = new ArrayList<>();
|
||||
if (tradeDTO.getStoreCoupons() != null) {
|
||||
memberCoupons.addAll(tradeDTO.getStoreCoupons().values().parallelStream().map(MemberCouponDTO::getMemberCoupon).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
// 平台优惠券
|
||||
//平台优惠券
|
||||
if (tradeDTO.getPlatformCoupon() != null && tradeDTO.getPlatformCoupon().getMemberCoupon() != null) {
|
||||
memberCoupons.add(tradeDTO.getPlatformCoupon().getMemberCoupon());
|
||||
}
|
||||
// 检查优惠券集合中是否存在过期优惠券
|
||||
//检查优惠券集合中是否存在过期优惠券
|
||||
this.checkMemberCoupons(memberCoupons);
|
||||
// 调用价格计算模块,返回价格计算结果
|
||||
//调用价格计算模块,返回价格计算结果
|
||||
PromotionPriceDTO promotionPrice = promotionPriceService.calculationPromotionPrice(promotionPriceParamList, memberCoupons);
|
||||
// 分配计算后的促销
|
||||
this.distributionPromotionPrice(tradeDTO, promotionPrice);
|
||||
@ -159,11 +159,11 @@ public class SkuPromotionRender implements CartRenderStep {
|
||||
private void distributionPromotionPrice(TradeDTO tradeDTO, PromotionPriceDTO promotionPrice) {
|
||||
|
||||
for (CartVO cartVO : tradeDTO.getCartList()) {
|
||||
// 根据店铺分配店铺价格计算结果
|
||||
//根据店铺分配店铺价格计算结果
|
||||
Optional<StorePromotionPriceDTO> storePromotionPriceDTOOptional = promotionPrice.getStorePromotionPriceList().parallelStream().filter(i -> i.getStoreId().equals(cartVO.getStoreId())).findAny();
|
||||
if (storePromotionPriceDTOOptional.isPresent()) {
|
||||
StorePromotionPriceDTO storePromotionPriceDTO = storePromotionPriceDTOOptional.get();
|
||||
// 根据商品分配商品结果计算结果
|
||||
//根据商品分配商品结果计算结果
|
||||
this.distributionSkuPromotionPrice(cartVO.getSkuList(), storePromotionPriceDTO);
|
||||
|
||||
PriceDetailDTO sSpd = new PriceDetailDTO();
|
||||
@ -183,7 +183,7 @@ public class SkuPromotionRender implements CartRenderStep {
|
||||
}
|
||||
}
|
||||
|
||||
// 根据整个购物车分配价格计算结果
|
||||
//根据整个购物车分配价格计算结果
|
||||
PriceDetailDTO priceDetailDTO = new PriceDetailDTO();
|
||||
|
||||
priceDetailDTO.setDiscountPrice(promotionPrice.getTotalDiscountPrice());
|
||||
@ -203,7 +203,7 @@ public class SkuPromotionRender implements CartRenderStep {
|
||||
private void distributionSkuPromotionPrice(List<CartSkuVO> skuList, StorePromotionPriceDTO storePromotionPriceDTO) {
|
||||
if (storePromotionPriceDTO != null) {
|
||||
for (CartSkuVO cartSkuVO : skuList) {
|
||||
// 获取当前购物车商品的商品计算结果
|
||||
//获取当前购物车商品的商品计算结果
|
||||
List<GoodsSkuPromotionPriceDTO> collect = storePromotionPriceDTO.getGoodsSkuPromotionPriceList().parallelStream().filter(i -> i.getSkuId().equals(cartSkuVO.getGoodsSku().getId())).collect(Collectors.toList());
|
||||
if (!collect.isEmpty()) {
|
||||
GoodsSkuPromotionPriceDTO goodsSkuPromotionPriceDTO = collect.get(0);
|
||||
@ -301,7 +301,7 @@ public class SkuPromotionRender implements CartRenderStep {
|
||||
|
||||
private void checkPromotionLimit(TradeDTO tradeDTO) {
|
||||
if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.PINTUAN)) {
|
||||
// 如果为拼团订单,则获取拼团活动ID
|
||||
//如果为拼团订单,则获取拼团活动ID
|
||||
Optional<String> pintuanId = tradeDTO.getSkuList().get(0).getPromotions().stream().filter(i -> i.getPromotionType().equals(PromotionTypeEnum.PINTUAN.name())).map(PromotionGoods::getPromotionId).findFirst();
|
||||
if (pintuanId.isPresent()) {
|
||||
Pintuan pintuan = pintuanService.getPintuanById(pintuanId.get());
|
||||
|
@ -145,7 +145,7 @@ public class CartServiceImpl implements CartService {
|
||||
|
||||
|
||||
tradeDTO.setCartTypeEnum(cartTypeEnum);
|
||||
// 如购物车发生更改,则重置优惠券
|
||||
//如购物车发生更改,则重置优惠券
|
||||
tradeDTO.setStoreCoupons(null);
|
||||
tradeDTO.setPlatformCoupon(null);
|
||||
this.resetTradeDTO(tradeDTO);
|
||||
@ -282,10 +282,10 @@ public class CartServiceImpl implements CartService {
|
||||
}
|
||||
}
|
||||
cartSkuVOS.removeAll(deleteVos);
|
||||
// 清除选择的优惠券
|
||||
//清除选择的优惠券
|
||||
tradeDTO.setPlatformCoupon(null);
|
||||
tradeDTO.setStoreCoupons(null);
|
||||
// 清除添加过的备注
|
||||
//清除添加过的备注
|
||||
tradeDTO.setStoreRemark(null);
|
||||
cache.put(this.getOriginKey(tradeDTO.getCartTypeEnum()), tradeDTO);
|
||||
}
|
||||
@ -339,7 +339,7 @@ public class CartServiceImpl implements CartService {
|
||||
}
|
||||
List<MemberCoupon> allScopeMemberCoupon = memberCouponService.getAllScopeMemberCoupon(tradeDTO.getMemberId(), storeIds);
|
||||
if (allScopeMemberCoupon != null && !allScopeMemberCoupon.isEmpty()) {
|
||||
// 过滤满足消费门槛
|
||||
//过滤满足消费门槛
|
||||
count += allScopeMemberCoupon.stream().filter(i -> i.getConsumeThreshold() <= totalPrice).count();
|
||||
}
|
||||
}
|
||||
@ -548,10 +548,10 @@ public class CartServiceImpl implements CartService {
|
||||
private void useCoupon(TradeDTO tradeDTO, MemberCoupon memberCoupon, CartTypeEnum cartTypeEnum) {
|
||||
//如果是平台优惠券
|
||||
if (Boolean.TRUE.equals(memberCoupon.getIsPlatform())) {
|
||||
// 购物车价格
|
||||
//购物车价格
|
||||
Double cartPrice = 0d;
|
||||
for (CartSkuVO cartSkuVO : tradeDTO.getSkuList()) {
|
||||
// 获取商品的促销信息
|
||||
//获取商品的促销信息
|
||||
Optional<PromotionGoods> promotionOptional =
|
||||
cartSkuVO.getPromotions().parallelStream().filter(promotionGoods ->
|
||||
(promotionGoods.getPromotionType().equals(PromotionTypeEnum.PINTUAN.name()) &&
|
||||
@ -576,7 +576,7 @@ public class CartServiceImpl implements CartService {
|
||||
else {
|
||||
//过滤对应店铺购物车
|
||||
CartSkuVO cartVO = tradeDTO.getSkuList().stream().filter(i -> i.getStoreId().equals(memberCoupon.getStoreId())).findFirst().orElse(null);
|
||||
// 优惠券消费门槛 <= 商品购买时的成交价(单品) * 购买数量
|
||||
//优惠券消费门槛 <= 商品购买时的成交价(单品) * 购买数量
|
||||
if (cartVO != null && memberCoupon.getConsumeThreshold() <= CurrencyUtil.mul(cartVO.getPurchasePrice(), cartVO.getNum())) {
|
||||
tradeDTO.getStoreCoupons().put(memberCoupon.getStoreId(), new MemberCouponDTO(memberCoupon));
|
||||
//选择店铺优惠券,则将品台优惠券清空
|
||||
@ -603,15 +603,15 @@ public class CartServiceImpl implements CartService {
|
||||
cartSkuVOS = tradeDTO.getSkuList();
|
||||
}
|
||||
|
||||
// 当初购物车商品中是否存在符合优惠券条件的商品sku
|
||||
//当初购物车商品中是否存在符合优惠券条件的商品sku
|
||||
if (memberCoupon.getScopeType().equals(CouponScopeTypeEnum.PORTION_GOODS_CATEGORY.name())) {
|
||||
// 分类路径是否包含
|
||||
//分类路径是否包含
|
||||
return cartSkuVOS.stream().anyMatch(i -> i.getGoodsSku().getCategoryPath().indexOf("," + memberCoupon.getScopeId() + ",") <= 0);
|
||||
} else if (memberCoupon.getScopeType().equals(CouponScopeTypeEnum.PORTION_GOODS.name())) {
|
||||
// 范围关联ID是否包含
|
||||
//范围关联ID是否包含
|
||||
return cartSkuVOS.stream().anyMatch(i -> memberCoupon.getScopeId().indexOf("," + i.getGoodsSku().getId() + ",") <= 0);
|
||||
} else if (memberCoupon.getScopeType().equals(CouponScopeTypeEnum.PORTION_SHOP_CATEGORY.name())) {
|
||||
// 分类路径是否包含
|
||||
//分类路径是否包含
|
||||
return cartSkuVOS.stream().anyMatch(i -> i.getGoodsSku().getStoreCategoryPath().indexOf("," + memberCoupon.getScopeId() + ",") <= 0);
|
||||
}
|
||||
return true;
|
||||
|
@ -97,7 +97,7 @@ public class AfterSale extends BaseEntity {
|
||||
@ApiModelProperty(value = "售后单状态", allowableValues = "APPLY,PASS,REFUSE,BUYER_RETURN,SELLER_RE_DELIVERY,BUYER_CONFIRM,SELLER_CONFIRM,COMPLETE")
|
||||
private String serviceStatus;
|
||||
|
||||
// 退款信息
|
||||
//退款信息
|
||||
|
||||
/**
|
||||
* @see cn.lili.modules.order.trade.entity.enums.AfterSaleRefundWayEnum
|
||||
@ -135,7 +135,7 @@ public class AfterSale extends BaseEntity {
|
||||
@ApiModelProperty(value = "退款时间")
|
||||
private Date refundTime;
|
||||
|
||||
// 买家物流信息
|
||||
//买家物流信息
|
||||
@ApiModelProperty(value = "发货单号")
|
||||
private String mLogisticsNo;
|
||||
|
||||
|
@ -101,7 +101,7 @@ public class OrderSearchParams extends PageVO {
|
||||
wrapper.like("o.sn", keywords);
|
||||
wrapper.like("oi.goods_name", keywords);
|
||||
}
|
||||
// 按卖家查询
|
||||
//按卖家查询
|
||||
if (StringUtils.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.STORE.name())) {
|
||||
wrapper.eq("o.store_id", UserContext.getCurrentUser().getStoreId());
|
||||
}
|
||||
@ -109,44 +109,44 @@ public class OrderSearchParams extends PageVO {
|
||||
&& StringUtils.isNotEmpty(storeId)) {
|
||||
wrapper.eq("o.store_id", storeId);
|
||||
}
|
||||
// 按买家查询
|
||||
//按买家查询
|
||||
if (StringUtils.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.MEMBER.name())) {
|
||||
wrapper.eq("o.member_id", UserContext.getCurrentUser().getId());
|
||||
}
|
||||
// 按照买家查询
|
||||
//按照买家查询
|
||||
if (StringUtils.isNotEmpty(memberId)) {
|
||||
wrapper.like("o.member_id", memberId);
|
||||
}
|
||||
|
||||
// 按订单编号查询
|
||||
//按订单编号查询
|
||||
if (StringUtils.isNotEmpty(orderSn)) {
|
||||
wrapper.like("o.sn", orderSn);
|
||||
}
|
||||
|
||||
// 按时间查询
|
||||
//按时间查询
|
||||
if (startDate != null) {
|
||||
wrapper.ge("o.create_time", startDate);
|
||||
}
|
||||
if (endDate != null) {
|
||||
wrapper.le("o.create_time", DateUtil.endOfDate(endDate));
|
||||
}
|
||||
// 按购买人用户名
|
||||
//按购买人用户名
|
||||
if (StringUtils.isNotEmpty(buyerName)) {
|
||||
wrapper.like("o.member_name", buyerName);
|
||||
}
|
||||
|
||||
// 按订单类型
|
||||
//按订单类型
|
||||
if (StringUtils.isNotEmpty(orderType)) {
|
||||
wrapper.eq("o.order_type", orderType)
|
||||
.or().eq("o.order_promotion_type", orderType);
|
||||
}
|
||||
|
||||
// 按支付方式
|
||||
//按支付方式
|
||||
if (StringUtils.isNotEmpty(paymentMethod)) {
|
||||
wrapper.eq("o.payment_method", paymentMethod);
|
||||
}
|
||||
|
||||
// 按标签查询
|
||||
//按标签查询
|
||||
if (StringUtils.isNotEmpty(tag)) {
|
||||
String orderStatusColumn = "o.order_status";
|
||||
OrderTagEnum tagEnum = OrderTagEnum.valueOf(tag);
|
||||
@ -179,7 +179,7 @@ public class OrderSearchParams extends PageVO {
|
||||
if (StringUtils.isNotEmpty(shipName)) {
|
||||
wrapper.like("o.ship_name", shipName);
|
||||
}
|
||||
// 按商品名称查询
|
||||
//按商品名称查询
|
||||
if (StringUtils.isNotEmpty(goodsName)) {
|
||||
wrapper.like("oi.goods_name", goodsName);
|
||||
}
|
||||
|
@ -72,11 +72,11 @@ public class AfterSaleSearchParams extends PageVO {
|
||||
if (StringUtils.isNotEmpty(orderSn)) {
|
||||
queryWrapper.like("order_sn", orderSn);
|
||||
}
|
||||
// 按买家查询
|
||||
//按买家查询
|
||||
if (StringUtils.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.MEMBER.name())) {
|
||||
queryWrapper.eq("member_id", UserContext.getCurrentUser().getId());
|
||||
}
|
||||
// 按卖家查询
|
||||
//按卖家查询
|
||||
if (StringUtils.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.STORE.name())) {
|
||||
queryWrapper.eq("store_id", UserContext.getCurrentUser().getStoreId());
|
||||
}
|
||||
@ -96,7 +96,7 @@ public class AfterSaleSearchParams extends PageVO {
|
||||
if (StringUtils.isNotEmpty(goodsName)) {
|
||||
queryWrapper.like("goods_name", goodsName);
|
||||
}
|
||||
// 按时间查询
|
||||
//按时间查询
|
||||
if (startDate != null) {
|
||||
queryWrapper.ge("create_time", startDate);
|
||||
}
|
||||
|
@ -440,7 +440,7 @@ public class AfterSaleServiceImpl extends ServiceImpl<AfterSaleMapper, AfterSale
|
||||
this.checkAfterSaleReturnMoneyParam(afterSaleDTO);
|
||||
break;
|
||||
case RETURN_GOODS:
|
||||
// 是否为有效状态
|
||||
//是否为有效状态
|
||||
boolean availableStatus = StrUtil.equalsAny(order.getOrderStatus(), OrderStatusEnum.DELIVERED.name(), OrderStatusEnum.COMPLETED.name());
|
||||
if (!PayStatusEnum.PAID.name().equals(order.getPayStatus()) && availableStatus) {
|
||||
throw new ServiceException(ResultCode.AFTER_SALES_BAN);
|
||||
|
@ -155,7 +155,7 @@ public class OrderPriceServiceImpl implements OrderPriceService {
|
||||
//计算修改后的订单货物金额
|
||||
double flowPrice = CurrencyUtil.mul(order.getFlowPrice(), priceFluctuationRatio);
|
||||
|
||||
// 记录修改金额
|
||||
//记录修改金额
|
||||
priceDetailDTO.setUpdatePrice(CurrencyUtil.sub(priceDetailDTO.getOriginalPrice(), flowPrice));
|
||||
priceDetailDTO.setFlowPrice(flowPrice);
|
||||
|
||||
@ -163,7 +163,7 @@ public class OrderPriceServiceImpl implements OrderPriceService {
|
||||
Double platFormCommission = CurrencyUtil.div(CurrencyUtil.mul(flowPrice, categoryService.getById(orderItem.getCategoryId()).getCommissionRate()), 100);
|
||||
priceDetailDTO.setPlatFormCommission(platFormCommission);
|
||||
|
||||
// 最终结算金额 = 流水金额-平台佣金-分销提佣
|
||||
//最终结算金额 = 流水金额-平台佣金-分销提佣
|
||||
double billPrice = CurrencyUtil.sub(CurrencyUtil.sub(priceDetailDTO.getFlowPrice(),priceDetailDTO.getPlatFormCommission()),
|
||||
priceDetailDTO.getDistributionCommission());
|
||||
priceDetailDTO.setBillPrice(billPrice);
|
||||
|
@ -161,9 +161,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
this.saveBatch(orders);
|
||||
//批量保存 子订单
|
||||
orderItemService.saveBatch(orderItems);
|
||||
// 批量记录订单操作日志
|
||||
//批量记录订单操作日志
|
||||
orderLogService.saveBatch(orderLogs);
|
||||
// 赠品根据店铺单独生成订单
|
||||
//赠品根据店铺单独生成订单
|
||||
this.generatorGiftOrder(tradeDTO);
|
||||
}
|
||||
|
||||
@ -304,7 +304,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
//要记录之前的收货地址,所以需要以代码方式进行调用 不采用注解
|
||||
String message = "订单[" + orderSn + "]收货信息修改,由[" + order.getConsigneeDetail() + "]修改为[" + memberAddressDTO.getConsigneeDetail() + "]";
|
||||
|
||||
BeanUtil.copyProperties(memberAddressDTO, order);// 记录订单操作日志
|
||||
BeanUtil.copyProperties(memberAddressDTO, order);//记录订单操作日志
|
||||
this.updateById(order);
|
||||
|
||||
OrderLog orderLog = new OrderLog(orderSn, UserContext.getCurrentUser().getId(), UserContext.getCurrentUser().getRole().getRole(), UserContext.getCurrentUser().getUsername(), message);
|
||||
@ -401,7 +401,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
orderMessage.setOrderSn(order.getSn());
|
||||
this.sendUpdateStatusMessage(orderMessage);
|
||||
|
||||
// 发送当前商品购买完成的信息(用于更新商品数据)
|
||||
//发送当前商品购买完成的信息(用于更新商品数据)
|
||||
List<OrderItem> orderItems = orderItemService.getByOrderSn(orderSn);
|
||||
List<GoodsCompleteMessage> goodsCompleteMessageList = new ArrayList<>();
|
||||
for (OrderItem orderItem : orderItems) {
|
||||
@ -488,10 +488,10 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
Pintuan pintuan = pintuanService.getPintuanById(pintuanId);
|
||||
List<Order> list = this.getPintuanOrder(pintuanId, parentOrderSn);
|
||||
if (Boolean.TRUE.equals(pintuan.getFictitious()) && pintuan.getRequiredNum() > list.size()) {
|
||||
// 如果开启虚拟成团且当前订单数量不足成团数量,则认为拼团成功
|
||||
//如果开启虚拟成团且当前订单数量不足成团数量,则认为拼团成功
|
||||
this.pintuanOrderSuccess(list);
|
||||
} else if (Boolean.FALSE.equals(pintuan.getFictitious()) && pintuan.getRequiredNum() > list.size()) {
|
||||
// 如果未开启虚拟成团且当前订单数量不足成团数量,则认为拼团失败
|
||||
//如果未开启虚拟成团且当前订单数量不足成团数量,则认为拼团失败
|
||||
this.pintuanOrderFailed(list);
|
||||
}
|
||||
}
|
||||
@ -534,10 +534,10 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
List<OrderBatchDeliverDTO> orderBatchDeliverDTOList = new ArrayList<>();
|
||||
try {
|
||||
inputStream = files.getInputStream();
|
||||
// 2.应用HUtool ExcelUtil获取ExcelReader指定输入流和sheet
|
||||
//2.应用HUtool ExcelUtil获取ExcelReader指定输入流和sheet
|
||||
ExcelReader excelReader = ExcelUtil.getReader(inputStream);
|
||||
// 可以加上表头验证
|
||||
// 3.读取第二行到最后一行数据
|
||||
//可以加上表头验证
|
||||
//3.读取第二行到最后一行数据
|
||||
List<List<Object>> read = excelReader.read(1, excelReader.getRowCount());
|
||||
for (List<Object> objects : read) {
|
||||
OrderBatchDeliverDTO orderBatchDeliverDTO = new OrderBatchDeliverDTO();
|
||||
@ -626,7 +626,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
List<Order> list = this.getPintuanOrder(pintuanId, parentOrderSn);
|
||||
int count = list.size();
|
||||
if (count == 1) {
|
||||
// 如果为开团订单,则发布一个一小时的延时任务,时间到达后,如果未成团则自动结束(未开启虚拟成团的情况下)
|
||||
//如果为开团订单,则发布一个一小时的延时任务,时间到达后,如果未成团则自动结束(未开启虚拟成团的情况下)
|
||||
PintuanOrderMessage pintuanOrderMessage = new PintuanOrderMessage();
|
||||
long startTime = DateUtil.offsetHour(new Date(), 1).getTime();
|
||||
pintuanOrderMessage.setOrderSn(parentOrderSn);
|
||||
@ -658,7 +658,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
queryWrapper.eq(Order::getPromotionId, pintuanId)
|
||||
.eq(Order::getOrderPromotionType, OrderPromotionTypeEnum.PINTUAN.name())
|
||||
.eq(Order::getPayStatus, PayStatusEnum.PAID.name());
|
||||
// 拼团sn=开团订单sn 或者 参团订单的开团订单sn
|
||||
//拼团sn=开团订单sn 或者 参团订单的开团订单sn
|
||||
queryWrapper.and(i -> i.eq(Order::getSn, parentOrderSn)
|
||||
.or(j -> j.eq(Order::getParentOrderSn, parentOrderSn)));
|
||||
//参团后的订单数(人数)
|
||||
|
@ -48,7 +48,7 @@ public class ArticleCategoryServiceImpl extends ServiceImpl<ArticleCategoryMappe
|
||||
if (StringUtils.isNotEmpty(list)) {
|
||||
throw new ServiceException(ResultCode.SUCCESS.ARTICLE_CATEGORY_NAME_EXIST);
|
||||
}
|
||||
// 非顶级分类
|
||||
//非顶级分类
|
||||
if (articleCategory.getParentId() != null && !articleCategory.getParentId().equals("0")) {
|
||||
ArticleCategory parent = this.getById(articleCategory.getParentId());
|
||||
if (parent == null) {
|
||||
@ -68,13 +68,13 @@ public class ArticleCategoryServiceImpl extends ServiceImpl<ArticleCategoryMappe
|
||||
|
||||
@Override
|
||||
public ArticleCategory updateArticleCategory(ArticleCategory articleCategory) {
|
||||
// 非顶级分类校验是否存在
|
||||
//非顶级分类校验是否存在
|
||||
if (!articleCategory.getParentId().equals("0")) {
|
||||
ArticleCategory parent = this.getById(articleCategory.getParentId());
|
||||
if (parent == null) {
|
||||
throw new ServiceException(ResultCode.ARTICLE_CATEGORY_PARENT_NOT_EXIST);
|
||||
}
|
||||
// 替换catPath 根据path规则来匹配级别
|
||||
//替换catPath 根据path规则来匹配级别
|
||||
if (articleCategory.getLevel() >= 2) {
|
||||
throw new ServiceException(ResultCode.ARTICLE_CATEGORY_BEYOND_TWO);
|
||||
}
|
||||
@ -123,11 +123,11 @@ public class ArticleCategoryServiceImpl extends ServiceImpl<ArticleCategoryMappe
|
||||
|
||||
@Override
|
||||
public List<ArticleCategoryVO> allChildren() {
|
||||
// 从缓存取所有的分类
|
||||
//从缓存取所有的分类
|
||||
Object all = cache.get(CachePrefix.ARTICLE_CATEGORY.getPrefix());
|
||||
List<ArticleCategoryVO> articleCategories;
|
||||
if (all == null) {
|
||||
// 调用初始化分类缓存方法
|
||||
//调用初始化分类缓存方法
|
||||
articleCategories = initCategory();
|
||||
} else {
|
||||
articleCategories = (List<ArticleCategoryVO>) all;
|
||||
|
@ -37,32 +37,32 @@ public class XmlHelper {
|
||||
|
||||
private XmlHelper(InputSource inputSource) throws ParserConfigurationException, SAXException, IOException {
|
||||
DocumentBuilderFactory dbf = getDocumentBuilderFactory();
|
||||
// This is the PRIMARY defense. If DTDs (doctypes) are disallowed, almost all
|
||||
// XML entity attacks are prevented
|
||||
// Xerces 2 only -
|
||||
// http://xerces.apache.org/xerces2-j/features.html#disallow-doctype-decl
|
||||
//This is the PRIMARY defense. If DTDs (doctypes) are disallowed, almost all
|
||||
//XML entity attacks are prevented
|
||||
//Xerces 2 only -
|
||||
//http://xerces.apache.org/xerces2-j/features.html#disallow-doctype-decl
|
||||
dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
|
||||
|
||||
// If you can't completely disable DTDs, then at least do the following:
|
||||
// Xerces 1 -
|
||||
// http://xerces.apache.org/xerces-j/features.html#external-general-entities
|
||||
// Xerces 2 -
|
||||
// http://xerces.apache.org/xerces2-j/features.html#external-general-entities
|
||||
// JDK7+ - http://xml.org/sax/features/external-general-entities
|
||||
//If you can't completely disable DTDs, then at least do the following:
|
||||
//Xerces 1 -
|
||||
//http://xerces.apache.org/xerces-j/features.html#external-general-entities
|
||||
//Xerces 2 -
|
||||
//http://xerces.apache.org/xerces2-j/features.html#external-general-entities
|
||||
//JDK7+ - http://xml.org/sax/features/external-general-entities
|
||||
dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
|
||||
|
||||
// Xerces 1 -
|
||||
// http://xerces.apache.org/xerces-j/features.html#external-parameter-entities
|
||||
// Xerces 2 -
|
||||
// http://xerces.apache.org/xerces2-j/features.html#external-parameter-entities
|
||||
// JDK7+ - http://xml.org/sax/features/external-parameter-entities
|
||||
//Xerces 1 -
|
||||
//http://xerces.apache.org/xerces-j/features.html#external-parameter-entities
|
||||
//Xerces 2 -
|
||||
//http://xerces.apache.org/xerces2-j/features.html#external-parameter-entities
|
||||
//JDK7+ - http://xml.org/sax/features/external-parameter-entities
|
||||
dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
|
||||
|
||||
// Disable external DTDs as well
|
||||
//Disable external DTDs as well
|
||||
dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
|
||||
|
||||
// and these as well, per Timothy Morgan's 2014 paper: "XML Schema, DTD, and
|
||||
// Entity Attacks"
|
||||
//and these as well, per Timothy Morgan's 2014 paper: "XML Schema, DTD, and
|
||||
//Entity Attacks"
|
||||
dbf.setXIncludeAware(false);
|
||||
dbf.setExpandEntityReferences(false);
|
||||
DocumentBuilder db = dbf.newDocumentBuilder();
|
||||
@ -218,14 +218,14 @@ public class XmlHelper {
|
||||
public Map<String, String> toMap() {
|
||||
Element root = doc.getDocumentElement();
|
||||
|
||||
// 将节点封装成map形式
|
||||
//将节点封装成map形式
|
||||
NodeList list = root.getChildNodes();
|
||||
Map<String, String> params = new HashMap<String, String>(list.getLength());
|
||||
for (int i = 0; i < list.getLength(); i++) {
|
||||
Node node = list.item(i);
|
||||
params.put(node.getNodeName(), node.getTextContent());
|
||||
}
|
||||
// 含有空白符会生成一个#text参数
|
||||
//含有空白符会生成一个#text参数
|
||||
params.remove("#text");
|
||||
return params;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.lili.modules.payment.kit.core.kit;
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by Fernflower decompiler)
|
||||
//Source code recreated from a .class file by IntelliJ IDEA
|
||||
//(powered by Fernflower decompiler)
|
||||
//
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@ -29,7 +29,7 @@ public class IpKit {
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getRemoteAddr();
|
||||
}
|
||||
// 对于通过多个代理的情况,第一个 IP 为客户端真实 IP,多个IP按照','分割
|
||||
//对于通过多个代理的情况,第一个 IP 为客户端真实 IP,多个IP按照','分割
|
||||
if (ip != null && ip.length() > 15) {
|
||||
if (ip.indexOf(",") > 0) {
|
||||
ip = ip.substring(0, ip.indexOf(","));
|
||||
|
@ -146,7 +146,7 @@ public class PayKit {
|
||||
for (int i = 0; i < keys.size(); i++) {
|
||||
String key = keys.get(i);
|
||||
String value = params.get(key);
|
||||
// 拼接时,不包括最后一个&字符
|
||||
//拼接时,不包括最后一个&字符
|
||||
if (i == keys.size() - 1) {
|
||||
if (quotes) {
|
||||
content.append(key).append("=").append('"').append(encode ? urlEncode(value) : value).append('"');
|
||||
@ -196,7 +196,7 @@ public class PayKit {
|
||||
for (Map.Entry<String, String> entry : params.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String value = entry.getValue();
|
||||
// 略过空值
|
||||
//略过空值
|
||||
if (StrUtil.isEmpty(value)) {
|
||||
continue;
|
||||
}
|
||||
@ -322,9 +322,9 @@ public class PayKit {
|
||||
if (StrUtil.isEmpty(signMessage)) {
|
||||
return null;
|
||||
}
|
||||
// 获取商户私钥
|
||||
//获取商户私钥
|
||||
PrivateKey privateKey = PayKit.getPrivateKey(keyPath);
|
||||
// 生成签名
|
||||
//生成签名
|
||||
return RsaKit.encryptByPrivateKey(signMessage, privateKey);
|
||||
}
|
||||
|
||||
@ -340,7 +340,7 @@ public class PayKit {
|
||||
if (StrUtil.isEmpty(signMessage)) {
|
||||
return null;
|
||||
}
|
||||
// 生成签名
|
||||
//生成签名
|
||||
return RsaKit.encryptByPrivateKey(signMessage, privateKey);
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class QrCodeKit {
|
||||
boolean bool = false;
|
||||
BufferedImage bufImg;
|
||||
Map<EncodeHintType, Object> hints = new HashMap<EncodeHintType, Object>(3);
|
||||
// 指定纠错等级
|
||||
//指定纠错等级
|
||||
hints.put(EncodeHintType.ERROR_CORRECTION, errorLevel);
|
||||
hints.put(EncodeHintType.MARGIN, margin);
|
||||
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
|
||||
|
@ -123,7 +123,7 @@ public class RsaKit {
|
||||
X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(keyBytes);
|
||||
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
|
||||
Key key = keyFactory.generatePublic(x509KeySpec);
|
||||
// 对数据加密
|
||||
//对数据加密
|
||||
Cipher cipher = Cipher.getInstance(fillMode);
|
||||
cipher.init(Cipher.ENCRYPT_MODE, key);
|
||||
int inputLen = dataByte.length;
|
||||
@ -131,7 +131,7 @@ public class RsaKit {
|
||||
int offSet = 0;
|
||||
byte[] cache;
|
||||
int i = 0;
|
||||
// 对数据分段加密
|
||||
//对数据分段加密
|
||||
while (inputLen - offSet > 0) {
|
||||
if (inputLen - offSet > MAX_ENCRYPT_BLOCK) {
|
||||
cache = cipher.doFinal(dataByte, offSet, MAX_ENCRYPT_BLOCK);
|
||||
@ -265,7 +265,7 @@ public class RsaKit {
|
||||
int offSet = 0;
|
||||
byte[] cache;
|
||||
int i = 0;
|
||||
// 对数据分段解密
|
||||
//对数据分段解密
|
||||
while (inputLen - offSet > 0) {
|
||||
if (inputLen - offSet > MAX_DECRYPT_BLOCK) {
|
||||
cache = cipher.doFinal(encryptedData, offSet, MAX_DECRYPT_BLOCK);
|
||||
|
@ -103,7 +103,7 @@ public class WxPayKit {
|
||||
if (signType == null) {
|
||||
signType = SignType.MD5;
|
||||
}
|
||||
// 生成签名前先去除sign
|
||||
//生成签名前先去除sign
|
||||
params.remove(FIELD_SIGN);
|
||||
String tempStr = PayKit.createLinkString(params);
|
||||
String stringSignTemp = tempStr + "&key=" + partnerKey;
|
||||
@ -122,7 +122,7 @@ public class WxPayKit {
|
||||
* @return 签名后的数据
|
||||
*/
|
||||
public static String createSign(Map<String, String> params, String secret) {
|
||||
// 生成签名前先去除sign
|
||||
//生成签名前先去除sign
|
||||
params.remove(FIELD_SIGN);
|
||||
String tempStr = PayKit.createLinkString(params);
|
||||
String stringSignTemp = tempStr + "&secret=" + secret;
|
||||
@ -432,10 +432,10 @@ public class WxPayKit {
|
||||
public static String buildAuthorization(RequestMethodEnums method, String urlSuffix, String mchId,
|
||||
String serialNo, String keyPath, String body, String nonceStr,
|
||||
long timestamp, String authType) throws Exception {
|
||||
// 构建签名参数
|
||||
//构建签名参数
|
||||
String buildSignMessage = PayKit.buildSignMessage(method, urlSuffix, timestamp, nonceStr, body);
|
||||
String signature = PayKit.createSign(buildSignMessage, keyPath);
|
||||
// 根据平台规则生成请求头 authorization
|
||||
//根据平台规则生成请求头 authorization
|
||||
return PayKit.getAuthorization(mchId, serialNo, nonceStr, String.valueOf(timestamp), signature, authType);
|
||||
}
|
||||
|
||||
@ -457,10 +457,10 @@ public class WxPayKit {
|
||||
public static String buildAuthorization(RequestMethodEnums method, String urlSuffix, String mchId,
|
||||
String serialNo, PrivateKey privateKey, String body, String nonceStr,
|
||||
long timestamp, String authType) throws Exception {
|
||||
// 构建签名参数
|
||||
//构建签名参数
|
||||
String buildSignMessage = PayKit.buildSignMessage(method, urlSuffix, timestamp, nonceStr, body);
|
||||
String signature = PayKit.createSign(buildSignMessage, privateKey);
|
||||
// 根据平台规则生成请求头 authorization
|
||||
//根据平台规则生成请求头 authorization
|
||||
return PayKit.getAuthorization(mchId, serialNo, nonceStr, String.valueOf(timestamp), signature, authType);
|
||||
}
|
||||
|
||||
@ -585,7 +585,7 @@ public class WxPayKit {
|
||||
*/
|
||||
public static boolean verifySignature(String signature, String body, String nonce, String timestamp, InputStream certInputStream) throws Exception {
|
||||
String buildSignMessage = PayKit.buildSignMessage(timestamp, nonce, body);
|
||||
// 获取证书
|
||||
//获取证书
|
||||
X509Certificate certificate = PayKit.getCertificate(certInputStream);
|
||||
PublicKey publicKey = certificate.getPublicKey();
|
||||
return RsaKit.checkByPublicKey(buildSignMessage, signature, publicKey);
|
||||
@ -624,11 +624,11 @@ public class WxPayKit {
|
||||
public static String verifyNotify(String serialNo, String body, String signature, String nonce,
|
||||
String timestamp, String key, String certPath) throws Exception {
|
||||
BufferedInputStream inputStream = FileUtil.getInputStream(certPath);
|
||||
// 获取平台证书序列号
|
||||
//获取平台证书序列号
|
||||
X509Certificate certificate = PayKit.getCertificate(inputStream);
|
||||
String serialNumber = certificate.getSerialNumber().toString(16).toUpperCase();
|
||||
System.out.println(serialNumber);
|
||||
// 验证证书序列号
|
||||
//验证证书序列号
|
||||
if (serialNumber.equals(serialNo)) {
|
||||
boolean verifySignature = WxPayKit.verifySignature(signature, body, nonce, timestamp, certificate.getPublicKey());
|
||||
if (verifySignature) {
|
||||
@ -639,7 +639,7 @@ public class WxPayKit {
|
||||
String associatedData = resource.getStr("associated_data");
|
||||
|
||||
AesUtil aesUtil = new AesUtil(key.getBytes(StandardCharsets.UTF_8));
|
||||
// 密文解密
|
||||
//密文解密
|
||||
return aesUtil.decryptToString(
|
||||
associatedData.getBytes(StandardCharsets.UTF_8),
|
||||
nonceStr.getBytes(StandardCharsets.UTF_8),
|
||||
@ -665,7 +665,7 @@ public class WxPayKit {
|
||||
public static String verifyNotify(String serialNo, String body, String signature, String nonce,
|
||||
String timestamp, String key, X509Certificate certificate) throws Exception {
|
||||
String serialNumber = certificate.getSerialNumber().toString(16).toUpperCase();
|
||||
// 验证证书序列号
|
||||
//验证证书序列号
|
||||
if (serialNumber.equals(serialNo)) {
|
||||
boolean verifySignature = WxPayKit.verifySignature(signature, body, nonce, timestamp, certificate.getPublicKey());
|
||||
if (verifySignature) {
|
||||
@ -676,7 +676,7 @@ public class WxPayKit {
|
||||
String associatedData = resource.getStr("associated_data");
|
||||
|
||||
AesUtil aesUtil = new AesUtil(key.getBytes(StandardCharsets.UTF_8));
|
||||
// 密文解密
|
||||
//密文解密
|
||||
return aesUtil.decryptToString(
|
||||
associatedData.getBytes(StandardCharsets.UTF_8),
|
||||
nonceStr.getBytes(StandardCharsets.UTF_8),
|
||||
|
@ -244,7 +244,7 @@ public class AliPayApi {
|
||||
*/
|
||||
public static AlipayTradePayResponse tradePayToResponse(AlipayTradePayModel model, String notifyUrl) throws AlipayApiException {
|
||||
AlipayTradePayRequest request = new AlipayTradePayRequest();
|
||||
// 填充业务参数
|
||||
//填充业务参数
|
||||
request.setBizModel(model);
|
||||
request.setNotifyUrl(notifyUrl);
|
||||
return doExecute(request);
|
||||
@ -316,7 +316,7 @@ public class AliPayApi {
|
||||
if (response.isSuccess()) {
|
||||
return true;
|
||||
} else {
|
||||
// 调用查询接口查询数据
|
||||
//调用查询接口查询数据
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
String outBizNo = jsonObject.getJSONObject("alipay_fund_trans_toaccount_transfer_response").getString("out_biz_no");
|
||||
AlipayFundTransOrderQueryModel queryModel = new AlipayFundTransOrderQueryModel();
|
||||
|
@ -245,7 +245,7 @@ public class AliPayPlugin implements Payment {
|
||||
private void verifyNotify(HttpServletRequest request) {
|
||||
try {
|
||||
AlipayPaymentSetting alipayPaymentSetting = alipayPaymentSetting();
|
||||
// 获取支付宝反馈信息
|
||||
//获取支付宝反馈信息
|
||||
Map<String, String> map = AliPayApi.toMap(request);
|
||||
log.info("支付回调响应:{}", JSONUtil.toJsonStr(map));
|
||||
boolean verifyResult = AlipaySignature.rsaCertCheckV1(map, alipayPaymentSetting.getAlipayPublicCertPath(), "UTF-8",
|
||||
|
@ -177,7 +177,7 @@ public class WechatApi {
|
||||
String mchId, String serialNo, String platSerialNo, String keyPath,
|
||||
String body, String nonceStr, long timestamp, String authType,
|
||||
File file) throws Exception {
|
||||
// 构建 Authorization
|
||||
//构建 Authorization
|
||||
String authorization = WxPayKit.buildAuthorization(method, urlSuffix, mchId, serialNo,
|
||||
keyPath, body, nonceStr, timestamp, authType);
|
||||
|
||||
@ -220,7 +220,7 @@ public class WechatApi {
|
||||
String mchId, String serialNo, String platSerialNo, PrivateKey privateKey,
|
||||
String body, String nonceStr, long timestamp, String authType,
|
||||
File file) throws Exception {
|
||||
// 构建 Authorization
|
||||
//构建 Authorization
|
||||
String authorization = WxPayKit.buildAuthorization(method, urlSuffix, mchId, serialNo,
|
||||
privateKey, body, nonceStr, timestamp, authType);
|
||||
|
||||
|
@ -191,7 +191,7 @@ public class WechatPlugin implements Payment {
|
||||
setting.getApiclient_key(),
|
||||
JSONUtil.toJsonStr(unifiedOrderModel)
|
||||
);
|
||||
// 根据证书序列号查询对应的证书来验证签名结果
|
||||
//根据证书序列号查询对应的证书来验证签名结果
|
||||
boolean verifySignature = WxPayKit.verifySignature(response, getPlatformCert());
|
||||
log.info("verifySignature: {}", verifySignature);
|
||||
log.info("统一下单响应 {}", response);
|
||||
@ -252,7 +252,7 @@ public class WechatPlugin implements Payment {
|
||||
setting.getApiclient_key(),
|
||||
JSONUtil.toJsonStr(unifiedOrderModel)
|
||||
);
|
||||
// 根据证书序列号查询对应的证书来验证签名结果
|
||||
//根据证书序列号查询对应的证书来验证签名结果
|
||||
boolean verifySignature = WxPayKit.verifySignature(response, getPlatformCert());
|
||||
log.info("verifySignature: {}", verifySignature);
|
||||
log.info("统一下单响应 {}", response);
|
||||
@ -316,7 +316,7 @@ public class WechatPlugin implements Payment {
|
||||
JSONUtil.toJsonStr(unifiedOrderModel)
|
||||
);
|
||||
log.info("统一下单响应 {}", response);
|
||||
// 根据证书序列号查询对应的证书来验证签名结果
|
||||
//根据证书序列号查询对应的证书来验证签名结果
|
||||
boolean verifySignature = WxPayKit.verifySignature(response, getPlatformCert());
|
||||
log.info("verifySignature: {}", verifySignature);
|
||||
|
||||
@ -392,7 +392,7 @@ public class WechatPlugin implements Payment {
|
||||
setting.getApiclient_key(),
|
||||
JSONUtil.toJsonStr(unifiedOrderModel)
|
||||
);
|
||||
// 根据证书序列号查询对应的证书来验证签名结果
|
||||
//根据证书序列号查询对应的证书来验证签名结果
|
||||
boolean verifySignature = WxPayKit.verifySignature(response, getPlatformCert());
|
||||
log.info("verifySignature: {}", verifySignature);
|
||||
log.info("统一下单响应 {}", response);
|
||||
@ -451,7 +451,7 @@ public class WechatPlugin implements Payment {
|
||||
log.info("微信支付通知密文 {}", result);
|
||||
|
||||
WechatPaymentSetting setting = wechatPaymentSetting();
|
||||
// 校验服务器端响应¬
|
||||
//校验服务器端响应¬
|
||||
String plainText = WxPayKit.verifyNotify(serialNo, result, signature, nonce, timestamp,
|
||||
setting.getApiKey3(), Objects.requireNonNull(getPlatformCert()));
|
||||
|
||||
@ -486,7 +486,7 @@ public class WechatPlugin implements Payment {
|
||||
Amount amount = new Amount().setRefund(CurrencyUtil.fen(refundLog.getTotalAmount()))
|
||||
.setTotal(CurrencyUtil.fen(refundLog.getPayPrice()));
|
||||
|
||||
// 退款参数准备
|
||||
//退款参数准备
|
||||
RefundModel refundModel = new RefundModel()
|
||||
.setTransaction_id(refundLog.getPaymentReceivableNo())
|
||||
.setOut_refund_no(refundLog.getOutOrderNo())
|
||||
@ -508,11 +508,11 @@ public class WechatPlugin implements Payment {
|
||||
JSONUtil.toJsonStr(refundModel)
|
||||
);
|
||||
log.info("微信退款响应 {}", response);
|
||||
// 退款申请成功
|
||||
//退款申请成功
|
||||
if (response.getStatus() == 200) {
|
||||
refundLogService.save(refundLog);
|
||||
} else {
|
||||
// 退款申请失败
|
||||
//退款申请失败
|
||||
refundLog.setErrorMessage(response.getBody());
|
||||
refundLogService.save(refundLog);
|
||||
}
|
||||
@ -543,7 +543,7 @@ public class WechatPlugin implements Payment {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// 校验服务器端响应¬
|
||||
//校验服务器端响应¬
|
||||
String plainText = WxPayKit.verifyNotify(serialNo, result, signature, nonce, timestamp,
|
||||
wechatPaymentSetting().getApiKey3(), Objects.requireNonNull(getPlatformCert()));
|
||||
log.info("微信退款通知明文 {}", plainText);
|
||||
@ -589,7 +589,7 @@ public class WechatPlugin implements Payment {
|
||||
if (!StringUtils.isEmpty(publicCert)) {
|
||||
return PayKit.getCertificate(publicCert);
|
||||
}
|
||||
// 获取平台证书列表
|
||||
//获取平台证书列表
|
||||
try {
|
||||
|
||||
WechatPaymentSetting setting = wechatPaymentSetting();
|
||||
@ -609,7 +609,7 @@ public class WechatPlugin implements Payment {
|
||||
if (response.getStatus() == 200) {
|
||||
JSONObject jsonObject = JSONUtil.parseObj(body);
|
||||
JSONArray dataArray = jsonObject.getJSONArray("data");
|
||||
// 默认认为只有一个平台证书
|
||||
//默认认为只有一个平台证书
|
||||
JSONObject encryptObject = dataArray.getJSONObject(0);
|
||||
JSONObject encryptCertificate = encryptObject.getJSONObject("encrypt_certificate");
|
||||
String associatedData = encryptCertificate.getStr("associated_data");
|
||||
@ -643,8 +643,8 @@ public class WechatPlugin implements Payment {
|
||||
|
||||
|
||||
AesUtil aesUtil = new AesUtil(wechatPaymentSetting().getApiKey3().getBytes(StandardCharsets.UTF_8));
|
||||
// 平台证书密文解密
|
||||
// encrypt_certificate 中的 associated_data nonce ciphertext
|
||||
//平台证书密文解密
|
||||
//encrypt_certificate 中的 associated_data nonce ciphertext
|
||||
return aesUtil.decryptToString(
|
||||
associatedData.getBytes(StandardCharsets.UTF_8),
|
||||
nonce.getBytes(StandardCharsets.UTF_8),
|
||||
|
@ -138,7 +138,7 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
|
||||
return null;
|
||||
}
|
||||
AdminUserVO adminUserVO = new AdminUserVO(user);
|
||||
// 关联部门
|
||||
//关联部门
|
||||
if (user.getDepartmentId() != null) {
|
||||
Department department = departmentService.getById(user.getDepartmentId());
|
||||
if (department != null) {
|
||||
|
@ -79,15 +79,15 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
|
||||
|
||||
@Override
|
||||
public CouponVO add(CouponVO coupon) {
|
||||
// 检查参数
|
||||
//检查参数
|
||||
this.checkParam(coupon);
|
||||
coupon.setUsedNum(0);
|
||||
coupon.setReceivedNum(0);
|
||||
// 保存到MYSQL中
|
||||
//保存到MYSQL中
|
||||
this.save(coupon);
|
||||
// 如果优惠券类型为部分商品则将促销活动商品更新
|
||||
//如果优惠券类型为部分商品则将促销活动商品更新
|
||||
this.updateScopePromotionGoods(coupon);
|
||||
// 保存到MONGO中
|
||||
//保存到MONGO中
|
||||
this.mongoTemplate.save(coupon);
|
||||
//如果优惠券是固定时间则添加延时任务
|
||||
if (coupon.getRangeDayType().equals(CouponRangeDayEnum.FIXEDTIME.name())) {
|
||||
@ -97,7 +97,7 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
|
||||
promotionMessage,
|
||||
DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.PROMOTION, (promotionMessage.getPromotionType() + promotionMessage.getPromotionId())),
|
||||
rocketmqCustomProperties.getPromotionTopic());
|
||||
// 发送促销活动开始的延时任务
|
||||
//发送促销活动开始的延时任务
|
||||
this.timeTrigger.addDelay(timeTriggerMsg);
|
||||
}
|
||||
|
||||
@ -107,16 +107,16 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
|
||||
@Override
|
||||
public CouponVO updateCoupon(CouponVO couponVO) {
|
||||
CouponVO coupon = checkStatus(couponVO.getId());
|
||||
// 检查参数
|
||||
//检查参数
|
||||
this.checkParam(couponVO);
|
||||
// 更新到MYSQL中
|
||||
//更新到MYSQL中
|
||||
this.updateById(couponVO);
|
||||
// 如果优惠券类型为部分商品则将促销活动商品更新
|
||||
//如果优惠券类型为部分商品则将促销活动商品更新
|
||||
this.updateScopePromotionGoods(couponVO);
|
||||
// 保存到MONGO中
|
||||
//保存到MONGO中
|
||||
this.mongoTemplate.save(couponVO);
|
||||
PromotionMessage promotionMessage = new PromotionMessage(couponVO.getId(), PromotionTypeEnum.COUPON.name(), PromotionStatusEnum.START.name(), coupon.getStartTime(), coupon.getEndTime());
|
||||
// 更新延时任务
|
||||
//更新延时任务
|
||||
this.timeTrigger.edit(TimeExecuteConstant.PROMOTION_EXECUTOR,
|
||||
promotionMessage,
|
||||
coupon.getStartTime().getTime(), couponVO.getStartTime().getTime(),
|
||||
@ -144,7 +144,7 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
|
||||
this.mongoTemplate.save(couponVO);
|
||||
if (promotionStatus.name().equals(PromotionStatusEnum.START.name())) {
|
||||
PromotionMessage promotionMessage = new PromotionMessage(couponVO.getId(), PromotionTypeEnum.COUPON.name(), PromotionStatusEnum.START.name(), couponVO.getStartTime(), couponVO.getEndTime());
|
||||
// 更新延时任务
|
||||
//更新延时任务
|
||||
this.timeTrigger.edit(TimeExecuteConstant.PROMOTION_EXECUTOR,
|
||||
promotionMessage,
|
||||
couponVO.getStartTime().getTime(), couponVO.getStartTime().getTime(),
|
||||
@ -160,10 +160,10 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
|
||||
public boolean deleteCoupon(String id) {
|
||||
CouponVO couponVO = checkStatus(id);
|
||||
LambdaUpdateWrapper<Coupon> couponUpdateWrapper = new LambdaUpdateWrapper<Coupon>().eq(Coupon::getId, id).set(Coupon::getPromotionStatus, PromotionStatusEnum.CLOSE.name()).set(Coupon::getDeleteFlag, true);
|
||||
// 更新优惠券状态为关闭,标示删除标志
|
||||
//更新优惠券状态为关闭,标示删除标志
|
||||
boolean result = this.update(couponUpdateWrapper);
|
||||
LambdaUpdateWrapper<PromotionGoods> updateWrapper = new LambdaUpdateWrapper<PromotionGoods>().eq(PromotionGoods::getPromotionId, id).set(PromotionGoods::getPromotionStatus, PromotionStatusEnum.CLOSE.name()).set(PromotionGoods::getDeleteFlag, true);
|
||||
// 更新促销商品记录信息为删除
|
||||
//更新促销商品记录信息为删除
|
||||
this.promotionGoodsService.update(updateWrapper);
|
||||
LambdaUpdateWrapper<MemberCoupon> memberCouponLambdaUpdateWrapper = new LambdaUpdateWrapper<MemberCoupon>().eq(MemberCoupon::getCouponId, id).set(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.CLOSED.name());
|
||||
memberCouponService.update(memberCouponLambdaUpdateWrapper);
|
||||
@ -373,7 +373,7 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
|
||||
}
|
||||
|
||||
private void updateScopePromotionGoods(CouponVO couponVO) {
|
||||
// 如果优惠券类型为部分商品则将促销活动更新至ES中
|
||||
//如果优惠券类型为部分商品则将促销活动更新至ES中
|
||||
if (CouponScopeTypeEnum.PORTION_GOODS.name().equals(couponVO.getScopeType()) && !couponVO.getPromotionGoodsList().isEmpty()) {
|
||||
PromotionTools.promotionGoodsInit(couponVO.getPromotionGoodsList(), couponVO, PromotionTypeEnum.COUPON);
|
||||
}
|
||||
|
@ -82,20 +82,20 @@ public class FullDiscountServiceImpl extends ServiceImpl<FullDiscountMapper, Ful
|
||||
|
||||
@Override
|
||||
public FullDiscount addFullDiscount(FullDiscountVO fullDiscountVO) {
|
||||
// 验证是否是有效参数
|
||||
//验证是否是有效参数
|
||||
PromotionTools.paramValid(fullDiscountVO.getStartTime().getTime(), fullDiscountVO.getEndTime().getTime(), fullDiscountVO.getNumber(), fullDiscountVO.getPromotionGoodsList());
|
||||
// 当前时间段是否存在同类活动
|
||||
//当前时间段是否存在同类活动
|
||||
this.checkSameActiveExist(fullDiscountVO.getStartTime(), fullDiscountVO.getEndTime(), fullDiscountVO.getStoreId(), null);
|
||||
// 检查满减参数
|
||||
//检查满减参数
|
||||
this.checkFullDiscount(fullDiscountVO);
|
||||
// 保存到MYSQL中
|
||||
//保存到MYSQL中
|
||||
this.save(fullDiscountVO);
|
||||
if (fullDiscountVO.getPromotionGoodsList() != null) {
|
||||
List<PromotionGoods> promotionGoodsList = PromotionTools.promotionGoodsInit(fullDiscountVO.getPromotionGoodsList(), fullDiscountVO, PromotionTypeEnum.FULL_DISCOUNT);
|
||||
// 促销活动商品更新
|
||||
//促销活动商品更新
|
||||
this.promotionGoodsService.saveOrUpdateBatch(promotionGoodsList);
|
||||
}
|
||||
// 保存到MONGO中
|
||||
//保存到MONGO中
|
||||
this.mongoTemplate.save(fullDiscountVO);
|
||||
PromotionMessage promotionMessage = new PromotionMessage(fullDiscountVO.getId(), PromotionTypeEnum.FULL_DISCOUNT.name(),
|
||||
PromotionStatusEnum.START.name(),
|
||||
@ -105,7 +105,7 @@ public class FullDiscountServiceImpl extends ServiceImpl<FullDiscountMapper, Ful
|
||||
fullDiscountVO.getStartTime().getTime(), promotionMessage,
|
||||
DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.PROMOTION, (promotionMessage.getPromotionType() + promotionMessage.getPromotionId())),
|
||||
rocketmqCustomProperties.getPromotionTopic());
|
||||
// 发送促销活动开始的延时任务
|
||||
//发送促销活动开始的延时任务
|
||||
this.timeTrigger.addDelay(timeTriggerMsg);
|
||||
return fullDiscountVO;
|
||||
}
|
||||
@ -132,31 +132,31 @@ public class FullDiscountServiceImpl extends ServiceImpl<FullDiscountMapper, Ful
|
||||
|
||||
@Override
|
||||
public FullDiscountVO modifyFullDiscount(FullDiscountVO fullDiscountVO) {
|
||||
// 检查满优惠活动是否存在
|
||||
//检查满优惠活动是否存在
|
||||
FullDiscountVO fullDiscount = this.checkFullDiscountExist(fullDiscountVO.getId());
|
||||
if (!fullDiscount.getPromotionStatus().equals(PromotionStatusEnum.NEW.name())) {
|
||||
throw new ServiceException("当前编辑的满优惠活动已经开始或者已经结束,无法修改");
|
||||
}
|
||||
// 检查活动是否已经开始
|
||||
//检查活动是否已经开始
|
||||
PromotionTools.checkPromotionTime(fullDiscountVO.getStartTime().getTime(), fullDiscountVO.getEndTime().getTime());
|
||||
// 检查满减参数
|
||||
//检查满减参数
|
||||
this.checkFullDiscount(fullDiscountVO);
|
||||
// 时间发生变化
|
||||
//时间发生变化
|
||||
if (!fullDiscount.getStartTime().equals(fullDiscountVO.getStartTime()) && fullDiscount.getEndTime().equals(fullDiscountVO.getEndTime())) {
|
||||
// 检查当前时间段是否存在同类活动
|
||||
//检查当前时间段是否存在同类活动
|
||||
this.checkSameActiveExist(fullDiscountVO.getStartTime(), fullDiscountVO.getEndTime(), fullDiscountVO.getStoreId(), fullDiscount.getId());
|
||||
|
||||
}
|
||||
// 更新到MYSQL中
|
||||
//更新到MYSQL中
|
||||
this.updateById(fullDiscountVO);
|
||||
if (fullDiscountVO.getPromotionGoodsList() != null) {
|
||||
// 促销活动商品更新
|
||||
//促销活动商品更新
|
||||
this.promotionGoodsService.updateBatchById(PromotionTools.promotionGoodsInit(fullDiscountVO.getPromotionGoodsList(), fullDiscountVO, PromotionTypeEnum.FULL_DISCOUNT));
|
||||
}
|
||||
// 保存到MONGO中
|
||||
//保存到MONGO中
|
||||
this.mongoTemplate.save(fullDiscountVO);
|
||||
PromotionMessage promotionMessage = new PromotionMessage(fullDiscountVO.getId(), PromotionTypeEnum.FULL_DISCOUNT.name(), PromotionStatusEnum.START.name(), fullDiscountVO.getStartTime(), fullDiscountVO.getEndTime());
|
||||
// 发送更新延时任务
|
||||
//发送更新延时任务
|
||||
this.timeTrigger.edit(TimeExecuteConstant.PROMOTION_EXECUTOR, promotionMessage,
|
||||
fullDiscount.getStartTime().getTime(), fullDiscountVO.getStartTime().getTime(),
|
||||
DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.PROMOTION, (promotionMessage.getPromotionType() + promotionMessage.getPromotionId())),
|
||||
@ -179,7 +179,7 @@ public class FullDiscountServiceImpl extends ServiceImpl<FullDiscountMapper, Ful
|
||||
@Override
|
||||
public boolean deleteFullDiscount(String id) {
|
||||
FullDiscountVO fullDiscount = this.checkFullDiscountExist(id);
|
||||
// 检查活动是否已经开始
|
||||
//检查活动是否已经开始
|
||||
boolean result = this.removeById(id);
|
||||
this.mongoTemplate.remove(new Query().addCriteria(Criteria.where("id").is(id)), FullDiscountVO.class);
|
||||
if (fullDiscount.getPromotionGoodsList() != null && !fullDiscount.getPromotionGoodsList().isEmpty()) {
|
||||
@ -214,24 +214,24 @@ public class FullDiscountServiceImpl extends ServiceImpl<FullDiscountMapper, Ful
|
||||
if (fullDiscountVO.getIsFullMinus() == null && fullDiscountVO.getIsCoupon() == null && fullDiscountVO.getIsGift() == null && fullDiscountVO.getIsPoint() == null && fullDiscountVO.getIsFullRate() == null) {
|
||||
throw new ServiceException("请选择一种优惠方式");
|
||||
}
|
||||
// 如果优惠方式是满减
|
||||
//如果优惠方式是满减
|
||||
if (Boolean.TRUE.equals(fullDiscountVO.getIsFullMinus())) {
|
||||
this.checkFullMinus(fullDiscountVO.getFullMinus(), fullDiscountVO.getFullMoney());
|
||||
fullDiscountVO.setTitle("满" + fullDiscountVO.getFullMoney() + " 减" + fullDiscountVO.getFullMinus());
|
||||
}
|
||||
// 如果优惠方式是赠品
|
||||
//如果优惠方式是赠品
|
||||
if (Boolean.TRUE.equals(fullDiscountVO.getIsGift())) {
|
||||
// 是否没有选择赠品
|
||||
//是否没有选择赠品
|
||||
boolean noGiftSelected = fullDiscountVO.getGiftId() == null;
|
||||
if (noGiftSelected) {
|
||||
throw new ServiceException("请选择赠品");
|
||||
}
|
||||
}
|
||||
// 如果优惠方式是赠优惠券
|
||||
//如果优惠方式是赠优惠券
|
||||
if (Boolean.TRUE.equals(fullDiscountVO.getIsCoupon())) {
|
||||
this.checkCoupon(fullDiscountVO.getCouponId(), fullDiscountVO.getEndTime().getTime());
|
||||
}
|
||||
// 如果优惠方式是折扣
|
||||
//如果优惠方式是折扣
|
||||
if (Boolean.TRUE.equals(fullDiscountVO.getIsFullRate())) {
|
||||
this.checkFullRate(fullDiscountVO.getFullRate());
|
||||
fullDiscountVO.setTitle("满" + fullDiscountVO.getFullMoney() + " 打" + fullDiscountVO.getFullRate() + "折");
|
||||
@ -248,7 +248,7 @@ public class FullDiscountServiceImpl extends ServiceImpl<FullDiscountMapper, Ful
|
||||
* @param id 满优惠活动ID
|
||||
*/
|
||||
private void checkSameActiveExist(Date statTime, Date endTime, String storeId, String id) {
|
||||
// 同一时间段内相同的活动
|
||||
//同一时间段内相同的活动
|
||||
QueryWrapper<FullDiscount> queryWrapper = PromotionTools.checkActiveTime(statTime, endTime, PromotionTypeEnum.FULL_DISCOUNT, storeId, id);
|
||||
Integer sameNum = this.count(queryWrapper);
|
||||
if (sameNum > 0) {
|
||||
@ -263,7 +263,7 @@ public class FullDiscountServiceImpl extends ServiceImpl<FullDiscountMapper, Ful
|
||||
* @param endTime 活动结束时间
|
||||
*/
|
||||
private void checkCoupon(String couponId, long endTime) {
|
||||
// 是否没有选择优惠券
|
||||
//是否没有选择优惠券
|
||||
boolean noCouponSelected = couponId == null;
|
||||
if (noCouponSelected) {
|
||||
throw new ServiceException("请选择优惠券");
|
||||
@ -281,7 +281,7 @@ public class FullDiscountServiceImpl extends ServiceImpl<FullDiscountMapper, Ful
|
||||
* @param fullMoney 优惠门槛
|
||||
*/
|
||||
private void checkFullMinus(Double fullMinus, Double fullMoney) {
|
||||
// 是否没有填写满减金额
|
||||
//是否没有填写满减金额
|
||||
boolean noFullMinusInput = fullMinus == null || fullMinus == 0;
|
||||
if (noFullMinusInput) {
|
||||
throw new ServiceException("请填写满减金额");
|
||||
@ -297,7 +297,7 @@ public class FullDiscountServiceImpl extends ServiceImpl<FullDiscountMapper, Ful
|
||||
* @param fullRate 打折数值
|
||||
*/
|
||||
private void checkFullRate(Double fullRate) {
|
||||
// 是否没有填写打折数值
|
||||
//是否没有填写打折数值
|
||||
boolean noFullRateInput = fullRate == null || fullRate == 0;
|
||||
if (noFullRateInput) {
|
||||
throw new ServiceException("请填写打折数值");
|
||||
|
@ -107,16 +107,16 @@ public class PintuanServiceImpl extends ServiceImpl<PintuanMapper, Pintuan> impl
|
||||
.eq(Order::getOrderStatus, OrderStatusEnum.PAID.name())
|
||||
.eq(Order::getParentOrderSn, "");
|
||||
List<Order> orders = orderService.list(queryWrapper);
|
||||
// 遍历订单状态为已支付,为团长的拼团订单
|
||||
//遍历订单状态为已支付,为团长的拼团订单
|
||||
for (Order order : orders) {
|
||||
Member member = memberService.getById(order.getMemberId());
|
||||
PintuanMemberVO memberVO = new PintuanMemberVO(member);
|
||||
LambdaQueryWrapper<Order> countQueryWrapper = new LambdaQueryWrapper<>();
|
||||
countQueryWrapper.eq(Order::getOrderStatus, OrderStatusEnum.PAID.name());
|
||||
countQueryWrapper.and(i -> i.eq(Order::getSn, order.getSn()).or(j -> j.eq(Order::getParentOrderSn, order.getSn())));
|
||||
// 获取已参团人数
|
||||
//获取已参团人数
|
||||
int count = orderService.count(countQueryWrapper);
|
||||
// 获取待参团人数
|
||||
//获取待参团人数
|
||||
int toBoGrouped = pintuan.getRequiredNum() - count;
|
||||
memberVO.setGroupNum(pintuan.getRequiredNum());
|
||||
memberVO.setGroupedNum(count);
|
||||
@ -192,7 +192,7 @@ public class PintuanServiceImpl extends ServiceImpl<PintuanMapper, Pintuan> impl
|
||||
PromotionTools.checkPromotionTime(pintuan.getStartTime().getTime(), pintuan.getEndTime().getTime());
|
||||
this.checkSamePromotion(pintuan.getStartTime(), pintuan.getEndTime(), pintuan.getStoreId(), null);
|
||||
pintuan.setPromotionStatus(PromotionStatusEnum.NEW.name());
|
||||
// 保存到MYSQL中
|
||||
//保存到MYSQL中
|
||||
boolean result = this.save(pintuan);
|
||||
this.updatePintuanPromotionGoods(pintuan);
|
||||
this.mongoTemplate.save(pintuan);
|
||||
@ -206,19 +206,19 @@ public class PintuanServiceImpl extends ServiceImpl<PintuanMapper, Pintuan> impl
|
||||
if (!pintuan.getPromotionStatus().equals(PromotionStatusEnum.NEW.name())) {
|
||||
throw new ServiceException("只有活动状态为新活动时(活动未开始)才可编辑!");
|
||||
}
|
||||
// 检查促销时间
|
||||
//检查促销时间
|
||||
PromotionTools.checkPromotionTime(pintuan.getStartTime().getTime(), pintuan.getEndTime().getTime());
|
||||
// 检查同一时间,同一店铺,同一类型的促销活动
|
||||
//检查同一时间,同一店铺,同一类型的促销活动
|
||||
this.checkSamePromotion(pintuan.getStartTime(), pintuan.getEndTime(), pintuan.getStoreId(), pintuan.getId());
|
||||
boolean result = this.updateById(pintuan);
|
||||
if (pintuan.getPromotionGoodsList() != null) {
|
||||
this.updatePintuanPromotionGoods(pintuan);
|
||||
}
|
||||
this.mongoTemplate.save(pintuan);
|
||||
// 时间发生变化
|
||||
//时间发生变化
|
||||
if (pintuan.getStartTime().getTime() != pintuanVO.getStartTime().getTime()) {
|
||||
PromotionMessage promotionMessage = new PromotionMessage(pintuan.getId(), PromotionTypeEnum.PINTUAN.name(), PromotionStatusEnum.START.name(), pintuan.getStartTime(), pintuan.getEndTime());
|
||||
// 更新延时任务
|
||||
//更新延时任务
|
||||
this.timeTrigger.edit(TimeExecuteConstant.PROMOTION_EXECUTOR,
|
||||
promotionMessage,
|
||||
pintuanVO.getStartTime().getTime(),
|
||||
@ -269,7 +269,7 @@ public class PintuanServiceImpl extends ServiceImpl<PintuanMapper, Pintuan> impl
|
||||
queryWrapper.eq(Order::getOrderPromotionType, PromotionTypeEnum.PINTUAN.name());
|
||||
queryWrapper.eq(Order::getPromotionId, pintuanId);
|
||||
queryWrapper.nested(i -> i.eq(Order::getPayStatus, PayStatusEnum.PAID.name()).or().eq(Order::getOrderStatus, OrderStatusEnum.PAID.name()));
|
||||
// 过滤父级拼团订单,根据父级拼团订单分组
|
||||
//过滤父级拼团订单,根据父级拼团订单分组
|
||||
Map<String, List<Order>> collect = orderService.list(queryWrapper).stream().filter(i -> !i.getParentOrderSn().equals("")).collect(Collectors.groupingBy(Order::getParentOrderSn));
|
||||
this.isOpenFictitiousPintuan(pintuan, collect);
|
||||
|
||||
@ -322,16 +322,16 @@ public class PintuanServiceImpl extends ServiceImpl<PintuanMapper, Pintuan> impl
|
||||
PintuanShareVO pintuanShareVO = new PintuanShareVO();
|
||||
pintuanShareVO.setPintuanMemberVOS(new ArrayList<>());
|
||||
LambdaQueryWrapper<Order> queryWrapper = new LambdaQueryWrapper<>();
|
||||
// 查找团长订单和已和当前拼团订单拼团的订单
|
||||
//查找团长订单和已和当前拼团订单拼团的订单
|
||||
queryWrapper.eq(Order::getOrderPromotionType, PromotionTypeEnum.PINTUAN.name())
|
||||
.eq(Order::getPayStatus, OrderStatusEnum.PAID.name())
|
||||
.and(i -> i.eq(Order::getParentOrderSn, parentOrderSn).or(j -> j.eq(Order::getSn, parentOrderSn)));
|
||||
List<Order> orders = orderService.list(queryWrapper);
|
||||
this.setPintuanOrderInfo(orders, pintuanShareVO, skuId);
|
||||
// 如果为根据团员订单sn查询拼团订单信息时,找到团长订单sn,然后找到所有参与到同一拼团的订单信息
|
||||
//如果为根据团员订单sn查询拼团订单信息时,找到团长订单sn,然后找到所有参与到同一拼团的订单信息
|
||||
if (!orders.isEmpty() && pintuanShareVO.getPromotionGoods() == null) {
|
||||
LambdaQueryWrapper<Order> orderLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
// 查找团长订单和已和当前拼团订单拼团的订单
|
||||
//查找团长订单和已和当前拼团订单拼团的订单
|
||||
orderLambdaQueryWrapper.eq(Order::getOrderPromotionType, PromotionTypeEnum.PINTUAN.name())
|
||||
.eq(Order::getPayStatus, OrderStatusEnum.PAID.name())
|
||||
.ne(Order::getSn, parentOrderSn)
|
||||
@ -365,9 +365,9 @@ public class PintuanServiceImpl extends ServiceImpl<PintuanMapper, Pintuan> impl
|
||||
LambdaQueryWrapper<Order> countQueryWrapper = new LambdaQueryWrapper<>();
|
||||
countQueryWrapper.eq(Order::getPayStatus, PayStatusEnum.PAID.name());
|
||||
countQueryWrapper.and(i -> i.eq(Order::getSn, order.getSn()).or(j -> j.eq(Order::getParentOrderSn, order.getSn())));
|
||||
// 获取已参团人数
|
||||
//获取已参团人数
|
||||
int count = orderService.count(countQueryWrapper);
|
||||
// 获取待参团人数
|
||||
//获取待参团人数
|
||||
int toBoGrouped = pintuanById.getRequiredNum() - count;
|
||||
memberVO.setGroupNum(pintuanById.getRequiredNum());
|
||||
memberVO.setGroupedNum(count);
|
||||
@ -392,7 +392,7 @@ public class PintuanServiceImpl extends ServiceImpl<PintuanMapper, Pintuan> impl
|
||||
promotionMessage,
|
||||
DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.PROMOTION, (promotionMessage.getPromotionType() + promotionMessage.getPromotionId())),
|
||||
rocketmqCustomProperties.getPromotionTopic());
|
||||
// 发送促销活动开始的延时任务
|
||||
//发送促销活动开始的延时任务
|
||||
this.timeTrigger.addDelay(timeTriggerMsg);
|
||||
}
|
||||
|
||||
@ -416,13 +416,13 @@ public class PintuanServiceImpl extends ServiceImpl<PintuanMapper, Pintuan> impl
|
||||
* @param collect 检查的订单列表
|
||||
*/
|
||||
private void isOpenFictitiousPintuan(PintuanVO pintuan, Map<String, List<Order>> collect) {
|
||||
// 成团人数
|
||||
//成团人数
|
||||
Integer requiredNum = pintuan.getRequiredNum();
|
||||
|
||||
for (Map.Entry<String, List<Order>> entry : collect.entrySet()) {
|
||||
// 是否开启虚拟成团
|
||||
//是否开启虚拟成团
|
||||
if (Boolean.FALSE.equals(pintuan.getFictitious()) && entry.getValue().size() < requiredNum) {
|
||||
// 如果未开启虚拟成团且已参团人数小于成团人数,则自动取消订单
|
||||
//如果未开启虚拟成团且已参团人数小于成团人数,则自动取消订单
|
||||
LambdaUpdateWrapper<Order> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(Order::getOrderPromotionType, PromotionTypeEnum.PINTUAN.name());
|
||||
updateWrapper.eq(Order::getPromotionId, pintuan.getId());
|
||||
@ -444,9 +444,9 @@ public class PintuanServiceImpl extends ServiceImpl<PintuanMapper, Pintuan> impl
|
||||
*/
|
||||
private void fictitiousPintuan(Map.Entry<String, List<Order>> entry, Integer requiredNum) {
|
||||
Map<String, List<Order>> listMap = entry.getValue().stream().collect(Collectors.groupingBy(Order::getPayStatus));
|
||||
// 未付款订单
|
||||
//未付款订单
|
||||
List<Order> unpaidOrders = listMap.get(PayStatusEnum.UNPAID.name());
|
||||
// 未付款订单自动取消
|
||||
//未付款订单自动取消
|
||||
if (unpaidOrders != null && !unpaidOrders.isEmpty()) {
|
||||
for (Order unpaidOrder : unpaidOrders) {
|
||||
unpaidOrder.setOrderStatus(OrderStatusEnum.CANCELLED.name());
|
||||
@ -455,11 +455,11 @@ public class PintuanServiceImpl extends ServiceImpl<PintuanMapper, Pintuan> impl
|
||||
orderService.updateBatchById(unpaidOrders);
|
||||
}
|
||||
List<Order> paidOrders = listMap.get(PayStatusEnum.PAID.name());
|
||||
// 如待参团人数大于0,并已开启虚拟成团
|
||||
//如待参团人数大于0,并已开启虚拟成团
|
||||
if (!paidOrders.isEmpty()) {
|
||||
// 待参团人数
|
||||
//待参团人数
|
||||
int waitNum = requiredNum - paidOrders.size();
|
||||
// 添加虚拟成团
|
||||
//添加虚拟成团
|
||||
for (int i = 0; i < waitNum; i++) {
|
||||
Order order = new Order();
|
||||
BeanUtil.copyProperties(paidOrders.get(0), order);
|
||||
@ -503,9 +503,9 @@ public class PintuanServiceImpl extends ServiceImpl<PintuanMapper, Pintuan> impl
|
||||
log.error("商品[" + promotionGood.getGoodsName() + "]不存在或处于不可售卖状态!");
|
||||
throw new ServiceException();
|
||||
}
|
||||
// 查询是否在同一时间段参与了拼团活动
|
||||
//查询是否在同一时间段参与了拼团活动
|
||||
Integer count = promotionGoodsService.findInnerOverlapPromotionGoods(PromotionTypeEnum.SECKILL.name(), promotionGood.getSkuId(), pintuan.getStartTime(), pintuan.getEndTime(), pintuan.getId());
|
||||
// 查询是否在同一时间段参与了限时抢购活动
|
||||
//查询是否在同一时间段参与了限时抢购活动
|
||||
count += promotionGoodsService.findInnerOverlapPromotionGoods(PromotionTypeEnum.PINTUAN.name(), promotionGood.getSkuId(), pintuan.getStartTime(), pintuan.getEndTime(), pintuan.getId());
|
||||
if (count > 0) {
|
||||
log.error("商品[" + promotionGood.getGoodsName() + "]已经在重叠的时间段参加了秒杀活动或拼团活动,不能参加拼团活动");
|
||||
|
@ -115,7 +115,7 @@ public class PointsGoodsServiceImpl extends ServiceImpl<PointsGoodsMapper, Point
|
||||
this.mongoTemplate.save(pointsGoods);
|
||||
if (pointsGoods.getStartTime().getTime() != pointsGoodsVO.getStartTime().getTime()) {
|
||||
PromotionMessage promotionMessage = new PromotionMessage(pointsGoods.getId(), PromotionTypeEnum.POINTS_GOODS.name(), PromotionStatusEnum.START.name(), pointsGoods.getStartTime(), pointsGoods.getEndTime());
|
||||
// 更新延时任务
|
||||
//更新延时任务
|
||||
this.timeTrigger.edit(TimeExecuteConstant.PROMOTION_EXECUTOR,
|
||||
promotionMessage,
|
||||
pointsGoodsVO.getStartTime().getTime(),
|
||||
@ -245,7 +245,7 @@ public class PointsGoodsServiceImpl extends ServiceImpl<PointsGoodsMapper, Point
|
||||
promotionMessage,
|
||||
DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.PROMOTION, (promotionMessage.getPromotionType() + promotionMessage.getPromotionId())),
|
||||
rocketmqCustomProperties.getPromotionTopic());
|
||||
// 发送促销活动开始的延时任务
|
||||
//发送促销活动开始的延时任务
|
||||
this.timeTrigger.addDelay(timeTriggerMsg);
|
||||
}
|
||||
|
||||
|
@ -130,14 +130,14 @@ public class PromotionGoodsServiceImpl extends ServiceImpl<PromotionGoodsMapper,
|
||||
LambdaQueryWrapper<PromotionGoods> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(PromotionGoods::getSkuId, cartSkuVO.getGoodsSku().getId()).eq(PromotionGoods::getPromotionStatus, PromotionStatusEnum.START.name());
|
||||
queryWrapper.le(PromotionGoods::getStartTime, date);
|
||||
// 获取有效的促销活动
|
||||
//获取有效的促销活动
|
||||
List<PromotionGoods> promotionGoods = this.list(queryWrapper);
|
||||
// 同步查询缓存中的促销活动商品的库存
|
||||
//同步查询缓存中的促销活动商品的库存
|
||||
for (PromotionGoods promotionGood : promotionGoods) {
|
||||
Integer goodsStock = this.getPromotionGoodsStock(PromotionTypeEnum.valueOf(promotionGood.getPromotionType()), promotionGood.getPromotionId(), promotionGood.getSkuId());
|
||||
promotionGood.setQuantity(goodsStock);
|
||||
}
|
||||
// 单独检查,添加适用于全品类的满优惠活动
|
||||
//单独检查,添加适用于全品类的满优惠活动
|
||||
Query query = new Query();
|
||||
query.addCriteria(Criteria.where("promotionStatus").is(PromotionStatusEnum.START.name()));
|
||||
query.addCriteria(Criteria.where("startTime").lte(date));
|
||||
@ -154,7 +154,7 @@ public class PromotionGoodsServiceImpl extends ServiceImpl<PromotionGoodsMapper,
|
||||
promotionGoods.add(p);
|
||||
}
|
||||
}
|
||||
// 单独检查,添加适用于全品类的全平台或属于当前店铺的满优惠活动
|
||||
//单独检查,添加适用于全品类的全平台或属于当前店铺的满优惠活动
|
||||
List<CouponVO> couponVOS = mongoTemplate.find(query, CouponVO.class);
|
||||
for (CouponVO couponVO : couponVOS) {
|
||||
if (couponVO.getPromotionGoodsList() == null && couponVO.getScopeType().equals(CouponScopeTypeEnum.ALL.name()) &&
|
||||
@ -214,7 +214,7 @@ public class PromotionGoodsServiceImpl extends ServiceImpl<PromotionGoodsMapper,
|
||||
query.addCriteria(Criteria.where("endTime").gt(now));
|
||||
List<PromotionGoodsDTO> promotionGoodsDTOList = new ArrayList<>();
|
||||
int total = 0;
|
||||
// 根据促销活动类型的不同,将满足当前促销活动类型且正在进行的促销商品返回出去
|
||||
//根据促销活动类型的不同,将满足当前促销活动类型且正在进行的促销商品返回出去
|
||||
switch (PromotionTypeEnum.valueOf(promotionType)) {
|
||||
case FULL_DISCOUNT:
|
||||
List<FullDiscountVO> fullDiscountVOS = this.mongoTemplate.find(query, FullDiscountVO.class);
|
||||
@ -395,7 +395,7 @@ public class PromotionGoodsServiceImpl extends ServiceImpl<PromotionGoodsMapper,
|
||||
searchParams.setSort(pageVo.getSort());
|
||||
searchParams.setOrder(pageVo.getOrder());
|
||||
IPage<GoodsSku> goodsSkuByPage = goodsSkuService.getGoodsSkuByPage(searchParams);
|
||||
// 将查询到的商品sku转换为促销商品
|
||||
//将查询到的商品sku转换为促销商品
|
||||
for (GoodsSku record : goodsSkuByPage.getRecords()) {
|
||||
PromotionGoodsDTO promotionGoods = new PromotionGoodsDTO(record);
|
||||
promotionGoods.setGoodsImage(record.getThumbnail());
|
||||
|
@ -47,13 +47,13 @@ public class PromotionPriceServiceImpl implements PromotionPriceService {
|
||||
public PromotionPriceDTO calculationPromotionPrice(List<PromotionPriceParamDTO> tradeSkuList, List<MemberCoupon> memberCouponList) {
|
||||
PromotionPriceDTO promotionPrice = new PromotionPriceDTO();
|
||||
if (!tradeSkuList.isEmpty()) {
|
||||
// 拆分出SkuId列表
|
||||
//拆分出SkuId列表
|
||||
List<String> skuIds = tradeSkuList.parallelStream().map(PromotionPriceParamDTO::getSkuId).collect(Collectors.toList());
|
||||
// 参与计算的ES商品SKU及其促销信息列表
|
||||
//参与计算的ES商品SKU及其促销信息列表
|
||||
List<EsGoodsIndex> esGoodsSkus = goodsSearchService.getEsGoodsBySkuIds(skuIds);
|
||||
// 参与计算的缓存中的商品SKU列表
|
||||
//参与计算的缓存中的商品SKU列表
|
||||
List<GoodsSku> goodsSkus = goodsSkuService.getGoodsSkuByIdFromCache(skuIds);
|
||||
// 计算价格
|
||||
//计算价格
|
||||
promotionPrice = this.calculationPromotionPrice(tradeSkuList, memberCouponList, esGoodsSkus, goodsSkus);
|
||||
}
|
||||
return promotionPrice;
|
||||
@ -71,15 +71,15 @@ public class PromotionPriceServiceImpl implements PromotionPriceService {
|
||||
private PromotionPriceDTO calculationPromotionPrice(List<PromotionPriceParamDTO> tradeSkuList, List<MemberCoupon> memberCouponList, List<EsGoodsIndex> esGoodsSkus, List<GoodsSku> goodsSkus) {
|
||||
PromotionPriceDTO promotionPrice = new PromotionPriceDTO();
|
||||
|
||||
// 单品商品SKU促销计算结果列表
|
||||
//单品商品SKU促销计算结果列表
|
||||
List<GoodsSkuPromotionPriceDTO> priceDTOList = this.packageGoodsSkuPromotionPrice(tradeSkuList, esGoodsSkus, goodsSkus);
|
||||
|
||||
// 将使用的优惠券根据店铺分类
|
||||
//将使用的优惠券根据店铺分类
|
||||
Map<String, List<MemberCoupon>> couponCollect = memberCouponList.parallelStream().collect(Collectors.groupingBy(MemberCoupon::getStoreId));
|
||||
|
||||
double couponTotalPrice = 0;
|
||||
|
||||
// 根据卖家分组商品信息
|
||||
//根据卖家分组商品信息
|
||||
Map<String, List<GoodsSkuPromotionPriceDTO>> storeCollect = priceDTOList.parallelStream().collect(Collectors.groupingBy(GoodsSkuPromotionPriceDTO::getStoreId));
|
||||
List<StorePromotionPriceDTO> storePromotionPriceList = new ArrayList<>();
|
||||
for (Map.Entry<String, List<GoodsSkuPromotionPriceDTO>> entry : storeCollect.entrySet()) {
|
||||
@ -89,42 +89,42 @@ public class PromotionPriceServiceImpl implements PromotionPriceService {
|
||||
Optional<GoodsSkuPromotionPriceDTO> firstFullDiscount = entry.getValue().parallelStream().filter(i -> i.getPromotionId() != null && i.getPromotionType().equals(PromotionTypeEnum.FULL_DISCOUNT.name())).findFirst();
|
||||
if (firstFullDiscount.isPresent()) {
|
||||
String promotionId = firstFullDiscount.get().getPromotionId();
|
||||
// 是否存在满优惠促销活动
|
||||
//是否存在满优惠促销活动
|
||||
String esPromotionFullDiscountKey = PromotionTypeEnum.FULL_DISCOUNT + "-" + promotionId;
|
||||
if (CharSequenceUtil.isNotEmpty(promotionId)) {
|
||||
FullDiscount fullDiscount = null;
|
||||
for (EsGoodsIndex skus : esGoodsSkus) {
|
||||
// 检查是否为正在进行的满优惠活动
|
||||
//检查是否为正在进行的满优惠活动
|
||||
if (skus.getPromotionMap() != null && skus.getPromotionMap().containsKey(esPromotionFullDiscountKey)) {
|
||||
fullDiscount = (FullDiscount) skus.getPromotionMap().get(esPromotionFullDiscountKey);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (fullDiscount != null) {
|
||||
// 计算满优惠活动
|
||||
//计算满优惠活动
|
||||
this.calculationFullDiscount(fullDiscount, storePromotionPrice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取店铺优惠券
|
||||
//获取店铺优惠券
|
||||
List<MemberCoupon> storeCoupons = couponCollect.get(entry.getKey());
|
||||
if (storeCoupons != null && !storeCoupons.isEmpty()) {
|
||||
// 计算店铺优惠券活动
|
||||
//计算店铺优惠券活动
|
||||
couponTotalPrice = this.calculationCoupon(storeCoupons, entry.getValue());
|
||||
storePromotionPrice.setTotalCouponPrice(couponTotalPrice);
|
||||
storePromotionPrice.setTotalFinalePrice(storePromotionPrice.getGoodsSkuPromotionPriceList().parallelStream().mapToDouble(GoodsSkuPromotionPriceDTO::getTotalFinalePrice).sum());
|
||||
}
|
||||
|
||||
// 累加除商品促销信息之外的信息
|
||||
//累加除商品促销信息之外的信息
|
||||
this.accumulationGoodsSkuPromotionOther(entry.getValue(), storePromotionPrice);
|
||||
|
||||
storePromotionPriceList.add(storePromotionPrice);
|
||||
}
|
||||
// 获取平台优惠券
|
||||
//获取平台优惠券
|
||||
List<MemberCoupon> platformCoupons = couponCollect.get("platform");
|
||||
if (platformCoupons != null && !platformCoupons.isEmpty()) {
|
||||
// 计算平台优惠券活动
|
||||
//计算平台优惠券活动
|
||||
couponTotalPrice = CurrencyUtil.add(couponTotalPrice, this.calculationCoupon(platformCoupons, priceDTOList));
|
||||
for (StorePromotionPriceDTO storePromotionPriceDTO : storePromotionPriceList) {
|
||||
Double couponPrice = storePromotionPriceDTO.getGoodsSkuPromotionPriceList().parallelStream().mapToDouble(GoodsSkuPromotionPriceDTO::getCouponPrice).sum();
|
||||
@ -136,7 +136,7 @@ public class PromotionPriceServiceImpl implements PromotionPriceService {
|
||||
promotionPrice.setTotalOriginPrice(storePromotionPriceList.parallelStream().mapToDouble(StorePromotionPriceDTO::getTotalOriginPrice).sum());
|
||||
promotionPrice.setTotalPoints(storePromotionPriceList.parallelStream().mapToDouble(StorePromotionPriceDTO::getTotalPoints).sum());
|
||||
promotionPrice.setTotalDiscountPrice(storePromotionPriceList.parallelStream().mapToDouble(StorePromotionPriceDTO::getTotalDiscountPrice).sum());
|
||||
// 最终结算金额 = 商品原价格合计 - 总优惠价格合计 - 优惠券合计
|
||||
//最终结算金额 = 商品原价格合计 - 总优惠价格合计 - 优惠券合计
|
||||
double totalFinalePrice = CurrencyUtil.sub(CurrencyUtil.sub(promotionPrice.getTotalOriginPrice(), promotionPrice.getTotalDiscountPrice()), promotionPrice.getTotalCouponPrice());
|
||||
promotionPrice.setTotalFinalePrice(totalFinalePrice);
|
||||
return promotionPrice;
|
||||
@ -157,16 +157,16 @@ public class PromotionPriceServiceImpl implements PromotionPriceService {
|
||||
List<EsGoodsIndex> collect = esGoodsSkus.parallelStream().filter(i -> i != null && i.getId().equals(skus.getId())).collect(Collectors.toList());
|
||||
if (!collect.isEmpty()) {
|
||||
EsGoodsIndex esGoodsIndex = collect.get(0);
|
||||
// 找出当前商品相应的结算参数
|
||||
//找出当前商品相应的结算参数
|
||||
PromotionPriceParamDTO tradeSku = tradeSkuList.parallelStream().filter(i -> i.getSkuId().equals(skus.getId())).findFirst().orElse(new PromotionPriceParamDTO());
|
||||
GoodsSkuPromotionPriceDTO goodsSkuPromotionPrice = new GoodsSkuPromotionPriceDTO(skus, tradeSku.getNum());
|
||||
// 商品原价总价 = 商品原价 * 数量
|
||||
//商品原价总价 = 商品原价 * 数量
|
||||
goodsSkuPromotionPrice.setTotalOriginalPrice(CurrencyUtil.mul(goodsSkuPromotionPrice.getOriginalPrice(), tradeSku.getNum()));
|
||||
// 获取当前商品所有参加的促销活动
|
||||
//获取当前商品所有参加的促销活动
|
||||
Map<String, Object> promotionMap = esGoodsIndex.getPromotionMap();
|
||||
// 是否计算拼团促销
|
||||
//是否计算拼团促销
|
||||
String pintuanId = tradeSku.getPintuanId() != null ? tradeSku.getPintuanId() : null;
|
||||
// 如果商品促销列表存在促销活动
|
||||
//如果商品促销列表存在促销活动
|
||||
this.calculationPromotionMap(promotionMap, goodsSkuPromotionPrice, esGoodsIndex, pintuanId);
|
||||
|
||||
goodsSkuPromotionPrice.setTotalOriginalPrice(CurrencyUtil.mul(goodsSkuPromotionPrice.getOriginalPrice(), goodsSkuPromotionPrice.getNumber()));
|
||||
@ -189,21 +189,21 @@ public class PromotionPriceServiceImpl implements PromotionPriceService {
|
||||
*/
|
||||
private void calculationPromotionMap(Map<String, Object> promotionMap, GoodsSkuPromotionPriceDTO goodsSkuPromotionPrice, EsGoodsIndex esGoodsIndex, String pintuanId) {
|
||||
if (promotionMap != null && !promotionMap.isEmpty()) {
|
||||
// 检查当前商品是否存在秒杀活动活动
|
||||
//检查当前商品是否存在秒杀活动活动
|
||||
Optional<String> existSeckill = promotionMap.keySet().parallelStream().filter(i -> i.contains(PromotionTypeEnum.SECKILL.name())).findFirst();
|
||||
if (existSeckill.isPresent()) {
|
||||
Seckill seckill = (Seckill) promotionMap.get(existSeckill.get());
|
||||
// 计算秒杀活动促销
|
||||
//计算秒杀活动促销
|
||||
this.calculationSeckill(seckill, goodsSkuPromotionPrice);
|
||||
seckill.setPromotionName(PromotionTypeEnum.SECKILL.name());
|
||||
goodsSkuPromotionPrice.getJoinPromotion().add(seckill);
|
||||
}
|
||||
|
||||
// 检查当前商品是否存在拼团活动
|
||||
//检查当前商品是否存在拼团活动
|
||||
Optional<String> existPintuan = promotionMap.keySet().parallelStream().filter(i -> i.contains(PromotionTypeEnum.PINTUAN.name())).findFirst();
|
||||
if (existPintuan.isPresent() && pintuanId != null) {
|
||||
Pintuan pintuan = (Pintuan) promotionMap.get(existPintuan.get());
|
||||
// 优惠的总价格 = 原商品总价 - 优惠后的商品总价
|
||||
//优惠的总价格 = 原商品总价 - 优惠后的商品总价
|
||||
double discountPrice = CurrencyUtil.sub(goodsSkuPromotionPrice.getOriginalPrice(), esGoodsIndex.getPromotionPrice());
|
||||
goodsSkuPromotionPrice.setDiscountPrice(discountPrice);
|
||||
goodsSkuPromotionPrice.setFinalePrice(esGoodsIndex.getPromotionPrice());
|
||||
@ -211,7 +211,7 @@ public class PromotionPriceServiceImpl implements PromotionPriceService {
|
||||
goodsSkuPromotionPrice.getJoinPromotion().add(pintuan);
|
||||
}
|
||||
|
||||
// 检查当前商品是否存在满优惠活动
|
||||
//检查当前商品是否存在满优惠活动
|
||||
Optional<String> existFullDiscount = promotionMap.keySet().parallelStream().filter(i -> i.contains(PromotionTypeEnum.FULL_DISCOUNT.name())).findFirst();
|
||||
if (existFullDiscount.isPresent()) {
|
||||
FullDiscount discount = (FullDiscount) promotionMap.get(existFullDiscount.get());
|
||||
@ -241,14 +241,14 @@ public class PromotionPriceServiceImpl implements PromotionPriceService {
|
||||
if (CouponScopeTypeEnum.PORTION_GOODS.name().equals(coupon.getScopeType())) {
|
||||
String[] scopeSkuIds = coupon.getScopeId().split(",");
|
||||
List<GoodsSkuPromotionPriceDTO> conformCollect = list.parallelStream().filter(i -> Arrays.asList(scopeSkuIds).contains(i.getSkuId())).collect(Collectors.toList());
|
||||
// 单个优惠券计算
|
||||
//单个优惠券计算
|
||||
couponTotalPrice = this.calculationSingleCoupon(coupon, conformCollect);
|
||||
} else if (CouponScopeTypeEnum.ALL.name().equals(coupon.getScopeType())) {
|
||||
// 单个优惠券计算
|
||||
//单个优惠券计算
|
||||
couponTotalPrice = this.calculationSingleCoupon(coupon, list);
|
||||
} else if (CouponScopeTypeEnum.PORTION_GOODS_CATEGORY.name().equals(coupon.getScopeType()) || CouponScopeTypeEnum.PORTION_SHOP_CATEGORY.name().equals(coupon.getScopeType())) {
|
||||
List<GoodsSkuPromotionPriceDTO> collect = this.filterCoupon(coupon, list);
|
||||
// 单个优惠券计算
|
||||
//单个优惠券计算
|
||||
couponTotalPrice = this.calculationSingleCoupon(coupon, collect);
|
||||
}
|
||||
}
|
||||
@ -265,7 +265,7 @@ public class PromotionPriceServiceImpl implements PromotionPriceService {
|
||||
private List<GoodsSkuPromotionPriceDTO> filterCoupon(MemberCoupon coupon, List<GoodsSkuPromotionPriceDTO> list) {
|
||||
String[] scopeCategories = coupon.getScopeId().split(",");
|
||||
|
||||
// 过滤优惠券范围内分类 商品sku促销价格信息列表
|
||||
//过滤优惠券范围内分类 商品sku促销价格信息列表
|
||||
return list.parallelStream().filter(i -> {
|
||||
String[] split;
|
||||
if (CouponScopeTypeEnum.PORTION_GOODS_CATEGORY.name().equals(coupon.getScopeType())) {
|
||||
@ -291,10 +291,10 @@ public class PromotionPriceServiceImpl implements PromotionPriceService {
|
||||
*/
|
||||
private double calculationSingleCoupon(MemberCoupon coupon, List<GoodsSkuPromotionPriceDTO> conformCollect) {
|
||||
double couponTotalPrice = 0;
|
||||
// 合计优惠券范围内的所有商品的原价
|
||||
//合计优惠券范围内的所有商品的原价
|
||||
double totalPrice = conformCollect.parallelStream().mapToDouble(GoodsSkuPromotionPriceDTO::getTotalFinalePrice).sum();
|
||||
|
||||
// 根据优惠券优惠类型,判断是否满足条件
|
||||
//根据优惠券优惠类型,判断是否满足条件
|
||||
if (CouponTypeEnum.PRICE.name().equals(coupon.getCouponType()) && coupon.getConsumeThreshold() <= totalPrice) {
|
||||
couponTotalPrice = CurrencyUtil.add(couponTotalPrice, coupon.getPrice());
|
||||
} else if (CouponTypeEnum.DISCOUNT.name().equals(coupon.getCouponType())) {
|
||||
@ -302,7 +302,7 @@ public class PromotionPriceServiceImpl implements PromotionPriceService {
|
||||
double discountRatePrice = CurrencyUtil.sub(totalPrice, CurrencyUtil.mul(totalPrice, fullRate));
|
||||
|
||||
couponTotalPrice = CurrencyUtil.add(couponTotalPrice, discountRatePrice);
|
||||
// 消费限额判断
|
||||
//消费限额判断
|
||||
// if (coupon.getConsumeThreshold() >= discountRatePrice) {
|
||||
// couponTotalPrice = CurrencyUtil.add(couponTotalPrice, discountRatePrice);
|
||||
// discountPrice = discountRatePrice;
|
||||
@ -312,7 +312,7 @@ public class PromotionPriceServiceImpl implements PromotionPriceService {
|
||||
// }
|
||||
}
|
||||
|
||||
// 分配到每个商品的优惠券金额
|
||||
//分配到每个商品的优惠券金额
|
||||
for (GoodsSkuPromotionPriceDTO goodsSkuPromotionPriceDTO : conformCollect) {
|
||||
double rate = CurrencyUtil.div(goodsSkuPromotionPriceDTO.getTotalFinalePrice(), totalPrice, 5);
|
||||
double distributeCouponPrice = CurrencyUtil.div(CurrencyUtil.mul(couponTotalPrice, rate), goodsSkuPromotionPriceDTO.getNumber());
|
||||
@ -344,7 +344,7 @@ public class PromotionPriceServiceImpl implements PromotionPriceService {
|
||||
* @param promotionPrice 商品SKU的计算促销信息
|
||||
*/
|
||||
private void calculationSeckill(Seckill seckill, GoodsSkuPromotionPriceDTO promotionPrice) {
|
||||
// 检查 活动有效时间 及 活动有效状态
|
||||
//检查 活动有效时间 及 活动有效状态
|
||||
if (checkPromotionValidTime(seckill.getStartTime(), seckill.getEndTime(), PromotionTypeEnum.SECKILL.name(), seckill.getId()) && seckill.getPromotionStatus().equals(PromotionStatusEnum.START.name())) {
|
||||
LambdaQueryWrapper<SeckillApply> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SeckillApply::getSkuId, promotionPrice.getSkuId()).eq(SeckillApply::getSeckillId, seckill.getId());
|
||||
@ -353,7 +353,7 @@ public class PromotionPriceServiceImpl implements PromotionPriceService {
|
||||
Integer quantity = promotionGoodsService.getPromotionGoodsStock(PromotionTypeEnum.SECKILL, seckill.getId(), seckillApply.getSkuId());
|
||||
int seckillTotalSaleNum = seckillApply.getSalesNum() + promotionPrice.getNumber();
|
||||
if (quantity >= seckillTotalSaleNum) {
|
||||
// 优惠的价格 = 原商品价 - 优惠后的商品价
|
||||
//优惠的价格 = 原商品价 - 优惠后的商品价
|
||||
double discountPrice = CurrencyUtil.sub(promotionPrice.getOriginalPrice(), seckillApply.getPrice());
|
||||
promotionPrice.setDiscountPrice(discountPrice);
|
||||
promotionPrice.setFinalePrice(seckillApply.getPrice());
|
||||
@ -371,33 +371,33 @@ public class PromotionPriceServiceImpl implements PromotionPriceService {
|
||||
* @param storePromotionPriceDTO 店铺促销计算信息
|
||||
*/
|
||||
private void calculationFullDiscount(FullDiscount fullDiscount, StorePromotionPriceDTO storePromotionPriceDTO) {
|
||||
// 检查 活动有效时间 及 活动有效状态
|
||||
//检查 活动有效时间 及 活动有效状态
|
||||
if (checkPromotionValidTime(fullDiscount.getStartTime(), fullDiscount.getEndTime(), PromotionTypeEnum.FULL_DISCOUNT.name(), fullDiscount.getId()) && fullDiscount.getPromotionStatus().equals(PromotionStatusEnum.START.name())) {
|
||||
// 是否免运费
|
||||
//是否免运费
|
||||
if (Boolean.TRUE.equals(fullDiscount.getIsFreeFreight())) {
|
||||
storePromotionPriceDTO.setIsFreeFreight(true);
|
||||
}
|
||||
List<GoodsSkuPromotionPriceDTO> goodsSkuPromotionPriceList = storePromotionPriceDTO.getGoodsSkuPromotionPriceList();
|
||||
|
||||
// 参与活动的商品总数量
|
||||
//参与活动的商品总数量
|
||||
this.accumulationGoodsSkuPromotionPrice(goodsSkuPromotionPriceList, storePromotionPriceDTO);
|
||||
|
||||
// 参与优惠商品的成交金额是否满足满优惠条件
|
||||
//参与优惠商品的成交金额是否满足满优惠条件
|
||||
if (fullDiscount.getFullMoney() <= storePromotionPriceDTO.getTotalJoinDiscountPrice()) {
|
||||
// 判断是否为满减,反之则为满折扣
|
||||
//判断是否为满减,反之则为满折扣
|
||||
if (Boolean.TRUE.equals(fullDiscount.getIsFullMinus())) {
|
||||
// 优惠总金额 = 原优惠总金额 + 满优惠减免的金额
|
||||
//优惠总金额 = 原优惠总金额 + 满优惠减免的金额
|
||||
storePromotionPriceDTO.setTotalDiscountPrice(CurrencyUtil.add(storePromotionPriceDTO.getTotalDiscountPrice(), fullDiscount.getFullMinus()));
|
||||
} else if (Boolean.TRUE.equals(fullDiscount.getIsFullRate())) {
|
||||
double fullRate = fullDiscount.getFullRate() >= 10 ? fullDiscount.getFullRate() / 100 : fullDiscount.getFullRate() / 10;
|
||||
// 满优惠减免的金额 = 原参与优惠的总金额 * 满优惠折扣(百分比)
|
||||
//满优惠减免的金额 = 原参与优惠的总金额 * 满优惠折扣(百分比)
|
||||
double discountPrice = CurrencyUtil.sub(storePromotionPriceDTO.getTotalJoinDiscountPrice(), CurrencyUtil.mul(storePromotionPriceDTO.getTotalJoinDiscountPrice(), fullRate));
|
||||
// 优惠总金额 = 原优惠总金额 + 满优惠减免的金额
|
||||
//优惠总金额 = 原优惠总金额 + 满优惠减免的金额
|
||||
storePromotionPriceDTO.setTotalDiscountPrice(CurrencyUtil.add(storePromotionPriceDTO.getTotalDiscountPrice(), discountPrice));
|
||||
}
|
||||
}
|
||||
|
||||
// 将计算完的促销价格,平均分配到参与促销的每个商品上去
|
||||
//将计算完的促销价格,平均分配到参与促销的每个商品上去
|
||||
this.distributeStoreFullDiscountPromotionPrice(storePromotionPriceDTO, fullDiscount);
|
||||
}
|
||||
}
|
||||
@ -410,7 +410,7 @@ public class PromotionPriceServiceImpl implements PromotionPriceService {
|
||||
* @param storePromotionPriceDTO 店铺促销计算信息
|
||||
*/
|
||||
private void accumulationGoodsSkuPromotionPrice(List<GoodsSkuPromotionPriceDTO> goodsSkuPromotionPriceList, StorePromotionPriceDTO storePromotionPriceDTO) {
|
||||
// 数据累加
|
||||
//数据累加
|
||||
double totalNotJoinDiscountPrice = 0;
|
||||
double totalJoinDiscountPrice = 0;
|
||||
double totalDiscountPrice = 0;
|
||||
@ -473,16 +473,16 @@ public class PromotionPriceServiceImpl implements PromotionPriceService {
|
||||
* @param storePromotionPriceDTO 店铺促销计算信息
|
||||
*/
|
||||
private void distributeStoreFullDiscountPromotionPrice(StorePromotionPriceDTO storePromotionPriceDTO, FullDiscount fullDiscount) {
|
||||
// 分配的促销总金额 = 促销总金额 / 分配的数量
|
||||
//分配的促销总金额 = 促销总金额 / 分配的数量
|
||||
for (GoodsSkuPromotionPriceDTO goodsSkuPromotionPrice : storePromotionPriceDTO.getGoodsSkuPromotionPriceList()) {
|
||||
// 属于相应的促销活动的商品金额均分
|
||||
//属于相应的促销活动的商品金额均分
|
||||
if (goodsSkuPromotionPrice.getDiscountPriceRate() != null
|
||||
&& goodsSkuPromotionPrice.getPromotionType() != null
|
||||
&& goodsSkuPromotionPrice.getPromotionType().equals(PromotionTypeEnum.FULL_DISCOUNT.name())) {
|
||||
double distributeDiscountTotalPrice = CurrencyUtil.mul(storePromotionPriceDTO.getTotalDiscountPrice(), goodsSkuPromotionPrice.getDiscountPriceRate());
|
||||
goodsSkuPromotionPrice.setDiscountPrice(distributeDiscountTotalPrice);
|
||||
goodsSkuPromotionPrice.setTotalDiscountPrice(distributeDiscountTotalPrice);
|
||||
// 单品成交价
|
||||
//单品成交价
|
||||
double finalPrice = CurrencyUtil.sub(goodsSkuPromotionPrice.getTotalOriginalPrice(), distributeDiscountTotalPrice);
|
||||
goodsSkuPromotionPrice.setFinalePrice(finalPrice);
|
||||
goodsSkuPromotionPrice.setTotalFinalePrice(CurrencyUtil.mul(finalPrice, goodsSkuPromotionPrice.getNumber()));
|
||||
|
@ -121,21 +121,21 @@ public class PromotionServiceImpl implements PromotionService {
|
||||
queryWrapper.eq("promotion_status", PromotionStatusEnum.START.name());
|
||||
queryWrapper.gt("start_time", new Date());
|
||||
queryWrapper.lt("end_time", new Date());
|
||||
// 获取当前进行的秒杀活动活动
|
||||
//获取当前进行的秒杀活动活动
|
||||
List<Seckill> seckillList = seckillService.list(queryWrapper);
|
||||
if (seckillList != null && !seckillList.isEmpty()) {
|
||||
for (Seckill seckill : seckillList) {
|
||||
resultMap.put(PromotionTypeEnum.SECKILL.name(), seckill);
|
||||
}
|
||||
}
|
||||
// 获取当前进行的满优惠活动
|
||||
//获取当前进行的满优惠活动
|
||||
List<FullDiscount> fullDiscountList = fullDiscountService.list(queryWrapper);
|
||||
if (fullDiscountList != null && !fullDiscountList.isEmpty()) {
|
||||
for (FullDiscount fullDiscount : fullDiscountList) {
|
||||
resultMap.put(PromotionTypeEnum.FULL_DISCOUNT.name(), fullDiscount);
|
||||
}
|
||||
}
|
||||
// 获取当前进行的拼团活动
|
||||
//获取当前进行的拼团活动
|
||||
List<Pintuan> pintuanList = pintuanService.list(queryWrapper);
|
||||
if (pintuanList != null && !pintuanList.isEmpty()) {
|
||||
for (Pintuan pintuan : pintuanList) {
|
||||
@ -249,14 +249,14 @@ public class PromotionServiceImpl implements PromotionService {
|
||||
fullDiscountVO.setPromotionStatus(promotionMessage.getPromotionStatus());
|
||||
//修改促销数据
|
||||
result = this.fullDiscountService.update(promotionMessage.updateWrapper());
|
||||
// clone一个活动信息,用于存放与索引中
|
||||
//clone一个活动信息,用于存放与索引中
|
||||
FullDiscountVO clone = ObjectUtil.clone(fullDiscountVO);
|
||||
clone.setPromotionGoodsList(null);
|
||||
if (fullDiscountVO.getPromotionGoodsList() == null && fullDiscountVO.getNumber() == -1) {
|
||||
// 如果为全品类则更新全部索引
|
||||
//如果为全品类则更新全部索引
|
||||
this.goodsIndexService.updateEsGoodsIndexAllByList(clone, esPromotionKey);
|
||||
} else {
|
||||
// 如不为全品类,更新指定索引
|
||||
//如不为全品类,更新指定索引
|
||||
for (PromotionGoods promotionGoods : fullDiscountVO.getPromotionGoodsList()) {
|
||||
promotionGoods.setPromotionStatus(promotionMessage.getPromotionStatus());
|
||||
}
|
||||
@ -293,15 +293,15 @@ public class PromotionServiceImpl implements PromotionService {
|
||||
.set(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.EXPIRE.name());
|
||||
this.memberCouponService.update(updateWrapper);
|
||||
}
|
||||
// clone一个活动信息,用于存放与索引中
|
||||
//clone一个活动信息,用于存放与索引中
|
||||
CouponVO clone = ObjectUtil.clone(couponVO);
|
||||
clone.setPromotionGoodsList(null);
|
||||
if (CouponScopeTypeEnum.PORTION_GOODS.name().equals(couponVO.getScopeType())) {
|
||||
// 如为部分商品,则更新部分商品索引
|
||||
//如为部分商品,则更新部分商品索引
|
||||
this.promotionGoodsService.updateBatchById(couponVO.getPromotionGoodsList());
|
||||
this.goodsIndexService.updateEsGoodsIndexByList(couponVO.getPromotionGoodsList(), clone, esPromotionKey);
|
||||
} else if (CouponScopeTypeEnum.ALL.name().equals(couponVO.getScopeType())) {
|
||||
// 如为全部,则更新全部商品索引
|
||||
//如为全部,则更新全部商品索引
|
||||
this.goodsIndexService.updateEsGoodsIndexAllByList(clone, esPromotionKey);
|
||||
}
|
||||
this.mongoTemplate.save(couponVO);
|
||||
@ -327,7 +327,7 @@ public class PromotionServiceImpl implements PromotionService {
|
||||
this.promotionGoodsService.updateBatchById(pintuanVO.getPromotionGoodsList());
|
||||
if (pintuanVO.getPromotionGoodsList() != null) {
|
||||
List<PromotionGoods> promotionGoodsList = pintuanVO.getPromotionGoodsList();
|
||||
// 更新促销商品索引
|
||||
//更新促销商品索引
|
||||
for (PromotionGoods promotionGoods : promotionGoodsList) {
|
||||
Pintuan pintuan1 = JSONUtil.toBean(JSONUtil.toJsonStr(pintuanVO), Pintuan.class);
|
||||
this.goodsIndexService.updateEsGoodsIndex(promotionGoods.getSkuId(), pintuan1, esPromotionKey, promotionGoods.getPrice());
|
||||
@ -357,14 +357,14 @@ public class PromotionServiceImpl implements PromotionService {
|
||||
result = this.seckillService.update(promotionMessage.updateWrapper());
|
||||
for (SeckillApply seckillApply : seckill.getSeckillApplyList()) {
|
||||
if (seckillApply.getPromotionApplyStatus().equals(PromotionApplyStatusEnum.PASS.name())) {
|
||||
// 下一个时间,默认为当天结束时间
|
||||
//下一个时间,默认为当天结束时间
|
||||
int nextHour = 23;
|
||||
String[] split = seckill.getHours().split(",");
|
||||
int[] hoursSored = Arrays.stream(split).mapToInt(Integer::parseInt).toArray();
|
||||
// 排序时间段
|
||||
//排序时间段
|
||||
Arrays.sort(hoursSored);
|
||||
for (int i : hoursSored) {
|
||||
// 如果当前时间段大于排序后的时间段的某个,当前时间段的下个时间段即为排序后的时间段的某个
|
||||
//如果当前时间段大于排序后的时间段的某个,当前时间段的下个时间段即为排序后的时间段的某个
|
||||
if (seckillApply.getTimeLine() < i) {
|
||||
nextHour = i;
|
||||
break;
|
||||
@ -374,12 +374,12 @@ public class PromotionServiceImpl implements PromotionService {
|
||||
String format = cn.hutool.core.date.DateUtil.format(seckill.getStartTime(), DateUtil.STANDARD_DATE_FORMAT);
|
||||
DateTime parseStartTime = cn.hutool.core.date.DateUtil.parse((format + " " + seckillApply.getTimeLine()), "yyyy-MM-dd HH");
|
||||
DateTime parseEndTime = cn.hutool.core.date.DateUtil.parse((format + " " + nextHour), "yyyy-MM-dd HH");
|
||||
// 如果是当天最后的时间段则设置到当天结束时间的59分59秒
|
||||
//如果是当天最后的时间段则设置到当天结束时间的59分59秒
|
||||
if (nextHour == seckillApply.getTimeLine()) {
|
||||
parseEndTime = cn.hutool.core.date.DateUtil.parse((format + " " + nextHour + ":59:59"), DateUtil.STANDARD_FORMAT);
|
||||
}
|
||||
seckill1.setStartTime(parseStartTime);
|
||||
// 当时商品的秒杀活动活动结束时间为下个时间段的开始
|
||||
//当时商品的秒杀活动活动结束时间为下个时间段的开始
|
||||
seckill1.setEndTime(parseEndTime);
|
||||
this.goodsIndexService.updateEsGoodsIndex(seckillApply.getSkuId(), seckill1, promotionTypeEnum.name() + "-" + seckillApply.getTimeLine(), seckillApply.getPrice());
|
||||
}
|
||||
|
@ -70,18 +70,18 @@ public class SeckillApplyServiceImpl extends ServiceImpl<SeckillApplyMapper, Sec
|
||||
@Override
|
||||
public List<SeckillTimelineVO> getSeckillTimeline() {
|
||||
List<SeckillTimelineVO> timelineVoS = new ArrayList<>();
|
||||
// 秒杀活动缓存key
|
||||
//秒杀活动缓存key
|
||||
String seckillCacheKey = PromotionCacheKeys.getSeckillTimelineKey(DateUtil.format(DateUtil.beginOfDay(new DateTime()), "yyyyMMdd"));
|
||||
Map<Object, Object> cacheSeckill = cache.getHash(seckillCacheKey);
|
||||
if (cacheSeckill == null || cacheSeckill.isEmpty()) {
|
||||
// 如缓存中不存在,则单独获取
|
||||
//如缓存中不存在,则单独获取
|
||||
try {
|
||||
timelineVoS = getSeckillTimelineToCache(seckillCacheKey);
|
||||
} catch (Exception e) {
|
||||
log.error("获取秒杀活动信息发生错误!", e);
|
||||
}
|
||||
} else {
|
||||
// 如缓存中存在,则取缓存中转为展示的信息
|
||||
//如缓存中存在,则取缓存中转为展示的信息
|
||||
for (Object value : cacheSeckill.values()) {
|
||||
SeckillTimelineVO seckillTimelineVO = (SeckillTimelineVO) value;
|
||||
timelineVoS.add(seckillTimelineVO);
|
||||
@ -93,14 +93,14 @@ public class SeckillApplyServiceImpl extends ServiceImpl<SeckillApplyMapper, Sec
|
||||
@Override
|
||||
public List<SeckillGoodsVO> getSeckillGoods(Integer timeline) {
|
||||
List<SeckillGoodsVO> seckillGoodsVoS = new ArrayList<>();
|
||||
// 秒杀活动缓存key
|
||||
//秒杀活动缓存key
|
||||
String seckillCacheKey = PromotionCacheKeys.getSeckillTimelineKey(DateUtil.format(DateUtil.beginOfDay(new DateTime()), "yyyyMMdd"));
|
||||
Map<Object, Object> cacheSeckill = cache.getHash(seckillCacheKey);
|
||||
if (cacheSeckill == null || cacheSeckill.isEmpty()) {
|
||||
// 如缓存中不存在,则单独获取
|
||||
//如缓存中不存在,则单独获取
|
||||
seckillGoodsVoS = wrapperSeckillGoods(timeline);
|
||||
} else {
|
||||
// 如缓存中存在,则取缓存中转为展示的信息
|
||||
//如缓存中存在,则取缓存中转为展示的信息
|
||||
for (Map.Entry<Object, Object> entry : cacheSeckill.entrySet()) {
|
||||
Integer timelineKey = Integer.parseInt(entry.getKey().toString());
|
||||
if (timelineKey.equals(timeline)) {
|
||||
@ -147,7 +147,7 @@ public class SeckillApplyServiceImpl extends ServiceImpl<SeckillApplyMapper, Sec
|
||||
if (seckill == null) {
|
||||
throw new ServiceException("当前参与的秒杀活动不存在!");
|
||||
}
|
||||
// 检查秒杀活动申请是否合法
|
||||
//检查秒杀活动申请是否合法
|
||||
checkSeckillApplyList(seckill.getHours(), seckillApplyList, storeId);
|
||||
//获取已参与活动的秒杀活动活动申请列表
|
||||
List<SeckillApply> originList = seckill.getSeckillApplyList() != null ? seckill.getSeckillApplyList() : new ArrayList<>();
|
||||
@ -223,7 +223,7 @@ public class SeckillApplyServiceImpl extends ServiceImpl<SeckillApplyMapper, Sec
|
||||
if (seckillApply.getPrice() > seckillApply.getOriginalPrice()) {
|
||||
throw new ServiceException("活动价格不能大于商品原价");
|
||||
}
|
||||
// 检查秒杀活动申请的时刻,是否存在在秒杀活动的时间段内
|
||||
//检查秒杀活动申请的时刻,是否存在在秒杀活动的时间段内
|
||||
String[] rangeHours = hours.split(",");
|
||||
boolean containsSame = Arrays.stream(rangeHours).anyMatch(i -> i.equals(seckillApply.getTimeLine().toString()));
|
||||
if (!containsSame) {
|
||||
@ -290,7 +290,7 @@ public class SeckillApplyServiceImpl extends ServiceImpl<SeckillApplyMapper, Sec
|
||||
private List<SeckillTimelineVO> getSeckillTimelineToCache(String seckillCacheKey) {
|
||||
List<SeckillTimelineVO> timelineList = new ArrayList<>();
|
||||
LambdaQueryWrapper<Seckill> queryWrapper = new LambdaQueryWrapper<>();
|
||||
// 查询当天时间段内的且状态不为结束或关闭的秒杀活动活动
|
||||
//查询当天时间段内的且状态不为结束或关闭的秒杀活动活动
|
||||
queryWrapper.gt(Seckill::getStartTime, new Date(cn.lili.common.utils.DateUtil.startOfTodDay() * 1000)).lt(Seckill::getEndTime, cn.lili.common.utils.DateUtil.endOfDate())
|
||||
.and(i -> i.eq(Seckill::getPromotionStatus, PromotionStatusEnum.NEW.name())
|
||||
.or(j -> j.eq(Seckill::getPromotionStatus, PromotionStatusEnum.START.name())));
|
||||
@ -376,11 +376,11 @@ public class SeckillApplyServiceImpl extends ServiceImpl<SeckillApplyMapper, Sec
|
||||
if (goodsSku.getQuantity() < seckillApply.getQuantity()) {
|
||||
throw new ServiceException(seckillApply.getGoodsName() + ",此商品库存不足");
|
||||
}
|
||||
// 查询是否在同一时间段参与了拼团活动
|
||||
//查询是否在同一时间段参与了拼团活动
|
||||
if (promotionGoodsService.findInnerOverlapPromotionGoods(PromotionTypeEnum.PINTUAN.name(), goodsSku.getId(), startTime, seckill.getEndTime(), seckill.getId()) > 0) {
|
||||
throw new ServiceException("商品[" + goodsSku.getGoodsName() + "]已经在重叠的时间段参加了拼团活动,不能参加秒杀活动");
|
||||
}
|
||||
// 查询是否在同一时间段参与了秒杀活动活动
|
||||
//查询是否在同一时间段参与了秒杀活动活动
|
||||
if (promotionGoodsService.findInnerOverlapPromotionGoods(PromotionTypeEnum.SECKILL.name(), goodsSku.getId(), startTime, seckill.getEndTime(), seckill.getId()) > 0) {
|
||||
throw new ServiceException("商品[" + goodsSku.getGoodsName() + "]已经在重叠的时间段参加了秒杀活动,不能参加秒杀活动活动");
|
||||
}
|
||||
@ -399,7 +399,7 @@ public class SeckillApplyServiceImpl extends ServiceImpl<SeckillApplyMapper, Sec
|
||||
PromotionGoods promotionGoods = new PromotionGoods(goodsSku);
|
||||
promotionGoods.setPrice(seckillApply.getPrice());
|
||||
promotionGoods.setQuantity(seckillApply.getQuantity());
|
||||
// 设置单独每个促销商品的结束时间
|
||||
//设置单独每个促销商品的结束时间
|
||||
int nextHour = 23;
|
||||
String[] split = seckill.getHours().split(",");
|
||||
int[] hoursSored = Arrays.stream(split).mapToInt(Integer::parseInt).toArray();
|
||||
|
@ -123,11 +123,11 @@ public class SeckillServiceImpl extends ServiceImpl<SeckillMapper, Seckill> impl
|
||||
|
||||
SeckillVO seckillVO=new SeckillVO();
|
||||
BeanUtil.copyProperties(seckill,seckillVO);
|
||||
// 检查秒杀活动参数
|
||||
//检查秒杀活动参数
|
||||
checkSeckillParam(seckillVO, seckill.getStoreId());
|
||||
// 保存到MYSQL中
|
||||
//保存到MYSQL中
|
||||
boolean result = this.save(seckill);
|
||||
// 保存到MONGO中
|
||||
//保存到MONGO中
|
||||
this.mongoTemplate.save(seckillVO);
|
||||
//添加秒杀延时任务
|
||||
this.addSeckillStartTask(seckillVO);
|
||||
@ -150,21 +150,21 @@ public class SeckillServiceImpl extends ServiceImpl<SeckillMapper, Seckill> impl
|
||||
|
||||
@Override
|
||||
public boolean modifySeckill(SeckillVO seckillVO) {
|
||||
// 检查该秒杀活动是否存在
|
||||
//检查该秒杀活动是否存在
|
||||
SeckillVO seckill = checkSeckillExist(seckillVO.getId());
|
||||
if (PromotionStatusEnum.START.name().equals(seckillVO.getPromotionStatus())) {
|
||||
throw new ServiceException("活动已经开始,不能进行编辑删除操作");
|
||||
}
|
||||
// 检查秒杀活动参数
|
||||
//检查秒杀活动参数
|
||||
this.checkSeckillParam(seckillVO, seckillVO.getStoreId());
|
||||
|
||||
// 更新到MYSQL中
|
||||
//更新到MYSQL中
|
||||
boolean result = this.updateById(seckillVO);
|
||||
// 保存到MONGO中
|
||||
//保存到MONGO中
|
||||
this.mongoTemplate.save(seckillVO);
|
||||
if (seckill.getStartTime().getTime() != seckillVO.getStartTime().getTime()) {
|
||||
PromotionMessage promotionMessage = new PromotionMessage(seckillVO.getId(), PromotionTypeEnum.SECKILL.name(), PromotionStatusEnum.START.name(), seckillVO.getStartTime(), seckillVO.getEndTime());
|
||||
// 更新延时任务
|
||||
//更新延时任务
|
||||
this.timeTrigger.edit(TimeExecuteConstant.PROMOTION_EXECUTOR,
|
||||
promotionMessage,
|
||||
seckill.getStartTime().getTime(),
|
||||
@ -180,7 +180,7 @@ public class SeckillServiceImpl extends ServiceImpl<SeckillMapper, Seckill> impl
|
||||
public void deleteSeckill(String id) {
|
||||
Seckill seckill = checkSeckillExist(id);
|
||||
if (PromotionStatusEnum.CLOSE.name().equals(seckill.getPromotionStatus()) || PromotionStatusEnum.END.name().equals(seckill.getPromotionStatus())) {
|
||||
// 更新秒杀活动状态为关闭,标示删除标志
|
||||
//更新秒杀活动状态为关闭,标示删除标志
|
||||
LambdaUpdateWrapper<Seckill> updateWrapper = new LambdaUpdateWrapper<Seckill>().eq(Seckill::getId, id).set(Seckill::getDeleteFlag, true).set(Seckill::getPromotionStatus, PromotionStatusEnum.CLOSE.name());
|
||||
this.update(updateWrapper);
|
||||
LambdaUpdateWrapper<SeckillApply> seckillApplyLambdaUpdateWrapper = new LambdaUpdateWrapper<SeckillApply>().eq(SeckillApply::getSeckillId, id).set(SeckillApply::getDeleteFlag, true);
|
||||
@ -266,7 +266,7 @@ public class SeckillServiceImpl extends ServiceImpl<SeckillMapper, Seckill> impl
|
||||
promotionMessage,
|
||||
DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.PROMOTION, (promotionMessage.getPromotionType() + promotionMessage.getPromotionId())),
|
||||
rocketmqCustomProperties.getPromotionTopic());
|
||||
// 发送促销活动开始的延时任务
|
||||
//发送促销活动开始的延时任务
|
||||
this.timeTrigger.addDelay(timeTriggerMsg);
|
||||
}
|
||||
|
||||
@ -291,10 +291,10 @@ public class SeckillServiceImpl extends ServiceImpl<SeckillMapper, Seckill> impl
|
||||
* @param storeId 卖家编号
|
||||
*/
|
||||
private void checkSeckillParam(SeckillVO seckill, String storeId) {
|
||||
// 同一时间段内相同的活动
|
||||
//同一时间段内相同的活动
|
||||
QueryWrapper<Seckill> queryWrapper = PromotionTools.checkActiveTime(seckill.getStartTime(), seckill.getEndTime(), PromotionTypeEnum.SECKILL, storeId, seckill.getId());
|
||||
int sameNum = this.count(queryWrapper);
|
||||
// 当前时间段是否存在同类活动
|
||||
//当前时间段是否存在同类活动
|
||||
if (sameNum > 0) {
|
||||
throw new ServiceException("当前时间内已存在同类活动");
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class PromotionTools {
|
||||
|
||||
checkPromotionTime(startTime, endTime);
|
||||
|
||||
// 如果促销活动选择的是部分商品参加活动
|
||||
//如果促销活动选择的是部分商品参加活动
|
||||
if (num != -1 && goodsList == null) {
|
||||
throw new ServiceException("请选择要参与活动的商品");
|
||||
}
|
||||
@ -62,7 +62,7 @@ public class PromotionTools {
|
||||
throw new ServiceException("活动起始时间必须大于当前时间");
|
||||
}
|
||||
|
||||
// 开始时间不能大于结束时间
|
||||
//开始时间不能大于结束时间
|
||||
if (startTime > endTime) {
|
||||
throw new ServiceException("活动起始时间不能大于活动结束时间");
|
||||
}
|
||||
@ -85,13 +85,13 @@ public class PromotionTools {
|
||||
String endTimeColumn = "end_time";
|
||||
if (PromotionTypeEnum.SECKILL != typeEnum) {
|
||||
queryWrapper.nested(i -> {
|
||||
// 新活动起始时间 大于 之前活动的起始时间 小于 之前活动的截止时间
|
||||
//新活动起始时间 大于 之前活动的起始时间 小于 之前活动的截止时间
|
||||
i.nested(i2 -> i2.le(startTimeColumn, startTime).ge(endTimeColumn, startTime));
|
||||
// 新活动结束时间 大于 之前活动的起始时间 小于 之前活动的截止时间
|
||||
//新活动结束时间 大于 之前活动的起始时间 小于 之前活动的截止时间
|
||||
i.or(i1 -> i1.le(startTimeColumn, endTime).ge(endTimeColumn, endTime));
|
||||
});
|
||||
} else {
|
||||
// queryWrapper.le(startTimeColumn, startTime).ge(endTimeColumn, startTime);
|
||||
//queryWrapper.le(startTimeColumn, startTime).ge(endTimeColumn, startTime);
|
||||
queryWrapper.ge(startTimeColumn, cn.hutool.core.date.DateUtil.beginOfDay(startTime)).le(endTimeColumn, cn.hutool.core.date.DateUtil.endOfDay(endTime));
|
||||
}
|
||||
if (storeId != null) {
|
||||
@ -100,7 +100,7 @@ public class PromotionTools {
|
||||
if (activityId != null) {
|
||||
queryWrapper.ne("id", activityId);
|
||||
}
|
||||
// 忽略已作废和已关闭的活动
|
||||
//忽略已作废和已关闭的活动
|
||||
queryWrapper.ne("promotion_status", PromotionStatusEnum.END.name());
|
||||
queryWrapper.ne("promotion_status", PromotionStatusEnum.CLOSE.name());
|
||||
queryWrapper.eq("delete_flag", false);
|
||||
@ -115,7 +115,7 @@ public class PromotionTools {
|
||||
* @return 促销商品列表
|
||||
*/
|
||||
public static List<PromotionGoods> promotionGoodsInit(List<PromotionGoods> originList, BasePromotion promotion, PromotionTypeEnum promotionTypeEnum) {
|
||||
// 本次促销商品入库
|
||||
//本次促销商品入库
|
||||
for (PromotionGoods promotionGoods : originList) {
|
||||
promotionGoods.setPromotionId(promotion.getId());
|
||||
promotionGoods.setStoreName(promotion.getStoreName());
|
||||
|
@ -132,7 +132,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
@Override
|
||||
public void deleteIndex(EsGoodsIndex goods) {
|
||||
if (ObjectUtils.isEmpty(goods)) {
|
||||
// 如果对象为空,则删除全量
|
||||
//如果对象为空,则删除全量
|
||||
goodsIndexRepository.deleteAll();
|
||||
}
|
||||
goodsIndexRepository.delete(goods);
|
||||
@ -237,7 +237,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
if (goodsIndex != null) {
|
||||
Map<String, Object> promotionMap = goodsIndex.getPromotionMap();
|
||||
if (promotionMap != null && !promotionMap.isEmpty()) {
|
||||
// 如果存在同类型促销活动删除
|
||||
//如果存在同类型促销活动删除
|
||||
List<String> collect = promotionMap.keySet().parallelStream().filter(i -> i.contains(promotionType.name())).collect(Collectors.toList());
|
||||
collect.forEach(promotionMap::remove);
|
||||
goodsIndex.setPromotionMap(promotionMap);
|
||||
@ -276,7 +276,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
private void removePromotionByPromotionId(EsGoodsIndex goodsIndex, String promotionId) {
|
||||
Map<String, Object> promotionMap = goodsIndex.getPromotionMap();
|
||||
if (promotionMap != null && !promotionMap.isEmpty()) {
|
||||
// 如果存在同类型促销活动删除
|
||||
//如果存在同类型促销活动删除
|
||||
List<String> collect = promotionMap.keySet().stream().filter(i -> i.split("-")[1].equals(promotionId)).collect(Collectors.toList());
|
||||
collect.forEach(promotionMap::remove);
|
||||
goodsIndex.setPromotionMap(promotionMap);
|
||||
@ -327,7 +327,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
public Map<String, Object> getPromotionMap(String id) {
|
||||
EsGoodsIndex goodsIndex = this.findById(id);
|
||||
|
||||
// 如果商品索引不为空,返回促销信息,否则返回空
|
||||
//如果商品索引不为空,返回促销信息,否则返回空
|
||||
if (goodsIndex != null) {
|
||||
Map<String, Object> promotionMap = goodsIndex.getPromotionMap();
|
||||
if (promotionMap == null || promotionMap.isEmpty()) {
|
||||
@ -406,7 +406,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
this.removePromotionKey(key, promotionMap, PromotionTypeEnum.SECKILL.name());
|
||||
}
|
||||
} else {
|
||||
// 添加促销活动前,如果是同一时间只可以有一个的活动,但商品索引的促销活动里存在其他(同一时间只可以有一个)的活动,则清除
|
||||
//添加促销活动前,如果是同一时间只可以有一个的活动,但商品索引的促销活动里存在其他(同一时间只可以有一个)的活动,则清除
|
||||
this.removePromotionKey(key, promotionMap, PromotionTypeEnum.PINTUAN.name(), PromotionTypeEnum.SECKILL.name(), PromotionTypeEnum.FULL_DISCOUNT.name());
|
||||
promotionMap.put(key, promotion);
|
||||
}
|
||||
@ -448,7 +448,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
*/
|
||||
private void wordsToDb(String words) {
|
||||
try {
|
||||
// 是否有重复
|
||||
//是否有重复
|
||||
GoodsWords entity = goodsWordsService.getOne(new LambdaQueryWrapper<GoodsWords>().eq(GoodsWords::getWords, words));
|
||||
if (entity == null) {
|
||||
GoodsWords goodsWords = new GoodsWords();
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user