计算价格接口

还车时先判断是手机定位,再判断车辆定位
This commit is contained in:
邱贞招 2024-09-26 08:58:28 +08:00
parent 10a2b15fc6
commit 7578ab49fd
12 changed files with 318 additions and 33 deletions

View File

@ -15,6 +15,7 @@ import com.ruoyi.system.domain.deviceAccessory.RlDeviceAccessory;
import com.ruoyi.system.domain.order.RlOrderQuery; import com.ruoyi.system.domain.order.RlOrderQuery;
import com.ruoyi.system.domain.order.RlOrderVO; import com.ruoyi.system.domain.order.RlOrderVO;
import com.ruoyi.system.domain.query.AuthenticationQuery; import com.ruoyi.system.domain.query.AuthenticationQuery;
import com.ruoyi.system.domain.vo.PriceVO;
import com.ruoyi.system.service.IRlDeviceAccessoryService; import com.ruoyi.system.service.IRlDeviceAccessoryService;
import com.ruoyi.system.service.IRlDeviceService; import com.ruoyi.system.service.IRlDeviceService;
import com.ruoyi.system.service.IRlOrderService; import com.ruoyi.system.service.IRlOrderService;
@ -293,4 +294,27 @@ public class AppVerifyController extends BaseController
return error(); return error();
} }
/**
* 计算价格
*/
@GetMapping("/calculatePrice")
public AjaxResult calculatePrice(@RequestBody RlOrderQuery order)
{
logger.info("【计算价格】请求参数order={}", JSON.toJSONString(order));
if(order.getModelId() == null){
return error("车型id不能为空");
}
if(order.getRuleId() == null){
return error("计费规则id不能为空");
}
if(order.getAgentId() == null){
return error("代理商id不能为空");
}
if(order.getDeliveryMethod() == null){
return error("配送方式不能为空");
}
PriceVO priceVO = orderService.calculatePrice(order);
return AjaxResult.success(priceVO);
}
} }

View File

@ -0,0 +1,21 @@
package com.ruoyi.common.utils.onenet;
import lombok.Data;
@Data
public class LocationVo {
private String lon;//经度
private String lat;//纬度
private Integer status;//电动车状态 0断电1上电运行 2轮动抱死 3超出区域断电远程下发了qlose 解析参数
private Integer bat;//电池电压 "bat":571 ==> 57.1V
private Integer csq;//信号强度
private Integer s;//卫星数量
private Integer q;//质量
}

View File

@ -48,7 +48,7 @@ public class RlOrder extends BaseEntity
private String sn; private String sn;
@Excel(name = "车型id") @Excel(name = "车型id")
private String modelId; private Long modelId;
/** 支付时间 */ /** 支付时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")

View File

@ -7,9 +7,20 @@ public class RlOrderQuery extends RlOrder{
/** 开始时间*/ /** 开始时间*/
private String startTime; private String startTime;
/** 结束时间*/ /** 结束时间*/
private String endTime; private String endTime;
/** 手机号*/ /** 手机号*/
private String phone; private String phone;
/** 还车经度*/
private String lon;
/** 还车纬度*/
private String lat;
/** 店铺id (还车店铺)*/
private Long returnStoreId;
} }

View File

@ -22,10 +22,6 @@ public class RlFeeRule extends BaseEntity
/** id */ /** id */
private Long ruleId; private Long ruleId;
/** 数量 */
@Excel(name = "数量")
private Integer num;
/** 租赁单位 */ /** 租赁单位 */
@Excel(name = "租赁单位") @Excel(name = "租赁单位")
private String rentalUnit; private String rentalUnit;

View File

@ -0,0 +1,21 @@
package com.ruoyi.system.domain.vo;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class PriceVO {
/** 总金额 */
private BigDecimal totalFee = BigDecimal.ZERO;
/** 押金 */
private BigDecimal deposit = BigDecimal.ZERO;
/** 租金 */
private BigDecimal rent = BigDecimal.ZERO;
/** 配送费 */
private BigDecimal deliveryFee = BigDecimal.ZERO;
}

View File

@ -278,6 +278,11 @@ public interface IRlDeviceService extends IService<RlDevice>
* 车辆下线 * 车辆下线
*/ */
Boolean offline(String sn,String status); Boolean offline(String sn,String status);
/**
* 判断是否在店铺附近
*/
Boolean isNearStore(RlOrderQuery orderQuery, RlDevice device);
// //
// /** // /**
// * 根据条件模糊查询车辆信息 // * 根据条件模糊查询车辆信息

View File

@ -4,6 +4,7 @@ import com.ruoyi.common.utils.wx.vo.PrepayResponseVO;
import com.ruoyi.system.domain.order.RlOrder; import com.ruoyi.system.domain.order.RlOrder;
import com.ruoyi.system.domain.order.RlOrderQuery; import com.ruoyi.system.domain.order.RlOrderQuery;
import com.ruoyi.system.domain.order.RlOrderVO; import com.ruoyi.system.domain.order.RlOrderVO;
import com.ruoyi.system.domain.vo.PriceVO;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.util.List;
@ -109,4 +110,9 @@ public interface IRlOrderService
* 押金退款 * 押金退款
*/ */
Boolean depositRefund(String orderNo); Boolean depositRefund(String orderNo);
/**
* 计算价格
*/
PriceVO calculatePrice(RlOrderQuery order);
} }

View File

@ -15,6 +15,7 @@ import com.ruoyi.common.utils.CommonUtil;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.http.HttpUtils; import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.common.utils.map.GeoUtils;
import com.ruoyi.common.utils.onenet.*; import com.ruoyi.common.utils.onenet.*;
import com.ruoyi.system.domain.RlCommandLog; import com.ruoyi.system.domain.RlCommandLog;
import com.ruoyi.system.domain.accessory.RlAccessoryVO; import com.ruoyi.system.domain.accessory.RlAccessoryVO;
@ -22,6 +23,7 @@ import com.ruoyi.system.domain.device.RlDevice;
import com.ruoyi.system.domain.RlOnlineLog; import com.ruoyi.system.domain.RlOnlineLog;
import com.ruoyi.system.domain.device.RlDeviceQuery; import com.ruoyi.system.domain.device.RlDeviceQuery;
import com.ruoyi.system.domain.device.RlDeviceVO; import com.ruoyi.system.domain.device.RlDeviceVO;
import com.ruoyi.system.domain.model.RlModelVO;
import com.ruoyi.system.domain.order.RlOrder; import com.ruoyi.system.domain.order.RlOrder;
import com.ruoyi.system.domain.order.RlOrderQuery; import com.ruoyi.system.domain.order.RlOrderQuery;
import com.ruoyi.system.domain.order.RlOrderVO; import com.ruoyi.system.domain.order.RlOrderVO;
@ -79,6 +81,9 @@ public class RlDeviceServiceImpl extends ServiceImpl<RlDeviceMapper, RlDevice> i
@Autowired @Autowired
private RlStoreService storeService; private RlStoreService storeService;
@Autowired
private ISysConfigService sysConfigService;
// //
// @Autowired // @Autowired
// private IEtFeeRuleService etFeeRuleService; // private IEtFeeRuleService etFeeRuleService;
@ -91,10 +96,10 @@ public class RlDeviceServiceImpl extends ServiceImpl<RlDeviceMapper, RlDevice> i
@Resource @Resource
private IRlTripLogService tripLogService; private IRlTripLogService tripLogService;
//
// @Resource @Resource
// private IEtModelService etModelService; private IRlModelService modelService;
//
@Autowired @Autowired
private ScheduledExecutorService scheduledExecutorService; private ScheduledExecutorService scheduledExecutorService;
@ -1372,6 +1377,12 @@ public class RlDeviceServiceImpl extends ServiceImpl<RlDeviceMapper, RlDevice> i
log.info("【还车关锁】远程关锁失败"); log.info("【还车关锁】远程关锁失败");
throw new ServiceException("远程关锁失败"); throw new ServiceException("远程关锁失败");
} }
/** 8.判断是否在店铺附近 先根据手机定位判断,再跟进车辆定位判断,如果两个都不在,则提示不在附近*/
boolean nearStore = isNearStore(orderQuery, device);
if(!nearStore){
throw new ServiceException("不在附近");
}
}else{ }else{
ResponseVo responseVo = sendCommandWithResp(device.getMac(), token, IotConstants.COMMAND_CLOSE + IotConstants.COMMAND_FREQUENCY_3600, "辅助还车关锁",orderNo); ResponseVo responseVo = sendCommandWithResp(device.getMac(), token, IotConstants.COMMAND_CLOSE + IotConstants.COMMAND_FREQUENCY_3600, "辅助还车关锁",orderNo);
if(responseVo.getCode()!=0){ if(responseVo.getCode()!=0){
@ -1394,6 +1405,9 @@ public class RlDeviceServiceImpl extends ServiceImpl<RlDeviceMapper, RlDevice> i
} }
BigDecimal overdueFee= BigDecimal.ZERO; BigDecimal overdueFee= BigDecimal.ZERO;
/** 6.计算逾期费用 */ /** 6.计算逾期费用 */
if(ObjectUtil.isNull(order.getExpiryTime())){
throw new ServiceException("订单没有到期时间");
}
if (order.getExpiryTime().before(DateUtils.getNowDate())) { if (order.getExpiryTime().before(DateUtils.getNowDate())) {
overdueFee = computeOverdueFee(order, updateOrder); overdueFee = computeOverdueFee(order, updateOrder);
} }
@ -1402,20 +1416,6 @@ public class RlDeviceServiceImpl extends ServiceImpl<RlDeviceMapper, RlDevice> i
if(i==0){ if(i==0){
throw new ServiceException("更新订单状态失败"); throw new ServiceException("更新订单状态失败");
} }
BigDecimal remainingDeposit = order.getDeposit();
/** 7.退押金 */
if (order.getDeposit().compareTo(BigDecimal.ZERO) > 0) {
// 如果 overdueFee 0直接跳过退押金
if (overdueFee.compareTo(BigDecimal.ZERO) > 0) {
// 获取剩余押金
remainingDeposit = remainingDeposit.subtract(overdueFee);
// 判断剩余押金是否为负数如果为负数则剩余押金为 0
if (remainingDeposit.compareTo(BigDecimal.ZERO) < 0) {
remainingDeposit = BigDecimal.ZERO;
}
}
}
log.info("还车成功"); log.info("还车成功");
return Boolean.TRUE; return Boolean.TRUE;
}else{ }else{
@ -1423,6 +1423,144 @@ public class RlDeviceServiceImpl extends ServiceImpl<RlDeviceMapper, RlDevice> i
} }
} }
/**
* 判断是否在店铺附近
*/
@Override
public Boolean isNearStore(RlOrderQuery orderQuery, RlDevice device) {
if (device.getStoreId() != null) {
StoreVo store = storeService.selectSmStoreById(orderQuery.getReturnStoreId());
if (store != null) {
BigDecimal lng = store.getLng();
BigDecimal lat = store.getLat();
String lon2 = orderQuery.getLon(); // 手机位置
String lat2 = orderQuery.getLat();
// 获取可还车的最大距离
double storeDistance = Double.parseDouble(sysConfigService.selectConfigByKey("store.distance"));
// 计算手机与店铺的距离
double distance = GeoUtils.calculateDistance(lat.doubleValue(), lng.doubleValue(), Double.valueOf(lat2), Double.valueOf(lon2));
log.info("【还车】手机与店铺距离: {} 米", distance);
if (distance <= storeDistance) {
return true;
}
// 获取车辆的最新定位
double[] latestLocation = getLatestLocation(device.getMac());
if (ObjectUtil.isNotNull(latestLocation)) {
double longitude1 = latestLocation[1];
double latitude1 = latestLocation[0];
log.info("【还车时根据车辆定位判断是否在停车区】,车辆经度: {},纬度: {}", longitude1, latitude1);
// 计算车辆与店铺的距离
double distanceToStore = GeoUtils.calculateDistance(lat.doubleValue(), lng.doubleValue(), latitude1, longitude1);
log.info("【还车】车辆与店铺距离: {} 米", distanceToStore);
return distanceToStore <= storeDistance;
}
}
}
return false;
}
@SneakyThrows
private double[] getLatestLocation(String mac) {
RlDevice device = deviceMapper.selectDeviceByMac(mac);
String token = Token.getToken();
DataPointRes datapoints = historyDatapoints(mac, token);
if(datapoints.getCode() == 0){
Data data = datapoints.getData();
List<Datastream> datastreams = data.getDevices();
for (Datastream datastream: datastreams) {
List<Datapoint> datapointList = datastream.getDatastreams();
if(ObjectUtil.isNotNull(datapointList)){
for (Datapoint datapoint:datapointList) {
if(datapoint.getId().equals(IotConstants.ONENET_LOCATION)){
String string = JSON.toJSONString(datapoint.getValue());
String at = datapoint.getAt();
if(StrUtil.isNotBlank(string)){
LocationVo locationVo = JSONObject.parseObject(string, LocationVo.class);
log.info("【手动更新】: locationVo---【{}】" , JSON.toJSONString(locationVo));
double[] doubles = CommonUtil.coordinateConvert(locationVo.getLon(), locationVo.getLat());
BigDecimal lat = new BigDecimal(doubles[0]).setScale(8, RoundingMode.HALF_UP);
BigDecimal lon = new BigDecimal(doubles[1]).setScale(8, RoundingMode.HALF_UP);
log.info("转换后的GCJ02经纬度" + lon + "---" + lat);
if(BigDecimal.ZERO.compareTo(lon) != 0 && BigDecimal.ZERO.compareTo(lat) != 0){
/** 计算电量和里程后更新设备*/
int i = updateDevice(at,locationVo, device, lon, lat);
return doubles;
}else{
noLocationUpdateDevice(at,locationVo,device);
}
}
}
}
}
}
}
return null;
}
/** 计算电量和里程后更新设备*/
public int updateDevice(String at,LocationVo locationVo, RlDevice device, BigDecimal lon, BigDecimal lat) {
device.setLatitude(lat.toString());
device.setLongitude(lon.toString());
Integer bat = locationVo.getBat();
BigDecimal divide = new BigDecimal(bat).divide(new BigDecimal(10));
log.info("保存电压:" + divide);
device.setVoltage(divide.toString());//电压
// 根据电压计算续航里程
RlModelVO model = modelService.selectEModelByModelId(device.getModelId());
if(ObjectUtil.isNotNull(model)){
Integer remainingMileage = 0;
if(StrUtil.isNotBlank(device.getVoltage())){
remainingMileage = CommonUtil.getRemainingMileage(device.getVoltage(), model.getFullVoltage(), model.getLowVoltage(), model.getFullEndurance());
}
Integer electricQuantity = CommonUtil.getElectricQuantity(device.getVoltage(), model.getFullVoltage(), model.getLowVoltage());//电量百分百
// device.setRemainingMileage(remainingMileage);
device.setRemainingPower(electricQuantity.toString());
}
device.setLastTime(DateUtils.parseDate(at));
device.setLastLocationTime(DateUtils.parseDate(at));
device.setGps("1");
// 信号强度
device.setSignalStrength(locationVo.getCsq());
device.setSatellites(locationVo.getS());
device.setQuality(locationVo.getQ());
int i = updateLocation(device);
return i;
}
/** 无定位更新设备 */
private void noLocationUpdateDevice(String at,LocationVo locationVo, RlDevice device) {
Integer bat = locationVo.getBat();
BigDecimal divide = new BigDecimal(bat).divide(new BigDecimal(10));
log.info("保存电压:" + divide);
device.setVoltage(divide.toString());//电压
RlModelVO model = modelService.selectEModelByModelId(device.getModelId());
// 根据电压计算续航里程
if(ObjectUtil.isNotNull(model)){
Integer remainingMileage = 0;
if(StrUtil.isNotBlank(device.getVoltage())){
remainingMileage = CommonUtil.getRemainingMileage(device.getVoltage(), model.getFullVoltage(), model.getLowVoltage(), model.getFullEndurance());
}
Integer electricQuantity = CommonUtil.getElectricQuantity(device.getVoltage(), model.getFullVoltage(), model.getLowVoltage());//电量百分百
// device.setRemainingMileage(remainingMileage);
device.setRemainingPower(electricQuantity.toString());
}
device.setLastTime(DateUtils.parseDate(at));
device.setGps("0");
device.setSignalStrength(locationVo.getCsq());
device.setSatellites(0);
device.setQuality(locationVo.getQ());
int i = updateLocation(device);
if(i>0){
log.info("未获取到定位===============保存电压等数值成功===========>" + device.getSn());
}
}
/** 计算逾期费用 */ /** 计算逾期费用 */
private BigDecimal computeOverdueFee(RlOrderVO order, RlOrder updateOrder) { private BigDecimal computeOverdueFee(RlOrderVO order, RlOrder updateOrder) {
String outUnit = order.getOutUnit(); String outUnit = order.getOutUnit();

View File

@ -10,11 +10,14 @@ import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.common.utils.uuid.IdUtils; import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.common.utils.wx.vo.PrepayResponseVO; import com.ruoyi.common.utils.wx.vo.PrepayResponseVO;
import com.ruoyi.system.domain.accessory.RlAccessoryVO; import com.ruoyi.system.domain.accessory.RlAccessoryVO;
import com.ruoyi.system.domain.agent.RlAgent;
import com.ruoyi.system.domain.device.RlDevice; import com.ruoyi.system.domain.device.RlDevice;
import com.ruoyi.system.domain.model.RlModelVO;
import com.ruoyi.system.domain.order.RlOrder; import com.ruoyi.system.domain.order.RlOrder;
import com.ruoyi.system.domain.order.RlOrderQuery; import com.ruoyi.system.domain.order.RlOrderQuery;
import com.ruoyi.system.domain.order.RlOrderVO; import com.ruoyi.system.domain.order.RlOrderVO;
import com.ruoyi.system.domain.rule.RlFeeRule; import com.ruoyi.system.domain.rule.RlFeeRule;
import com.ruoyi.system.domain.vo.PriceVO;
import com.ruoyi.system.mapper.RlOrderMapper; import com.ruoyi.system.mapper.RlOrderMapper;
import com.ruoyi.system.service.*; import com.ruoyi.system.service.*;
import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse; import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
@ -54,6 +57,12 @@ public class RlOrderServiceImpl implements IRlOrderService
@Autowired @Autowired
private IRlDeviceService deviceService; private IRlDeviceService deviceService;
@Resource
private IRlAgentService agentService;
@Autowired
private IRlModelService modelService;
/** /**
* 查询订单 * 查询订单
* *
@ -208,7 +217,7 @@ public class RlOrderServiceImpl implements IRlOrderService
} }
private void setFeeRule(RlOrderQuery order, RlFeeRule feeRule) { private void setFeeRule(RlOrderQuery order, RlFeeRule feeRule) {
order.setNum(feeRule.getNum()); order.setNum(order.getNum());
order.setPrice(feeRule.getPrice()); order.setPrice(feeRule.getPrice());
order.setExplain(feeRule.getExplain()); order.setExplain(feeRule.getExplain());
order.setInstructions(feeRule.getInstructions()); order.setInstructions(feeRule.getInstructions());
@ -223,7 +232,7 @@ public class RlOrderServiceImpl implements IRlOrderService
}else{ }else{
startTime = order.getExpiryTime(); startTime = order.getExpiryTime();
} }
Date expiryTime = DateUtils.getTimeAfterXUnit(startTime, feeRule.getNum(), feeRule.getRentalUnit()); Date expiryTime = DateUtils.getTimeAfterXUnit(startTime, order.getNum(), feeRule.getRentalUnit());
order.setExpiryTime(expiryTime); order.setExpiryTime(expiryTime);
} }
@ -254,6 +263,9 @@ public class RlOrderServiceImpl implements IRlOrderService
*/ */
@Override @Override
public PrepayResponseVO relet(String orderNo, Long ruleId) { public PrepayResponseVO relet(String orderNo, Long ruleId) {
if(StrUtil.isBlank(orderNo)){
throw new RuntimeException("订单号不能为空");
}
RlOrderVO order = orderMapper.selectRlOrderByOrderNo(orderNo); RlOrderVO order = orderMapper.selectRlOrderByOrderNo(orderNo);
RlOrderQuery orderQuery = new RlOrderQuery(); RlOrderQuery orderQuery = new RlOrderQuery();
BeanUtils.copyBeanProp(orderQuery,order); BeanUtils.copyBeanProp(orderQuery,order);
@ -320,7 +332,8 @@ public class RlOrderServiceImpl implements IRlOrderService
RlOrderVO order = orderMapper.selectRlOrderByOrderNo(orderNo); RlOrderVO order = orderMapper.selectRlOrderByOrderNo(orderNo);
BigDecimal deposit = order.getDeposit(); BigDecimal deposit = order.getDeposit();
BigDecimal overdueFee = order.getOverdueFee(); BigDecimal overdueFee = order.getOverdueFee();
BigDecimal remainingDeposit = deposit.subtract(overdueFee); BigDecimal deductionAmount = order.getDeductionAmount();
BigDecimal remainingDeposit = deposit.subtract(overdueFee).subtract(deductionAmount);
if(remainingDeposit.compareTo(BigDecimal.ZERO) <= 0){ if(remainingDeposit.compareTo(BigDecimal.ZERO) <= 0){
return true; return true;
} }
@ -335,5 +348,60 @@ public class RlOrderServiceImpl implements IRlOrderService
return null; return null;
} }
/**
* 计算价格
*/
@Override
public PriceVO calculatePrice(RlOrderQuery order) {
PriceVO priceVO = new PriceVO();
BigDecimal totalFee = BigDecimal.ZERO;
// 押金
deposit(order.getModelId(), priceVO, totalFee);
// 租金
rentFee(order, priceVO, totalFee);
// 配送费
deliveryFee(order.getAgentId(), priceVO, totalFee);
priceVO.setTotalFee(totalFee);
return priceVO;
}
private void deposit(Long modelId, PriceVO priceVO, BigDecimal totalFee) {
RlModelVO rlModelVO = modelService.selectEModelByModelId(modelId);
if(rlModelVO == null){
throw new ServiceException("车型不存在");
}
BigDecimal deposit = rlModelVO.getDeposit();
if(rlModelVO == null){
throw new ServiceException("车型不存在");
}
priceVO.setDeposit(deposit);
totalFee.add(deposit);
}
private void deliveryFee(Long agentId, PriceVO priceVO, BigDecimal totalFee) {
RlAgent agent = agentService.selectRlAgentByAgentId(agentId);
if(agent == null){
throw new ServiceException("代理商不存在");
}
if(!agent.getIsFreeCar()){
BigDecimal deliveryFee = agent.getDeliveryFee();
totalFee.add(deliveryFee);
priceVO.setDeliveryFee(deliveryFee);
}
}
private void rentFee(RlOrderQuery order, PriceVO priceVO, BigDecimal totalFee) {
RlFeeRule feeRule = feeRuleService.selectRlFeeRuleByRuleId(order.getRuleId());
if(feeRule == null){
throw new ServiceException("租赁规则不存在");
}
Integer num = order.getNum();
if(num != null){
BigDecimal rent = feeRule.getPrice().multiply(new BigDecimal(num));
priceVO.setRent(rent);
totalFee.add(rent);
}
}
} }

View File

@ -6,7 +6,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="RlFeeRule" id="RlFeeRuleResult"> <resultMap type="RlFeeRule" id="RlFeeRuleResult">
<result property="ruleId" column="rule_id" /> <result property="ruleId" column="rule_id" />
<result property="num" column="num" />
<result property="rentalUnit" column="rental_unit" /> <result property="rentalUnit" column="rental_unit" />
<result property="price" column="price" /> <result property="price" column="price" />
<result property="explain" column="explain" /> <result property="explain" column="explain" />
@ -18,13 +17,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectRlFeeRuleVo"> <sql id="selectRlFeeRuleVo">
select rule_id, num, rental_unit, price, `explain`, instructions, out_unit, out_price, is_deleted, model_id from rl_fee_rule select rule_id, rental_unit, price, `explain`, instructions, out_unit, out_price, is_deleted, model_id from rl_fee_rule
</sql> </sql>
<select id="selectRlFeeRuleList" parameterType="RlFeeRule" resultMap="RlFeeRuleResult"> <select id="selectRlFeeRuleList" parameterType="RlFeeRule" resultMap="RlFeeRuleResult">
<include refid="selectRlFeeRuleVo"/> <include refid="selectRlFeeRuleVo"/>
<where> <where>
<if test="num != null "> and num = #{num}</if>
<if test="rentalUnit != null and rentalUnit != ''"> and rental_unit = #{rentalUnit}</if> <if test="rentalUnit != null and rentalUnit != ''"> and rental_unit = #{rentalUnit}</if>
<if test="price != null "> and price = #{price}</if> <if test="price != null "> and price = #{price}</if>
<if test="explain != null and explain != ''"> and `explain` = #{explain}</if> <if test="explain != null and explain != ''"> and `explain` = #{explain}</if>
@ -48,7 +46,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertRlFeeRule" parameterType="RlFeeRule" useGeneratedKeys="true" keyProperty="ruleId"> <insert id="insertRlFeeRule" parameterType="RlFeeRule" useGeneratedKeys="true" keyProperty="ruleId">
insert into rl_fee_rule insert into rl_fee_rule
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="num != null">num,</if>
<if test="rentalUnit != null">rental_unit,</if> <if test="rentalUnit != null">rental_unit,</if>
<if test="price != null">price,</if> <if test="price != null">price,</if>
<if test="explain != null">`explain`,</if> <if test="explain != null">`explain`,</if>
@ -59,7 +56,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="modelId != null">model_id,</if> <if test="modelId != null">model_id,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="num != null">#{num},</if>
<if test="rentalUnit != null">#{rentalUnit},</if> <if test="rentalUnit != null">#{rentalUnit},</if>
<if test="price != null">#{price},</if> <if test="price != null">#{price},</if>
<if test="explain != null">#{explain},</if> <if test="explain != null">#{explain},</if>
@ -74,7 +70,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateRlFeeRule" parameterType="RlFeeRule"> <update id="updateRlFeeRule" parameterType="RlFeeRule">
update rl_fee_rule update rl_fee_rule
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="num != null">num = #{num},</if>
<if test="rentalUnit != null">rental_unit = #{rentalUnit},</if> <if test="rentalUnit != null">rental_unit = #{rentalUnit},</if>
<if test="price != null">price = #{price},</if> <if test="price != null">price = #{price},</if>
<if test="explain != null">`explain` = #{explain},</if> <if test="explain != null">`explain` = #{explain},</if>

View File

@ -82,7 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHEN r.rental_unit = 'year' THEN '年租' WHEN r.rental_unit = 'year' THEN '年租'
ELSE r.rental_unit ELSE r.rental_unit
END, END,
'', r.num, '', '', o.num, '',
CASE CASE
WHEN r.rental_unit = 'hours' THEN '小时' WHEN r.rental_unit = 'hours' THEN '小时'
WHEN r.rental_unit = 'day' THEN '天' WHEN r.rental_unit = 'day' THEN '天'