From e030255c23c7ba3e2cbad1036a810d6d72fa864f Mon Sep 17 00:00:00 2001 From: liujie <liujie> Date: 星期四, 26 十月 2023 18:04:58 +0800 Subject: [PATCH] 修改bug --- cloud-server-activity/src/main/java/com/dsh/activity/controller/CouponController.java | 129 ++++++++++++++++++++++++++++++------------- 1 files changed, 90 insertions(+), 39 deletions(-) diff --git a/cloud-server-activity/src/main/java/com/dsh/activity/controller/CouponController.java b/cloud-server-activity/src/main/java/com/dsh/activity/controller/CouponController.java index 3228d61..f49d537 100644 --- a/cloud-server-activity/src/main/java/com/dsh/activity/controller/CouponController.java +++ b/cloud-server-activity/src/main/java/com/dsh/activity/controller/CouponController.java @@ -44,6 +44,7 @@ import javax.annotation.Resource; import java.math.BigDecimal; import java.text.SimpleDateFormat; +import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; @@ -163,41 +164,45 @@ @PostMapping("/base/coupon/getAllCoupons") public List<Coupon> getAllCoupons(@RequestBody CommodityRequest request){ List<Coupon> couponList = new ArrayList<>(); - String provinceCode = ""; - String cityCode = ""; - if (ToolUtil.isEmpty(request.getLat()) && ToolUtil.isEmpty(request.getLon())){ - return couponList; - } +// String provinceCode = ""; +// String cityCode = ""; +// if (ToolUtil.isEmpty(request.getLat()) && ToolUtil.isEmpty(request.getLon())){ +// return couponList; +// } +// 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(); - } - try { + LocalDateTime currentDate = LocalDateTime.now(); + couponList = couponService.list(new QueryWrapper<Coupon>() - .eq("auditStatus",2) + .eq("distributionMethod",1) .eq("state",1) - .eq("status",2)); - if (couponList.size() > 0 ){ - Iterator<Coupon> iterator = couponList.iterator(); - while (iterator.hasNext()) { - Coupon merchandise = iterator.next(); - if (merchandise.getUseScope() == 2){ - List<CouponCity> couponCities = cityService.list(new LambdaQueryWrapper<CouponCity>() - .eq(CouponCity::getCouponId,merchandise.getId())); - if (couponCities.size() > 0){ - for (CouponCity couponCity : couponCities) { - if (!Objects.equals(couponCity.getCityCode(), cityCode) && !Objects.equals(couponCity.getProvinceCode(), provinceCode)){ - iterator.remove(); // 移除符合条件的商品 - break; - } - } - } - } - } - } + .eq("status",1) + .le("startTime", currentDate) + .ge("endTime", currentDate)); +// if (couponList.size() > 0 ){ +// Iterator<Coupon> iterator = couponList.iterator(); +// while (iterator.hasNext()) { +// Coupon merchandise = iterator.next(); +// if (merchandise.getUseScope() == 2){ +// List<CouponCity> couponCities = cityService.list(new LambdaQueryWrapper<CouponCity>() +// .eq(CouponCity::getCouponId,merchandise.getId())); +// if (couponCities.size() > 0){ +// for (CouponCity couponCity : couponCities) { +// if (!Objects.equals(couponCity.getCityCode(), cityCode) && !Objects.equals(couponCity.getProvinceCode(), provinceCode)){ +// iterator.remove(); // 移除符合条件的商品 +// break; +// } +// } +// } +// } +// } +// } return couponList; } catch (Exception e) { throw new RuntimeException(e); @@ -223,7 +228,28 @@ @ResponseBody @PostMapping("/base/coupon/queryCouponListSearch") public List<Map<String,Object>> getCouponListOfSearch(@RequestBody CouponListOfSearch ofSearch){ - List<Map<String, Object>> mapList = couponService.queryCouponListOfSearch(ofSearch); + List<Map<String, Object>> mapList1 = couponService.queryCouponListOfSearch(ofSearch); + List<Map<String, Object>> mapList = new ArrayList<>(); + + if(ofSearch.getStoreId()!=null){ + for (Map<String, Object> map : mapList1) { + List<CouponStore> id = couStoreService.list(new LambdaQueryWrapper<CouponStore>().eq(CouponStore::getCouponId, map.get("id").toString())); + List<Integer> collect = id.stream().map(CouponStore::getStoreId).collect(Collectors.toList()); + if(collect.size()==0){ + collect.add(-1); + } + if(collect.contains(ofSearch.getStoreId())){ + if(collect.size()>1){ + map.put("size",1); + }else { + map.put("size",0); + } + mapList.add(map); + } + } + }else { + mapList = mapList1; + } if (mapList.size() > 0){ for (Map<String, Object> stringObjectMap : mapList) { Integer o = (Integer) stringObjectMap.get("id"); @@ -238,6 +264,24 @@ return mapList; } + + @ResponseBody + @PostMapping("/base/coupon/queryCouponListSearch1") + public List<Map<String,Object>> getCouponListOfSearch1(@RequestBody CouponListOfSearch ofSearch){ + List<Map<String, Object>> mapList = couponService.queryCouponListOfSearch1(ofSearch); + if (mapList.size() > 0){ + for (Map<String, Object> stringObjectMap : mapList) { + Integer o = (Integer) stringObjectMap.get("id"); + Object startTime = stringObjectMap.get("startTime"); + Object endTime = stringObjectMap.get("endTime"); + stringObjectMap.put("timeValue",startTime + "至"+endTime); + int count = ucService.count(new LambdaQueryWrapper<UserCoupon>() + .eq(UserCoupon::getCouponId, o)); + stringObjectMap.put("hasPickQty",count); + } + } + return mapList; + } @ResponseBody @PostMapping("/base/coupon/couponExamineListSearch") public List<Map<String,Object>> getCouponExamineListOfSearch(@RequestBody CouponExamineListSearch ofSearch){ @@ -248,11 +292,14 @@ Object endTime = stringObjectMap.get("endTime"); stringObjectMap.put("timeValue",startTime + "至"+endTime); Integer publisherType = (Integer) stringObjectMap.get("publisherType"); - if ( publisherType == 1) { - Integer cityManagerId = (Integer) stringObjectMap.get("cityManagerId"); - TCityManager byId = citClient.getById(cityManagerId); - stringObjectMap.put("province", byId.getProvince()); - stringObjectMap.put("city", byId.getCity()); + if (publisherType!=null) { + if (publisherType == 1) { + Integer cityManagerId = (Integer) stringObjectMap.get("cityManagerId"); + TCityManager byId = citClient.getById(cityManagerId); + stringObjectMap.put("province", byId.getProvince()); + + stringObjectMap.put("city", byId.getCity()); + } } } } @@ -441,7 +488,7 @@ } coupon.setAuditStatus(1); coupon.setStatus(1); - coupon.setState(2); + coupon.setState(1); coupon.setInsertTime(new Date()); coupon.setCover(dataVo.getGoodImg()); String goodImgs = dataVo.getGoodImgs(); @@ -460,6 +507,10 @@ coupon.setPublisherType(1); coupon.setCityManagerId(dataVo.getCityManagerId()); } + if(dataVo.getObjType()!=1){ + coupon.setAuditStatus(1); + } + boolean save = couponService.save(coupon); if (save){ if (dataVo.getCompany() == 3){ -- Gitblit v1.7.1