@Test public void testReprintTransactionLog() throws Exception { }
@Override public CommonResult reprintTransactionLog(String invoiceCode, Integer newCashierId){ List<TransactionLog> transactionLogs = transactionLogMapper.listLogsByInvoiceCode(invoiceCode); String newInvoiceCode; synchronized (this) { CommonResult result = invoiceService.getNextInvoiceCode(); newInvoiceCode = (String) result.getData(); } int count = 0; for(TransactionLog transactionLog: transactionLogs){ transactionLog.setStatus((byte)5); count += transactionLogMapper.update(transactionLog); TransactionLog newTransactionLog = (TransactionLog) transactionLog.clone(); newTransactionLog.setId(null); newTransactionLog.setCashierId(newCashierId); newTransactionLog.setInvoiceCode(newInvoiceCode); newTransactionLog.setStatus((byte) 2); CommonResult insertReverseResult = transactionService.insertTransactionLog(newTransactionLog); if (insertReverseResult.getCode() == 500) return insertReverseResult; } invoiceService.updateStatus((byte)3, newInvoiceCode); CommonResult insertExceptionResult = transactionService.insertTransactionExceptionLog( invoiceCode, newInvoiceCode, null, newCashierId, "发票重打" ); if (insertExceptionResult.getCode() == 500) return insertExceptionResult; if(count == transactionLogs.size()) return CommonResult.success(newInvoiceCode); else return CommonResult.fail(); }
PaymentServiceImpl implements PaymentService { @Override public CommonResult reprintTransactionLog(String invoiceCode, Integer newCashierId){ List<TransactionLog> transactionLogs = transactionLogMapper.listLogsByInvoiceCode(invoiceCode); String newInvoiceCode; synchronized (this) { CommonResult result = invoiceService.getNextInvoiceCode(); newInvoiceCode = (String) result.getData(); } int count = 0; for(TransactionLog transactionLog: transactionLogs){ transactionLog.setStatus((byte)5); count += transactionLogMapper.update(transactionLog); TransactionLog newTransactionLog = (TransactionLog) transactionLog.clone(); newTransactionLog.setId(null); newTransactionLog.setCashierId(newCashierId); newTransactionLog.setInvoiceCode(newInvoiceCode); newTransactionLog.setStatus((byte) 2); CommonResult insertReverseResult = transactionService.insertTransactionLog(newTransactionLog); if (insertReverseResult.getCode() == 500) return insertReverseResult; } invoiceService.updateStatus((byte)3, newInvoiceCode); CommonResult insertExceptionResult = transactionService.insertTransactionExceptionLog( invoiceCode, newInvoiceCode, null, newCashierId, "发票重打" ); if (insertExceptionResult.getCode() == 500) return insertExceptionResult; if(count == transactionLogs.size()) return CommonResult.success(newInvoiceCode); else return CommonResult.fail(); } }
PaymentServiceImpl implements PaymentService { @Override public CommonResult reprintTransactionLog(String invoiceCode, Integer newCashierId){ List<TransactionLog> transactionLogs = transactionLogMapper.listLogsByInvoiceCode(invoiceCode); String newInvoiceCode; synchronized (this) { CommonResult result = invoiceService.getNextInvoiceCode(); newInvoiceCode = (String) result.getData(); } int count = 0; for(TransactionLog transactionLog: transactionLogs){ transactionLog.setStatus((byte)5); count += transactionLogMapper.update(transactionLog); TransactionLog newTransactionLog = (TransactionLog) transactionLog.clone(); newTransactionLog.setId(null); newTransactionLog.setCashierId(newCashierId); newTransactionLog.setInvoiceCode(newInvoiceCode); newTransactionLog.setStatus((byte) 2); CommonResult insertReverseResult = transactionService.insertTransactionLog(newTransactionLog); if (insertReverseResult.getCode() == 500) return insertReverseResult; } invoiceService.updateStatus((byte)3, newInvoiceCode); CommonResult insertExceptionResult = transactionService.insertTransactionExceptionLog( invoiceCode, newInvoiceCode, null, newCashierId, "发票重打" ); if (insertExceptionResult.getCode() == 500) return insertExceptionResult; if(count == transactionLogs.size()) return CommonResult.success(newInvoiceCode); else return CommonResult.fail(); }  }
PaymentServiceImpl implements PaymentService { @Override public CommonResult reprintTransactionLog(String invoiceCode, Integer newCashierId){ List<TransactionLog> transactionLogs = transactionLogMapper.listLogsByInvoiceCode(invoiceCode); String newInvoiceCode; synchronized (this) { CommonResult result = invoiceService.getNextInvoiceCode(); newInvoiceCode = (String) result.getData(); } int count = 0; for(TransactionLog transactionLog: transactionLogs){ transactionLog.setStatus((byte)5); count += transactionLogMapper.update(transactionLog); TransactionLog newTransactionLog = (TransactionLog) transactionLog.clone(); newTransactionLog.setId(null); newTransactionLog.setCashierId(newCashierId); newTransactionLog.setInvoiceCode(newInvoiceCode); newTransactionLog.setStatus((byte) 2); CommonResult insertReverseResult = transactionService.insertTransactionLog(newTransactionLog); if (insertReverseResult.getCode() == 500) return insertReverseResult; } invoiceService.updateStatus((byte)3, newInvoiceCode); CommonResult insertExceptionResult = transactionService.insertTransactionExceptionLog( invoiceCode, newInvoiceCode, null, newCashierId, "发票重打" ); if (insertExceptionResult.getCode() == 500) return insertExceptionResult; if(count == transactionLogs.size()) return CommonResult.success(newInvoiceCode); else return CommonResult.fail(); }  @Override CommonResult listTransactionLogsByRegistrationId(Integer registrationId); @Override CommonResult listTransactionLogsByInvoiceCode(String invoiceCode); @Override CommonResult listTransactionLogsByCollectionAndProjectId(Integer collectionId, Integer projectId); @Override @Transactional CommonResult updateTransactionLogsAsPaid(List<TransactionParam> transactionParams); @Override CommonResult updateTransactionLogsAsReturned(List<TransactionParam> transactionLogParams); @Override CommonResult reprintTransactionLog(String invoiceCode, Integer newCashierId); @Override CommonResult listLogsByRegistrationIdAndDate(Integer registrationId, String beginDateStr, String endDateStr); }
PaymentServiceImpl implements PaymentService { @Override public CommonResult reprintTransactionLog(String invoiceCode, Integer newCashierId){ List<TransactionLog> transactionLogs = transactionLogMapper.listLogsByInvoiceCode(invoiceCode); String newInvoiceCode; synchronized (this) { CommonResult result = invoiceService.getNextInvoiceCode(); newInvoiceCode = (String) result.getData(); } int count = 0; for(TransactionLog transactionLog: transactionLogs){ transactionLog.setStatus((byte)5); count += transactionLogMapper.update(transactionLog); TransactionLog newTransactionLog = (TransactionLog) transactionLog.clone(); newTransactionLog.setId(null); newTransactionLog.setCashierId(newCashierId); newTransactionLog.setInvoiceCode(newInvoiceCode); newTransactionLog.setStatus((byte) 2); CommonResult insertReverseResult = transactionService.insertTransactionLog(newTransactionLog); if (insertReverseResult.getCode() == 500) return insertReverseResult; } invoiceService.updateStatus((byte)3, newInvoiceCode); CommonResult insertExceptionResult = transactionService.insertTransactionExceptionLog( invoiceCode, newInvoiceCode, null, newCashierId, "发票重打" ); if (insertExceptionResult.getCode() == 500) return insertExceptionResult; if(count == transactionLogs.size()) return CommonResult.success(newInvoiceCode); else return CommonResult.fail(); }  @Override CommonResult listTransactionLogsByRegistrationId(Integer registrationId); @Override CommonResult listTransactionLogsByInvoiceCode(String invoiceCode); @Override CommonResult listTransactionLogsByCollectionAndProjectId(Integer collectionId, Integer projectId); @Override @Transactional CommonResult updateTransactionLogsAsPaid(List<TransactionParam> transactionParams); @Override CommonResult updateTransactionLogsAsReturned(List<TransactionParam> transactionLogParams); @Override CommonResult reprintTransactionLog(String invoiceCode, Integer newCashierId); @Override CommonResult listLogsByRegistrationIdAndDate(Integer registrationId, String beginDateStr, String endDateStr);  }