修改话费定时任务问题

dev-discount
袁野 2 years ago
parent aa6f91aa43
commit b096362261
  1. 2
      hai-bweb/src/main/java/com/bweb/controller/HighOpenApiController.java
  2. 2
      hai-cweb/src/main/java/com/cweb/controller/HighTestController.java
  3. 36
      hai-service/src/main/java/com/hai/common/utils/HttpsUtils.java
  4. 32
      hai-service/src/main/java/com/hai/common/utils/WxUtils.java
  5. 4
      hai-service/src/main/java/com/hai/config/HuiLianTongConfig.java
  6. 28
      hai-service/src/main/java/com/hai/config/RechargeConfig.java

@ -203,7 +203,7 @@ public class HighOpenApiController {
highGasOrderPush.setRequestContent(JSONObject.toJSONString(object));
highGasOrderPush.setReturnContent(returnParam.toJSONString());
highGasOrderPushMapper.insert(highGasOrderPush);
if (returnParam == null || !returnParam.getString("result").equals("success")) {
if (!returnParam.getString("result").equals("success")) {
log.error("HighOpenApiController -> couJointDist() error!","商户派发电子券失败");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户派发电子券失败");
}

File diff suppressed because one or more lines are too long

@ -506,6 +506,42 @@ public class HttpsUtils {
return null;
}
public static JSONObject doPostByCy(String apiUrl, Map<String,Object> body) {
CloseableHttpClient httpClient = null;
if (apiUrl.startsWith("https")) {
httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory())
.setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build();
} else {
httpClient = HttpClients.createDefault();
}
String httpStr = null;
CloseableHttpResponse response = null;
try {
HttpPost httpPost = new HttpPost(apiUrl);
httpPost.setConfig(requestConfig);
StringEntity stringEntity = new StringEntity(JSON.toJSONString(body), "UTF-8");// 解决中文乱码问题
stringEntity.setContentType("application/json");
httpPost.setEntity(stringEntity);
response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
httpStr = EntityUtils.toString(entity, "UTF-8");
System.out.println("-------------------------------------------" + httpStr);
return JSON.parseObject(httpStr);
} catch (Exception e) {
log.error(e.getMessage(),e);
} finally {
if (response != null) {
try {
EntityUtils.consume(response.getEntity());
} catch (IOException e) {
log.error(e.getMessage(),e);
}
}
}
return null;
}
public static JSONObject doPostForm(String apiUrl, String body, Map<String,Object> header) {
CloseableHttpClient httpClient = null;
if (apiUrl.startsWith("https")) {

@ -438,6 +438,38 @@ public class WxUtils {
}
}
/**
* 生成龙阅签名. 注意若含有sign_type字段必须和signType参数保持一致
*
* @param data 待签名数据
* @param key API密钥
* @param signType 签名方式
* @return 签名
*/
public static String generateSignatureCy(final Map<String, Object> data, String key, WXPayConstants.SignType signType) throws Exception {
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 (data.get(k) != null) // 参数值为空,则不参与签名
sb.append(k).append("=").append(data.get(k)).append("&");
}
sb.append("appsecret=").append(key);
if (WXPayConstants.SignType.MD5.equals(signType)) {
return MD5(sb.toString() , true);
}
else if (WXPayConstants.SignType.HMACSHA256.equals(signType)) {
return HMACSHA256(sb.toString(), key);
}
else {
throw new Exception(String.format("Invalid sign_type: %s", signType));
}
}
/**
* 生成签名.
*

@ -42,6 +42,9 @@ public class HuiLianTongConfig {
@Resource
private RedisUtil redisUtil;
@Resource
private HighGasOrderPushMapper highGasOrderPushMapper;
/**
* 获取token
* @return
@ -155,7 +158,6 @@ public class HuiLianTongConfig {
JSONObject o = HuiLianTongUnionCardConfig.syncPayOrder(mapPost);
System.out.println("订单同步请求参数---------" + mapPost);
System.out.println("订单同步请求结果---------" + o);
}
}
} catch (Exception e) {

@ -148,12 +148,34 @@ public class RechargeConfig {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("agentOrderId" , object.getString("agentOrderId"));
paramMap.put("productId" , object.getString("productId"));
paramMap.put("productId" , object.getInteger("productId"));
paramMap.put("mobile" , object.getString("mobile"));
paramMap.put("timestamp" , DateUtil.date2String(new Date() , DateUtil.Y_M_D_HMS));
paramMap.put("appid" , CommonSysConst.getSysConfig().getCyApiKey());
paramMap.put("sign", WxUtils.generateSignatureLy(paramMap , CommonSysConst.getSysConfig().getCyAppSecret() , WXPayConstants.SignType.MD5));
return HttpsUtils.doPost(CommonSysConst.getSysConfig().getCyPostUrl()+ "/api/interface/recharge", paramMap , new HashMap<>());
paramMap.put("sign", WxUtils.generateSignatureCy(paramMap , CommonSysConst.getSysConfig().getCyAppSecret() , WXPayConstants.SignType.MD5));
return HttpsUtils.doPostByCy(CommonSysConst.getSysConfig().getCyPostUrl()+ "/api/interface/recharge", paramMap);
}
/**
* @Author Sum1Dream
* @name rechargeOrderByCy.java
* @Description // 城宇话费查询订单详情
* @Date 10:22 2022/7/14
* @Param [com.alibaba.fastjson.JSONObject]
* @return com.alibaba.fastjson.JSONObject
*/
public static JSONObject queryRechargeByCy(JSONObject object) throws Exception {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("orderId" , object.getString("orderNo"));
paramMap.put("timestamp" , DateUtil.date2String(new Date() , DateUtil.Y_M_D_HMS));
paramMap.put("appid" , CommonSysConst.getSysConfig().getCyApiKey());
paramMap.put("sign", WxUtils.generateSignatureCy(paramMap , CommonSysConst.getSysConfig().getCyAppSecret() , WXPayConstants.SignType.MD5));
return HttpsUtils.doPostByCy(CommonSysConst.getSysConfig().getCyPostUrl()+ "/api/interface/queryRecharge", paramMap);
}

Loading…
Cancel
Save