| | |
| | | @Slf4j |
| | | public class GoodsorderServiceImpl implements GoodsorderService { |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | private GoodsorderMapper goodsorderMapper; |
| | | |
| | |
| | | MPJLambdaWrapper<Goodsorder> queryWrapper = initQueryParamByModel(model); |
| | | queryWrapper.orderByAsc(Goodsorder::getPayDate); |
| | | goodsorderList = goodsorderJoinMapper.selectJoinList(GoodsorderExportVO.class,queryWrapper); |
| | | |
| | | }else{ |
| | | MPJLambdaWrapper<Refund> queryWrapper = new MPJLambdaWrapper<>(); |
| | | queryWrapper.selectAs(Refund::getMoney,GoodsorderExportVO::getRefundMoney); |
| | |
| | | queryWrapper.selectAs(Member::getOpenid, Goodsorder::getOpenid); |
| | | queryWrapper.selectAs(DiscountMember::getName, Goodsorder::getDiscountName); |
| | | queryWrapper.leftJoin(Member.class, Member::getId ,Goodsorder::getMemberId); |
| | | queryWrapper.leftJoin(DiscountMember.class, DiscountMember::getId ,Goodsorder::getObjId); |
| | | queryWrapper.leftJoin(DiscountMember.class, DiscountMember::getGoodsorderId ,Goodsorder::getId); |
| | | // queryWrapper.select("(select r.name from discount_member r where r.isdeleted=0 and r.goodsorder_id=t.id limit 1) as discountName"); |
| | | queryWrapper.select("(select max(r.done_date) from refund r where r.obj_id=t.id and r.status in(0,2)) as refund_date"); |
| | | queryWrapper.select("(select sum(r.money) from refund r where r.obj_id=t.id and r.status in(0,2)) as refund_money"); |
| | | //时间段筛选 |
| | |
| | | queryWrapper.like(model.getCode() !=null,Goodsorder::getCode,model.getCode()); |
| | | queryWrapper.like(model.getId() !=null,Goodsorder::getId,model.getId()); |
| | | queryWrapper.eq(model.getStatus() !=null,Goodsorder::getStatus,model.getStatus()); |
| | | queryWrapper.eq(model.getPayWay() !=null,Goodsorder::getPayWay,model.getPayWay()); |
| | | queryWrapper.like(model.getOnlineOrderid() !=null,Goodsorder::getOnlineOrderid,model.getOnlineOrderid()); |
| | | queryWrapper.like(model.getOpenid() !=null,Member::getOpenid,model.getOpenid()); |
| | | queryWrapper.eq(Goodsorder::getIsdeleted,Constants.ZERO); |
| | | //如果是骑行订单只显示支付成功的 |
| | | queryWrapper.eq(Constants.equalsInteger(model.getType(),Constants.ZERO),Goodsorder::getPayStatus,Constants.ONE); |
| | | queryWrapper.in(Constants.equalsInteger(model.getType(),Constants.ONE),Goodsorder::getStatus,Constants.ONE,Constants.ZERO); |
| | | |
| | | return queryWrapper; |
| | | } |
| | |
| | | if(Objects.nonNull(pageWrap.getModel().getCloseStatus()) && pageWrap.getModel().getCloseStatus().equals(Constants.ONE)){ |
| | | queryWrapper.eq(Goodsorder::getStatus,Constants.GOODSORDER_STATUS.CLOSE.getKey()); |
| | | } |
| | | queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getDiscountName()),Goodsorder::getDiscountName,pageWrap.getModel().getDiscountName()); |
| | | queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getDiscountName()),DiscountMember::getName,pageWrap.getModel().getDiscountName()); |
| | | IPage<Goodsorder> goodsorderIPage = goodsorderJoinMapper.selectJoinPage(page, Goodsorder.class, queryWrapper); |
| | | if (!CollectionUtils.isEmpty(goodsorderIPage.getRecords())){ |
| | | goodsorderIPage.getRecords().forEach(s->{ |
| | |
| | | } |
| | | return PageData.from(goodsorderIPage); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public long count(Goodsorder goodsorder) { |
| | |
| | | homeResponse.setIsStopServe(this.checkTemporaryStop()?1:0); |
| | | homeResponse.setIsBusiness(this.checkBusiness()?0:1); |
| | | homeResponse.setUnBusinessTips("营业时间为"+ systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.BUSINESS_STARTTIME).getCode() +" ~ "+systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.BUSINESS_ENDTIME).getCode()+",请在营业时间内使用本系统"); |
| | | homeResponse.setEleBusinessArea(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.PARK_LAT_LNG_LIST).getCode()); |
| | | |
| | | homeResponse.setAdList(adMapper.selectList(new QueryWrapper<Ad>() |
| | | .eq("isdeleted",Constants.ZERO) |
| | |
| | | discountMapper.selectList(new QueryWrapper<Discount>().lambda() |
| | | .eq(Discount::getIsdeleted,Constants.ZERO) |
| | | .eq(Discount::getStatus,Constants.ZERO) |
| | | .apply(" now() BETWEEN start_date and ( end_date + INTERVAL '1 day' ) ") |
| | | .orderByDesc(Discount::getId) |
| | | .last(" limit 3 ") |
| | | ) |
| | |
| | | Goodsorder goodsorder = this.goodsorderMapper.selectOne(new QueryWrapper<Goodsorder>() |
| | | .eq("member_id",memberId) |
| | | .eq("status",Constants.goodsorderStatus.pay) |
| | | .eq("type",0) |
| | | .last(" limit 1 ")); |
| | | homeResponse.setDepositStatus(Constants.ZERO); |
| | | if(goodsorder!=null){ |
| | |
| | | memberRidesResponse.setVoltageStatus(this.getVoltageStatus(bikes)); |
| | | } |
| | | //查询当前的骑行套餐 |
| | | memberRidesResponse.setDiscountMember(this.getUseDiscount(memberId,Constants.ZERO)); |
| | | memberRidesResponse.setDiscountMember(this.getUseDiscount(memberId,Constants.ZERO,memberRides.getType())); |
| | | homeResponse.setMemberRidesResponse(memberRidesResponse); |
| | | } |
| | | } |
| | |
| | | @Override |
| | | public Integer getVoltageStatus(Bikes bikes){ |
| | | //低电量电压 |
| | | BigDecimal lowVoltage = new BigDecimal(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME, Constants.LOW_VOLTAGE).getCode()); |
| | | BigDecimal lowVoltage = new BigDecimal(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME, Constants.LOW_BIKE_VOLTAGE).getCode()); |
| | | if(Objects.isNull(bikes)||Objects.isNull(bikes.getVoltage())||Objects.isNull(lowVoltage)){ |
| | | return 0; |
| | | } |
| | | return bikes.getVoltage().compareTo(lowVoltage)>0?0:1; |
| | | return bikes.getVoltage().compareTo(lowVoltage)>=0?0:1; |
| | | } |
| | | |
| | | |
| | |
| | | if(Constants.equalsInteger(goodsorder.getType(),Constants.ZERO)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED); |
| | | } |
| | | goodsorder.setMoney(Constants.translateMoney(goodsorder.getMoney())); |
| | | goodsorderDetailVO.setGoodsOrder(goodsorder); |
| | | Member member = memberMapper.selectById(goodsorder.getMemberId()); |
| | | if(Objects.nonNull(member)){ |
| | | goodsorderDetailVO.setMember(member); |
| | | } |
| | | //查询商品信息 |
| | | DiscountMember discountMember = discountMemberMapper.selectById(goodsorder.getObjId()); |
| | | DiscountMember discountMember = discountMemberMapper.selectOne(new QueryWrapper<DiscountMember>().lambda() |
| | | .eq(DiscountMember::getIsdeleted,Constants.ZERO) |
| | | .eq(DiscountMember::getGoodsorderId,goodsorder.getId())); |
| | | if(Objects.nonNull(discountMember)){ |
| | | goodsorderDetailVO.setDiscountMember(discountMember); |
| | | } |
| | |
| | | .eq(Refund::getObjId,goodsorder.getId()) |
| | | .orderByDesc(Refund::getId) |
| | | ); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(refunds)){ |
| | | for (Refund refund:refunds) { |
| | | if(Objects.nonNull(refund.getMoney())){ |
| | | refund.setMoney(Constants.translateMoney(refund.getMoney())); |
| | | } |
| | | } |
| | | } |
| | | goodsorderDetailVO.setRefundList(refunds); |
| | | |
| | | return goodsorderDetailVO; |
| | |
| | | freeTime = Integer.parseInt(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME, Constants.FREE_RENT_TIME).getCode()); |
| | | }catch (Exception e){ |
| | | } |
| | | closeMoney = getCloseMoneyByRides(memberRides,freeTime,true,goodsorder.getMoney(),goodsorder.getMemberId()).getAmount(); |
| | | closeMoney = getCloseMoneyByRides(memberRides,freeTime,true,goodsorder.getMoney(),goodsorder.getMemberId(),true).getAmount(); |
| | | //实际结算价格,记录在最高车型记录上 |
| | | // memberRides.get(0).setActualPrice(closeMoney); |
| | | } |
| | |
| | | update.setCloseDate(new Date()); |
| | | update.setCloseInfo(Constants.REFUND_TYPE.get(type).getInfo()); |
| | | update.setCloseUserId(goodsorder.getEditor()); |
| | | update.setType(Constants.ZERO); |
| | | if(Constants.REFUND_TYPE.PLAT_FORCE.getKey() == type){ |
| | | //如果是强制结算 |
| | | update.setCloseType(Constants.ONE); |
| | |
| | | transactionsMapper.insert(transactions); |
| | | } |
| | | |
| | | private RidesDetailResponse getCloseMoneyByRides(List<MemberRides> memberRides,int freeTime,boolean isClose,BigDecimal yjMoney,String memberId) { |
| | | private RidesDetailResponse getCloseMoneyByRides(List<MemberRides> memberRides,int freeTime,boolean isClose,BigDecimal yjMoney,String memberId,Boolean unOver) { |
| | | RidesDetailResponse ridesDetailResponse = new RidesDetailResponse(); |
| | | ridesDetailResponse.setHaveDisCount(Constants.ZERO); |
| | | BigDecimal closeMoney = new BigDecimal(0.00); |
| | |
| | | topRides.setActualPrice(closeMoney); |
| | | } |
| | | //查询是否存在套餐信息 |
| | | DiscountMember discountMember = this.getUseDiscount(memberId,durationSum); |
| | | DiscountMember discountMember = this.getUseDiscount(memberId,durationSum,Objects.nonNull(topRides)?topRides.getType():null); |
| | | //计算抵扣金额 |
| | | if(Objects.nonNull(discountMember) && discountMember.getSurplusTime() > Constants.ZERO && Objects.nonNull(topRides)){ |
| | | //unOver 是否未结算 未结算的订单根据当前套餐查询 已结算的订单根据已生成的数据进行查询 |
| | | if(Objects.nonNull(discountMember) && Objects.nonNull(topRides) && unOver){ |
| | | //存储抵扣记录 |
| | | DiscountLog discountLog = new DiscountLog(); |
| | | discountLog.setIsdeleted(Constants.ZERO); |
| | |
| | | discountLog.setEditInfo("骑行抵扣"); |
| | | discountLog.setGoodsorderId(topRides.getOrdreId()); |
| | | //如果骑行时间小于等于剩余时间 则直接添加 骑行卡使用数据 修正实际支付金额 |
| | | if(discountMember.getSurplusTime() >= durationSum){ |
| | | if(Constants.equalsInteger(discountMember.getLimitType(),Constants.ZERO) || discountMember.getSurplusTime() >= durationSum){ |
| | | discountLog.setRideTime(durationSum); |
| | | discountLog.setRidePrice(closeMoney); |
| | | discountLogMapper.insert(discountLog); |
| | | topRides.setActualPrice(BigDecimal.ZERO); |
| | | closeMoney = BigDecimal.ZERO; |
| | | }else{ |
| | | int baseTime =Constants.formatIntegerNum(topRides.getBaseTime()); |
| | | BigDecimal closeDisCountMoney = Constants.formatDecimalNum(topRides.getBasePrice()); |
| | | //如果是一口价方式,价格直接为一口价baseMoney,如果不是计算正常价格 |
| | | //减去优惠时长剩余时长 |
| | | Integer durationDisCountSum = durationSum - discountMember.getSurplusTime(); |
| | | discountLog.setRideTime(discountMember.getSurplusTime()); |
| | | discountLog.setRideTime(durationDisCountSum<=Constants.ZERO?discountMember.getSurplusTime():Constants.ZERO); |
| | | //如果是一口价方式,价格直接为一口价baseMoney,如果不是计算正常价格 |
| | | if(baseTime != -1){//不是一口价 |
| | | if(durationDisCountSum > baseTime && Constants.formatIntegerNum(topRides.getUnitTime())>0){ |
| | | //如果超出了起步价格,计算超出价格 |
| | |
| | | //计算金额累计超出部门价格(超出时间单位*超出单位时间价格) |
| | | closeDisCountMoney = closeDisCountMoney.add(unit.multiply(Constants.formatDecimalNum(topRides.getUnitPrice()))); |
| | | } |
| | | discountLog.setRidePrice(closeMoney.subtract(closeDisCountMoney)); |
| | | discountLog.setRidePrice(durationDisCountSum<=Constants.ZERO?closeMoney.subtract(closeDisCountMoney):BigDecimal.ZERO); |
| | | }else{ |
| | | discountLog.setRidePrice(BigDecimal.ZERO); |
| | | } |
| | | } |
| | | discountLogMapper.insert(discountLog); |
| | | ridesDetailResponse.setHaveDisCount(Constants.ONE); |
| | | if(isClose&&discountLog.getRideTime()>Constants.ZERO){ |
| | | discountLogMapper.insert(discountLog); |
| | | } |
| | | ridesDetailResponse.setHaveDisCount(discountLog.getRideTime()>Constants.ZERO?Constants.ONE:Constants.ZERO); |
| | | ridesDetailResponse.setDisCountMoney(discountLog.getRidePrice()); |
| | | }else if(Objects.nonNull(discountMember) && Objects.nonNull(topRides) |
| | | && !unOver ){ |
| | | //已还车则查询是否有 套餐卡使用记录 |
| | | List<DiscountLog> discountLogList = discountLogMapper.selectList(new QueryWrapper<DiscountLog>().lambda().eq(DiscountLog::getGoodsorderId,topRides.getOrdreId()).eq(DiscountLog::getType,Constants.ZERO) |
| | | .eq(DiscountLog::getIsdeleted,Constants.ZERO)); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(discountLogList)){ |
| | | ridesDetailResponse.setHaveDisCount(Constants.ONE); |
| | | ridesDetailResponse.setDisCountMoney(discountLogList.stream().map(i->i.getRidePrice()).reduce(BigDecimal.ZERO,BigDecimal::add)); |
| | | } |
| | | } |
| | | //如果订单价格封顶了,取订单 价格 |
| | | if(Constants.compareBigdecimal(closeMoney, yjMoney) ==1){ |
| | |
| | | LoginUserInfo principal = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(Objects.isNull(goodsorderBackDTO) |
| | | || StringUtils.isBlank(goodsorderBackDTO.getOrderId()) |
| | | || StringUtils.isBlank(goodsorderBackDTO.getReason()) |
| | | || Objects.isNull(goodsorderBackDTO.getBackType()) |
| | | || Objects.isNull(goodsorderBackDTO.getMoney())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | |
| | | .selectAs(BaseParam::getSortnum,MemberRides::getSortnum) |
| | | .leftJoin(BaseParam.class,BaseParam::getId,MemberRides::getParamId) |
| | | .eq(MemberRides::getOrdreId,id) |
| | | .in(MemberRides::getStatus,Constants.MEMBER_RIDES_STATUS.RIDES_RUNNING.getKey(),Constants.MEMBER_RIDES_STATUS.BACK_CYCLING.getKey()) |
| | | .in(MemberRides::getStatus,Constants.MEMBER_RIDES_STATUS.RIDES_RUNNING.getKey() |
| | | ,Constants.MEMBER_RIDES_STATUS.BACK_CYCLING.getKey(),Constants.MEMBER_RIDES_STATUS.RIDES_PAUSING.getKey()) |
| | | .orderByDesc(MemberRides::getCreateDate)); |
| | | if (!CollectionUtils.isEmpty(memberRides)){ |
| | | //预计结算价格和计算时长 |
| | |
| | | return memberRidesResponse; |
| | | }).collect(Collectors.toList()); |
| | | //累计和预算结算金额 |
| | | RidesDetailResponse ridesDetailResponse = getCloseMoneyByRides(memberRides,freeTime,false,goodsorder.getMoney(),goodsorder.getMemberId()); |
| | | RidesDetailResponse ridesDetailResponse = getCloseMoneyByRides(memberRides,freeTime,false,goodsorder.getMoney(),goodsorder.getMemberId(), |
| | | Constants.equalsInteger(goodsorder.getStatus(),Constants.GOODSORDER_STATUS.CLOSE.getKey())?false:true); |
| | | if(Constants.formatIntegerNum(goodsorder.getStatus())!= Constants.goodsorderStatus.pay){ |
| | | //如果非已支付但未结算,使用订单金额 |
| | | ridesDetailResponse.setAmount(goodsorder.getCloseMoney()); |
| | |
| | | qry.setStatus(Constants.goodsorderStatus.pay); |
| | | qry.setMemberId(memberId); |
| | | qry.setIsdeleted(Constants.ZERO); |
| | | qry.setType(Constants.ZERO); |
| | | if(goodsorderMapper.selectCount(new QueryWrapper<>(qry))>Constants.ZERO){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"已支付过定金,无法重复该操作"); |
| | | } |
| | |
| | | discountMember.setMemberId(memberId); |
| | | discountMember.setStatus(Constants.TWO); |
| | | discountMember.setGoodsorderId(goodsorderId); |
| | | if(!Constants.equalsInteger(discountMember.getUseType(),Constants.ZERO)){ |
| | | if(Constants.equalsInteger(discountMember.getUseType(),Constants.ONE)){ |
| | | discountMember.setUseStartDate(DateUtil.StringToDateFormat(DateUtil.getCurrDate(),"yyyy-MM-dd")); |
| | | } |
| | | discountMember.setUseEndDate( DateUtil.StringToDateFormat(DateUtil.getXDaysAfter(discountMember.getUseStartDate(),discountMember.getUseDays()-1),"yyyy-MM-dd")); |
| | | } |
| | | discountMemberMapper.insert(discountMember); |
| | | |
| | | Goodsorder goodsorder = new Goodsorder(); |
| | | goodsorder.setId(goodsorderId); |
| | | goodsorder.setCreateDate(new Date()); |
| | |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到套餐信息"); |
| | | } |
| | | if(!(Constants.equalsInteger(discount.getIsdeleted(),Constants.ZERO) |
| | | ||Constants.equalsInteger(discount.getStatus(),Constants.ZERO))){ |
| | | && Constants.equalsInteger(discount.getStatus(),Constants.ZERO))){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"套餐已下架,无法进行购买,请刷新查看"); |
| | | } |
| | | if(!(discount.getStartDate().getTime() < System.currentTimeMillis() |
| | |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"套餐开放时间未到,无法进行购买"); |
| | | } |
| | | //验证是否超过今日可售卖数量 |
| | | if(Objects.nonNull(discount.getSaleDayLimit())){ |
| | | if(Objects.nonNull(discount.getSaleDayLimit())&&discount.getSaleDayLimit()>Constants.ZERO){ |
| | | if(goodsorderMapper.selectCount(new QueryWrapper<Goodsorder>().lambda() |
| | | .eq(Goodsorder::getType,Constants.ONE) |
| | | .eq(Goodsorder::getObjId,discount.getId()) |
| | |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"套餐今日发行量已售罄,请明日查看!"); |
| | | } |
| | | } |
| | | if(Objects.nonNull(discount.getSaleLimit())){ |
| | | if(Objects.nonNull(discount.getSaleLimit())&&discount.getSaleLimit()>Constants.ZERO){ |
| | | if(goodsorderMapper.selectCount(new QueryWrapper<Goodsorder>().lambda() |
| | | .eq(Goodsorder::getType,Constants.ONE) |
| | | .eq(Goodsorder::getObjId,discount.getId()) |
| | | .in(Goodsorder::getStatus,Constants.ZERO,Constants.ONE) |
| | | .apply(" EXTRACT(YEAR FROM create_date) = EXTRACT(YEAR FROM CURRENT_DATE) ") |
| | | )>=discount.getSaleDayLimit()){ |
| | | )>=discount.getSaleLimit()){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"套餐发行量已售罄!"); |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | private Object getWxPayResponse(Goodsorder goodsorder,String openid){ |
| | | Object response = null; |
| | | //调起支付 |
| | | Object response = null; |
| | | PrepayRequest request = new PrepayRequest(); |
| | | request.setAttach("createGoodsOrder"); |
| | | request.setDescription(Constants.equalsInteger(goodsorder.getType(),Constants.ZERO)?"森林公园自行车骑行押金支付":"森林公园自行车购买骑行套餐支付"); |
| | |
| | | Goodsorder goodsorder = this.goodsorderMapper.selectOne(new QueryWrapper<Goodsorder>() |
| | | .eq("member_id",memberId) |
| | | .eq("status",Constants.goodsorderStatus.pay) |
| | | .eq("type",Constants.ZERO) |
| | | .last(" limit 1 ")); |
| | | if(Objects.isNull(goodsorder)){ |
| | | throw new BusinessException(ResponseStatus.NO_UNCLOSEED_ORDER.getCode(),"无骑行订单记录"); |
| | |
| | | * 获取当前可使用的套餐 |
| | | * @param memberId |
| | | */ |
| | | public DiscountMember getUseDiscount(String memberId,Integer driveTime){ |
| | | @Override |
| | | public DiscountMember getUseDiscount(String memberId,Integer driveTime,Integer type){ |
| | | if(Objects.isNull(type)){ |
| | | return null; |
| | | } |
| | | String today = DateUtil.getToday(); |
| | | //判断今天是否为节假日 |
| | | Holidays holidays = new Holidays(); |
| | |
| | | Integer holiday = holidaysMapper.selectCount(new QueryWrapper<>(holidays))>0?1:0; |
| | | List<DiscountMember> discountMemberList = discountMemberMapper.selectJoinList(DiscountMember.class,new MPJLambdaWrapper<DiscountMember>() |
| | | .selectAll(DiscountMember.class) |
| | | .select(" select sum(d.ride_time) from discount_log d where and d.discount_member_id = discount_member.id " + |
| | | "and d.isdeleted = 0 and d.type = 0 and EXTRACT(DAY FROM d.create_date) = EXTRACT(DAY FROM CURRENT_DATE) " , DiscountMember::getUseTime)//查询今日已使用时间 |
| | | .select(" ( select sum(d.ride_time) from discount_log d where d.discount_member_id = t.id " + |
| | | "and d.isdeleted = 0 and d.type = 0 and EXTRACT(DAY FROM d.create_date) = EXTRACT(DAY FROM CURRENT_DATE) ) " , DiscountMember::getUseTime)//查询今日已使用时间 |
| | | .eq(DiscountMember::getStatus,Constants.ZERO) |
| | | .eq(DiscountMember::getMemberId,memberId) |
| | | .ge(DiscountMember::getUseStartDate, Utils.Date.getStart(DateUtil.stringToDate(today,"yyyy-MM-dd"))) |
| | | .le(DiscountMember::getUseEndDate, Utils.Date.getEnd(DateUtil.stringToDate(today,"yyyy-MM-dd"))) |
| | | .apply(" t.use_start_date <= '"+today+"' and t.use_end_date >= '"+today+"' ") |
| | | |
| | | .eq(Constants.equalsInteger(holiday,Constants.ZERO),DiscountMember::getUseWorkday,Constants.ONE) |
| | | .eq(Constants.equalsInteger(holiday,Constants.ONE),DiscountMember::getUseHoliday,Constants.ONE) |
| | | |
| | | .eq(Constants.equalsInteger(type,Constants.ZERO),DiscountMember::getIsbike,Constants.ONE) |
| | | .eq(Constants.equalsInteger(type,Constants.ONE),DiscountMember::getIselecbike,Constants.ONE) |
| | | .orderByDesc(DiscountMember::getLimitType) |
| | | .orderByDesc(DiscountMember::getLimitTime) |
| | | ); |
| | |
| | | if(list.size()>Constants.ZERO){ |
| | | //d1在前则升序 反之降序 |
| | | list.sort((d1,d2)-> Integer.compare(d2.getSurplusTime(),d1.getSurplusTime())); |
| | | return list.get(Constants.ZERO); |
| | | } |
| | | return list.get(Constants.ZERO); |
| | | }else{ |
| | | //无无期限的套餐 优先查询剩余时长大于骑行时长的信息(取时间最小的套餐) 再查询小于骑行时长的套餐 |
| | | List<DiscountMember> list = discountMemberList.stream().filter(i->i.getSurplusTime()>=driveTime).collect(Collectors.toList()); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(list)){ |
| | | if(list.size()>Constants.ZERO){ |
| | | //d1在前则升序 反之降序 |
| | | list.sort((d1,d2)-> Integer.compare(d2.getSurplusTime(),d1.getSurplusTime())); |
| | | list.sort((d1,d2)-> Integer.compare(d1.getSurplusTime(),d2.getSurplusTime())); |
| | | return list.get(Constants.ZERO); |
| | | } |
| | | return list.get(Constants.ZERO); |
| | | |
| | | } |
| | | list = discountMemberList.stream().filter(i->i.getSurplusTime()<driveTime).collect(Collectors.toList()); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(list)){ |
| | | if(list.size()>Constants.ZERO){ |
| | | list.sort((d1,d2)-> Integer.compare(d1.getSurplusTime(),d2.getSurplusTime())); |
| | | list.sort((d1,d2)-> Integer.compare(d2.getSurplusTime(),d1.getSurplusTime())); |
| | | } |
| | | return list.get(Constants.ZERO); |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void autCancel(){ |
| | | goodsorderMapper.update(null,new UpdateWrapper<Goodsorder>().lambda() |
| | | .set(Goodsorder::getStatus,Constants.GOODSORDER_STATUS.CANCEL.getKey()) |
| | | .set(Goodsorder::getEditDate,DateUtil.getCurrDateTime()) |
| | | .eq(Goodsorder::getStatus,Constants.GOODSORDER_STATUS.UN_PAY.getKey()) |
| | | .apply(" NOW() >= create_date + INTERVAL '30 min' ") |
| | | ); |
| | | } |
| | | |
| | | } |