同步
This commit is contained in:
@@ -232,4 +232,35 @@ public interface Cache<T> {
|
||||
* @return
|
||||
*/
|
||||
Set<ZSetOperations.TypedTuple<Object>> reverseRangeWithScores(String sortedSetName, Integer start, Integer end);
|
||||
|
||||
|
||||
/**
|
||||
* 向Zset里添加成员
|
||||
*
|
||||
* @param key key值
|
||||
* @param score 分数
|
||||
* @param value 值
|
||||
* @return 增加状态
|
||||
*/
|
||||
boolean zAdd(String key, long score, String value);
|
||||
|
||||
|
||||
/**
|
||||
* 获取 某key 下 某一分值区间的队列
|
||||
*
|
||||
* @param key 缓存key
|
||||
* @param from 开始时间
|
||||
* @param to 结束时间
|
||||
* @return 数据
|
||||
*/
|
||||
Set<ZSetOperations.TypedTuple<Object>> zRangeByScore(String key, int from, long to);
|
||||
|
||||
/**
|
||||
* 移除 Zset队列值
|
||||
*
|
||||
* @param key key值
|
||||
* @param value 删除的集合
|
||||
* @return 删除数量
|
||||
*/
|
||||
Long zRemove(String key, String... value);
|
||||
}
|
||||
|
||||
@@ -242,4 +242,47 @@ public class RedisCache implements Cache {
|
||||
public Set<ZSetOperations.TypedTuple<Object>> reverseRangeWithScores(String sortedSetName, Integer start, Integer end) {
|
||||
return this.redisTemplate.opsForZSet().reverseRangeWithScores(sortedSetName, start, end);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 向Zset里添加成员
|
||||
*
|
||||
* @param key key值
|
||||
* @param score 分数,通常用于排序
|
||||
* @param value 值
|
||||
* @return 增加状态
|
||||
*/
|
||||
@Override
|
||||
public boolean zAdd(String key, long score, String value) {
|
||||
Boolean result = redisTemplate.opsForZSet().add(key, value, score);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取 某key 下 某一分值区间的队列
|
||||
*
|
||||
* @param key 缓存key
|
||||
* @param from 开始时间
|
||||
* @param to 结束时间
|
||||
* @return 数据
|
||||
*/
|
||||
@Override
|
||||
public Set<ZSetOperations.TypedTuple<Object>> zRangeByScore(String key, int from, long to) {
|
||||
Set<ZSetOperations.TypedTuple<Object>> set = redisTemplate.opsForZSet().rangeByScoreWithScores(key, from, to);
|
||||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除 Zset队列值
|
||||
*
|
||||
* @param key key值
|
||||
* @param value 删除的集合
|
||||
* @return 删除数量
|
||||
*/
|
||||
@Override
|
||||
public Long zRemove(String key, String... value) {
|
||||
return redisTemplate.opsForZSet().remove(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,6 +143,7 @@ public enum ResultCode {
|
||||
/**
|
||||
* 支付
|
||||
*/
|
||||
PAY_UN_WANTED(32000, "当前订单不需要付款,返回订单列表等待系统订单出库即可"),
|
||||
PAY_SUCCESS(32001, "支付成功"),
|
||||
PAY_INCONSISTENT_ERROR(32002, "付款金额和应付金额不一致"),
|
||||
PAY_DOUBLE_ERROR(32003, "订单已支付,不能再次进行支付"),
|
||||
|
||||
@@ -6,7 +6,7 @@ import javax.servlet.http.HttpServletRequestWrapper;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 防止Xss sql注入
|
||||
* 防止Xss
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
@@ -93,8 +93,8 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
private String cleanXSS(String value) {
|
||||
if (value != null) {
|
||||
//推荐使用ESAPI库来避免脚本攻击,value = ESAPI.encoder().canonicalize(value);
|
||||
// 避免空字符串
|
||||
value = value.replaceAll(" ", "");
|
||||
// // 避免空字符串
|
||||
// value = value.replaceAll(" ", "");
|
||||
// 避免script 标签
|
||||
Pattern scriptPattern = Pattern.compile("<script>(.*?)</script>", Pattern.CASE_INSENSITIVE);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
|
||||
@@ -10,6 +10,7 @@ import cn.lili.common.sms.AliSmsUtil;
|
||||
import cn.lili.common.sms.SmsUtil;
|
||||
import cn.lili.common.utils.CommonUtil;
|
||||
import cn.lili.common.verification.enums.VerificationEnums;
|
||||
import cn.lili.config.properties.SmsTemplateSetting;
|
||||
import cn.lili.modules.connect.util.Base64Utils;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.member.service.MemberService;
|
||||
@@ -51,6 +52,9 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil {
|
||||
@Autowired
|
||||
private MemberService memberService;
|
||||
|
||||
@Autowired
|
||||
private SmsTemplateSetting smsTemplateSetting;
|
||||
|
||||
@Override
|
||||
public void sendSmsCode(String mobile, VerificationEnums verificationEnums, String uuid) {
|
||||
//获取短信配置
|
||||
@@ -75,17 +79,17 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil {
|
||||
switch (verificationEnums) {
|
||||
//登录
|
||||
case LOGIN: {
|
||||
templateCode = "SMS_205755300";
|
||||
templateCode = smsTemplateSetting.getLOGIN();
|
||||
break;
|
||||
}
|
||||
//注册
|
||||
case REGISTER: {
|
||||
templateCode = "SMS_205755298";
|
||||
templateCode = smsTemplateSetting.getREGISTER();
|
||||
break;
|
||||
}
|
||||
//找回密码
|
||||
case FIND_USER: {
|
||||
templateCode = "SMS_205755301";
|
||||
templateCode = smsTemplateSetting.getFIND_USER();
|
||||
break;
|
||||
}
|
||||
//修改密码
|
||||
@@ -96,7 +100,15 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil {
|
||||
}
|
||||
//更新为用户最新手机号
|
||||
mobile = member.getMobile();
|
||||
templateCode = "SMS_205755297";
|
||||
templateCode = smsTemplateSetting.getUPDATE_PASSWORD();
|
||||
break;
|
||||
}
|
||||
//设置支付密码
|
||||
case WALLET_PASSWORD: {
|
||||
Member member = memberService.getById(UserContext.getCurrentUser().getId());
|
||||
//更新为用户最新手机号
|
||||
mobile = member.getMobile();
|
||||
templateCode = smsTemplateSetting.getWALLET_PASSWORD();
|
||||
break;
|
||||
}
|
||||
//如果不是有效的验证码手段,则此处不进行短信操作
|
||||
|
||||
@@ -17,6 +17,8 @@ import org.springframework.messaging.support.MessageBuilder;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 延时任务实现
|
||||
*
|
||||
* @author paulG
|
||||
* @since 2020/11/5
|
||||
**/
|
||||
@@ -32,8 +34,23 @@ public class RocketmqTimerTrigger implements TimeTrigger {
|
||||
|
||||
|
||||
@Override
|
||||
public void add(String executorName, Object param, Long triggerTime, String uniqueKey, String topic) {
|
||||
public void add(TimeTriggerMsg timeTriggerMsg) {
|
||||
this.addExecute(timeTriggerMsg.getTriggerExecutor(), timeTriggerMsg.getParam(), timeTriggerMsg.getTriggerTime(), timeTriggerMsg.getUniqueKey(), timeTriggerMsg.getTopic());
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加延时任务
|
||||
*
|
||||
* @param executorName 执行器beanId
|
||||
* @param param 执行参数
|
||||
* @param triggerTime 执行时间 时间戳 秒为单位
|
||||
* @param uniqueKey 如果是一个 需要有 修改/取消 延时任务功能的延时任务,<br/>
|
||||
* 请填写此参数,作为后续删除,修改做为唯一凭证 <br/>
|
||||
* 建议参数为:COUPON_{ACTIVITY_ID} 例如 coupon_123<br/>
|
||||
* 业务内全局唯一
|
||||
* @param topic rocketmq topic
|
||||
*/
|
||||
public void addExecute(String executorName, Object param, Long triggerTime, String uniqueKey, String topic) {
|
||||
|
||||
TimeTriggerMsg timeTriggerMsg = new TimeTriggerMsg(executorName, triggerTime, param, uniqueKey, topic);
|
||||
Message<TimeTriggerMsg> message = MessageBuilder.withPayload(timeTriggerMsg).build();
|
||||
@@ -41,13 +58,9 @@ public class RocketmqTimerTrigger implements TimeTrigger {
|
||||
this.rocketMQTemplate.asyncSend(topic, message, RocketmqSendCallbackBuilder.commonCallback());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(TimeTriggerMsg timeTriggerMsg) {
|
||||
this.add(timeTriggerMsg.getTriggerExecutor(), timeTriggerMsg.getParam(), timeTriggerMsg.getTriggerTime(), timeTriggerMsg.getUniqueKey(), timeTriggerMsg.getTopic());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDelay(TimeTriggerMsg timeTriggerMsg, int delayTime) {
|
||||
//执行器唯一key
|
||||
String uniqueKey = timeTriggerMsg.getUniqueKey();
|
||||
if (StringUtils.isEmpty(uniqueKey)) {
|
||||
uniqueKey = StringUtils.getRandStr(10);
|
||||
@@ -56,7 +69,7 @@ public class RocketmqTimerTrigger implements TimeTrigger {
|
||||
String generateKey = TimeTriggerUtil.generateKey(timeTriggerMsg.getTriggerExecutor(), timeTriggerMsg.getTriggerTime(), uniqueKey);
|
||||
this.cache.put(generateKey, 1);
|
||||
//设置延时任务
|
||||
if (Boolean.TRUE.equals(promotionDelayQueue.addJobId(JSONUtil.toJsonStr(timeTriggerMsg), delayTime))) {
|
||||
if (Boolean.TRUE.equals(promotionDelayQueue.addJob(JSONUtil.toJsonStr(timeTriggerMsg), delayTime))) {
|
||||
log.info("add Redis key {}", generateKey);
|
||||
log.info("定时执行在【" + DateUtil.toString(timeTriggerMsg.getTriggerTime(), "yyyy-MM-dd HH:mm:ss") + "】,消费【" + timeTriggerMsg.getParam().toString() + "】");
|
||||
} else {
|
||||
@@ -73,7 +86,7 @@ public class RocketmqTimerTrigger implements TimeTrigger {
|
||||
@Override
|
||||
public void delete(String executorName, Long triggerTime, String uniqueKey, String topic) {
|
||||
String generateKey = TimeTriggerUtil.generateKey(executorName, triggerTime, uniqueKey);
|
||||
log.info("delete redis key {} -----------------------", generateKey);
|
||||
log.info("删除延时任务{}", generateKey);
|
||||
this.cache.remove(generateKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cn.lili.common.delayqueue;
|
||||
package cn.lili.common.trigger.delay;
|
||||
|
||||
import cn.lili.common.utils.RedisUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.common.cache.Cache;
|
||||
import cn.lili.common.utils.ThreadPoolUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -22,7 +23,7 @@ import java.util.concurrent.TimeUnit;
|
||||
public abstract class AbstractDelayQueueMachineFactory {
|
||||
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
private Cache cache;
|
||||
|
||||
/**
|
||||
* 插入任务id
|
||||
@@ -31,12 +32,14 @@ public abstract class AbstractDelayQueueMachineFactory {
|
||||
* @param time 延时时间(单位 :秒)
|
||||
* @return 是否插入成功
|
||||
*/
|
||||
public boolean addJobId(String jobId, Integer time) {
|
||||
public boolean addJob(String jobId, Integer time) {
|
||||
//获取时间
|
||||
Calendar instance = Calendar.getInstance();
|
||||
instance.add(Calendar.SECOND, time);
|
||||
long delaySeconds = instance.getTimeInMillis() / 1000;
|
||||
boolean result = redisUtil.zadd(setDelayQueueName(), delaySeconds, jobId);
|
||||
log.info("redis add delay, key {}, delay time {}", setDelayQueueName(), time);
|
||||
//增加延时任务 参数依次为:队列名称、执行时间、任务id
|
||||
boolean result = cache.zAdd(setDelayQueueName(), delaySeconds, jobId);
|
||||
log.info("增加延时任务, 缓存key {}, 等待时间 {}", setDelayQueueName(), time);
|
||||
return result;
|
||||
|
||||
}
|
||||
@@ -45,21 +48,24 @@ public abstract class AbstractDelayQueueMachineFactory {
|
||||
* 延时队列机器开始运作
|
||||
*/
|
||||
private void startDelayQueueMachine() {
|
||||
log.info(String.format("延时队列机器{%s}开始运作", setDelayQueueName()));
|
||||
log.info("延时队列机器{}开始运作", setDelayQueueName());
|
||||
|
||||
// 发生异常捕获并且继续不能让战斗停下来
|
||||
// 监听redis队列
|
||||
while (true) {
|
||||
try {
|
||||
// 获取当前时间的时间戳
|
||||
long now = System.currentTimeMillis() / 1000;
|
||||
// 获取当前时间前的任务列表
|
||||
Set<DefaultTypedTuple> tuples = redisUtil.zrangeByScoreWithScores(setDelayQueueName(), 0, now);
|
||||
// 如果不为空则遍历判断其是否满足取消要求
|
||||
if (!CollectionUtils.isEmpty(tuples)) {
|
||||
for (DefaultTypedTuple tuple : tuples) {
|
||||
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 = redisUtil.zremove(setDelayQueueName(), jobId);
|
||||
// 移除缓存,如果移除成功则表示当前线程处理了延时任务,则执行延时任务
|
||||
Long num = cache.zRemove(setDelayQueueName(), jobId);
|
||||
// 如果移除成功, 则执行
|
||||
if (num > 0) {
|
||||
ThreadPoolUtil.execute(() -> invoke(jobId));
|
||||
@@ -68,7 +74,7 @@ public abstract class AbstractDelayQueueMachineFactory {
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error(String.format("处理延时任务发生异常,异常原因为{%s}", e.getMessage()), e);
|
||||
log.error("处理延时任务发生异常,异常原因为{}", e.getMessage(), e);
|
||||
} finally {
|
||||
// 间隔一秒钟搞一次
|
||||
try {
|
||||
@@ -1,7 +1,6 @@
|
||||
package cn.lili.common.trigger.delay;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.common.delayqueue.AbstractDelayQueueMachineFactory;
|
||||
import cn.lili.common.trigger.interfaces.TimeTrigger;
|
||||
import cn.lili.common.trigger.model.TimeTriggerMsg;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.common.delayqueue;
|
||||
package cn.lili.common.trigger.enums;
|
||||
|
||||
/**
|
||||
* 延时任务类型
|
||||
@@ -9,19 +9,6 @@ import cn.lili.common.trigger.model.TimeTriggerMsg;
|
||||
*/
|
||||
public interface TimeTrigger {
|
||||
|
||||
/**
|
||||
* 添加延时任务
|
||||
*
|
||||
* @param executorName 执行器beanId
|
||||
* @param param 执行参数
|
||||
* @param triggerTime 执行时间 时间戳 秒为单位
|
||||
* @param uniqueKey 如果是一个 需要有 修改/取消 延时任务功能的延时任务,<br/>
|
||||
* 请填写此参数,作为后续删除,修改做为唯一凭证 <br/>
|
||||
* 建议参数为:COUPON_{ACTIVITY_ID} 例如 coupon_123<br/>
|
||||
* 业务内全局唯一
|
||||
* @param topic rocketmq topic
|
||||
*/
|
||||
void add(String executorName, Object param, Long triggerTime, String uniqueKey, String topic);
|
||||
|
||||
/**
|
||||
* 添加延时任务
|
||||
|
||||
@@ -2,14 +2,15 @@ package cn.lili.common.trigger.interfaces;
|
||||
|
||||
/**
|
||||
* 延时任务执行器接口
|
||||
* @author Chopper
|
||||
*
|
||||
* @author Chopper
|
||||
*/
|
||||
public interface TimeTriggerExecutor {
|
||||
|
||||
|
||||
/**
|
||||
* 执行任务
|
||||
*
|
||||
* @param object 任务参数
|
||||
*/
|
||||
void execute(Object object);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.common.delayqueue;
|
||||
package cn.lili.common.trigger.message;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.common.delayqueue;
|
||||
package cn.lili.common.trigger.message;
|
||||
|
||||
import cn.lili.modules.promotion.entity.enums.PromotionStatusEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
@@ -1,6 +1,8 @@
|
||||
package cn.lili.common.trigger.model;
|
||||
|
||||
/**
|
||||
* 延时任务执行器常量
|
||||
*
|
||||
* @author paulG
|
||||
* @since 2020/8/20
|
||||
**/
|
||||
@@ -16,14 +18,4 @@ public abstract class TimeExecuteConstant {
|
||||
*/
|
||||
public static final String BROADCAST_EXECUTOR = "broadcastTimeTriggerExecutor";
|
||||
|
||||
/**
|
||||
* 拼团延迟加载执行器
|
||||
*/
|
||||
public static final String PINTUAN_EXECUTOR = "pintuanTimeTriggerExecutor";
|
||||
|
||||
/**
|
||||
* 拼团延迟加载执行器
|
||||
*/
|
||||
public static final String FULL_DISCOUNT_EXECUTOR = "fullDiscountTimeTriggerExecutor";
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
package cn.lili.common.delayqueue;
|
||||
package cn.lili.common.trigger.util;
|
||||
|
||||
import cn.lili.common.trigger.enums.DelayQueueType;
|
||||
|
||||
/**
|
||||
* 延时任务工具类
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.lili.config.properties;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 短信模版设置
|
||||
*
|
||||
* @author Chopper
|
||||
*/
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "lili.sms")
|
||||
public class SmsTemplateSetting {
|
||||
//登录
|
||||
private String LOGIN = "SMS_205755300";
|
||||
//注册
|
||||
private String REGISTER = "SMS_205755298";
|
||||
//找回密码
|
||||
private String FIND_USER = "SMS_205755301";
|
||||
//设置密码
|
||||
private String UPDATE_PASSWORD = "SMS_205755297";
|
||||
//设置支付密码
|
||||
private String WALLET_PASSWORD = "SMS_205755297";
|
||||
}
|
||||
@@ -2,14 +2,14 @@ package cn.lili.modules.broadcast.serviceimpl;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.common.delayqueue.BroadcastMessage;
|
||||
import cn.lili.common.delayqueue.DelayQueueTools;
|
||||
import cn.lili.common.delayqueue.DelayQueueType;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.trigger.enums.DelayQueueType;
|
||||
import cn.lili.common.trigger.interfaces.TimeTrigger;
|
||||
import cn.lili.common.trigger.model.TimeExecuteConstant;
|
||||
import cn.lili.common.trigger.model.TimeTriggerMsg;
|
||||
import cn.lili.common.trigger.util.DelayQueueTools;
|
||||
import cn.lili.common.utils.BeanUtil;
|
||||
import cn.lili.common.utils.DateUtil;
|
||||
import cn.lili.common.utils.PageUtil;
|
||||
|
||||
@@ -216,8 +216,8 @@ public class Order extends BaseEntity {
|
||||
} else {
|
||||
this.setOrderType(tradeDTO.getCartTypeEnum().name());
|
||||
}
|
||||
//设定订单默认状态
|
||||
this.setId(orderId);
|
||||
|
||||
//设置默认支付状态
|
||||
this.setOrderStatus(OrderStatusEnum.UNPAID.name());
|
||||
this.setPayStatus(PayStatusEnum.UNPAID.name());
|
||||
this.setDeliverStatus(DeliverStatusEnum.UNDELIVERED.name());
|
||||
|
||||
@@ -4,26 +4,22 @@ import cn.lili.base.BaseEntity;
|
||||
import cn.lili.modules.base.entity.enums.ClientTypeEnum;
|
||||
import cn.lili.modules.order.order.entity.enums.OrderTypeEnum;
|
||||
import cn.lili.modules.order.order.entity.enums.PayStatusEnum;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 订单
|
||||
* 订单支付日志:实际为订单部分字段提取过来的一个vo
|
||||
*
|
||||
* @author Chopper
|
||||
* @date 2020/11/17 7:30 下午
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "li_order")
|
||||
@TableName("li_order")
|
||||
@ApiModel(value = "订单")
|
||||
public class PaymentLog extends BaseEntity {
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ import cn.hutool.json.JSONUtil;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import cn.hutool.poi.excel.ExcelWriter;
|
||||
import cn.lili.common.aop.syslog.annotation.SystemLogPoint;
|
||||
import cn.lili.common.delayqueue.DelayQueueTools;
|
||||
import cn.lili.common.delayqueue.DelayQueueType;
|
||||
import cn.lili.common.delayqueue.PintuanOrderMessage;
|
||||
import cn.lili.common.trigger.util.DelayQueueTools;
|
||||
import cn.lili.common.trigger.enums.DelayQueueType;
|
||||
import cn.lili.common.trigger.message.PintuanOrderMessage;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.rocketmq.RocketmqSendCallbackBuilder;
|
||||
|
||||
@@ -145,20 +145,32 @@ public class CashierSupport {
|
||||
public CashierParam cashierParam(PayParam payParam) {
|
||||
for (CashierExecute paramInterface : cashierExecuteList) {
|
||||
CashierParam cashierParam = paramInterface.getPaymentParams(payParam);
|
||||
if (cashierParam != null) {
|
||||
cashierParam.setSupport(support(payParam.getClientType()));
|
||||
cashierParam.setWalletValue(memberWalletService.getMemberWallet(UserContext.getCurrentUser().getId()).getMemberWallet());
|
||||
OrderSetting orderSetting = JSONUtil.toBean(settingService.get(SettingEnum.ORDER_SETTING.name()).getSettingValue(), OrderSetting.class);
|
||||
Integer minute = orderSetting.getAutoCancel();
|
||||
cashierParam.setAutoCancel(cashierParam.getCreateTime().getTime() + minute * 1000 * 60);
|
||||
return cashierParam;
|
||||
//如果为空,则表示收银台参数初始化不匹配,继续匹配下一条
|
||||
if (cashierParam == null) {
|
||||
continue;
|
||||
}
|
||||
//如果订单不需要付款,则抛出异常,直接返回
|
||||
if (cashierParam.getPrice() <= 0) {
|
||||
throw new ServiceException(ResultCode.PAY_UN_WANTED);
|
||||
}
|
||||
cashierParam.setSupport(support(payParam.getClientType()));
|
||||
cashierParam.setWalletValue(memberWalletService.getMemberWallet(UserContext.getCurrentUser().getId()).getMemberWallet());
|
||||
OrderSetting orderSetting = JSONUtil.toBean(settingService.get(SettingEnum.ORDER_SETTING.name()).getSettingValue(), OrderSetting.class);
|
||||
Integer minute = orderSetting.getAutoCancel();
|
||||
cashierParam.setAutoCancel(cashierParam.getCreateTime().getTime() + minute * 1000 * 60);
|
||||
return cashierParam;
|
||||
}
|
||||
|
||||
log.error("错误的支付请求:{}", payParam.toString());
|
||||
throw new ServiceException(ResultCode.PAY_CASHIER_ERROR);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 支付结果
|
||||
*
|
||||
* @param payParam
|
||||
* @return
|
||||
*/
|
||||
public Boolean paymentResult(PayParam payParam) {
|
||||
for (CashierExecute cashierExecute : cashierExecuteList) {
|
||||
if (cashierExecute.cashierEnum().name().equals(payParam.getOrderType())) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.lili.modules.promotion.service;
|
||||
|
||||
import cn.lili.common.delayqueue.PromotionMessage;
|
||||
import cn.lili.common.trigger.message.PromotionMessage;
|
||||
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package cn.lili.modules.promotion.serviceimpl;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.delayqueue.DelayQueueTools;
|
||||
import cn.lili.common.delayqueue.DelayQueueType;
|
||||
import cn.lili.common.delayqueue.PromotionMessage;
|
||||
import cn.lili.common.trigger.util.DelayQueueTools;
|
||||
import cn.lili.common.trigger.enums.DelayQueueType;
|
||||
import cn.lili.common.trigger.message.PromotionMessage;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.trigger.interfaces.TimeTrigger;
|
||||
import cn.lili.common.trigger.model.TimeExecuteConstant;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package cn.lili.modules.promotion.serviceimpl;
|
||||
|
||||
import cn.lili.common.delayqueue.DelayQueueTools;
|
||||
import cn.lili.common.delayqueue.DelayQueueType;
|
||||
import cn.lili.common.delayqueue.PromotionMessage;
|
||||
import cn.lili.common.trigger.util.DelayQueueTools;
|
||||
import cn.lili.common.trigger.enums.DelayQueueType;
|
||||
import cn.lili.common.trigger.message.PromotionMessage;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.trigger.interfaces.TimeTrigger;
|
||||
import cn.lili.common.trigger.model.TimeExecuteConstant;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package cn.lili.modules.promotion.serviceimpl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.lili.common.delayqueue.DelayQueueTools;
|
||||
import cn.lili.common.delayqueue.DelayQueueType;
|
||||
import cn.lili.common.delayqueue.PromotionMessage;
|
||||
import cn.lili.common.trigger.util.DelayQueueTools;
|
||||
import cn.lili.common.trigger.enums.DelayQueueType;
|
||||
import cn.lili.common.trigger.message.PromotionMessage;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.trigger.interfaces.TimeTrigger;
|
||||
import cn.lili.common.trigger.model.TimeExecuteConstant;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package cn.lili.modules.promotion.serviceimpl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.lili.common.delayqueue.DelayQueueTools;
|
||||
import cn.lili.common.delayqueue.DelayQueueType;
|
||||
import cn.lili.common.delayqueue.PromotionMessage;
|
||||
import cn.lili.common.trigger.util.DelayQueueTools;
|
||||
import cn.lili.common.trigger.enums.DelayQueueType;
|
||||
import cn.lili.common.trigger.message.PromotionMessage;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.trigger.interfaces.TimeTrigger;
|
||||
import cn.lili.common.trigger.model.TimeExecuteConstant;
|
||||
|
||||
@@ -3,7 +3,7 @@ package cn.lili.modules.promotion.serviceimpl;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.common.delayqueue.PromotionMessage;
|
||||
import cn.lili.common.trigger.message.PromotionMessage;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.utils.DateUtil;
|
||||
import cn.lili.modules.order.cart.entity.vo.FullDiscountVO;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package cn.lili.modules.promotion.serviceimpl;
|
||||
|
||||
import cn.lili.common.delayqueue.DelayQueueTools;
|
||||
import cn.lili.common.delayqueue.DelayQueueType;
|
||||
import cn.lili.common.delayqueue.PromotionMessage;
|
||||
import cn.lili.common.trigger.util.DelayQueueTools;
|
||||
import cn.lili.common.trigger.enums.DelayQueueType;
|
||||
import cn.lili.common.trigger.message.PromotionMessage;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.trigger.interfaces.TimeTrigger;
|
||||
import cn.lili.common.trigger.model.TimeExecuteConstant;
|
||||
|
||||
@@ -153,10 +153,16 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
//索引名称拼接
|
||||
String indexName = elasticsearchProperties.getIndexPrefix() + "_" + EsSuffix.GOODS_INDEX_NAME;
|
||||
|
||||
//如果索引不存在,则创建索引
|
||||
if (!indexExist(indexName)) {
|
||||
createIndexRequest(indexName);
|
||||
//索引初始化,因为mapping结构问题:
|
||||
//但是如果索引已经自动生成过,这里就不会创建索引,设置mapping,所以这里决定在初始化索引的同时,将已有索引删除,重新创建
|
||||
|
||||
//如果索引存在,则删除,重新生成。 这里应该有更优解。
|
||||
if (this.indexExist(indexName)) {
|
||||
deleteIndexRequest(indexName);
|
||||
}
|
||||
|
||||
//如果索引不存在,则创建索引
|
||||
createIndexRequest(indexName);
|
||||
if (goodsIndexList != null && !goodsIndexList.isEmpty()) {
|
||||
goodsIndexRepository.deleteAll();
|
||||
for (EsGoodsIndex goodsIndex : goodsIndexList) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 短信配置
|
||||
*
|
||||
* 这里在前台不做调整,方便客户直接把服务商的内容配置在我们平台
|
||||
* @author Chopper
|
||||
* @date 2020/11/30 15:23
|
||||
*/
|
||||
@@ -17,7 +17,7 @@ public class SmsSetting implements Serializable {
|
||||
* 节点地址
|
||||
* key
|
||||
* 密钥
|
||||
* 签名,这里在前台不做调整,方便客户直接把服务商的内容配置在我们平台
|
||||
* 签名
|
||||
*/
|
||||
private String regionId;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public class AppVersionServiceImpl extends ServiceImpl<AppVersionMapper, AppVers
|
||||
@Override
|
||||
public boolean checkAppVersion(AppVersion appVersion) {
|
||||
//检测版本是否存在
|
||||
if(null!=this.getOne(new LambdaQueryWrapper<AppVersion>().eq(AppVersion::getVersion,appVersion))){
|
||||
if(null!=this.getOne(new LambdaQueryWrapper<AppVersion>().eq(AppVersion::getVersion,appVersion.getVersion()))){
|
||||
throw new ServiceException(ResultCode.APP_VERSION_EXIST);
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user