|
@@ -22,10 +22,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 com.ylx.massage.utils.WeChatUtil;
|
|
|
+import com.ylx.massage.utils.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.compress.utils.Lists;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -51,8 +48,8 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
|
|
|
@Resource
|
|
|
private WechatAccountConfig wxPayProperties;
|
|
|
-
|
|
|
-
|
|
|
+ @Resource
|
|
|
+ private LocationUtil locationUtil;
|
|
|
|
|
|
@Resource
|
|
|
private TWxUserService wxUserService;
|
|
@@ -91,8 +88,8 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
private RefundVoucherService refundVoucherService;
|
|
|
|
|
|
|
|
|
- public Boolean isFree(String jsId, BigDecimal distance) {
|
|
|
- TJs js = jsService.getById(jsId);
|
|
|
+ public Boolean isFree(TJs js, BigDecimal distance) {
|
|
|
+
|
|
|
Date date = new Date();
|
|
|
//白天免车费(07.30-20.00)
|
|
|
long current = Long.parseLong(DateTimeUtils.numTime(date));
|
|
@@ -129,14 +126,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
if (order.getcGoods().isEmpty()) {
|
|
|
throw new ServiceException("请选择项目");
|
|
|
}
|
|
|
- //计算车费
|
|
|
- if (order.getDistance() != null) {
|
|
|
- //判断是否可以免车费
|
|
|
- if (!this.isFree(order.getcJsId(), order.getDistance())) {
|
|
|
- BigDecimal bigDecimal = massageUtil.calculateTaxiFare(order.getDistance());
|
|
|
- order.setFare(bigDecimal.setScale(MassageConstants.INTEGER_TWO, RoundingMode.HALF_UP));
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
//优惠卷减免
|
|
|
// List<CouponReceiveVo> coupons = couponReceiveService.getByOpenId(order.getcOpenId());
|
|
|
// BigDecimal preferential = this.setCoupon(coupons);
|
|
@@ -158,6 +148,21 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
if (address == null) {
|
|
|
throw new ServiceException("请先添加地址");
|
|
|
}
|
|
|
+ TJs js = jsService.getById(order.getcJsId());
|
|
|
+ //添加位置信息
|
|
|
+ locationUtil.geoAdd(LocationUtil.GEO_KEY_USER, js.getcOpenId(), Double.parseDouble(js.getLongitude().toString()), Double.parseDouble(js.getLatitude().toString()));
|
|
|
+ locationUtil.geoAdd(LocationUtil.GEO_KEY_USER, order.getcOpenId(), Double.parseDouble(address.getLongitude().toString()), Double.parseDouble(address.getLatitude().toString()));
|
|
|
+ double distance = locationUtil.getDistance(js.getcOpenId(), order.getcOpenId());
|
|
|
+ locationUtil.remove(LocationUtil.GEO_KEY_USER, js.getcOpenId() + "," + order.getcOpenId());
|
|
|
+ order.setDistance(new BigDecimal(distance));
|
|
|
+ //计算车费
|
|
|
+ if (order.getDistance() != null && order.getDistance().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ //判断是否可以免车费
|
|
|
+ if (!this.isFree(js, order.getDistance())) {
|
|
|
+ BigDecimal bigDecimal = massageUtil.calculateTaxiFare(order.getDistance());
|
|
|
+ order.setFare(bigDecimal.setScale(MassageConstants.INTEGER_TWO, RoundingMode.HALF_UP));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
order.setAddress(address.getAddress());
|
|
|
order.setName(address.getName());
|