Commit c608e6ab authored by jiaorz's avatar jiaorz

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

# Conflicts:
#	xx-order/xx-order-server/src/main/java/com/xxfc/platform/order/biz/OrderAccountBiz.java
parents 97e54217 20c9b184
......@@ -4,7 +4,7 @@ import java.util.HashMap;
import java.util.Map;
public enum DeductionTypeEnum {
//账款类型 1--违约金;2--消费金额;3--赔偿金(定损);4--违章扣款
//账款类型 1--违约金;2--消费金额;3--赔偿金(定损);4--违章相关
VIOLATE_CANCEL(101, "提前取消违约金"),
VIOLATE_ADVANCE(102, "提前还车违约金"),
VIOLATE_DELAY(103, "延迟还车违约金"),
......
......@@ -7,6 +7,9 @@ import java.util.List;
@Data
public class DedDetailDTO {
//public static final int TYPE_VIOLATE_ADVANCE = 1;
/**
* : 扣除项名称
*/
......
......@@ -9,6 +9,8 @@ public class OrderAccountDeduction {
public static final int ORIGIN_ORDER = 1;
public static final int ORIGIN_DEPOSIT = 2;
public static final int ORIGIN_ORDER_DEPOSIT = 3;
public static final int ORIGIN_DEPOSIT_ORDERß = 4;
/**
* 名称
......
......@@ -8,7 +8,25 @@ import java.util.List;
@Data
public class OrderAccountDetail {
/**
* 实际返回订单款
*/
BigDecimal orderAmount;
/**
* 实际返回押金款
*/
BigDecimal depositAmount;
/**
* 原来要返回的订单款
*/
BigDecimal originOrderAmount;
/**
* 原来要返回的押金款
*/
BigDecimal originDepositAmount;
/**
* 扣款列表
*/
List<OrderAccountDeduction> deductions = Lists.newArrayList();
}
......@@ -294,18 +294,31 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
}
OrderAccountDetail oad = new OrderAccountDetail();
InProgressVO inProgressVO = orderCalculateBiz.inProgressCalculate(orderMQDTO, orderItem, orderMQDTO.getOrderRentVehicleDetail().getFreeDays()
, orderMQDTO.getOrderRentVehicleDetail().getUsedDay(), oad);
orderCalculateBiz.calculateOrderComplete(orderMQDTO, orderMQDTO.getOrderRentVehicleDetail(), oad, orderItem, orderMQDTO.getOrderRentVehicleDetail().getUsedDay());
//还车扣除款 剩余的 钱,再减去违章预备金
oad.getDeductions().add(new OrderAccountDeduction(){{
setOrigin(OrderAccountDeduction.ORIGIN_DEPOSIT);
setAmount(illegalReserve);
setType(DeductionTypeEnum.VIOLATE_TRAFFIC_KEEP.getCode());
}});
oad.getDeductions().add(
initDeduction(illegalReserve, "违章保证金", DeductionTypeEnum.VIOLATE_TRAFFIC_KEEP, OrderAccountDeduction.ORIGIN_DEPOSIT)
);
oad.getDeductions().add(
initDeduction(crosstown.getDeductionCost(), "定损赔偿金", DeductionTypeEnum.DAMAGES, OrderAccountDeduction.ORIGIN_DEPOSIT)
);
//剩余押金 -
oad.setDepositAmount(oad.getDepositAmount().subtract(illegalReserve).subtract(crosstown.getDeductionCost()));
handleCrosstownDetail(crosstown, oad);
BigDecimal refundAmont = crosstown.getRestDeposit().subtract(illegalReserve);
BigDecimal originalRefundAmount = crosstown.getRestDeposit().add(crosstown.getDeductionCost()).subtract(illegalReserve);
String refundDesc = "退还押金:"+ refundAmont.toString()+ "(已扣除 违章预备金:"+ illegalReserve.toString();
refundDesc = handleDed(crosstown, refundDesc);
refundDesc += ")";
refundTrigger(orderMQDTO, orderMQDTO.getOrderRentVehicleDetail(), illegalReserve, originalRefundAmount, refundAmont, refundDesc, RefundStatusEnum.RESIDUE_ILLEGAL.getCode(), RefundTypeEnum.PART_DEPOSIT, oad);
orderDepositRefundRecordBiz.completeRecordStatus(crosstown.getId(), depositRefundRecordStatus);
orderMsgBiz.handelMsgDeposit(orderMQDTO.getOrderRentVehicleDetail(), orderMQDTO, userFeign.userDetailById(orderMQDTO.getUserId()).getData());
}
}
private String handleDed(OrderVehicleCrosstown crosstown, String refundDesc) {
try{
if(null != crosstown.getDedDetail()) {
List<DedDetailDTO> dddList = JSONUtil.toList(JSONUtil.parseArray(crosstown.getDedDetail()), DedDetailDTO.class);
......@@ -316,14 +329,29 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
}catch (Exception e) {
log.error("crosstown.getDedDetail() crosstown id :"+crosstown.getId() +" 转换失败");
}
refundDesc += ")";
refundTrigger(orderMQDTO, orderMQDTO.getOrderRentVehicleDetail(), illegalReserve, originalRefundAmount, refundAmont, refundDesc, RefundStatusEnum.RESIDUE_ILLEGAL.getCode(), RefundTypeEnum.PART_DEPOSIT, null);
return refundDesc;
}
// DepositRefundRecord depositRefundRecord = orderDepositRefundRecordBiz.findByCrossIdAndStatus(crosstown.getId(), depositRefundRecordStatus);
// depositRefundRecord.setIscomplete(Boolean.TRUE);
// orderDepositRefundRecordBiz.updateSelectiveById(depositRefundRecord);
orderDepositRefundRecordBiz.completeRecordStatus(crosstown.getId(), depositRefundRecordStatus);
orderMsgBiz.handelMsgDeposit(orderMQDTO.getOrderRentVehicleDetail(), orderMQDTO, userFeign.userDetailById(orderMQDTO.getUserId()).getData());
private void handleCrosstownDetail(OrderVehicleCrosstown crosstown, OrderAccountDetail oad) {
try{
if(null != crosstown.getViolateDetail()) {
List<DedDetailDTO> dddList = JSONUtil.toList(JSONUtil.parseArray(crosstown.getViolateDetail()), DedDetailDTO.class);
for(DedDetailDTO vio : dddList) {
if(OrderViolateEnum.BEFORE.getCode().equals(vio.getType())) {
for(OrderAccountDeduction deduction : oad.getDeductions()) {
if(DeductionTypeEnum.VIOLATE_ADVANCE.getCode().equals(deduction.getType())) {
deduction.setName(vio.getDeductions());
BigDecimal diff = vio.getCost().subtract(deduction.getAmount());
//修改归还押金金额
oad.setDepositAmount(oad.getDepositAmount().subtract(diff));
deduction.setAmount(vio.getCost());
}
}
}
}
}
}catch (Exception e) {
log.error("crosstown.getViolateDetail() crosstown id :"+crosstown.getId() +" 转换失败");
}
}
}
\ No newline at end of file
......@@ -126,7 +126,7 @@ public class OrderCalculateBiz {
residueDays = 2;
}
inProgressVO.setViolateAmount(orderItem.getUnitPrice().multiply(new BigDecimal((residueDays + ""))));
OrderAccountDeduction violateDeduction = orderAccountBiz.initDeduction(inProgressVO.getViolateAmount(), "违约金", DeductionTypeEnum.VIOLATE_CANCEL, OrderAccountDeduction.ORIGIN_DEPOSIT);
OrderAccountDeduction violateDeduction = orderAccountBiz.initDeduction(inProgressVO.getViolateAmount(), "违约金", DeductionTypeEnum.VIOLATE_ADVANCE, OrderAccountDeduction.ORIGIN_DEPOSIT);
oad.getDeductions().add(violateDeduction);
}else if(residueDays < 0){
//如果订单 出发中 或者 已完成 或者定损中
......@@ -139,7 +139,7 @@ public class OrderCalculateBiz {
}
//超过的天数 * 200% * 单价
inProgressVO.setViolateAmount(orderItem.getUnitPrice().multiply(new BigDecimal(2+ "")).multiply(new BigDecimal((overDays + ""))));
OrderAccountDeduction violateDeduction = orderAccountBiz.initDeduction(inProgressVO.getViolateAmount(), "违约金", DeductionTypeEnum.VIOLATE_CANCEL, OrderAccountDeduction.ORIGIN_DEPOSIT);
OrderAccountDeduction violateDeduction = orderAccountBiz.initDeduction(inProgressVO.getViolateAmount(), "违约金", DeductionTypeEnum.VIOLATE_DELAY, OrderAccountDeduction.ORIGIN_DEPOSIT);
oad.getDeductions().add(violateDeduction);
}
}
......@@ -155,4 +155,13 @@ public class OrderCalculateBiz {
Integer freeDays = (null == orderItem.getCutNum())?0 :orderItem.getCutNum();
return inProgressCalculate(baseOrder, orderItem, freeDays, useDays, null);
}
public InProgressVO calculateOrderComplete(BaseOrder baseOrder, OrderRentVehicleDetail orvd, OrderAccountDetail oad, OrderItem orderItem, Integer useDays) {
InProgressVO inProgressVO = inProgressCalculate(baseOrder, orderItem, orvd.getFreeDays(), useDays, oad);
oad.setDepositAmount(orvd.getDeposit().subtract(inProgressVO.getExtraAmount()).subtract(inProgressVO.getViolateAmount()));
oad.setOrderAmount(inProgressVO.getRefundOrderAmount());
oad.setOriginDepositAmount(orvd.getDeposit());
oad.setOriginOrderAmount(baseOrder.getRealAmount());
return inProgressVO;
}
}
\ No newline at end of file
......@@ -113,7 +113,7 @@ public class OrderCancelBiz {
setVersion(baseOrder.getVersion());
}};
BaseOrder hasUpdateOrder = baseOrderBiz.updateSelectiveByIdReT(updateOrder);
InProgressVO inProgressVO = new InProgressVO();
InProgressVO inProgressVO = null;
OrderAccountDetail oad = new OrderAccountDetail();
//触发退款流程
......@@ -145,9 +145,7 @@ public class OrderCancelBiz {
//计算:使用天数 当前时间 - 开始时间的0时0分0秒
Long useTimeLag = System.currentTimeMillis() - beginOfStartDay;
Integer useDays = new BigDecimal(useTimeLag + "").divide(new BigDecimal((24 * 60 * 60 * 1000)+ "")).setScale(0, BigDecimal.ROUND_UP).intValue();
inProgressVO = orderCalculateBiz.inProgressCalculate(baseOrder, orderItem, freeDays, useDays, oad);
oad.setDepositAmount(orvd.getDeposit().subtract(inProgressVO.getExtraAmount()).subtract(inProgressVO.getViolateAmount()));
oad.setOrderAmount(inProgressVO.getRefundOrderAmount());
inProgressVO = orderCalculateBiz.calculateOrderComplete(baseOrder, orvd, oad, orderItem, useDays);
//结合
//退款子流程: 订单基础,退款描述,退款金额
orderAccountBiz.refundSubProcess(baseOrder, "", baseOrder.getRealAmount().subtract(orvd.getDeposit()), oad.getDepositAmount().add(oad.getOrderAmount()), RefundTypeEnum.ORDER_FUND.getCode(), RefundStatusEnum.ALL.getCode(), oad);
......@@ -233,7 +231,8 @@ public class OrderCancelBiz {
//取消租车免费天数使用
if(null != orvd.getFreeDays() && orvd.getFreeDays() > 0) {
int result = userFeign.memberDays(baseOrder.getUserId(), orvd.getFreeDays(), UserFeign.MEMBER_DAYS_WITHDRAW);
Integer freeDays = (null == inProgressVO) ? orvd.getFreeDays(): inProgressVO.getBackFreeDays();
int result = userFeign.memberDays(baseOrder.getUserId(), freeDays, UserFeign.MEMBER_DAYS_WITHDRAW);
if(result < 0) {
throw new BaseException(ResultCode.FAILED_CODE);
}
......
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