|
@@ -89,8 +89,6 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
private RefundVoucherService refundVoucherService;
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
public Boolean isFree(TJs js, BigDecimal distance) {
|
|
|
|
|
|
Date date = new Date();
|
|
@@ -158,7 +156,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
if (order.getDistance() != null && order.getDistance().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
//判断是否可以免车费
|
|
|
if (!this.isFree(js, order.getDistance())) {
|
|
|
- BigDecimal bigDecimal = massageUtil.calculateTaxiFare(order.getDistance(),order.getDeptId());
|
|
|
+ BigDecimal bigDecimal = massageUtil.calculateTaxiFare(order.getDistance(), order.getDeptId());
|
|
|
order.setFare(bigDecimal.setScale(MassageConstants.INTEGER_TWO, RoundingMode.HALF_UP));
|
|
|
}
|
|
|
}
|
|
@@ -217,7 +215,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
@Override
|
|
|
public Object updateAddressById(TOrder borrow) {
|
|
|
TOrder order = this.getById(borrow.getcId());
|
|
|
- if(borrow.getLatitude()!=null && borrow.getLatitude()!=0 && borrow.getLongitude()!=null && borrow.getLongitude()!=0){
|
|
|
+ if (borrow.getLatitude() != null && borrow.getLatitude() != 0 && borrow.getLongitude() != null && borrow.getLongitude() != 0) {
|
|
|
order.setAtlasAdd(borrow.getAtlasAdd());
|
|
|
order.setcName(borrow.getcName());
|
|
|
order.setcPhone(borrow.getcPhone());
|
|
@@ -236,7 +234,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
if (order.getDistance() != null && order.getDistance().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
//判断是否可以免车费
|
|
|
if (!this.isFree(js, order.getDistance())) {
|
|
|
- BigDecimal bigDecimal = massageUtil.calculateTaxiFare(order.getDistance(),order.getDeptId());
|
|
|
+ BigDecimal bigDecimal = massageUtil.calculateTaxiFare(order.getDistance(), order.getDeptId());
|
|
|
order.setFare(bigDecimal.setScale(MassageConstants.INTEGER_TWO, RoundingMode.HALF_UP));
|
|
|
}
|
|
|
}
|
|
@@ -250,12 +248,12 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
public Object depart(TOrder order) {
|
|
|
|
|
|
LambdaQueryWrapper<TOrder> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(TOrder::getcId,order.getcId()).eq(TOrder::getnStatus,OrderStatusEnum.RECEIVED_ORDER.getCode());
|
|
|
+ wrapper.eq(TOrder::getcId, order.getcId()).eq(TOrder::getnStatus, OrderStatusEnum.RECEIVED_ORDER.getCode());
|
|
|
order.setnStatus(OrderStatusEnum.DEPART.getCode());
|
|
|
order.setDepartTime(new Date());
|
|
|
order.setDepartLatitude(Optional.ofNullable(order.getDepartLatitude()).orElse(BigDecimal.ZERO));
|
|
|
order.setDepartLongitude(Optional.ofNullable(order.getDepartLongitude()).orElse(BigDecimal.ZERO));
|
|
|
- return this.update(order,wrapper);
|
|
|
+ return this.update(order, wrapper);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -281,18 +279,18 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public TOrder transferOrder(TOrder order) {
|
|
|
- if(StringUtils.isBlank(order.getcId())){
|
|
|
+ if (StringUtils.isBlank(order.getcId())) {
|
|
|
throw new ServiceException("订单id不能为空");
|
|
|
}
|
|
|
- if(StringUtils.isBlank(order.getcJsId())){
|
|
|
+ if (StringUtils.isBlank(order.getcJsId())) {
|
|
|
throw new ServiceException("转单技师ID不能为空");
|
|
|
}
|
|
|
TOrder oldOrder = this.getById(order.getcId());
|
|
|
|
|
|
oldOrder.setOldJsId(oldOrder.getcJsId());
|
|
|
oldOrder.setcJsId(order.getcJsId());
|
|
|
- log.info("新技师:{},老技师{}",oldOrder.getcJsId(),oldOrder.getOldJsId());
|
|
|
- if(!this.updateById(oldOrder)){
|
|
|
+ log.info("新技师:{},老技师{}", oldOrder.getcJsId(), oldOrder.getOldJsId());
|
|
|
+ if (!this.updateById(oldOrder)) {
|
|
|
throw new ServiceException("转单失败");
|
|
|
}
|
|
|
//改变新技师服务状态
|
|
@@ -317,6 +315,54 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public TOrder verification(TOrder order) {
|
|
|
+ if (StringUtils.isBlank(order.getCouponReceiveId())) {
|
|
|
+ throw new ServiceException("认领优惠券id为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(order.getcId())) {
|
|
|
+ throw new ServiceException("订单id为空");
|
|
|
+ }
|
|
|
+ TOrder tOrder = this.getById(order.getcId());
|
|
|
+ tOrder.setCouponReceiveId(order.getCouponReceiveId());
|
|
|
+ CouponReceive couponReceive = couponReceiveService.getById(order.getCouponReceiveId());
|
|
|
+ Coupon coupon = couponService.getById(couponReceive.getCouponId());
|
|
|
+
|
|
|
+ //折扣券
|
|
|
+ if (coupon.getDiscountType() == 2) {
|
|
|
+ //判断门槛金额
|
|
|
+ if (tOrder.getTotalPrice().compareTo(coupon.getThresholdAmount()) >= 0) {
|
|
|
+ //折扣值
|
|
|
+ BigDecimal divide = coupon.getRebValue().divide(new BigDecimal(10));
|
|
|
+ //优惠后的金额 = 订单总金额*折扣值
|
|
|
+ BigDecimal bigDecimal = tOrder.getTotalPrice().multiply(divide).setScale(MassageConstants.INTEGER_TWO, RoundingMode.HALF_UP);
|
|
|
+ //优惠值
|
|
|
+ tOrder.setPreferential(tOrder.getTotalPrice().subtract(bigDecimal));
|
|
|
+ tOrder.setTotalPrice(bigDecimal);
|
|
|
+ return getOrder(tOrder);
|
|
|
+ } else {
|
|
|
+ throw new ServiceException("不满足优惠券门槛金额");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (tOrder.getTotalPrice().compareTo(coupon.getThresholdAmount()) >= 0) {
|
|
|
+ //优惠值
|
|
|
+ tOrder.setPreferential(coupon.getDiscountValue());
|
|
|
+ tOrder.setTotalPrice(tOrder.getTotalPrice().subtract(coupon.getDiscountValue()));
|
|
|
+ return getOrder(tOrder);
|
|
|
+ } else {
|
|
|
+ throw new ServiceException("不满足优惠券门槛金额");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private TOrder getOrder(TOrder tOrder) {
|
|
|
+ if (updateById(tOrder)) {
|
|
|
+ return tOrder;
|
|
|
+ } else {
|
|
|
+ throw new ServiceException("优惠券核销失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 支付订单
|
|
@@ -339,15 +385,15 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
|
|
|
|
|
|
orderNew.setPayType(order.getPayType());
|
|
|
- if (StringUtils.isNotBlank(order.getCouponReceiveId())) {
|
|
|
- orderNew.setCouponReceiveId(order.getCouponReceiveId());
|
|
|
- CouponReceive couponReceive = couponReceiveService.getById(order.getCouponReceiveId());
|
|
|
- Coupon coupon = couponService.getById(couponReceive.getCouponId());
|
|
|
- //无门槛优惠券
|
|
|
- orderNew.setPreferential(coupon.getDiscountValue());
|
|
|
- //todo 其他优惠卷....
|
|
|
- orderNew.setTotalPrice(orderNew.getTotalPrice().subtract(coupon.getDiscountValue()));
|
|
|
- }
|
|
|
+// if (StringUtils.isNotBlank(order.getCouponReceiveId())) {
|
|
|
+// orderNew.setCouponReceiveId(order.getCouponReceiveId());
|
|
|
+// CouponReceive couponReceive = couponReceiveService.getById(order.getCouponReceiveId());
|
|
|
+// Coupon coupon = couponService.getById(couponReceive.getCouponId());
|
|
|
+// //无门槛优惠券
|
|
|
+// orderNew.setPreferential(coupon.getDiscountValue());
|
|
|
+// //todo 其他优惠卷....
|
|
|
+// orderNew.setTotalPrice(orderNew.getTotalPrice().subtract(coupon.getDiscountValue()));
|
|
|
+// }
|
|
|
//判断支付方式
|
|
|
if (order.getPayType().equals(MassageConstants.INTEGER_ONE)) {
|
|
|
//微信支付
|
|
@@ -471,7 +517,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
// 微信退款原路返回
|
|
|
rechargeService.refund(refundVoucher.getRefundNo(), null, orderNew.getOrderNo(), orderNew.getTotalPrice());
|
|
|
}
|
|
|
- log.info("余额支付退款user:{}",user);
|
|
|
+ log.info("余额支付退款user:{}", user);
|
|
|
|
|
|
// 消费金额对应减少
|
|
|
paramUser.setdMoney(user.getdMoney().subtract(orderNew.getTotalPrice()));
|