Commit 2f4629dc authored by jiaorz's avatar jiaorz

Merge remote-tracking branch 'origin/master-background-manager' into master-background-manager

parents 6f9c467a 09ec18bc
package com.xxfc.platform.order.pojo.account;
import com.xxfc.platform.order.contant.enumerate.DeductionTypeEnum;
import lombok.Data;
import org.assertj.core.util.Lists;
......@@ -33,4 +34,19 @@ public class OrderAccountDetail {
public BigDecimal realTotalDeduct() {
return originDepositAmount.add(originOrderAmount).subtract(orderAmount).subtract(depositAmount);
}
public void changeCancelViolate(BigDecimal coverAmount) {
if(null != coverAmount) {
for(OrderAccountDeduction deduction : deductions) {
if(DeductionTypeEnum.VIOLATE_CANCEL.getCode().equals(deduction)) {
//修改取消违约金
//获取差值
BigDecimal diff = coverAmount.subtract(deduction.getAmount());
//修改归还押金金额
setDepositAmount(getDepositAmount().subtract(diff));
deduction.setAmount(coverAmount);
}
}
}
}
}
......@@ -9,6 +9,7 @@ import java.math.BigDecimal;
BigDecimal refundAmount;
BigDecimal realAmount;
BigDecimal cutAmount;
BigDecimal topAmount;
String refundDesc;
public void setRefundAmount(BigDecimal refundAmount) {
......
......@@ -3,6 +3,8 @@ package com.xxfc.platform.order.pojo.order;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class CancelOrderDTO {
@ApiModelProperty(value = "取消原因")
......@@ -10,4 +12,7 @@ public class CancelOrderDTO {
@ApiModelProperty(value = "app用户id")
private String appUserId;
@ApiModelProperty(value = "修改违约金")
private BigDecimal changeViolateAmount;
}
\ No newline at end of file
......@@ -90,11 +90,18 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
/**
* 租车退款流程
* @param baseOrder
* @param orderDeductSource 主要商品(租车费用、旅游费用等)
* @param orderDeductSource 订单款扣除费用源,主要商品(租车费用、旅游费用等)
* @param timeLag 与开始时间的时间差
* @param dicParentKey
* @param dicParentKey 计算违约金的dickey
* @param depositAmount 押金款
* @param depositDeductSource 押金款扣除费用源
* @param oad 账单信息
* @param topAmount 扣款封顶值
* @param orderViolateCoverAmount 订单违约金覆盖值
* @param depositViolateCoverAmount 押金违约金覆盖值
*/
public BigDecimal rentRefundProcessCancel(BaseOrder baseOrder, BigDecimal orderDeductSource, Long timeLag, String dicParentKey, BigDecimal depositAmount, BigDecimal depositDeductSource, OrderAccountDetail oad, BigDecimal topAmount) {
public BigDecimal rentRefundProcessCancel(BaseOrder baseOrder, BigDecimal orderDeductSource, Long timeLag, String dicParentKey, BigDecimal depositAmount, BigDecimal depositDeductSource
, OrderAccountDetail oad, BigDecimal topAmount, BigDecimal orderViolateCoverAmount, BigDecimal depositViolateCoverAmount) {
//原来退款 和 最终退款
BigDecimal originalRefundAmount = BigDecimal.ZERO;
BigDecimal refundAmount = BigDecimal.ZERO;
......@@ -112,6 +119,9 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
if(null != orderDeductSource && BigDecimal.ZERO.compareTo(orderDeductSource) < 0) {
BigDecimal orderDeductAmount = calculateDeduction(orderDeductSource, timeLag, dicParentKey, orderRefundDescBuilder);
orderDeductAmount = orderDeductAmount.setScale(2, RoundingMode.HALF_UP);
if(null != orderViolateCoverAmount) {
orderDeductAmount = orderViolateCoverAmount;
}
if(topAmount.compareTo(orderDeductAmount) > 0) {
totalDeductAmount = totalDeductAmount.add(orderDeductAmount);
topAmount = topAmount.subtract(orderDeductAmount);
......@@ -142,6 +152,9 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
//通过原扣除款 计算剩余款
BigDecimal depositDeductAmount = calculateDeduction(depositDeductSource, timeLag, dicParentKey, depositRefundDescBuilder);
depositDeductAmount = depositDeductAmount.setScale(2, RoundingMode.HALF_UP);
if(null != orderViolateCoverAmount) {
depositDeductAmount = orderViolateCoverAmount;
}
if(topAmount.compareTo(depositDeductAmount) > 0) {
totalDeductAmount = totalDeductAmount.add(depositDeductAmount);
topAmount = topAmount.subtract(depositDeductAmount);
......@@ -182,11 +195,13 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
/**
* 退款子流程
* @param baseOrder
* @param baseOrder 基础订单信息
* @param refundDesc 退款描述
* @param originalRefundAmount 原退款金额
* @param refundAmount 退款金额
* @param refundType 退款类型
* @param refundStatus 退款状态
* @param oad 账单信息
*/
public void refundSubProcess(BaseOrder baseOrder, String refundDesc, BigDecimal originalRefundAmount, BigDecimal refundAmount, Integer refundType, Integer refundStatus, OrderAccountDetail oad) {
String refundTradeNo = null;
......
......@@ -274,6 +274,7 @@ public class OrderCalculateBiz {
StringBuilder refundDescBuilder = new StringBuilder("");
String refundDesc = "";
InProgressVO inProgressVO = new InProgressVO();
BigDecimal topAmount = BigDecimal.ZERO;
switch (orderTypeEnum) {
case RENT_VEHICLE:
......@@ -287,6 +288,7 @@ public class OrderCalculateBiz {
setType(ItemTypeEnum.VEHICLE_MODEL.getCode());
setOrderId(orderPageVO.getId());
}});
topAmount = vehicleItem.getUnitPrice().multiply(new BigDecimal(2+ ""));
if(timeLag < 0 ) {
OrderAccountDetail oad = new OrderAccountDetail();
......@@ -330,6 +332,7 @@ public class OrderCalculateBiz {
BigDecimal adultItemAmount = (null == adultItem)? BigDecimal.ZERO: adultItem.getRealAmount();
BigDecimal childItemAmount = (null == childItem)? BigDecimal.ZERO: childItem.getRealAmount();
topAmount = adultItemAmount.add(childItemAmount);
BigDecimal deductionAmount = orderAccountBiz.calculateDeduction(adultItemAmount.add(childItemAmount)
, orderPageVO.getOrderTourDetail().getStartTime() - System.currentTimeMillis()
......@@ -348,6 +351,7 @@ public class OrderCalculateBiz {
orpv.setRealAmount(orderPageVO.getRealAmount());
orpv.setRefundAmount(totalRefundAmount);
orpv.setCutAmount(totalDeductAmount);
orpv.setTopAmount(topAmount);
return orpv;
}
}
\ No newline at end of file
......@@ -115,7 +115,7 @@ public class OrderCancelBiz {
* @param baseOrder
*/
@Transactional
public void cancel(BaseOrder baseOrder) {
public void cancel(BaseOrder baseOrder, BigDecimal changeViolateAmount) {
OrderRentVehicleDetail orvd = new OrderRentVehicleDetail();
OrderTourDetail otd = new OrderTourDetail();
OrderMemberDetail omd = new OrderMemberDetail();
......@@ -151,6 +151,12 @@ public class OrderCancelBiz {
if(timeLag < 0 ) {
Integer useDays = orderCalculateBiz.getIncludeDays(orvd.getStartTime(), System.currentTimeMillis());
inProgressVO = orderCalculateBiz.calculateOrderComplete(baseOrder, orvd, oad, orderItem, useDays, Boolean.TRUE);
//判断是否修改违约金
if(null != changeViolateAmount) {
oad.changeCancelViolate(changeViolateAmount);
}
//结合
//退款子流程: 订单基础,退款描述,退款金额
orderAccountBiz.refundSubProcess(baseOrder, "", baseOrder.getRealAmount().subtract(orvd.getDeposit()), oad.getDepositAmount().add(oad.getOrderAmount()), AccountTypeEnum.OUT_ORDER_FUND.getCode(), RefundStatusEnum.ALL.getCode(), oad);
......@@ -195,7 +201,7 @@ public class OrderCancelBiz {
BigDecimal topAmount = orderItem.getUnitPrice().multiply(new BigDecimal(2+ ""));
//退款流程
orderAccountBiz.rentRefundProcessCancel(baseOrder, BigDecimal.ZERO, timeLag, APP_ORDER+ "_"+ RENT_REFUND, orvd.getDeposit(), orderItem.getBuyAmount(), oad, topAmount);
orderAccountBiz.rentRefundProcessCancel(baseOrder, BigDecimal.ZERO, timeLag, APP_ORDER+ "_"+ RENT_REFUND, orvd.getDeposit(), orderItem.getBuyAmount(), oad, topAmount, null, changeViolateAmount);
//设置订单数据
//baseOrder.setDamagesAmount(csv.getDamagesAmount());
......@@ -260,7 +266,7 @@ public class OrderCancelBiz {
}
//退款流程
orderAccountBiz.rentRefundProcessCancel(baseOrder, adultItemAmount.add(childItemAmount), timeLag, APP_ORDER+ "_"+ key, BigDecimal.ZERO, BigDecimal.ZERO, oad, adultItemAmount.add(childItemAmount) );
orderAccountBiz.rentRefundProcessCancel(baseOrder, adultItemAmount.add(childItemAmount), timeLag, APP_ORDER+ "_"+ key, BigDecimal.ZERO, BigDecimal.ZERO, oad, adultItemAmount.add(childItemAmount), changeViolateAmount, null);
//如果有扣款项,则生成额外的费用明细
if(oad.getDeductions().size() > 0) {
......
......@@ -247,24 +247,24 @@ public class BaseOrderController extends CommonBaseController implements UserRes
if (StringUtils.isBlank(BaseContextHandler.getUserID())) {
throw new BaseException(ResultCode.AJAX_WECHAT_NOTEXIST_CODE);
}
cancelCommon(no, cancelOrderDto, BaseContextHandler.getUserID());
cancelCommon(no, cancelOrderDto, BaseContextHandler.getUserID(), null);
return ObjectRestResponse.succ();
}
@RequestMapping(value = "/back-stage/cancel/{no}", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "取消订单")
@ApiOperation(value = "后台取消订单")
@IgnoreClientToken
public ObjectRestResponse bgCancel(@PathVariable String no, @RequestBody CancelOrderDTO cancelOrderDto) {
//查询列表数据
if (StringUtils.isBlank(cancelOrderDto.getAppUserId())) {
throw new BaseException(ResultCode.AJAX_WECHAT_NOTEXIST_CODE);
}
cancelCommon(no, cancelOrderDto, cancelOrderDto.getAppUserId());
cancelCommon(no, cancelOrderDto, cancelOrderDto.getAppUserId(), cancelOrderDto.getChangeViolateAmount());
return ObjectRestResponse.succ();
}
private void cancelCommon(String no, CancelOrderDTO cancelOrderDto, String userId) {
private void cancelCommon(String no, CancelOrderDTO cancelOrderDto, String userId, BigDecimal changeViolateAmount) {
BaseOrder dbBaseOrder = baseOrderBiz.selectOne(new BaseOrder() {{
setNo(no);
}});
......@@ -272,7 +272,7 @@ public class BaseOrderController extends CommonBaseController implements UserRes
throw new BaseException(ResultCode.NOTEXIST_CODE);
}
dbBaseOrder.setCancelReason(cancelOrderDto.getCancelReason());
orderCancelBiz.cancel(dbBaseOrder);
orderCancelBiz.cancel(dbBaseOrder, changeViolateAmount);
}
@RequestMapping(value = "/app/unauth/notifyUrl", method = RequestMethod.GET)
......
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