| | |
| | | @Autowired |
| | | private AppUserClient appUserClient; |
| | | |
| | | /** |
| | | * 查询注册赠送优惠券 判断当前优惠券限领数量 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/coupon/queryCouponByUser/{userId}") |
| | | public List<Integer> queryCouponByUser(@PathVariable("userId") Integer userId){ |
| | | List<Coupon> list = couponService.list(new QueryWrapper<Coupon>().eq("distributionMethod", 2) |
| | | .le("startTime", new Date()).ge("endTime", new Date()).eq("auditStatus", 2) |
| | | .eq("state", 1)); |
| | | |
| | | for (Coupon coupon : list) { |
| | | // 发放数量 |
| | | Integer quantityIssued = coupon.getQuantityIssued(); |
| | | // 限领数量 |
| | | Integer pickUpQuantity = coupon.getPickUpQuantity(); |
| | | // 优惠券已领取数量 |
| | | int couponId = ucService.count(new QueryWrapper<UserCoupon>().eq("couponId", coupon.getId())); |
| | | // 用户已领取该优惠券数量 |
| | | int count = ucService.count(new QueryWrapper<UserCoupon>().eq("couponId", coupon.getId() |
| | | ).eq("userId", userId)); |
| | | if (couponId>=quantityIssued){ |
| | | continue; |
| | | } |
| | | if (count>=pickUpQuantity){ |
| | | continue; |
| | | } |
| | | // 条件满足 将优惠券送给用户 |
| | | UserCoupon userCoupon = new UserCoupon(); |
| | | userCoupon.setCouponId(coupon.getId()); |
| | | userCoupon.setUserId(userId); |
| | | userCoupon.setStatus(1); |
| | | userCoupon.setInsertTime(new Date()); |
| | | ucService.save(userCoupon); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/coupon/queryCouponList") |
| | |
| | | collect.add(-1); |
| | | } |
| | | if(collect.contains(ofSearch.getStoreId())){ |
| | | if(collect.size()>1){ |
| | | map.put("size",1); |
| | | }else { |
| | | map.put("size",0); |
| | | } |
| | | mapList.add(map); |
| | | } |
| | | } |
| | |
| | | @PostMapping("/base/coupon/queryCouponListSearch1") |
| | | public List<Map<String,Object>> getCouponListOfSearch1(@RequestBody CouponListOfSearch ofSearch){ |
| | | List<Map<String, Object>> mapList = couponService.queryCouponListOfSearch1(ofSearch); |
| | | |
| | | Date currentDate = new Date(); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String currentDateStr = sdf.format(currentDate); |
| | | |
| | | // Iterate over the mapList and remove entries where endTime is less than the current date |
| | | Iterator<Map<String, Object>> iterator = mapList.iterator(); |
| | | while (iterator.hasNext()) { |
| | | Map<String, Object> map = iterator.next(); |
| | | String endTime = (String) map.get("endTime"); |
| | | if (endTime.compareTo(currentDateStr) < 0) { |
| | | iterator.remove(); |
| | | } |
| | | } |
| | | |
| | | |
| | | if (mapList.size() > 0){ |
| | | for (Map<String, Object> stringObjectMap : mapList) { |
| | | Integer o = (Integer) stringObjectMap.get("id"); |
| | |
| | | coupon.setPublisherType(1); |
| | | coupon.setCityManagerId(dataVo.getCityManagerId()); |
| | | } |
| | | if(dataVo.getObjType()!=1){ |
| | | coupon.setAuditStatus(1); |
| | | } |
| | | if (dataVo.getUserType()==1){ |
| | | coupon.setAuditStatus(2); |
| | | }else{ |
| | | coupon.setAuditStatus(1); |
| | | } |
| | | if(dataVo.getObjType()!=1){ |
| | | coupon.setAuditStatus(1); |
| | | } |
| | | |
| | | boolean save = couponService.save(coupon); |
| | | if (save){ |
| | | if (dataVo.getCompany() == 3){ |