|
|
@@ -226,6 +226,80 @@ public class LeYunFuController {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @RequestMapping(value = "/appUnifiedOrder", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public Map<String, String> appUnifiedOrder(@RequestParam(required = true, value = "userId") String userId,
|
|
|
+ @RequestParam(required = true, value = "productId") String productId,
|
|
|
+ @RequestParam(required = true, value = "ip") String ip) {
|
|
|
+ try {
|
|
|
+
|
|
|
+
|
|
|
+ double cash = 1;
|
|
|
+
|
|
|
+ ProductInfo productInfo = productInfoService.getProductInfoById(productId);
|
|
|
+
|
|
|
+ cash = productInfo.getMoney().doubleValue();
|
|
|
+
|
|
|
+ int total = 0;
|
|
|
+
|
|
|
+
|
|
|
+ total = (int) (cash * 100);
|
|
|
+
|
|
|
+ //测试为一分
|
|
|
+ total = 1;
|
|
|
+
|
|
|
+ JSONObject attach = new JSONObject();
|
|
|
+ attach.put("productId", productId);
|
|
|
+ attach.put("userId", userId);
|
|
|
+ attach.put("cash", cash);
|
|
|
+ attach.put("total", total);
|
|
|
+
|
|
|
+
|
|
|
+ String out_trade_no = MbappUtil.create_out_trade_no();
|
|
|
+ String nonceStr = MbappUtil.create_nonce_str();
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, String> params = new TreeMap<>();
|
|
|
+ params.put("mch_id", PropertiesFileLoader.getProperties("leyunfu_mch_id")); //商户号
|
|
|
+ params.put("nonce_str", nonceStr); //随机串
|
|
|
+ params.put("amount", String.valueOf(total)); //金额 单位分
|
|
|
+ params.put("body", productInfo.getProductName()); //商品或支付单简要描述
|
|
|
+ params.put("out_trade_no", out_trade_no); //商户系统内部的订单号
|
|
|
+ params.put("notify_url", PropertiesFileLoader.getProperties("leyunfu_return_url")); //接收支付结果异步通知回调地址
|
|
|
+ params.put("spbill_create_ip", ip); //客户端IP
|
|
|
+ params.put("return_url", PropertiesFileLoader.getProperties("leyunfu_notify_url")); //页面回调地址
|
|
|
+ params.put("payment_type", "trade.weixin.app"); //支付类型
|
|
|
+ params.put("attach", attach.toString()); //附加数据
|
|
|
+
|
|
|
+
|
|
|
+ String signSrc = getSignSrc(params);
|
|
|
+ String sign = DigestUtils.md5Hex(signSrc + "&key=" + PropertiesFileLoader.getProperties("leyunfu_mch_secret"));
|
|
|
+ params.put("sign_type", "MD5"); //签名方式
|
|
|
+ params.put("sign", sign); //签名
|
|
|
+
|
|
|
+
|
|
|
+ WxpayTemp wxpayTemp = new WxpayTemp();
|
|
|
+ wxpayTemp.setOrderId(productId);
|
|
|
+ wxpayTemp.setUserId(userId);
|
|
|
+ wxpayTemp.setCash(BigDecimal.valueOf(cash));
|
|
|
+ wxpayTemp.setTotalAmount(BigDecimal.valueOf(total / 100.0));
|
|
|
+ wxpayTemp.setOutTradeNo(out_trade_no);
|
|
|
+ wxpayTemp.setTypeFlag(AppConstant.Aliapi.BUY);
|
|
|
+ wxpayTemp.setResultCode("NOT_PAY");
|
|
|
+ wxpayTemp.setCreateUser("lyf");
|
|
|
+ wxpayTempMapper.insertSelective(wxpayTemp);
|
|
|
+
|
|
|
+ return params;
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("leyunfu下单失败", e);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return null;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@RequestMapping(value = "/orderquery", method = RequestMethod.GET)
|
|
|
@ResponseBody
|
|
|
public String orderquery(@RequestParam(required = true, value = "out_trade_no") String out_trade_no) {
|