批量收款接口事务;
This commit is contained in:
+3
@@ -18,6 +18,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@@ -165,6 +166,8 @@ public class ReceiptManageApplicationService {
|
||||
throw new ServiceException("收款数据处理失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//自己try捕获的异常也要标记事务回滚,确保收款失败时全部回滚
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
throw new ServiceException("第" + index + "笔收款失败:" + e.getMessage() + ",本次收款已全部回滚");
|
||||
}
|
||||
index++;
|
||||
|
||||
@@ -170,6 +170,7 @@ public class ReceiptManageApi extends BaseController{
|
||||
//事务内排队逐笔收款,任意一笔失败全部回滚
|
||||
return toAjax(receiptManageApplicationService.queueBatchCollection(receiptManageDOList));
|
||||
}catch (Exception e){
|
||||
//异常已在应用服务层事务内标记回滚(收款失败必回滚),此处仅返回失败结果
|
||||
return AjaxResult.error("收款失败:" + e.getMessage());
|
||||
}finally {
|
||||
if (redissonMultiLock != null && payInfoDetailLock) {
|
||||
|
||||
Reference in New Issue
Block a user