| | |
| | | |
| | | JSONObject userResult = JSONObject.parseObject(responseEntity.getBody().toString()); |
| | | int total = userResult.getIntValue("total"); |
| | | if(total < 1){ |
| | | if (total < 1) { |
| | | //未查询到用户信息 |
| | | throw new IllegalArgumentException("未查询微信用户"); |
| | | } |
| | |
| | | paramMap.put("appid", wechatAuthProperties.getAppId()); |
| | | paramMap.put("mch_id", wechatAuthProperties.getMchId()); |
| | | paramMap.put("nonce_str", PayUtil.makeUUID(32)); |
| | | paramMap.put("body", ""); |
| | | paramMap.put("body", "HC智慧家园-停车费"); |
| | | paramMap.put("out_trade_no", orderNum); |
| | | paramMap.put("total_fee", PayUtil.moneyToIntegerStr(payAmount)); |
| | | paramMap.put("spbill_create_ip", PayUtil.getLocalIp()); |
| | |
| | | //转换为xml |
| | | String xmlData = PayUtil.mapToXml(paramMap); |
| | | |
| | | logger.debug("调用支付统一下单接口" + xmlData); |
| | | |
| | | ResponseEntity<String> responseEntity = restTemplate.postForEntity( |
| | | wechatAuthProperties.getWxPayUnifiedOrder(), xmlData, String.class); |
| | | |
| | | logger.debug("统一下单返回"+responseEntity); |
| | | //请求微信后台,获取预支付ID |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { |
| | | throw new IllegalArgumentException("支付失败" + responseEntity.getBody()); |