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

Merge branch 'feature_chw_zjw' into dev-chw

parents fec6db00 2ce97581
......@@ -376,4 +376,7 @@ public class BaseOrder implements Serializable {
@Column(name = "insure_status")
private Integer insureStatus;
@Column(name = "insure_amount")
private BigDecimal insureAmount;
}
......@@ -126,6 +126,10 @@ public class OrderItem implements Serializable {
@ApiModelProperty(value = "真实的总价")
private BigDecimal realAmount;
public void setRealAmount(BigDecimal realAmount) {
this.realAmount = realAmount;
}
/**
* 订单id
*/
......
......@@ -104,7 +104,7 @@ public class OrderPersonInsurance implements Serializable {
*/
@Column(name = "pay_time")
@ApiModelProperty(value = "支付时间")
private Long paytime;
private Long payTime;
/**
* 退款时间
......
......@@ -95,4 +95,16 @@ public class RentVehiclePriceVO extends OrderPriceVO{
//标记是否单价一样
private Integer sameUnitPrice = 1;
//是否买人身保险
private Integer needPersonInsurance = 0;
//保险个数
private Integer personInsureNum = 0;
//保险单价
private BigDecimal personInsurePrice = BigDecimal.ZERO;
//保险总价
private BigDecimal personInsureAmount = BigDecimal.ZERO;
}
......@@ -51,6 +51,7 @@ import java.util.*;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_FALSE;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE;
import static com.xxfc.platform.order.entity.BaseOrder.INSURE_STATUS_CNL;
import static com.xxfc.platform.order.entity.OrderPersonInsurance.*;
import static com.xxfc.platform.order.contant.enumerate.AccountTypeEnum.OUT_RESIDUE_ORDER;
import static com.xxfc.platform.order.pojo.account.OrderAccountDeduction.ORIGIN_DEPOSIT;
......@@ -137,6 +138,14 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
if(null != orderDeductSource && BigDecimal.ZERO.compareTo(orderDeductSource) < 0) {
BigDecimal orderDeductAmount = calculateDeduction(orderDeductSource, timeLag, dicParentKey, orderRefundDescBuilder);
Integer dayLag = Long.valueOf(timeLag/(1000L * 60L * 60L * 24L)).intValue();
if(dayLag <= 0 && baseOrder.getInsureAmount().compareTo(BigDecimal.ZERO) > 0) {
//扣钱
orderDeductAmount = orderDeductAmount.add(baseOrder.getInsureAmount());
orderRefundDescBuilder = orderRefundDescBuilder.insert(0, "小于24小时扣除保险费");
}
//如果属于免扣费情况
if(noDeduct) {
orderDeductAmount = BigDecimal.ZERO;
......@@ -172,33 +181,33 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
BigDecimal originalDepositRefundAmount = BigDecimal.ZERO.add(depositAmount);
BigDecimal depositRefundAmount = BigDecimal.ZERO.add(depositAmount);
if(null != depositDeductSource && BigDecimal.ZERO.compareTo(depositDeductSource) < 0) {
//通过原扣除款 计算剩余款
BigDecimal depositDeductAmount = calculateDeduction(depositDeductSource, timeLag, dicParentKey, depositRefundDescBuilder);
//如果属于免扣费情况
if(noDeduct) {
depositDeductAmount = BigDecimal.ZERO;
depositRefundDescBuilder = new StringBuilder("");
}
depositDeductAmount = depositDeductAmount.setScale(2, RoundingMode.HALF_UP);
if(null != orderViolateCoverAmount) {
depositDeductAmount = orderViolateCoverAmount;
}
if (null != depositViolateCoverAmount) {
depositDeductAmount = depositViolateCoverAmount;
}
if(topAmount.compareTo(depositDeductAmount) > 0) {
totalDeductAmount = totalDeductAmount.add(depositDeductAmount);
topAmount = topAmount.subtract(depositDeductAmount);
}else {
totalDeductAmount = totalDeductAmount.add(topAmount);
depositDeductAmount = topAmount;
topAmount = BigDecimal.ZERO;
}
//返回押金
depositRefundAmount = originalDepositRefundAmount.subtract(depositDeductAmount);
}
// if(null != depositDeductSource && BigDecimal.ZERO.compareTo(depositDeductSource) < 0) {
// //通过原扣除款 计算剩余款
// BigDecimal depositDeductAmount = calculateDeduction(depositDeductSource, timeLag, dicParentKey, depositRefundDescBuilder);
// //如果属于免扣费情况
// if(noDeduct) {
// depositDeductAmount = BigDecimal.ZERO;
// depositRefundDescBuilder = new StringBuilder("");
// }
// depositDeductAmount = depositDeductAmount.setScale(2, RoundingMode.HALF_UP);
// if(null != orderViolateCoverAmount) {
// depositDeductAmount = orderViolateCoverAmount;
// }
// if (null != depositViolateCoverAmount) {
// depositDeductAmount = depositViolateCoverAmount;
// }
// if(topAmount.compareTo(depositDeductAmount) > 0) {
// totalDeductAmount = totalDeductAmount.add(depositDeductAmount);
// topAmount = topAmount.subtract(depositDeductAmount);
// }else {
// totalDeductAmount = totalDeductAmount.add(topAmount);
// depositDeductAmount = topAmount;
// topAmount = BigDecimal.ZERO;
// }
//
// //返回押金
// depositRefundAmount = originalDepositRefundAmount.subtract(depositDeductAmount);
// }
//设置违章款账单
StringBuilder stringBuilder = new StringBuilder("");
......
......@@ -123,6 +123,10 @@ public class OrderCalculateBiz implements CalculateInterface {
//其他消费金额 = 商品真实价格 - 主要商品真实价格 = (商品价格 - 优惠价格)- 主要商品真实价格
BigDecimal otherItemRealAmount = goodsRealAmount.subtract(vehicleItemDTO.getRealAmount());
// //人身保险费用处理
// Long dayLong = 1000L * 60L * 60L * 24L;
// if()
InProgressVO inProgressVO = new InProgressVO();
inProgressVO.setUsedDays(useDays);
......
......@@ -3,6 +3,7 @@ package com.xxfc.platform.order.biz.inner;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
......@@ -44,6 +45,8 @@ import java.util.List;
import java.util.Map;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE;
import static com.xxfc.platform.order.entity.OrderPersonInsurance.STATUS_CNL;
import static com.xxfc.platform.order.entity.OrderPersonInsurance.STATUS_PAY;
import static com.xxfc.platform.universal.constant.DictionaryKey.*;
/**
......@@ -93,6 +96,9 @@ public class OrderCancelBiz {
@Autowired
SpecialRentBiz specialRentBiz;
@Autowired
OrderPersonInsuranceBiz orderPersonInsuranceBiz;
@Autowired
RabbitProduct rabbitProduct;
......@@ -264,7 +270,8 @@ public class OrderCancelBiz {
//退款流程
//违约金封顶 租车身份价 * 2天
orderAccountBiz.rentRefundProcessCancel(baseOrder, BigDecimal.ZERO, timeLag, APP_ORDER+ "_"+ RENT_REFUND, orvd.getDeposit(), vehicleItemDTO.getBuyAmount(), oad, vehicleItemDTO.getTopAmount(0), null, changeViolateAmount, (!overCancelBuffer));
orderAccountBiz.rentRefundProcessCancel(baseOrder, vehicleItemDTO.getBuyAmount(), timeLag, APP_ORDER+ "_"+ RENT_REFUND, orvd.getDeposit(), BigDecimal.ZERO, oad, vehicleItemDTO.getTopAmount(0), null, changeViolateAmount, (!overCancelBuffer));
//设置订单数据
//baseOrder.setDamagesAmount(csv.getDamagesAmount());
......@@ -295,6 +302,24 @@ public class OrderCancelBiz {
}
}
}
//设置人身保险状态
if(BaseOrder.INSURE_STATUS_BUY == baseOrder.getInsureStatus()) {
List<OrderPersonInsurance> insuranceList = orderPersonInsuranceBiz.selectList(new OrderPersonInsurance(){{
setOrderId(baseOrder.getId());
}});
Integer dayLag = Long.valueOf(timeLag/(1000L * 60L * 60L * 24L)).intValue();
if(dayLag <= 0) {
baseOrder.setInsureStatus(BaseOrder.INSURE_STATUS_CNL);
//更新 申请状态
insuranceList.forEach( insurance -> {
insurance.setStatus(STATUS_CNL);
insurance.setRefundTime(DateUtil.date().getTime());
});
}
}
}
//已付款的取消订单发送消息
......
......@@ -443,6 +443,7 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
private RentVehiclePriceVO dayCalculatePrice(RentVehicleBO detail) {
RentVehiclePriceVO rvp = new RentVehiclePriceVO();
BigDecimal realAmount = BigDecimal.ZERO;
BigDecimal orderAmount = BigDecimal.ZERO;
BigDecimal goodsAmount = BigDecimal.ZERO;
......@@ -561,16 +562,29 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
}
if(SYS_TRUE == detail.getNeedPersonInsurance() && CollUtil.isNotEmpty(detail.getInsurances())) {
for(OrderPersonInsurance opi : detail.getInsurances()) {
opi.setOrderDay(detail.getDayNum());
//计算天数
orderAccountBiz.calculatePersonInsurance(detail.getStartTime(), detail.getEndTime(), opi);
if(STATUS_TOPAY == opi.getStatus()) {
rvp.setNeedPersonInsurance(SYS_TRUE);
OrderPersonInsurance metaopi = new OrderPersonInsurance();
//计算天数
orderAccountBiz.calculatePersonInsurance(detail.getStartTime(), detail.getEndTime(), metaopi);
if(STATUS_TOPAY == metaopi.getStatus()) {
for(OrderPersonInsurance opi : detail.getInsurances()) {
opi.setOrderDay(detail.getDayNum());
opi.setAmount(metaopi.getAmount());
opi.setStatus(metaopi.getStatus());
opi.setInsuranceDay(metaopi.getInsuranceDay());
opi.setStartTime(metaopi.getStartTime());
opi.setEndTime(metaopi.getEndTime());
detail.getConfirmInsurances().add(BeanUtil.toBean(opi, OrderPersonInsurance.class));
OrderItem personInsuranceOrderItem = orderItemBiz.initOrderItem(opi.getAmount(), 1, "人身保险", null, ItemTypeEnum.PERSON_INSURANCE, JSONUtil.toJsonStr(opi));
detail.getItems().add(personInsuranceOrderItem);
personInsuranceAmount = personInsuranceAmount.add(opi.getAmount());
}
OrderItem personInsuranceOrderItem = orderItemBiz.initOrderItem(metaopi.getAmount(), detail.getConfirmInsurances().size(), "人身保险", null, ItemTypeEnum.PERSON_INSURANCE, JSONUtil.toJsonStr(metaopi));
rvp.setPersonInsureNum(personInsuranceOrderItem.getBuyNum());
rvp.setPersonInsurePrice(metaopi.getAmount());
rvp.setPersonInsureAmount(personInsuranceOrderItem.getRealAmount());
detail.getItems().add(personInsuranceOrderItem);
}else {
throw new BaseException("人身保险信息不正确", ResultCode.PARAM_ILLEGAL_CODE);
}
}
......@@ -613,7 +627,6 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
realAmount = orderAmount.subtract(couponAmount);
//生成订单明细
RentVehiclePriceVO rvp = new RentVehiclePriceVO();
rvp.setOrderSign(detail.getOrderSign());
rvp.setPriceType(vehicle.getPriceType());
rvp.setDeposit(depositAmount);
......@@ -746,7 +759,7 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
detail.getConfirmInsurances().add(BeanUtil.toBean(opi, OrderPersonInsurance.class));
OrderItem personInsuranceOrderItem = orderItemBiz.initOrderItem(opi.getAmount(), 1, "人身保险", null, ItemTypeEnum.PERSON_INSURANCE, JSONUtil.toJsonStr(opi));
detail.getItems().add(personInsuranceOrderItem);
personInsuranceAmount = personInsuranceAmount.add(opi.getAmount());
personInsuranceAmount = personInsuranceAmount.add(personInsuranceOrderItem.getCalculateAmount(Boolean.TRUE));
}
}
}
......
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