/** * 批量代付接口 * * @param serialno * @param tDetailList * @return */ public Response payMoney(String serialno, List<TransDetail> tDetailList, String businessCode) { Request req = new Request(); RequestBody reqBody = new RequestBody(); RequestInfo reqInfo = new RequestInfo(); // info reqInfo.setTRX_CODE(TRX_CODE_100002); reqInfo.setVERSION("04"); reqInfo.setDATA_TYPE("2"); reqInfo.setUSER_NAME(username); reqInfo.setUSER_PASS(userpass); reqInfo.setREQ_SN(serialno); reqInfo.setSIGNED_MSG(""); req.setINFO(reqInfo); // body/sum int totalSum = 0; for (TransDetail tDetail : tDetailList) { totalSum += tDetail.getAMOUNT(); } TransSum tSum = new TransSum(); tSum.setBUSINESS_CODE(businessCode); tSum.setMERCHANT_ID(merchantId); tSum.setTOTAL_ITEM(tDetailList.size()); tSum.setTOTAL_SUM(totalSum); reqBody.setTRANS_SUM(tSum); // body/details reqBody.setTRANS_DETAIL(tDetailList); req.setBODY(reqBody); return send(req); }
/** * 实时代收接口 * * @param serialno * @param tDetailList * @return */ public Response collectMoney(String serialno, TransDetail tDetail, String businessCode) { Request req = new Request(); RequestBody reqBody = new RequestBody(); RequestInfo reqInfo = new RequestInfo(); // info reqInfo.setTRX_CODE(TRX_CODE_100004); reqInfo.setVERSION("04"); reqInfo.setDATA_TYPE("2"); reqInfo.setUSER_NAME(username); reqInfo.setUSER_PASS(userpass); reqInfo.setREQ_SN(serialno); reqInfo.setSIGNED_MSG(""); req.setINFO(reqInfo); // body/sum TransSum tSum = new TransSum(); tSum.setBUSINESS_CODE(businessCode); tSum.setMERCHANT_ID(merchantId); tSum.setTOTAL_ITEM(1); tSum.setTOTAL_SUM(tDetail.getAMOUNT()); reqBody.setTRANS_SUM(tSum); // body/details List<TransDetail> tDetailList = new ArrayList<TransDetail>(); tDetailList.add(tDetail); reqBody.setTRANS_DETAIL(tDetailList); req.setBODY(reqBody); return send(req); }