From 21a5bdc97d9a3436944b7edd932e854cf3d43f1f Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Thu, 21 Oct 2021 12:18:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cweb/controller/HighTestController.java | 95 ++++--------------- .../src/main/resources/prod/application.yml | 2 +- .../java/com/hai/config/UnionPayConfig.java | 70 ++++++++++++++ 3 files changed, 91 insertions(+), 76 deletions(-) create mode 100644 hai-service/src/main/java/com/hai/config/UnionPayConfig.java diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java b/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java index 17bc8728..1d6d626d 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java @@ -12,10 +12,7 @@ import com.hai.common.utils.*; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; -import com.hai.model.HighMerchantModel; -import com.hai.model.HighMerchantStoreModel; -import com.hai.model.ResponseData; -import com.hai.model.ResultProfitSharing; +import com.hai.model.*; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -185,12 +182,12 @@ public class HighTestController { return ResponseMsgUtil.success("初始化完成"); } - @RequestMapping(value = "/queryCompanyAccountInfo2JD", method = RequestMethod.GET) + @RequestMapping(value = "/pushTuanYouOrder", method = RequestMethod.GET) @ResponseBody - @ApiOperation(value = "查询团油账户") - public ResponseData queryCompanyAccountInfo2JD() { + @ApiOperation(value = "推送团油订单") + public ResponseData pushTuanYouOrder() { try { - /*HighOrder order = highOrderService.getOrderByOrderNo("HF2021091414532044405"); + HighOrder order = highOrderService.getOrderByOrderNo("HF2021100910141059900"); for (HighChildOrder highChildOrder : order.getHighChildOrderList()) { HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highChildOrder.getGoodsId()); // 推送团油订单 @@ -203,6 +200,7 @@ public class HighTestController { paramMap.put("priceGun", priceGun); // 枪单价 paramMap.put("priceVip", priceVip); // 优惠价 paramMap.put("driverPhone", order.getMemPhone()); + // paramMap.put("driverPhone", "17726395120"); paramMap.put("thirdSerialNo", order.getOrderNo()); paramMap.put("refuelingAmount", highChildOrder.getTotalPrice()); @@ -224,53 +222,31 @@ public class HighTestController { if (orderPushObject != null && orderPushObject.getString("code").equals("200")) { highChildOrder.setGasOrderNo(orderPushObject.getJSONObject("result").getString("orderNo")); } - }*/ - return ResponseMsgUtil.success(TuanYouConfig.queryCompanyAccountInfo2JD()); - } catch (Exception e) { - log.error("HighOrderController --> getOrderById() error!", e); - return ResponseMsgUtil.exception(e); - } - } - @RequestMapping(value = "/test2", method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "获取汇联通Token") - public ResponseData test2() { - try { - return ResponseMsgUtil.success(huiLianTongConfig.getToken()); + highOrderService.updateOrder(order); + } + return ResponseMsgUtil.success(order); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } - @RequestMapping(value = "/getCorpCouTypes", method = RequestMethod.GET) + @RequestMapping(value = "/queryCompanyAccountInfo2JD", method = RequestMethod.GET) @ResponseBody - @ApiOperation(value = "测试") - public ResponseData getCorpCouTypes(@RequestParam(name = "token", required = true) String token) { + @ApiOperation(value = "查询团油余额") + public ResponseData queryCompanyAccountInfo2JD() { try { - return ResponseMsgUtil.success(HuiLianTongConfig.getCorpCouTypes(token)); - } catch (Exception e) { - log.error("HighOrderController --> getOrderById() error!", e); - return ResponseMsgUtil.exception(e); - } - } - @RequestMapping(value = "/getCouState", method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "测试") - public ResponseData getCouState(@RequestParam(name = "token", required = true) String token, - @RequestParam(name = "couNo", required = true) String couNo) { - try { - return ResponseMsgUtil.success(HuiLianTongConfig.getCouState(token,couNo)); + return ResponseMsgUtil.success(TuanYouConfig.queryCompanyAccountInfo2JD()); } catch (Exception e) { - log.error("HighOrderController --> getOrderById() error!", e); + log.error("HighOrderController --> queryCompanyAccountInfo2JD() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/couJointDist", method = RequestMethod.GET) @ResponseBody - @ApiOperation(value = "测试") + @ApiOperation(value = "派发贵州卡券") public ResponseData couJointDist(@RequestParam(name = "token", required = true) String token) { try { return ResponseMsgUtil.success(HuiLianTongConfig.couJointDist(token,"HF"+System.currentTimeMillis(),"20JY000251",2,"17726395120", "oArhO6XxKSvjI9wLP3cTK-iSG8yY")); @@ -280,42 +256,12 @@ public class HighTestController { } } - @RequestMapping(value = "/splitSccount", method = RequestMethod.GET) + @RequestMapping(value = "/unionPay", method = RequestMethod.GET) @ResponseBody - @ApiOperation(value = "测试") - public ResponseData splitSccount() { + @ApiOperation(value = "银联支付") + public ResponseData unionPay() { try { - //List list = highOrderService.getErrorOrder(); - /* HighOrder order = highOrderService.getOrderByOrderNo("20210827003355621063330"); - BigDecimal rake = new BigDecimal("0.01"); - - // 计算微信收取的手续费 支付金额 * 0.002 注:如果与两个相邻数字的距离相等,则为上舍入的舍入模式。 - BigDecimal wxHandlingFee = order.getPayRealPrice().multiply(new BigDecimal("0.002")).setScale(2,BigDecimal.ROUND_HALF_DOWN); - BigDecimal price = order.getPayRealPrice().subtract(wxHandlingFee); - - // 计算分账金额 手续费后的价格 * 0.01 注:如果与两个相邻数字的距离相等,则为上舍入的舍入模式。 - BigDecimal profitSharingAmount = price.multiply(rake).setScale(2,BigDecimal.ROUND_DOWN); - this.wxProfitsharing(order.getPaySerialNo(),order.getOrderNo(),profitSharingAmount);*/ - - // 获取token - String token = huiLianTongConfig.getToken(); - - /*Map push = new HashMap<>(); - push.put("token", tokenObject.getString("data")); - push.put("couTypeCode", "20JY000575"); - push.put("distCouCount", 1); - push.put("userPhone", "13985049936"); - push.put("thirdUserId", "oArhO6VXHf4hUENO2Mkwm6BAiy0A");*/ - - // 推送给高速 - JSONObject returnParam = HuiLianTongConfig.couJointDist( - token, - "HF20210926163742075051", - "20JY000573", - 1, - "18585414282", - "oArhO6YcG2zQNdvTV-FktVaZ-bEw"); - return ResponseMsgUtil.success(returnParam); + return ResponseMsgUtil.success(UnionPayConfig.apppayacc()); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); @@ -368,7 +314,6 @@ public class HighTestController { } } - public CloseableHttpClient readCertificate(String mchId) throws Exception{ /** * 注意PKCS12证书 是从微信商户平台-》账户设置-》 API安全 中下载的 @@ -393,7 +338,7 @@ public class HighTestController { //小程序退款需要调用双向证书的认证 CloseableHttpClient httpClient = readCertificate(mchId); try { - HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/profitsharing"); // 设置响应头信息 + HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/refund"); // 设置响应头信息 httpost.addHeader("Connection", "keep-alive"); httpost.addHeader("Accept", "*/*"); httpost.addHeader("Content-Type", "text/xml"); diff --git a/hai-cweb/src/main/resources/prod/application.yml b/hai-cweb/src/main/resources/prod/application.yml index 084041b4..2cd8599a 100644 --- a/hai-cweb/src/main/resources/prod/application.yml +++ b/hai-cweb/src/main/resources/prod/application.yml @@ -9,7 +9,7 @@ debug: false #datasource数据源设置 spring: datasource: - url: jdbc:mysql://127.0.0.1:3306/hsg?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8 + url: jdbc:mysql://122.9.135.148:3306/hsg?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8 username: root password: HF123456. type: com.alibaba.druid.pool.DruidDataSource diff --git a/hai-service/src/main/java/com/hai/config/UnionPayConfig.java b/hai-service/src/main/java/com/hai/config/UnionPayConfig.java new file mode 100644 index 00000000..252675d3 --- /dev/null +++ b/hai-service/src/main/java/com/hai/config/UnionPayConfig.java @@ -0,0 +1,70 @@ +package com.hai.config; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.hai.common.pay.util.sdk.WXPayConstants; +import com.hai.common.utils.HttpsUtils; +import com.hai.common.utils.MD5Util; +import org.apache.commons.lang3.StringUtils; + +import java.util.*; + +/** + * 银联支付 + * @author hurui + */ +public class UnionPayConfig { + + public static JSONObject apppayacc() throws Exception { + Map paramMap = new HashMap<>(); +/* paramMap.put("channelid", "D01X66666666761"); + paramMap.put("merid", "531000012972390"); + paramMap.put("termid", "W1489519"); + paramMap.put("tradetrace", System.currentTimeMillis()); + paramMap.put("opt", "dirBankPay"); + paramMap.put("tradetype", "APP"); + paramMap.put("tradeamt", "1"); + paramMap.put("body", "test"); + paramMap.put("notifyurl", "notifyurl"); + paramMap.put("returnurl", "returnurl");*/ + + paramMap.put("channelid", "D01X66666666761"); + paramMap.put("merid", "531000012972390"); + paramMap.put("termid", "W1489519"); + paramMap.put("tradetrace", System.currentTimeMillis()); + paramMap.put("opt", "upPreOrder"); + paramMap.put("tradetype", "APP"); + paramMap.put("tradeamt", "1"); + paramMap.put("body", "test"); + paramMap.put("notifyurl", "notifyurl"); + + String reqStr = generateSignature(paramMap, null); + paramMap.put("sign", MD5Util.encode(generateSignature(paramMap,"sa72ivadl84273dlj2kdaia2idiadik5").getBytes()).toLowerCase()); + reqStr += "&sign=" + MD5Util.encode(generateSignature(paramMap,"sa72ivadl84273dlj2kdaia2idiadik5").getBytes()).toUpperCase(); + Map body = new LinkedHashMap<>(); + body.put("from", reqStr); + return HttpsUtils.doSmsPost("https://notify-test.eycard.cn:7443/WorthTech_Access_AppPaySystemV2/apppayacc", body, new HashMap<>()); + } + + public static String generateSignature(final Map data, String key){ + Set keySet = data.keySet(); + String[] keyArray = keySet.toArray(new String[keySet.size()]); + Arrays.sort(keyArray); + StringBuilder sb = new StringBuilder(); + for (String k : keyArray) { + if (k.equals(WXPayConstants.FIELD_SIGN)) { + continue; + } + if (StringUtils.isBlank(sb.toString())) { + sb.append(k).append("=").append(data.get(k)); + } else { + sb.append("&").append(k).append("=").append(data.get(k)); + } + } + if (StringUtils.isNotBlank(key)) { + sb.append("&key=").append(key); + } + return sb.toString(); + } + +}