Commit 7b2c365f authored by 周健威's avatar 周健威

Merge branch 'master-modify-cutAmount' into dev

parents 28d83629 ae656f5b
......@@ -88,15 +88,27 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
* @param timeLag 与开始时间的时间差
* @param dicParentKey
*/
public BigDecimal rentRefundProcessCancel(BaseOrder baseOrder, BigDecimal mainItemRealAmount, Long timeLag, String dicParentKey, BigDecimal depositAmount, BigDecimal originalDeductAmount, OrderAccountDetail oad) {
public BigDecimal rentRefundProcessCancel(BaseOrder baseOrder, BigDecimal mainItemRealAmount, Long timeLag, String dicParentKey, BigDecimal depositAmount, BigDecimal originalDeductAmount, OrderAccountDetail oad, BigDecimal topAmount) {
//计算退款金额
//商品价格 - 优惠券减免的价格
BigDecimal originalRefundAmount = BigDecimal.ZERO.add(mainItemRealAmount);
StringBuilder refundDescBuilder = new StringBuilder("取消订单退款:");
StringBuilder orderRefundDescBuilder = new StringBuilder("");
StringBuilder depositRefundDescBuilder = new StringBuilder("");
BigDecimal totalDeductAmount = BigDecimal.ZERO;
if(null == oad) {
oad = new OrderAccountDetail();
}
BigDecimal refundMainGoodsAmount = calculateRefund(originalRefundAmount, timeLag, dicParentKey, refundDescBuilder, oad);
BigDecimal orderDeductAmount = calculateDeduction(originalRefundAmount, timeLag, dicParentKey, orderRefundDescBuilder);
orderDeductAmount = orderDeductAmount.setScale(2, RoundingMode.HALF_UP);
if(topAmount.compareTo(orderDeductAmount) > 0) {
totalDeductAmount = totalDeductAmount.add(orderDeductAmount);
topAmount = topAmount.subtract(orderDeductAmount);
}else {
totalDeductAmount = totalDeductAmount.add(topAmount);
orderDeductAmount = topAmount;
topAmount = BigDecimal.ZERO;
}
BigDecimal refundMainGoodsAmount = originalRefundAmount.subtract(orderDeductAmount);
refundMainGoodsAmount = refundMainGoodsAmount.setScale(2, RoundingMode.HALF_UP);
//退款金额 = 主要商品退款 + (其他商品退款) 即--> 主要商品退款 + (总商品款 - 主要商品款)
......@@ -106,22 +118,41 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
// 押金
BigDecimal originalRefundAmountDeposit = BigDecimal.ZERO.add(depositAmount);
BigDecimal refundAmountDeposit = BigDecimal.ZERO.add(depositAmount);
refundDescBuilder = refundDescBuilder.append(",押金退款:");
if(null != originalDeductAmount && BigDecimal.ZERO.compareTo(originalDeductAmount) < 0) {
//通过原扣除款 计算剩余款
BigDecimal residueAmount = calculateRefund(originalDeductAmount, timeLag, dicParentKey, refundDescBuilder, oad);
residueAmount = residueAmount.setScale(2, RoundingMode.HALF_UP);
BigDecimal depositDeductAmount = calculateDeduction(originalDeductAmount, timeLag, dicParentKey, depositRefundDescBuilder);
depositDeductAmount = depositDeductAmount.setScale(2, RoundingMode.HALF_UP);
if(topAmount.compareTo(depositDeductAmount) > 0) {
totalDeductAmount = totalDeductAmount.add(depositDeductAmount);
topAmount = topAmount.subtract(depositDeductAmount);
}else {
totalDeductAmount = totalDeductAmount.add(topAmount);
depositDeductAmount = topAmount;
topAmount = BigDecimal.ZERO;
}
//返回押金
refundAmountDeposit = originalRefundAmount.subtract(orderDeductAmount);
}
//退款金额 :押金 - (原扣除款 - 剩余款) 即: 押金 - (免费天数对应的钱 - 剩余款)
refundAmountDeposit = originalRefundAmountDeposit.subtract(originalDeductAmount.subtract(residueAmount));
//设置违章款账单
StringBuilder stringBuilder = new StringBuilder("");
if(totalDeductAmount.compareTo(BigDecimal.ZERO) > 0) {
if(orderRefundDescBuilder.length() > 0) {
stringBuilder = orderRefundDescBuilder;
}else {
stringBuilder = depositRefundDescBuilder;
}
oad.getDeductions().add(initDeduction(totalDeductAmount, stringBuilder.toString(), DeductionTypeEnum.VIOLATE_CANCEL, OrderAccountDeduction.ORIGIN_DEPOSIT));
}
//设置订单押金金额
originalRefundAmount = originalRefundAmount.add(originalRefundAmountDeposit);
oad.setDepositAmount(refundAmountDeposit);
refundAmount = refundAmount.add(refundAmountDeposit);
//退款子流程: 订单基础,退款描述, 款金额
refundSubProcess(baseOrder, refundDescBuilder.toString(), originalRefundAmount, refundAmount, AccountTypeEnum.OUT_ORDER_FUND.getCode(), RefundStatusEnum.ALL.getCode(), oad);
refundSubProcess(baseOrder, stringBuilder.toString(), originalRefundAmount, refundAmount, AccountTypeEnum.OUT_ORDER_FUND.getCode(), RefundStatusEnum.ALL.getCode(), oad);
return refundAmount;
}
......@@ -163,11 +194,12 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
}
}
public BigDecimal calculateRefund(BigDecimal goodsAmount, Long timeLag, String dicParentKey, StringBuilder refundDescBuilder, OrderAccountDetail orderAccountDetail) {
public BigDecimal calculateDeduction(BigDecimal goodsAmount, Long timeLag, String dicParentKey, StringBuilder refundDescBuilder) {
BigDecimal refundGoodsAmount = goodsAmount;
if(null == orderAccountDetail) {
orderAccountDetail = new OrderAccountDetail();
}
BigDecimal deductGoodsAmount = goodsAmount;
// if(null == orderAccountDetail) {
// orderAccountDetail = new OrderAccountDetail();
// }
//根据时间处理goodsAmount
//获取出发时间 到现在 距离时间
......@@ -193,13 +225,14 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
}})+ "").toString());
refundDescBuilder = refundDescBuilder.insert(0, names[1]+ ",");
if(goodsAmount.subtract(refundGoodsAmount).compareTo(BigDecimal.ZERO) > 0) {
orderAccountDetail.getDeductions().add(initDeduction(goodsAmount.subtract(refundGoodsAmount), names[1], DeductionTypeEnum.VIOLATE_CANCEL, OrderAccountDeduction.ORIGIN_DEPOSIT));
deductGoodsAmount = goodsAmount.subtract(refundGoodsAmount);
//orderAccountDetail.getDeductions().add(initDeduction(goodsAmount.subtract(refundGoodsAmount), names[1], DeductionTypeEnum.VIOLATE_CANCEL, OrderAccountDeduction.ORIGIN_DEPOSIT));
}
break;
}
}
return refundGoodsAmount;
return deductGoodsAmount;
}
/**
......@@ -336,6 +369,7 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
csv.setModelAmount(orderItem.getUnitPrice());
csv.setUsedAmount(inProgressVO.getUsedAmount());
csv.setUsedDayNum(inProgressVO.getUsedDays());
csv.setUsedfreeDayNum(inProgressVO.getUsedfreeDays());
csv.setUsedFreeAmount(inProgressVO.getUsedFreeDaysAmount());
csv.setHadConpon((StrUtil.isNotBlank(orderMQDTO.getCouponTickerNos())? Boolean.TRUE: Boolean.FALSE));
if(csv.getUsedDayNum() == orderMQDTO.getOrderRentVehicleDetail().getDayNum()) {
......
......@@ -150,7 +150,7 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper,OrderRefund> {
// //商品价格 - 优惠券减免的价格
// BigDecimal originalRefundAmount = BigDecimal.ZERO.add(baseOrder.getGoodsAmount().subtract(baseOrder.getCouponAmount()));
// StringBuilder refundDescBuilder = new StringBuilder("取消订单退款:");
// BigDecimal refundGoodsAmount = calculateRefund(originalRefundAmount, timeLag, dicParentKey, refundDescBuilder);
// BigDecimal refundGoodsAmount = calculateDeduction(originalRefundAmount, timeLag, dicParentKey, refundDescBuilder);
// refundGoodsAmount = refundGoodsAmount.setScale(2, RoundingMode.HALF_UP);
//
// //退款金额
......@@ -176,7 +176,7 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper,OrderRefund> {
// StringBuilder refundDescBuilder = new StringBuilder("取消订单押金退款:");
// if(null != originalDeductAmount && BigDecimal.ZERO.compareTo(originalDeductAmount) < 0) {
// //通过原扣除款 计算剩余款
// BigDecimal residueAmount = calculateRefund(originalDeductAmount, timeLag, dicParentKey, refundDescBuilder);
// BigDecimal residueAmount = calculateDeduction(originalDeductAmount, timeLag, dicParentKey, refundDescBuilder);
// residueAmount = residueAmount.setScale(2, RoundingMode.HALF_UP);
//
// //退款金额 :押金 - (原扣除款 - 剩余款) 即: 押金 - (免费天数对应的钱 - 剩余款)
......@@ -188,7 +188,7 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper,OrderRefund> {
// return refundAmount;
// }
//
// public BigDecimal calculateRefund(BigDecimal goodsAmount, Long timeLag, String dicParentKey, StringBuilder refundDescBuilder) {
// public BigDecimal calculateDeduction(BigDecimal goodsAmount, Long timeLag, String dicParentKey, StringBuilder refundDescBuilder) {
// BigDecimal refundGoodsAmount = goodsAmount;
//
// //根据时间处理goodsAmount
......
......@@ -17,6 +17,7 @@ import com.xxfc.platform.order.pojo.calculate.InProgressVO;
import com.xxfc.platform.order.pojo.mq.OrderMQDTO;
import com.xxfc.platform.order.pojo.price.CancelNoStartVO;
import com.xxfc.platform.order.pojo.price.CancelStartedVO;
import com.xxfc.platform.order.pojo.price.CostDetailExtend;
import com.xxfc.platform.tour.feign.TourFeign;
import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.vehicle.common.RestResponse;
......@@ -171,10 +172,12 @@ public class OrderCancelBiz {
//生成额外的费用明细
CancelStartedVO csv = new CancelStartedVO();
csv.setType(CostDetailExtend.CANCEL_STARTED);
csv.setConsumeAmount(inProgressVO.getConsumeAmount());
csv.setModelAmount(orderItem.getUnitPrice());
csv.setUsedAmount(inProgressVO.getUsedAmount());
csv.setUsedDayNum(inProgressVO.getUsedDays());
csv.setUsedfreeDayNum(inProgressVO.getUsedfreeDays());
csv.setUsedFreeAmount(inProgressVO.getUsedFreeDaysAmount());
csv.setHadConpon((StrUtil.isNotBlank(baseOrder.getCouponTickerNos())? Boolean.TRUE: Boolean.FALSE));
//如果有扣款项,则生成额外的费用明细
......@@ -196,15 +199,13 @@ public class OrderCancelBiz {
//判断是否使用免费天数,并且进行扣款
if(freeDays > 0) {
freeDayAmount = orderItem.getUnitPrice().multiply(new BigDecimal(orvd.getFreeDays()+ ""));
//违约金封顶 租车身份价 * 2天
BigDecimal topAmount = orderItem.getUnitPrice().multiply(new BigDecimal(2+ ""));
if(freeDayAmount.compareTo(topAmount) > 0) {
freeDayAmount = topAmount;
}
}
//违约金封顶 租车身份价 * 2天
BigDecimal topAmount = orderItem.getUnitPrice().multiply(new BigDecimal(2+ ""));
//退款流程
orderAccountBiz.rentRefundProcessCancel(baseOrder, orderItem.getRealAmount(), timeLag, APP_ORDER+ "_"+ RENT_REFUND, orvd.getDeposit(), freeDayAmount, oad);
orderAccountBiz.rentRefundProcessCancel(baseOrder, orderItem.getRealAmount(), timeLag, APP_ORDER+ "_"+ RENT_REFUND, orvd.getDeposit(), freeDayAmount, oad, topAmount);
//如果有扣款项,则生成额外的费用明细
if(oad.getDeductions().size() > 0) {
......@@ -257,7 +258,7 @@ public class OrderCancelBiz {
}
//退款流程
orderAccountBiz.rentRefundProcessCancel(baseOrder, adultItem.getRealAmount().add(childItem.getRealAmount()), timeLag, APP_ORDER+ "_"+ key, BigDecimal.ZERO, BigDecimal.ZERO, oad);
orderAccountBiz.rentRefundProcessCancel(baseOrder, adultItem.getRealAmount().add(childItem.getRealAmount()), timeLag, APP_ORDER+ "_"+ key, BigDecimal.ZERO, BigDecimal.ZERO, oad, BigDecimal.ZERO );
//如果有扣款项,则生成额外的费用明细
if(oad.getDeductions().size() > 0) {
......
......@@ -84,7 +84,7 @@ public class OrderRefundController extends BaseController<OrderRefundBiz,OrderRe
DateTime startTime = DateTime.parse(new DateTime(orderPageVO.getOrderRentVehicleDetail().getStartTime()).toString(CommonConstants.YMR_SLASH_FORMATTER_JODA), CommonConstants.YMR_SLASH_FORMATTER_JODA);
InProgressVO inProgressVO = orderCalculateBiz.inProgressCalculate(orderPageVO, baseOrderBiz.getDaysBetweenDateTime(startTime, nowTime));
// orderRefundAmount = orderAccountBiz.calculateRefund(orderPageVO.getGoodsAmount().subtract(orderPageVO.getCouponAmount())
// orderRefundAmount = orderAccountBiz.calculateDeduction(orderPageVO.getGoodsAmount().subtract(orderPageVO.getCouponAmount())
// , orderPageVO.getOrderRentVehicleDetail().getStartTime() - System.currentTimeMillis()
// , DictionaryKey.APP_ORDER+ "_"+ RENT_REFUND
// , refundDescBuilder);
......@@ -102,7 +102,7 @@ public class OrderRefundController extends BaseController<OrderRefundBiz,OrderRe
// }});
// originalDeductAmount = orderItem.getUnitPrice().multiply(new BigDecimal(orvd.getFreeDays()+ ""));
// }
// BigDecimal residueAmount = orderRefundBiz.calculateRefund(originalDeductAmount, timeLag, APP_ORDER+ "_"+ RENT_REFUND, refundDescBuilder);
// BigDecimal residueAmount = orderRefundBiz.calculateDeduction(originalDeductAmount, timeLag, APP_ORDER+ "_"+ RENT_REFUND, refundDescBuilder);
//扣款 = 违约金 + 消费金额
BigDecimal residueAmount = BigDecimal.ZERO;
//inProgressVO.get
......@@ -119,7 +119,7 @@ public class OrderRefundController extends BaseController<OrderRefundBiz,OrderRe
// if(SYS_TRUE.equals(orderPageVO.getOrderTourDetail().getIsOutside())) {
// key = TOUR_REFUND;
// }
// orderRefundAmount = orderRefundBiz.calculateRefund(orderPageVO.getGoodsAmount().subtract(orderPageVO.getCouponAmount())
// orderRefundAmount = orderRefundBiz.calculateDeduction(orderPageVO.getGoodsAmount().subtract(orderPageVO.getCouponAmount())
// , orderPageVO.getOrderTourDetail().getStartTime() - System.currentTimeMillis()
// , DictionaryKey.APP_ORDER+ "_"+ key
// , refundDescBuilder);
......
......@@ -313,7 +313,7 @@ public class OrderTourService extends AbstractOrderHandle<OrderTourDetailBiz, To
* @return
*/
private void costDetail(TourPriceVO vo, String children) {
OrderTemplate template = orderTemplateBiz.selectByCode(OrderCostEnum.RENT_VEHICLE.getCode());
OrderTemplate template = orderTemplateBiz.selectByCode(OrderCostEnum.TOUR.getCode());
template.setTemplate(orderTemplateBiz.result(template.getTemplate(), new HashMap(){{
put("children", children);
put("paramJson", "");
......
......@@ -3,7 +3,6 @@ package com.xxfc.platform.vehicle.biz;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.constant.*;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import com.xxfc.platform.vehicle.entity.*;
......@@ -74,7 +73,7 @@ public class VehicleActiveService {
ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getCode());
}
//添加出车时间过滤 再出车开始时间前一天至结束时间内可以出车,并且预定记录为已审核状态
checkDateInvalide(departureVo);
checkDateInvalid(departureVo);
Integer MileageLift = vehicle.getMileageLastUpdate();
Integer MileageLift1 = departureVo.getMileage();
if (MileageLift1 == null) {
......@@ -181,6 +180,7 @@ public class VehicleActiveService {
}
public void arrival(VehicleArrivalVo arrivalVo) {
log.info("用户还车操作:arrivalVo = {}", arrivalVo.toString());
Vehicle vehicle = vehicleMapper.selectByPrimaryKey(arrivalVo.getVehicleId());
if (vehicle == null) {
throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getDesc(),
......@@ -194,21 +194,17 @@ public class VehicleActiveService {
// throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getDesc() + ", 车辆状态是:" + getVehicleStatus(vehicle.getStatus(), vehicle.getId()),
// ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getCode());
// }
Integer Mileagerest = vehicle.getMileageLastUpdate();
Integer Mileagerest1 = arrivalVo.getMileage();
if (Mileagerest1 == null) {
Integer MileageRest = vehicle.getMileageLastUpdate();
Integer MileageRest1 = arrivalVo.getMileage();
if (MileageRest1 == null) {
throw new BaseException(ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getDesc(),
ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getCode());
}
if (Mileagerest != null && Mileagerest1 >= Mileagerest) {
if (MileageRest != null && MileageRest1 >= MileageRest) {
VehicleBookRecord vehicleBookRecord = null;
if (arrivalVo.getBookRecordId() != null) {
vehicleBookRecord = vehicleBookRecordBiz.selectById(arrivalVo.getBookRecordId());
updateBookRecordStatus(vehicleBookRecord, 2);
}
// 写入车辆公里数,还车分公司id
vehicle.setMileageLastUpdate(Mileagerest1);
vehicle.setMileageLastUpdate(MileageRest1);
if (vehicleBookRecord != null) {
vehicle.setParkBranchCompanyId(vehicleBookRecord.getRetCompany());
}
......@@ -250,14 +246,23 @@ public class VehicleActiveService {
bookVehicleVo.setBookEndDate(null);
bookVehicleVo.setUnbookStartDate(actualArrivalDate.toString(DATE_TIME_FORMATTER));
bookVehicleVo.setUnbookEndDate(arrivalDate.toString(DATE_TIME_FORMATTER));
bookVehicleVo.setRemark(bookVehicleVo.getRemark() + " 用户提前还车,取消剩余天数, 初始预定结束时间是," + new DateTime(vehicleBookRecord.getBookEndDate()).toString(DATE_TIME_FORMATTER));
vehicleBookRecord.setRemark(bookVehicleVo.getRemark());
try {
Boolean hasSuc = vehicleBiz.unbookVehicle(bookVehicleVo);
if (!hasSuc) {
throw new BaseException(ResCode.VEHICLE_UNBOOK_FAIL.getDesc(), ResCode.VEHICLE_UNBOOK_FAIL.getCode());
}
} catch (Exception e) {
log.info("提前还车失败,bookVehicleVo = {}", bookVehicleVo.toString());
e.printStackTrace();
}
} else if (actualArrivalDate.compareTo(arrivalDate) > 0) {//实际还车时间大于预计还车时间
vehicleBookRecord.setRemark(vehicleBookRecord.getRemark() + " 用户延期还车,实际占用日期");
}
if (arrivalVo.getBookRecordId() != null) {
vehicleBookRecord = vehicleBookRecordBiz.selectById(arrivalVo.getBookRecordId());
updateBookRecordStatus(vehicleBookRecord, 2);
}
departureLog.setMileageEnd(arrivalVo.getMileage());
departureLog.setRecycleMan(arrivalVo.getRecycleMan());
......@@ -307,7 +312,7 @@ public class VehicleActiveService {
}
//添加出车时间过滤 再出车开始时间前一天至结束时间内可以出车,并且预定记录为已审核状态
public void checkDateInvalide(VehicleDepartureVo arrivalVo) {
public void checkDateInvalid(VehicleDepartureVo arrivalVo) {
if (arrivalVo.getBookRecordId() != null) {
VehicleBookRecord vehicleBookRecord = vehicleBookRecordBiz.selectById(arrivalVo.getBookRecordId());
if (vehicleBookRecord != null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment