| | |
| | | |
| | | @RequestMapping("/base/pointMerchars/writeOff") |
| | | public Object writeOff(@RequestBody WriteOffDTO dto) { |
| | | UserPointsMerchandise byId = userPointsMerchandiseService.getById(dto.getId()); |
| | | byId.setStoreId(dto.getVerifiStoreId()); |
| | | byId.setStatus(2); |
| | | byId.setVerificationTime(new Date()); |
| | | byId.setUserId(null); |
| | | byId.setVerificationUserId(dto.getVerificationUserId()); |
| | | return userPointsMerchandiseService.updateById(byId); |
| | | if (dto == null || dto.getId() == null) { |
| | | throw new IllegalArgumentException("门票记录不能为空"); |
| | | } |
| | | if (!Integer.valueOf(1).equals(dto.getGoType()) && !Integer.valueOf(2).equals(dto.getGoType())) { |
| | | throw new IllegalArgumentException("入园方式参数不正确"); |
| | | } |
| | | |
| | | UserPointsMerchandise ticket = userPointsMerchandiseService.getById(dto.getId()); |
| | | if (ticket == null) { |
| | | throw new IllegalArgumentException("门票记录不存在"); |
| | | } |
| | | if (!Integer.valueOf(1).equals(ticket.getStatus())) { |
| | | throw new IllegalStateException("该门票已核销"); |
| | | } |
| | | |
| | | // 以待核销状态作为更新条件,避免并发请求重复核销同一张门票。 |
| | | UserPointsMerchandise updatedTicket = new UserPointsMerchandise(); |
| | | updatedTicket.setId(ticket.getId()); |
| | | updatedTicket.setVerifiStoreId(dto.getVerifiStoreId()); |
| | | updatedTicket.setStatus(2); |
| | | updatedTicket.setVerificationTime(new Date()); |
| | | updatedTicket.setVerificationUserId(dto.getVerificationUserId()); |
| | | updatedTicket.setGoType(dto.getGoType()); |
| | | boolean updated = userPointsMerchandiseService.update(updatedTicket, |
| | | new LambdaQueryWrapper<UserPointsMerchandise>() |
| | | .eq(UserPointsMerchandise::getId, ticket.getId()) |
| | | .eq(UserPointsMerchandise::getStatus, 1)); |
| | | if (!updated) { |
| | | throw new IllegalStateException("该门票已核销"); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Autowired |
| | |
| | | map.put("id", pointsMerchandise.getId()); |
| | | map.put("userId", pointsMerchandise.getUserId()); |
| | | map.put("status", pointsMerchandise.getStatus()); |
| | | map.put("goType", pointsMerchandise.getGoType()); |
| | | map.put("payTime", sdf.format(pointsMerchandise.getPaymentTime())); |
| | | map.put("orderNumber", pointsMerchandise.getOrderNumber()); |
| | | mapList.add(map); |