无关风月
17 小时以前 538d011bfe8c57c756c32695c88e07b595d76434
cloud-server-activity/src/main/java/com/dsh/activity/controller/PointMercharsController.java
@@ -1,6 +1,7 @@
package com.dsh.activity.controller;
import com.alipay.api.domain.ArrangementVORes;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dsh.activity.entity.*;
@@ -92,11 +93,13 @@
     */
    @RequestMapping("/base/pointMerchars/changeState")
    public void changeState(@RequestBody CoachChangeStateVO dto) {
        pmdsService.changeState(dto);
    }
    @ResponseBody
    @PostMapping("/base/pointMerchars/goodsList")
    public List<PointsMerchandise> goodsList() {
        return pmdsService.list();
    }
    /**
     * 根据id查询
     */
@@ -226,10 +229,12 @@
                String endTime = (String) stringObjectMap.get("endTime");
                stringObjectMap.put("timeValue", startTime + "至" + endTime);
                int count1 = upmseService.count(new LambdaQueryWrapper<UserPointsMerchandise>()
                        .eq(UserPointsMerchandise::getPointsMerchandiseId, o));
                        .eq(UserPointsMerchandise::getPointsMerchandiseId, o)
                        .eq(UserPointsMerchandise::getPayStatus, 2).eq(UserPointsMerchandise::getState, 1));
                int count2 = upmseService.count(new LambdaQueryWrapper<UserPointsMerchandise>()
                        .eq(UserPointsMerchandise::getPointsMerchandiseId, o)
                        .eq(UserPointsMerchandise::getStatus, 2));
                        .eq(UserPointsMerchandise::getStatus, 2)
                        .eq(UserPointsMerchandise::getPayStatus, 2).eq(UserPointsMerchandise::getState, 1));
                stringObjectMap.put("hasExchangeQty", count1);
                stringObjectMap.put("hasPickQty", count2);
@@ -324,7 +329,8 @@
        QueryWrapper<PointsMerchandise> wrapper = new QueryWrapper<PointsMerchandise>()
                .eq("state", 1)
                .eq("shelves", 1)
                .gt("endTime", new Date());
                .gt("endTime", new Date())
                .eq("status", 1);
        if(cIds.size() > 0){
            wrapper.in("id", cIds);
        }
@@ -335,7 +341,17 @@
                integralCommodity.setCommodityId(merchandise.getId());
                integralCommodity.setCommodityImg(merchandise.getCover());
                integralCommodity.setCommodityName(merchandise.getName());
                integralCommodity.setCommodityPrice(merchandise.getPrice());
                if(merchandise.getRedemptionMethod() == 1){
                    integralCommodity.setIntegral(merchandise.getIntegral());
                }
                if(merchandise.getRedemptionMethod() == 2){
                    integralCommodity.setCommodityPrice(merchandise.getPrice());
                    integralCommodity.setIntegral(merchandise.getIntegral());
                }
                if(merchandise.getRedemptionMethod() == 3){
                    integralCommodity.setCommodityPrice(merchandise.getPrice());
                }
                integralCommodity.setRedemptionMethod(merchandise.getRedemptionMethod());
                integralCommodity.setGoodsType(merchandise.getType());
                integralCommodity.setSort(merchandise.getSort());
                commodity.add(integralCommodity);
@@ -348,27 +364,30 @@
            storeCoupons.add(couponStore.getCouponId());
        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        QueryWrapper<Coupon> queryWrapper = new QueryWrapper<Coupon>().eq("state", 1).gt("endTime", sdf.format(new Date()));
        QueryWrapper<Coupon> queryWrapper = new QueryWrapper<Coupon>()
                .eq("state", 1).gt("endTime", sdf.format(new Date()));
        if(storeCoupons.size() > 0){
            queryWrapper.in("id", storeCoupons);
        }
        List<Coupon> list = couponService.list(queryWrapper.last(" ORDER BY insertTime desc"));
        if (!list.isEmpty()){
            for (Coupon coupon : list) {
            IntegralCommodity integralCommodity = new IntegralCommodity();
            integralCommodity.setCommodityId(coupon.getId());
            integralCommodity.setCommodityImg(coupon.getCover());
            integralCommodity.setCommodityName(coupon.getName());
            integralCommodity.setCommodityPrice(coupon.getIntegral());
            integralCommodity.setGoodsType(coupon.getType());
//            integralCommodity.setSort(coupon.getSort());
            commodity.add(integralCommodity);
                IntegralCommodity integralCommodity = new IntegralCommodity();
                integralCommodity.setCommodityId(coupon.getId());
                integralCommodity.setCommodityImg(coupon.getCover());
                integralCommodity.setCommodityName(coupon.getName());
                if(coupon.getRedemptionMethod() == 1){
                    integralCommodity.setIntegral(coupon.getIntegral().intValue());
                }
                if(coupon.getRedemptionMethod() == 2){
                    integralCommodity.setCommodityPrice(coupon.getCash());
                    integralCommodity.setIntegral(coupon.getIntegral().intValue());
                }
                integralCommodity.setRedemptionMethod(coupon.getRedemptionMethod());
                integralCommodity.setGoodsType(4);
                commodity.add(integralCommodity);
            }
        }
        System.out.println(commodity);
        return commodity;
    }
@@ -394,7 +413,11 @@
        list = pmdsService.list(new QueryWrapper<PointsMerchandise>()
                .eq("state", 1)
                .eq("shelves", 1).le("startTime", new Date()).ge("endTime", new Date()));
                .eq("shelves", 1)
                .le("startTime", new Date())
                .ge("endTime", new Date())
                .eq("status", 1)
        );
        if (list.size() > 0) {
            Iterator<PointsMerchandise> iterator = list.iterator();
            while (iterator.hasNext()) {
@@ -603,6 +626,8 @@
    @Autowired
    private UserCouponService userCouponService;
    @Autowired
    private VipDetailService vipDetailService;
    @PostMapping("/base/pointMerchars/getGoodDetails")
    public ProductDetailsVo getGoodDetailsWithId(@RequestBody ProductDetailRequest detailRequest) {
@@ -809,15 +834,18 @@
    private ICouponService couponService;
    @ResponseBody
    @PostMapping("/base/pointMerchars/getDetailsOfExchange")
    public ExchangeDetailsVo getIntegralExchangeDetails(@RequestBody Integer appUserId) {
    public ExchangeDetailsVo getIntegralExchangeDetails(@RequestBody Integer appUserId) throws ParseException {
        ExchangeDetailsVo detailsVo = new ExchangeDetailsVo();
        List<ExchangeDetailsResponse> responses = new ArrayList<>();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
        List<UserPointsMerchandise> pointsMerchandises = upmseService.list(new QueryWrapper<UserPointsMerchandise>()
                .eq("userId", appUserId).eq("payStatus", 2));
        List<PointsMerchandiseStore> pointsMerchandiseStoreList = pointsMerchandiseStoreService.list();
        Map<Integer, List<PointsMerchandiseStore>> pointsMerchandiseStoreMap = pointsMerchandiseStoreList.stream().collect(Collectors.groupingBy(PointsMerchandiseStore::getPointsMerchandiseId));
        List<Coupon> list1 = couponService.list();
        List<Integer> ids = new ArrayList<>();
@@ -828,7 +856,8 @@
        }
        List<UserCoupon> userCoupons = new ArrayList<>();
        if (ids.size() > 0) {
            userCoupons = userCouponService.list(new QueryWrapper<UserCoupon>().eq("userId", appUserId).in("couponId", ids));
            userCoupons = userCouponService.list(new QueryWrapper<UserCoupon>().eq("userId", appUserId).in("couponId", ids)
                    .ne("status",3));
        }
        if (pointsMerchandises.size() > 0) {
            for (UserPointsMerchandise pointsMerchandise : pointsMerchandises) {
@@ -836,6 +865,7 @@
                if (merchandise == null) {
                    continue;
                }
                ExchangeDetailsResponse detailsResponse = new ExchangeDetailsResponse();
                detailsResponse.setDetailsId(pointsMerchandise.getId());
                detailsResponse.setGoodName(merchandise.getName());
@@ -909,8 +939,11 @@
                                        list4.add(43);
                                        detailsResponse.setRid(list4);
                                    }
                                }
                            }
                            if (detailsResponse.getRid()==null){
                                List<Integer> integers = stoClient.querySiteIdById(collect);
                                detailsResponse.setRid(integers);
                            }
                            //======================================================
                        }
@@ -931,40 +964,53 @@
                            }
                            detailsResponse.setRid(list4);
                            detailsResponse.setSid(list3);
                        System.err.println("门票rid"+list4);
                        System.err.println("门票sid"+list3);
                    }
                    if (merchandise.getCardType() == 1) {
                        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
                        Calendar calendar = Calendar.getInstance();
                        calendar.setTime(pointsMerchandise.getInsertTime());
                        calendar.add(Calendar.DAY_OF_MONTH, 1);
                        Date end = calendar.getTime();
                        String startDate = dateFormat.format(pointsMerchandise.getInsertTime());
                        String endDate = dateFormat.format(end);
                        detailsResponse.setStartTime(startDate);
                        detailsResponse.setEndTime(startDate);
                        Date now = new Date();
                        Calendar cal1 = Calendar.getInstance();
                        cal1.setTime(pointsMerchandise.getInsertTime());
                        Calendar cal2 = Calendar.getInstance();
                        cal2.setTime(now);
                        // Compare the year, month, and day of the two Calendar instances
                        boolean isSameDate = cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
                                cal1.get(Calendar.MONTH) == cal2.get(Calendar.MONTH) &&
                                cal1.get(Calendar.DAY_OF_MONTH) == cal2.get(Calendar.DAY_OF_MONTH);
                        // 日卡开始时间和结束时间根据门店营业时间来
                        // 查询门店
                        List<Integer> storeIds = pointsMerchandiseStoreMap.get(merchandise.getId()).stream().map(PointsMerchandiseStore::getStoreId)
                                .collect(Collectors.toList());
                        List<Store> stores = storeClient.queryStoreByIds(storeIds);
                        String startTime = "";
                        String endTime = "";
                        // Print the result
                        if (isSameDate) {
                        } else {
                            System.out.println("The two dates do not have the same date.");
                            detailsResponse.setUseStatus(3);
                        if (stores != null && !stores.isEmpty()) {
                            // 初始化为第一个门店的时间
                            startTime = stores.get(0).getStartTime();
                            endTime = stores.get(0).getEndTime();
                            // 遍历所有门店,找出最早的开始时间和最晚的结束时间
                            for (Store store : stores) {
                                String storeStartTime = store.getStartTime();
                                String storeEndTime = store.getEndTime();
                                if (storeStartTime != null && startTime != null) {
                                    // 比较开始时间,找出最早的
                                    if (storeStartTime.compareTo(startTime) < 0) {
                                        startTime = storeStartTime;
                                    }
                                }
                                if (storeEndTime != null && endTime != null) {
                                    // 比较结束时间,找出最晚的
                                    if (storeEndTime.compareTo(endTime) > 0) {
                                        endTime = storeEndTime;
                                    }
                                }
                            }
                        }
                        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())){
                            System.err.println("过期了,当前门店中最晚营业时间为"+format+" "+endTime+":00");
                            detailsResponse.setUseStatus(3);
                        }
                    } else if (merchandise.getCardType() == 2) {
                        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
                        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                        Calendar calendar = Calendar.getInstance();
                        calendar.setTime(pointsMerchandise.getInsertTime());
                        calendar.add(Calendar.DAY_OF_MONTH, 31);
@@ -980,7 +1026,7 @@
                        }
                    } else if (merchandise.getCardType() == 3) {
                        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
                        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);
@@ -996,7 +1042,7 @@
                        }
                    } else if (merchandise.getCardType() == 4) {
                        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
                        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);
@@ -1020,6 +1066,26 @@
            detailsVo.setDetailsResponses(responses);
        }
        // 2.0新增会员权益赠送门票
        List<VipDetail> list = vipDetailService.lambdaQuery()
                .eq(VipDetail::getAppUserId, appUserId).eq(VipDetail::getType, 2).list();
        for (VipDetail vipDetail : list) {
                ExchangeDetailsResponse detailsResponse = new ExchangeDetailsResponse();
                // 添加-用于区分会员权益门票
                detailsResponse.setDetailsId(Long.valueOf("-"+vipDetail.getId()));
                detailsResponse.setGoodName(vipDetail.getTicketName());
                detailsResponse.setStartTime(simpleDateFormat.format(vipDetail.getStartTime()));
                detailsResponse.setEndTime(simpleDateFormat.format(vipDetail.getEndTime()));
                detailsResponse.setUseStatus(vipDetail.getStatus()==1?2:1);
                detailsResponse.setGoodType(3);
                // 表明是会员赠送的门票
                detailsResponse.setExchangeType(4);
                // 全国通用
            detailsResponse.setRid(Collections.singletonList(0));
            detailsResponse.setSid(Collections.singletonList(0));
                responses.add(detailsResponse);
            }
        if (userCoupons.size() > 0) {
            for (UserCoupon userCoupon : userCoupons) {
@@ -1039,13 +1105,14 @@
                    detailsResponse.setIntegral(c.getIntegral().intValue());
                    detailsResponse.setCash(c.getCash());
                }
                if (userCoupon.getIsVipGrant()!=null && userCoupon.getIsVipGrant()==1){
                    detailsResponse.setExchangeType(4);
                }
                detailsResponse.setStartTime(simpleDateFormat.format(c.getStartTime()));
                detailsResponse.setEndTime(simpleDateFormat.format(c.getEndTime()));
                detailsResponse.setUseStatus(userCoupon.getStatus() == 1 ? 2 : 1);
                detailsResponse.setGoodType(4);
                responses.add(detailsResponse);
            }
            Comparator<ExchangeDetailsResponse> comparator = Comparator.comparing(ExchangeDetailsResponse::getStartTime).reversed();
            Collections.sort(responses, comparator);
@@ -1064,9 +1131,95 @@
    public PointDetailsVo getSpecificsOfGoods(@RequestBody Long speMercharsId) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        PointDetailsVo detailsVo = new PointDetailsVo();
        if (speMercharsId.toString().contains("-1")){
            // 会员优惠券
            VipDetail vipDetail = vipDetailService.getById(Math.abs(speMercharsId));
            if (vipDetail.getType()==1){
                Coupon coupon = iCouponService.getById(vipDetail.getCouponId());
                detailsVo.setDetailsId(Long.valueOf(coupon.getId()));
                List<String> list3 = new ArrayList<>();
                list3.add(ToolUtil.isEmpty(coupon.getCover()) ? "" : coupon.getCover());
                if (ToolUtil.isNotEmpty(coupon.getProductImages())) {
                    list3.addAll(Arrays.asList(StrUtils.splitStr2StrArr(coupon.getProductImages(), ",")));
                }
                detailsVo.setPics(list3);
                Collections.sort(detailsVo.getPics(), (s1, s2) -> {
                    if (s1.equals(coupon.getCover())) {
                        return -1; // s1排在前面
                    } else if (s2.equals(coupon.getCover())) {
                        return 1; // s2排在前面
                    } else {
                        return 0; // 保持原顺序
                    }
                });
                detailsVo.setGoodName(coupon.getName());
                detailsVo.setExchangeType(coupon.getRedemptionMethod());
                if (coupon.getRedemptionMethod() == 1) {
                    detailsVo.setIntegral(coupon.getIntegral().intValue());
                } else {
                    detailsVo.setIntegral(coupon.getIntegral().intValue());
                    detailsVo.setCash(coupon.getCash());
                }
                if (coupon.getUseScope() == 1) {
                    detailsVo.setExchangeAddrType(1);
                    detailsVo.setBelongs("全国通用");
                } else if (coupon.getUseScope() == 2) {
                    detailsVo.setExchangeAddrType(2);
                    List<CouponCity> list = ccityService.list(new LambdaQueryWrapper<CouponCity>()
                            .eq(CouponCity::getCouponId, coupon.getId()));
                    if (list.size() > 0) {
                        detailsVo.setBelongs(list.get(0).getProvince() + "|" + list.get(0).getCity() + "用户可用");
                    }
                } else {
                    detailsVo.setExchangeAddrType(3);
                    List<CouponStore> list = cstoreService.list(new QueryWrapper<CouponStore>()
                            .eq("couponId", coupon.getId()));
                    StoreDetailOfCourse courseOfStore = stoClient.getCourseOfStore(list.get(0).getStoreId());
                    detailsVo.setBelongs(courseOfStore.getStoreName() + "可用");
                }
                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
                detailsVo.setStartTime(format.format(coupon.getStartTime()));
                detailsVo.setEndTime(format.format(coupon.getEndTime()));
                detailsVo.setContents(coupon.getIllustrate());
                detailsVo.setGoodType(4);
            }else{
                // 门票
                detailsVo.setDetailsId(Long.valueOf("-"+vipDetail.getId()));
                detailsVo.setGoodName(vipDetail.getTicketName());
                switch (vipDetail.getStatus()){
                    case 1:
                        detailsVo.setUseType(2);
                        break;
                    case 2:
                        detailsVo.setUseType(1);
                        break;
                    case 3:
                        detailsVo.setUseType(3);
                        break;
                }
                detailsVo.setStartTime(simpleDateFormat.format(vipDetail.getStartTime()));
                detailsVo.setEndTime(simpleDateFormat.format(vipDetail.getEndTime()));
                detailsVo.setOrderTime(simpleDateFormat.format(vipDetail.getInsertTime()));
                if (vipDetail.getUseTime()!=null){
                    detailsVo.setWriteOffTime(simpleDateFormat.format(vipDetail.getUseTime()));
                }
                if (vipDetail.getUseStoreId()!=null){
                    StoreDetailOfCourse courseOfStore = stoClient.getCourseOfStore(vipDetail.getUseStoreId());
                    detailsVo.setWriteOffName(courseOfStore.getStoreName());
                }
                detailsVo.setBelongs("全国通用");
                detailsVo.setGoodType(3);
                detailsVo.setCardType(1);
                detailsVo.setExchangeAddrType(1);
            }
            detailsVo.setDetailsId(Long.valueOf("-"+vipDetail.getId()));
            return detailsVo;
        }
        UserPointsMerchandise byId = upmseService.getById(speMercharsId);
        if (ToolUtil.isNotEmpty(byId)) {
            List<PointsMerchandiseStore> stores = storeService.list(new QueryWrapper<PointsMerchandiseStore>().eq("pointsMerchandiseId", byId.getPointsMerchandiseId()));
@@ -1362,7 +1515,6 @@
    @PostMapping("/base/pointMerchars/updateDetailsUserPointMercase")
    public void updateDetailsUserPointMercase(@RequestBody UserPointsMerchandise merchandise) {
        merchandise.setUserId(null);
        merchandise.setPointsMerchandiseId(null);
        upmseService.updateById(merchandise);
    }
@@ -1441,8 +1593,6 @@
    @PostMapping("/base/pointMerchars/getConsumeDetails")
    public List<ConsumeDetail> getConsumeDetails(@RequestBody BillingDataRequestVo requestVo) {
        return upmseService.getConsumeDetails(requestVo);
    }
@@ -1548,17 +1698,21 @@
        List<Map<String, Object>> mapList = new ArrayList<>();
        LambdaQueryWrapper<UserPointsMerchandise> userPointsMerchandiseLambdaQueryWrapper = new LambdaQueryWrapper<>();
        userPointsMerchandiseLambdaQueryWrapper.eq(UserPointsMerchandise::getPointsMerchandiseId, pointMercharsPayedVo.getId());
        userPointsMerchandiseLambdaQueryWrapper.eq(UserPointsMerchandise::getPayStatus, 2).eq(UserPointsMerchandise::getState, 1);
        if (ToolUtil.isNotEmpty(pointMercharsPayedVo.getStatus())) {
            userPointsMerchandiseLambdaQueryWrapper.eq(UserPointsMerchandise::getStatus, pointMercharsPayedVo.getStatus());
        }
        List<UserPointsMerchandise> list = upmseService.list(userPointsMerchandiseLambdaQueryWrapper);
        List<UserPointsMerchandise> list = upmseService.list(userPointsMerchandiseLambdaQueryWrapper.orderByDesc(UserPointsMerchandise::getPaymentTime)
                .isNotNull(UserPointsMerchandise::getPaymentTime));
        System.out.println(list);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if (list.size() > 0) {
            for (UserPointsMerchandise pointsMerchandise : list) {
                Map<String, Object> map = new HashMap<>();
                map.put("id", pointsMerchandise.getId());
                map.put("userId", pointsMerchandise.getUserId());
                map.put("status", pointsMerchandise.getStatus());
                map.put("payTime", sdf.format(pointsMerchandise.getPaymentTime()));
                mapList.add(map);
            }
        }
@@ -1710,12 +1864,19 @@
                }
            }else if (byId.getUseScope()==4){
                // 如果是指定场地
                List<Integer> collect1 = list.stream().map(PointsMerchandiseStore::getSiteId).collect(Collectors.toList());
                List<Integer> collect1 = list.stream().map(PointsMerchandiseStore::getSiteId).distinct().collect(Collectors.toList());
                int temp =0;
                List<Integer> collect = list.stream().map(PointsMerchandiseStore::getStoreId).collect(Collectors.toList());
                List<Store> stores1 = new ArrayList<>();
                for (Integer integer : collect) {
                    List<Integer> list1 = new ArrayList<>();
                    list1.add(integer);
                    List<Store> stores = stoClient.queryStoreByIds(list1);
                    stores1.addAll(stores);
                }
                List<Store> stores = stoClient.queryStoreByIds(collect);
                while (temp!=collect1.size()){
                    for (Store store : stores) {
                    for (Store store : stores1) {
                        Integer integer = collect1.get(temp);
                        Site site = siteClient.querySiteById(integer);
                        StoreVos storeVos1 = new StoreVos();
@@ -1748,11 +1909,15 @@
    @PostMapping("/base/pointMerchars/updateGoodsDetail")
    public boolean updateGoodsDetail(@RequestBody Map<String, Object> map) {
        try {
            String name = (String) map.get("name");
            Integer pointMerchandiseId = (Integer) map.get("pointMerchandiseId");
            PointsMerchandise byId1 = pmdsService.getById(pointMerchandiseId);
            if (Integer.valueOf(map.get("type").toString()) != 1) {
                byId1.setStatus(2);
            }
            if(StringUtils.hasLength(name)){
                byId1.setName(name);
            }
            Integer quantityIssued = (Integer) map.get("quantityIssued");
            Integer pickUpQuantity = (Integer) map.get("pickUpQuantity");
            String redemptionInstructions = (String) map.get("redemptionInstructions");