记得上下班打卡 | git大法好,push需谨慎

Commit 863b85f0 authored by jiangxiulong's avatar jiangxiulong

用户申请退款增加锁 防止重复请求

parent 7269696b
package com.liquidnet.service.kylin.constant; package com.liquidnet.service.kylin.constant;
import rx.Completable;
public class KylinRedisConst { public class KylinRedisConst {
public static final String FIELDS = "kylin:fields:id"; public static final String FIELDS = "kylin:fields:id";
public static final String PERFORMANCES = "kylin:performances:id:"; public static final String PERFORMANCES = "kylin:performances:id:";
...@@ -37,6 +39,7 @@ public class KylinRedisConst { ...@@ -37,6 +39,7 @@ public class KylinRedisConst {
// 手续费 // 手续费
public static final String ORDER_REFUND_POUNDAGE = "kylin:order:poundage"; public static final String ORDER_REFUND_POUNDAGE = "kylin:order:poundage";
public static final String ORDER_REFUND_POUNDAGE_EXPLAIN = "kylin:order:poundageExplain"; public static final String ORDER_REFUND_POUNDAGE_EXPLAIN = "kylin:order:poundageExplain";
public static final String REDIS_KEY_KYLIN_REFUND_LOCK = "kylin:order:refund:lock:entitiesId:";
public static final String USERID_BUY_INFO = "kylin:buy:userId:"; public static final String USERID_BUY_INFO = "kylin:buy:userId:";
public static final String IDCARD_BUY_INFO = "kylin:buy:idCard:"; public static final String IDCARD_BUY_INFO = "kylin:buy:idCard:";
......
...@@ -144,6 +144,11 @@ public class KylinOrderTicketsRefundServiceImpl { ...@@ -144,6 +144,11 @@ public class KylinOrderTicketsRefundServiceImpl {
} }
public ResponseDto sendOrderRefund(String orderId, String orderTicketEntitiesId, String reason, String picList, String ticketNum, Integer sendExpressType, String expressNumber, String expressContacts, String expressPhone, String sendExpressAddress, String appointmentTime) { public ResponseDto sendOrderRefund(String orderId, String orderTicketEntitiesId, String reason, String picList, String ticketNum, Integer sendExpressType, String expressNumber, String expressContacts, String expressPhone, String sendExpressAddress, String appointmentTime) {
boolean isLock = dataUtils.setRefundLock(orderTicketEntitiesId);
if (!isLock) {
return ResponseDto.failure("正在处理,请勿重复操作~");
}
KylinOrderTicketEntitiesVo orderTicketEntitiesVo = null; KylinOrderTicketEntitiesVo orderTicketEntitiesVo = null;
try { try {
String uid = CurrentUtil.getCurrentUid(); String uid = CurrentUtil.getCurrentUid();
...@@ -234,6 +239,9 @@ public class KylinOrderTicketsRefundServiceImpl { ...@@ -234,6 +239,9 @@ public class KylinOrderTicketsRefundServiceImpl {
} catch (Exception e) { } catch (Exception e) {
log.error("sendOrderRefundException e:[{}]", e); log.error("sendOrderRefundException e:[{}]", e);
return ResponseDto.failure("申请失败"); return ResponseDto.failure("申请失败");
} finally {
// 执行完毕。释放锁
dataUtils.delRefundLock(orderTicketEntitiesId);
} }
} }
......
...@@ -814,4 +814,17 @@ public class DataUtils { ...@@ -814,4 +814,17 @@ public class DataUtils {
} }
return priceExpress; return priceExpress;
} }
public boolean setRefundLock(String orderTicketEntitiesId) {
String redisKey = KylinRedisConst.REDIS_KEY_KYLIN_REFUND_LOCK
.concat(orderTicketEntitiesId);
return redisUtil.lock(redisKey, 1, 60);
}
public void delRefundLock(String orderTicketEntitiesId) {
String redisKey = KylinRedisConst.REDIS_KEY_KYLIN_REFUND_LOCK
.concat(orderTicketEntitiesId);
redisUtil.uLock(redisKey);
}
} }
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