刘帅
2026-09-08 572df690f72ed4a077d934823f261dec39b3cc7d
cloud-server-activity/src/main/java/com/dsh/activity/controller/PointMercharsController.java
@@ -124,13 +124,37 @@
    @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
@@ -284,8 +308,8 @@
     */
    @ResponseBody
    @RequestMapping("/base/pointMerchars/getAmount")
    public List<PointMerchandiseIncomeVo> getAmount() {
        return userPointsMerchandiseService.getAmount();
    public List<PointMerchandiseIncomeVo> getAmount(@RequestBody List<Integer> storeIds) {
        return userPointsMerchandiseService.getAmount(storeIds);
    }
@@ -398,7 +422,7 @@
    @PostMapping("/base/pointMerchars/getCommoditys")
    public PointMerchandiseVo getVicinityGoods(@RequestBody CommodityRequest request) {
        System.err.println("积分商城请求参数"+request);
        PointMerchandiseVo pointMerchandiseVo = new PointMerchandiseVo();
        List<PointsMerchandise> list = new ArrayList<>();
        String provinceCode = "";
@@ -436,13 +460,15 @@
                pointMerchandiseVo.setMerchandises(list);
                return pointMerchandiseVo;
            }else{
                List<PointsMerchandise> pointsMerchandiseList = pmdsService.lambdaQuery().in(PointsMerchandise::getId, pointsMerchandiseIds).list();
                list.addAll(pointsMerchandiseList);
                List<PointsMerchandise> listAll = list.stream().distinct().collect(Collectors.toList());
                list = listAll;
                List<PointsMerchandise> pointsMerchandiseList = pmdsService.lambdaQuery()
                        .eq(PointsMerchandise::getState, 1)
                        .eq(PointsMerchandise::getShelves,1)
                        .in(PointsMerchandise::getId, pointsMerchandiseIds).list();
                list = pointsMerchandiseList;
            }
        }
        list = list.stream().distinct().collect(Collectors.toList());
        if (list.size() > 0) {
            Iterator<PointsMerchandise> iterator = list.iterator();
            while (iterator.hasNext()) {
@@ -910,7 +936,7 @@
                detailsResponse.setGoodType(merchandise.getType());
                if (merchandise.getType() == 3) {
                    detailsResponse.setCodeType(3);
                    detailsResponse.setDataId(pointsMerchandise.getPointsMerchandiseId());
                    detailsResponse.setDataId(pointsMerchandise.getId()+"");
                    detailsResponse.setCardType(merchandise.getCardType());
                    List<Integer> sids = new ArrayList<>();
                    detailsResponse.setUserId(appUserId);
@@ -1031,7 +1057,7 @@
                        String format = simpleDateFormat1.format(pointsMerchandise.getInsertTime());
                        detailsResponse.setStartTime(format + " " + startTime + ":00");
                        detailsResponse.setEndTime(format + " " + endTime + ":00");
                        if (simpleDateFormat.parse(format + " " + endTime + ":00").before(new Date())) {
                        if (simpleDateFormat.parse(format + " " + endTime + ":00").before(new Date()) &&detailsResponse.getUseStatus()==2) {
                            System.err.println("过期了,当前门店中最晚营业时间为" + format + " " + endTime + ":00");
                            detailsResponse.setUseStatus(3);
                        }
@@ -1047,15 +1073,22 @@
                        detailsResponse.setEndTime(endDate);
                        Date now = new Date();
                        if (now.after(end)) {
                        if (now.after(end)&&detailsResponse.getUseStatus()==2) {
                            detailsResponse.setUseStatus(3);
                        }
//                        if (detailsResponse.getUseStatus()!=3){
//                            if (detailsResponse.getUseStatus()==1 &&now.after(end)){
//                                detailsResponse.setUseStatus(2);
//                            }else{
//                                detailsResponse.setUseStatus(2);
//                            }
//                        }
                    } else if (merchandise.getCardType() == 3) {
                        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                        Calendar calendar = Calendar.getInstance();
                        calendar.setTime(pointsMerchandise.getInsertTime());
                        calendar.add(Calendar.DAY_OF_MONTH, 93);
                        calendar.add(Calendar.DAY_OF_MONTH, 90);
                        Date end = calendar.getTime();
                        String startDate = dateFormat.format(pointsMerchandise.getInsertTime());
                        String endDate = dateFormat.format(end);
@@ -1063,15 +1096,22 @@
                        detailsResponse.setEndTime(endDate);
                        Date now = new Date();
                        if (now.after(end)) {
                        if (now.after(end)&&detailsResponse.getUseStatus()==2) {
                            detailsResponse.setUseStatus(3);
                        }
//                        if (detailsResponse.getUseStatus()!=3){
//                            if (detailsResponse.getUseStatus()==1 &&now.after(end)){
//                                detailsResponse.setUseStatus(2);
//                            }else{
//                                detailsResponse.setUseStatus(2);
//                            }
//                        }
                    } else if (merchandise.getCardType() == 4) {
                        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                        Calendar calendar = Calendar.getInstance();
                        calendar.setTime(pointsMerchandise.getInsertTime());
                        calendar.add(Calendar.DAY_OF_MONTH, 372);
                        calendar.add(Calendar.DAY_OF_MONTH, 365);
                        Date end = calendar.getTime();
                        String startDate = dateFormat.format(pointsMerchandise.getInsertTime());
                        String endDate = dateFormat.format(end);
@@ -1079,9 +1119,16 @@
                        detailsResponse.setEndTime(endDate);
                        Date now = new Date();
                        if (now.after(end)) {
                        if (now.after(end)&&detailsResponse.getUseStatus()==2) {
                            detailsResponse.setUseStatus(3);
                        }
//                        if (detailsResponse.getUseStatus()!=3){
//                            if (detailsResponse.getUseStatus()==1 &&now.after(end)){
//                                detailsResponse.setUseStatus(2);
//                            }else{
//                                detailsResponse.setUseStatus(2);
//                            }
//                        }
                    }
@@ -1105,12 +1152,16 @@
            detailsResponse.setUseStatus(vipDetail.getStatus() == 1 ? 2 : 1);
            detailsResponse.setGoodType(3);
            detailsResponse.setCardType(3);
            detailsResponse.setDataId(vipDetail.getId()+"");
            // 表明是会员赠送的门票
            detailsResponse.setExchangeType(4);
            // 全国通用
            detailsResponse.setRid(Collections.singletonList(0));
            detailsResponse.setSid(Collections.singletonList(0));
            Date now = new Date();
            if (now.after(vipDetail.getEndTime())&&detailsResponse.getUseStatus()==2) {
                detailsResponse.setUseStatus(3);
            }
            responses.add(detailsResponse);
        }
        if (userCoupons.size() > 0) {
@@ -1139,6 +1190,10 @@
                detailsResponse.setEndTime(simpleDateFormat.format(c.getEndTime()));
                detailsResponse.setUseStatus(userCoupon.getStatus() == 1 ? 2 : 1);
                detailsResponse.setGoodType(4);
                Date now = new Date();
                if (now.after(c.getEndTime())&&detailsResponse.getUseStatus()==2) {
                    detailsResponse.setUseStatus(3);
                }
                responses.add(detailsResponse);
            }
            Comparator<ExchangeDetailsResponse> comparator = Comparator.comparing(ExchangeDetailsResponse::getStartTime).reversed();
@@ -1748,7 +1803,9 @@
                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);
            }
        }