提交代码

dev-discount
胡锐 3 years ago
parent 5e8a27ef34
commit 21a5bdc97d
  1. 95
      hai-cweb/src/main/java/com/cweb/controller/HighTestController.java
  2. 2
      hai-cweb/src/main/resources/prod/application.yml
  3. 70
      hai-service/src/main/java/com/hai/config/UnionPayConfig.java

@ -12,10 +12,7 @@ import com.hai.common.utils.*;
import com.hai.config.*; import com.hai.config.*;
import com.hai.dao.HighGasOrderPushMapper; import com.hai.dao.HighGasOrderPushMapper;
import com.hai.entity.*; import com.hai.entity.*;
import com.hai.model.HighMerchantModel; import com.hai.model.*;
import com.hai.model.HighMerchantStoreModel;
import com.hai.model.ResponseData;
import com.hai.model.ResultProfitSharing;
import com.hai.service.*; import com.hai.service.*;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -185,12 +182,12 @@ public class HighTestController {
return ResponseMsgUtil.success("初始化完成"); return ResponseMsgUtil.success("初始化完成");
} }
@RequestMapping(value = "/queryCompanyAccountInfo2JD", method = RequestMethod.GET) @RequestMapping(value = "/pushTuanYouOrder", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "查询团油账户") @ApiOperation(value = "推送团油订单")
public ResponseData queryCompanyAccountInfo2JD() { public ResponseData pushTuanYouOrder() {
try { try {
/*HighOrder order = highOrderService.getOrderByOrderNo("HF2021091414532044405"); HighOrder order = highOrderService.getOrderByOrderNo("HF2021100910141059900");
for (HighChildOrder highChildOrder : order.getHighChildOrderList()) { for (HighChildOrder highChildOrder : order.getHighChildOrderList()) {
HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highChildOrder.getGoodsId()); HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highChildOrder.getGoodsId());
// 推送团油订单 // 推送团油订单
@ -203,6 +200,7 @@ public class HighTestController {
paramMap.put("priceGun", priceGun); // 枪单价 paramMap.put("priceGun", priceGun); // 枪单价
paramMap.put("priceVip", priceVip); // 优惠价 paramMap.put("priceVip", priceVip); // 优惠价
paramMap.put("driverPhone", order.getMemPhone()); paramMap.put("driverPhone", order.getMemPhone());
// paramMap.put("driverPhone", "17726395120");
paramMap.put("thirdSerialNo", order.getOrderNo()); paramMap.put("thirdSerialNo", order.getOrderNo());
paramMap.put("refuelingAmount", highChildOrder.getTotalPrice()); paramMap.put("refuelingAmount", highChildOrder.getTotalPrice());
@ -224,53 +222,31 @@ public class HighTestController {
if (orderPushObject != null && orderPushObject.getString("code").equals("200")) { if (orderPushObject != null && orderPushObject.getString("code").equals("200")) {
highChildOrder.setGasOrderNo(orderPushObject.getJSONObject("result").getString("orderNo")); highChildOrder.setGasOrderNo(orderPushObject.getJSONObject("result").getString("orderNo"));
} }
}*/ highOrderService.updateOrder(order);
return ResponseMsgUtil.success(TuanYouConfig.queryCompanyAccountInfo2JD()); }
} catch (Exception e) { return ResponseMsgUtil.success(order);
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());
} catch (Exception e) { } catch (Exception e) {
log.error("HighOrderController --> getOrderById() error!", e); log.error("HighOrderController --> getOrderById() error!", e);
return ResponseMsgUtil.exception(e); return ResponseMsgUtil.exception(e);
} }
} }
@RequestMapping(value = "/getCorpCouTypes", method = RequestMethod.GET) @RequestMapping(value = "/queryCompanyAccountInfo2JD", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "测试") @ApiOperation(value = "查询团油余额")
public ResponseData getCorpCouTypes(@RequestParam(name = "token", required = true) String token) { public ResponseData queryCompanyAccountInfo2JD() {
try { 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) return ResponseMsgUtil.success(TuanYouConfig.queryCompanyAccountInfo2JD());
@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));
} catch (Exception e) { } catch (Exception e) {
log.error("HighOrderController --> getOrderById() error!", e); log.error("HighOrderController --> queryCompanyAccountInfo2JD() error!", e);
return ResponseMsgUtil.exception(e); return ResponseMsgUtil.exception(e);
} }
} }
@RequestMapping(value = "/couJointDist", method = RequestMethod.GET) @RequestMapping(value = "/couJointDist", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "测试") @ApiOperation(value = "派发贵州卡券")
public ResponseData couJointDist(@RequestParam(name = "token", required = true) String token) { public ResponseData couJointDist(@RequestParam(name = "token", required = true) String token) {
try { try {
return ResponseMsgUtil.success(HuiLianTongConfig.couJointDist(token,"HF"+System.currentTimeMillis(),"20JY000251",2,"17726395120", "oArhO6XxKSvjI9wLP3cTK-iSG8yY")); 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 @ResponseBody
@ApiOperation(value = "测试") @ApiOperation(value = "银联支付")
public ResponseData splitSccount() { public ResponseData unionPay() {
try { try {
//List<HighOrder> list = highOrderService.getErrorOrder(); return ResponseMsgUtil.success(UnionPayConfig.apppayacc());
/* 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<String, Object> 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);
} catch (Exception e) { } catch (Exception e) {
log.error("HighOrderController --> getOrderById() error!", e); log.error("HighOrderController --> getOrderById() error!", e);
return ResponseMsgUtil.exception(e); return ResponseMsgUtil.exception(e);
@ -368,7 +314,6 @@ public class HighTestController {
} }
} }
public CloseableHttpClient readCertificate(String mchId) throws Exception{ public CloseableHttpClient readCertificate(String mchId) throws Exception{
/** /**
* 注意PKCS12证书 是从微信商户平台-账户设置- API安全 中下载的 * 注意PKCS12证书 是从微信商户平台-账户设置- API安全 中下载的
@ -393,7 +338,7 @@ public class HighTestController {
//小程序退款需要调用双向证书的认证 //小程序退款需要调用双向证书的认证
CloseableHttpClient httpClient = readCertificate(mchId); CloseableHttpClient httpClient = readCertificate(mchId);
try { 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("Connection", "keep-alive");
httpost.addHeader("Accept", "*/*"); httpost.addHeader("Accept", "*/*");
httpost.addHeader("Content-Type", "text/xml"); httpost.addHeader("Content-Type", "text/xml");

@ -9,7 +9,7 @@ debug: false
#datasource数据源设置 #datasource数据源设置
spring: spring:
datasource: 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 username: root
password: HF123456. password: HF123456.
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource

@ -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<String,Object> 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<String,Object> 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<String, Object> data, String key){
Set<String> 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();
}
}
Loading…
Cancel
Save