|
|
@@ -65,7 +65,10 @@ import org.redisson.api.RedissonClient;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.PlatformTransactionManager;
|
|
|
+import org.springframework.transaction.TransactionStatus;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.transaction.support.DefaultTransactionDefinition;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
@@ -123,6 +126,8 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
|
|
|
|
|
|
@Resource
|
|
|
private RedissonClient redissonClient;
|
|
|
+ @Resource
|
|
|
+ private PlatformTransactionManager transactionManager;
|
|
|
|
|
|
@Override
|
|
|
public TbIndent findIndentByPayOrdersNo(String ordersNo) {
|
|
|
@@ -1193,7 +1198,6 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
public Result riderDelivery(Long userId, RiderDeliveryDTO deliveryDTO) {
|
|
|
// 添加拍照发短信逻辑
|
|
|
// 因为原有的确认送达方法代码比较凌乱,且不好重新封装,所以这里就在原有确认收货方法之前添加拍照发短信逻辑
|
|
|
@@ -1203,15 +1207,25 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
|
|
|
throw new SqxException("无效的跑腿订单id");
|
|
|
}
|
|
|
|
|
|
+ TransactionStatus status = null;
|
|
|
RLock lock = redissonClient.getLock(String.format(RedisKey.UPDATE_INDENT_LOCK, indentNumber));
|
|
|
lock.lock();
|
|
|
try {
|
|
|
+ status = transactionManager.getTransaction(new DefaultTransactionDefinition());
|
|
|
// 如果是外卖订单
|
|
|
if (ObjectUtil.equal(indentOrder.getIndentType(), "5")) {
|
|
|
handTakeoutOrder(indentOrder, userId, deliveryDTO);
|
|
|
}
|
|
|
|
|
|
- return finshOrder(userId, indentNumber, deliveryDTO.getItemCode());
|
|
|
+ Result result = finshOrder(userId, indentNumber, deliveryDTO.getItemCode());
|
|
|
+
|
|
|
+ transactionManager.commit(status);
|
|
|
+ return result;
|
|
|
+ } catch (Exception e) {
|
|
|
+ if (ObjectUtil.isNotNull(status)) {
|
|
|
+ transactionManager.rollback(status);
|
|
|
+ }
|
|
|
+ throw e;
|
|
|
} finally {
|
|
|
lock.unlock();
|
|
|
}
|