订单支付金额为0时问题解决。

This commit is contained in:
Chopper
2021-06-07 17:36:48 +08:00
parent 203abe1087
commit c2367f763f
4 changed files with 50 additions and 8 deletions

View File

@@ -141,6 +141,7 @@ public enum ResultCode {
/**
* 支付
*/
PAY_UN_WANTED(32000, "当前订单不需要付款,返回订单列表等待系统订单出库即可"),
PAY_SUCCESS(32001, "支付成功"),
PAY_INCONSISTENT_ERROR(32002, "付款金额和应付金额不一致"),
PAY_DOUBLE_ERROR(32003, "订单已支付,不能再次进行支付"),

View File

@@ -220,6 +220,8 @@ public class Order extends BaseEntity {
}
}
}
//设置默认支付状态
this.setOrderStatus(OrderStatusEnum.UNPAID.name());
this.setPayStatus(PayStatusEnum.UNPAID.name());
this.setDeliverStatus(DeliverStatusEnum.UNDELIVERED.name());

View File

@@ -145,20 +145,28 @@ public class CashierSupport {
public CashierParam cashierParam(PayParam payParam) {
for (CashierExecute paramInterface : cashierExecuteList) {
CashierParam cashierParam = paramInterface.getPaymentParams(payParam);
if (cashierParam != null) {
cashierParam.setSupport(support(payParam.getClientType()));
cashierParam.setWalletValue(memberWalletService.getMemberWallet(UserContext.getCurrentUser().getId()).getMemberWallet());
OrderSetting orderSetting = JSONUtil.toBean(settingService.get(SettingEnum.ORDER_SETTING.name()).getSettingValue(), OrderSetting.class);
Integer minute = orderSetting.getAutoCancel();
cashierParam.setAutoCancel(cashierParam.getCreateTime().getTime() + minute * 1000 * 60);
return cashierParam;
//如果订单不需要付款,则抛出异常,直接返回
if (cashierParam.getPrice() <= 0) {
throw new ServiceException(ResultCode.PAY_UN_WANTED);
}
cashierParam.setSupport(support(payParam.getClientType()));
cashierParam.setWalletValue(memberWalletService.getMemberWallet(UserContext.getCurrentUser().getId()).getMemberWallet());
OrderSetting orderSetting = JSONUtil.toBean(settingService.get(SettingEnum.ORDER_SETTING.name()).getSettingValue(), OrderSetting.class);
Integer minute = orderSetting.getAutoCancel();
cashierParam.setAutoCancel(cashierParam.getCreateTime().getTime() + minute * 1000 * 60);
return cashierParam;
}
log.error("错误的支付请求:{}", payParam.toString());
throw new ServiceException(ResultCode.PAY_CASHIER_ERROR);
}
/**
* 支付结果
*
* @param payParam
* @return
*/
public Boolean paymentResult(PayParam payParam) {
for (CashierExecute cashierExecute : cashierExecuteList) {
if (cashierExecute.cashierEnum().name().equals(payParam.getOrderType())) {