http请求,xml格式

  • b0_609761
    了解作者
  • 856.3KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-01 11:50
    上传日期
http请求,传输方式以xml格式,可以以文件的方式传输,或以拼接字符串的方式请求http请求,传输方式以xml格式,可以以文件的方式传输,或以拼接字符串的方式请求
testpractice.rar
内容介绍
package com.taobao.o2o.facade.service.impl; import com.taobao.api.domain.AcquireOrderQueryResult; import com.taobao.api.domain.AcquireRefundResult; import com.taobao.api.request.TradeAcquireCloseorderRequest; import com.taobao.api.request.TradeAcquireCreateandpayRequest; import com.taobao.api.request.TradeAcquireOrderQueryRequest; import com.taobao.api.request.TradeAcquirePrecreateRequest; import com.taobao.api.request.TradeAcquireRefundQueryRequest; import com.taobao.api.request.TradeAcquireRefundRequest; import com.taobao.api.response.TradeAcquireCloseorderResponse; import com.taobao.api.response.TradeAcquireCreateandpayResponse; import com.taobao.api.response.TradeAcquireOrderQueryResponse; import com.taobao.api.response.TradeAcquirePrecreateResponse; import com.taobao.api.response.TradeAcquireRefundQueryResponse; import com.taobao.api.response.TradeAcquireRefundResponse; import com.taobao.o2o.facade.PayStatusUtil; import com.taobao.o2o.facade.TradeResultErrorCodeUtil; import com.taobao.o2o.facade.domain.O2OCreateAndPayInput; import com.taobao.o2o.facade.domain.O2OOrderCloseInput; import com.taobao.o2o.facade.domain.O2OOrderQueryInput; import com.taobao.o2o.facade.domain.O2OOrderRefundInput; import com.taobao.o2o.facade.domain.O2OOrderRefundQueryInput; import com.taobao.o2o.facade.domain.O2OPrecreateInput; import com.taobao.o2o.facade.result.O2OOrderCloseResult; import com.taobao.o2o.facade.result.O2OOrderQueryResult; import com.taobao.o2o.facade.result.O2OOrderRefundResult; import com.taobao.o2o.facade.result.O2OPrecreateOrderResult; import com.taobao.o2o.facade.service.O2OTradeService; import com.taobao.o2o.facade.service.OrderLogService; import com.taobao.o2o.gateway.service.impl.OrderCloseTradeServiceImpl; import com.taobao.o2o.gateway.service.impl.OrderQueryTradeServiceImpl; import com.taobao.o2o.gateway.service.impl.OrderRefundQueryTradeServiceImpl; import com.taobao.o2o.gateway.service.impl.OrderRefundTradeServiceImpl; import com.taobao.o2o.gateway.service.impl.PrecreateOrderTradeServiceImpl; import com.taobao.o2o.gateway.service.impl.SoundWeaveBarCodeTradeServiceImpl; /******* * o2o facade服务层,接收来自pos系统或者商家系统内部的请求 * <p> * <li>把来自商家请求进行转发,到gateway * <li>进行错误代码/错误信息的转码 * <li>创建相关请求对象TaobaoRequest的后代类的实例时,目前都是采用setter方式做的,如果从代码简洁性来说,你可考虑使用反射做成通用的方式 * </p> * */ public class O2OTradeServiceImpl implements O2OTradeService { private SoundWeaveBarCodeTradeServiceImpl soundWeaveBarCodeTradeService; private PrecreateOrderTradeServiceImpl precreateOrderService; private OrderQueryTradeServiceImpl orderQueryTradeService; private OrderCloseTradeServiceImpl orderCloseTradeService; private OrderRefundTradeServiceImpl orderRefundTradeService; private OrderRefundQueryTradeServiceImpl orderRefundQueryTradeService; private OrderLogService orderLogService; // 声波条码下单 public O2OOrderQueryResult createAndPayOrder(O2OCreateAndPayInput input) { orderLogService.writeOrderLog(input.getOperatorId(), input.getIp(), input.getOutId()); O2OOrderQueryResult r2 = new O2OOrderQueryResult(); TradeAcquireCreateandpayRequest req = createOrder4CreateAndPayRequest(input); TradeAcquireCreateandpayResponse r = soundWeaveBarCodeTradeService .service(req); if (!r.isSuccess()) { r2.setSuccess(false); convertO2OCreateAndPayErrorCode(r2, r); } else { createO2OOrderQueryResult(r2, r.getSoundWavePayOrderResult()); } return r2; } // 订单查询 public O2OOrderQueryResult orderQuery(O2OOrderQueryInput input) { O2OOrderQueryResult r2 = new O2OOrderQueryResult(); TradeAcquireOrderQueryRequest req = createOrderQueryRequest(input); TradeAcquireOrderQueryResponse r = orderQueryTradeService.service(req); if (!r.isSuccess() || r.getO2oOrderPayResult() == null) { r2.setSuccess(false); convertO2OOrderQueryErrorCode(r2, r); } else { createO2OOrderQueryResult(r2, r.getO2oOrderPayResult()); } return r2; } // 预下单生成二维码(j仅仅是生成二维码) // 预下单的数据,不能直接通过查询接口去查询订单信息 public O2OPrecreateOrderResult createQrcode4Precreate( O2OPrecreateInput input) { orderLogService.writeOrderLog(input.getOperatorId(), input.getIp(), input.getOutId()); O2OPrecreateOrderResult r2 = new O2OPrecreateOrderResult(); TradeAcquirePrecreateRequest req = createTradeAcquirePrecreateRequest(input); TradeAcquirePrecreateResponse r = precreateOrderService.service(req); if (!r.isSuccess()) { r2.setSuccess(false); decodePrecreateOrderErrorCode(r2, r); } else { createO2OPrecreateOrderResult(r2, r); } return r2; } public O2OOrderCloseResult orderClose(O2OOrderCloseInput input) { O2OOrderCloseResult r2 = new O2OOrderCloseResult(); TradeAcquireCloseorderRequest req = createOrderCloseRequest(input); TradeAcquireCloseorderResponse r = orderCloseTradeService.service(req); if (!r.isSuccess()) { r2.setSuccess(false); convertO2OOrderCloseErrorCode(r2, r); } else { createO2OOrderCloseResult(r2, r); } return r2; } @Override public O2OOrderRefundResult orderRefund(O2OOrderRefundInput input) { O2OOrderRefundResult r2 = new O2OOrderRefundResult(); TradeAcquireRefundRequest req = createOrderRefundRequest(input); TradeAcquireRefundResponse r = orderRefundTradeService.service(req); if (!r.isSuccess()) { r2.setSuccess(false); convertO2OOrderRefundErrorCode(r2, r); } else { createO2OOrderRefundResult(r2, r.getO2oRefundOrderResult()); } return r2; } @Override public O2OOrderRefundResult orderRefundQuery(O2OOrderRefundQueryInput input) { O2OOrderRefundResult r2 = new O2OOrderRefundResult(); TradeAcquireRefundQueryRequest req = createOrderRefundQueryRequest(input); TradeAcquireRefundQueryResponse r = orderRefundQueryTradeService .service(req); if (!r.isSuccess()) { r2.setSuccess(false); convertO2OOrderRefundQueryErrorCode(r2, r); } else { createO2OOrderRefundResult(r2, r.getO2oRefundOrderResult()); } return r2; } /******* * 按照pos系统的ip查询最近1笔订单信息 * */ public O2OOrderQueryResult queryLastOrderByIp(String ip, String currentOper, String currentIp) { String outId = orderLogService.queryLastOrderByIp(ip); O2OOrderQueryInput input = new O2OOrderQueryInput(); input.setIp(currentIp); input.setOperatorId(currentOper); input.setOutId(outId); return orderQuery(input); } /******* * 按照pos系统的操作人员查询最近1笔订单信息 * */ public O2OOrderQueryResult queryLastOrderByOper(String oper, String currentOper, String currentIp) { String outId = orderLogService.queryLastOrderByOper(oper); O2OOrderQueryInput input = new O2OOrderQueryInput(); input.setIp(currentIp); input.setOperatorId(currentOper); input.setOutId(outId); return orderQuery(input); } private void createO2OOrderRefundResult(O2OOrderRefundResult r2, AcquireRefundResult r) { r2.setAlipayRefundFlowNo(r.getAlipayRefundFlowNo()); r2.setAlipayTradeNo(r.getAlipayTradeNo()); r2.setBuyerAlipayId(r.getBuyerAlipayId()); r2.setBuyerId(r.getBuyerId()); r2.setBuyerNick(r.getBuyerNick()); r2.setFundIsChanged(r.getFundIsChanged()); r2.setMaxCanRefundFee(r.getMaxCanRefundFee()); r2.setOutId(r.getOutId()); r2.setOutRefundReqNo(r.getOutRefundReqNo()); r2.setReceiptNo(r.getReceiptNo()); r2.setRefundAmount(r.getRefundAmount()); r2.setSellerAlipayId(r.getSellerAlipayId()); r2.setSellerId(r.getSellerId()); r2.setSellerNick(r.getSellerNick()); r2.setTradeNo(r.getTradeNo()); r2.setSuccess(true); } private TradeAcquireRefundRequest createOrderRefu
评论
    相关推荐