2019独角兽企业重金招聘Python工程师标准>>>
1.public ResultObject forNotSupSwSendAlipayRequest(String orderNo) {
//获取订单信息
BaseMapEntity orderParamMap = new BaseMapEntity();
orderParamMap.put("orderNo",orderNo);
orderParamMap.put("status",7);//订单状态(1.待车主接单 2.待租客支付 3.租客取车选择 4.待车主确认交车 5.待租客确认取车 6.车辆使用中 7.待车主确认还车 8.租客押金冻结 9.待车主确认退还租客押金 10已完成 11.已取消)
BaseMapEntity vehicleOrderMap = vehicleOrderDao.queryVehicleOrderInfo(orderParamMap);
if(null == vehicleOrderMap){
return ResultObjectDto.initError(1, "订单不存在或状态已改变");
}
// TODO chenCang 2018-11-26 增加冻结转支付逻辑
BaseMapEntity waterMap = new BaseMapEntity();
waterMap.put("orderNo", orderNo);
waterMap.put("profitType", 3);
waterMap.put("purseChannel", 4);
//查询订单流水: 无论有没有预授权,接下来的分账操作一定会完成
BaseMapEntity userPurse = userPurseWaterDao.selectByOrderNo(waterMap);
if (userPurse != null) {
String tradeNo = userPurse.getString("thirdTradeNo"); //支付宝交易流水号
if (!StringUtils.isBlank(tradeNo)) {
String realCostStr = vehicleOrderMap.getString("orderRealCost");
String depositStr = vehicleOrderMap.getString("orderCostDeposit");
BigDecimal realCost = new BigDecimal(realCostStr);
if (!StringUtils.isBlank(depositStr)) {
realCost = realCost.subtract(new BigDecimal(depositStr));
}
//预授权转支付
String payUserId = userPurse.getString("payUserId");
AlipayUtils.authTradePay(orderNo,tradeNo,"预授权转支付",realCost.toString(),null,"NOT_COMPLETE",payUserId,AlipayBusiTypeEnum.ALPAY300);
}
}
return ResultObjectDto.initOk();
}
2. /**
* 支付宝授权转支付
* @Date 2018/11/15 14:02
* @Param orderNo 订单号
* @Param authNo 预授权冻结交易号
* @Param subject 解冻转支付标题,用于展示在支付宝账单中
* @Param amount 结算支付金额
* @Param body 备注信息
* @Param authConfirmMode 预授权确认模式,授权转交易请求中传入,适用于预授权转交易业务使用,COMPLETE:转交易支付完成结束预授权,解冻剩余金额; NOT_COMPLETE:转交易支付完成不结束预授权,不解冻剩余金额
* @Param busiType 业务类型
* @return java.lang.String
**/
public static String authTradePay(
String orderNo,
String authNo,
String subject,
String amount,
String body,
String authConfirmMode,
String payUserId,
AlipayBusiTypeEnum busiType) {
String alipaySeller = ConfigUtil.getSettings("alipay_seller");
String outOrderNo = orderNo + Long.toString(System.currentTimeMillis());
AlipayClient alipayClient = getAlipayClient();
AlipayTradePayRequest request = new AlipayTradePayRequest();
AlipayTradePayModel model = new AlipayTradePayModel();
model.setOutTradeNo(outOrderNo); // 预授权转支付商户订单号,为新的商户交易流水号;如果重试发起扣款,商户订单号不要变;
model.setProductCode("PRE_AUTH_ONLINE"); // 固定值PRE_AUTH_ONLINE
model.setAuthNo(authNo); // 填写预授权冻结交易号
model.setSubject(subject); // 解冻转支付标题,用于展示在支付宝账单中
model.setTotalAmount(amount); // 结算支付金额
model.setSellerId(alipaySeller); // 填写卖家支付宝账户pid
model.setBuyerId(payUserId); // 填写预授权用户uid,通过预授权冻结接口返回的payer_user_id字段获取
//model.setStoreId("test_store_id"); // 填写实际交易发生的终端编号,与预授权的outStoreCode保持一致即可
model.setBody(body); // 可填写备注信息
model.setAuthConfirmMode(authConfirmMode);//必须使用COMPLETE,传入该值用户剩余金额会自动解冻
request.setBizModel(model);
String notifyUrl = ConfigUtil.getSettings("pament_domain")+"/api/pay/alipaycallback/" + busiType.getBusiTypeCode() + "/dealBusinessForAlipayCallback.do";
request.setNotifyUrl(notifyUrl);//异步通知地址,必填,该接口只通过该参数进行异步通知
String result = "";
try{
AlipayTradePayResponse response = alipayClient.execute(request);
if(response.isSuccess()){
logger.info("订单:"+orderNo+"支付宝授权转支付成功===>"+response.getBody());
result = response.getBody();
} else {
logger.info("订单:"+orderNo+"支付宝授权转支付失败"+response.getMsg());
}
//处理交易流水记录
BaseMapEntity waterMap = new BaseMapEntity();
waterMap.put("className", "com.ds.tech.service.util.alibaba.AlipayUtils");
waterMap.put("methodName", "authTradePay");
waterMap.put("tradeType", "2"); //交易方式:1.银行卡 2.支付宝 3.微信
waterMap.put("tradeInput", JSONObject.toJSON(request).toString());
waterMap.put("tradeOutput", JSONObject.toJSON(response).toString());
waterMap.put("tradeTime", new Date());
userPurseWaterHisMapper.insertUserPurseWaterHistory(waterMap);
}catch (AlipayApiException e){
logger.info(ExceptionUtil.getExceptionStr("订单:"+orderNo+"支付宝授权转支付失败",e));
}
return result;
}
3.