Commit 076838c7 authored by 周健威's avatar 周健威

添加部分代码

parent 44aa7328
...@@ -6,6 +6,10 @@ import java.math.BigDecimal; ...@@ -6,6 +6,10 @@ import java.math.BigDecimal;
@Data @Data
public class OrderAccountDeduction { public class OrderAccountDeduction {
public static final int ORIGIN_ORDER = 1;
public static final int ORIGIN_DEPOSIT = 2;
/** /**
* 名称 * 名称
*/ */
...@@ -17,7 +21,7 @@ public class OrderAccountDeduction { ...@@ -17,7 +21,7 @@ public class OrderAccountDeduction {
Integer type; Integer type;
/** /**
* 来源 * 来源 1--订单款 2--押金
*/ */
Integer origin; Integer origin;
......
...@@ -10,7 +10,6 @@ import com.xxfc.platform.order.contant.enumerate.RefundStatusEnum; ...@@ -10,7 +10,6 @@ import com.xxfc.platform.order.contant.enumerate.RefundStatusEnum;
import com.xxfc.platform.order.contant.enumerate.RefundTypeEnum; import com.xxfc.platform.order.contant.enumerate.RefundTypeEnum;
import com.xxfc.platform.order.entity.BaseOrder; import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.entity.OrderItem; import com.xxfc.platform.order.entity.OrderItem;
import com.xxfc.platform.order.entity.OrderRefund;
import com.xxfc.platform.order.pojo.account.OrderAccountDeduction; import com.xxfc.platform.order.pojo.account.OrderAccountDeduction;
import com.xxfc.platform.order.pojo.account.OrderAccountDetail; import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
import com.xxfc.platform.universal.entity.Dictionary; import com.xxfc.platform.universal.entity.Dictionary;
...@@ -25,7 +24,6 @@ import com.xxfc.platform.order.entity.OrderAccount; ...@@ -25,7 +24,6 @@ import com.xxfc.platform.order.entity.OrderAccount;
import com.xxfc.platform.order.mapper.OrderAccountMapper; import com.xxfc.platform.order.mapper.OrderAccountMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import javax.xml.ws.Action;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.Map; import java.util.Map;
...@@ -58,7 +56,7 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> { ...@@ -58,7 +56,7 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
* @param timeLag 与开始时间的时间差 * @param timeLag 与开始时间的时间差
* @param dicParentKey * @param dicParentKey
*/ */
public BigDecimal rentRefundProcessTotal(BaseOrder baseOrder, OrderItem mainItem, Long timeLag, String dicParentKey, BigDecimal depositAmount, BigDecimal originalDeductAmount) { public BigDecimal rentRefundProcessCancel(BaseOrder baseOrder, OrderItem mainItem, Long timeLag, String dicParentKey, BigDecimal depositAmount, BigDecimal originalDeductAmount) {
//计算退款金额 //计算退款金额
//商品价格 - 优惠券减免的价格 //商品价格 - 优惠券减免的价格
BigDecimal originalRefundAmount = BigDecimal.ZERO.add(mainItem.getRealAmount()); BigDecimal originalRefundAmount = BigDecimal.ZERO.add(mainItem.getRealAmount());
...@@ -158,11 +156,7 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> { ...@@ -158,11 +156,7 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
set("ga", goodsAmount); set("ga", goodsAmount);
}})).toString()); }})).toString());
refundDescBuilder = refundDescBuilder.insert(0, names[1]+ ","); refundDescBuilder = refundDescBuilder.insert(0, names[1]+ ",");
OrderAccountDeduction orderAccountDeduction = new OrderAccountDeduction(); orderAccountDetail.getDeductions().add(initDeduction(goodsAmount.subtract(refundGoodsAmount), names[1], DeductionTypeEnum.VIOLATE, OrderAccountDeduction.ORIGIN_DEPOSIT));
orderAccountDeduction.setType(DeductionTypeEnum.VIOLATE.getCode());
orderAccountDeduction.setName(names[1]);
orderAccountDeduction.setAmount(goodsAmount.subtract(refundGoodsAmount));
orderAccountDetail.getDeductions().add(orderAccountDeduction);
break; break;
} }
} }
...@@ -170,6 +164,21 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> { ...@@ -170,6 +164,21 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
return refundGoodsAmount; return refundGoodsAmount;
} }
/**
* 初始化deduction
* @param subtract
* @param name
* @return
*/
public OrderAccountDeduction initDeduction(BigDecimal subtract, String name, DeductionTypeEnum dte, Integer origin) {
OrderAccountDeduction orderAccountDeduction = new OrderAccountDeduction();
orderAccountDeduction.setType(dte.getCode());
orderAccountDeduction.setName(name);
orderAccountDeduction.setAmount(subtract);
orderAccountDeduction.setOrigin(origin);
return orderAccountDeduction;
}
/** /**
* 记录订单退款记录 * 记录订单退款记录
* @param orderId * @param orderId
......
...@@ -9,13 +9,13 @@ import com.xxfc.platform.activity.entity.Coupon; ...@@ -9,13 +9,13 @@ import com.xxfc.platform.activity.entity.Coupon;
import com.xxfc.platform.activity.feign.ActivityFeign; import com.xxfc.platform.activity.feign.ActivityFeign;
import com.xxfc.platform.app.entity.Cofig; import com.xxfc.platform.app.entity.Cofig;
import com.xxfc.platform.app.feign.ConfigFeign; import com.xxfc.platform.app.feign.ConfigFeign;
import com.xxfc.platform.order.biz.OrderAccountBiz;
import com.xxfc.platform.order.biz.OrderItemBiz; import com.xxfc.platform.order.biz.OrderItemBiz;
import com.xxfc.platform.order.biz.OrderRefundBiz; import com.xxfc.platform.order.biz.OrderRefundBiz;
import com.xxfc.platform.order.contant.enumerate.ItemTypeEnum; import com.xxfc.platform.order.contant.enumerate.*;
import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum;
import com.xxfc.platform.order.contant.enumerate.RefundStatusEnum;
import com.xxfc.platform.order.contant.enumerate.RefundTypeEnum;
import com.xxfc.platform.order.entity.*; import com.xxfc.platform.order.entity.*;
import com.xxfc.platform.order.pojo.account.OrderAccountDeduction;
import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
import com.xxfc.platform.order.pojo.calculate.InProgressVO; import com.xxfc.platform.order.pojo.calculate.InProgressVO;
import com.xxfc.platform.universal.constant.DictionaryKey; import com.xxfc.platform.universal.constant.DictionaryKey;
import com.xxfc.platform.universal.dto.SmsTemplateDTO; import com.xxfc.platform.universal.dto.SmsTemplateDTO;
...@@ -71,9 +71,13 @@ public class OrderCalculateBiz { ...@@ -71,9 +71,13 @@ public class OrderCalculateBiz {
@Autowired @Autowired
OrderItemBiz orderItemBiz; OrderItemBiz orderItemBiz;
public InProgressVO inProgressCalculate(BaseOrder baseOrder, OrderItem orderItem, Integer freeDays, Integer useDays) { @Autowired
OrderAccountBiz orderAccountBiz;
public InProgressVO inProgressCalculate(BaseOrder baseOrder, OrderItem orderItem, Integer freeDays, Integer useDays, OrderAccountDetail oad) {
BigDecimal refundAmount = BigDecimal.ZERO; BigDecimal refundAmount = BigDecimal.ZERO;
InProgressVO inProgressVO = new InProgressVO(); InProgressVO inProgressVO = new InProgressVO();
//计算:剩余免费天数 //计算:剩余免费天数
Integer backFreeDays = freeDays - useDays; Integer backFreeDays = freeDays - useDays;
//待返还的免费天数 //待返还的免费天数
...@@ -107,9 +111,14 @@ public class OrderCalculateBiz { ...@@ -107,9 +111,14 @@ public class OrderCalculateBiz {
consumeAmount = consumeAmount.subtract(couponAmount); consumeAmount = consumeAmount.subtract(couponAmount);
} }
if(consumeAmount.compareTo(orderItem.getRealAmount()) > 0) { if(consumeAmount.compareTo(orderItem.getRealAmount()) > 0) {
//消费金额 大于真实的金额 增加额外费用 //消费金额 大于真实的金额 增加额外费用
inProgressVO.setExtraAmount(consumeAmount.subtract(orderItem.getRealAmount())); inProgressVO.setExtraAmount(consumeAmount.subtract(orderItem.getRealAmount()));
// consumeAmount = orderItem
OrderAccountDeduction extraDeduction = orderAccountBiz.initDeduction(inProgressVO.getExtraAmount(), "消费额外费用", DeductionTypeEnum.EXTRA, OrderAccountDeduction.ORIGIN_DEPOSIT);
oad.getDeductions().add(extraDeduction);
}else { }else {
//否则,设置返回钱 //否则,设置返回钱
refundAmount = refundAmount.add(orderItem.getRealAmount().subtract(consumeAmount)); refundAmount = refundAmount.add(orderItem.getRealAmount().subtract(consumeAmount));
...@@ -132,6 +141,8 @@ public class OrderCalculateBiz { ...@@ -132,6 +141,8 @@ public class OrderCalculateBiz {
residueDays = 2; residueDays = 2;
} }
inProgressVO.setViolateAmount(orderItem.getUnitPrice().multiply(new BigDecimal((residueDays + "")))); inProgressVO.setViolateAmount(orderItem.getUnitPrice().multiply(new BigDecimal((residueDays + ""))));
OrderAccountDeduction violateDeduction = orderAccountBiz.initDeduction(inProgressVO.getViolateAmount(), "违约金", DeductionTypeEnum.VIOLATE, OrderAccountDeduction.ORIGIN_DEPOSIT);
oad.getDeductions().add(violateDeduction);
} }
return inProgressVO; return inProgressVO;
...@@ -143,6 +154,6 @@ public class OrderCalculateBiz { ...@@ -143,6 +154,6 @@ public class OrderCalculateBiz {
setOrderId(baseOrder.getId()); setOrderId(baseOrder.getId());
}}); }});
Integer freeDays = (null == orderItem.getCutNum())?0 :orderItem.getCutNum(); Integer freeDays = (null == orderItem.getCutNum())?0 :orderItem.getCutNum();
return inProgressCalculate(baseOrder, orderItem, freeDays, useDays); return inProgressCalculate(baseOrder, orderItem, freeDays, useDays, null);
} }
} }
\ No newline at end of file
...@@ -4,7 +4,6 @@ import com.github.wxiaoqi.security.admin.feign.UserFeign; ...@@ -4,7 +4,6 @@ import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO; import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.common.exception.BaseException; import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.activity.entity.Coupon;
import com.xxfc.platform.activity.feign.ActivityFeign; import com.xxfc.platform.activity.feign.ActivityFeign;
import com.xxfc.platform.order.biz.*; import com.xxfc.platform.order.biz.*;
import com.xxfc.platform.order.contant.enumerate.*; import com.xxfc.platform.order.contant.enumerate.*;
...@@ -16,7 +15,6 @@ import com.xxfc.platform.universal.feign.ThirdFeign; ...@@ -16,7 +15,6 @@ import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.vehicle.common.RestResponse; import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.feign.VehicleFeign; import com.xxfc.platform.vehicle.feign.VehicleFeign;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.assertj.core.util.Lists;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -141,9 +139,11 @@ public class OrderCancelBiz { ...@@ -141,9 +139,11 @@ public class OrderCancelBiz {
//计算:使用天数 当前时间 - 开始时间的0时0分0秒 //计算:使用天数 当前时间 - 开始时间的0时0分0秒
Long useTimeLag = System.currentTimeMillis() - orvd.getStartTime(); Long useTimeLag = System.currentTimeMillis() - orvd.getStartTime();
Integer useDays = new BigDecimal(useTimeLag + "").divide(new BigDecimal((24 * 60 * 60 * 1000)+ "")).setScale(0, BigDecimal.ROUND_UP).intValue(); Integer useDays = new BigDecimal(useTimeLag + "").divide(new BigDecimal((24 * 60 * 60 * 1000)+ "")).setScale(0, BigDecimal.ROUND_UP).intValue();
InProgressVO inProgressVO = orderCalculateBiz.inProgressCalculate(baseOrder, orderItem, freeDays, useDays); InProgressVO inProgressVO = orderCalculateBiz.inProgressCalculate(baseOrder, orderItem, freeDays, useDays, null);
//结合 //结合
//退款子流程: 订单基础,退款描述,退款金额
orderAccountBiz.refundSubProcess(baseOrder, "", baseOrder.getRealAmount(), inProgressVO.getRefundAmount(), RefundTypeEnum.ORDER_FUND.getCode(), RefundStatusEnum.ALL.getCode(), null);
}else { }else {
//没到出车时间 //没到出车时间
...@@ -158,7 +158,7 @@ public class OrderCancelBiz { ...@@ -158,7 +158,7 @@ public class OrderCancelBiz {
} }
} }
orderAccountBiz.rentRefundProcessTotal(hasUpdateOrder, orderItem, timeLag, APP_ORDER+ "_"+ RENT_REFUND, orvd.getDeposit(), freeDayAmount); orderAccountBiz.rentRefundProcessCancel(hasUpdateOrder, orderItem, timeLag, APP_ORDER+ "_"+ RENT_REFUND, orvd.getDeposit(), freeDayAmount);
} }
//退款流程 //退款流程
...@@ -168,7 +168,7 @@ public class OrderCancelBiz { ...@@ -168,7 +168,7 @@ public class OrderCancelBiz {
// //退押金 // //退押金
// orderRefundBiz.rentRefundDepositProcess(hasUpdateOrder, orvd.getDeposit(), timeLag, APP_ORDER+ "_"+ RENT_REFUND, freeDayAmount); // orderRefundBiz.rentRefundDepositProcess(hasUpdateOrder, orvd.getDeposit(), timeLag, APP_ORDER+ "_"+ RENT_REFUND, freeDayAmount);
// //
// orderAccountBiz.rentRefundProcessTotal(hasUpdateOrder, orderItem, timeLag, APP_ORDER+ "_"+ RENT_REFUND, orvd.getDeposit(), freeDayAmount);freeDayAmount // orderAccountBiz.rentRefundProcessCancel(hasUpdateOrder, orderItem, timeLag, APP_ORDER+ "_"+ RENT_REFUND, orvd.getDeposit(), freeDayAmount);freeDayAmount
//已付款的取消订单发送消息 //已付款的取消订单发送消息
try { try {
......
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