|
|
@@ -29,6 +29,7 @@ import com.ylx.massage.mapper.ProductOrderItemMapper;
|
|
|
import com.ylx.massage.mapper.ProductSkuMapper;
|
|
|
import com.ylx.massage.service.*;
|
|
|
import com.ylx.massage.utils.OrderNumberGenerator;
|
|
|
+import com.ylx.point.service.IPointAccountService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -78,6 +79,9 @@ public class ProductOrderInfoServiceImpl extends ServiceImpl<ProductOrderInfoMap
|
|
|
@Resource
|
|
|
private IAfterSaleOrderService afterSaleOrderService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private IPointAccountService pointAccountService;
|
|
|
+
|
|
|
/**
|
|
|
* 创建商品订单
|
|
|
*
|
|
|
@@ -255,20 +259,31 @@ public class ProductOrderInfoServiceImpl extends ServiceImpl<ProductOrderInfoMap
|
|
|
if (orderInfo.getOrderStatus() != 0) {
|
|
|
throw new ServiceException("订单状态错误");
|
|
|
}
|
|
|
- // 3、校验支付金额是否正确
|
|
|
- if (orderInfo.getTotalAmount().compareTo(productOrderPayRequest.getTotalPrice()) != 0) {
|
|
|
- throw new ServiceException("支付金额错误");
|
|
|
- }
|
|
|
- // 4、校验支付方式是否正确
|
|
|
+ // 3、校验支付方式是否正确
|
|
|
if (orderInfo.getPayType() != productOrderPayRequest.getPayType()) {
|
|
|
- throw new ServiceException("支付方式错误");
|
|
|
+ throw new ServiceException("支付方式不正确");
|
|
|
}
|
|
|
- //判断支付方式
|
|
|
+
|
|
|
+ // 4、校验支付金额是否正确
|
|
|
+ if(productOrderPayRequest.getPayType().equals(MassageConstants.INTEGER_ONE) || productOrderPayRequest.getPayType().equals(MassageConstants.INTEGER_TWO)){
|
|
|
+ if (orderInfo.getTotalAmount().compareTo(productOrderPayRequest.getTotalPrice()) != 0) {
|
|
|
+ throw new ServiceException("支付金额错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //5、如果支付方式为积分支付,那么只需要校验支付的积分
|
|
|
+ if (productOrderPayRequest.getPayType().equals(MassageConstants.INTEGER_THREE)) {
|
|
|
+ if (orderInfo.getPointsUsed() != productOrderPayRequest.getPointsToPay()) {
|
|
|
+ throw new ServiceException("支付积分不正确");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //6、判断支付方式
|
|
|
if (productOrderPayRequest.getPayType().equals(MassageConstants.INTEGER_ONE)) {
|
|
|
//微信支付
|
|
|
R resp = rechargeService.getPay(orderInfo.getOrderNo(), orderInfo.getTotalAmount(), orderInfo.getOpenId(), BillTypeEnum.WX_PAY.getInfo(), BillTypeEnum.WX_PAY.getCode().toString());
|
|
|
return resp;
|
|
|
- } else {
|
|
|
+ } else if (productOrderPayRequest.getPayType().equals(MassageConstants.INTEGER_TWO)) {
|
|
|
//余额支付
|
|
|
TWxUser user = wxUserService.getByOpenId(orderInfo.getOpenId());
|
|
|
if (null == user) {
|
|
|
@@ -280,6 +295,10 @@ public class ProductOrderInfoServiceImpl extends ServiceImpl<ProductOrderInfoMap
|
|
|
orderPayManage(user, orderInfo);
|
|
|
return R.ok();
|
|
|
}
|
|
|
+ }else{
|
|
|
+ //积分支付
|
|
|
+ pointAccountService.deductPoints(orderInfo.getOpenId(), orderInfo.getPointsUsed(), orderInfo.getOrderNo(), "积分商品下单");
|
|
|
+ return R.ok();
|
|
|
}
|
|
|
}
|
|
|
|