Commit b3488624 by wuwenlong

下单防并发优化;

parent 681840e2
...@@ -24,6 +24,8 @@ public class Constants ...@@ -24,6 +24,8 @@ public class Constants
public static final String CONFIG_KEY_API_URL = "https://www.coujio.com"; //admin接口地址 public static final String CONFIG_KEY_API_URL = "https://www.coujio.com"; //admin接口地址
// 订单取消Key // 订单取消Key
public static final String ORDER_AUTO_CANCEL_KEY = "order_auto_cancel_key"; public static final String ORDER_AUTO_CANCEL_KEY = "order_auto_cancel_key";
// 订单锁定Key
public static final String ORDER_LOCK_KEY = "order_lock_key";
//测试环境,经测试需要,手机验证码测试环境可以不需要就能登录,value为1,则不验证验证码 //测试环境,经测试需要,手机验证码测试环境可以不需要就能登录,value为1,则不验证验证码
public static final String PHONE_TEST_KEY = "phone_test_key"; public static final String PHONE_TEST_KEY = "phone_test_key";
//通过uuid缓存的key 查找对应的 token数据 WX_TOKEN_USER:TOKEN //通过uuid缓存的key 查找对应的 token数据 WX_TOKEN_USER:TOKEN
......
...@@ -127,12 +127,10 @@ public class OrderTask { ...@@ -127,12 +127,10 @@ public class OrderTask {
String cancelStr; String cancelStr;
DateTime cancelTime; DateTime cancelTime;
cancelStr = sysConfigService.selectConfigByKey("order_cancel_time"); cancelStr = sysConfigService.selectConfigByKey("order_cancel_time");
if (StrUtil.isBlank(cancelStr)) { if (StrUtil.isBlank(cancelStr)) {
cancelStr = "1"; cancelStr = "5";
} }
cancelTime = cn.hutool.core.date.DateUtil.offset(sOrder.getCreateTime(), DateField.HOUR_OF_DAY, Integer.parseInt(cancelStr)); cancelTime = cn.hutool.core.date.DateUtil.offset(sOrder.getCreateTime(), DateField.MINUTE, Integer.parseInt(cancelStr));
long between = cn.hutool.core.date.DateUtil.between(cancelTime, cn.hutool.core.date.DateUtil.date(), DateUnit.SECOND, false); long between = cn.hutool.core.date.DateUtil.between(cancelTime, cn.hutool.core.date.DateUtil.date(), DateUnit.SECOND, false);
if (between < 0) {// 未到过期时间继续循环 if (between < 0) {// 未到过期时间继续循环
return Boolean.FALSE; return Boolean.FALSE;
...@@ -147,6 +145,7 @@ public class OrderTask { ...@@ -147,6 +145,7 @@ public class OrderTask {
couponUser.setUseStatus(CouponStatusEnum.NORMAL.getValue()); couponUser.setUseStatus(CouponStatusEnum.NORMAL.getValue());
consumerCouponService.updateById(couponUser); consumerCouponService.updateById(couponUser);
} }
logger.info(String.format("删除订单,订单号【%s】",sOrder.getOrderNo()));
return Boolean.TRUE; return Boolean.TRUE;
}); });
return execute; return execute;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment