| | |
| | | PurchaseRecordVo recordVo = new PurchaseRecordVo(); |
| | | recordVo.setPurchaseType("报名赛事"); |
| | | recordVo.setPurchaseTime(dateFormat.format(coms.getInsertTime())); |
| | | Competition competition = cttService.getById(coms.getCompetitionId()); |
| | | recordVo.setPurchaseAmount("-"+competition.getPrice()); |
| | | PaymentCompetition paymentCompetition = paymentCompetitionService.getById(coms.getPaymentCompetitionId()); |
| | | recordVo.setPurchaseAmount("-"+paymentCompetition.getAmount()); |
| | | recordVos.add(recordVo); |
| | | }); |
| | | } |
| | |
| | | @PostMapping("/api/competition/queryMyCompetitionList") |
| | | @ApiOperation(value = "获取已报名赛事列表", tags = {"APP-赛事活动列表"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "类型(1=未开始,2=进行中,3=已结束,4=已取消)", name = "type", dataType = "int", required = true), |
| | | @ApiImplicitParam(value = "类型(0=全部,1=未开始,2=进行中,3=已结束,4=已取消)", name = "type", dataType = "int", required = true), |
| | | @ApiImplicitParam(value = "页码,首页1", name = "pageSize", dataType = "int", required = true), |
| | | @ApiImplicitParam(value = "页条数", name = "pageNo", dataType = "int", required = true), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | |
| | | @TableField("endAge") |
| | | private Integer endAge; |
| | | /** |
| | | * 支付方式(1=现金,2=玩湃币支付,3=课时支付) |
| | | * 现金支付价格 |
| | | */ |
| | | @TableField("payType") |
| | | private Integer payType; |
| | | @TableField("cashPrice") |
| | | private Double cashPrice; |
| | | /** |
| | | * 支付金额 |
| | | * 玩湃币支付价格 |
| | | */ |
| | | @TableField("price") |
| | | private BigDecimal price; |
| | | @TableField("playPaiCoin") |
| | | private Integer playPaiCoin; |
| | | /** |
| | | * 课时支付价格 |
| | | */ |
| | | @TableField("classPrice") |
| | | private Integer classPrice; |
| | | /** |
| | | * 参加地址 |
| | | */ |
| | |
| | | private String city; |
| | | @ApiModelProperty("参赛地址") |
| | | private String address; |
| | | @ApiModelProperty("支付方式(1=现金,2=玩湃币支付,3=课时支付)") |
| | | private Integer payType; |
| | | @ApiModelProperty("支付价格") |
| | | private Double price; |
| | | @ApiModelProperty("现金支付价格") |
| | | private Double cashPrice; |
| | | @ApiModelProperty("玩湃币支付价格") |
| | | private Integer playPaiCoin; |
| | | @ApiModelProperty("课时支付价格") |
| | | private Integer classPrice; |
| | | @ApiModelProperty("赛事简介") |
| | | private String introduction; |
| | | @ApiModelProperty("报名须知") |
| | |
| | | private String age; |
| | | @ApiModelProperty("热度") |
| | | private Integer heat; |
| | | @ApiModelProperty("状态(1=未开始,2=进行中,3=已结束,4=已取消)") |
| | | private Integer status; |
| | | } |
| | |
| | | private Integer age; |
| | | @ApiModelProperty("身份证号码") |
| | | private String idcard; |
| | | @ApiModelProperty("电话号码") |
| | | private String phone; |
| | | @ApiModelProperty("剩余课时") |
| | | private Integer residueClassHour; |
| | | } |
| | |
| | | competitionInfo.setProvince(competition.getEntryProvince()); |
| | | competitionInfo.setCity(competition.getEntryCity()); |
| | | competitionInfo.setAddress(competition.getEntryAddress()); |
| | | competitionInfo.setPayType(competition.getPayType()); |
| | | competitionInfo.setPrice(competition.getPrice().doubleValue()); |
| | | competitionInfo.setCashPrice(competition.getCashPrice()); |
| | | competitionInfo.setPlayPaiCoin(competition.getPlayPaiCoin()); |
| | | competitionInfo.setClassPrice(competition.getClassPrice()); |
| | | competitionInfo.setIntroduction(competition.getIntroduction()); |
| | | competitionInfo.setRegistrationNotes(competition.getRegistrationNotes()); |
| | | competitionInfo.setApply(0); |
| | |
| | | AppUser appUser = appUserClient.queryAppUser(uid); |
| | | String[] split = paymentCompetitionVo.getIds().split(";"); |
| | | Competition competition = this.getById(paymentCompetitionVo.getId()); |
| | | BigDecimal money = competition.getPrice().multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN); |
| | | BigDecimal money = null; |
| | | if(paymentCompetitionVo.getPayType() == 1 || paymentCompetitionVo.getPayType() == 2){ |
| | | money = new BigDecimal(competition.getCashPrice()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN); |
| | | } |
| | | if(paymentCompetitionVo.getPayType() == 3){//玩湃币 |
| | | money = new BigDecimal(competition.getPlayPaiCoin()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN); |
| | | if(money.compareTo(new BigDecimal(appUser.getPlayPaiCoins())) > 0){ |
| | | return ResultUtil.error("报名失败,玩湃币不足,请充值"); |
| | | } |
| | | } |
| | | if(paymentCompetitionVo.getPayType() == 4){//课程 |
| | | money = new BigDecimal(competition.getClassPrice()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN); |
| | | for (String s : split) { |
| | | Participant participant = participantService.getById(s); |
| | | Student student = studentClient.queryStudentByPhone(participant.getPhone()); |
| | |
| | | return ResultUtil.error(participant.getName() + "不是学员,无法使用课时支付。"); |
| | | } |
| | | Integer integer = coursePackagePaymentClient.queryResidueClassHour(student.getId()); |
| | | if(new BigDecimal(integer).compareTo(competition.getPrice()) < 0){ |
| | | if(new BigDecimal(integer).compareTo(new BigDecimal(competition.getClassPrice())) < 0){ |
| | | return ResultUtil.error(participant.getName() + "剩余课时不足,无法完成支付。"); |
| | | } |
| | | } |
| | |
| | | paymentCompetition.setCompetitionId(paymentCompetitionVo.getId()); |
| | | paymentCompetition.setAppUserId(uid); |
| | | paymentCompetition.setPayType(paymentCompetitionVo.getPayType()); |
| | | paymentCompetition.setAmount(competition.getPrice().multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); |
| | | paymentCompetition.setAmount(money.doubleValue()); |
| | | paymentCompetition.setPayStatus(1); |
| | | paymentCompetition.setInsertTime(new Date()); |
| | | paymentCompetitionService.save(paymentCompetition); |
| | |
| | | Student student = studentClient.queryStudentByPhone(participant.getPhone()); |
| | | PaymentDeductionClassHour paymentDeductionClassHour = new PaymentDeductionClassHour(); |
| | | paymentDeductionClassHour.setId(student.getId()); |
| | | paymentDeductionClassHour.setClassHour(competition.getPrice().intValue()); |
| | | paymentDeductionClassHour.setClassHour(competition.getClassPrice()); |
| | | paymentDeductionClassHour.setCode(code); |
| | | coursePackagePaymentClient.paymentDeductionClassHour(paymentDeductionClassHour); |
| | | } |
| | |
| | | }else{ |
| | | participantVo.setResidueClassHour(0); |
| | | } |
| | | participantVo.setPhone(participant.getPhone()); |
| | | listVo.add(participantVo); |
| | | } |
| | | return listVo; |
| | |
| | | @Override |
| | | public List<CompetitionListVo> queryMyCompetitionList(Integer uid, Integer type, Integer pageSize, Integer pageNo) throws Exception { |
| | | pageSize = (pageSize - 1) * pageNo; |
| | | if(0 == type){ |
| | | type = null; |
| | | } |
| | | return this.baseMapper.queryMyCompetitionList(uid, type, pageSize, pageNo); |
| | | } |
| | | |
| | |
| | | competitionInfo.setProvince(competition.getEntryProvince()); |
| | | competitionInfo.setCity(competition.getEntryCity()); |
| | | competitionInfo.setAddress(competition.getEntryAddress()); |
| | | competitionInfo.setPayType(competition.getPayType()); |
| | | competitionInfo.setPrice(competition.getPrice().doubleValue()); |
| | | competitionInfo.setCashPrice(competition.getCashPrice()); |
| | | competitionInfo.setPlayPaiCoin(competition.getPlayPaiCoin()); |
| | | competitionInfo.setClassPrice(competition.getClassPrice()); |
| | | competitionInfo.setIntroduction(competition.getIntroduction()); |
| | | competitionInfo.setRegistrationNotes(competition.getRegistrationNotes()); |
| | | competitionInfo.setApply(1); |
| | |
| | | Student student = studentClient.queryStudentByPhone(participant.getPhone()); |
| | | PaymentDeductionClassHour paymentDeductionClassHour = new PaymentDeductionClassHour(); |
| | | paymentDeductionClassHour.setId(student.getId()); |
| | | paymentDeductionClassHour.setClassHour(competition.getPrice().intValue()); |
| | | paymentDeductionClassHour.setClassHour(competition.getClassPrice()); |
| | | paymentDeductionClassHour.setCode(code); |
| | | coursePackagePaymentClient.rollbackPaymentDeductionClassHour(paymentDeductionClassHour); |
| | | } |
| | |
| | | b.introduction, |
| | | DATE_FORMAT(b.registerEndTime, '%Y-%m-%d %H:%i') as registerEndTime, |
| | | CONCAT(b.startAge, '-', b.endAge) as age, |
| | | b.baseNumber + b.applicantsNumber as heat |
| | | b.baseNumber + b.applicantsNumber as heat, |
| | | if(a.payStatus = 3, 4, b.status) as status |
| | | from t_payment_competition a |
| | | left join t_competition b on (a.competitionId = b.id) |
| | | where a.state = 1 and a.appUserId = #{uid} and a.payStatus != 1 |
| | |
| | | } |
| | | |
| | | //校验参数签名 Verify parameter signature |
| | | ResultUtil resultUtil = preHandle(request); |
| | | if(resultUtil.getCode() != 200){ |
| | | log.info("签名异常"); |
| | | response.setRawStatusCode(resultUtil.getCode()); |
| | | byte[] bits = JSON.toJSONBytes(resultUtil); |
| | | DataBuffer buffer = response.bufferFactory().wrap(bits); |
| | | HttpHeaders headers = response.getHeaders(); |
| | | String first = headers.getFirst("Content-Type"); |
| | | if(StringUtils.isEmpty(first)){ |
| | | headers.add("Content-Type", "application/json;charset=UTF-8"); |
| | | } |
| | | |
| | | return response.writeWith(Mono.just(buffer)); |
| | | } |
| | | // ResultUtil resultUtil = preHandle(request); |
| | | // if(resultUtil.getCode() != 200){ |
| | | // log.info("签名异常"); |
| | | // response.setRawStatusCode(resultUtil.getCode()); |
| | | // byte[] bits = JSON.toJSONBytes(resultUtil); |
| | | // DataBuffer buffer = response.bufferFactory().wrap(bits); |
| | | // HttpHeaders headers = response.getHeaders(); |
| | | // String first = headers.getFirst("Content-Type"); |
| | | // if(StringUtils.isEmpty(first)){ |
| | | // headers.add("Content-Type", "application/json;charset=UTF-8"); |
| | | // } |
| | | // |
| | | // return response.writeWith(Mono.just(buffer)); |
| | | // } |
| | | |
| | | return chain.filter(exchange.mutate().request(request.mutate().build()).build()); |
| | | } |
| | |
| | | //package cn.mb.cloud.gateway.filter; |
| | | // |
| | | //import com.alibaba.fastjson.JSON; |
| | | //import lombok.extern.slf4j.Slf4j; |
| | | //import org.reactivestreams.Publisher; |
| | | //import org.springframework.cloud.gateway.filter.GatewayFilterChain; |
| | | //import org.springframework.cloud.gateway.filter.GlobalFilter; |
| | | //import org.springframework.core.Ordered; |
| | | //import org.springframework.core.io.buffer.DataBuffer; |
| | | //import org.springframework.core.io.buffer.DataBufferFactory; |
| | | //import org.springframework.core.io.buffer.DataBufferUtils; |
| | | //import org.springframework.http.HttpStatus; |
| | | //import org.springframework.http.server.reactive.ServerHttpRequest; |
| | | //import org.springframework.http.server.reactive.ServerHttpResponse; |
| | | //import org.springframework.http.server.reactive.ServerHttpResponseDecorator; |
| | | //import org.springframework.stereotype.Component; |
| | | //import org.springframework.web.server.ServerWebExchange; |
| | | //import reactor.core.publisher.Flux; |
| | | //import reactor.core.publisher.Mono; |
| | | // |
| | | //import java.nio.charset.StandardCharsets; |
| | | //import java.util.ArrayList; |
| | | //import java.util.List; |
| | | // |
| | | ///** |
| | | // * 日志拦截器 |
| | | // */ |
| | | //@Slf4j |
| | | //@Component |
| | | //public class ResponseParamFilter implements GlobalFilter, Ordered { |
| | | // |
| | | // @Override |
| | | // public int getOrder() { |
| | | // return -1; |
| | | // } |
| | | // |
| | | // @Override |
| | | // public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { |
| | | // try { |
| | | // ServerHttpRequest request = exchange.getRequest(); |
| | | // String uri = request.getURI().getRawPath(); |
| | | // ServerHttpResponse originalResponse = exchange.getResponse(); |
| | | // DataBufferFactory bufferFactory = originalResponse.bufferFactory(); |
| | | // HttpStatus statusCode = originalResponse.getStatusCode(); |
| | | // if(statusCode == HttpStatus.OK){ |
| | | // ServerHttpResponseDecorator decoratedResponse = new ServerHttpResponseDecorator(originalResponse) { |
| | | // @Override |
| | | // public Mono<Void> writeWith(Publisher<? extends DataBuffer> body) { |
| | | // if (body instanceof Flux) { |
| | | // Flux<? extends DataBuffer> fluxBody = Flux.from(body); |
| | | // return super.writeWith(fluxBody.map(dataBuffer -> { |
| | | // byte[] content = new byte[dataBuffer.readableByteCount()]; |
| | | // dataBuffer.read(content); |
| | | // DataBufferUtils.release(dataBuffer);//释放掉内存 Release memory |
| | | // // 构建日志 build Journal |
| | | // StringBuffer sb = new StringBuffer(); |
| | | // sb.append(" 响应操作 -> " + uri + " || 响应参数-> {} \n"); |
| | | // |
| | | // List<Object> rspArgs = new ArrayList<>(); |
| | | // rspArgs.add(originalResponse.getStatusCode()); |
| | | // String data = new String(content, StandardCharsets.UTF_8);//data |
| | | // sb.append(data); |
| | | // log.info(sb.toString(), rspArgs.toArray()); |
| | | // return bufferFactory.wrap(content); |
| | | // })); |
| | | // } else { |
| | | // log.error("响应操作 -> " + uri + " || 响应参数-> {} \n", getStatusCode()); |
| | | // } |
| | | // return super.writeWith(body); |
| | | // } |
| | | // }; |
| | | // return chain.filter(exchange.mutate().response(decoratedResponse).build()); |
| | | // } |
| | | // return chain.filter(exchange);//降级处理返回数据 Downgrade processing returns data |
| | | // }catch (Exception e){ |
| | | // log.error("gateway log exception.\n" + e); |
| | | // return chain.filter(exchange); |
| | | // } |
| | | // } |
| | | //} |
| | | package cn.mb.cloud.gateway.filter; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.reactivestreams.Publisher; |
| | | import org.springframework.cloud.gateway.filter.GatewayFilterChain; |
| | | import org.springframework.cloud.gateway.filter.GlobalFilter; |
| | | import org.springframework.core.Ordered; |
| | | import org.springframework.core.io.buffer.DataBuffer; |
| | | import org.springframework.core.io.buffer.DataBufferFactory; |
| | | import org.springframework.core.io.buffer.DataBufferUtils; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.server.reactive.ServerHttpRequest; |
| | | import org.springframework.http.server.reactive.ServerHttpResponse; |
| | | import org.springframework.http.server.reactive.ServerHttpResponseDecorator; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.server.ServerWebExchange; |
| | | import reactor.core.publisher.Flux; |
| | | import reactor.core.publisher.Mono; |
| | | |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 日志拦截器 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class ResponseParamFilter implements GlobalFilter, Ordered { |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return -1; |
| | | } |
| | | |
| | | @Override |
| | | public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { |
| | | try { |
| | | ServerHttpRequest request = exchange.getRequest(); |
| | | String uri = request.getURI().getRawPath(); |
| | | ServerHttpResponse originalResponse = exchange.getResponse(); |
| | | DataBufferFactory bufferFactory = originalResponse.bufferFactory(); |
| | | HttpStatus statusCode = originalResponse.getStatusCode(); |
| | | if(statusCode == HttpStatus.OK){ |
| | | ServerHttpResponseDecorator decoratedResponse = new ServerHttpResponseDecorator(originalResponse) { |
| | | @Override |
| | | public Mono<Void> writeWith(Publisher<? extends DataBuffer> body) { |
| | | if (body instanceof Flux) { |
| | | Flux<? extends DataBuffer> fluxBody = Flux.from(body); |
| | | return super.writeWith(fluxBody.map(dataBuffer -> { |
| | | byte[] content = new byte[dataBuffer.readableByteCount()]; |
| | | dataBuffer.read(content); |
| | | DataBufferUtils.release(dataBuffer);//释放掉内存 Release memory |
| | | // 构建日志 build Journal |
| | | StringBuffer sb = new StringBuffer(); |
| | | sb.append(" 响应操作 -> " + uri + " || 响应参数-> {} \n"); |
| | | |
| | | List<Object> rspArgs = new ArrayList<>(); |
| | | rspArgs.add(originalResponse.getStatusCode()); |
| | | String data = new String(content, StandardCharsets.UTF_8);//data |
| | | sb.append(data); |
| | | log.info(sb.toString(), rspArgs.toArray()); |
| | | return bufferFactory.wrap(content); |
| | | })); |
| | | } else { |
| | | log.error("响应操作 -> " + uri + " || 响应参数-> {} \n", getStatusCode()); |
| | | } |
| | | return super.writeWith(body); |
| | | } |
| | | }; |
| | | return chain.filter(exchange.mutate().response(decoratedResponse).build()); |
| | | } |
| | | return chain.filter(exchange);//降级处理返回数据 Downgrade processing returns data |
| | | }catch (Exception e){ |
| | | log.error("gateway log exception.\n" + e); |
| | | return chain.filter(exchange); |
| | | } |
| | | } |
| | | } |
| | |
| | | //package cn.mb.cloud.gateway.filter; |
| | | // |
| | | //import lombok.extern.slf4j.Slf4j; |
| | | //import org.springframework.cloud.gateway.filter.GatewayFilterChain; |
| | | //import org.springframework.cloud.gateway.filter.GlobalFilter; |
| | | //import org.springframework.core.Ordered; |
| | | //import org.springframework.core.io.buffer.*; |
| | | //import org.springframework.http.HttpMethod; |
| | | //import org.springframework.http.MediaType; |
| | | //import org.springframework.http.server.reactive.ServerHttpRequest; |
| | | //import org.springframework.http.server.reactive.ServerHttpRequestDecorator; |
| | | //import org.springframework.http.server.reactive.ServerHttpResponse; |
| | | //import org.springframework.stereotype.Component; |
| | | //import org.springframework.web.server.ServerWebExchange; |
| | | //import reactor.core.publisher.Flux; |
| | | //import reactor.core.publisher.Mono; |
| | | // |
| | | //import java.nio.charset.StandardCharsets; |
| | | //import java.util.Set; |
| | | // |
| | | // |
| | | //@Slf4j |
| | | //@Component |
| | | //public class WrapperResponseGlobalFilter implements GlobalFilter, Ordered { |
| | | // |
| | | // @Override |
| | | // public int getOrder() { |
| | | // return Ordered.HIGHEST_PRECEDENCE; |
| | | // } |
| | | // |
| | | // @Override |
| | | // public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { |
| | | // ServerHttpRequest req = exchange.getRequest(); |
| | | // ServerHttpResponse res = exchange.getResponse(); |
| | | // String method = req.getMethodValue(); |
| | | // MediaType ct = req.getHeaders().getContentType(); |
| | | // if (HttpMethod.POST.matches(method)) { |
| | | // return DataBufferUtils.join(req.getBody()).flatMap(dataBuffer -> { |
| | | // byte[] bytes = new byte[dataBuffer.readableByteCount()]; |
| | | // dataBuffer.read(bytes); |
| | | //// String bodyStr = new String(bytes, StandardCharsets.UTF_8); |
| | | //// exchange.getAttributes().put("POST_BODY", bodyStr); |
| | | // DataBufferUtils.release(dataBuffer); |
| | | // Flux<DataBuffer> cachedFlux = Flux.defer(() -> { |
| | | // DataBuffer buffer = res.bufferFactory().wrap(bytes); |
| | | // return Mono.just(buffer); |
| | | // }); |
| | | // ServerHttpRequest mutateReq = new ServerHttpRequestDecorator(req) { |
| | | // @Override |
| | | // public Flux<DataBuffer> getBody() { |
| | | // return cachedFlux; |
| | | // } |
| | | // }; |
| | | // return chain.filter(exchange.mutate().request(mutateReq).build()); |
| | | // }); |
| | | // } |
| | | // return chain.filter(exchange); |
| | | // } |
| | | // |
| | | //} |
| | | package cn.mb.cloud.gateway.filter; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.cloud.gateway.filter.GatewayFilterChain; |
| | | import org.springframework.cloud.gateway.filter.GlobalFilter; |
| | | import org.springframework.core.Ordered; |
| | | import org.springframework.core.io.buffer.*; |
| | | import org.springframework.http.HttpMethod; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.server.reactive.ServerHttpRequest; |
| | | import org.springframework.http.server.reactive.ServerHttpRequestDecorator; |
| | | import org.springframework.http.server.reactive.ServerHttpResponse; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.server.ServerWebExchange; |
| | | import reactor.core.publisher.Flux; |
| | | import reactor.core.publisher.Mono; |
| | | |
| | | |
| | | |
| | | @Slf4j |
| | | @Component |
| | | public class WrapperResponseGlobalFilter implements GlobalFilter, Ordered { |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return Ordered.HIGHEST_PRECEDENCE; |
| | | } |
| | | |
| | | @Override |
| | | public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { |
| | | ServerHttpRequest req = exchange.getRequest(); |
| | | ServerHttpResponse res = exchange.getResponse(); |
| | | String method = req.getMethodValue(); |
| | | MediaType ct = req.getHeaders().getContentType(); |
| | | if (HttpMethod.POST.matches(method)) { |
| | | return DataBufferUtils.join(req.getBody()).flatMap(dataBuffer -> { |
| | | byte[] bytes = new byte[dataBuffer.readableByteCount()]; |
| | | dataBuffer.read(bytes); |
| | | // String bodyStr = new String(bytes, StandardCharsets.UTF_8); |
| | | // exchange.getAttributes().put("POST_BODY", bodyStr); |
| | | DataBufferUtils.release(dataBuffer); |
| | | Flux<DataBuffer> cachedFlux = Flux.defer(() -> { |
| | | DataBuffer buffer = res.bufferFactory().wrap(bytes); |
| | | return Mono.just(buffer); |
| | | }); |
| | | ServerHttpRequest mutateReq = new ServerHttpRequestDecorator(req) { |
| | | @Override |
| | | public Flux<DataBuffer> getBody() { |
| | | return cachedFlux; |
| | | } |
| | | }; |
| | | return chain.filter(exchange.mutate().request(mutateReq).build()); |
| | | }); |
| | | } |
| | | return chain.filter(exchange); |
| | | } |
| | | |
| | | } |
| | |
| | | <artifactId>httpmime</artifactId> |
| | | <version>4.5.2</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.gavaghan</groupId> |
| | | <artifactId>geodesy</artifactId> |
| | | <version>1.1.3</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
| | |
| | | package com.dsh.other.controller; |
| | | |
| | | import com.dsh.other.model.BaseVo; |
| | | import com.dsh.other.model.*; |
| | | import com.dsh.other.service.ISiteService; |
| | | import com.dsh.other.service.ISiteTypeService; |
| | | import com.dsh.other.util.ResultUtil; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.List; |
| | |
| | | @Autowired |
| | | private ISiteService siteService; |
| | | |
| | | // @Autowired |
| | | // private |
| | | // |
| | | // |
| | | // |
| | | // public ResultUtil<List<BaseVo>> querySiteType(){ |
| | | // try { |
| | | // |
| | | // }catch (Exception e){ |
| | | // e.printStackTrace(); |
| | | // return ResultUtil.runErr(); |
| | | // } |
| | | // } |
| | | @Autowired |
| | | private ISiteTypeService siteTypeService; |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/site/querySiteType") |
| | | @ApiOperation(value = "获取场地类型", tags = {"用户—预约场地"}) |
| | | @ApiImplicitParams({ |
| | | }) |
| | | public ResultUtil<List<BaseVo>> querySiteType(){ |
| | | try { |
| | | List<BaseVo> list = siteTypeService.querySiteType(); |
| | | return ResultUtil.success(list); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/site/querySiteList") |
| | | @ApiOperation(value = "获取场地列表", tags = {"用户—预约场地"}) |
| | | @ApiImplicitParams({ |
| | | }) |
| | | public ResultUtil<List<QuerySiteListVo>> querySiteList(QuerySiteList querySiteList){ |
| | | try { |
| | | List<QuerySiteListVo> querySiteListVos = siteService.querySiteList(querySiteList); |
| | | return ResultUtil.success(querySiteListVos); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/site/querySiteInfo") |
| | | @ApiOperation(value = "获取场地详情", tags = {"用户—预约场地"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "场地id", name = "id", dataType = "int", required = true), |
| | | }) |
| | | public ResultUtil<QuerySiteInfoVo> querySiteInfo(Integer id){ |
| | | try { |
| | | QuerySiteInfoVo querySiteInfoVo = siteService.querySiteInfo(id); |
| | | return ResultUtil.success(querySiteInfoVo); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/site/querySiteTimes") |
| | | @ApiOperation(value = "获取场地详情时间段数据", tags = {"用户—预约场地"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "场地id", name = "id", dataType = "int", required = true), |
| | | @ApiImplicitParam(value = "日期(2023-01-01)", name = "day", dataType = "string", required = true), |
| | | }) |
| | | public ResultUtil<List<QuerySiteTimes>> querySiteTimes(Integer id, String day){ |
| | | try { |
| | | List<QuerySiteTimes> list = siteService.querySiteTimes(id, day); |
| | | return ResultUtil.success(list); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/store/queryStoreLists") |
| | | @ApiOperation(value = "获取门店列表", tags = {"APP-加入玩湃", "APP-课程列表"}) |
| | | @ApiOperation(value = "获取门店列表", tags = {"APP-加入玩湃", "APP-课程列表", "用户—预约场地"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "经纬", name = "lon", dataType = "string", required = false), |
| | | @ApiImplicitParam(value = "纬度", name = "lat", dataType = "string", required = false), |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/store/queryAllCity") |
| | | @ApiOperation(value = "获取所有开通城市", tags = {"APP-赛事活动列表"}) |
| | | @ApiOperation(value = "获取所有开通城市", tags = {"APP-赛事活动列表", "用户—预约场地"}) |
| | | @ApiImplicitParams({ |
| | | }) |
| | | public ResultUtil<List<ProvinceAndCityVo>> queryAllCity(){ |
| | |
| | | */ |
| | | @TableField("state") |
| | | private Integer state; |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | @TableField("insertTime") |
| | | private Date insertTime; |
| | | |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.dsh.other.entity.Site; |
| | | import com.dsh.other.model.QuerySiteList; |
| | | import com.dsh.other.model.QuerySiteListVo; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/7/13 16:10 |
| | | */ |
| | | public interface SiteMapper extends BaseMapper<Site> { |
| | | |
| | | |
| | | /** |
| | | * 获取场地列表 |
| | | * @param querySiteList |
| | | * @return |
| | | */ |
| | | List<QuerySiteListVo> querySiteList(@Param("item") QuerySiteList querySiteList); |
| | | } |
New file |
| | |
| | | package com.dsh.other.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.dsh.other.entity.SiteType; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/7/17 10:58 |
| | | */ |
| | | public interface SiteTypeMapper extends BaseMapper<SiteType> { |
| | | } |
New file |
| | |
| | | package com.dsh.other.model; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/7/17 11:49 |
| | | */ |
| | | @Data |
| | | @ApiModel |
| | | public class QuerySiteInfoVo { |
| | | @ApiModelProperty("场地id") |
| | | private Integer id; |
| | | @ApiModelProperty("场地名称") |
| | | private String name; |
| | | @ApiModelProperty("场地类型名称") |
| | | private String siteTypeName; |
| | | @ApiModelProperty("门店名称") |
| | | private String storeName; |
| | | @ApiModelProperty("门店地址") |
| | | private String storeAddress; |
| | | @ApiModelProperty("门店经度") |
| | | private String storeLon; |
| | | @ApiModelProperty("门店纬度") |
| | | private String storeLat; |
| | | @ApiModelProperty("门店电话") |
| | | private String storePhone; |
| | | @ApiModelProperty("现金价格(x/半小时)") |
| | | private Double cashPrice; |
| | | @ApiModelProperty("玩湃币价格(x/半小时)") |
| | | private Integer playPaiCoin; |
| | | } |
New file |
| | |
| | | package com.dsh.other.model; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/7/17 11:20 |
| | | */ |
| | | @Data |
| | | @ApiModel |
| | | public class QuerySiteList { |
| | | @ApiModelProperty(value = "预约开始时间(10:00)", required = false, dataType = "String") |
| | | private String startTime; |
| | | @ApiModelProperty(value = "预约结束时间(12:00)", required = false, dataType = "String") |
| | | private String endTime; |
| | | @ApiModelProperty(value = "场地类型id", required = false, dataType = "int") |
| | | private Integer siteTypeId; |
| | | @ApiModelProperty(value = "所在城市code", required = false, dataType = "String") |
| | | private String cityCode; |
| | | @ApiModelProperty(value = "所在门店id", required = false, dataType = "int") |
| | | private Integer storeId; |
| | | @ApiModelProperty(value = "页码,首页1", required = true, dataType = "int") |
| | | private Integer pageNum; |
| | | @ApiModelProperty(value = "页条数", required = true, dataType = "int") |
| | | private Integer pageSize; |
| | | @ApiModelProperty(value = "当前经度", required = true, dataType = "String") |
| | | private String lon; |
| | | @ApiModelProperty(value = "当前纬度", required = true, dataType = "String") |
| | | private String lat; |
| | | } |
New file |
| | |
| | | package com.dsh.other.model; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/7/17 11:25 |
| | | */ |
| | | @Data |
| | | @ApiModel |
| | | public class QuerySiteListVo { |
| | | @ApiModelProperty("场地id") |
| | | private Integer id; |
| | | @ApiModelProperty("场地名称") |
| | | private String name; |
| | | @ApiModelProperty("场地类型名称") |
| | | private String siteTypeName; |
| | | @ApiModelProperty("门店名称") |
| | | private String storeName; |
| | | @ApiModelProperty("门店地址") |
| | | private String storeAddress; |
| | | @ApiModelProperty("门店经度") |
| | | private String storeLon; |
| | | @ApiModelProperty("门店纬度") |
| | | private String storeLat; |
| | | @ApiModelProperty("距离") |
| | | private Double distance; |
| | | @ApiModelProperty("可预约时间段") |
| | | private String times; |
| | | @ApiModelProperty("预约价格") |
| | | private Double price; |
| | | } |
New file |
| | |
| | | package com.dsh.other.model; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/7/17 17:24 |
| | | */ |
| | | @Data |
| | | @ApiModel |
| | | public class QuerySiteTimes { |
| | | @ApiModelProperty("时间段") |
| | | private String time; |
| | | @ApiModelProperty("是否可选(0=否,1=是)") |
| | | private int selectable; |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.dsh.other.entity.Site; |
| | | import com.dsh.other.model.QuerySiteInfoVo; |
| | | import com.dsh.other.model.QuerySiteList; |
| | | import com.dsh.other.model.QuerySiteListVo; |
| | | import com.dsh.other.model.QuerySiteTimes; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/7/13 16:10 |
| | | */ |
| | | public interface ISiteService extends IService<Site> { |
| | | |
| | | |
| | | /** |
| | | * 获取场地列表 |
| | | * @param querySiteList |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | List<QuerySiteListVo> querySiteList(QuerySiteList querySiteList) throws Exception; |
| | | |
| | | |
| | | /** |
| | | * 获取场地详情 |
| | | * @param id |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | QuerySiteInfoVo querySiteInfo(Integer id) throws Exception; |
| | | |
| | | |
| | | /** |
| | | * 获取场地预约日期数据 |
| | | * @param id |
| | | * @param day |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | List<QuerySiteTimes> querySiteTimes(Integer id, String day) throws Exception; |
| | | } |
New file |
| | |
| | | package com.dsh.other.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.dsh.other.entity.SiteType; |
| | | import com.dsh.other.model.BaseVo; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/7/17 10:58 |
| | | */ |
| | | public interface ISiteTypeService extends IService<SiteType> { |
| | | |
| | | |
| | | /** |
| | | * 获取场地分类 |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | List<BaseVo> querySiteType() throws Exception; |
| | | } |
| | |
| | | package com.dsh.other.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.dsh.other.entity.Site; |
| | | import com.dsh.other.entity.SiteBooking; |
| | | import com.dsh.other.entity.SiteType; |
| | | import com.dsh.other.entity.Store; |
| | | import com.dsh.other.mapper.SiteMapper; |
| | | import com.dsh.other.model.QuerySiteInfoVo; |
| | | import com.dsh.other.model.QuerySiteList; |
| | | import com.dsh.other.model.QuerySiteListVo; |
| | | import com.dsh.other.model.QuerySiteTimes; |
| | | import com.dsh.other.service.ISiteBookingService; |
| | | import com.dsh.other.service.ISiteService; |
| | | import com.dsh.other.service.ISiteTypeService; |
| | | import com.dsh.other.service.StoreService; |
| | | import com.dsh.other.util.GeodesyUtil; |
| | | import com.dsh.other.util.ToolUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | */ |
| | | @Service |
| | | public class SiteServiceImpl extends ServiceImpl<SiteMapper, Site> implements ISiteService { |
| | | |
| | | @Autowired |
| | | private ISiteTypeService siteTypeService; |
| | | |
| | | @Autowired |
| | | private StoreService storeService; |
| | | |
| | | @Autowired |
| | | private ISiteBookingService siteBookingService; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取场地列表 |
| | | * @param querySiteList |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public List<QuerySiteListVo> querySiteList(QuerySiteList querySiteList) throws Exception { |
| | | querySiteList.setPageNum((querySiteList.getPageNum() - 1) *querySiteList.getPageSize()); |
| | | List<QuerySiteListVo> querySiteListVos = this.baseMapper.querySiteList(querySiteList); |
| | | for (QuerySiteListVo querySiteListVo : querySiteListVos) { |
| | | if(ToolUtil.isEmpty(querySiteList.getLon())){ |
| | | querySiteListVo.setDistance(0D); |
| | | continue; |
| | | } |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(querySiteList.getLon() + "," + querySiteList.getLat(), querySiteListVo.getStoreLon() + "," + querySiteListVo.getStoreLat()); |
| | | querySiteListVo.setDistance(distance.get("WGS84")); |
| | | } |
| | | return querySiteListVos; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取场地详情 |
| | | * @param id |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public QuerySiteInfoVo querySiteInfo(Integer id) throws Exception { |
| | | Site site = this.getById(id); |
| | | SiteType siteType = siteTypeService.getById(site.getSiteTypeId()); |
| | | Store store = storeService.getById(site.getStoreId()); |
| | | QuerySiteInfoVo querySiteInfoVo = new QuerySiteInfoVo(); |
| | | querySiteInfoVo.setId(site.getId()); |
| | | querySiteInfoVo.setName(site.getName()); |
| | | querySiteInfoVo.setSiteTypeName(siteType.getName()); |
| | | querySiteInfoVo.setStoreName(store.getName()); |
| | | querySiteInfoVo.setStoreAddress(store.getAddress()); |
| | | querySiteInfoVo.setStoreLon(store.getLon()); |
| | | querySiteInfoVo.setStoreLat(store.getLat()); |
| | | querySiteInfoVo.setStorePhone(store.getPhone()); |
| | | querySiteInfoVo.setCashPrice(site.getCashPrice()); |
| | | querySiteInfoVo.setPlayPaiCoin(site.getPlayPaiCoin()); |
| | | return querySiteInfoVo; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取场地预约日期数据 |
| | | * @param id |
| | | * @param day |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public List<QuerySiteTimes> querySiteTimes(Integer id, String day) throws Exception { |
| | | Site site = this.getById(id); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | Calendar s = Calendar.getInstance(); |
| | | s.setTime(sdf.parse(day + " " + site.getAppointmentStartTime())); |
| | | Calendar e = Calendar.getInstance(); |
| | | e.setTime(sdf.parse(day + " " + site.getAppointmentEndTime())); |
| | | |
| | | int hour = e.get(Calendar.HOUR_OF_DAY); |
| | | int minute = e.get(Calendar.MINUTE); |
| | | List<QuerySiteTimes> list = new ArrayList<>(); |
| | | while (true){ |
| | | int s_hour = s.get(Calendar.HOUR_OF_DAY); |
| | | int s_minute = s.get(Calendar.MINUTE); |
| | | String start = s_hour + ":" + s_minute; |
| | | |
| | | s.set(Calendar.MINUTE, s.get(Calendar.MINUTE) + 30); |
| | | int e_hour = s.get(Calendar.HOUR_OF_DAY); |
| | | int e_minute = s.get(Calendar.MINUTE); |
| | | String end = e_hour + ":" + e_minute; |
| | | |
| | | QuerySiteTimes querySiteTimes = new QuerySiteTimes(); |
| | | querySiteTimes.setTime(start + "-" + end); |
| | | querySiteTimes.setSelectable(1); |
| | | |
| | | SiteBooking siteBooking = siteBookingService.getOne(new QueryWrapper<SiteBooking>().eq("siteId", id).eq("state", 1) |
| | | .in("status", Arrays.asList(3, 4, 5)).last(" and DATE_FORMAT(startTime, '%Y-%m-%d %H:%i') <= '" + day + " " + start + "' and DATE_FORMAT(endTime, '%Y-%m-%d %H:%i') >= '" + day + " " + end + "'")); |
| | | if(null != siteBooking){ |
| | | querySiteTimes.setSelectable(0); |
| | | } |
| | | list.add(querySiteTimes); |
| | | |
| | | if(e_hour == hour && minute == e_minute){ |
| | | break; |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | } |
New file |
| | |
| | | package com.dsh.other.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.dsh.other.entity.SiteType; |
| | | import com.dsh.other.mapper.SiteTypeMapper; |
| | | import com.dsh.other.model.BaseVo; |
| | | import com.dsh.other.service.ISiteTypeService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/7/17 10:59 |
| | | */ |
| | | @Service |
| | | public class SiteTypeServiceImpl extends ServiceImpl<SiteTypeMapper, SiteType> implements ISiteTypeService { |
| | | |
| | | |
| | | /** |
| | | * 获取场地分类 |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public List<BaseVo> querySiteType() throws Exception { |
| | | List<SiteType> siteTypes = this.list(new QueryWrapper<SiteType>().eq("state", 1)); |
| | | List<BaseVo> list = new ArrayList<>(); |
| | | for (SiteType siteType : siteTypes) { |
| | | BaseVo baseVo = new BaseVo(); |
| | | BeanUtils.copyProperties(siteType, baseVo); |
| | | list.add(baseVo); |
| | | } |
| | | return list; |
| | | } |
| | | } |
New file |
| | |
| | | package com.dsh.other.util; |
| | | |
| | | import org.gavaghan.geodesy.Ellipsoid; |
| | | import org.gavaghan.geodesy.GeodeticCalculator; |
| | | import org.gavaghan.geodesy.GeodeticCurve; |
| | | import org.gavaghan.geodesy.GlobalCoordinates; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 计算两个金纬度坐标之间的直线距离 |
| | | */ |
| | | public class GeodesyUtil { |
| | | |
| | | |
| | | /** |
| | | * 获取直线距离 |
| | | * @param fromLonLat |
| | | * @param toLonLat |
| | | * @return |
| | | */ |
| | | public static Map<String, Double> getDistance(String fromLonLat, String toLonLat){ |
| | | String[] from = fromLonLat.split(","); |
| | | String[] to = toLonLat.split(","); |
| | | GlobalCoordinates source = new GlobalCoordinates(Double.valueOf(from[1]), Double.valueOf(from[0])); |
| | | GlobalCoordinates target = new GlobalCoordinates(Double.valueOf(to[1]), Double.valueOf(to[0])); |
| | | double Sphere = getDistanceMeter(source, target, Ellipsoid.Sphere); |
| | | double WGS84 = getDistanceMeter(source, target, Ellipsoid.WGS84); |
| | | double GRS80 = getDistanceMeter(source, target, Ellipsoid.GRS80); |
| | | double GRS67 = getDistanceMeter(source, target, Ellipsoid.GRS67); |
| | | double ANS = getDistanceMeter(source, target, Ellipsoid.ANS); |
| | | double WGS72 = getDistanceMeter(source, target, Ellipsoid.WGS72); |
| | | double Clarke1858 = getDistanceMeter(source, target, Ellipsoid.Clarke1858); |
| | | double Clarke1880 = getDistanceMeter(source, target, Ellipsoid.Clarke1880); |
| | | // System.out.println("Sphere坐标系计算结果:"+Sphere + "米"); |
| | | // System.out.println("WGS84坐标系计算结果:"+WGS84 + "米"); |
| | | // System.out.println("GRS80坐标系计算结果:"+GRS80 + "米"); |
| | | // System.out.println("GRS67坐标系计算结果:"+GRS67 + "米"); |
| | | // System.out.println("ANS坐标系计算结果:"+ANS + "米"); |
| | | // System.out.println("WGS72坐标系计算结果:"+WGS72 + "米"); |
| | | // System.out.println("Clarke1858坐标系计算结果:"+Clarke1858 + "米"); |
| | | // System.out.println("Clarke1880坐标系计算结果:"+Clarke1880 + "米"); |
| | | Map<String, Double> map = new HashMap<>(); |
| | | map.put("Sphere", Sphere); |
| | | map.put("WGS84", WGS84); |
| | | map.put("GRS80", GRS80); |
| | | map.put("GRS67", GRS67); |
| | | map.put("ANS", ANS); |
| | | map.put("WGS72", WGS72); |
| | | map.put("Clarke1858", Clarke1858); |
| | | map.put("Clarke1880", Clarke1880); |
| | | return map; |
| | | } |
| | | |
| | | |
| | | private static double getDistanceMeter(GlobalCoordinates gpsFrom, GlobalCoordinates gpsTo, Ellipsoid ellipsoid){ |
| | | //创建GeodeticCalculator,调用计算方法,传入坐标系、经纬度用于计算距离 |
| | | GeodeticCurve geoCurve = new GeodeticCalculator().calculateGeodeticCurve(ellipsoid, gpsFrom, gpsTo); |
| | | return geoCurve.getEllipsoidalDistance(); |
| | | } |
| | | |
| | | } |
| | |
| | | <mapper namespace="com.dsh.other.mapper.SiteMapper"> |
| | | |
| | | |
| | | <select id="querySiteList" resultType="com.dsh.other.model.QuerySiteListVo"> |
| | | select |
| | | a.id, |
| | | a.`name`, |
| | | c.`name` as siteTypeName, |
| | | b.`name` as storeName, |
| | | b.address as storeAddress, |
| | | b.lon as storeLon, |
| | | b.lat as storeLat, |
| | | CONCAT(a.appointmentStartTime, '-', a.appointmentEndTime) as times, |
| | | a.cashPrice as price |
| | | from t_site a |
| | | left join t_store b on (a.storeId = b.id) |
| | | left join t_site_type c on (a.siteTypeId = c.id) |
| | | where a.state = 1 |
| | | <if test="null != item.startTime and '' != item.startTime and null != item.endTime and '' != item.endTime"> |
| | | and CONCAT(DATE_FORMAT(now, '%Y-%m-%d', ' ', a.appointmentStartTime)) <= CONCAT(DATE_FORMAT(now, '%Y-%m-%d', ' ', #{item.startTime})) and CONCAT(DATE_FORMAT(now, '%Y-%m-%d', ' ', a.appointmentEndTime)) >= CONCAT(DATE_FORMAT(now, '%Y-%m-%d', ' ', #{item.endTime})) |
| | | </if> |
| | | <if test="null != item.siteTypeId"> |
| | | and a.siteTypeId = #{item.siteTypeId} |
| | | </if> |
| | | <if test="null != item.cityCode"> |
| | | and b.cityCode = #{item.cityCode} |
| | | </if> |
| | | <if test="null != item.storeId"> |
| | | and a.storeId = #{item.storeId} |
| | | </if> |
| | | order by a.insertTime desc limit #{item.pageNum}, #{item.pageSize} |
| | | </select> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.dsh.other.mapper.SiteTypeMapper"> |
| | | |
| | | |
| | | </mapper> |