Commit 15d67332 by huluobin

微信支付校验

parent 32b30971
......@@ -66,6 +66,9 @@ public class PayServiceImpl implements PayService {
throw new RRException("订单状态异常");
}
this.checkCustomerBalance(currentCustomerId, orderId);
/*1、扣除余额*/
ConsumerCommand consumerCmd = ConsumerCommand.builder()
.amount(orderManage.getTotalPaymentAmount().multiply(new BigDecimal(100)).intValue())
......@@ -136,6 +139,22 @@ public class PayServiceImpl implements PayService {
}
private void checkCustomerBalance(Integer customerId, Integer orderId) throws RRException {
OrderManage orderManage = orderManageService.getById(orderId);
CustomerBalance customerBalance = customerBalanceMapper.selectOne(new LambdaQueryWrapper<CustomerBalance>().eq(CustomerBalance::getCustomerId, customerId));
if (customerBalance == null) {
throw new RRException("您不是会员,请直接使用pos支付");
}
if (orderManage.getTotalPaymentAmount().multiply(new BigDecimal(100)).intValue() < customerBalance.getBalance()) {
throw new RRException("请使用余额支付");
}
if (customerBalance.getBalance() <= 0) {
throw new RRException("余额为0,请直接使用pos支付");
}
}
@Override
public WxPayMpOrderResult balanceWxPay(BalanceWxPayQuery qry) throws UnknownHostException, WxPayException {
......@@ -146,15 +165,9 @@ public class PayServiceImpl implements PayService {
}
//2、余额检查
CustomerBalance customerBalance = customerBalanceMapper.selectOne(new LambdaQueryWrapper<CustomerBalance>().eq(CustomerBalance::getCustomerId, orderManage.getOrderUser()));
if (customerBalance == null) {
throw new RRException("余额不存在");
}
this.checkCustomerBalance(qry.getCustomerId(), qry.getOrderId());
CustomerBalance customerBalance = customerBalanceMapper.selectOne(new LambdaQueryWrapper<CustomerBalance>().eq(CustomerBalance::getCustomerId, qry.getCustomerId()));
if (orderManage.getTotalPaymentAmount().multiply(new BigDecimal(100)).intValue() < customerBalance.getBalance()) {
throw new RRException("请使用余额支付");
}
//3、微信统一下单
BigDecimal leftTotalPaymentAmount = orderManage.getTotalPaymentAmount().subtract(new BigDecimal(customerBalance.getBalance()).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP));
......@@ -193,12 +206,8 @@ public class PayServiceImpl implements PayService {
throw new RRException("订单状态异常");
}
//2、余额检查
CustomerBalance customerBalance = customerBalanceMapper.selectOne(new LambdaQueryWrapper<CustomerBalance>().eq(CustomerBalance::getCustomerId, currentCustomerId));
if (orderManage.getTotalPaymentAmount().multiply(new BigDecimal(100)).intValue() < customerBalance.getBalance()) {
throw new RRException("请使用余额支付");
}
this.checkCustomerBalance(currentCustomerId, orderId);
//3、更新订单
//支付类型:请余额pos支付
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment