下面是我总结的调用第三方接口缴费的通用逻辑

代码逻辑如下:

图片描述

代码示例:

public RestDTO<BaseDTO> charge(Param param)
        throws Exception {
    String xxxx = "xxxxxxxxxxxxxxxxxxxxxxxxx";
    String xxx = "xxxxxxxxxxxxxxxxxxxxxxx";
    User user = Mapper.getUserById(param.getUserId());        
     String pwd = SeUtil.checkHashKey(user.getUser(), param.getPwd(),param);
    //校验密码
    if (!user.getPwd().equals(pwd)) {
        throw new ServiceException(Error.errorPwd);
    }
    //随机生成一个唯一的id值
    Long orderId = Long.valueOf(orderNoService.getNextId());
    String xxx = FileMd5Util.md5Hex(xxx + xxx + param.xxxxx
             +param.xxxx + orderId);
    Map<String, String> map = new HashMap<String, String>();
    map.put("xxxxxx", xxxxxxxx);
    map.put("xxxxx", xxxxxx));
    map.put("xxxx", xxxx);
    map.put("xxxx", xxxxx);
    map.put("xxxxx", xxxxxx);
    String rslt = APIProxy.getExample().get(
            "https://xxxxxx.cn.com/ossxay/xxxxxx", map);
    logger.info("充值/缴费返回值 {}", rslt);

    if (!rslt.contains("\"error_code\":0")) {
        throw new ServiceException(Error.error500);
    }

    RestDTO<BaseDTO> dto = new RestDTO<BaseDTO>();
    dto.setStatus(RestStatus.SUCCESS);
    dto.setMessage("充值成功/缴费成功");
    return dto;
}

MichaelDuan
1.8k 声望39 粉丝

« 上一篇
servlet容器