| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.xml.crypto.Data; |
| | | import java.math.BigDecimal; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | |
| | | |
| | | @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); |
| | |
| | | public HashMap<String, Object> queryFee(@RequestBody QueryDataFee queryDataFee) { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | String data = queryDataFee.getData(); |
| | | List<Integer> ids = queryDataFee.getIds(); |
| | | List<Integer> ids = queryDataFee.getIds() == null |
| | | ? new ArrayList<>() : new ArrayList<>(queryDataFee.getIds()); |
| | | if (ids.size() == 0) { |
| | | ids.add(-1); |
| | | } else { |
| | | |
| | | } |
| | | List<PointsMerchandise> list1 = pmdsService.list(new LambdaQueryWrapper<PointsMerchandise>().eq(PointsMerchandise::getRedemptionMethod, 3)); |
| | | // 只查询门票商品(type=3),并按购买记录关联的商品 ID 统计。 |
| | | // 旧逻辑会对每一笔订单遍历全部门票商品,导致日/月/季/年卡被重复累加。 |
| | | List<PointsMerchandise> tickets = pmdsService.list(new LambdaQueryWrapper<PointsMerchandise>() |
| | | .eq(PointsMerchandise::getRedemptionMethod, 3) |
| | | .eq(PointsMerchandise::getType, 3)); |
| | | LambdaQueryWrapper<UserPointsMerchandise> vipPaymentLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | if (ToolUtil.isNotEmpty(data)) { |
| | | String stime = data.split(" - ")[0] + " 00:00:00"; |
| | |
| | | vipPaymentLambdaQueryWrapper.between(UserPointsMerchandise::getInsertTime, stime, etime); |
| | | } |
| | | vipPaymentLambdaQueryWrapper.in(UserPointsMerchandise::getUserId, ids); |
| | | List<Integer> collect = list1.stream().map(PointsMerchandise::getId).collect(Collectors.toList()); |
| | | List<Integer> collect = tickets.stream().map(PointsMerchandise::getId).collect(Collectors.toList()); |
| | | if (collect.size() == 0) { |
| | | collect.add(-1); |
| | | } |
| | | vipPaymentLambdaQueryWrapper.in(UserPointsMerchandise::getPointsMerchandiseId, collect); |
| | | vipPaymentLambdaQueryWrapper.eq(UserPointsMerchandise::getPayStatus, 2); |
| | | ArrayList<Integer> objects = new ArrayList<>(); |
| | | vipPaymentLambdaQueryWrapper.and(wrapper -> wrapper.isNull(UserPointsMerchandise::getState) |
| | | .or().eq(UserPointsMerchandise::getState, 1)); |
| | | List<UserPointsMerchandise> list = upmseService.list(vipPaymentLambdaQueryWrapper); |
| | | |
| | | double a = 0; |
| | | double d = 0; |
| | | double m = 0; |
| | | double j = 0; |
| | | double y = 0; |
| | | Map<Integer, PointsMerchandise> ticketMap = tickets.stream() |
| | | .collect(Collectors.toMap(PointsMerchandise::getId, ticket -> ticket, (first, ignored) -> first)); |
| | | BigDecimal all = BigDecimal.ZERO; |
| | | BigDecimal day = BigDecimal.ZERO; |
| | | BigDecimal month = BigDecimal.ZERO; |
| | | BigDecimal quarter = BigDecimal.ZERO; |
| | | BigDecimal year = BigDecimal.ZERO; |
| | | for (UserPointsMerchandise userPointsMerchandise : list) { |
| | | for (PointsMerchandise pointsMerchandise : list1) { |
| | | if (pointsMerchandise.getId() == userPointsMerchandise.getPointsMerchandiseId()) { |
| | | a += pointsMerchandise.getCash().doubleValue(); |
| | | } |
| | | if (pointsMerchandise.getType() == 3) { |
| | | if (pointsMerchandise.getCardType() == 1) { |
| | | d += pointsMerchandise.getCash().doubleValue(); |
| | | } |
| | | if (pointsMerchandise.getCardType() == 2) { |
| | | m += pointsMerchandise.getCash().doubleValue(); |
| | | } |
| | | if (pointsMerchandise.getCardType() == 3) { |
| | | j += pointsMerchandise.getCash().doubleValue(); |
| | | } |
| | | if (pointsMerchandise.getCardType() == 4) { |
| | | y += pointsMerchandise.getCash().doubleValue(); |
| | | } |
| | | } |
| | | PointsMerchandise ticket = ticketMap.get(userPointsMerchandise.getPointsMerchandiseId()); |
| | | if (ticket == null || userPointsMerchandise.getCash() == null) { |
| | | continue; |
| | | } |
| | | |
| | | BigDecimal paidCash = userPointsMerchandise.getCash(); |
| | | all = all.add(paidCash); |
| | | if (Integer.valueOf(1).equals(ticket.getCardType())) { |
| | | day = day.add(paidCash); |
| | | } else if (Integer.valueOf(2).equals(ticket.getCardType())) { |
| | | month = month.add(paidCash); |
| | | } else if (Integer.valueOf(3).equals(ticket.getCardType())) { |
| | | quarter = quarter.add(paidCash); |
| | | } else if (Integer.valueOf(4).equals(ticket.getCardType())) { |
| | | year = year.add(paidCash); |
| | | } |
| | | } |
| | | |
| | | map.put("all", a); |
| | | map.put("day", d); |
| | | map.put("month", m); |
| | | map.put("quarter", j); |
| | | map.put("year", y); |
| | | map.put("all", all); |
| | | map.put("day", day); |
| | | map.put("month", month); |
| | | map.put("quarter", quarter); |
| | | map.put("year", year); |
| | | return map; |
| | | |
| | | |