From 2ea09c0f11223d40493c8c49bba333ca2e94e168 Mon Sep 17 00:00:00 2001 From: huangqizhen <15552608129@163.com> Date: Thu, 23 Oct 2025 10:34:42 +0800 Subject: [PATCH] =?UTF-8?q?10.23=20=E4=BF=AE=E6=94=B9=E5=9C=B0=E5=8C=BA?= =?UTF-8?q?=E6=98=A0=E5=B0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../demo/controller/cash/CashRefundController.java | 31 +++++++++++++++++----- .../example/demo/service/cash/RefundService.java | 6 ++--- .../serviceImpl/cash/CashRefundServiceImpl.java | 16 ++++++++--- 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/example/demo/controller/cash/CashRefundController.java b/src/main/java/com/example/demo/controller/cash/CashRefundController.java index c0d2fe4..7eb5a37 100644 --- a/src/main/java/com/example/demo/controller/cash/CashRefundController.java +++ b/src/main/java/com/example/demo/controller/cash/CashRefundController.java @@ -88,7 +88,7 @@ public class CashRefundController { } @PostMapping("/add") - public Result add(@RequestBody CashRecordDone cashRecordDone) { + public Result add(@RequestBody CashRecordDone cashRecordDone) throws Exception { try { return Result.success(refundService.add(cashRecordDone)); } catch (Exception e) { @@ -112,27 +112,44 @@ public class CashRefundController { return Result.success(refundService.select(page.getPageNum(), page.getPageSize(), page.getCashRecordDone())); } @PostMapping("/update") - public Result update(@RequestBody CashRecordDone cashRecordDone) { + public Result update(@RequestBody CashRecordDone cashRecordDone)throws Exception { + if (cashRecordDone.getStatus() == null) { + return Result.error("状态为空"); + } if (cashRecordDone.getStatus() == 10) { return Result.success(refundService.withdraw(cashRecordDone)); } else if (cashRecordDone.getStatus() == 11) { - return Result.success(refundService.update(cashRecordDone)); + try { + return Result.success(refundService.update(cashRecordDone)); + } catch (Exception e) { + return Result.error(e.getMessage()); + } } else return Result.error("该订单状态无法支持此操作"); } @PostMapping("/review") - public Result review(@RequestBody CashRecordDone cashRecordDone) { - return Result.success(refundService.review(cashRecordDone)); + public Result review(@RequestBody CashRecordDone cashRecordDone){ + try { + return Result.success(refundService.review(cashRecordDone)); + } catch (Exception e) { + return Result.error(e.getMessage()); + } } @PostMapping("/finalReview") public Result finalReview(@RequestBody CashRecordDone cashRecordDone) { return Result.success(refundService.finalreview(cashRecordDone)); } @PostMapping("/executor") - public Result executor(@RequestBody CashRecordDone cashRecordDone) { - return Result.success(refundService.executor(cashRecordDone)); + public Result executor(@RequestBody CashRecordDone cashRecordDone) throws Exception { + try { + return Result.success(refundService.executor(cashRecordDone)); + } + catch (Exception e) { + return Result.error(e.getMessage()); + } + } } diff --git a/src/main/java/com/example/demo/service/cash/RefundService.java b/src/main/java/com/example/demo/service/cash/RefundService.java index a0dd385..3612678 100644 --- a/src/main/java/com/example/demo/service/cash/RefundService.java +++ b/src/main/java/com/example/demo/service/cash/RefundService.java @@ -17,13 +17,13 @@ public interface RefundService { //添加 int add(CashRecordDone cashRecordDone) throws Exception; //修改 - int update(CashRecordDone cashRecordDone); + int update(CashRecordDone cashRecordDone) throws Exception; // int withdraw(CashRecordDone cashRecordDone); //审核 - int review(CashRecordDone cashRecordDone); + int review(CashRecordDone cashRecordDone) throws Exception; // 执行 - int executor(CashRecordDone cashRecordDone); + int executor(CashRecordDone cashRecordDone) throws Exception; //修改原数据状态 int updateStatus(CashRecordDone cashRecordDone); diff --git a/src/main/java/com/example/demo/serviceImpl/cash/CashRefundServiceImpl.java b/src/main/java/com/example/demo/serviceImpl/cash/CashRefundServiceImpl.java index e3a871f..11bcb5d 100644 --- a/src/main/java/com/example/demo/serviceImpl/cash/CashRefundServiceImpl.java +++ b/src/main/java/com/example/demo/serviceImpl/cash/CashRefundServiceImpl.java @@ -6,6 +6,7 @@ import com.example.demo.domain.vo.cash.CashRecordDone; import com.example.demo.domain.vo.coin.Result; import com.example.demo.mapper.cash.CashRefundMapper; import com.example.demo.mapper.coin.AuditMapper; +import com.example.demo.mapper.coin.MarketMapper; import com.example.demo.mapper.coin.RefundMapper; import com.example.demo.service.cash.RefundService; import com.github.pagehelper.PageHelper; @@ -37,6 +38,8 @@ public class CashRefundServiceImpl implements RefundService { private RefundMapper refundMapper; @Autowired private AuditMapper auditMapper; + @Autowired + private MarketMapper marketMapper; @Override public PageInfo select(Integer pageNum, Integer pageSize, CashRecordDone cashRecordDone) { PageHelper.startPage(pageNum, pageSize); @@ -75,7 +78,9 @@ public class CashRefundServiceImpl implements RefundService { //生成订单号后半部分 String orderNumber = cashRecordDone.getOrderCode(); //构建订单信息 - cashRecordDone.setOrderCode("TK_" + orderNumber); //订单号 + cashRecordDone.setOrderCode("TK" + orderNumber); //订单号 + cashRecordDone.setMarket(marketMapper.getMarketId(cashRecordDone.getMarket())); + cashRecordDone.setReceivedMarket(marketMapper.getMarketId(cashRecordDone.getReceivedMarket())); cashRefundMapper.insert(cashRecordDone); CashRecordDone cashRecordDone1 = new CashRecordDone(); cashRecordDone1.setId(cashRecordDone.getId()); @@ -86,7 +91,7 @@ public class CashRefundServiceImpl implements RefundService { } @Override - public int update(CashRecordDone cashRecordDone) { + public int update(CashRecordDone cashRecordDone) throws Exception { if (cashRecordDone.getJwcode()== null) { throw new RuntimeException("未输入精网号"); } @@ -112,8 +117,11 @@ public class CashRefundServiceImpl implements RefundService { } @Override - public int review(CashRecordDone cashRecordDone) { + public int review(CashRecordDone cashRecordDone) throws Exception { if(cashRecordDone.getStatus()== 12|| cashRecordDone.getStatus()== 22){ + if(cashRecordDone.getOrderCode()== null){ + throw new RuntimeException("未输入订单号"); + } CashRecordDone cashRecordDone1 = new CashRecordDone(); cashRecordDone1.setOrderCode(cashRecordDone.getOrderCode().substring(2)); cashRecordDone1.setStatus(4); @@ -126,7 +134,7 @@ CashRecordDone cashRecordDone1 = new CashRecordDone(); } @Override - public int executor(CashRecordDone cashRecordDone) { + public int executor(CashRecordDone cashRecordDone) throws Exception { if(cashRecordDone.getRefundVoucher()== null){ throw new RuntimeException("未输入退款凭证"); }