调用第三方接口缴费的通用逻辑

java 4 2016-02-29 13:03
女装

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

代码逻辑如下:

代码示例:

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;
}
女装
文章评论