|
|
@ -1,21 +1,25 @@ |
|
|
|
package com.hai.schedule; |
|
|
|
package com.hai.schedule; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
|
|
|
import com.hai.common.utils.DateUtil; |
|
|
|
import com.hai.common.utils.HttpsUtils; |
|
|
|
import com.hai.common.utils.HttpsUtils; |
|
|
|
import com.hai.entity.HighOrder; |
|
|
|
import com.hai.entity.HighOrder; |
|
|
|
|
|
|
|
import com.hai.entity.SecSinopecConfig; |
|
|
|
|
|
|
|
import com.hai.service.HighCouponCodeService; |
|
|
|
|
|
|
|
import com.hai.service.SecSinopecConfigService; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
|
|
|
|
|
import springfox.documentation.spring.web.json.Json; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
import java.security.MessageDigest; |
|
|
|
import java.security.MessageDigest; |
|
|
|
import java.security.NoSuchAlgorithmException; |
|
|
|
import java.security.NoSuchAlgorithmException; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.*; |
|
|
|
import java.util.HashMap; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @Auther: 胡锐 |
|
|
|
* @Auther: 胡锐 |
|
|
@ -29,33 +33,65 @@ public class SynchronizeCNPC { |
|
|
|
|
|
|
|
|
|
|
|
private static final String[] HEX_DIGITS = {"0" ,"1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"}; |
|
|
|
private static final String[] HEX_DIGITS = {"0" ,"1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"}; |
|
|
|
|
|
|
|
|
|
|
|
//@Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private HighCouponCodeService highCouponCodeService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private SecSinopecConfigService secSinopecConfigService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次
|
|
|
|
public void certification() { |
|
|
|
public void certification() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<SecSinopecConfig> sinopecConfig = secSinopecConfigService.getListSinopecConfig(new HashMap<>()); |
|
|
|
|
|
|
|
for (SecSinopecConfig config : sinopecConfig) { |
|
|
|
Map<String, Object> tokenMap = new HashMap<>(); |
|
|
|
Map<String, Object> tokenMap = new HashMap<>(); |
|
|
|
tokenMap.put("appId", "jsVpwDoHZfR2rrpjhA"); |
|
|
|
tokenMap.put("appId", config.getAppId()); |
|
|
|
tokenMap.put("appSecret", "R7yJjinikdPhOlTrVgmdS7cblWMMOf99zEJkfPgaTIoDtKGlX51JKueLV725a6S4"); |
|
|
|
tokenMap.put("appSecret", config.getAppSecret()); |
|
|
|
JSONObject jsonObject = HttpsUtils.doPost("https://app.zshcqsy.com/api-provider/api/open/merchant/token", JSON.toJSONString(tokenMap)); |
|
|
|
JSONObject jsonObject = HttpsUtils.doPost("https://app.zshcqsy.com/api-provider/api/open/merchant/token", JSON.toJSONString(tokenMap)); |
|
|
|
log.error(jsonObject.toJSONString()); |
|
|
|
log.error(jsonObject.toJSONString()); |
|
|
|
|
|
|
|
|
|
|
|
if (jsonObject != null && jsonObject.getBoolean("success") == true) { |
|
|
|
if (jsonObject != null && jsonObject.getBoolean("success") == true) { |
|
|
|
JSONObject data = jsonObject.getJSONObject("data"); |
|
|
|
JSONObject data = jsonObject.getJSONObject("data"); |
|
|
|
String token = data.getString("token"); |
|
|
|
String token = data.getString("token"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Calendar instance = Calendar.getInstance(); |
|
|
|
|
|
|
|
instance.add(Calendar.MINUTE, -10); |
|
|
|
|
|
|
|
|
|
|
|
Map<String,Object> bodyMap = new HashMap<>(); |
|
|
|
Map<String,Object> bodyMap = new HashMap<>(); |
|
|
|
bodyMap.put("appId", "jsVpwDoHZfR2rrpjhA"); |
|
|
|
bodyMap.put("appId", config.getAppId()); |
|
|
|
bodyMap.put("pageNo", 1); |
|
|
|
bodyMap.put("pageNo", 1); |
|
|
|
bodyMap.put("pageSize", 10); |
|
|
|
bodyMap.put("pageSize", 100); |
|
|
|
bodyMap.put("startTime", new Date()); |
|
|
|
bodyMap.put("startTime", instance.getTime()); |
|
|
|
bodyMap.put("endTime", new Date()); |
|
|
|
bodyMap.put("endTime", new Date()); |
|
|
|
bodyMap.put("customerCode", "48464274"); |
|
|
|
bodyMap.put("customerCode", config.getCode()); |
|
|
|
|
|
|
|
|
|
|
|
String signature = "hAFO76ZqXmIqosNw3PTAP4wxGJTN7MPawSU0QFDzzNioLjKMEaVFDlNKRIQX6n0DgyoVMy170T0b13P8uUTAQsbk9UNRPFO5i0fWp1hHOhNdaaQ2BdC0WXQz5QQ5epyK"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Long date = new Date().getTime(); |
|
|
|
Long date = new Date().getTime(); |
|
|
|
String sha256 = encodeBySHA256(signature + JSON.toJSONString(bodyMap) + date); |
|
|
|
String sha256 = encodeBySHA256(config.getSignkey() + JSON.toJSONString(bodyMap) + date); |
|
|
|
JSONObject object = HttpsUtils.doPost("https://app.zshcqsy.com/api-provider/sapapi/open/coupon/customerRedeemcodeList", JSON.toJSONString(bodyMap), token, sha256, date); |
|
|
|
JSONObject object = HttpsUtils.doPost("https://app.zshcqsy.com/api-provider/sapapi/open/coupon/customerRedeemcodeList", JSON.toJSONString(bodyMap), token, sha256, date); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//JSONObject object = JSONObject.parseObject("{\"code\":1000,\"data\":{\"pageNo\":1,\"pageSize\":100,\"rowCount\":\"2\",\"list\":[{\"nodeName\":\"中国石油化工股份有限公司重庆江南石油分公司大学城南二路加油加\",\"totalAmount\":150.00,\"codeId\":\"01DIhbtPzIghPP0mPWaWzO13\",\"nodeNo\":\"50000105\",\"name\":\"重庆惠昕石化有限责任公司11.02日150元券\",\"useTime\":\"2021-04-03 06:11:14\"},{\"nodeName\":\"中国石化销售有限公司重庆三峡分公司忠县经营部三台加油站\",\"totalAmount\":100.00,\"codeId\":\"201126141728001027\",\"nodeNo\":\"50000238\",\"name\":\"重庆惠昕石化有限责任公司11.26日100元券\",\"useTime\":\"2021-04-03 15:16:03\"}]},\"success\":true}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(Objects.equals(object.get("success"), true)) { |
|
|
|
|
|
|
|
log.error(JSONObject.toJSONString(object.get("data"))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object dataJson = JSONObject.parse(JSONObject.toJSONString(object.get("data"))); |
|
|
|
|
|
|
|
JSONObject dataObject = JSON.parseObject(JSONObject.toJSONString(dataJson)); |
|
|
|
|
|
|
|
JSONArray list = dataObject.getJSONArray("list"); |
|
|
|
|
|
|
|
for (Object dataJsonObject : list) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
JSONObject parseObject = JSON.parseObject(JSON.toJSONString(dataJsonObject)); |
|
|
|
|
|
|
|
String codeId = parseObject.getString("codeId"); |
|
|
|
|
|
|
|
Date useTime = DateUtil.format(parseObject.getString("useTime"), "yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
|
|
|
highCouponCodeService.cnpcCallbackCouponCode(codeId, useTime); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.error("HighCouponSchedule --> expiredCoupon() error!", e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
log.error(object.toJSONString()); |
|
|
|
log.error(object.toJSONString()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String encodeBySHA256(String str) { |
|
|
|
public String encodeBySHA256(String str) { |
|
|
|
try{ |
|
|
|
try{ |
|
|
|