| | |
| | | .le(StringUtils.hasLength(vipDetailDto.getUseEndTime()), VipDetail::getUseTime, vipDetailDto.getUseEndTime()) |
| | | .eq(vipDetailDto.getOperatorId() != null, VipDetail::getOperatorId, vipDetailDto.getOperatorId()) |
| | | .eq(vipDetailDto.getType() != null, VipDetail::getType, vipDetailDto.getType()) |
| | | .eq(vipDetailDto.getStatus() != null, VipDetail::getStatus, vipDetailDto.getStatus()).list(); |
| | | .eq(vipDetailDto.getStatus() != null, VipDetail::getStatus, vipDetailDto.getStatus()) |
| | | .orderByDesc(VipDetail::getInsertTime) |
| | | .list(); |
| | | |
| | | |
| | | // 使用 Stream + 手动拷贝提升性能和可读性(或使用 MapStruct) |
| | | vipDetailVOS = list.stream().map(vipDetail -> { |
| | |
| | | .eq("state", 1) |
| | | .eq("status", 1) |
| | | .le("startTime", currentDate) |
| | | .ge("endTime", currentDate)); |
| | | .ge("endTime", currentDate) |
| | | .orderByDesc("insertTime", "id")); |
| | | if (couponList.size() > 0) { |
| | | Iterator<Coupon> iterator = couponList.iterator(); |
| | | while (iterator.hasNext()) { |
| | |
| | | coupon.setIntegral(BigDecimal.valueOf(dataVo.getRequiredPoints())); |
| | | break; |
| | | case 2: |
| | | coupon.setIntegral(BigDecimal.valueOf(dataVo.getRequiredPoints())); |
| | | coupon.setCash(dataVo.getRequiredCash()); |
| | | if (dataVo.getRequiredCash() != null){ |
| | | coupon.setCash(dataVo.getRequiredCash()); |
| | | }else{ |
| | | coupon.setCash(BigDecimal.ZERO); |
| | | |
| | | } |
| | | if (dataVo.getRequiredPoints() != null){ |
| | | coupon.setIntegral(BigDecimal.valueOf(dataVo.getRequiredPoints())); |
| | | |
| | | }else{ |
| | | coupon.setIntegral(BigDecimal.ZERO); |
| | | |
| | | } |
| | | break; |
| | | case 3: |
| | | coupon.setCash(dataVo.getRequiredCash()); |
| | |
| | | Integer pickUpQuantity = dataVo.getPickUpQuantity(); |
| | | // 赠送用户数量 |
| | | int count = quantityIssued / pickUpQuantity; |
| | | |
| | | // 自动发券 |
| | | if (dataVo.getDistributionMethod() == 3) { |
| | | // 判断用户人群 再判断限领数量 |
| | |
| | | // 全部用户ids |
| | | List<Integer> collect = tAppUsers.stream() |
| | | .map(TAppUser::getId).collect(Collectors.toList()); |
| | | if (collect.size()<count){ |
| | | count = collect.size(); |
| | | } |
| | | for (int i = 0; i < count; i++) { |
| | | for (int j = 0; j < pickUpQuantity; j++) { |
| | | UserCoupon u1 = new UserCoupon(); |
| | |
| | | List<Integer> collect1 = tAppUsers.stream().filter(t -> t.getVipEndTime().after(new Date())) |
| | | .map(TAppUser::getId) |
| | | .collect(Collectors.toList()); |
| | | if (collect1.size()<count){ |
| | | count = collect1.size(); |
| | | } |
| | | for (int i = 0; i < count; i++) { |
| | | for (int j = 0; j < pickUpQuantity; j++) { |
| | | UserCoupon u1 = new UserCoupon(); |
| | |
| | | case 3: |
| | | // 给已有学员用户发券 获取已有学员的用户ids |
| | | List<Integer> collect2 = studentClient.getHasStudentUser(); |
| | | if (collect2.size()<count){ |
| | | count = collect2.size(); |
| | | } |
| | | for (int i = 0; i < count; i++) { |
| | | for (int j = 0; j < pickUpQuantity; j++) { |
| | | UserCoupon u1 = new UserCoupon(); |
| | |
| | | VipDetail vipDetailServiceById = vipDetailService.getById(userCoupon.getVipDetailId()); |
| | | vipDetailServiceById.setUseTime(new Date()); |
| | | vipDetailServiceById.setStatus(2); |
| | | vipDetailServiceById.setOperatorId(0); |
| | | vipDetailService.updateById(vipDetailServiceById); |
| | | } |
| | | |
| | | } |
| | | @GetMapping("/base/coupon/updateTypeOther/{id}/{operatorId}/{storeId}/{siteId}") |
| | | void updateTypeOther(@PathVariable("id")Long id,@PathVariable("operatorId")Integer operatorId, |
| | | @PathVariable("storeId")Integer storeId,@PathVariable("siteId")Integer siteId){ |
| | | couponService.updateType(id); |
| | | UserCoupon userCoupon = userCouponService.getById(id); |
| | | if (userCoupon.getIsVipGrant()!=null&& userCoupon.getIsVipGrant()==1){ |
| | | VipDetail vipDetailServiceById = vipDetailService.getById(userCoupon.getVipDetailId()); |
| | | vipDetailServiceById.setUseTime(new Date()); |
| | | vipDetailServiceById.setStatus(2); |
| | | vipDetailServiceById.setOperatorId(operatorId); |
| | | vipDetailServiceById.setUseStoreId(storeId); |
| | | if (siteId!=0){ |
| | | vipDetailServiceById.setUseSiteId(siteId); |
| | | } |
| | | vipDetailService.updateById(vipDetailServiceById); |
| | | } |
| | | |
| | | } |