源码:
import java.io.ByteArrayOutputStream;
import javax.imageio.ImageIO;
import org.springframework.web.bind.annotation.RequestMapping;/*** 获取二维码图像* 二维码支付** @param price 金额* @return 二维码图像* @throws IOException IOException*/
@RequestMapping(value = "toQrPay.jpg", produces = "image/jpeg;charset=UTF-8")
public byte[] toQrPay(BigDecimal price) throws IOException {//获取对应的支付账户操作工具(可根据账户id)ByteArrayOutputStream baos = new ByteArrayOutputStream();ImageIO.write(service.genQrPay(new PayOrder("订单title","摘要",null == price ? BigDecimal.valueOf(0.01) : price,System.currentTimeMillis() + "", AliTransactionType.SWEEPPAY)),"JPEG",baos);return baos.toByteArray();
}