|
|
@ -46,72 +46,13 @@ public class OrderService extends MybatisBaseService<OrderMapper, PayOrder> { |
|
|
|
order.setName(dto.getName()); |
|
|
|
order.setCreateBySid(dto.getUserSid()); |
|
|
|
order.setOpenId(dto.getOpenId()); |
|
|
|
order.setReturnUrl(dto.getReturnUrl()); |
|
|
|
baseMapper.insert(order); |
|
|
|
payOrderVo.setCreateTime(DateUtils.format(order.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); |
|
|
|
payOrderVo.setGoods(order.getName()); |
|
|
|
payOrderVo.setMainSid(order.getSid()); |
|
|
|
payOrderVo.setOutTradeNo(order.getOutTradeNo()); |
|
|
|
payOrderVo.setPrice(order.getTotalTee()); |
|
|
|
/* OrderVo orderVo = new OrderVo(); |
|
|
|
Map<Object, Object> resultObj = new TreeMap(); |
|
|
|
if (dto.getPayType() == 0) {//支付宝
|
|
|
|
return rb.setMsg("暂不支持支付宝支付"); |
|
|
|
} else if (dto.getPayType() == 1) { |
|
|
|
try { |
|
|
|
Map<Object, Object> parame = new TreeMap<Object, Object>(); |
|
|
|
parame.put("appid", order.getAppId()); |
|
|
|
// 商家账号。
|
|
|
|
parame.put("mch_id", order.getMchId()); |
|
|
|
String randomStr = CharUtil.getRandomNum(18).toUpperCase(); |
|
|
|
// 随机字符串
|
|
|
|
parame.put("nonce_str", randomStr); |
|
|
|
// 商户订单编号
|
|
|
|
parame.put("out_trade_no", order.getOutTradeNo()); |
|
|
|
|
|
|
|
// 商品描述
|
|
|
|
parame.put("body", order.getRemark()); |
|
|
|
|
|
|
|
//支付金额
|
|
|
|
parame.put("total_fee", new BigDecimal(dto.getTotalTee()).multiply(new BigDecimal(100)).intValue()); |
|
|
|
// 回调地址
|
|
|
|
parame.put("notify_url", "http://192.168.0.111:7777/wxPay/payNotify"); |
|
|
|
// 交易类型APP
|
|
|
|
parame.put("trade_type", tradeType); |
|
|
|
parame.put("spbill_create_ip", ip); |
|
|
|
parame.put("openid", dto.getOpenId()); |
|
|
|
String sign = WechatUtil.arraySign(parame, order.getSecret()); |
|
|
|
// 数字签证
|
|
|
|
parame.put("sign", sign); |
|
|
|
String xml = MapUtils.convertMap2Xml(parame); |
|
|
|
log.info("xml:" + xml); |
|
|
|
Map<String, Object> resultUn = XmlUtil.xmlStrToMap(WechatUtil.requestOnce(uniformorder, xml)); |
|
|
|
// 响应报文
|
|
|
|
String return_code = MapUtils.getString("return_code", resultUn); |
|
|
|
String return_msg = MapUtils.getString("return_msg", resultUn); |
|
|
|
if (return_code.equalsIgnoreCase("FAIL")) { |
|
|
|
return rb.setMsg("支付失败," + return_msg); |
|
|
|
} else if (return_code.equalsIgnoreCase("SUCCESS")) { |
|
|
|
String prepay_id = MapUtils.getString("prepay_id", resultUn); |
|
|
|
// 先生成paySign 参考https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=7_7&index=5
|
|
|
|
resultObj.put("appId", order.getAppId()); |
|
|
|
resultObj.put("timeStamp", DateUtils.timeToStr(System.currentTimeMillis() / 1000, DateUtils.DATE_TIME_PATTERN)); |
|
|
|
resultObj.put("nonceStr", nonceStr); |
|
|
|
// resultObj.put("package", "prepay_id=" + prepay_id);
|
|
|
|
resultObj.put("package", "Sign=WXPay"); |
|
|
|
resultObj.put("partnerid", order.getMchId()); |
|
|
|
resultObj.put("signType", "MD5"); |
|
|
|
resultObj.put("prepayid", prepay_id); |
|
|
|
String paySign = WechatUtil.arraySign(resultObj, order.getSecret()); |
|
|
|
// resultObj.put("paySign", paySign);
|
|
|
|
resultObj.put("sign", paySign); |
|
|
|
return rb.success().setData(orderVo); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
return rb.setMsg("支付失败,error=" + e.getMessage()); |
|
|
|
} |
|
|
|
}*/ |
|
|
|
|
|
|
|
return rb.success().setData(payOrderVo); |
|
|
|
} |
|
|
|
|
|
|
@ -163,7 +104,7 @@ public class OrderService extends MybatisBaseService<OrderMapper, PayOrder> { |
|
|
|
parame.put("trade_type", tradeType); |
|
|
|
parame.put("spbill_create_ip", ip); |
|
|
|
parame.put("openid", payOrder.getOpenId()); |
|
|
|
parame.put("sign_type","MD5"); |
|
|
|
parame.put("sign_type", "MD5"); |
|
|
|
String sign = WechatUtil.arraySign(parame, wxPayVo.getSecret()); |
|
|
|
// 数字签证
|
|
|
|
parame.put("sign", sign); |
|
|
@ -179,9 +120,9 @@ public class OrderService extends MybatisBaseService<OrderMapper, PayOrder> { |
|
|
|
// 返回数据
|
|
|
|
String result_code = MapUtils.getString("result_code", resultUn); |
|
|
|
String err_code_des = MapUtils.getString("err_code_des", resultUn); |
|
|
|
if(result_code.equalsIgnoreCase("FAIL")){ |
|
|
|
if (result_code.equalsIgnoreCase("FAIL")) { |
|
|
|
return rb.setMsg("支付失败," + err_code_des); |
|
|
|
}else if (result_code.equalsIgnoreCase("SUCCESS")) { |
|
|
|
} else if (result_code.equalsIgnoreCase("SUCCESS")) { |
|
|
|
String prepay_id = MapUtils.getString("prepay_id", resultUn); |
|
|
|
// sign = MapUtils.getString("sign", resultUn);
|
|
|
|
// 先生成paySign 参考https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=7_7&index=5
|
|
|
|