从数据库读取计价规则

main
topsun 2 years ago
parent cfbb91076d
commit c0b7556927

@ -1,7 +1,8 @@
package com.internal.contant;
public enum CommonStatusEnum {
public enum
CommonStatusEnum {
/**
*TOKEN1100 - 1199
*/
@ -11,6 +12,11 @@ public enum CommonStatusEnum {
*
*/
VERIFICATION_CODE_ERROR(1099,"验证码错误"),
/**
*1300-1399
*/
PRICE_RULE_EMPTY(1300,"规则不存在"),
/**
*
*/
@ -24,6 +30,8 @@ public enum CommonStatusEnum {
private int code;
private String message;

@ -0,0 +1,16 @@
package com.internal.dto;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class PriceRule {
private String cityCode;
private String vehicleType;
private Double startFare;
private int startMile;
private double unitPricePerMile;
private double unitPricePerMinute;
}

@ -35,5 +35,16 @@
<groupId>io.github.openfeign</groupId>
<artifactId>feign-httpclient</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.3.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
</dependencies>
</project>

@ -1,5 +1,6 @@
package com.taxi.serviceprice;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@ -8,6 +9,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableDiscoveryClient//服务发现
@EnableFeignClients
@MapperScan("com.taxi.serviceprice.mapper")
public class ServicePriceApplication {
public static void main(String[] args) {

@ -0,0 +1,9 @@
package com.taxi.serviceprice.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.internal.dto.PriceRule;
import org.springframework.stereotype.Repository;
@Repository
public interface PriceRuleMapper extends BaseMapper<PriceRule> {
}

@ -1,13 +1,20 @@
package com.taxi.serviceprice.service;
import com.internal.contant.CommonStatusEnum;
import com.internal.dto.PriceRule;
import com.internal.dto.ResponseResult;
import com.internal.request.ForecastPriceDTO;
import com.internal.response.DirectionResponse;
import com.taxi.serviceprice.mapper.PriceRuleMapper;
import com.taxi.serviceprice.remote.ServiceMapClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
@Slf4j
public class ForecastPriceService {
@ -15,6 +22,9 @@ public class ForecastPriceService {
@Autowired
private ServiceMapClient serviceMapClient;
@Autowired
private PriceRuleMapper priceRuleMapper;
/**
*
* @param depLongitude
@ -42,6 +52,16 @@ public class ForecastPriceService {
log.info("距离"+directionResponse.getData().getDistance());
log.info("时间"+directionResponse.getData().getDuration());
log.info("读取计价规则");
Map<String,Object> queryMap = new HashMap<>();
queryMap.put("city_code","11000");
queryMap.put("vehicle_type","1");
List<PriceRule> pricetRules = priceRuleMapper.selectByMap(queryMap);
log.info("读取计价规则count = "+pricetRules.size());
if(pricetRules.size() < 1){
ResponseResult.fail(CommonStatusEnum.PRICE_RULE_EMPTY);
}else{
}
log.info("根据距离、时长,计价规则;计算价格");
return ResponseResult.success();
}

@ -2,6 +2,11 @@ server:
port: 8084
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/service-price?characterEncoding=utf-8&serverTimezone=GMT%2B8
username: root
password: topsun123
cloud:
nacos:
discovery:

@ -2,6 +2,11 @@ server:
port: 8084
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/service-price?characterEncoding=utf-8&serverTimezone=GMT%2B8
username: root
password: topsun123
cloud:
nacos:
discovery:

Loading…
Cancel
Save