Commit 17c1d66d authored by jiaorz's avatar jiaorz

Merge branch 'master-modify-cutAmount' into dev

parents 0e2ee64e ef449193
...@@ -61,8 +61,7 @@ import java.util.TimeZone; ...@@ -61,8 +61,7 @@ import java.util.TimeZone;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant.*; import static com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant.*;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_FALSE; import static com.github.wxiaoqi.security.common.constant.CommonConstants.*;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE;
import static com.xxfc.platform.universal.constant.DictionaryKey.APP_ORDER; import static com.xxfc.platform.universal.constant.DictionaryKey.APP_ORDER;
/** /**
...@@ -215,7 +214,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> { ...@@ -215,7 +214,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> {
return ObjectRestResponse.succ(orderPageVo); return ObjectRestResponse.succ(orderPageVo);
} }
//获取两个日期之间的天数 //获取两个日期之间的天数(不包含头尾)
public int getDaysBetweenDateTime(DateTime startDay, DateTime endDay) { public int getDaysBetweenDateTime(DateTime startDay, DateTime endDay) {
int a = 0; int a = 0;
for (DateTime curDate = startDay.plusDays(1); curDate.compareTo(endDay) < 0; curDate = curDate.plusDays(1)) { for (DateTime curDate = startDay.plusDays(1); curDate.compareTo(endDay) < 0; curDate = curDate.plusDays(1)) {
...@@ -224,6 +223,16 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> { ...@@ -224,6 +223,16 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> {
return a; return a;
} }
//获取两个日期之间的天数(包含头尾)
public int getDaysBetweenDateTimeHasStartEnd(DateTime startDay, DateTime endDay) {
int a = 0;
for (DateTime curDate = startDay; curDate.compareTo(endDay) <= 0; curDate = curDate.plusDays(1)) {
a++;
}
return a;
}
public void updateCrossRefund(OrderPageVO orderPageVO) { public void updateCrossRefund(OrderPageVO orderPageVO) {
//计算延期费用 //计算延期费用
DedDetailDTO dedDetailDTO = new DedDetailDTO(); DedDetailDTO dedDetailDTO = new DedDetailDTO();
...@@ -233,7 +242,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> { ...@@ -233,7 +242,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> {
DateTime startTime = DateTime.parse(new DateTime(orderPageVO.getOrderRentVehicleDetail().getStartTime()).toString(DEFAULT_DATE_TIME_FORMATTER), DEFAULT_DATE_TIME_FORMATTER); DateTime startTime = DateTime.parse(new DateTime(orderPageVO.getOrderRentVehicleDetail().getStartTime()).toString(DEFAULT_DATE_TIME_FORMATTER), DEFAULT_DATE_TIME_FORMATTER);
//设置使用天数 //设置使用天数
int userUsedDay = getDaysBetweenDateTime(startTime, nowTime); int userUsedDay = getDaysBetweenDateTimeHasStartEnd(startTime, nowTime);
orderPageVO.getOrderRentVehicleDetail().setUsedDay(userUsedDay); orderPageVO.getOrderRentVehicleDetail().setUsedDay(userUsedDay);
orderRentVehicleBiz.updateSelectiveById(orderPageVO.getOrderRentVehicleDetail()); orderRentVehicleBiz.updateSelectiveById(orderPageVO.getOrderRentVehicleDetail());
//实际预定的天数 //实际预定的天数
...@@ -258,7 +267,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> { ...@@ -258,7 +267,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> {
if (orderPageVO.getOrderRentVehicleDetail().getEndTime() > nowTime.getMillis()) { if (orderPageVO.getOrderRentVehicleDetail().getEndTime() > nowTime.getMillis()) {
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
//提前的天数, 当天就算使用一天 //提前的天数, 当天就算使用一天
int noUsedDay = getDaysBetweenDateTime(nowTime, endTime) - 1; int noUsedDay = getDaysBetweenDateTimeHasStartEnd(nowTime, endTime) - 1;
//退还未使用的天数,或者金额,扣除违约金,实际未使用天数的金额,最多3000元 //退还未使用的天数,或者金额,扣除违约金,实际未使用天数的金额,最多3000元
// InProgressVO inProgressVO = new InProgressVO(); // InProgressVO inProgressVO = new InProgressVO();
// inProgressVO.setViolateAmount(new BigDecimal(200)); // inProgressVO.setViolateAmount(new BigDecimal(200));
...@@ -285,17 +294,19 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> { ...@@ -285,17 +294,19 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> {
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("违约金( ¥"); stringBuilder.append("违约金( ¥");
//延期的天数, 延期违约金是延期天数*200% //延期的天数, 延期违约金是延期天数*200%
int usedDay = getDaysBetweenDateTime(endTime, nowTime); int extraUsedDay = getDaysBetweenDateTimeHasStartEnd(endTime, nowTime) - 1;
stringBuilder.append(amount); if(extraUsedDay > 0) {
stringBuilder.append(" x "); stringBuilder.append(amount);
stringBuilder.append(usedDay); stringBuilder.append(" x ");
stringBuilder.append("(天)"); stringBuilder.append(extraUsedDay);
stringBuilder.append(" x 2"); stringBuilder.append("(天)");
BigDecimal cost = amount.multiply(new BigDecimal(usedDay)).multiply(new BigDecimal(2)); stringBuilder.append(" x 2");
stringBuilder.append(" = "); BigDecimal cost = amount.multiply(new BigDecimal(extraUsedDay+ "")).multiply(new BigDecimal(2+ ""));
stringBuilder.append(cost); stringBuilder.append(" = ");
stringBuilder.append("元"); stringBuilder.append(cost);
initDedDetail(dedDetailDTO, OrderViolateEnum.AFTER.getCode(), cost, stringBuilder); stringBuilder.append("元");
initDedDetail(dedDetailDTO, OrderViolateEnum.AFTER.getCode(), cost, stringBuilder);
}
} }
orderPageVO.setDedDetailDTO(JSONObject.toJSONString(dedDetailDTO)); orderPageVO.setDedDetailDTO(JSONObject.toJSONString(dedDetailDTO));
} }
......
...@@ -35,6 +35,7 @@ import com.xxfc.platform.universal.constant.DictionaryKey; ...@@ -35,6 +35,7 @@ import com.xxfc.platform.universal.constant.DictionaryKey;
import com.xxfc.platform.universal.entity.Dictionary; import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.feign.ThirdFeign; import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.universal.vo.OrderPayVo; import com.xxfc.platform.universal.vo.OrderPayVo;
import com.xxfc.platform.universal.vo.OrderRefundVo;
import com.xxfc.platform.vehicle.feign.VehicleFeign; import com.xxfc.platform.vehicle.feign.VehicleFeign;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
...@@ -343,4 +344,23 @@ public class BaseOrderController extends CommonBaseController implements UserRes ...@@ -343,4 +344,23 @@ public class BaseOrderController extends CommonBaseController implements UserRes
List<Integer> companyIds; List<Integer> companyIds;
} }
@RequestMapping(value = "/app/unauth/refund/{no}/{refundAmount}", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "退款")
@IgnoreClientToken
@IgnoreUserToken
public ObjectRestResponse refundAmount(@PathVariable("no") String no, @PathVariable("refundAmount") BigDecimal refundAmount) {
OrderRefundVo orv = new OrderRefundVo();
BaseOrder baseOrder = baseOrderBiz.selectOne(new BaseOrder(){{
setNo(no);
}});
orv.setAmount(baseOrder.getRealAmount().multiply(new BigDecimal("100")).intValue());
orv.setOrderNo(baseOrder.getNo());
orv.setRefundDesc("");
orv.setRefundAmount(refundAmount.multiply(new BigDecimal("100")).intValue());
ObjectRestResponse<String> result = thirdFeign.refund(orv);
return ObjectRestResponse.succ(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