刘帅
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,20 +422,22 @@
    @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 = "";
        String cityCode = "";
        if (ToolUtil.isEmpty(request.getLon()) && ToolUtil.isEmpty(request.getLat())) {
            return pointMerchandiseVo;
        }else{
            try {
                Map<String, String> geocode = gdMapGeocodingUtil.geocode(request.getLon(), request.getLat());
                provinceCode = geocode.get("provinceCode");
                cityCode = geocode.get("cityCode");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        try {
            Map<String, String> geocode = gdMapGeocodingUtil.geocode(request.getLon(), request.getLat());
            provinceCode = geocode.get("provinceCode");
            cityCode = geocode.get("cityCode");
        } catch (Exception e) {
            e.printStackTrace();
        }
        list = pmdsService.list(new QueryWrapper<PointsMerchandise>()
                .eq("state", 1)
@@ -420,6 +446,29 @@
                .ge("endTime", new Date())
                .eq("status", 1)
        );
        if (request.getShopId()!=null){
            List<Integer> storeId = new ArrayList<>();
            storeId.add(request.getShopId());
            List<Store> stores = storeClient.queryStoreByIds(storeId);
            Store store = stores.get(0);
            provinceCode = store.getProvinceCode();
            cityCode = store.getCityCode();
            List<Integer> pointsMerchandiseIds = pmdstoService.lambdaQuery().eq(PointsMerchandiseStore::getStoreId, request.getShopId()).list()
                    .stream().map(PointsMerchandiseStore::getPointsMerchandiseId)
                    .collect(Collectors.toList());
            if (pointsMerchandiseIds.isEmpty()){
                pointMerchandiseVo.setMerchandises(list);
                return pointMerchandiseVo;
            }else{
                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()) {
@@ -887,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);
@@ -1008,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);
                        }
@@ -1024,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);
@@ -1040,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);
@@ -1056,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);
//                            }
//                        }
                    }
@@ -1082,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) {
@@ -1116,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();
@@ -1725,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);
            }
        }