Commit 945850ee authored by jiaorz's avatar jiaorz

Merge remote-tracking branch 'origin/master-modify-cutAmount' into master-modify-cutAmount

parents 091f3b0d 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;
}
/**
......
......@@ -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
......
......@@ -199,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) {
......@@ -260,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", "");
......
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