支付回调

/**
 * 订单信息同步给商户
 *
 * @param corpId
 * @param jsonObject
 * @return
 */
@Override
public BaseResult orderCallBack(Long corpId, JSONObject jsonObject) {
    ApiCorpConfig apiCorpConfigQuery = new ApiCorpConfig();
    apiCorpConfigQuery.setCorpId(corpId);
    ApiCorpConfig apiCorpConfig = apiCorpConfigDao.selectOne(apiCorpConfigQuery);
    if (apiCorpConfig == null){
        throw new BaseBussinessException(ErrorCodeEnum.GW10019010);
    }
    String orderGrantNotifyAddress = apiCorpConfig.getOrderGrantNotifyAddress();
    if (StrUtil.isEmpty(orderGrantNotifyAddress)){
        return new BaseResult(false, 200, "没有配置回调地址");
    }
    NoticeSettlementVo noticeSettlementVo = new NoticeSettlementVo();
    noticeSettlementVo.setAppId(apiCorpConfig.getAppId());
    String jsonString  =JSON.toJSONString(jsonObject);
    noticeSettlementVo.setContent(jsonString);
    Long now = new Date().getTime();
    noticeSettlementVo.setTimestamp(now);
    String concatString = apiCorpConfig.getAppId()+apiCorpConfig.getSecret()+jsonString+ +now;
    String md5String = MD5Util.md5(concatString);
    noticeSettlementVo.setSign(md5String);
    String jsonBody = JSON.toJSONString(noticeSettlementVo);
    log.info("调用外部接口参数为:"+jsonBody);
    String body = "{\"flag\":\"false\"}";
    try {
        body = HttpRequest.post(orderGrantNotifyAddress).body(jsonBody).execute().body();
    }catch (Exception e){
        log.info(e.getMessage());
        e.printStackTrace();
    }
    log.info("调用外部接口返回值为:"+body);
    return JSON.parseObject(body,BaseResult.class);
}

 

上一篇:UISearchBar 自定义处理


下一篇:Spring Cloud Gateway过滤器精确控制异常返回(实战,控制http返回码和message字段)