计算价格接口
还车时先判断是手机定位,再判断车辆定位
This commit is contained in:
parent
10a2b15fc6
commit
7578ab49fd
|
@ -15,6 +15,7 @@ import com.ruoyi.system.domain.deviceAccessory.RlDeviceAccessory;
|
|||
import com.ruoyi.system.domain.order.RlOrderQuery;
|
||||
import com.ruoyi.system.domain.order.RlOrderVO;
|
||||
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.IRlDeviceService;
|
||||
import com.ruoyi.system.service.IRlOrderService;
|
||||
|
@ -293,4 +294,27 @@ public class AppVerifyController extends BaseController
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;//质量
|
||||
}
|
|
@ -48,7 +48,7 @@ public class RlOrder extends BaseEntity
|
|||
private String sn;
|
||||
|
||||
@Excel(name = "车型id")
|
||||
private String modelId;
|
||||
private Long modelId;
|
||||
|
||||
/** 支付时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
|
|
|
@ -7,9 +7,20 @@ public class RlOrderQuery extends RlOrder{
|
|||
|
||||
/** 开始时间*/
|
||||
private String startTime;
|
||||
|
||||
/** 结束时间*/
|
||||
private String endTime;
|
||||
|
||||
/** 手机号*/
|
||||
private String phone;
|
||||
|
||||
/** 还车经度*/
|
||||
private String lon;
|
||||
|
||||
/** 还车纬度*/
|
||||
private String lat;
|
||||
|
||||
/** 店铺id (还车店铺)*/
|
||||
private Long returnStoreId;
|
||||
|
||||
}
|
||||
|
|
|
@ -22,10 +22,6 @@ public class RlFeeRule extends BaseEntity
|
|||
/** id */
|
||||
private Long ruleId;
|
||||
|
||||
/** 数量 */
|
||||
@Excel(name = "数量")
|
||||
private Integer num;
|
||||
|
||||
/** 租赁单位 */
|
||||
@Excel(name = "租赁单位")
|
||||
private String rentalUnit;
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -278,6 +278,11 @@ public interface IRlDeviceService extends IService<RlDevice>
|
|||
* 车辆下线
|
||||
*/
|
||||
Boolean offline(String sn,String status);
|
||||
|
||||
/**
|
||||
* 判断是否在店铺附近
|
||||
*/
|
||||
Boolean isNearStore(RlOrderQuery orderQuery, RlDevice device);
|
||||
//
|
||||
// /**
|
||||
// * 根据条件模糊查询车辆信息
|
||||
|
|
|
@ -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.RlOrderQuery;
|
||||
import com.ruoyi.system.domain.order.RlOrderVO;
|
||||
import com.ruoyi.system.domain.vo.PriceVO;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
@ -109,4 +110,9 @@ public interface IRlOrderService
|
|||
* 押金退款
|
||||
*/
|
||||
Boolean depositRefund(String orderNo);
|
||||
|
||||
/**
|
||||
* 计算价格
|
||||
*/
|
||||
PriceVO calculatePrice(RlOrderQuery order);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.ruoyi.common.utils.CommonUtil;
|
|||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.http.HttpUtils;
|
||||
import com.ruoyi.common.utils.map.GeoUtils;
|
||||
import com.ruoyi.common.utils.onenet.*;
|
||||
import com.ruoyi.system.domain.RlCommandLog;
|
||||
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.device.RlDeviceQuery;
|
||||
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.RlOrderQuery;
|
||||
import com.ruoyi.system.domain.order.RlOrderVO;
|
||||
|
@ -79,6 +81,9 @@ public class RlDeviceServiceImpl extends ServiceImpl<RlDeviceMapper, RlDevice> i
|
|||
|
||||
@Autowired
|
||||
private RlStoreService storeService;
|
||||
|
||||
@Autowired
|
||||
private ISysConfigService sysConfigService;
|
||||
//
|
||||
// @Autowired
|
||||
// private IEtFeeRuleService etFeeRuleService;
|
||||
|
@ -91,10 +96,10 @@ public class RlDeviceServiceImpl extends ServiceImpl<RlDeviceMapper, RlDevice> i
|
|||
|
||||
@Resource
|
||||
private IRlTripLogService tripLogService;
|
||||
//
|
||||
// @Resource
|
||||
// private IEtModelService etModelService;
|
||||
//
|
||||
|
||||
@Resource
|
||||
private IRlModelService modelService;
|
||||
|
||||
@Autowired
|
||||
private ScheduledExecutorService scheduledExecutorService;
|
||||
|
||||
|
@ -1372,6 +1377,12 @@ public class RlDeviceServiceImpl extends ServiceImpl<RlDeviceMapper, RlDevice> i
|
|||
log.info("【还车关锁】远程关锁失败");
|
||||
throw new ServiceException("远程关锁失败");
|
||||
}
|
||||
|
||||
/** 8.判断是否在店铺附近 先根据手机定位判断,再跟进车辆定位判断,如果两个都不在,则提示不在附近*/
|
||||
boolean nearStore = isNearStore(orderQuery, device);
|
||||
if(!nearStore){
|
||||
throw new ServiceException("不在附近");
|
||||
}
|
||||
}else{
|
||||
ResponseVo responseVo = sendCommandWithResp(device.getMac(), token, IotConstants.COMMAND_CLOSE + IotConstants.COMMAND_FREQUENCY_3600, "辅助还车关锁",orderNo);
|
||||
if(responseVo.getCode()!=0){
|
||||
|
@ -1394,6 +1405,9 @@ public class RlDeviceServiceImpl extends ServiceImpl<RlDeviceMapper, RlDevice> i
|
|||
}
|
||||
BigDecimal overdueFee= BigDecimal.ZERO;
|
||||
/** 6.计算逾期费用 */
|
||||
if(ObjectUtil.isNull(order.getExpiryTime())){
|
||||
throw new ServiceException("订单没有到期时间");
|
||||
}
|
||||
if (order.getExpiryTime().before(DateUtils.getNowDate())) {
|
||||
overdueFee = computeOverdueFee(order, updateOrder);
|
||||
}
|
||||
|
@ -1402,20 +1416,6 @@ public class RlDeviceServiceImpl extends ServiceImpl<RlDeviceMapper, RlDevice> i
|
|||
if(i==0){
|
||||
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("还车成功");
|
||||
return Boolean.TRUE;
|
||||
}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) {
|
||||
String outUnit = order.getOutUnit();
|
||||
|
|
|
@ -10,11 +10,14 @@ import com.ruoyi.common.utils.bean.BeanUtils;
|
|||
import com.ruoyi.common.utils.uuid.IdUtils;
|
||||
import com.ruoyi.common.utils.wx.vo.PrepayResponseVO;
|
||||
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.model.RlModelVO;
|
||||
import com.ruoyi.system.domain.order.RlOrder;
|
||||
import com.ruoyi.system.domain.order.RlOrderQuery;
|
||||
import com.ruoyi.system.domain.order.RlOrderVO;
|
||||
import com.ruoyi.system.domain.rule.RlFeeRule;
|
||||
import com.ruoyi.system.domain.vo.PriceVO;
|
||||
import com.ruoyi.system.mapper.RlOrderMapper;
|
||||
import com.ruoyi.system.service.*;
|
||||
import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
|
||||
|
@ -54,6 +57,12 @@ public class RlOrderServiceImpl implements IRlOrderService
|
|||
@Autowired
|
||||
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) {
|
||||
order.setNum(feeRule.getNum());
|
||||
order.setNum(order.getNum());
|
||||
order.setPrice(feeRule.getPrice());
|
||||
order.setExplain(feeRule.getExplain());
|
||||
order.setInstructions(feeRule.getInstructions());
|
||||
|
@ -223,7 +232,7 @@ public class RlOrderServiceImpl implements IRlOrderService
|
|||
}else{
|
||||
startTime = order.getExpiryTime();
|
||||
}
|
||||
Date expiryTime = DateUtils.getTimeAfterXUnit(startTime, feeRule.getNum(), feeRule.getRentalUnit());
|
||||
Date expiryTime = DateUtils.getTimeAfterXUnit(startTime, order.getNum(), feeRule.getRentalUnit());
|
||||
order.setExpiryTime(expiryTime);
|
||||
}
|
||||
|
||||
|
@ -254,6 +263,9 @@ public class RlOrderServiceImpl implements IRlOrderService
|
|||
*/
|
||||
@Override
|
||||
public PrepayResponseVO relet(String orderNo, Long ruleId) {
|
||||
if(StrUtil.isBlank(orderNo)){
|
||||
throw new RuntimeException("订单号不能为空");
|
||||
}
|
||||
RlOrderVO order = orderMapper.selectRlOrderByOrderNo(orderNo);
|
||||
RlOrderQuery orderQuery = new RlOrderQuery();
|
||||
BeanUtils.copyBeanProp(orderQuery,order);
|
||||
|
@ -320,7 +332,8 @@ public class RlOrderServiceImpl implements IRlOrderService
|
|||
RlOrderVO order = orderMapper.selectRlOrderByOrderNo(orderNo);
|
||||
BigDecimal deposit = order.getDeposit();
|
||||
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){
|
||||
return true;
|
||||
}
|
||||
|
@ -335,5 +348,60 @@ public class RlOrderServiceImpl implements IRlOrderService
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<resultMap type="RlFeeRule" id="RlFeeRuleResult">
|
||||
<result property="ruleId" column="rule_id" />
|
||||
<result property="num" column="num" />
|
||||
<result property="rentalUnit" column="rental_unit" />
|
||||
<result property="price" column="price" />
|
||||
<result property="explain" column="explain" />
|
||||
|
@ -18,13 +17,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</resultMap>
|
||||
|
||||
<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>
|
||||
|
||||
<select id="selectRlFeeRuleList" parameterType="RlFeeRule" resultMap="RlFeeRuleResult">
|
||||
<include refid="selectRlFeeRuleVo"/>
|
||||
<where>
|
||||
<if test="num != null "> and num = #{num}</if>
|
||||
<if test="rentalUnit != null and rentalUnit != ''"> and rental_unit = #{rentalUnit}</if>
|
||||
<if test="price != null "> and price = #{price}</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 into rl_fee_rule
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="num != null">num,</if>
|
||||
<if test="rentalUnit != null">rental_unit,</if>
|
||||
<if test="price != null">price,</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>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="num != null">#{num},</if>
|
||||
<if test="rentalUnit != null">#{rentalUnit},</if>
|
||||
<if test="price != null">#{price},</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 rl_fee_rule
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="num != null">num = #{num},</if>
|
||||
<if test="rentalUnit != null">rental_unit = #{rentalUnit},</if>
|
||||
<if test="price != null">price = #{price},</if>
|
||||
<if test="explain != null">`explain` = #{explain},</if>
|
||||
|
|
|
@ -82,7 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
WHEN r.rental_unit = 'year' THEN '年租'
|
||||
ELSE r.rental_unit
|
||||
END,
|
||||
'(', r.num, '',
|
||||
'(', o.num, '',
|
||||
CASE
|
||||
WHEN r.rental_unit = 'hours' THEN '小时'
|
||||
WHEN r.rental_unit = 'day' THEN '天'
|
||||
|
|
Loading…
Reference in New Issue
Block a user