|
|
|
@@ -13,6 +13,7 @@ import com.simple.common.ResultData; |
|
|
|
import com.simple.domain.po.*; |
|
|
|
import com.simple.enums.EnumOrderStatus; |
|
|
|
import com.simple.enums.EnumPayStatus; |
|
|
|
import com.simple.enums.EnumPayType; |
|
|
|
import com.simple.enums.EnumPayWay; |
|
|
|
import com.simple.exception.MallinkException; |
|
|
|
import com.simple.mapper.WxAppinfoMapper; |
|
|
|
@@ -86,6 +87,9 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
logger.error("pay order, order status not allow, repaymentReq: " + order.toString() + " , payWay: " + payWay.toString()); |
|
|
|
throw new MallinkException(ErrorCode.ORDER_IS_NOT_PAY); |
|
|
|
} |
|
|
|
if (order.getPaymentType() != EnumPayType.PAY_PAYMENT.getCode()) { |
|
|
|
return new ResultData(ErrorCode.PAY_ORDER_IS_NOT_PAYMENT); |
|
|
|
} |
|
|
|
// 2. check 是否有支付订单 |
|
|
|
Date currentDate = new Date(); |
|
|
|
List<WxPayOrder> list = wxPayOrderMapper.findList(record); |
|
|
|
@@ -355,32 +359,41 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
} |
|
|
|
|
|
|
|
Date currentDate = new Date(); |
|
|
|
// 修改支付订单状态 |
|
|
|
try { |
|
|
|
WxPayOrder updateOrder = new WxPayOrder(); |
|
|
|
updateOrder.setId(record.getId()); |
|
|
|
updateOrder.setOrderId(record.getOrderId()); |
|
|
|
updateOrder.setUpdateTime(currentDate); |
|
|
|
updateOrder.setPayOrderStatus(record.getPayOrderStatus()); |
|
|
|
updateOrder.setPayTimeEnd(currentDate); |
|
|
|
updateOrder.setFailReason(record.getFailReason()); |
|
|
|
wxPayOrderMapper.updateByPrimaryKeySelective(updateOrder); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
throw new MallinkException(ErrorCode.DB_FAIL); |
|
|
|
if (record.getId() > 0) { |
|
|
|
// 修改支付订单状态 |
|
|
|
// 订单金额为0时,支付订单不创建,直接更改订单状态 |
|
|
|
try { |
|
|
|
WxPayOrder updateOrder = new WxPayOrder(); |
|
|
|
updateOrder.setId(record.getId()); |
|
|
|
updateOrder.setOrderId(record.getOrderId()); |
|
|
|
updateOrder.setUpdateTime(currentDate); |
|
|
|
updateOrder.setPayOrderStatus(record.getPayOrderStatus()); |
|
|
|
updateOrder.setPayTimeEnd(currentDate); |
|
|
|
updateOrder.setFailReason(record.getFailReason()); |
|
|
|
wxPayOrderMapper.updateByPrimaryKeySelective(updateOrder); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
throw new MallinkException(ErrorCode.DB_FAIL); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 修改订单状态 |
|
|
|
if (record.getPayOrderStatus() == EnumPayStatus.PAY_WAY_SUCCESS.getCode()) { |
|
|
|
try { |
|
|
|
wxOrderService.updateOrderStatus(order.getId(), EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS); |
|
|
|
int _count = wxOrderService.updateOrderStatus(order.getId(), EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS); |
|
|
|
if (_count > 1) { |
|
|
|
throw new MallinkException(ErrorCode.ORDER_IS_FAIL); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
throw new MallinkException(ErrorCode.DB_FAIL); |
|
|
|
} |
|
|
|
} else if (record.getPayOrderStatus() == EnumPayStatus.PAY_WAY_CANCEL.getCode()) { |
|
|
|
try { |
|
|
|
wxOrderService.updateOrderStatus(order.getId(), EnumOrderStatus.ORDER_STATUS_OVERTIME_CANCEL); |
|
|
|
int _count = wxOrderService.updateOrderStatus(order.getId(), EnumOrderStatus.ORDER_STATUS_OVERTIME_CANCEL); |
|
|
|
if (_count > 1) { |
|
|
|
throw new MallinkException(ErrorCode.ORDER_IS_FAIL); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
throw new MallinkException(ErrorCode.DB_FAIL); |
|
|
|
|