Commit 93b9c44d authored by jiaorz's avatar jiaorz

Merge remote-tracking branch 'origin/dev' into dev

parents 7cb58ff6 678ab118
package com.xxfc.platform.order.bo;
import cn.hutool.json.JSONObject;
import com.xxfc.platform.order.contant.enumerate.AccountTypeEnum;
import com.xxfc.platform.order.contant.enumerate.DeductionTypeEnum;
import com.xxfc.platform.order.contant.enumerate.StatisticsStatusEnum;
import com.xxfc.platform.order.pojo.account.OrderAccountBo;
import com.xxfc.platform.order.pojo.account.OrderAccountDeduction;
import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
/**
* @author libin
......@@ -40,6 +30,7 @@ public class FeeTypeBo implements Serializable {
private BigDecimal breakRulesRegulationAmount = BigDecimal.ZERO;
private BigDecimal lossSpecifiedAmount = BigDecimal.ZERO;
private BigDecimal extraAmount = BigDecimal.ZERO;
private BigDecimal extraNoDeductibleAmount = BigDecimal.ZERO;
}
......
......@@ -132,12 +132,14 @@ public enum StatisticsStatusEnum {
if (orderAccountBo.getAccountType().equals(AccountTypeEnum.IN_ORDER_PAY.getCode())) {
//订单押金
feeTypeBo.setDepositAmount(feeTypeBo.getDepositAmount().add(accountDetailEntity.getDepositAmount()));
//订单金额(不包含免赔和押金)
feeTypeBo.setTotalAmount(feeTypeBo.getTotalAmount().add(accountDetailEntity.getOrderAmount()));
if (hasDamageSafe) {
BigDecimal dameSafeAmount = getDameSafeAmount(orderAccountBo.getData());
feeTypeBo.setNoDeductibleAmount(feeTypeBo.getNoDeductibleAmount().add(dameSafeAmount));
feeTypeBo.setTotalAmount(feeTypeBo.getTotalAmount().subtract(feeTypeBo.getNoDeductibleAmount()));
}
//订单金额(不包含免赔和押金)
feeTypeBo.setTotalAmount(feeTypeBo.getTotalAmount().add(accountDetailEntity.getOrderAmount()).subtract(feeTypeBo.getNoDeductibleAmount()));
} else {
//退款订单押金
feeTypeBo.setDepositRefundAmount(feeTypeBo.getDepositRefundAmount().add(accountDetailEntity.getDepositAmount()));
......@@ -182,6 +184,10 @@ public enum StatisticsStatusEnum {
feeTypeBo.setExtraAmount(feeTypeBo.getExtraAmount().add(extendAmount));
}
}
//其他费用-延迟用车不记免赔
if (Objects.equals(DeductionTypeEnum.OTHER_DELAY_SAFE.getCode(),deduction.getType())){
feeTypeBo.setExtraNoDeductibleAmount(feeTypeBo.getExtraNoDeductibleAmount().add(deductionAmount));
}
}
//退款订单金额(不包含免赔和押金)
feeTypeBo.setOrderRefundAmount(feeTypeBo.getOrderRefundAmount().add(accountDetailEntity.getOrderAmount()).subtract(feeTypeBo.getNoDeductibleRefundAmount()));
......
......@@ -45,4 +45,6 @@ public class OrderRentVehicleReceivedStatistics extends OrderReceivedStatisticsB
@ApiModelProperty("不计免赔费用")
private BigDecimal noDeductibleRefundAmount;
@Column(name = "extra_no_deductible_amount")
private BigDecimal extraNoDeductibleAmount;
}
......@@ -47,6 +47,8 @@ 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.pojo.account.OrderAccountDeduction.ORIGIN_DEPOSIT;
import static com.xxfc.platform.order.pojo.account.OrderAccountDeduction.ORIGIN_ORDER_DEPOSIT;
import static com.xxfc.platform.order.pojo.pay.NotifyUrlDTO.PAY_WAY_ALI;
import static com.xxfc.platform.universal.constant.DictionaryKey.APP_ORDER;
......@@ -200,7 +202,7 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
originType = OrderAccountDeduction.ORIGIN_ORDER;
}else {
stringBuilder = depositRefundDescBuilder;
originType = OrderAccountDeduction.ORIGIN_DEPOSIT;
originType = ORIGIN_DEPOSIT;
}
oad.getDeductions().add(initDeduction(totalDeductAmount, stringBuilder.toString(), DeductionTypeEnum.VIOLATE_CANCEL, originType));
}
......@@ -436,13 +438,13 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
handleDedRefundDesc = handleDed(crosstown, handleDedRefundDesc, csv);
if(csv.getDamagesAmount().compareTo(BigDecimal.ZERO) > 0) {
oad.getDeductions().add(
initDeduction(csv.getDamagesAmount(), handleDedRefundDesc, DeductionTypeEnum.DAMAGES, OrderAccountDeduction.ORIGIN_DEPOSIT)
initDeduction(csv.getDamagesAmount(), handleDedRefundDesc, DeductionTypeEnum.DAMAGES, ORIGIN_DEPOSIT)
);
}
//还车扣除款 剩余的 钱,再减去违章预备金
oad.getDeductions().add(
initDeduction(illegalReserve, "违章保证金", DeductionTypeEnum.VIOLATE_TRAFFIC_KEEP, OrderAccountDeduction.ORIGIN_DEPOSIT)
initDeduction(illegalReserve, "违章保证金", DeductionTypeEnum.VIOLATE_TRAFFIC_KEEP, ORIGIN_DEPOSIT)
);
//剩余押金 = 押金 - 违章保证金 - 定损金额
......@@ -618,7 +620,7 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
//如果没有修改,则添加
if(Boolean.FALSE.equals(flag)) {
OrderAccountDeduction oadNew = initDeduction(vio.getCost(), vio.getDeductions(), DeductionTypeEnum.OTHER_DELAY_SAFE, OrderAccountDeduction.ORIGIN_DEPOSIT);
OrderAccountDeduction oadNew = initDeduction(vio.getCost(), vio.getDeductions(), DeductionTypeEnum.OTHER_DELAY_SAFE, ORIGIN_DEPOSIT);
oad.getDeductions().add(oadNew);
//修改归还押金金额
resetDeposit(oad);
......@@ -634,8 +636,29 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
private void resetDeposit(OrderAccountDetail oad) {
//修改归还押金金额
BigDecimal toDeduction = oad.getDeductions().parallelStream().map(OrderAccountDeduction::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
oad.setDepositAmount(oad.getOriginDepositAmount().subtract(toDeduction));
//扣费(押金源)
BigDecimal toDeduction = oad.getDeductions().parallelStream().filter(oadTemp ->
(Integer.valueOf(ORIGIN_DEPOSIT).equals(oadTemp.getOrigin()))
).map(OrderAccountDeduction::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
//扣费(订单_押金源)
BigDecimal toOdDeduction = oad.getDeductions().parallelStream().filter(oadTemp ->
(Integer.valueOf(ORIGIN_ORDER_DEPOSIT).equals(oadTemp.getOrigin()))
).map(OrderAccountDeduction::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal toExtendDeduction = oad.getOriginOrderAmount().subtract(toOdDeduction);
//如果订单原款 - 扣费 小于零,则押金有额外扣费
if(toExtendDeduction.compareTo(BigDecimal.ZERO) < 0) {
//置反
toExtendDeduction = BigDecimal.ZERO.subtract(toExtendDeduction);
}else {
//否则 则置为零
toExtendDeduction = BigDecimal.ZERO;
}
oad.setDepositAmount(oad.getOriginDepositAmount().subtract(toDeduction).subtract(toExtendDeduction));
}
private void handleViolateDetail(DeductionTypeEnum dte, OrderAccountDetail oad, DedDetailDTO vio, CancelStartedVO csv) {
......@@ -658,7 +681,7 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
//如果没有修改,则添加
if(Boolean.FALSE.equals(flag)) {
OrderAccountDeduction oadNew = initDeduction(vio.getCost(), vio.getDeductions(), dte, OrderAccountDeduction.ORIGIN_DEPOSIT);
OrderAccountDeduction oadNew = initDeduction(vio.getCost(), vio.getDeductions(), dte, ORIGIN_DEPOSIT);
oad.getDeductions().add(oadNew);
//修改归还押金金额
resetDeposit(oad);
......@@ -692,7 +715,7 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
if(null != orderViolation) {
//设置扣款项
oad.getDeductions().add(
initDeduction(orderViolation.getPrice(), DeductionTypeEnum.VIOLATE_TRAFFIC_DEDUCT.getDesc(), DeductionTypeEnum.VIOLATE_TRAFFIC_DEDUCT, OrderAccountDeduction.ORIGIN_DEPOSIT)
initDeduction(orderViolation.getPrice(), DeductionTypeEnum.VIOLATE_TRAFFIC_DEDUCT.getDesc(), DeductionTypeEnum.VIOLATE_TRAFFIC_DEDUCT, ORIGIN_DEPOSIT)
);
//还车扣除款 剩余的 钱,再减去违章预备金
......
......@@ -17,6 +17,17 @@
<result property="payWay" column="pay_way"/>
<result property="companyId" column="company_id"/>
<result property="crtTime" column="crt_time"/>
<result property="extraNoDeductibleAmount" column="extral_no_deductible_amount"/>
<result property="orderRefundAmount" column="order_refund_amount"/>
<result property="lateFeeAmount" column="late_fee_amount"/>
<result property="extraAmount" column="extra_amount"/>
<result property="companyName" column="company_name"/>
<result property="noDeductibleAmount" column="no_deductible_amount"/>
<result property="noDeductibleRefundAmount" column="no_deductible_refund_amount"/>
<result property="lossSpecifiedAmount" column="loss_specified_amount"/>
<result property="depositRefundAmount" column="deposit_refund_amount"/>
<result property="depositAmount" column="deposit_amount"/>
<result property="breakRulesRegulationAmount" column="break_rules_regulation_amount"/>
</resultMap>
<select id="selectOrderRentVehicleReceivedStatisticsGroupByDate" resultType="com.xxfc.platform.order.entity.OrderRentVehicleReceivedStatistics">
select `year`,`date`,IFNULL(sum(`total_amount`-`order_refund_amount`),0) as `totalAmount`,IFNULL(sum(`total_quantity`),0) as `totalQuantity` from `order_rent_vehicle_received_statistics` where 1=1
......
......@@ -97,7 +97,7 @@ public class ServiceTest {
@Test
public void testMemberStatistics(){
Date date = DateTime.parse("2019-11-28").toDate();
Date date = DateTime.parse("2019-11-15").toDate();
Date startDate = DateUtil.beginOfDay(date).toJdkDate();
Date endDate = DateUtil.endOfDay(date).toJdkDate();
Map<Integer, String> companyMap = vehicleFeign.findCompanyMap();
......@@ -106,7 +106,7 @@ public class ServiceTest {
@Test
public void testRentVehicleStatistics(){
Date date = DateTime.parse("2019-11-29").toDate();
Date date = DateTime.parse("2019-11-15").toDate();
Date startDate = DateUtil.beginOfDay(date).toJdkDate();
Date endDate = DateUtil.endOfDay(date).toJdkDate();
Map<Integer, String> companyMap = vehicleFeign.findCompanyMap();
......@@ -127,13 +127,13 @@ public class ServiceTest {
public void testOrderReceivedStatisticsJobHandler(){
cn.hutool.core.date.DateTime dateTime = DateUtil.parse("2019-11-29", "yyyy-MM-dd");
// cn.hutool.core.date.DateTime offset = DateUtil.offset(dateTime, DateField.DAY_OF_MONTH, 1);
// orderReceivedStatisticsJobHandler.execute("2019-10-08");
LocalDate startLocalDate = LocalDate.of(2019, 10, 01);
LocalDate endLocalDate = LocalDate.of(2019,12,20);
orderReceivedStatisticsJobHandler.execute("2019-11-15");
/* LocalDate startLocalDate = LocalDate.of(2019, 10, 01);
LocalDate endLocalDate = LocalDate.of(2019,12,19);
while (startLocalDate.isBefore(endLocalDate)){
String dateStr = startLocalDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
startLocalDate = startLocalDate.plusDays(1);
orderReceivedStatisticsJobHandler.execute(dateStr);
}
}*/
}
}
......@@ -71,7 +71,7 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper, OrderRefund> {
String refundDesc = StringUtils.isNotBlank(orderRefundVo.getRefundDesc()) ? orderRefundVo.getRefundDesc() : "审核通过,退款";
String out_refund_no = Snowflake.build() + "";
if (StringUtils.isBlank(order_no) || StringUtils.isBlank(appid) || StringUtils.isBlank(mchId) || StringUtils.isBlank(partnerKey)
|| payAmount == null || payAmount == 0 || refundAmount == null || refundAmount == 0) {
|| payAmount == null || payAmount == 0 || (refundAmount == null && orderRefundVo.getFreeze2PayAmount() == null) || (refundAmount == 0 && orderRefundVo.getFreeze2PayAmount() == 0)) {
log.error("-----参数为空-----------");
return JsonResultUtil.createFailedResult(ResultCode.NULL_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