Commit 508b87ec authored by jiaorz's avatar jiaorz

Merge branch 'master-modify-cutAmount' into dev

parents 4aecfcfb 90a821c9
......@@ -47,6 +47,7 @@ public class CommonConstants {
public static final DateTimeFormatter DATE_TIME_LINE_FORMATTER = DateTimeFormatter.ofPattern(DATE_TIME_LINE);
public static final DateTimeFormatter YMR_SLASH_FORMATTER = DateTimeFormatter.ofPattern(YMR_SLASH);
public static final org.joda.time.format.DateTimeFormatter YMR_SLASH_FORMATTER_JODA = org.joda.time.format.DateTimeFormat.forPattern(YMR_SLASH);
public static final FastDateFormat HOUR_MINUTE_FORMATTE_HUTOOL = FastDateFormat.getInstance(HOUR_MINUTE);
}
......@@ -8,7 +8,7 @@ public enum DeductionTypeEnum {
VIOLATE_CANCEL(101, "提前取消违约金"),
VIOLATE_ADVANCE(102, "提前还车违约金"),
VIOLATE_DELAY(103, "延迟还车违约金"),
EXTRA(201, "消费金额"),
CONSUME(201, "消费金额"),
DAMAGES(301, "赔偿金(定损)"),
VIOLATE_TRAFFIC_DEDUCT(401, "违章扣款"),
VIOLATE_TRAFFIC_KEEP(402, "违章扣款保留金"),
......
......@@ -10,7 +10,7 @@ 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;
public static final int ORIGIN_DEPOSIT_ORDER = 4;
/**
* 名称
......
......@@ -24,7 +24,7 @@ public class InProgressVO {
BigDecimal extraAmount = BigDecimal.ZERO;
/**
* 实际消费金额
* 实际主要消费金额
*/
BigDecimal consumeAmount = BigDecimal.ZERO;
......
package com.xxfc.platform.order.biz;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.db.sql.Order;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.JsonUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.xxfc.platform.order.contant.enumerate.DeductionTypeEnum;
......@@ -376,7 +370,7 @@ public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderSta
//消费金额
orderStatistics.setTotalExpenditure(get(OrderAccountDeductions,new ArrayList<Integer>(){{
add(DeductionTypeEnum.EXTRA.getCode());
add(DeductionTypeEnum.CONSUME.getCode());
}}));
}
}
......
package com.xxfc.platform.order.biz.inner;
import cn.hutool.core.lang.Dict;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.xxfc.platform.activity.entity.Coupon;
import com.xxfc.platform.activity.feign.ActivityFeign;
......@@ -13,7 +12,6 @@ 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.price.RentVehiclePriceVO;
import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.vehicle.feign.VehicleFeign;
import lombok.extern.slf4j.Slf4j;
......@@ -22,7 +20,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
/**
......@@ -63,6 +60,9 @@ public class OrderCalculateBiz {
public InProgressVO inProgressCalculate(BaseOrder baseOrder, OrderItem orderItem, Integer freeDays, Integer useDays, OrderAccountDetail oad) {
BigDecimal refundAmount = BigDecimal.ZERO;
BigDecimal consumeAmount = BigDecimal.ZERO;
//其他消费金额
BigDecimal otherItemRealAmount = baseOrder.getGoodsAmount().subtract(orderItem.getRealAmount());
InProgressVO inProgressVO = new InProgressVO();
inProgressVO.setUsedDays(useDays);
inProgressVO.setUsedfreeDays(freeDays);
......@@ -100,22 +100,30 @@ public class OrderCalculateBiz {
consumeAmount = consumeAmount.subtract(couponAmount);
}
if(consumeAmount.compareTo(orderItem.getRealAmount()) > 0) {
//消费金额 大于真实的金额 增加额外费用
inProgressVO.setExtraAmount(consumeAmount.subtract(orderItem.getRealAmount()));
// consumeAmount = orderItem
OrderAccountDeduction extraDeduction = orderAccountBiz.initDeduction(inProgressVO.getExtraAmount(), "消费额外费用", DeductionTypeEnum.EXTRA, OrderAccountDeduction.ORIGIN_DEPOSIT);
//设置消费金额
consumeAmount = consumeAmount.add(otherItemRealAmount);
inProgressVO.setConsumeAmount(consumeAmount);
if(consumeAmount.compareTo(BigDecimal.ZERO) > 0) {
//消费金额 大于0 增加额外费用
OrderAccountDeduction extraDeduction = orderAccountBiz.initDeduction(consumeAmount, "消费金额", DeductionTypeEnum.CONSUME, OrderAccountDeduction.ORIGIN_ORDER_DEPOSIT);
oad.getDeductions().add(extraDeduction);
}
//消费金额 小于商品的金额 返回钱
if(consumeAmount.compareTo(baseOrder.getGoodsAmount()) <= 0) {
//设置返回钱
refundAmount = refundAmount.add(baseOrder.getGoodsAmount().subtract(consumeAmount));
}else {
//否则,设置返回钱
refundAmount = refundAmount.add(orderItem.getRealAmount().subtract(consumeAmount));
//设置额外扣减(押金里面扣)
inProgressVO.setExtraAmount(consumeAmount.subtract(baseOrder.getGoodsAmount()));
}
} else {
}
}else {
//返回剩余免费天数,返回优惠券,订单款
refundAmount = refundAmount.add(orderItem.getRealAmount());
refundAmount = refundAmount.add(baseOrder.getGoodsAmount());
inProgressVO.setBackFreeDays(backFreeDays);
}
......@@ -162,10 +170,12 @@ public class OrderCalculateBiz {
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.setDepositAmount(orvd.getDeposit().subtract(inProgressVO.getConsumeAmount().add(inProgressVO.getViolateAmount())));
oad.setOrderAmount(inProgressVO.getRefundOrderAmount());
oad.setOriginDepositAmount(orvd.getDeposit());
oad.setOriginOrderAmount(baseOrder.getRealAmount());
oad.setOriginOrderAmount(baseOrder.getGoodsAmount());
return inProgressVO;
}
}
\ No newline at end of file
......@@ -25,6 +25,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.weekend.WeekendSqls;
import java.math.BigDecimal;
import java.util.*;
......@@ -138,6 +140,10 @@ public class OrderCancelBiz {
setOrderId(baseOrder.getId());
}});
// List<OrderItem> otherOrderItems = orderItemBiz.selectByExample(new Example.Builder(OrderItem.class)
// .where(WeekendSqls.<OrderItem>custom().andNotEqualTo(OrderItem::getType, ItemTypeEnum.VEHICLE_MODEL.getCode())).build()
// );
//原退还押金
Integer freeDays = (null == orderItem.getCutNum())?0 :orderItem.getCutNum();
BigDecimal freeDayAmount = BigDecimal.ZERO;
......
......@@ -223,6 +223,8 @@ public class BackStageOrderController extends CommonBaseController implements Us
List<Integer> list = userFeign.getUserIdByUsername(dto.getKeywords());
if(list != null) {
userIds.addAll(list);
} else {
return ObjectRestResponse.succ(new PageDataVO<>());
}
}
dto.setUserIds(userIds);
......
......@@ -3,22 +3,27 @@ package com.xxfc.platform.order.rest;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.common.constant.CommonConstants;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.vo.PageParam;
import com.xxfc.platform.order.biz.BaseOrderBiz;
import com.xxfc.platform.order.biz.OrderAccountBiz;
import com.xxfc.platform.order.biz.OrderItemBiz;
import com.xxfc.platform.order.biz.OrderRefundBiz;
import com.xxfc.platform.order.biz.inner.OrderCalculateBiz;
import com.xxfc.platform.order.biz.inner.OrderCancelBiz;
import com.xxfc.platform.order.contant.enumerate.ItemTypeEnum;
import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum;
import com.xxfc.platform.order.entity.OrderItem;
import com.xxfc.platform.order.entity.OrderRefund;
import com.xxfc.platform.order.entity.OrderRentVehicleDetail;
import com.xxfc.platform.order.pojo.calculate.InProgressVO;
import com.xxfc.platform.order.pojo.order.OrderPageVO;
import com.xxfc.platform.universal.constant.DictionaryKey;
import lombok.Data;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
......@@ -41,11 +46,14 @@ public class OrderRefundController extends BaseController<OrderRefundBiz,OrderRe
BaseOrderBiz baseOrderBiz;
@Autowired
OrderRefundBiz orderRefundBiz;
OrderAccountBiz orderAccountBiz;
@Autowired
OrderItemBiz orderItemBiz;
@Autowired
OrderCalculateBiz orderCalculateBiz;
@Autowired
UserFeign userFeign;
......@@ -72,7 +80,11 @@ public class OrderRefundController extends BaseController<OrderRefundBiz,OrderRe
switch (orderTypeEnum) {
case RENT_VEHICLE:
// orderRefundAmount = orderRefundBiz.calculateRefund(orderPageVO.getGoodsAmount().subtract(orderPageVO.getCouponAmount())
DateTime nowTime = DateTime.parse(DateTime.now().toString(CommonConstants.YMR_SLASH_FORMATTER_JODA), CommonConstants.YMR_SLASH_FORMATTER_JODA);
DateTime startTime = DateTime.parse(new DateTime(orderPageVO.getOrderRentVehicleDetail().getStartTime()).toString(CommonConstants.YMR_SLASH_FORMATTER_JODA), CommonConstants.YMR_SLASH_FORMATTER_JODA);
InProgressVO inProgressVO = orderCalculateBiz.inProgressCalculate(orderPageVO, baseOrderBiz.getDaysBetweenDateTime(startTime, nowTime));
// orderRefundAmount = orderAccountBiz.calculateRefund(orderPageVO.getGoodsAmount().subtract(orderPageVO.getCouponAmount())
// , orderPageVO.getOrderRentVehicleDetail().getStartTime() - System.currentTimeMillis()
// , DictionaryKey.APP_ORDER+ "_"+ RENT_REFUND
// , refundDescBuilder);
......@@ -91,11 +103,14 @@ public class OrderRefundController extends BaseController<OrderRefundBiz,OrderRe
// originalDeductAmount = orderItem.getUnitPrice().multiply(new BigDecimal(orvd.getFreeDays()+ ""));
// }
// BigDecimal residueAmount = orderRefundBiz.calculateRefund(originalDeductAmount, timeLag, APP_ORDER+ "_"+ RENT_REFUND, refundDescBuilder);
// residueAmount = residueAmount.setScale(2, RoundingMode.HALF_UP);
//
// //押金剩余款 :押金 - (原扣除款 - 剩余款)
// //退款金额 :订单剩余款 + 押金剩余款
// orderRefundAmount = orderRefundAmount.add(originalRefundAmount.subtract(originalDeductAmount.subtract(residueAmount)));
//扣款 = 违约金 + 消费金额
BigDecimal residueAmount = BigDecimal.ZERO;
//inProgressVO.get
residueAmount = residueAmount.setScale(2, RoundingMode.HALF_UP);
//押金剩余款 :押金 - (原扣除款 - 剩余款)
//退款金额 :订单剩余款 + 押金剩余款
//orderRefundAmount = orderRefundAmount.add(originalRefundAmount.subtract(originalDeductAmount.subtract(residueAmount)));
break;
case TOUR:
......
package com.xxfc.platform.order.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Dict;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
......@@ -413,12 +414,12 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
*/
private void costDetail(RentVehiclePriceVO vo, String children) {
OrderTemplate template = orderTemplateBiz.selectByCode(OrderCostEnum.RENT_VEHICLE.getCode());
template.setTemplate(orderTemplateBiz.result(template.getTemplate(), new HashMap(){{
put("children", children);
put("vehicleAmount", vo.getVehicleAmount());
put("realAmount", vo.getRealAmount());
put("paramJson", vo.getParamJson());
}}));
// (Map<String, String>)CollUtil.zip(CollUtil.newArrayList("children", "vehicleAmount", "realAmount", "paramJson")
// , CollUtil.newArrayList(children, vo.getVehicleAmount()+"", vo.getRealAmount()+"", vo.getParamJson()));
template.setTemplate(orderTemplateBiz.result(template.getTemplate()
, CollUtil.zip(CollUtil.newArrayList("children", "vehicleAmount", "realAmount", "paramJson")
, CollUtil.newArrayList(children, vo.getVehicleAmount()
, vo.getRealAmount(), vo.getParamJson()))));
String result = orderTemplateBiz.result(template, Dict.parse(vo));
vo.setCostDetail(result);
}
......
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