订单支付金额为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

@ -0,0 +1,31 @@
package cn.lili.event.impl;
import cn.lili.event.TradeEvent;
import cn.lili.modules.order.cart.entity.dto.TradeDTO;
import cn.lili.modules.order.order.service.TradeService;
import cn.lili.modules.payment.kit.enums.PaymentMethodEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 订单状态处理类
*
* @author Chopper
* @date 2020-07-03 11:20
**/
@Service
public class OrderStatusHandlerExecute implements TradeEvent {
@Autowired
private TradeService tradeService;
@Override
public void orderCreate(TradeDTO tradeDTO) {
//如果订单需要支付金额为0则将订单步入到下一个流程
if (tradeDTO.getPriceDetailDTO().getFlowPrice() <= 0) {
tradeService.payTrade(tradeDTO.getSn(), PaymentMethodEnum.BANK_TRANSFER.name(), "-1");
}
}
}

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())) {