init version for new gitea
This commit is contained in:
127
src/main/java/com/saye/hrs/scheduler/CheckRecharge.java
Normal file
127
src/main/java/com/saye/hrs/scheduler/CheckRecharge.java
Normal file
@@ -0,0 +1,127 @@
|
||||
//package com.saye.hrs.scheduler;
|
||||
//
|
||||
//import java.util.Date;
|
||||
//import java.util.HashMap;
|
||||
//import java.util.List;
|
||||
//import java.util.TreeMap;
|
||||
//import java.util.Map.Entry;
|
||||
//
|
||||
//import javax.annotation.Resource;
|
||||
//
|
||||
//import org.slf4j.Logger;
|
||||
//import org.slf4j.LoggerFactory;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//import org.springframework.http.HttpEntity;
|
||||
//import org.springframework.http.HttpHeaders;
|
||||
//import org.springframework.http.HttpMethod;
|
||||
//import org.springframework.http.MediaType;
|
||||
//import org.springframework.http.ResponseEntity;
|
||||
//import org.springframework.scheduling.annotation.Scheduled;
|
||||
//import org.springframework.web.client.RestTemplate;
|
||||
//
|
||||
//import com.alibaba.fastjson.JSON;
|
||||
//import com.saye.hrs.commons.date.DateDUtil;
|
||||
//import com.saye.hrs.commons.encrypt.EncryptUtil;
|
||||
//import com.saye.hrs.commons.string.StringDUtil;
|
||||
//import com.saye.hrs.commons.webservice.WSUtil;
|
||||
//import com.saye.hrs.controller.ApiController;
|
||||
//import com.saye.hrs.model.StatusDefine;
|
||||
//
|
||||
//@Configuration
|
||||
//public class CheckRecharge {
|
||||
//
|
||||
// private static final Logger logger = LoggerFactory.getLogger(ApiController.class);
|
||||
//
|
||||
// @Scheduled(cron="0 */1 * * * ?")
|
||||
// public void run() {
|
||||
// logger.debug("定时检查充值信息开始!");
|
||||
// try {
|
||||
// RestTemplate restTemplate = new RestTemplate();
|
||||
// HttpHeaders headers = new HttpHeaders();
|
||||
// headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
|
||||
// String url = StatusDefine.IP_PORT+"/api/findRechargeWait";
|
||||
// HttpEntity<String> entity = new HttpEntity<String>("{}", headers);
|
||||
// ResponseEntity<List> resp =restTemplate.exchange(url, HttpMethod.POST, entity, List.class);
|
||||
// List list = resp.getBody();
|
||||
// for(int i=0;i<list.size();i++) {
|
||||
// HashMap orderMap = (HashMap) list.get(i);
|
||||
// String merOrderId = StringDUtil.changeNullToEmpty(orderMap.get("MERORDERID"));
|
||||
// TreeMap<Object,Object> map = new TreeMap<Object,Object>();
|
||||
// map.put("msgSrcId", "12YK");
|
||||
// map.put("msgSrc", "WWW.KRLSFYBJ.COM");
|
||||
// map.put("msgType", "query");
|
||||
// map.put("requestTimestamp", DateDUtil.getTheCurrentTime());
|
||||
// map.put("merOrderId", merOrderId);
|
||||
// map.put("mid", "898652880620011");
|
||||
// map.put("tid", "65954193");
|
||||
// map.put("signType", "SHA256");
|
||||
// String key = "KfG8PnwGSK8AXQFKtyfQnKi3x5kcZtDkWX2tctAMhcF5e6Ax";
|
||||
// StringBuilder str = new StringBuilder();
|
||||
// for(Entry<Object, Object> e: map.entrySet()) {
|
||||
// str.append(e.getKey());
|
||||
// str.append("=");
|
||||
// str.append(e.getValue());
|
||||
// str.append("&");
|
||||
// }
|
||||
// str.deleteCharAt(str.length()-1);
|
||||
// str.append(key);
|
||||
// String sign = EncryptUtil.getSHA256Str(str.toString());
|
||||
// map.put("sign", sign.toUpperCase());
|
||||
// url = "https://qr.chinaums.com/netpay-route-server/api/";
|
||||
// String body = JSON.toJSONString(map);
|
||||
// entity = new HttpEntity<String>(body, headers);
|
||||
// ResponseEntity<HashMap> resp1 =restTemplate.exchange(url, HttpMethod.POST, entity, HashMap.class);
|
||||
// HashMap result = resp1.getBody();
|
||||
// String status = StringDUtil.changeNullToEmpty(result.get("status"));
|
||||
// String targetOrderId = StringDUtil.changeNullToEmpty(result.get("targetOrderId"));
|
||||
// //支付结果信息写入数据库
|
||||
// HashMap<Object,Object> requestMap = new HashMap<Object,Object>();
|
||||
// url = StatusDefine.IP_PORT+"/api/addHisRecharge";
|
||||
// requestMap.put("status", status);
|
||||
// requestMap.put("merOrderId", merOrderId);
|
||||
// requestMap.put("targetOrderId", targetOrderId);
|
||||
// requestMap.put("resultText", JSON.toJSONString(result));
|
||||
// HttpEntity<String> entity1 = new HttpEntity<String>(JSON.toJSONString(requestMap), headers) ;
|
||||
// ResponseEntity<HashMap> resp2 =restTemplate.exchange(url, HttpMethod.POST, entity1, HashMap.class);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// logger.error("定时检查充值信息异常"+e.toString());
|
||||
// }
|
||||
// logger.debug("定时检查充值信息结束!");
|
||||
// }
|
||||
//
|
||||
// public static void main(String[] args) {
|
||||
// RestTemplate restTemplate = new RestTemplate();
|
||||
// HttpHeaders headers = new HttpHeaders();
|
||||
// headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
|
||||
// HttpEntity<String> entity = new HttpEntity<String>("{}", headers);
|
||||
// String merOrderId = "12YK20231211121037254";
|
||||
// TreeMap<Object,Object> map = new TreeMap<Object,Object>();
|
||||
// map.put("msgSrcId", "12YK");
|
||||
// map.put("msgSrc", "WWW.KRLSFYBJ.COM");
|
||||
// map.put("msgType", "query");
|
||||
// map.put("requestTimestamp", DateDUtil.getTheCurrentTime());
|
||||
// map.put("merOrderId", merOrderId);
|
||||
// map.put("mid", "898652880620011");
|
||||
// map.put("tid", "65954193");
|
||||
// map.put("signType", "SHA256");
|
||||
// String key = "KfG8PnwGSK8AXQFKtyfQnKi3x5kcZtDkWX2tctAMhcF5e6Ax";
|
||||
// StringBuilder str = new StringBuilder();
|
||||
// for(Entry<Object, Object> e: map.entrySet()) {
|
||||
// str.append(e.getKey());
|
||||
// str.append("=");
|
||||
// str.append(e.getValue());
|
||||
// str.append("&");
|
||||
// }
|
||||
// str.deleteCharAt(str.length()-1);
|
||||
// str.append(key);
|
||||
// String sign = EncryptUtil.getSHA256Str(str.toString());
|
||||
// map.put("sign", sign.toUpperCase());
|
||||
// String url = "https://qr.chinaums.com/netpay-route-server/api/";
|
||||
// String body = JSON.toJSONString(map);
|
||||
// entity = new HttpEntity<String>(body, headers);
|
||||
// ResponseEntity<HashMap> resp1 =restTemplate.exchange(url, HttpMethod.POST, entity, HashMap.class);
|
||||
// HashMap result = resp1.getBody();
|
||||
// System.out.println(result);
|
||||
// }
|
||||
//}
|
||||
59
src/main/java/com/saye/hrs/scheduler/LoadStatusDefine.java
Normal file
59
src/main/java/com/saye/hrs/scheduler/LoadStatusDefine.java
Normal file
@@ -0,0 +1,59 @@
|
||||
package com.saye.hrs.scheduler;
|
||||
|
||||
import com.saye.hrs.commons.log.LogUtil;
|
||||
import com.saye.hrs.model.StatusDefine;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description: 项目启动完成后加载默认参数
|
||||
* @author thuang
|
||||
* @date 2022/3/15 13:17
|
||||
* @version 1.0
|
||||
*/
|
||||
@Component
|
||||
@Order(value = 1)
|
||||
public class LoadStatusDefine implements ApplicationRunner {
|
||||
|
||||
@Autowired
|
||||
private Environment environment;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
LogUtil.debug(this.getClass(),"/************************************开始加载系统默认参数*************************************************/");
|
||||
|
||||
String appid = environment.getProperty("appid");
|
||||
String secret = environment.getProperty("secret");
|
||||
String wxMchid = environment.getProperty("wxMchid");
|
||||
String wxWechartkey = environment.getProperty("wxWechartkey");
|
||||
String wxybkey = environment.getProperty("wxybkey");
|
||||
String wxCertPath = environment.getProperty("wxCertPath");
|
||||
String ip_port = environment.getProperty("IP_PORT");
|
||||
String wxTokenUrl = environment.getProperty("wxTokenUrl");
|
||||
String cityId = environment.getProperty("cityId");//这个不用了
|
||||
String channel = environment.getProperty("channel");
|
||||
|
||||
StatusDefine.wxAppId=appid;
|
||||
StatusDefine.wxSecret=secret;
|
||||
StatusDefine.wxMchid=wxMchid;
|
||||
StatusDefine.wxWechartkey=wxWechartkey;
|
||||
StatusDefine.wxybkey=wxybkey;
|
||||
StatusDefine.wxCertPath=wxCertPath;
|
||||
StatusDefine.IP_PORT=ip_port;
|
||||
StatusDefine.wxTokenUrl=wxTokenUrl;
|
||||
StatusDefine.channel=channel;
|
||||
|
||||
LogUtil.debug(this.getClass(),"/************************************加载系统默认参数完成*************************************************/");
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
182
src/main/java/com/saye/hrs/scheduler/ReSendMessage.java
Normal file
182
src/main/java/com/saye/hrs/scheduler/ReSendMessage.java
Normal file
@@ -0,0 +1,182 @@
|
||||
//package com.saye.hrs.scheduler;
|
||||
//
|
||||
//import com.alibaba.fastjson.JSONObject;
|
||||
//import com.saye.hrs.commons.date.DateDUtil;
|
||||
//import com.saye.hrs.commons.log.LogUtil;
|
||||
//import com.saye.hrs.commons.qitahoutai.HoutaiService;
|
||||
//import com.saye.hrs.commons.string.StringDUtil;
|
||||
//import com.saye.hrs.commons.webservice.OtherWSUtil;
|
||||
//import com.saye.hrs.commons.wxpay.pojo.PassbackParams;
|
||||
//import com.saye.hrs.commons.wxpay.pojo.WxResult;
|
||||
//import com.saye.hrs.dto.SettlementDTO;
|
||||
//import com.saye.hrs.model.StatusDefine;
|
||||
//import com.saye.hrs.model.WxybResult;
|
||||
//import com.saye.hrs.model.YbPassbackParams;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//import org.springframework.scheduling.annotation.Scheduled;
|
||||
//
|
||||
//import javax.annotation.Resource;
|
||||
//import java.math.BigDecimal;
|
||||
//import java.math.RoundingMode;
|
||||
//import java.net.URLDecoder;
|
||||
//import java.util.Calendar;
|
||||
//import java.util.Date;
|
||||
//import java.util.HashMap;
|
||||
//import java.util.List;
|
||||
//
|
||||
///***
|
||||
// * @title ReSendMessage
|
||||
// * @description TODO 已经废弃 本地不做任何处理
|
||||
// * @author thuang
|
||||
// * @create 2023/8/22 10:10
|
||||
// **/
|
||||
//@Configuration
|
||||
//public class ReSendMessage {
|
||||
//
|
||||
// @Resource
|
||||
// private HoutaiService houtaiService;
|
||||
//
|
||||
// @Scheduled(cron="0 0 0 * * ?")
|
||||
// private void ReSendLastMessage(){
|
||||
// //获取前一个星期没发送成功的记录,重新发送
|
||||
// Calendar calendar = Calendar.getInstance();
|
||||
// calendar.setTime(new Date());
|
||||
// calendar.add(Calendar.DATE,-7);
|
||||
// Date time = calendar.getTime();
|
||||
// String startTime = DateDUtil.DateToStr(DateDUtil.yyyyMMdd, time);
|
||||
//
|
||||
// //查询数据库中的记录 先查询微信没发送的
|
||||
// try {
|
||||
// String findUrl= StatusDefine.IP_PORT+"/api/getWxNotSendInfo";
|
||||
// HashMap<Object,Object> searchMap=new HashMap<>();
|
||||
// searchMap.put("endTime", DateDUtil.yyyyMMdd);
|
||||
// searchMap.put("startTime", startTime);
|
||||
// HashMap<Object, Object> map = houtaiService.PostInfoByParam(findUrl, searchMap);
|
||||
// String errCode = StringDUtil.changeNullToEmpty(map.get("errCode"));
|
||||
//
|
||||
// if ("0".equals(errCode)){
|
||||
// List<WxResult> mapList = (List<WxResult>) map.get("List");
|
||||
//
|
||||
// //重新发送
|
||||
// for (WxResult wxResult : mapList) {
|
||||
// try {
|
||||
// PassbackParams callBackParam = JSONObject.parseObject(URLDecoder.decode(wxResult.getAttach(), "UTF-8"), PassbackParams.class);
|
||||
// if ("SUCCESS".equals(wxResult.getResult_code()) && "SUCCESS".equals(wxResult.getReturn_code())) {
|
||||
//
|
||||
// //查询后台错误 不知道有没有发过 先发了再说
|
||||
// SettlementDTO reqDTO=new SettlementDTO();
|
||||
// reqDTO.setPatid(callBackParam.getPatid());
|
||||
// reqDTO.setSjh(callBackParam.getSjh());
|
||||
// reqDTO.setZje(callBackParam.getZje());
|
||||
// reqDTO.setYsje(callBackParam.getYsje());
|
||||
// reqDTO.setPaymoney(callBackParam.getZfje());
|
||||
// reqDTO.setPaytype("9");
|
||||
// reqDTO.setPaylsh(wxResult.getTransaction_id());
|
||||
// reqDTO.setZfjsbz("1");
|
||||
// HashMap<Object, Object> settlementResultMap = OtherWSUtil.Settlement(reqDTO);
|
||||
//
|
||||
// String errCode1 = StringDUtil.changeNullToEmpty(settlementResultMap.get("errCode"));
|
||||
//
|
||||
// if ("0".equals(errCode1)){
|
||||
// wxResult.setMzjsStatus("1");
|
||||
// }else {
|
||||
// wxResult.setMzjsStatus("0");
|
||||
// LogUtil.error(this.getClass(),StringDUtil.changeNullToEmpty(settlementResultMap.get("errMsg")));
|
||||
// }
|
||||
//
|
||||
// //成功存储信息
|
||||
// String url = StatusDefine.IP_PORT+"/api/addWxPayInfo";
|
||||
// houtaiService.PostInfoByParam(url,wxResult);
|
||||
//
|
||||
// }
|
||||
// }catch (Exception e){
|
||||
// e.printStackTrace();
|
||||
// LogUtil.error(this.getClass(),"晚上定时发送未写入his的记录失败,原因"+e.getMessage());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }catch (Exception e){
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// //再查询医保没发送的
|
||||
// try {
|
||||
// String findUrl= StatusDefine.IP_PORT+"/api/getWxybNotSendInfo";
|
||||
// HashMap<Object,Object> searchMap=new HashMap<>();
|
||||
// searchMap.put("endTime", DateDUtil.yyyyMMdd);
|
||||
// searchMap.put("startTime", startTime);
|
||||
// HashMap<Object, Object> map = houtaiService.PostInfoByParam(findUrl, searchMap);
|
||||
// String errCode = StringDUtil.changeNullToEmpty(map.get("errCode"));
|
||||
//
|
||||
// if ("0".equals(errCode)){
|
||||
// List<WxybResult> mapList = (List<WxybResult>) map.get("List");
|
||||
//
|
||||
// for (WxybResult wxybResult : mapList) {
|
||||
// try {
|
||||
// YbPassbackParams callBackParam = JSONObject.parseObject(URLDecoder.decode(wxybResult.getAttach(), "UTF-8"), YbPassbackParams.class);
|
||||
//
|
||||
// if ("SUCCESS".equals(wxybResult.getResult_code()) && "SUCCESS".equals(wxybResult.getReturn_code())) {
|
||||
// //查询后台错误 不知道有没有发过 先发了再说
|
||||
// SettlementDTO reqDTO = new SettlementDTO();
|
||||
// reqDTO.setPatid(callBackParam.getPatid());
|
||||
// reqDTO.setSjh(wxybResult.getSerial_no());
|
||||
// reqDTO.setYsje(callBackParam.getYsje());
|
||||
//
|
||||
// //从微信返回的金额为分,要改为元来传输给his
|
||||
// Integer totalFee = wxybResult.getTotal_fee();
|
||||
// Integer cashFee = wxybResult.getCash_fee();
|
||||
// BigDecimal totalFeeBD = new BigDecimal(totalFee).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);
|
||||
// BigDecimal cashFeeBD = new BigDecimal(cashFee).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);
|
||||
//
|
||||
// reqDTO.setZje(totalFeeBD.toString());
|
||||
// reqDTO.setPaymoney(cashFeeBD.toString());
|
||||
// reqDTO.setPaytype("9");
|
||||
// reqDTO.setPaylsh(wxybResult.getCash_order_id());
|
||||
// reqDTO.setZfjsbz("0");
|
||||
// HashMap<Object, Object> settlementResultMap = OtherWSUtil.Settlement(reqDTO);
|
||||
//
|
||||
// String errCode1 = StringDUtil.changeNullToEmpty(settlementResultMap.get("errCode"));
|
||||
//
|
||||
// if ("0".equals(errCode1)) {
|
||||
// wxybResult.setMzjsStatus("1");
|
||||
// } else {
|
||||
// wxybResult.setMzjsStatus("0");
|
||||
// LogUtil.error(this.getClass(), StringDUtil.changeNullToEmpty(settlementResultMap.get("errMsg")));
|
||||
// }
|
||||
// //存储信息
|
||||
// String url = StatusDefine.IP_PORT + "/api/addWxybPayInfo";
|
||||
// houtaiService.PostInfoByParam(url, wxybResult);
|
||||
// }
|
||||
//
|
||||
// }catch (Exception e){
|
||||
// e.printStackTrace();
|
||||
// LogUtil.error(this.getClass(),"晚上定时发送未写入his的医保记录失败,原因"+e.getMessage());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }catch (Exception e){
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public static void main(String[] args) {
|
||||
// SettlementDTO reqDTO=new SettlementDTO();
|
||||
// reqDTO.setPatid("421322");
|
||||
// reqDTO.setSjh("20230823yypt120036");
|
||||
// reqDTO.setZje("2.36");
|
||||
// reqDTO.setYsje("2.3600");
|
||||
// reqDTO.setPaymoney("2.3600");
|
||||
// reqDTO.setPaytype("9");
|
||||
// reqDTO.setPaylsh("4200001956202308234945588695");
|
||||
// reqDTO.setZfjsbz("1");
|
||||
// HashMap<Object, Object> settlementResultMap = OtherWSUtil.Settlement(reqDTO);
|
||||
//
|
||||
// String errCode1 = StringDUtil.changeNullToEmpty(settlementResultMap.get("errCode"));
|
||||
// String errMsg = StringDUtil.changeNullToEmpty(settlementResultMap.get("errMsg"));
|
||||
// System.out.println(errCode1);
|
||||
// System.out.println(errMsg);
|
||||
// }
|
||||
//}
|
||||
132
src/main/java/com/saye/hrs/scheduler/RetrieveAccessToken.java
Normal file
132
src/main/java/com/saye/hrs/scheduler/RetrieveAccessToken.java
Normal file
@@ -0,0 +1,132 @@
|
||||
package com.saye.hrs.scheduler;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.saye.hrs.commons.getBean.GetBeanUtil;
|
||||
import com.saye.hrs.config.RestTemplateConfig;
|
||||
import com.saye.hrs.model.StatusDefine;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/***
|
||||
* @title RetrieveAccessToken
|
||||
* @description TODO 请填写注释
|
||||
* @author thuang
|
||||
* @create 2023/8/11 15:36
|
||||
**/
|
||||
//@Configuration
|
||||
public class RetrieveAccessToken {
|
||||
|
||||
private static String access_token;
|
||||
//获取到的token的失效时间
|
||||
private static Integer token_expire;
|
||||
private static long tokenTimeMillis;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(Object.class);
|
||||
|
||||
// @Scheduled(cron="0 0 0/1 * * ?")
|
||||
// private void retrieveToken(){
|
||||
// manualToken();
|
||||
// }
|
||||
|
||||
public static String getToken(){
|
||||
if (access_token==null){
|
||||
manualToken();
|
||||
}
|
||||
//使用的token的时候,如果当前时间-获取token的时间 < 60 * 5 ,则重新获取
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
logger.debug("expires_in:" + token_expire);
|
||||
logger.debug("tokenTimeMillis:" + tokenTimeMillis);
|
||||
logger.debug("currentTimeMillis:" + currentTimeMillis);
|
||||
|
||||
if(token_expire - (tokenTimeMillis - currentTimeMillis) < 300){
|
||||
manualToken();
|
||||
}
|
||||
return access_token;
|
||||
}
|
||||
|
||||
public static void manualToken(){
|
||||
System.out.println("开始获取微信token");
|
||||
String url=StatusDefine.wxTokenUrl;
|
||||
|
||||
HashMap<Object,Object> dataMap=new HashMap<>();
|
||||
dataMap.put("grant_type","client_credential");
|
||||
dataMap.put("appid",StatusDefine.wxAppId);
|
||||
dataMap.put("secret",StatusDefine.wxSecret);
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
HttpEntity<Object> entity = new HttpEntity<>(dataMap, headers);
|
||||
|
||||
RestTemplateConfig restTemplateConfig = GetBeanUtil.getBean(RestTemplateConfig.class);
|
||||
RestTemplate restTemplate = restTemplateConfig.getInstance();
|
||||
|
||||
ResponseEntity<String> forEntity = restTemplate.postForEntity(url,entity, String.class);
|
||||
int statusCodeValue = forEntity.getStatusCodeValue();
|
||||
|
||||
if (statusCodeValue==200){
|
||||
String body = forEntity.getBody();
|
||||
JSONObject jsonObject = JSONObject.parseObject(body);
|
||||
|
||||
Integer errcode = jsonObject.getInteger("errcode");
|
||||
|
||||
if(errcode==null){
|
||||
access_token = jsonObject.getString("access_token");
|
||||
// Integer integer = jsonObject.getInteger("expires_in");
|
||||
token_expire = jsonObject.getInteger("expires_in");
|
||||
tokenTimeMillis = System.currentTimeMillis();
|
||||
|
||||
logger.debug("access_token:" + access_token);
|
||||
logger.debug("expires_in:" + token_expire);
|
||||
|
||||
}else{
|
||||
String errmsg = jsonObject.getString("errmsg");
|
||||
logger.error("获取access_token错误,errcode:"+errcode+"errMsg:"+errmsg);
|
||||
}
|
||||
}else{
|
||||
logger.error("获取access_token错误,statusCodeValue:"+statusCodeValue);
|
||||
}
|
||||
System.out.println("获取微信token结束");
|
||||
}
|
||||
|
||||
// public static void manualToken(){
|
||||
// System.out.println("开始获取微信token");
|
||||
// String url=StatusDefine.wxTokenUrl+"?grant_type=client_credential&appid="+StatusDefine.wxAppId+"&secret="+StatusDefine.wxSecret;
|
||||
//
|
||||
// RestTemplateConfig restTemplateConfig = GetBeanUtil.getBean(RestTemplateConfig.class);
|
||||
// RestTemplate restTemplate = restTemplateConfig.getInstance();
|
||||
//
|
||||
// ResponseEntity<String> forEntity = restTemplate.getForEntity(url, String.class);
|
||||
// int statusCodeValue = forEntity.getStatusCodeValue();
|
||||
//
|
||||
// if (statusCodeValue==200){
|
||||
// String body = forEntity.getBody();
|
||||
// JSONObject jsonObject = JSONObject.parseObject(body);
|
||||
//
|
||||
// Integer errcode = jsonObject.getInteger("errcode");
|
||||
//
|
||||
// if(errcode==null){
|
||||
// access_token = jsonObject.getString("access_token");
|
||||
// token_expire = jsonObject.getInteger("expires_in");
|
||||
// tokenTimeMillis = System.currentTimeMillis();
|
||||
// }else{
|
||||
// String errmsg = jsonObject.getString("errmsg");
|
||||
// logger.error("获取access_token错误,errcode:"+errcode+"errMsg:"+errmsg);
|
||||
// }
|
||||
// }else{
|
||||
// logger.error("获取access_token错误,statusCodeValue:"+statusCodeValue);
|
||||
// }
|
||||
// System.out.println("获取微信token结束");
|
||||
// }
|
||||
|
||||
}
|
||||
198
src/main/java/com/saye/hrs/scheduler/Runner.java
Normal file
198
src/main/java/com/saye/hrs/scheduler/Runner.java
Normal file
@@ -0,0 +1,198 @@
|
||||
//package com.saye.hrs.scheduler;
|
||||
//
|
||||
//import com.alibaba.fastjson.JSON;
|
||||
//import com.saye.hrs.commons.date.DateDUtil;
|
||||
//import com.saye.hrs.commons.encrypt.EncryptUtil;
|
||||
//import com.saye.hrs.commons.string.StringDUtil;
|
||||
//import com.saye.hrs.controller.ApiController;
|
||||
//import com.saye.hrs.model.StatusDefine;
|
||||
//import org.slf4j.Logger;
|
||||
//import org.slf4j.LoggerFactory;
|
||||
//import org.springframework.boot.CommandLineRunner;
|
||||
//import org.springframework.core.annotation.Order;
|
||||
//import org.springframework.http.*;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//import org.springframework.web.client.RestTemplate;
|
||||
//
|
||||
//import java.util.HashMap;
|
||||
//import java.util.List;
|
||||
//import java.util.Map.Entry;
|
||||
//import java.util.TreeMap;
|
||||
//
|
||||
//
|
||||
///**
|
||||
// * Description: 放弃这种写法,同checkRecharge一样,一定时间后会有问题
|
||||
// * @author dqzhang
|
||||
// * @created 2020年5月19日 下午2:56:20
|
||||
// */
|
||||
//@Component
|
||||
//@Order(value=1)
|
||||
//public class Runner implements CommandLineRunner{
|
||||
// private static final Logger logger = LoggerFactory.getLogger(ApiController.class);
|
||||
//
|
||||
// @Override
|
||||
// public void run(String... args) throws Exception{
|
||||
// new Thread(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// while(true) {
|
||||
// long startTime = System.currentTimeMillis();
|
||||
// logger.debug("定时检查充值信息开始!");
|
||||
// try {
|
||||
// RestTemplate restTemplate = new RestTemplate();
|
||||
// HttpHeaders headers = new HttpHeaders();
|
||||
// headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
|
||||
// String url = StatusDefine.IP_PORT+"/api/findRechargeWait";
|
||||
// HttpEntity<String> entity = new HttpEntity<String>("{}", headers);
|
||||
// ResponseEntity<List> resp =restTemplate.exchange(url, HttpMethod.POST, entity, List.class);
|
||||
// logger.debug("查询充值信息记录结束");
|
||||
// List list = resp.getBody();
|
||||
// for(int i=0;i<list.size();i++) {
|
||||
// HashMap orderMap = (HashMap) list.get(i);
|
||||
// String merOrderId = StringDUtil.changeNullToEmpty(orderMap.get("MERORDERID"));
|
||||
// String totalAmount = StringDUtil.changeNullToEmpty(orderMap.get("TOTALAMOUNT"));
|
||||
// TreeMap<Object,Object> map = new TreeMap<Object,Object>();
|
||||
// map.put("msgSrcId", "12YK");
|
||||
// map.put("msgSrc", "WWW.KRLSFYBJ.COM");
|
||||
// map.put("msgType", "query");
|
||||
// map.put("requestTimestamp", DateDUtil.getTheCurrentTime());
|
||||
// map.put("merOrderId", merOrderId);
|
||||
// map.put("mid", "898652880620011");
|
||||
// map.put("tid", "65954193");
|
||||
// map.put("signType", "SHA256");
|
||||
// String key = "KfG8PnwGSK8AXQFKtyfQnKi3x5kcZtDkWX2tctAMhcF5e6Ax";
|
||||
// StringBuilder str = new StringBuilder();
|
||||
// for(Entry<Object, Object> e: map.entrySet()) {
|
||||
// str.append(e.getKey());
|
||||
// str.append("=");
|
||||
// str.append(e.getValue());
|
||||
// str.append("&");
|
||||
// }
|
||||
// str.deleteCharAt(str.length()-1);
|
||||
// str.append(key);
|
||||
// String sign = EncryptUtil.getSHA256Str(str.toString());
|
||||
// map.put("sign", sign.toUpperCase());
|
||||
// url = "https://qr.chinaums.com/netpay-route-server/api/";
|
||||
// String body = JSON.toJSONString(map);
|
||||
// entity = new HttpEntity<String>(body, headers);
|
||||
// logger.debug(merOrderId+"查询充值结果开始");
|
||||
// ResponseEntity<HashMap> resp1 =restTemplate.exchange(url, HttpMethod.POST, entity, HashMap.class);
|
||||
// logger.debug(merOrderId+"查询充值结果结束");
|
||||
// HashMap result = resp1.getBody();
|
||||
// String status = StringDUtil.changeNullToEmpty(result.get("status"));
|
||||
// String targetOrderId = StringDUtil.changeNullToEmpty(result.get("targetOrderId"));
|
||||
// //支付结果信息写入数据库
|
||||
// HashMap<Object,Object> requestMap = new HashMap<Object,Object>();
|
||||
// url = StatusDefine.IP_PORT+"/api/addHisRecharge";
|
||||
// requestMap.put("status", status);
|
||||
// requestMap.put("merOrderId", merOrderId);
|
||||
// requestMap.put("targetOrderId", targetOrderId);
|
||||
// requestMap.put("resultText", JSON.toJSONString(result));
|
||||
// HttpEntity<String> entity1 = new HttpEntity<String>(JSON.toJSONString(requestMap), headers) ;
|
||||
// logger.debug(merOrderId+"结果信息写入数据库开始");
|
||||
// ResponseEntity<HashMap> resp2 =restTemplate.exchange(url, HttpMethod.POST, entity1, HashMap.class);
|
||||
// logger.debug(merOrderId+"结果信息写入数据库结束");
|
||||
// HashMap resultMap = resp2.getBody();
|
||||
// //his充值失败 进行退款
|
||||
// if("2".equals(resultMap.get("hisStatus"))) {
|
||||
// logger.debug(merOrderId+"执行退款开始");
|
||||
// refund(merOrderId,totalAmount,0);
|
||||
// logger.debug(merOrderId+"执行退款结束");
|
||||
// }
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// logger.error("定时检查充值信息异常"+e.toString());
|
||||
// }
|
||||
// logger.debug("定时检查充值信息结束!");
|
||||
// long endTime = System.currentTimeMillis();
|
||||
// try {
|
||||
// long jg = endTime - startTime;
|
||||
// if (jg<(30*1000)){
|
||||
// Thread.sleep((30*1000)-jg);
|
||||
// }
|
||||
// } catch (InterruptedException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }).start();
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public void refund(String originalOrderId,String Amount,int index) {
|
||||
//
|
||||
// if(index>1) {
|
||||
// //两次退款失败后 不再进行退款 写入消息提醒
|
||||
// String url = StatusDefine.IP_PORT+"/api/addRefundMessageNotice";
|
||||
// HashMap<Object,Object> map = new HashMap<Object,Object>();
|
||||
// map.put("id", originalOrderId);
|
||||
// String body = JSON.toJSONString(map);
|
||||
// RestTemplate restTemplate = new RestTemplate();
|
||||
// HttpHeaders headers = new HttpHeaders();
|
||||
// headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
// HttpEntity<String> entity = new HttpEntity<String>(body, headers) ;
|
||||
// ResponseEntity<HashMap> resp1 =restTemplate.exchange(url, HttpMethod.POST, entity, HashMap.class);
|
||||
// return;
|
||||
// }
|
||||
// String errCode = "";
|
||||
// String errMsg = "";
|
||||
// TreeMap<Object,Object> map = new TreeMap<Object,Object>();
|
||||
// map.put("msgSrcId", "12YK");
|
||||
// map.put("msgSrc", "WWW.KRLSFYBJ.COM");
|
||||
// map.put("msgType", "refund");
|
||||
// map.put("requestTimestamp", DateDUtil.getTheCurrentTime());
|
||||
// map.put("merOrderId", originalOrderId);
|
||||
// map.put("mid", "898652880620011");
|
||||
// map.put("tid", "65954193");
|
||||
// map.put("refundAmount", Amount);
|
||||
// map.put("signType", "SHA256");
|
||||
// String key = "KfG8PnwGSK8AXQFKtyfQnKi3x5kcZtDkWX2tctAMhcF5e6Ax";
|
||||
// StringBuilder str = new StringBuilder();
|
||||
// for(Entry<Object, Object> e: map.entrySet()) {
|
||||
// str.append(e.getKey());
|
||||
// str.append("=");
|
||||
// str.append(e.getValue());
|
||||
// str.append("&");
|
||||
// }
|
||||
// str.deleteCharAt(str.length()-1);
|
||||
// str.append(key);
|
||||
// String sign = EncryptUtil.getSHA256Str(str.toString());
|
||||
// map.put("sign", sign.toUpperCase());
|
||||
// String url = "https://qr.chinaums.com/netpay-route-server/api/";
|
||||
// RestTemplate restTemplate = new RestTemplate();
|
||||
// HttpHeaders headers = new HttpHeaders();
|
||||
// headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
// String body = JSON.toJSONString(map);
|
||||
// HttpEntity<String> entity = new HttpEntity<String>(body, headers);
|
||||
// ResponseEntity<HashMap> res =restTemplate.exchange(url, HttpMethod.POST, entity, HashMap.class);
|
||||
// HashMap resultMap = res.getBody();
|
||||
// //成功后写入退款信息
|
||||
// if("0".equals(resultMap.get("errCode"))) {
|
||||
//
|
||||
// String refundOrderId = StringDUtil.changeNullToEmpty(resultMap.get("refundOrderId"));
|
||||
//
|
||||
// HashMap<Object,Object> refundMap = new HashMap<Object,Object>();
|
||||
// refundMap.put("refundOrderId",refundOrderId);
|
||||
// refundMap.put("czyh","");
|
||||
// refundMap.put("hzid","");
|
||||
// refundMap.put("hzxm","");
|
||||
// refundMap.put("tranType","");
|
||||
// refundMap.put("Amount",Amount);
|
||||
// refundMap.put("payType","");
|
||||
// refundMap.put("payCode","");
|
||||
// refundMap.put("originalOrderId",originalOrderId);
|
||||
// refundMap.put("merchantOrderId",originalOrderId);
|
||||
// refundMap.put("refundRequestId",refundOrderId);
|
||||
// url = StatusDefine.IP_PORT+"/api/addRefund";
|
||||
// String requestBody = JSON.toJSONString(refundMap);
|
||||
// logger.info("退款请求参数"+requestBody);
|
||||
// entity = new HttpEntity<String>(requestBody, headers) ;
|
||||
// ResponseEntity<HashMap> result =restTemplate.exchange(url, HttpMethod.POST, entity, HashMap.class);
|
||||
// }else {
|
||||
// index++;
|
||||
// refund(originalOrderId,Amount,index);
|
||||
// }
|
||||
// logger.info("退款参数"+body+"结果:"+resultMap);
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.saye.hrs.scheduler.factory;
|
||||
|
||||
import org.quartz.spi.TriggerFiredBundle;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
|
||||
import org.springframework.scheduling.quartz.AdaptableJobFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class MyJobFactory extends AdaptableJobFactory {
|
||||
|
||||
@Autowired
|
||||
private AutowireCapableBeanFactory capableBeanFactory;
|
||||
|
||||
@Override
|
||||
protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
|
||||
// 调用父类的方法
|
||||
Object jobInstance = super.createJobInstance(bundle);
|
||||
// 进行注入
|
||||
capableBeanFactory.autowireBean(jobInstance);
|
||||
return jobInstance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.saye.hrs.scheduler.factory;
|
||||
|
||||
|
||||
import com.saye.hrs.commons.getBean.GetBeanUtil;
|
||||
import com.saye.hrs.commons.string.StringDUtil;
|
||||
import org.quartz.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 调度工厂类
|
||||
*/
|
||||
@Service("MySchedulerFactory")
|
||||
@Component
|
||||
public class MySchedulerFactory {
|
||||
private static Logger logger = LoggerFactory.getLogger(MySchedulerFactory.class);
|
||||
|
||||
public SchedulerFactoryBean getSchedulerFactoryBean(){
|
||||
return GetBeanUtil.getBean(SchedulerFactoryBean.class);
|
||||
}
|
||||
|
||||
public void scheduleJobs() throws Exception {
|
||||
Scheduler scheduler = getScheduler();
|
||||
// 为了避免org.quartz.ObjectAlreadyExistsException,在执行前将scheduler进行清理
|
||||
scheduler.clear();
|
||||
|
||||
//添加任务
|
||||
addJob("1","定时检查充值信息",null,"0/30 * * * * ?","com.saye.hrs.scheduler.job.CheckRecharge");
|
||||
|
||||
addJob("2","获取微信token",null,"0 0 0/1 * * ?","com.saye.hrs.scheduler.job.WXManualToken");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取scheduler
|
||||
* @return
|
||||
* @author
|
||||
* @date 2018年12月27日
|
||||
*/
|
||||
public Scheduler getScheduler() {
|
||||
return getSchedulerFactoryBean().getScheduler();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加新的定时任务
|
||||
* @param id
|
||||
* @param name
|
||||
* @param group
|
||||
* @param cron
|
||||
* @param classz
|
||||
* @throws Exception
|
||||
*/
|
||||
public void addJob(String id,String name, String group,String cron, String classz) throws Exception{
|
||||
|
||||
Scheduler scheduler = getScheduler();
|
||||
try {
|
||||
if (StringDUtil.isNotBlank(classz)) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends Job> clazz = (Class<? extends Job>) Class.forName(classz);
|
||||
JobDetail jobDetail = JobBuilder.newJob(clazz).withIdentity(id, group)
|
||||
.usingJobData("id", id).usingJobData("name", name).build();
|
||||
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(cron);
|
||||
CronTrigger cronTrigger = TriggerBuilder.newTrigger().withIdentity(id, group)
|
||||
.withSchedule(scheduleBuilder).build();
|
||||
scheduler.scheduleJob(jobDetail, cronTrigger);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.info("添加定时任务失败:" + " 异常信息:" + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.saye.hrs.scheduler.factory;
|
||||
|
||||
import com.saye.hrs.commons.getBean.GetBeanUtil;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
|
||||
|
||||
/**
|
||||
* 定时任务运行工厂类
|
||||
*/
|
||||
@Configuration
|
||||
public class StartSchedulerListener implements ApplicationListener<ContextRefreshedEvent> {
|
||||
|
||||
@Autowired
|
||||
public MySchedulerFactory mySchedulerFactory;
|
||||
@Autowired
|
||||
private MyJobFactory myJobFactory;
|
||||
|
||||
// springboot 启动监听
|
||||
@Override
|
||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||
try {
|
||||
mySchedulerFactory.scheduleJobs();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//注入SchedulerFactoryBean
|
||||
@Bean
|
||||
public SchedulerFactoryBean schedulerFactoryBean() {
|
||||
SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
|
||||
schedulerFactoryBean.setJobFactory(myJobFactory);
|
||||
return schedulerFactoryBean;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
191
src/main/java/com/saye/hrs/scheduler/job/CheckRecharge.java
Normal file
191
src/main/java/com/saye/hrs/scheduler/job/CheckRecharge.java
Normal file
@@ -0,0 +1,191 @@
|
||||
package com.saye.hrs.scheduler.job;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.saye.hrs.commons.date.DateDUtil;
|
||||
import com.saye.hrs.commons.encrypt.EncryptUtil;
|
||||
import com.saye.hrs.commons.string.StringDUtil;
|
||||
import com.saye.hrs.controller.ApiController;
|
||||
import com.saye.hrs.model.StatusDefine;
|
||||
import org.quartz.DisallowConcurrentExecution;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/***
|
||||
* @title CheckRecharge
|
||||
* @description TODO 请填写注释
|
||||
* @author thuang
|
||||
* @create 2024/2/18 13:22
|
||||
**/
|
||||
@DisallowConcurrentExecution
|
||||
public class CheckRecharge implements Job {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ApiController.class);
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
logger.debug("定时检查充值信息开始!");
|
||||
try {
|
||||
|
||||
SimpleClientHttpRequestFactory httpRequestFactory = new SimpleClientHttpRequestFactory();
|
||||
httpRequestFactory.setConnectTimeout(30 * 1000);
|
||||
httpRequestFactory.setReadTimeout(60 * 1000);
|
||||
RestTemplate restTemplate = new RestTemplate(httpRequestFactory);
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
|
||||
String url = StatusDefine.IP_PORT+"/api/findRechargeWait";
|
||||
HttpEntity<String> entity = new HttpEntity<String>("{}", headers);
|
||||
ResponseEntity<List> resp =restTemplate.exchange(url, HttpMethod.POST, entity, List.class);
|
||||
logger.debug("查询充值信息记录结束");
|
||||
List list = resp.getBody();
|
||||
for(int i=0;i<list.size();i++) {
|
||||
HashMap orderMap = (HashMap) list.get(i);
|
||||
String merOrderId = StringDUtil.changeNullToEmpty(orderMap.get("MERORDERID"));
|
||||
String totalAmount = StringDUtil.changeNullToEmpty(orderMap.get("TOTALAMOUNT"));
|
||||
TreeMap<Object,Object> map = new TreeMap<Object,Object>();
|
||||
map.put("msgSrcId", "12YK");
|
||||
map.put("msgSrc", "WWW.KRLSFYBJ.COM");
|
||||
map.put("msgType", "query");
|
||||
map.put("requestTimestamp", DateDUtil.getTheCurrentTime());
|
||||
map.put("merOrderId", merOrderId);
|
||||
map.put("mid", "898652880620011");
|
||||
map.put("tid", "65954193");
|
||||
map.put("signType", "SHA256");
|
||||
String key = "KfG8PnwGSK8AXQFKtyfQnKi3x5kcZtDkWX2tctAMhcF5e6Ax";
|
||||
StringBuilder str = new StringBuilder();
|
||||
for(Map.Entry<Object, Object> e: map.entrySet()) {
|
||||
str.append(e.getKey());
|
||||
str.append("=");
|
||||
str.append(e.getValue());
|
||||
str.append("&");
|
||||
}
|
||||
str.deleteCharAt(str.length()-1);
|
||||
str.append(key);
|
||||
String sign = EncryptUtil.getSHA256Str(str.toString());
|
||||
map.put("sign", sign.toUpperCase());
|
||||
url = "https://qr.chinaums.com/netpay-route-server/api/";
|
||||
String body = JSON.toJSONString(map);
|
||||
entity = new HttpEntity<String>(body, headers);
|
||||
logger.debug(merOrderId+"查询充值结果开始");
|
||||
ResponseEntity<HashMap> resp1 =restTemplate.exchange(url, HttpMethod.POST, entity, HashMap.class);
|
||||
logger.debug(merOrderId+"查询充值结果结束");
|
||||
HashMap result = resp1.getBody();
|
||||
String status = StringDUtil.changeNullToEmpty(result.get("status"));
|
||||
String targetOrderId = StringDUtil.changeNullToEmpty(result.get("targetOrderId"));
|
||||
//支付结果信息写入数据库
|
||||
HashMap<Object,Object> requestMap = new HashMap<Object,Object>();
|
||||
url = StatusDefine.IP_PORT+"/api/addHisRecharge";
|
||||
requestMap.put("status", status);
|
||||
requestMap.put("merOrderId", merOrderId);
|
||||
requestMap.put("targetOrderId", targetOrderId);
|
||||
requestMap.put("resultText", JSON.toJSONString(result));
|
||||
HttpEntity<String> entity1 = new HttpEntity<String>(JSON.toJSONString(requestMap), headers) ;
|
||||
logger.debug(merOrderId+"结果信息写入数据库开始");
|
||||
ResponseEntity<HashMap> resp2 =restTemplate.exchange(url, HttpMethod.POST, entity1, HashMap.class);
|
||||
logger.debug(merOrderId+"结果信息写入数据库结束");
|
||||
HashMap resultMap = resp2.getBody();
|
||||
//his充值失败 进行退款
|
||||
if("2".equals(resultMap.get("hisStatus"))) {
|
||||
logger.debug(merOrderId+"执行退款开始");
|
||||
refund(merOrderId,totalAmount,0);
|
||||
logger.debug(merOrderId+"执行退款结束");
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("定时检查充值信息异常"+e.toString());
|
||||
}
|
||||
logger.debug("定时检查充值信息结束!");
|
||||
}
|
||||
|
||||
public void refund(String originalOrderId,String Amount,int index) {
|
||||
|
||||
if(index>1) {
|
||||
//两次退款失败后 不再进行退款 写入消息提醒
|
||||
String url = StatusDefine.IP_PORT+"/api/addRefundMessageNotice";
|
||||
HashMap<Object,Object> map = new HashMap<Object,Object>();
|
||||
map.put("id", originalOrderId);
|
||||
String body = JSON.toJSONString(map);
|
||||
SimpleClientHttpRequestFactory httpRequestFactory = new SimpleClientHttpRequestFactory();
|
||||
httpRequestFactory.setConnectTimeout(60 * 1000);
|
||||
httpRequestFactory.setReadTimeout(5 * 60 * 1000);
|
||||
RestTemplate restTemplate = new RestTemplate(httpRequestFactory);
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
HttpEntity<String> entity = new HttpEntity<String>(body, headers) ;
|
||||
ResponseEntity<HashMap> resp1 =restTemplate.exchange(url, HttpMethod.POST, entity, HashMap.class);
|
||||
return;
|
||||
}
|
||||
String errCode = "";
|
||||
String errMsg = "";
|
||||
TreeMap<Object,Object> map = new TreeMap<Object,Object>();
|
||||
map.put("msgSrcId", "12YK");
|
||||
map.put("msgSrc", "WWW.KRLSFYBJ.COM");
|
||||
map.put("msgType", "refund");
|
||||
map.put("requestTimestamp", DateDUtil.getTheCurrentTime());
|
||||
map.put("merOrderId", originalOrderId);
|
||||
map.put("mid", "898652880620011");
|
||||
map.put("tid", "65954193");
|
||||
map.put("refundAmount", Amount);
|
||||
map.put("signType", "SHA256");
|
||||
String key = "KfG8PnwGSK8AXQFKtyfQnKi3x5kcZtDkWX2tctAMhcF5e6Ax";
|
||||
StringBuilder str = new StringBuilder();
|
||||
for(Map.Entry<Object, Object> e: map.entrySet()) {
|
||||
str.append(e.getKey());
|
||||
str.append("=");
|
||||
str.append(e.getValue());
|
||||
str.append("&");
|
||||
}
|
||||
str.deleteCharAt(str.length()-1);
|
||||
str.append(key);
|
||||
String sign = EncryptUtil.getSHA256Str(str.toString());
|
||||
map.put("sign", sign.toUpperCase());
|
||||
String url = "https://qr.chinaums.com/netpay-route-server/api/";
|
||||
SimpleClientHttpRequestFactory httpRequestFactory = new SimpleClientHttpRequestFactory();
|
||||
httpRequestFactory.setConnectTimeout(60 * 1000);
|
||||
httpRequestFactory.setReadTimeout(5 * 60 * 1000);
|
||||
RestTemplate restTemplate = new RestTemplate(httpRequestFactory);
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
String body = JSON.toJSONString(map);
|
||||
HttpEntity<String> entity = new HttpEntity<String>(body, headers);
|
||||
ResponseEntity<HashMap> res =restTemplate.exchange(url, HttpMethod.POST, entity, HashMap.class);
|
||||
HashMap resultMap = res.getBody();
|
||||
//成功后写入退款信息
|
||||
if("0".equals(resultMap.get("errCode"))) {
|
||||
|
||||
String refundOrderId = StringDUtil.changeNullToEmpty(resultMap.get("refundOrderId"));
|
||||
|
||||
HashMap<Object,Object> refundMap = new HashMap<Object,Object>();
|
||||
refundMap.put("refundOrderId",refundOrderId);
|
||||
refundMap.put("czyh","");
|
||||
refundMap.put("hzid","");
|
||||
refundMap.put("hzxm","");
|
||||
refundMap.put("tranType","");
|
||||
refundMap.put("Amount",Amount);
|
||||
refundMap.put("payType","");
|
||||
refundMap.put("payCode","");
|
||||
refundMap.put("originalOrderId",originalOrderId);
|
||||
refundMap.put("merchantOrderId",originalOrderId);
|
||||
refundMap.put("refundRequestId",refundOrderId);
|
||||
url = StatusDefine.IP_PORT+"/api/addRefund";
|
||||
String requestBody = JSON.toJSONString(refundMap);
|
||||
logger.info("退款请求参数"+requestBody);
|
||||
entity = new HttpEntity<String>(requestBody, headers) ;
|
||||
ResponseEntity<HashMap> result =restTemplate.exchange(url, HttpMethod.POST, entity, HashMap.class);
|
||||
}else {
|
||||
index++;
|
||||
refund(originalOrderId,Amount,index);
|
||||
}
|
||||
logger.info("退款参数"+body+"结果:"+resultMap);
|
||||
}
|
||||
}
|
||||
21
src/main/java/com/saye/hrs/scheduler/job/WXManualToken.java
Normal file
21
src/main/java/com/saye/hrs/scheduler/job/WXManualToken.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.saye.hrs.scheduler.job;
|
||||
|
||||
import com.saye.hrs.scheduler.RetrieveAccessToken;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
/***
|
||||
* @title WXManualToken
|
||||
* @description TODO 请填写注释
|
||||
* @author thuang
|
||||
* @create 2024/2/18 14:07
|
||||
**/
|
||||
public class WXManualToken implements Job {
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
RetrieveAccessToken.manualToken();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user