Search in sources :

Example 1 with Wrapper

use of com.paascloud.wrapper.Wrapper in project paascloud-master by paascloud.

the class MqMessageServiceImpl method confirmReceiveMessage.

@Override
@Transactional(rollbackFor = Exception.class)
public void confirmReceiveMessage(String cid, MqMessageData messageData) {
    final String messageKey = messageData.getMessageKey();
    log.info("confirmReceiveMessage - 消费者={}, 确认收到key={}的消息", cid, messageKey);
    // 先保存消息
    messageData.setMessageType(MqMessageTypeEnum.CONSUMER_MESSAGE.messageType());
    messageData.setId(UniqueIdGenerator.generateId());
    mqMessageDataMapper.insertSelective(messageData);
    Wrapper wrapper = tpcMqMessageFeignApi.confirmReceiveMessage(cid, messageKey);
    log.info("tpcMqMessageFeignApi.confirmReceiveMessage result={}", wrapper);
    if (wrapper == null) {
        throw new TpcBizException(ErrorCodeEnum.GL99990002);
    }
    if (wrapper.error()) {
        throw new TpcBizException(ErrorCodeEnum.TPC10050004, wrapper.getMessage(), messageKey);
    }
}
Also used : Wrapper(com.paascloud.wrapper.Wrapper) TpcBizException(com.paascloud.provider.exceptions.TpcBizException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with Wrapper

use of com.paascloud.wrapper.Wrapper in project paascloud-master by paascloud.

the class MqMessageServiceImpl method saveAndConfirmFinishMessage.

@Override
public void saveAndConfirmFinishMessage(String cid, String messageKey) {
    Wrapper wrapper = tpcMqMessageFeignApi.confirmConsumedMessage(cid, messageKey);
    log.info("tpcMqMessageFeignApi.confirmReceiveMessage result={}", wrapper);
    if (wrapper == null) {
        throw new TpcBizException(ErrorCodeEnum.GL99990002);
    }
    if (wrapper.error()) {
        throw new TpcBizException(ErrorCodeEnum.TPC10050004, wrapper.getMessage(), messageKey);
    }
}
Also used : Wrapper(com.paascloud.wrapper.Wrapper) TpcBizException(com.paascloud.provider.exceptions.TpcBizException)

Example 3 with Wrapper

use of com.paascloud.wrapper.Wrapper in project paascloud-master by paascloud.

the class MqMessageServiceImpl method confirmAndSendMessage.

@Override
public void confirmAndSendMessage(String messageKey) {
    // 发送确认消息给消息中心
    try {
        Wrapper wrapper = tpcMqMessageFeignApi.confirmAndSendMessage(messageKey);
        if (wrapper == null) {
            throw new TpcBizException(ErrorCodeEnum.GL99990002);
        }
        if (wrapper.error()) {
            throw new TpcBizException(ErrorCodeEnum.TPC10050004, wrapper.getMessage(), messageKey);
        }
        log.info("<== saveMqProducerMessage - 存储并发送消息给消息中心成功. messageKey={}", messageKey);
    } catch (Exception e) {
        log.error("<== saveMqProducerMessage - 存储并发送消息给消息中心失败. messageKey={}", messageKey, e);
    }
}
Also used : Wrapper(com.paascloud.wrapper.Wrapper) TpcBizException(com.paascloud.provider.exceptions.TpcBizException) TpcBizException(com.paascloud.provider.exceptions.TpcBizException)

Example 4 with Wrapper

use of com.paascloud.wrapper.Wrapper in project paascloud-master by paascloud.

the class PtcPayController method alipayCallback.

/**
 * 支付宝回调信息.
 *
 * @param request the request
 *
 * @return the object
 */
@PostMapping("/alipayCallback")
@ApiOperation(httpMethod = "POST", value = "支付宝回调信息")
public Object alipayCallback(HttpServletRequest request) {
    logger.info("收到支付宝回调信息");
    Map<String, String> params = Maps.newHashMap();
    Map requestParams = request.getParameterMap();
    for (Object o : requestParams.keySet()) {
        String name = (String) o;
        String[] values = (String[]) requestParams.get(name);
        String valueStr = "";
        for (int i = 0; i < values.length; i++) {
            valueStr = (i == values.length - 1) ? valueStr + values[i] : valueStr + values[i] + ",";
        }
        params.put(name, valueStr);
    }
    logger.info("支付宝回调,sign:{},trade_status:{},参数:{}", params.get("sign"), params.get("trade_status"), params.toString());
    // 非常重要,验证回调的正确性,是不是支付宝发的.并且呢还要避免重复通知.
    params.remove("sign_type");
    try {
        boolean alipayRSACheckedV2 = AlipaySignature.rsaCheckV2(params, Configs.getAlipayPublicKey(), "utf-8", Configs.getSignType());
        if (!alipayRSACheckedV2) {
            return WrapMapper.error("非法请求,验证不通过,再恶意请求我就报警找网警了");
        }
    } catch (AlipayApiException e) {
        logger.error("支付宝验证回调异常", e);
    }
    // todo 验证各种数据
    Wrapper serverResponse = ptcAlipayService.aliPayCallback(params);
    if (serverResponse.success()) {
        return PtcApiConstant.AlipayCallback.RESPONSE_SUCCESS;
    }
    return PtcApiConstant.AlipayCallback.RESPONSE_FAILED;
}
Also used : Wrapper(com.paascloud.wrapper.Wrapper) AlipayApiException(com.alipay.api.AlipayApiException) Map(java.util.Map) PostMapping(org.springframework.web.bind.annotation.PostMapping) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

Wrapper (com.paascloud.wrapper.Wrapper)4 TpcBizException (com.paascloud.provider.exceptions.TpcBizException)3 AlipayApiException (com.alipay.api.AlipayApiException)1 ApiOperation (io.swagger.annotations.ApiOperation)1 Map (java.util.Map)1 Transactional (org.springframework.transaction.annotation.Transactional)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1