Search in sources :

Example 1 with PtcPayInfo

use of com.paascloud.provider.model.domain.PtcPayInfo in project paascloud-master by paascloud.

the class PtcAlipayServiceImpl method aliPayCallback.

@Override
public Wrapper aliPayCallback(Map<String, String> params) {
    log.info("支付宝回调. - aliPayCallback. params={}", params);
    String orderNo = params.get("out_trade_no");
    String tradeNo = params.get("trade_no");
    String tradeStatus = params.get("trade_status");
    OrderDto order = omcOrderService.queryOrderDtoByOrderNo(orderNo);
    if (order == null) {
        throw new OmcBizException(ErrorCodeEnum.OMC10031010);
    }
    if (order.getStatus() >= OmcApiConstant.OrderStatusEnum.PAID.getCode()) {
        throw new OmcBizException(ErrorCodeEnum.OMC10031011);
    }
    if (PtcApiConstant.AlipayCallback.TRADE_STATUS_TRADE_SUCCESS.equals(tradeStatus)) {
        order.setPaymentTime(DateUtil.parseDate(params.get("gmt_payment")));
        order.setStatus(OmcApiConstant.OrderStatusEnum.PAID.getCode());
        ModelMapper modelMapper = new ModelMapper();
        OmcOrder omcOrder = modelMapper.map(order, OmcOrder.class);
        omcOrderService.update(omcOrder);
    }
    PtcPayInfo payInfo = new PtcPayInfo();
    payInfo.setUserId(order.getUserId());
    payInfo.setOrderNo(order.getOrderNo());
    payInfo.setPayPlatform(PtcApiConstant.PayPlatformEnum.ALIPAY.getCode());
    payInfo.setPlatformNumber(tradeNo);
    payInfo.setPlatformStatus(tradeStatus);
    payInfo.setUpdateTime(new Date());
    payInfo.setCreatedTime(new Date());
    payInfo.setCreator(order.getCreator());
    payInfo.setCreatorId(order.getUserId());
    payInfo.setLastOperator(order.getLastOperator());
    payInfo.setLastOperatorId(order.getLastOperatorId());
    payInfo.setId(UniqueIdGenerator.generateId());
    ptcPayInfoMapper.insertSelective(payInfo);
    return WrapMapper.ok();
}
Also used : PtcPayInfo(com.paascloud.provider.model.domain.PtcPayInfo) OrderDto(com.paascloud.provider.model.dto.OrderDto) OmcBizException(com.paascloud.provider.exceptions.OmcBizException) OmcOrder(com.paascloud.provider.model.domain.OmcOrder) Date(java.util.Date) ModelMapper(org.modelmapper.ModelMapper)

Aggregations

OmcBizException (com.paascloud.provider.exceptions.OmcBizException)1 OmcOrder (com.paascloud.provider.model.domain.OmcOrder)1 PtcPayInfo (com.paascloud.provider.model.domain.PtcPayInfo)1 OrderDto (com.paascloud.provider.model.dto.OrderDto)1 Date (java.util.Date)1 ModelMapper (org.modelmapper.ModelMapper)1