|
@@ -17,6 +17,7 @@ import com.ylx.massage.enums.JsStatusEnum;
|
|
|
import com.ylx.massage.enums.OrderStatusEnum;
|
|
|
import com.ylx.massage.mapper.TOrderMapper;
|
|
|
import com.ylx.massage.service.*;
|
|
|
+import com.ylx.massage.utils.DateTimeUtils;
|
|
|
import com.ylx.massage.utils.MassageUtil;
|
|
|
import com.ylx.massage.utils.OrderNumberGenerator;
|
|
|
import org.apache.commons.compress.utils.Lists;
|
|
@@ -25,13 +26,11 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.xml.crypto.Data;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
-import java.util.Optional;
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -68,6 +67,29 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
// @Resource
|
|
|
// private TInfoService infoService;
|
|
|
|
|
|
+ public Boolean isFree(String jsId, BigDecimal distance) {
|
|
|
+ TJs js = jsService.getById(jsId);
|
|
|
+ Date date = new Date();
|
|
|
+ //白天免车费(07.30-20.00)
|
|
|
+ long current = Long.parseLong(DateTimeUtils.numTime(date));
|
|
|
+ if (current >= MassageConstants.START_FREE && current <= MassageConstants.END_FREE) {
|
|
|
+ if (js.getDaytimeMileage().compareTo(distance) >= 0) {
|
|
|
+ //免车费
|
|
|
+ return Boolean.TRUE;
|
|
|
+ } else {
|
|
|
+ return Boolean.FALSE;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //夜间免车费(20.00-07.30)
|
|
|
+ if (js.getNigthMileage().compareTo(distance) >= 0) {
|
|
|
+ //免车费
|
|
|
+ return Boolean.TRUE;
|
|
|
+ } else {
|
|
|
+ return Boolean.FALSE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 添加订单
|
|
|
*
|
|
@@ -84,8 +106,11 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
}
|
|
|
//计算车费
|
|
|
if (order.getDistance() != null) {
|
|
|
- BigDecimal bigDecimal = massageUtil.calculateTaxiFare(order.getDistance());
|
|
|
- order.setFare(bigDecimal.setScale(MassageConstants.INTEGER_TWO, RoundingMode.HALF_UP));
|
|
|
+ //判断是否可以免车费
|
|
|
+ if (!this.isFree(order.getcJsId(), order.getDistance())) {
|
|
|
+ BigDecimal bigDecimal = massageUtil.calculateTaxiFare(order.getDistance());
|
|
|
+ order.setFare(bigDecimal.setScale(MassageConstants.INTEGER_TWO, RoundingMode.HALF_UP));
|
|
|
+ }
|
|
|
}
|
|
|
//订单价格
|
|
|
List<TXiangmu> list = JSONObject.parseArray(order.getcGoods().toJSONString(), TXiangmu.class);
|
|
@@ -124,7 +149,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
if (!orderNew.getnStatus().equals(OrderStatusEnum.WAIT_PAY.getCode())) {
|
|
|
throw new ServiceException("该订单已经支付或者超时被取消");
|
|
|
}
|
|
|
- if(StringUtils.isBlank(orderNew.getParentNo())){
|
|
|
+ if (StringUtils.isBlank(orderNew.getParentNo())) {
|
|
|
TJs js = jsService.getById(orderNew.getcJsId());
|
|
|
if (null == js || js.getnStatus().equals(JsStatusEnum.JS_SERVICE.getCode())) {
|
|
|
throw new ServiceException("该技师已在服务中请重新下单");
|