|
@@ -17,6 +17,7 @@ import com.ylx.common.exception.ServiceException;
|
|
|
import com.ylx.massage.domain.*;
|
|
|
import com.ylx.massage.domain.vo.CouponReceiveVo;
|
|
|
import com.ylx.massage.domain.vo.HomeBlock;
|
|
|
+import com.ylx.massage.domain.vo.OrderVerificationVo;
|
|
|
import com.ylx.massage.enums.BillTypeEnum;
|
|
|
import com.ylx.massage.enums.DiscountTypeEnum;
|
|
|
import com.ylx.massage.enums.JsStatusEnum;
|
|
@@ -316,18 +317,20 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public TOrder verification(TOrder order) {
|
|
|
+ public OrderVerificationVo verification(TOrder order) {
|
|
|
if (StringUtils.isBlank(order.getCouponReceiveId())) {
|
|
|
throw new ServiceException("认领优惠券id为空");
|
|
|
}
|
|
|
if (StringUtils.isBlank(order.getcId())) {
|
|
|
throw new ServiceException("订单id为空");
|
|
|
}
|
|
|
+ OrderVerificationVo orderVerificationVo = new OrderVerificationVo();
|
|
|
TOrder tOrder = this.getById(order.getcId());
|
|
|
- tOrder.setCouponReceiveId(order.getCouponReceiveId());
|
|
|
+ orderVerificationVo.setCouponReceiveId(order.getCouponReceiveId());
|
|
|
CouponReceive couponReceive = couponReceiveService.getById(order.getCouponReceiveId());
|
|
|
Coupon coupon = couponService.getById(couponReceive.getCouponId());
|
|
|
-
|
|
|
+ log.info("订单信息,{}", tOrder);
|
|
|
+ log.info("优惠卷信息,{}", coupon);
|
|
|
//折扣券
|
|
|
if (coupon.getDiscountType() == 2) {
|
|
|
//判断门槛金额
|
|
@@ -337,18 +340,18 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
//优惠后的金额 = 订单总金额*折扣值
|
|
|
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);
|
|
|
+ orderVerificationVo.setPreferential(tOrder.getTotalPrice().subtract(bigDecimal));
|
|
|
+ orderVerificationVo.setTotalPrice(bigDecimal);
|
|
|
+ return orderVerificationVo;
|
|
|
} 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);
|
|
|
+ orderVerificationVo.setPreferential(coupon.getDiscountValue());
|
|
|
+ orderVerificationVo.setTotalPrice(tOrder.getTotalPrice().subtract(coupon.getDiscountValue()));
|
|
|
+ return orderVerificationVo;
|
|
|
} else {
|
|
|
throw new ServiceException("不满足优惠券门槛金额");
|
|
|
}
|
|
@@ -383,17 +386,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());
|
|
|
+ orderNew.setPreferential(order.getPreferential());
|
|
|
+ orderNew.setTotalPrice(order.getTotalPrice());
|
|
|
+ if (!updateById(orderNew)) {
|
|
|
+ throw new ServiceException("支付失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
//判断支付方式
|
|
|
if (order.getPayType().equals(MassageConstants.INTEGER_ONE)) {
|
|
|
//微信支付
|
|
@@ -435,6 +436,9 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
public void orderPayManage(TWxUser user, TOrder orderNew) {
|
|
|
|
|
|
//删除优惠卷
|
|
|
+// if(orderNew.){
|
|
|
+//
|
|
|
+// }
|
|
|
|
|
|
// 更新用户金额 及下单此时
|
|
|
TWxUser paramUser = new TWxUser();
|