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

Commit ea8a7622 authored by 胡佳晨's avatar 胡佳晨

库存加锁 回调修改

parent 3b2696e0
......@@ -110,7 +110,7 @@ public class KylinRefundsStatusServiceImpl {
new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER)
);
dataUtils.delOrderTicketRedis(orderTicketsId);
mongoVoUtils.resetOrderListVo(orderInfo.getUserId(), 2, orderTicketsId);
mongoVoUtils.resetOrderListVo(orderInfo.getUserId(), 2, orderTicketsId,null);
// 订单入场人表 和 缓存
......@@ -230,7 +230,7 @@ public class KylinRefundsStatusServiceImpl {
KylinOrderTickets orderInfo = kylinOrderTicketsMapper.selectOne(
new QueryWrapper<KylinOrderTickets>().eq("order_tickets_id", orderTicketsId)
);
mongoVoUtils.resetOrderListVo(orderInfo.getUserId(), 2, orderTicketsId);
mongoVoUtils.resetOrderListVo(orderInfo.getUserId(), 2, orderTicketsId,null);
// 入场人
for (String entitiesId : orderTicketEntitiesIdsArr) {
......@@ -481,7 +481,7 @@ public class KylinRefundsStatusServiceImpl {
new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER)
);
dataUtils.delOrderTicketRedis(orderTicketsId);
mongoVoUtils.resetOrderListVo(orderInfo.getUserId(), 2, orderTicketsId);
mongoVoUtils.resetOrderListVo(orderInfo.getUserId(), 2, orderTicketsId,null);
// 退款单完成
KylinOrderRefunds kylinOrderRefunds = new KylinOrderRefunds();
......
......@@ -156,12 +156,16 @@ public class MongoVoUtils {
* @param type 1新增 2修改
* @param orderId 订单id [需要新增或者修改的订单id]
*/
public Boolean resetOrderListVo(String userId, Integer type, String orderId) {
public Boolean resetOrderListVo(String userId, Integer type, String orderId , KylinOrderTicketVo dataSingle) {
List<KylinOrderListVo> vo = new ArrayList<>();
List<KylinOrderListVo> redisVo = new ArrayList();
KylinOrderListVo voItem = new KylinOrderListVo();
KylinOrderTicketVo data = dataUtils.getOrderTicketVo(orderId);
KylinOrderTicketVo data;
if (dataSingle == null) {
data = dataUtils.getOrderTicketVo(orderId);
} else {
data = dataSingle;
}
BeanUtils.copyProperties(data, voItem);
redisVo.add(voItem);
List<KylinOrderListVo> redisData = dataUtils.getOrderList(userId);
......
......@@ -235,16 +235,16 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
// 判断库存
int surplusGeneral = -1;
if(redisLockUtil.tryLock("locak:"+ticketData.getTicketsId(),10,1)) {
// if(redisLockUtil.tryLock("locak:"+ticketData.getTicketsId(),10,1)) {
currentTime = System.currentTimeMillis();
surplusGeneral = dataUtils.changeSurplusGeneral(payOrderParam.getTicketId(), -payOrderParam.getNumber());
currentTime = System.currentTimeMillis() - currentTime;
log.debug("redis 获取库存 -> time:" + (currentTime) + "毫秒");
redisLockUtil.unlock("locak:"+ticketData.getTicketsId());
}else{
redisLockUtil.unlock("locak:"+ticketData.getTicketsId());
return ResponseDto.failure("下单超时");//乱七八糟异常
}
// }else{
// redisLockUtil.unlock("locak:"+ticketData.getTicketsId());
// return ResponseDto.failure("下单超时");//乱七八糟异常
// }
if (surplusGeneral < 0) {//库存回滚
currentTime = System.currentTimeMillis();
......@@ -312,7 +312,6 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
}
} catch (Exception e) {
if (isDownGeneral) {
currentTime = System.currentTimeMillis();
currentTime = System.currentTimeMillis();
dataUtils.changeSurplusGeneral(payOrderParam.getTicketId(), payOrderParam.getNumber());
currentTime = System.currentTimeMillis() - currentTime;
......@@ -611,7 +610,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
log.debug("mongo 添加 订单 -> time:" + (currentTime) + "毫秒");
currentTime = System.currentTimeMillis();
mongoVoUtils.resetOrderListVo(uid, 1, orderTicketVo.getOrderTicketsId());
mongoVoUtils.resetOrderListVo(uid, 1, orderTicketVo.getOrderTicketsId(),orderTicketVo);
currentTime = System.currentTimeMillis() - currentTime;
log.debug("redis 修改订单列表 -> time:" + (currentTime) + "毫秒");
......@@ -827,13 +826,14 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
Query.query(Criteria.where("orderId").is(orderTickets.getOrderTicketsId())).getQueryObject(),
new BasicDBObject("$set", mongoConverter.convertToMongoType(orderTicketEntitiesVo))
);
dataUtils.delOrderTicketRedis(orderTickets.getOrderTicketsId());
rabbitTemplate.convertAndSend(MQConst.EXCHANGES_LIQUIDNET_SQL_ORDER_PAY, MQConst.ROUTING_KEY_SQL_ORDER_PAY,
SqlMapping.gets(sqls, sqlsDataA, sqlsDataB, sqlsDataC, sqlsDataD));
//生成vo redis
mongoVoUtils.resetOrderListVo(orderTicketData.getUserId(), 2, orderTicketData.getOrderTicketsId());
dataUtils.delOrderTicketRedis(orderTickets.getOrderTicketsId());
mongoVoUtils.resetOrderListVo(orderTicketData.getUserId(), 2, orderTicketData.getOrderTicketsId(),null);
// 发短信
KylinPerformanceVo performanceData = dataUtils.getPerformanceVo(orderTicketData.getPerformanceId());
KylinTicketTimesVo ticketTimesData = null;
......@@ -1043,13 +1043,19 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
LocalDateTime strTime = vo.getChangeDate();
dataUtils.delOrderTicketRedis(orderTickets.getOrderTicketsId());
vo.setChangeDate(now);
vo.setStatus(KylinTableStatusConst.ORDER_STATUS2);
vo.setUpdatedAt(DateUtil.Formatter.yyyyMMddHHmmssSSS.format(now));
redisUtil.set(KylinRedisConst.ORDER+vo.getOrderTicketsId(),vo);
map2.put(vo.getTicketId(), map2.get(vo.getTicketId()) == null ? vo.getNumber() : map2.get(vo.getTicketId()) + vo.getNumber());
mongoVoUtils.resetOrderListVo(item.getUserId(), 2, item.getOrderTicketsId());
mongoVoUtils.resetOrderListVo(item.getUserId(), 2, item.getOrderTicketsId(),vo);
List<KylinOrderTicketEntities> entities = entitiesMapper.selectList(new UpdateWrapper<KylinOrderTicketEntities>().eq("order_id", item.getOrderTicketsId()));
// List<KylinOrderTicketEntities> entities = entitiesMapper.selectList(new UpdateWrapper<KylinOrderTicketEntities>().eq("order_id", item.getOrderTicketsId()));
List<KylinOrderTicketEntitiesVo> entities = vo.getEntitiesVoList();
entitiesMapper.selectList(new UpdateWrapper<KylinOrderTicketEntities>().eq("order_id", item.getOrderTicketsId()));
for (int i = 0; i < entities.size(); i++) {
KylinOrderTicketEntities items = entities.get(i);
KylinOrderTicketEntitiesVo items = entities.get(i);
dataUtils.changeBuyInfo(items.getUserId(), items.getEnterIdCode(), items.getPerformanceId(), items.getTicketId(), -1);
}
......@@ -1069,6 +1075,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
} catch (Exception e) {
//redisLockUtil.unlock(lock);
log.debug("CHECK TIME SYNC = "+e.getMessage());
e.printStackTrace();
return false;
}
......
......@@ -183,7 +183,7 @@ public class KylinRefundsStatusServiceImpl {
orderVov
);
dataUtils.delOrderTicketRedis(orderTicketsId);
mongoVoUtils.resetOrderListVo(orderInfo.getUserId(), 2, orderTicketsId);
mongoVoUtils.resetOrderListVo(orderInfo.getUserId(), 2, orderTicketsId,null);
// 退款单完成
KylinOrderRefunds kylinOrderRefunds = new KylinOrderRefunds();
......@@ -239,7 +239,7 @@ public class KylinRefundsStatusServiceImpl {
new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER)
);
dataUtils.delOrderTicketRedis(orderTicketsId);
mongoVoUtils.resetOrderListVo(orderInfo.getUserId(), 2, orderTicketsId);
mongoVoUtils.resetOrderListVo(orderInfo.getUserId(), 2, orderTicketsId,null);
// 订单入场人表 和 缓存
......
......@@ -159,12 +159,16 @@ public class MongoVoUtils {
* @param type 1新增 2修改
* @param orderId 订单id [需要新增或者修改的订单id]
*/
public Boolean resetOrderListVo(String userId, Integer type, String orderId) {
public Boolean resetOrderListVo(String userId, Integer type, String orderId, KylinOrderTicketVo dataSingle) {
List<KylinOrderListVo> vo = new ArrayList<>();
List<KylinOrderListVo> redisVo = new ArrayList();
KylinOrderListVo voItem = new KylinOrderListVo();
KylinOrderTicketVo data = dataUtils.getOrderTicketVo(orderId);
KylinOrderTicketVo data;
if (dataSingle == null) {
data = dataUtils.getOrderTicketVo(orderId);
} else {
data = dataSingle;
}
BeanUtils.copyProperties(data, voItem);
redisVo.add(voItem);
List<KylinOrderListVo> redisData = dataUtils.getOrderList(userId);
......
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