| | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | @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); |
| | |
| | | @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"); |
| | |
| | | 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){ |
| | |
| | | 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()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | coupon.setAuditStatus(1); |
| | | coupon.setStatus(1); |
| | | coupon.setState(2); |
| | | coupon.setState(1); |
| | | coupon.setInsertTime(new Date()); |
| | | coupon.setCover(dataVo.getGoodImg()); |
| | | String goodImgs = dataVo.getGoodImgs(); |
| | |
| | | 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){ |