@Test void tradePrecreate() { assertTrue(StringUtils.isNotBlank(alipayRunner.tradePrecreate(1001L))); }
public String tradePrecreate(long seckillId) { Seckill seckill = redisService.getSeckill(seckillId); Goods goods = goodsMapper.selectById(seckill.getGoodsId()); String outTradeNo = "tradeprecreate" + System.currentTimeMillis() + (long) (Math.random() * 10000000L); Factory.setOptions(getOptions()); try { AlipayTradePrecreateResponse response = Factory.Payment.FaceToFace() .preCreate(goods.getName(), outTradeNo, String.valueOf(seckill.getPrice())); if (ResponseChecker.success(response)) { String finalQrcodeImagePath = String.format(qrcodeImagePath + "/qr-%s.png", response.outTradeNo); ZxingUtils.getQRCodeImge(response.qrCode, 256, finalQrcodeImagePath); log.info("支付宝当面扫调用成功！"); return finalQrcodeImagePath.split("/")[finalQrcodeImagePath.split("/").length - 1]; } else { log.error("调用失败，原因：" + response.msg + "，" + response.subMsg); } } catch (Exception e) { log.error("调用遭遇异常，原因：" + e.getMessage()); } return null; }
AlipayRunner { public String tradePrecreate(long seckillId) { Seckill seckill = redisService.getSeckill(seckillId); Goods goods = goodsMapper.selectById(seckill.getGoodsId()); String outTradeNo = "tradeprecreate" + System.currentTimeMillis() + (long) (Math.random() * 10000000L); Factory.setOptions(getOptions()); try { AlipayTradePrecreateResponse response = Factory.Payment.FaceToFace() .preCreate(goods.getName(), outTradeNo, String.valueOf(seckill.getPrice())); if (ResponseChecker.success(response)) { String finalQrcodeImagePath = String.format(qrcodeImagePath + "/qr-%s.png", response.outTradeNo); ZxingUtils.getQRCodeImge(response.qrCode, 256, finalQrcodeImagePath); log.info("支付宝当面扫调用成功！"); return finalQrcodeImagePath.split("/")[finalQrcodeImagePath.split("/").length - 1]; } else { log.error("调用失败，原因：" + response.msg + "，" + response.subMsg); } } catch (Exception e) { log.error("调用遭遇异常，原因：" + e.getMessage()); } return null; } }
AlipayRunner { public String tradePrecreate(long seckillId) { Seckill seckill = redisService.getSeckill(seckillId); Goods goods = goodsMapper.selectById(seckill.getGoodsId()); String outTradeNo = "tradeprecreate" + System.currentTimeMillis() + (long) (Math.random() * 10000000L); Factory.setOptions(getOptions()); try { AlipayTradePrecreateResponse response = Factory.Payment.FaceToFace() .preCreate(goods.getName(), outTradeNo, String.valueOf(seckill.getPrice())); if (ResponseChecker.success(response)) { String finalQrcodeImagePath = String.format(qrcodeImagePath + "/qr-%s.png", response.outTradeNo); ZxingUtils.getQRCodeImge(response.qrCode, 256, finalQrcodeImagePath); log.info("支付宝当面扫调用成功！"); return finalQrcodeImagePath.split("/")[finalQrcodeImagePath.split("/").length - 1]; } else { log.error("调用失败，原因：" + response.msg + "，" + response.subMsg); } } catch (Exception e) { log.error("调用遭遇异常，原因：" + e.getMessage()); } return null; }  }
AlipayRunner { public String tradePrecreate(long seckillId) { Seckill seckill = redisService.getSeckill(seckillId); Goods goods = goodsMapper.selectById(seckill.getGoodsId()); String outTradeNo = "tradeprecreate" + System.currentTimeMillis() + (long) (Math.random() * 10000000L); Factory.setOptions(getOptions()); try { AlipayTradePrecreateResponse response = Factory.Payment.FaceToFace() .preCreate(goods.getName(), outTradeNo, String.valueOf(seckill.getPrice())); if (ResponseChecker.success(response)) { String finalQrcodeImagePath = String.format(qrcodeImagePath + "/qr-%s.png", response.outTradeNo); ZxingUtils.getQRCodeImge(response.qrCode, 256, finalQrcodeImagePath); log.info("支付宝当面扫调用成功！"); return finalQrcodeImagePath.split("/")[finalQrcodeImagePath.split("/").length - 1]; } else { log.error("调用失败，原因：" + response.msg + "，" + response.subMsg); } } catch (Exception e) { log.error("调用遭遇异常，原因：" + e.getMessage()); } return null; }  String tradePrecreate(long seckillId); }
AlipayRunner { public String tradePrecreate(long seckillId) { Seckill seckill = redisService.getSeckill(seckillId); Goods goods = goodsMapper.selectById(seckill.getGoodsId()); String outTradeNo = "tradeprecreate" + System.currentTimeMillis() + (long) (Math.random() * 10000000L); Factory.setOptions(getOptions()); try { AlipayTradePrecreateResponse response = Factory.Payment.FaceToFace() .preCreate(goods.getName(), outTradeNo, String.valueOf(seckill.getPrice())); if (ResponseChecker.success(response)) { String finalQrcodeImagePath = String.format(qrcodeImagePath + "/qr-%s.png", response.outTradeNo); ZxingUtils.getQRCodeImge(response.qrCode, 256, finalQrcodeImagePath); log.info("支付宝当面扫调用成功！"); return finalQrcodeImagePath.split("/")[finalQrcodeImagePath.split("/").length - 1]; } else { log.error("调用失败，原因：" + response.msg + "，" + response.subMsg); } } catch (Exception e) { log.error("调用遭遇异常，原因：" + e.getMessage()); } return null; }  String tradePrecreate(long seckillId);  }