江体小程序和zlb接口开发 #1
15
pom.xml
15
pom.xml
@@ -104,6 +104,11 @@
|
||||
<artifactId>mapstruct</artifactId>
|
||||
<version>1.5.5.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.9</version>
|
||||
</dependency>
|
||||
|
||||
<!-- http -->
|
||||
<dependency>
|
||||
@@ -111,6 +116,11 @@
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.13</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>4.12.0</version>
|
||||
</dependency>
|
||||
<!-- collections -->
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
@@ -129,6 +139,11 @@
|
||||
</dependency>
|
||||
|
||||
<!-- json -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.83</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.fastjson2</groupId>
|
||||
<artifactId>fastjson2</artifactId>
|
||||
|
||||
38
src/main/java/com/xiang/common/enums/DateFormatEnum.java
Normal file
38
src/main/java/com/xiang/common/enums/DateFormatEnum.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package com.xiang.common.enums;
|
||||
|
||||
/**
|
||||
* @author clover
|
||||
* @Date 2020/9/15 20:11
|
||||
*/
|
||||
public enum DateFormatEnum {
|
||||
COMMON("ECS_DISK", "yyyy-MM-dd'T'HH:mm:ss'Z'"),
|
||||
COMMON1("ENUM_FORMAT", "yyyy-MM-dd HH:mm:ss"),
|
||||
ENUM_FORMAT_OTS("ENUM_FORMAT_OTS", "yyyy-MM-ddHH:mm:ss"),
|
||||
ASCM_ONE_FORMAT("ASCM_ONE_FORMAT", "yyyy-MM-dd'T'HH:mm'Z'"),
|
||||
ASCM_TWO_FORMAT("ASCM_TWO_FORMAT", "yyyy-MM-dd'T'HH:mm:ss'Z'"),
|
||||
ASCM_THREE_FORMAT("ASCM_THREE_FORMAT", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"),
|
||||
ASCM_FOUR_FORMAT("ASCM_FOUR_FORMAT", "yyyy-MM-dd'T'HH:mm:ss+08:00"),
|
||||
ASCM_FIVE_FORMAT("ASCM_FIVE_FORMAT", "yyyy-MM-dd'T'HH:mm:ss"),
|
||||
IRS_FORMAT_YMD("IRS_FORMAT_YMD", "yyyyMMdd"),
|
||||
IRS_FORMAT_YM("IRS_FORMAT_YM", "yyyyMM"),
|
||||
ENUM_FORMAT_YMD("ENUM_FORMAT_YMD", "yyyy-MM-dd"),
|
||||
ENUM_FORMAT_YMD000("ENUM_FORMAT_YMD", "yyyy-MM-dd 00:00:00"),
|
||||
ENUM_FORMAT_YMD_CSB("ENUM_FORMAT_YMD_CSB", "yyyy-MM-dd/00");
|
||||
|
||||
private String key;
|
||||
private String value;
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
DateFormatEnum(String key, String value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.xiang.common.factory;
|
||||
|
||||
import com.xiang.common.config.DingTalkRobotProperties;
|
||||
import com.xiang.common.enums.DingTalkBizTypeEnum;
|
||||
import com.xiang.common.utils.dingTalk.AbstractDingTalkFactory;
|
||||
import com.xiang.common.utils.dingTalk.DingTalkSender;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class JntyzxDingTalkFactory extends AbstractDingTalkFactory {
|
||||
public JntyzxDingTalkFactory(DingTalkRobotProperties dingTalkRobotProperties, DingTalkSender dingTalkSender) {
|
||||
super(dingTalkRobotProperties, dingTalkSender);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMsg(String msg) {
|
||||
getClient(DingTalkBizTypeEnum.JT).sendDingTalkMsg(msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.xiang.common.handler;
|
||||
|
||||
public interface CallbackHandler {
|
||||
void onResponse(String response);
|
||||
void onFailure(Throwable t);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.xiang.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbJlUserInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface ZlbJlUserInfoMapper extends BaseMapper<ZlbJlUserInfo> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.xiang.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbLoginInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface ZlbLoginInfoMapper extends BaseMapper<ZlbLoginInfo> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xiang.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbPayOrder;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface ZlbOrderInfoMapper extends BaseMapper<ZlbPayOrder> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
16
src/main/java/com/xiang/common/mapper/ZlbSiteInfoMapper.java
Normal file
16
src/main/java/com/xiang/common/mapper/ZlbSiteInfoMapper.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.xiang.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbSiteInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface ZlbSiteInfoMapper extends BaseMapper<ZlbSiteInfo> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xiang.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbTokenInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface ZlbTokenInfoMapper extends BaseMapper<ZlbTokenInfo> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
16
src/main/java/com/xiang/common/mapper/ZlbUserInfoMapper.java
Normal file
16
src/main/java/com/xiang/common/mapper/ZlbUserInfoMapper.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.xiang.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbUserInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface ZlbUserInfoMapper extends BaseMapper<ZlbUserInfo> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.xiang.common.pojo.jntyzx.zlb;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @TableName zlb_jl_user_info
|
||||
*/
|
||||
@TableName(value ="zlb_jl_user_info")
|
||||
@Data
|
||||
public class ZlbJlUserInfo {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 星期几
|
||||
*/
|
||||
private String week;
|
||||
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
private String day;
|
||||
|
||||
/**
|
||||
* token
|
||||
*/
|
||||
private String token;
|
||||
|
||||
/**
|
||||
* secretKey
|
||||
*/
|
||||
private String secretKey;
|
||||
|
||||
/**
|
||||
* 场地信息
|
||||
*/
|
||||
private String placeName;
|
||||
|
||||
/**
|
||||
* 时间id111
|
||||
*/
|
||||
private String siteTimeName;
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.xiang.common.pojo.jntyzx.zlb;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @TableName zlb_login_info
|
||||
*/
|
||||
@TableName(value ="zlb_login_info")
|
||||
@Data
|
||||
public class ZlbLoginInfo {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 11
|
||||
*/
|
||||
private String cookie;
|
||||
|
||||
/**
|
||||
* 22
|
||||
*/
|
||||
private String bizSessionId;
|
||||
|
||||
/**
|
||||
* 33
|
||||
*/
|
||||
private String xDeviceId;
|
||||
|
||||
/**
|
||||
* 44
|
||||
*/
|
||||
private String xSignValue;
|
||||
|
||||
/**
|
||||
* 55
|
||||
*/
|
||||
private String token;
|
||||
|
||||
/**
|
||||
* 66
|
||||
*/
|
||||
private String gucGsid;
|
||||
|
||||
/**
|
||||
* 77
|
||||
*/
|
||||
private String xSiteCode;
|
||||
|
||||
/**
|
||||
* 77
|
||||
*/
|
||||
private String aliyungfTc;
|
||||
|
||||
/**
|
||||
* 是否失效0-未失效,1-失效
|
||||
*/
|
||||
private Integer isDel;
|
||||
|
||||
/**
|
||||
* 数据创建时间
|
||||
*/
|
||||
private Date createdDate;
|
||||
|
||||
/**
|
||||
* 数据修改时间
|
||||
*/
|
||||
private Date updatedDate;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.xiang.common.pojo.jntyzx.zlb;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caoliang
|
||||
* @version 1.0
|
||||
* @date 2025-06-18 00:52:44
|
||||
* @Description:***
|
||||
*/
|
||||
@Data
|
||||
public class ZlbOrderInfo {
|
||||
private String id;
|
||||
private ZlbData data;
|
||||
|
||||
@Data
|
||||
public static class ZlbData {
|
||||
private Integer bgImageWidth;
|
||||
private Integer bgImageHeight;
|
||||
private String startTime;
|
||||
private String stopTime;
|
||||
private List<TrackList> trackList;
|
||||
|
||||
@Data
|
||||
public static class TrackList {
|
||||
private Integer x;
|
||||
private Integer y;
|
||||
private Integer t;
|
||||
private String type;
|
||||
}
|
||||
}
|
||||
private String siteOrderDetailsStr;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.xiang.common.pojo.jntyzx.zlb;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author caoliang
|
||||
* @version 1.0
|
||||
* @date 2025-06-22 19:49:46
|
||||
* @Description:***
|
||||
*/
|
||||
@Data
|
||||
public class ZlbOrderJson {
|
||||
@JsonProperty("issueIds")
|
||||
@JSONField(ordinal=1)
|
||||
private String issueIds;
|
||||
@JsonProperty("issueAmount")
|
||||
@JSONField(ordinal=2)
|
||||
private Integer issueAmount;
|
||||
@JsonProperty("cardOrderId")
|
||||
@JSONField(ordinal=3)
|
||||
private String cardOrderId;
|
||||
|
||||
|
||||
@JsonProperty("amount")
|
||||
@JSONField(ordinal=4)
|
||||
private Integer amount;
|
||||
@JsonProperty("belongDate")
|
||||
@JSONField(ordinal=5)
|
||||
private String belongDate;
|
||||
@JsonProperty("dayEffectiveTimes")
|
||||
@JSONField(ordinal=6)
|
||||
private String dayEffectiveTimes;
|
||||
@JsonProperty("dayOverdueTimes")
|
||||
@JSONField(ordinal=7)
|
||||
private String dayOverdueTimes;
|
||||
@JsonProperty("placeName")
|
||||
@JSONField(ordinal=8)
|
||||
private String placeName;
|
||||
@JsonProperty("siteId")
|
||||
@JSONField(ordinal=9)
|
||||
private String siteId;
|
||||
@JsonProperty("siteItemId")
|
||||
@JSONField(ordinal=10)
|
||||
private Integer siteItemId;
|
||||
@JsonProperty("siteRuleId")
|
||||
@JSONField(ordinal=11)
|
||||
private String siteRuleId;
|
||||
@JsonProperty("siteTicketId")
|
||||
@JSONField(ordinal=12)
|
||||
private Integer siteTicketId;
|
||||
@JsonProperty("payChannel")
|
||||
@JSONField(ordinal=13)
|
||||
private Integer payChannel;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.xiang.common.pojo.jntyzx.zlb;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author caoliang
|
||||
* @version 1.0
|
||||
* @date 2025-06-18 00:52:44
|
||||
* @Description:***
|
||||
*/
|
||||
@Data
|
||||
public class ZlbOrderWqInfo {
|
||||
private String siteOrderDetailsStr;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.xiang.common.pojo.jntyzx.zlb;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author caoliang
|
||||
* @version 1.0
|
||||
* @date 2025-06-22 19:49:46
|
||||
* @Description:***
|
||||
*/
|
||||
@Data
|
||||
public class ZlbOrderWqJson {
|
||||
@JsonProperty("issueIds")
|
||||
@JSONField(ordinal=1)
|
||||
private String issueIds;
|
||||
@JsonProperty("issueAmount")
|
||||
@JSONField(ordinal=2)
|
||||
private Integer issueAmount;
|
||||
@JsonProperty("cardOrderId")
|
||||
@JSONField(ordinal=3)
|
||||
private String cardOrderId;
|
||||
|
||||
|
||||
@JsonProperty("amount")
|
||||
@JSONField(ordinal=4)
|
||||
private Integer amount;
|
||||
@JsonProperty("belongDate")
|
||||
@JSONField(ordinal=5)
|
||||
private String belongDate;
|
||||
@JsonProperty("dayEffectiveTimes")
|
||||
@JSONField(ordinal=6)
|
||||
private String dayEffectiveTimes;
|
||||
@JsonProperty("dayOverdueTimes")
|
||||
@JSONField(ordinal=7)
|
||||
private String dayOverdueTimes;
|
||||
@JsonProperty("placeName")
|
||||
@JSONField(ordinal=8)
|
||||
private String placeName;
|
||||
|
||||
@JsonProperty("saasTicketId")
|
||||
@JSONField(ordinal=9)
|
||||
private String saasTicketId;
|
||||
|
||||
@JsonProperty("siteId")
|
||||
@JSONField(ordinal=10)
|
||||
private String siteId;
|
||||
@JsonProperty("siteItemId")
|
||||
@JSONField(ordinal=11)
|
||||
private Integer siteItemId;
|
||||
@JsonProperty("siteRuleId")
|
||||
@JSONField(ordinal=12)
|
||||
private String siteRuleId;
|
||||
@JsonProperty("siteTicketId")
|
||||
@JSONField(ordinal=13)
|
||||
private Integer siteTicketId;
|
||||
@JsonProperty("payChannel")
|
||||
@JSONField(ordinal=14)
|
||||
private Integer payChannel;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.xiang.common.pojo.jntyzx.zlb;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @TableName zlb_order_info
|
||||
*/
|
||||
@TableName(value ="zlb_order_info")
|
||||
@Data
|
||||
public class ZlbPayOrder {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
private String day;
|
||||
|
||||
/**
|
||||
* 场馆
|
||||
*/
|
||||
private String venues;
|
||||
|
||||
/**
|
||||
* 场地名称
|
||||
*/
|
||||
private String placeName;
|
||||
|
||||
/**
|
||||
* 时间id111
|
||||
*/
|
||||
private String time;
|
||||
|
||||
/**
|
||||
* 0-未付款,1-已付款
|
||||
*/
|
||||
private Integer isPay;
|
||||
}
|
||||
139
src/main/java/com/xiang/common/pojo/jntyzx/zlb/ZlbSiteInfo.java
Normal file
139
src/main/java/com/xiang/common/pojo/jntyzx/zlb/ZlbSiteInfo.java
Normal file
@@ -0,0 +1,139 @@
|
||||
package com.xiang.common.pojo.jntyzx.zlb;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @TableName zlb_site_info
|
||||
*/
|
||||
@TableName(value ="zlb_site_info")
|
||||
@Data
|
||||
public class ZlbSiteInfo {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 场地Id
|
||||
*/
|
||||
private Integer type;
|
||||
private Integer siteTicketId;
|
||||
|
||||
/**
|
||||
* 场地名称
|
||||
*/
|
||||
private String siteTicketName;
|
||||
private String saasTicketId;
|
||||
|
||||
/**
|
||||
* 金额
|
||||
*/
|
||||
private String siteRuleId;
|
||||
|
||||
/**
|
||||
* 金额
|
||||
*/
|
||||
private String siteId;
|
||||
|
||||
/**
|
||||
* 时间顺序id
|
||||
*/
|
||||
private String placeName;
|
||||
|
||||
/**
|
||||
* 票id
|
||||
*/
|
||||
private Integer weekType;
|
||||
|
||||
/**
|
||||
* 票id
|
||||
*/
|
||||
private Integer blocId;
|
||||
|
||||
/**
|
||||
* 票id
|
||||
*/
|
||||
private Integer stadiumId;
|
||||
|
||||
/**
|
||||
* 会员号
|
||||
*/
|
||||
private String stadiumName;
|
||||
|
||||
/**
|
||||
* 票id
|
||||
*/
|
||||
private Integer siteItemId;
|
||||
|
||||
/**
|
||||
* 订场人信息
|
||||
*/
|
||||
private String spName;
|
||||
|
||||
/**
|
||||
* 订场人电话
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 票id
|
||||
*/
|
||||
private Integer startCheckMinutes;
|
||||
|
||||
/**
|
||||
* 票id
|
||||
*/
|
||||
private Integer endCheckMinutes;
|
||||
|
||||
/**
|
||||
* 订场时间
|
||||
*/
|
||||
private String dayEffectiveTimes;
|
||||
|
||||
/**
|
||||
* 场地票名
|
||||
*/
|
||||
private String dayOverdueTimes;
|
||||
|
||||
/**
|
||||
* 票id
|
||||
*/
|
||||
private Integer amount;
|
||||
|
||||
/**
|
||||
* 票id
|
||||
*/
|
||||
private Integer ticketType;
|
||||
|
||||
/**
|
||||
* 场地票名
|
||||
*/
|
||||
private String belongDate;
|
||||
|
||||
/**
|
||||
* 场地票名
|
||||
*/
|
||||
private String isOpen;
|
||||
|
||||
/**
|
||||
* 票id
|
||||
*/
|
||||
private Integer isPreferential;
|
||||
|
||||
/**
|
||||
* 数据创建时间
|
||||
*/
|
||||
private Date createdDate;
|
||||
|
||||
/**
|
||||
* 数据修改时间
|
||||
*/
|
||||
private Date updatedDate;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xiang.common.pojo.jntyzx.zlb;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author caoliang
|
||||
* @version 1.0
|
||||
* @date 2025-06-19 23:53:44
|
||||
* @Description:***
|
||||
*/
|
||||
@Data
|
||||
public class ZlbSiteRequest {
|
||||
|
||||
private String dataStr;
|
||||
private String stadiumId;
|
||||
private Integer siteItemId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.xiang.common.pojo.jntyzx.zlb;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @TableName zlb_token_info
|
||||
*/
|
||||
@TableName(value ="zlb_token_info")
|
||||
@Data
|
||||
public class ZlbTokenInfo {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* tokenId
|
||||
*/
|
||||
private String tokenId;
|
||||
private String zlbUserId;
|
||||
private String secretKey;
|
||||
|
||||
/**
|
||||
* 是否失效0-未失效,1-失效
|
||||
*/
|
||||
private Integer isDel;
|
||||
private Date createdDate;
|
||||
private Date updatedDate;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.xiang.common.pojo.jntyzx.zlb;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @TableName zlb_user_info
|
||||
*/
|
||||
@TableName(value ="zlb_user_info")
|
||||
@Data
|
||||
public class ZlbUserInfo {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 星期几
|
||||
*/
|
||||
private String week;
|
||||
|
||||
/**
|
||||
* 分配的任务参数
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 场地信息
|
||||
*/
|
||||
private String placeName;
|
||||
|
||||
/**
|
||||
* 时间id111
|
||||
*/
|
||||
private String siteTimeName;
|
||||
|
||||
/**
|
||||
* 是否开抢0-抢,1-不抢
|
||||
*/
|
||||
private Integer isBook;
|
||||
}
|
||||
86
src/main/java/com/xiang/common/utils/AESECBUtils.java
Normal file
86
src/main/java/com/xiang/common/utils/AESECBUtils.java
Normal file
@@ -0,0 +1,86 @@
|
||||
package com.xiang.common.utils;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class AESECBUtils {
|
||||
// 填充方式(PKCS5Padding)
|
||||
private static final String ALGORITHM = "AES/ECB/PKCS5Padding";
|
||||
|
||||
/**
|
||||
* AES ECB 模式加密
|
||||
*
|
||||
* @param plainText 明文字符串
|
||||
* @param key 密钥(16 / 24 / 32 字节)
|
||||
* @return 十六进制格式的密文
|
||||
*/
|
||||
public static String encrypt(String plainText, String key) throws Exception {
|
||||
Cipher cipher = Cipher.getInstance(ALGORITHM);
|
||||
SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), "AES");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, keySpec);
|
||||
|
||||
byte[] encrypted = cipher.doFinal(plainText.getBytes(StandardCharsets.UTF_8));
|
||||
return bytesToHex(encrypted).toUpperCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* AES ECB 模式解密
|
||||
*
|
||||
* @param hexCipherText 十六进制格式的密文
|
||||
* @param key 密钥(16 / 24 / 32 字节)
|
||||
* @return 解密后的明文
|
||||
*/
|
||||
public static String decrypt(String hexCipherText, String key) throws Exception {
|
||||
Cipher cipher = Cipher.getInstance(ALGORITHM);
|
||||
SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), "AES");
|
||||
cipher.init(Cipher.DECRYPT_MODE, keySpec);
|
||||
|
||||
byte[] cipherData = hexStringToByteArray(hexCipherText);
|
||||
byte[] decrypted = cipher.doFinal(cipherData);
|
||||
return new String(decrypted, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
// 十六进制字符串转 byte[]
|
||||
private static byte[] hexStringToByteArray(String s) {
|
||||
int len = s.length();
|
||||
byte[] data = new byte[len / 2];
|
||||
for (int i = 0; i < len; i += 2) {
|
||||
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
|
||||
+ Character.digit(s.charAt(i + 1), 16));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
// byte[] 转十六进制字符串
|
||||
private static String bytesToHex(byte[] bytes) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b : bytes) {
|
||||
sb.append(String.format("%02x", b));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
// 示例主函数
|
||||
public static void main(String[] args) {
|
||||
String key = "1ad2ee1b6e3f4e81"; // 16字节密钥
|
||||
// String key = "3f18655f909d495d"; // 16字节密钥
|
||||
// String key = "ea08f7da82e44df7"; // 16字节密钥
|
||||
// 取前16位数密钥
|
||||
//String key = keystr.substring(0,16);
|
||||
|
||||
String longCiphertext = "8A559F1F4A8A782169E6F5BC32217A8CAA263E173FA2C05751CFC49B9018D57779F5B7C47B8C1570142EAB5A781175DE45AD141C3CC8E62380EA6C0036A2D80BF219B326C2302553E43B0F534A51D18D";
|
||||
|
||||
try {
|
||||
String decrypted = decrypt(longCiphertext, key);
|
||||
System.out.println("长密文解密结果: " + decrypted);
|
||||
decrypted = "{\"stadiumId\":\"49\",\"siteItemId\":1940,\"belongDate\":\"2025-10-10\",\"channelType\":6}";
|
||||
// decrypted = " {\"stadiumId\":\"360112\",\"siteItemId\":1148,\"belongDate\":\"2025-08-11\",\"channelType\":6}";
|
||||
String reEncrypted = encrypt(decrypted, key);
|
||||
System.out.println("重新加密结果: " + reEncrypted);
|
||||
} catch (Exception e) {
|
||||
System.err.println("长密文解密失败: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
606
src/main/java/com/xiang/common/utils/DateUtils.java
Normal file
606
src/main/java/com/xiang/common/utils/DateUtils.java
Normal file
@@ -0,0 +1,606 @@
|
||||
package com.xiang.common.utils;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.xiang.common.enums.DateFormatEnum;
|
||||
|
||||
import javax.xml.datatype.DatatypeConfigurationException;
|
||||
import javax.xml.datatype.DatatypeFactory;
|
||||
import javax.xml.datatype.XMLGregorianCalendar;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author clover
|
||||
* @Date 2020/9/15 09:31
|
||||
*/
|
||||
public class DateUtils {
|
||||
|
||||
|
||||
/**
|
||||
* 构造函数.
|
||||
*/
|
||||
public void DateUtil() {
|
||||
throw new RuntimeException("this is a util class,can not instance!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String ENUM_FORMAT = "yyyy-MM-dd HH:mm:ss";
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String ASCM_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
|
||||
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String ENUM_FORMAT_YMD = "yyyy-MM-dd";
|
||||
public static final String ENUM_FORMAT_YMD_1 = "yyyyMMdd";
|
||||
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String ENUM_FORMAT_YMDS = "yyyy-MM-dd HH:mm:ss.S";
|
||||
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String ENUM_FORMAT_SLASH = "yyyy/MM/dd HH:mm:ss";
|
||||
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String ENUM_FORMAT_YMDS_SLASH = "yyyy/MM/dd HH:mm:ss.S";
|
||||
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String LEVEL_DAY = "day"; // 粒度级别
|
||||
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String LEVEL_HOUR = "hour";
|
||||
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String LEVEL_MINUTE = "minute";
|
||||
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String LEVEL_SECOND = "second";
|
||||
|
||||
/**
|
||||
* 日期特殊字符对应.
|
||||
*/
|
||||
private static Map<String, String> mapSign = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 使用ThreadLocal保证SimpleDateFormat线程安全.
|
||||
*/
|
||||
private static ThreadLocal<Map<String, SimpleDateFormat>> threadLocalDateFormat = new ThreadLocal<>();
|
||||
|
||||
/**
|
||||
* 初始化DateFormat标志位.
|
||||
*/
|
||||
private static void initMapSign() {
|
||||
if (mapSign.isEmpty()) {
|
||||
mapSign.put("上午|下午", "a");
|
||||
mapSign.put("星期[一二三四五六日天七]", "E");
|
||||
mapSign.put("CST", "z");
|
||||
mapSign.put("公元[前]?", "G");
|
||||
}
|
||||
}
|
||||
|
||||
public static int getWeekDay() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
return calendar.get(Calendar.DAY_OF_WEEK);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Date date = DateUtils.addDate(new Date(), 6);
|
||||
String day = DateUtils.format(date, DateUtils.ENUM_FORMAT_YMD_1);
|
||||
System.out.println(day);
|
||||
System.out.println(getWeekDay(day));
|
||||
}
|
||||
|
||||
public static String getWeekDay(String bookTime) {//20250101
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||
// 解析输入日期
|
||||
LocalDate date = LocalDate.parse(bookTime, formatter);
|
||||
// 获取星期几
|
||||
DayOfWeek dayOfWeek = date.getDayOfWeek();
|
||||
// 将星期几转换为中文
|
||||
return convertToChinese(dayOfWeek);
|
||||
}
|
||||
|
||||
public static String getWeekDayTwo(String bookTime) {//20250101
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
// 解析输入日期
|
||||
LocalDate date = LocalDate.parse(bookTime, formatter);
|
||||
// 获取星期几
|
||||
DayOfWeek dayOfWeek = date.getDayOfWeek();
|
||||
// 将星期几转换为中文
|
||||
return convertToChinese(dayOfWeek);
|
||||
}
|
||||
|
||||
private static String convertToChinese(DayOfWeek dayOfWeek) {
|
||||
switch (dayOfWeek) {
|
||||
case MONDAY:
|
||||
return "星期一";
|
||||
case TUESDAY:
|
||||
return "星期二";
|
||||
case WEDNESDAY:
|
||||
return "星期三";
|
||||
case THURSDAY:
|
||||
return "星期四";
|
||||
case FRIDAY:
|
||||
return "星期五";
|
||||
case SATURDAY:
|
||||
return "星期六";
|
||||
case SUNDAY:
|
||||
return "星期日";
|
||||
default:
|
||||
return "未知";
|
||||
}
|
||||
}
|
||||
|
||||
public static String getBookTime() {
|
||||
Date date = DateUtils.addDate(new Date(), 1);
|
||||
return DateUtils.formatYMd(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前时间的毫秒数
|
||||
*
|
||||
* @return 当前时间
|
||||
*/
|
||||
public static long getTimeInMillis() {
|
||||
Date now = new Date();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(now);
|
||||
return calendar.getTimeInMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* 常规日期格式yyyy-MM-dd HH:mm:ss.
|
||||
*
|
||||
* @param date date
|
||||
* @return time
|
||||
*/
|
||||
public static String format(Date date) {
|
||||
return getDateFormat(ENUM_FORMAT).format(date);
|
||||
}
|
||||
|
||||
public static String format(Long timestamp) {
|
||||
return getDateFormat(ENUM_FORMAT).format(timestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 常规日期格式yyyy-MM-dd.
|
||||
*
|
||||
* @param date date
|
||||
* @return time
|
||||
*/
|
||||
public static String formatYMd(Date date) {
|
||||
return getDateFormat(ENUM_FORMAT_YMD).format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化时间.
|
||||
*
|
||||
* @param date date
|
||||
* @param dateFormat dateFormat
|
||||
* @return time
|
||||
*/
|
||||
public static String format(Date date, String dateFormat) {
|
||||
if (null == date) {
|
||||
return null;
|
||||
}
|
||||
return getDateFormat(dateFormat).format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* parse时间(yyyy-MM-dd HH:mm:ss).
|
||||
*
|
||||
* @param source source
|
||||
* @return Date
|
||||
* @throws ParseException ParseException
|
||||
*/
|
||||
public static Date parse(String source) throws ParseException {
|
||||
return getDateFormat(DateFormatEnum.COMMON1.getValue()).parse(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* parse时间(yyyy-MM-dd HH:mm:ss).
|
||||
*
|
||||
* @param source source
|
||||
* @return Date
|
||||
* @throws ParseException ParseException
|
||||
*/
|
||||
public static Date parseAscm(String source) throws ParseException {
|
||||
return getDateFormat(ASCM_FORMAT).parse(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* parse时间(yyyy-MM-dd).
|
||||
*
|
||||
* @param source source
|
||||
* @return Date
|
||||
* @throws ParseException ParseException
|
||||
*/
|
||||
public static Date parseYMd(String source) throws ParseException {
|
||||
return getDateFormat(ENUM_FORMAT_YMD).parse(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化时间.
|
||||
*
|
||||
* @param time time
|
||||
* @param dateFormat dateFormat
|
||||
* @return Date
|
||||
* @throws ParseException ParseException
|
||||
*/
|
||||
public static Date parse(String time, String dateFormat) throws ParseException {
|
||||
if (isNullOrEmpty(time) || isNullOrEmpty(dateFormat)) {
|
||||
return null;
|
||||
}
|
||||
return getDateFormat(dateFormat).parse(time);
|
||||
}
|
||||
|
||||
public static Date parse(String time, String dateFormat, String timeZone) throws ParseException {
|
||||
if (isNullOrEmpty(time) || isNullOrEmpty(dateFormat)) {
|
||||
return null;
|
||||
}
|
||||
return getDateFormat(dateFormat, timeZone).parse(time);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定时间格式的 SimpleDateFormat.
|
||||
*
|
||||
* @param pattern 时间格式
|
||||
* @return SimpleDateFormat
|
||||
*/
|
||||
public static SimpleDateFormat getDateFormat(String pattern) {
|
||||
Map<String, SimpleDateFormat> dateFormatMap = threadLocalDateFormat.get();
|
||||
if (dateFormatMap == null) {
|
||||
dateFormatMap = new HashMap<>();
|
||||
}
|
||||
SimpleDateFormat simpleDateFormat = dateFormatMap.get(pattern);
|
||||
if (simpleDateFormat == null) {
|
||||
simpleDateFormat = new SimpleDateFormat(pattern, Locale.getDefault());
|
||||
dateFormatMap.put(pattern, simpleDateFormat);
|
||||
threadLocalDateFormat.set(dateFormatMap);
|
||||
}
|
||||
return simpleDateFormat;
|
||||
}
|
||||
|
||||
private static SimpleDateFormat getDateFormat(String pattern, String timeZone) {
|
||||
SimpleDateFormat dateFormat = getDateFormat(pattern);
|
||||
if (StringUtils.isNotBlank(timeZone)) {
|
||||
dateFormat.setTimeZone(TimeZone.getTimeZone(timeZone));
|
||||
}
|
||||
return dateFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动解析时间格式并parse(时间格式为yyyyMMddHHmmssS,默认24小时制、前包含且必须包含yyyyMMdd).
|
||||
*
|
||||
* @param time time
|
||||
* @return Date
|
||||
* @throws ParseException ParseException
|
||||
*/
|
||||
public static Date parseAuto(String time) throws ParseException {
|
||||
if (isNullOrEmpty(time) || time.length() < 8) {
|
||||
return null;
|
||||
}
|
||||
initMapSign();
|
||||
time = time.trim();
|
||||
String formatPattern = "";
|
||||
if (time.matches("[\\d]+")) { // 纯数字
|
||||
String all = "yyyyMMddHHmmssSSS";
|
||||
if (time.length() > all.length()) { // 超长截取
|
||||
time = time.substring(0, all.length());
|
||||
}
|
||||
formatPattern = all.substring(0, time.length());
|
||||
} else {
|
||||
char next = 'y';
|
||||
String idNext = "yMdHmsS";
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
for (char var : time.toCharArray()) {
|
||||
if (String.valueOf(var).matches("[0-9]")) {
|
||||
buffer.append(next);
|
||||
} else if ("T".equals(String.valueOf(var))) {
|
||||
buffer.append("'").append(var).append("'");
|
||||
} else {
|
||||
buffer.append(var);
|
||||
next = idNext.charAt(Math.min(idNext.indexOf(next) + 1, idNext.length() - 1));
|
||||
}
|
||||
}
|
||||
formatPattern = buffer.toString();
|
||||
}
|
||||
for (Map.Entry<String, String> entry : mapSign.entrySet()) {
|
||||
formatPattern = formatPattern.replaceAll(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return parse(time, formatPattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为空或"".
|
||||
*
|
||||
* @param param param
|
||||
* @return boolean
|
||||
*/
|
||||
private static boolean isNullOrEmpty(String param) {
|
||||
return null == param || "".equals(param.trim());
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期增加num天.
|
||||
*
|
||||
* @param date date
|
||||
* @param num 加减天数
|
||||
* @return Date
|
||||
*/
|
||||
public static Date addDate(Date date, int num) {
|
||||
return addDate(date, Calendar.DATE, num);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间增加.
|
||||
*
|
||||
* @param date date
|
||||
* @param calendar 加减级别Calendar
|
||||
* @param num 加减天数
|
||||
* @return Date
|
||||
*/
|
||||
public static Date addDate(Date date, int calendar, int num) {
|
||||
if (null == date || 0 == num) {
|
||||
return date;
|
||||
}
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
cal.add(calendar, num);
|
||||
return cal.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 保留日期到某一级别(天、时、分、秒...).
|
||||
*
|
||||
* @param date date
|
||||
* @param level 保留级别,null保留到day
|
||||
* @return date
|
||||
*/
|
||||
public static Date setDate(Date date, String level) {
|
||||
if (null == date || null == level) {
|
||||
return date;
|
||||
}
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
switch (level) {
|
||||
case LEVEL_DAY: // 保留到 Day
|
||||
// cal.set(Calendar.HOUR, 0); // 12小时制
|
||||
cal.set(Calendar.HOUR_OF_DAY, 0); // 24小时制
|
||||
cal.set(Calendar.MINUTE, 0);
|
||||
cal.set(Calendar.SECOND, 0);
|
||||
break;
|
||||
case LEVEL_HOUR: // 保留到 Hour
|
||||
cal.set(Calendar.MINUTE, 0);
|
||||
cal.set(Calendar.SECOND, 0);
|
||||
break;
|
||||
case LEVEL_MINUTE: // 保留到 MINUTE
|
||||
cal.set(Calendar.SECOND, 0);
|
||||
break;
|
||||
case LEVEL_SECOND: // 保留到 SECOND
|
||||
cal.set(Calendar.MILLISECOND, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return cal.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 比较两个日期的间隔(时间差绝对值,向下取整)(day、hour、minute).
|
||||
*
|
||||
* @param date1 date1
|
||||
* @param date2 date2
|
||||
* @param level 比较级别
|
||||
* @return int 无对应时间间隔级别
|
||||
*/
|
||||
public static Integer getDateInterval(Date date1, Date date2, String level) {
|
||||
Double num = dateInterval(date1, date2, level);
|
||||
if (null == num) {
|
||||
return null;
|
||||
}
|
||||
return (int) Math.floor(num);
|
||||
}
|
||||
|
||||
/**
|
||||
* 比较两个日期的间隔(时间差绝对值,向上取整)(day、hour、minute).
|
||||
*
|
||||
* @param date1 date1
|
||||
* @param date2 date2
|
||||
* @param level 比较级别
|
||||
* @return int 无对应时间间隔级别
|
||||
*/
|
||||
public static Integer getDateIntervalCeil(Date date1, Date date2, String level) {
|
||||
Double num = dateInterval(date1, date2, level);
|
||||
if (null == num) {
|
||||
return null;
|
||||
}
|
||||
return (int) Math.ceil(num);
|
||||
}
|
||||
|
||||
/**
|
||||
* 比较两个日期的间隔(day、hour、minute).
|
||||
*
|
||||
* @param date1 date1
|
||||
* @param date2 date2
|
||||
* @param level 比较级别
|
||||
* @return int 无对应时间间隔级别
|
||||
*/
|
||||
private static Double dateInterval(Date date1, Date date2, String level) {
|
||||
Double time = (double) (date1.getTime() - date2.getTime());
|
||||
if (time < 0) {
|
||||
time = time * -1;
|
||||
}
|
||||
Double num = null;
|
||||
switch (level) {
|
||||
case LEVEL_DAY: // 天
|
||||
num = (Double) (time / TimeUnit.DAYS.toMillis(1));
|
||||
break;
|
||||
case LEVEL_HOUR: // 小时
|
||||
num = (Double) (time / TimeUnit.HOURS.toMillis(1));
|
||||
break;
|
||||
case LEVEL_MINUTE: // 分钟
|
||||
num = (Double) (time / TimeUnit.MINUTES.toMillis(1));
|
||||
break;
|
||||
case LEVEL_SECOND: // 秒
|
||||
num = (Double) (time / TimeUnit.SECONDS.toMillis(1));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前日期指定时间.
|
||||
*
|
||||
* @param date date
|
||||
* @param time time
|
||||
* @return date
|
||||
* @throws ParseException ParseException
|
||||
*/
|
||||
public static Date dateToHms(Date date, String time) throws ParseException {
|
||||
if (null == date || isNullOrEmpty(time)) {
|
||||
return date;
|
||||
}
|
||||
StringBuilder timeBuf = new StringBuilder();
|
||||
String dateStr = formatYMd(date);
|
||||
timeBuf.append(dateStr).append(" ");
|
||||
time = time.trim();
|
||||
while (!time.matches(".*\\d")) {
|
||||
time = time.substring(0, time.length() - 1);
|
||||
}
|
||||
timeBuf.append(time);
|
||||
if (time.matches("\\d{1,2}:\\d{1,2}:\\d{1,2}")) {
|
||||
timeBuf.append(".0");
|
||||
} else if (time.matches("\\d{1,2}:\\d{1,2}")) {
|
||||
timeBuf.append(":00.0");
|
||||
} else if (time.matches("\\d{1,2}")) {
|
||||
timeBuf.append(":00:00.0");
|
||||
}
|
||||
return parse(timeBuf.toString(), ENUM_FORMAT_YMDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取N天之前的时间
|
||||
*
|
||||
* @param beforeDays
|
||||
* @return
|
||||
*/
|
||||
public static Date getDateBefore(int beforeDays) {
|
||||
Calendar now = Calendar.getInstance();
|
||||
now.setTime(new Date());
|
||||
now.set(Calendar.DATE, now.get(Calendar.DATE) - beforeDays);
|
||||
return now.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将Date类转换为XMLGregorianCalendar.
|
||||
*
|
||||
* @param date date
|
||||
* @return XMLGregorianCalendar
|
||||
* @throws DatatypeConfigurationException DatatypeConfigurationException
|
||||
*/
|
||||
public static XMLGregorianCalendar dateToXmlDate(Date date) throws DatatypeConfigurationException {
|
||||
XMLGregorianCalendar dateType = null;
|
||||
if (null != date) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
DatatypeFactory dtf = DatatypeFactory.newInstance();
|
||||
dateType = dtf.newXMLGregorianCalendar();
|
||||
if (null != dateType) {
|
||||
dateType.setYear(cal.get(Calendar.YEAR));
|
||||
// 由于Calendar.MONTH取值范围为0~11,需要加1
|
||||
dateType.setMonth(cal.get(Calendar.MONTH) + 1);
|
||||
dateType.setDay(cal.get(Calendar.DAY_OF_MONTH));
|
||||
dateType.setHour(cal.get(Calendar.HOUR_OF_DAY));
|
||||
dateType.setMinute(cal.get(Calendar.MINUTE));
|
||||
dateType.setSecond(cal.get(Calendar.SECOND));
|
||||
}
|
||||
}
|
||||
return dateType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理ThreadLocal(每次线程结束都应执行此操作).
|
||||
*/
|
||||
public static void clearThreadLocal() {
|
||||
threadLocalDateFormat.remove();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取前一天的23点59分59秒,避免
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getYesterdayForSurvey() {
|
||||
SimpleDateFormat dateFormat = getDateFormat(DateFormatEnum.COMMON1.getValue());
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.add(Calendar.DATE, -1);
|
||||
c.set(Calendar.HOUR_OF_DAY, 23);
|
||||
c.set(Calendar.MINUTE, 59);
|
||||
c.set(Calendar.SECOND, 59);
|
||||
return dateFormat.format(c.getTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取前一天时间yyyy-mm-dd
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getYesterdayForYMD() {
|
||||
SimpleDateFormat dateFormat = getDateFormat(DateFormatEnum.ENUM_FORMAT_YMD.getValue());
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.add(Calendar.DATE, -1);
|
||||
return dateFormat.format(c.getTime());
|
||||
}
|
||||
|
||||
public static Date getYesterday() {
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.add(Calendar.DATE, -1);
|
||||
c.set(Calendar.HOUR_OF_DAY, 23);
|
||||
c.set(Calendar.MINUTE, 59);
|
||||
c.set(Calendar.SECOND, 59);
|
||||
return c.getTime();
|
||||
}
|
||||
|
||||
public static String getLastDayMonthStr() {
|
||||
LocalDate now = LocalDate.now();
|
||||
LocalDate lastDay = now.minusDays(1L);
|
||||
return lastDay.format(DateTimeFormatter.ofPattern("yyyyMM"));
|
||||
}
|
||||
|
||||
private static final ConcurrentHashMap<String, Date> modifiedDate = new ConcurrentHashMap<>();
|
||||
|
||||
public static Date getModifiedDate(String key) {
|
||||
return modifiedDate.get(key);
|
||||
}
|
||||
|
||||
public static Date setModifiedDate(String key, Date date) {
|
||||
return modifiedDate.put(key, date);
|
||||
}
|
||||
}
|
||||
169
src/main/java/com/xiang/common/utils/OkHttpUtil.java
Normal file
169
src/main/java/com/xiang/common/utils/OkHttpUtil.java
Normal file
@@ -0,0 +1,169 @@
|
||||
package com.xiang.common.utils;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.xiang.common.handler.CallbackHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.*;
|
||||
|
||||
import javax.net.ssl.*;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Slf4j
|
||||
public class OkHttpUtil {
|
||||
|
||||
private static final String secretId = "o82qrnb4z0s8y6j9qvyw";
|
||||
private static final String signature = "p93f1o4fn6zht9sa6aryu9wpfp2el8dm";
|
||||
private static final String urlString = "https://dps.kdlapi.com/api/getdps/?secret_id=" + secretId + "&signature=" + signature + "&num=1&format=text&sep=1";
|
||||
// 用户名密码认证(私密代理/独享代理)
|
||||
static final String username = "d2859987908";
|
||||
static final String password = "1auxzpkz";
|
||||
// 单例实例
|
||||
private static final OkHttpUtil INSTANCE;
|
||||
|
||||
static {
|
||||
try {
|
||||
INSTANCE = new OkHttpUtil();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (KeyManagementException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
// OkHttpClient 实例
|
||||
private final OkHttpClient client;
|
||||
|
||||
// 私有构造方法,初始化 OkHttpClient
|
||||
private OkHttpUtil() throws NoSuchAlgorithmException, KeyManagementException {
|
||||
// 创建一个信任所有证书的TrustManager
|
||||
final TrustManager[] trustAllCerts = new TrustManager[]{
|
||||
new X509TrustManager() {
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return new X509Certificate[]{};
|
||||
}
|
||||
}
|
||||
};
|
||||
// 初始化SSLContext
|
||||
final SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
|
||||
|
||||
// 创建一个信任所有主机名的HostnameVerifier
|
||||
HostnameVerifier allHostsValid = new HostnameVerifier() {
|
||||
@Override
|
||||
public boolean verify(String hostname, SSLSession session) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
// 2. 配置连接池(关键参数)
|
||||
ConnectionPool pool = new ConnectionPool(
|
||||
5, // 最大空闲连接数(根据服务器承受能力调整)
|
||||
5, // 存活时间(分钟)
|
||||
TimeUnit.MINUTES
|
||||
);
|
||||
|
||||
client = new OkHttpClient.Builder()
|
||||
.sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustAllCerts[0])
|
||||
.hostnameVerifier(allHostsValid)
|
||||
.connectionPool(pool)
|
||||
.connectTimeout(60, TimeUnit.SECONDS) // 连接超时时间
|
||||
.readTimeout(60, TimeUnit.SECONDS) // 读取超时时间
|
||||
.writeTimeout(60, TimeUnit.SECONDS) // 写入超时时间
|
||||
.retryOnConnectionFailure(true) // 自动重试
|
||||
.protocols(Arrays.asList(Protocol.HTTP_2, Protocol.HTTP_1_1)) // 协议优先级
|
||||
.build();
|
||||
}
|
||||
|
||||
public OkHttpUtil(OkHttpClient client){
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 获取单例实例
|
||||
public static OkHttpUtil getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发送 GET 请求
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param headers 请求头(可以为空)
|
||||
* @return 响应结果
|
||||
* @throws IOException 请求失败时抛出异常
|
||||
*/
|
||||
public String get(String url, Map<String, String> headers) throws IOException {
|
||||
Request.Builder builder = new Request.Builder().url(url);
|
||||
|
||||
// 添加请求头
|
||||
if (headers != null) {
|
||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||
builder.addHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
Request request = builder.build();
|
||||
try (Response response = client.newCall(request).execute()) {
|
||||
String string = response.body().string();
|
||||
if (!response.isSuccessful()) {
|
||||
log.error("{}okhttp请求失败: {}-->", url, string);
|
||||
}
|
||||
return string;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送 POST 请求(JSON 格式)
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param headers 请求头(可以为空)
|
||||
* @param json JSON 请求体
|
||||
* @return 响应结果
|
||||
* @throws IOException 请求失败时抛出异常
|
||||
*/
|
||||
public String postJson(String url, Map<String, String> headers, String json) throws IOException {
|
||||
RequestBody body = RequestBody.create(json, MediaType.parse("application/json; charset=utf-8"));
|
||||
Request.Builder builder = new Request.Builder()
|
||||
.url(url)
|
||||
.post(body)
|
||||
.addHeader("User-Agent", "BookingClient/1.0");
|
||||
|
||||
// 添加请求头
|
||||
if (headers != null) {
|
||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||
builder.addHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
Request request = builder.build();
|
||||
|
||||
try (Response response = client.newCall(request).execute()) {
|
||||
String string = response.body().string();
|
||||
if (!response.isSuccessful()) {
|
||||
log.error("{}okhttp请求失败: {}-->", url, string);
|
||||
return string;
|
||||
}
|
||||
return string;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.xiang.service.module.jntyzx.zlb.constants;
|
||||
|
||||
public class ZlbUrlConstants {
|
||||
/**
|
||||
* 获取验证码接口
|
||||
*/
|
||||
public static final String captchaUrl = "https://asian.hzsports.net/sendMessageServer/in/captcha/genCaptcha";
|
||||
/**
|
||||
* 获取图片轨迹接口
|
||||
*/
|
||||
public static final String getCaptchaUrl = "http://118.31.116.52:5700/captcha";
|
||||
/**
|
||||
* 下单接口
|
||||
*/
|
||||
public static final String newOrderUrl = "https://asian.hzsports.net/sportticketserver/site/sitePlaceOrder";
|
||||
/**
|
||||
* 获取用户信息接口
|
||||
*/
|
||||
public static final String getUserInfoUrl = "https://asian.hzsports.net/sportthirdserver/zjmanage/getUserInfo";
|
||||
/**
|
||||
* 获取场地接口
|
||||
*/
|
||||
public static final String getSiteInfoUrl = "https://asian.hzsports.net/sportticketserver/site/selectTicketListBy";
|
||||
/**
|
||||
* 获取订单接口
|
||||
*/
|
||||
public static final String getOrderInfoUrl = "https://asian.hzsports.net/sportticketserver/orderV2/listSiteAndTicket";
|
||||
/**
|
||||
* 获取订单详情接口
|
||||
*/
|
||||
public static final String getOrderDetailUrl = "https://asian.hzsports.net/sportticketserver/orderV2/siteDetail/%s";
|
||||
/**
|
||||
* 退单接口
|
||||
*/
|
||||
public static final String getOrderRefundUrl = "https://asian.hzsports.net/sportticketserver/orderV2/refund";
|
||||
/**
|
||||
* 取消接口
|
||||
*/
|
||||
public static final String getOrderCancelUrl = "https://asian.hzsports.net/sportticketserver/orderV2/cancel";
|
||||
|
||||
|
||||
public static final String siteStr = "{\"stadiumId\":\"49\",\"siteItemId\":1940,\"belongDate\":\"%s\",\"channelType\":6}";
|
||||
public static final String siteWqStr = "{\"stadiumId\":\"360112\",\"siteItemId\":1148,\"belongDate\":\"%s\",\"channelType\":6}";
|
||||
public static final String refundStr = "{\"detailOrderId\":%s,\"detailOrderIds\":[%s],\"type\":2}";
|
||||
public static final String cancelStr = "{\"orderId\":%s,\"type\":2}";
|
||||
|
||||
public static final String REDIS_PREFIX = "order:renew";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.xiang.service.module.jntyzx.zlb.schedule;
|
||||
|
||||
public class ZlbTaskConfig {
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.xiang.service.module.jntyzx.zlb.service;
|
||||
|
||||
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbUserInfo;
|
||||
import com.xiang.common.utils.OkHttpUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author caoliang
|
||||
* @version 1.0
|
||||
* @date 2025-06-19 23:26:08
|
||||
* @Description:***
|
||||
*/
|
||||
public interface ZlbService {
|
||||
void queryZLbSiteInfo(String ymdDate,Integer type) throws Exception;
|
||||
|
||||
String getKey(String tokenId, OkHttpUtil client) throws IOException;
|
||||
|
||||
|
||||
void testJs(String token, String name) throws IOException;
|
||||
|
||||
Map<String, String> getHeaders(String tokenId);
|
||||
|
||||
String buildSiteOrder(ZlbUserInfo zlbUserInfo, String secretKey, String day) throws Exception;
|
||||
|
||||
void createOrder(ZlbUserInfo zlbUserInfo) throws Exception;
|
||||
|
||||
String createOrderWq(ZlbUserInfo zlbUserInfo) throws Exception;
|
||||
|
||||
String buildNewOrder(String siteOrderDetailsStr, OkHttpUtil client) throws IOException;
|
||||
|
||||
void deleteRedis(String name);
|
||||
|
||||
void installRedis(String name);
|
||||
|
||||
void jianlou(String name, String day,long time) throws Exception;
|
||||
|
||||
void refundOrder(String refundName, String day) throws Exception;
|
||||
|
||||
void cancelOrder(String cancelName, String day) throws Exception;
|
||||
}
|
||||
@@ -0,0 +1,600 @@
|
||||
package com.xiang.service.module.jntyzx.zlb.service;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.xiang.common.factory.JntyzxDingTalkFactory;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.*;
|
||||
import com.xiang.common.utils.AESECBUtils;
|
||||
import com.xiang.common.utils.DateUtils;
|
||||
import com.xiang.common.utils.OkHttpUtil;
|
||||
import com.xiang.service.module.jntyzx.zlb.constants.ZlbUrlConstants;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ZlbServiceImpl implements ZlbService {
|
||||
|
||||
|
||||
@Resource
|
||||
private ZlbSiteInfoService zlbSiteInfoService;
|
||||
@Resource
|
||||
private ZlbTokenInfoService zlbTokenInfoService;
|
||||
@Autowired
|
||||
private JntyzxDingTalkFactory jntyzxDingTalkFactory;
|
||||
@Autowired
|
||||
private ZlbUserInfoService zlbUserInfoService;
|
||||
@Autowired
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
|
||||
@Override
|
||||
public void queryZLbSiteInfo(String ymdDate, Integer type) throws Exception {
|
||||
log.info("开始查询场地信息");
|
||||
LambdaQueryWrapper<ZlbSiteInfo> wrapper1 = Wrappers.lambdaQuery();
|
||||
wrapper1.eq(ZlbSiteInfo::getType, type);
|
||||
wrapper1.eq(ZlbSiteInfo::getBelongDate, ymdDate);
|
||||
List<ZlbSiteInfo> zlbSiteInfoList1 = zlbSiteInfoService.list(wrapper1);
|
||||
if (!zlbSiteInfoList1.isEmpty()) {
|
||||
if (type == 1) {
|
||||
dayinLog(zlbSiteInfoList1);
|
||||
return;
|
||||
} else {
|
||||
zlbSiteInfoService.remove(wrapper1);
|
||||
}
|
||||
}
|
||||
jntyzxDingTalkFactory.sendMsg(type + "没有查到" + ymdDate + "的场地,开始补齐");
|
||||
OkHttpUtil client = OkHttpUtil.getInstance();
|
||||
LambdaQueryWrapper<ZlbTokenInfo> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(ZlbTokenInfo::getName, "Xiang");
|
||||
ZlbTokenInfo zlbTokenInfo = zlbTokenInfoService.getOne(wrapper);
|
||||
List<ZlbSiteInfo> zlbSiteInfoList = new ArrayList<>();
|
||||
String tokenId = zlbTokenInfo.getTokenId();
|
||||
String key = getKey(tokenId, client);
|
||||
log.info("tokenId==>{}", tokenId);
|
||||
String siteOrderDetailsStr = "";
|
||||
if (type.equals(1)) {
|
||||
siteOrderDetailsStr = String.format(ZlbUrlConstants.siteStr, ymdDate);
|
||||
} else if (type.equals(2)) {
|
||||
siteOrderDetailsStr = String.format(ZlbUrlConstants.siteWqStr, ymdDate);
|
||||
}
|
||||
String reEncrypted = AESECBUtils.encrypt(siteOrderDetailsStr, key);
|
||||
ZlbSiteRequest zlbSiteRequest = new ZlbSiteRequest();
|
||||
zlbSiteRequest.setDataStr(reEncrypted);
|
||||
zlbSiteRequest.setStadiumId("49");
|
||||
zlbSiteRequest.setSiteItemId(1940);
|
||||
String jsonString = JSON.toJSONString(zlbSiteRequest);
|
||||
log.info("json:{}", jsonString);
|
||||
//请求场地信息
|
||||
Map<String, String> headers = getHeaders(tokenId);
|
||||
String siteInfo = client.postJson(ZlbUrlConstants.getSiteInfoUrl, headers, jsonString);
|
||||
log.info("请求场地返回信息: \n {}", siteInfo);
|
||||
JSONObject jsonObject = JSONObject.parseObject(siteInfo);
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
String listString = data.getString("list");
|
||||
List<ZlbSiteInfo> zlbSiteInfos = JSONArray.parseArray(listString, ZlbSiteInfo.class);
|
||||
for (ZlbSiteInfo zlbSiteInfo : zlbSiteInfos) {
|
||||
Integer ticketType = zlbSiteInfo.getTicketType();
|
||||
if (ticketType == 1 && type == 1) {//代表可以抢的场地号
|
||||
zlbSiteInfo.setType(1);
|
||||
zlbSiteInfoList.add(zlbSiteInfo);
|
||||
}
|
||||
if (ticketType == 4 && type == 1) {//代表可以抢的场地号
|
||||
zlbSiteInfo.setType(4);
|
||||
zlbSiteInfoList.add(zlbSiteInfo);
|
||||
}
|
||||
if (type == 2) {//代表可以抢的场地号
|
||||
zlbSiteInfo.setType(2);
|
||||
zlbSiteInfoList.add(zlbSiteInfo);
|
||||
}
|
||||
}
|
||||
if (!zlbSiteInfoList.isEmpty()) {
|
||||
|
||||
zlbSiteInfoService.saveBatch(zlbSiteInfoList);
|
||||
}
|
||||
if (type.equals(1)) {
|
||||
dayinLog(zlbSiteInfoList);
|
||||
}
|
||||
}
|
||||
|
||||
private void dayinLog(List<ZlbSiteInfo> zlbSiteInfoList1) {
|
||||
Map<String, List<ZlbSiteInfo>> collect = zlbSiteInfoList1.stream().collect(Collectors.groupingBy(ZlbSiteInfo::getDayEffectiveTimes));
|
||||
List<ZlbSiteInfo> zlbSiteInfos6_8 = collect.get("18:00");
|
||||
List<ZlbSiteInfo> zlbSiteInfos8_10 = collect.get("20:00");
|
||||
List<String> collect1 = zlbSiteInfos6_8.stream().map(ZlbSiteInfo::getPlaceName).collect(Collectors.toList());
|
||||
List<String> collect2 = zlbSiteInfos8_10.stream().map(ZlbSiteInfo::getPlaceName).collect(Collectors.toList());
|
||||
jntyzxDingTalkFactory.sendMsg("查询到后天场地6-8" + collect1);
|
||||
jntyzxDingTalkFactory.sendMsg("查询到后天场地8-10" + collect2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey(String tokenId, OkHttpUtil client) throws IOException {
|
||||
Map<String, String> headers = getHeaders(tokenId);
|
||||
String response = client.postJson(ZlbUrlConstants.getUserInfoUrl, headers, "{}");
|
||||
log.info("获取用户信息返回:{}", response);
|
||||
if (StringUtils.isNotBlank(response)) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(response);
|
||||
String code = jsonObject.getString("code");
|
||||
if ("200".equals(code)) {
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
String secretKey = data.getString("secretKey");
|
||||
//截取密钥前16位
|
||||
return secretKey.substring(0, 16);
|
||||
}
|
||||
}
|
||||
return "未登录";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getHeaders(String tokenId) {
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Host", "asian.hzsports.net");
|
||||
headers.put("Accept", "*/*");
|
||||
headers.put("Sec-Fetch-Site", "cross-site");
|
||||
headers.put("Accept-Language", "zh-CN,zh;q=0.9");
|
||||
headers.put("Accept-Encoding", "gzip, deflate, br");
|
||||
headers.put("token", tokenId);
|
||||
headers.put("yayunToken", tokenId);
|
||||
headers.put("Origin", "https://mapi.zjzwfw.gov.cn");
|
||||
headers.put("User-Agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 18_6_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/22G100 Ariver/1.0.10 Jupiter/1.0.0 000001@ZLB_iphone_7.28.0 hanweb_iphone_/hanweb/dtdreamweb/bundleVersion7.28.0");
|
||||
headers.put("Referer", "https://mapi.zjzwfw.gov.cn/");
|
||||
headers.put("Connection", "keep-alive");
|
||||
headers.put("Content-Type", "application/json;charset=UTF-8");
|
||||
headers.put("Sec-Fetch-Dest", "empty");
|
||||
headers.put("Sec-Fetch-Mode", "cors");
|
||||
return headers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String buildSiteOrder(ZlbUserInfo zlbUserInfo, String secretKey, String day) throws Exception {
|
||||
//获取配置的场地号
|
||||
log.info("secretKey:{}", secretKey);
|
||||
String placeName = zlbUserInfo.getPlaceName();
|
||||
String siteTimeName = zlbUserInfo.getSiteTimeName();
|
||||
LambdaQueryWrapper<ZlbSiteInfo> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(ZlbSiteInfo::getPlaceName, placeName);
|
||||
wrapper.eq(ZlbSiteInfo::getDayEffectiveTimes, siteTimeName);
|
||||
wrapper.eq(ZlbSiteInfo::getBelongDate, day);
|
||||
ZlbSiteInfo zlbSiteInfo = zlbSiteInfoService.getOne(wrapper);
|
||||
if (zlbSiteInfo != null) {
|
||||
ZlbOrderJson zlbOrderJson = new ZlbOrderJson();
|
||||
zlbOrderJson.setAmount(zlbSiteInfo.getAmount());
|
||||
zlbOrderJson.setBelongDate(zlbSiteInfo.getBelongDate());
|
||||
zlbOrderJson.setDayEffectiveTimes(zlbSiteInfo.getDayEffectiveTimes());
|
||||
zlbOrderJson.setDayOverdueTimes(zlbSiteInfo.getDayOverdueTimes());
|
||||
zlbOrderJson.setPlaceName(zlbSiteInfo.getPlaceName());
|
||||
zlbOrderJson.setSiteId(zlbSiteInfo.getSiteId());
|
||||
zlbOrderJson.setSiteItemId(zlbSiteInfo.getSiteItemId());
|
||||
zlbOrderJson.setSiteRuleId(zlbSiteInfo.getSiteRuleId());
|
||||
zlbOrderJson.setSiteTicketId(zlbSiteInfo.getSiteTicketId());
|
||||
zlbOrderJson.setPayChannel(2);
|
||||
List<ZlbOrderJson> zlbOrderJsons = new ArrayList<>();
|
||||
zlbOrderJsons.add(zlbOrderJson);
|
||||
String jsonString = JSON.toJSONString(zlbOrderJsons);
|
||||
return AESECBUtils.encrypt(jsonString, secretKey);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createOrder(ZlbUserInfo zlbUserInfo) throws Exception {
|
||||
Date date = DateUtils.addDate(new Date(), 1);
|
||||
String day = DateUtils.format(date, DateUtils.ENUM_FORMAT_YMD);
|
||||
String name = zlbUserInfo.getName();
|
||||
String placeName = zlbUserInfo.getPlaceName();
|
||||
String siteTimeName = zlbUserInfo.getSiteTimeName();
|
||||
//获取Token
|
||||
ZlbTokenInfo zlbTokenInfo = zlbTokenInfoService.queryByName(name);
|
||||
OkHttpUtil client = OkHttpUtil.getInstance();
|
||||
String tokenId = zlbTokenInfo.getTokenId();
|
||||
String secretKey = getKey(tokenId, client);
|
||||
//组装场地信息
|
||||
String siteOrderDetailsStr = buildSiteOrder(zlbUserInfo, secretKey, day);
|
||||
//加密
|
||||
|
||||
for (int i = 1; i < 12; i++) {
|
||||
String response1 = sendOrder(siteOrderDetailsStr, zlbTokenInfo.getTokenId(), client);
|
||||
String str = buildOrder(name, response1, placeName, siteTimeName);
|
||||
if ("下单成功".equals(str)) {
|
||||
return;
|
||||
}
|
||||
if ("您选择场地已被售出".equals(str)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String buildOrder(String name, String response, String placeName, String siteTimeName) throws InterruptedException {
|
||||
String orderId = "";
|
||||
log.info("订单接口返回结果==> \n {}", response);
|
||||
JSONObject jsonObject = JSONObject.parseObject(response);
|
||||
if (jsonObject.getInteger("code") == 200) {
|
||||
jntyzxDingTalkFactory.sendMsg(name + "订单接口下单返回成功请2分钟内付款√√√√√√场地号:" + placeName + "时间:" + siteTimeName);
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
orderId = data.getString("orderId");
|
||||
log.info("{}订单{}创建成功", name, orderId);
|
||||
String redisKey = ZlbUrlConstants.REDIS_PREFIX + "_" + orderId + "_" + name;
|
||||
redisTemplate.opsForValue().set(redisKey, name);
|
||||
redisTemplate.expire(redisKey, 123, TimeUnit.SECONDS);
|
||||
return "下单成功";
|
||||
} else if (response.contains("场地不在可售时间内")) {
|
||||
return "下单失败";
|
||||
} else if (response.contains("下单失败")) {
|
||||
return "下单失败";
|
||||
} else if (response.contains("您选择场地已被售出")) {
|
||||
return "您选择场地已被售出";
|
||||
} else if (response.contains("此票超过用户每日订场次数")) {
|
||||
return "下单失败";
|
||||
} else if (response.contains("您有一笔待支付的订场订单")) {
|
||||
Thread.sleep(1000);
|
||||
return "您有一笔待支付的订场订单";
|
||||
} else if (response.contains("场地火爆")) {
|
||||
log.info("{}场地火爆下单返回失败暂停1s下单 \n{}", name, response);
|
||||
return "下单失败";
|
||||
} else {
|
||||
log.info("{}订单接口下单返回失败 \n{}", name, response);
|
||||
}
|
||||
return orderId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createOrderWq(ZlbUserInfo zlbUserInfo) throws Exception {
|
||||
String orderId = "";
|
||||
Date date = DateUtils.addDate(new Date(), 3);
|
||||
String day = DateUtils.format(date, DateUtils.ENUM_FORMAT_YMD);
|
||||
String name = zlbUserInfo.getName();
|
||||
String placeName = zlbUserInfo.getPlaceName();
|
||||
String siteTimeName = zlbUserInfo.getSiteTimeName();
|
||||
//获取Token
|
||||
ZlbTokenInfo zlbTokenInfo = zlbTokenInfoService.queryByName(name);
|
||||
String siteOrderDetailsStr = buildSiteOrderList(zlbUserInfo, zlbTokenInfo.getSecretKey(), day);
|
||||
//组装参数加密
|
||||
for (int i = 1; i < 10; i++) {
|
||||
String response = sendOrderWq(siteOrderDetailsStr, zlbTokenInfo.getTokenId());
|
||||
log.info("订单接口返回结果==> \n {}", response);
|
||||
JSONObject jsonObject = JSONObject.parseObject(response);
|
||||
if (jsonObject.getInteger("code") == 200) {
|
||||
jntyzxDingTalkFactory.sendMsg(name + "订单接口下单返回成功请2分钟内付款√√√√√√场地号:" + placeName + "时间:" + siteTimeName);
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
orderId = data.getString("orderId");
|
||||
return orderId;
|
||||
} else if (response.contains("下单失败")) {
|
||||
jntyzxDingTalkFactory.sendMsg(response);
|
||||
return "";
|
||||
} else if (response.contains("场地不在可售时间内")) {
|
||||
jntyzxDingTalkFactory.sendMsg(response);
|
||||
return "";
|
||||
} else if (response.contains("您选择场地已被售出")) {
|
||||
jntyzxDingTalkFactory.sendMsg(name + "订单接口下单返回失败 \n" + response);
|
||||
return "";
|
||||
} else if (response.contains("此票超过用户每日订场次数")) {
|
||||
jntyzxDingTalkFactory.sendMsg(name + "订单接口下单返回失败 \n" + response);
|
||||
return "";
|
||||
} else if (response.contains("您有一笔待支付的订场订单")) {
|
||||
jntyzxDingTalkFactory.sendMsg(name + "订单接口下单返回失败 \n" + response);
|
||||
Thread.sleep(1500);
|
||||
} else if (response.contains("场地火爆")) {
|
||||
log.info("{}场地火爆下单返回失败暂停1s下单 \n{}", name, response);
|
||||
Thread.sleep(200);
|
||||
} else {
|
||||
jntyzxDingTalkFactory.sendMsg(name + "订单接口下单返回失败请检查日志重试第" + i + "次××××××==> \n" + response);
|
||||
}
|
||||
}
|
||||
return orderId;
|
||||
}
|
||||
|
||||
private String sendOrderWq(String siteOrderDetailsStr, String tokenId) throws IOException {
|
||||
OkHttpUtil client = OkHttpUtil.getInstance();
|
||||
Map<String, String> headers = getHeaders(tokenId);
|
||||
ZlbOrderWqInfo zlbOrderInfo = new ZlbOrderWqInfo();
|
||||
zlbOrderInfo.setSiteOrderDetailsStr(siteOrderDetailsStr);
|
||||
String jsonString = JSON.toJSONString(zlbOrderInfo);
|
||||
log.info("json:\n {}", jsonString);
|
||||
return client.postJson(ZlbUrlConstants.newOrderUrl, headers, jsonString);
|
||||
}
|
||||
|
||||
private String buildSiteOrderList(ZlbUserInfo zlbUserInfo, String secretKey, String day) throws Exception {
|
||||
//获取配置的场地号
|
||||
log.info("secretKey:{}", secretKey);
|
||||
String placeName = zlbUserInfo.getPlaceName();
|
||||
String siteTimeName = zlbUserInfo.getSiteTimeName();
|
||||
String[] siteTimeNameList = siteTimeName.split(",");
|
||||
LambdaQueryWrapper<ZlbSiteInfo> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(ZlbSiteInfo::getPlaceName, placeName);
|
||||
wrapper.in(ZlbSiteInfo::getDayEffectiveTimes, Arrays.asList(siteTimeNameList));
|
||||
wrapper.eq(ZlbSiteInfo::getBelongDate, day);
|
||||
List<ZlbSiteInfo> zlbSiteInfoList = zlbSiteInfoService.list(wrapper);
|
||||
if (CollectionUtils.isNotEmpty(zlbSiteInfoList)) {
|
||||
List<ZlbOrderWqJson> zlbOrderJsons = new ArrayList<>();
|
||||
for (ZlbSiteInfo zlbSiteInfo : zlbSiteInfoList) {
|
||||
ZlbOrderWqJson zlbOrderJson = new ZlbOrderWqJson();
|
||||
zlbOrderJson.setIssueIds(null);
|
||||
zlbOrderJson.setIssueAmount(0);
|
||||
zlbOrderJson.setCardOrderId(null);
|
||||
zlbOrderJson.setAmount(zlbSiteInfo.getAmount());
|
||||
zlbOrderJson.setBelongDate(zlbSiteInfo.getBelongDate());
|
||||
zlbOrderJson.setDayEffectiveTimes(zlbSiteInfo.getDayEffectiveTimes());
|
||||
zlbOrderJson.setDayOverdueTimes(zlbSiteInfo.getDayOverdueTimes());
|
||||
zlbOrderJson.setPlaceName(zlbSiteInfo.getPlaceName());
|
||||
zlbOrderJson.setSaasTicketId(zlbSiteInfo.getSaasTicketId());
|
||||
zlbOrderJson.setSiteId(zlbSiteInfo.getSiteId());
|
||||
zlbOrderJson.setSiteItemId(zlbSiteInfo.getSiteItemId());
|
||||
zlbOrderJson.setSiteRuleId(zlbSiteInfo.getSiteRuleId());
|
||||
zlbOrderJson.setSiteTicketId(zlbSiteInfo.getSiteTicketId());
|
||||
zlbOrderJson.setPayChannel(2);
|
||||
zlbOrderJsons.add(zlbOrderJson);
|
||||
}
|
||||
String jsonString = com.alibaba.fastjson.JSON.toJSONString(zlbOrderJsons, SerializerFeature.WriteMapNullValue);
|
||||
return AESECBUtils.encrypt(jsonString, secretKey);
|
||||
}
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
private String sendOrder(String siteOrderDetailsStr, String token, OkHttpUtil client) throws Exception {
|
||||
//请求参数以及图片验证码
|
||||
String newOrderJson = buildNewOrder(siteOrderDetailsStr, client);
|
||||
Map<String, String> headers = getHeaders(token);
|
||||
return client.postJson(ZlbUrlConstants.newOrderUrl, headers, newOrderJson);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String buildNewOrder(String siteOrderDetailsStr, OkHttpUtil client) throws IOException {
|
||||
//获取图片验证码
|
||||
String s = client.postJson(ZlbUrlConstants.captchaUrl, null, "{}");
|
||||
//获取验证码轨迹
|
||||
String track = HttpRequest.post(ZlbUrlConstants.getCaptchaUrl).body(s).execute().body();
|
||||
ZlbOrderInfo zlbOrderInfo = JSONObject.parseObject(track, ZlbOrderInfo.class);
|
||||
zlbOrderInfo.setSiteOrderDetailsStr(siteOrderDetailsStr);
|
||||
String jsonString = JSON.toJSONString(zlbOrderInfo);
|
||||
log.info("json:\n {}", jsonString);
|
||||
return jsonString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRedis(String name) {
|
||||
// 定义模糊匹配模式
|
||||
String pattern = ZlbUrlConstants.REDIS_PREFIX + "_*_" + name;
|
||||
// 查找所有匹配的键
|
||||
Set<String> keys = redisTemplate.keys(pattern);
|
||||
// 批量删除
|
||||
if (!keys.isEmpty()) {
|
||||
redisTemplate.delete(keys);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void installRedis(String name) {
|
||||
String redisKey = ZlbUrlConstants.REDIS_PREFIX + "_" + 123456 + "_" + name;
|
||||
redisTemplate.opsForValue().set(redisKey, name);
|
||||
redisTemplate.expire(redisKey, 1234, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
public static volatile boolean running = true;
|
||||
|
||||
@Override
|
||||
public void jianlou(String name, String day, long time) throws Exception {
|
||||
jntyzxDingTalkFactory.sendMsg(name + "自定义捡漏开始捡漏时间:" + day + " 捡漏人:" + name + " 捡漏间隔:" + time + "ms");
|
||||
//获取Token
|
||||
ZlbTokenInfo zlbTokenInfo = zlbTokenInfoService.queryByName(name);
|
||||
String tokenId = zlbTokenInfo.getTokenId();
|
||||
//代理ip
|
||||
OkHttpUtil client = OkHttpUtil.getInstance();
|
||||
String secretKey = getKey(tokenId, client);
|
||||
if ("未登录".equals(secretKey)) {
|
||||
jntyzxDingTalkFactory.sendMsg(name + "未登录请检查登录信息");
|
||||
return;
|
||||
}
|
||||
log.info("开始捡漏:{}", name);
|
||||
String siteOrderDetailsStr = String.format(ZlbUrlConstants.siteStr, day);
|
||||
String reEncrypted = AESECBUtils.encrypt(siteOrderDetailsStr, secretKey);
|
||||
ZlbSiteRequest zlbSiteRequest = new ZlbSiteRequest();
|
||||
zlbSiteRequest.setDataStr(reEncrypted);
|
||||
String jsonString = JSON.toJSONString(zlbSiteRequest);
|
||||
//请求场地信息
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("token", tokenId);
|
||||
int count = 0;
|
||||
long startTime = System.currentTimeMillis();
|
||||
// 可重用对象
|
||||
JSONObject jsonObject = null;
|
||||
List<ZlbSiteInfo> zlbSiteInfos = null;
|
||||
running = true;
|
||||
while (running) {
|
||||
try {
|
||||
String siteInfo = client.postJson(ZlbUrlConstants.getSiteInfoUrl, headers, jsonString);
|
||||
if (StringUtils.isEmpty(siteInfo)) {
|
||||
return;
|
||||
}
|
||||
// log.info("请求场地返回信息: \n {}", siteInfo);
|
||||
jsonObject = JSONObject.parseObject(siteInfo);
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
String listString = data.getString("list");
|
||||
zlbSiteInfos = JSONArray.parseArray(listString, ZlbSiteInfo.class);
|
||||
for (ZlbSiteInfo zlbSiteInfo : zlbSiteInfos) {
|
||||
Integer ticketType = zlbSiteInfo.getTicketType();
|
||||
if (ticketType == 1) {//代表可以抢的场地号
|
||||
jntyzxDingTalkFactory.sendMsg(day + "ZLb捡漏发现场地:" + zlbSiteInfo.getPlaceName() + "时间点:" + zlbSiteInfo.getDayEffectiveTimes());
|
||||
ZlbOrderJson zlbOrderJson = new ZlbOrderJson();
|
||||
zlbOrderJson.setAmount(zlbSiteInfo.getAmount());
|
||||
zlbOrderJson.setBelongDate(zlbSiteInfo.getBelongDate());
|
||||
zlbOrderJson.setDayEffectiveTimes(zlbSiteInfo.getDayEffectiveTimes());
|
||||
zlbOrderJson.setDayOverdueTimes(zlbSiteInfo.getDayOverdueTimes());
|
||||
zlbOrderJson.setPlaceName(zlbSiteInfo.getPlaceName());
|
||||
zlbOrderJson.setSiteId(zlbSiteInfo.getSiteId());
|
||||
zlbOrderJson.setSiteItemId(zlbSiteInfo.getSiteItemId());
|
||||
zlbOrderJson.setSiteRuleId(zlbSiteInfo.getSiteRuleId());
|
||||
zlbOrderJson.setSiteTicketId(zlbSiteInfo.getSiteTicketId());
|
||||
zlbOrderJson.setPayChannel(2);
|
||||
List<ZlbOrderJson> zlbOrderJsons = new ArrayList<>();
|
||||
zlbOrderJsons.add(zlbOrderJson);
|
||||
String jsonStr = JSON.toJSONString(zlbOrderJsons);
|
||||
String encrypt = AESECBUtils.encrypt(jsonStr, secretKey);
|
||||
//拿到请求参数准备发请求
|
||||
String response = sendPost(client, headers, encrypt);
|
||||
log.info("请求参数: \n {}", jsonStr);
|
||||
JSONObject jsonObject22 = JSONObject.parseObject(response);
|
||||
if (jsonObject22.getInteger("code") == 200) {
|
||||
jntyzxDingTalkFactory.sendMsg(name + "ZLb捡漏场地成功请及时付款" + zlbSiteInfo.getPlaceName() + "时间:" + zlbSiteInfo.getDayEffectiveTimes());
|
||||
JSONObject data1 = jsonObject22.getJSONObject("data");
|
||||
String orderId = data1.getString("orderId");
|
||||
log.info("{}订单{}创建成功", name, orderId);
|
||||
String redisKey = ZlbUrlConstants.REDIS_PREFIX + "_" + orderId + "_" + name;
|
||||
redisTemplate.opsForValue().set(redisKey, name);
|
||||
redisTemplate.expire(redisKey, 120, TimeUnit.SECONDS);
|
||||
running = false;
|
||||
} else {
|
||||
jntyzxDingTalkFactory.sendMsg(name + "ZLb捡漏场地失败请查看日志" + response);
|
||||
}
|
||||
}
|
||||
}
|
||||
count++;
|
||||
if (count % 30 == 0) {
|
||||
long duration = System.currentTimeMillis() - startTime;
|
||||
log.info("监控循环性能 已访问接口次数:{} - 平均每次循环耗时: {}ms", count, duration / 30);
|
||||
startTime = System.currentTimeMillis();
|
||||
}
|
||||
//休息5s
|
||||
Thread.sleep(time);
|
||||
} catch (Exception e) {
|
||||
log.error("请求场地信息异常:{}", e.getMessage());
|
||||
jntyzxDingTalkFactory.sendMsg(name + "ZLb自定义捡漏异常请查看日志");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
log.info("捡漏结束");
|
||||
jntyzxDingTalkFactory.sendMsg("自定义捡漏结束");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refundOrder(String refundName, String day) throws Exception {
|
||||
//找到退款人的token
|
||||
ZlbTokenInfo zlbTokenInfo = zlbTokenInfoService.getOne(new LambdaQueryWrapper<ZlbTokenInfo>().eq(ZlbTokenInfo::getName, refundName));
|
||||
if (zlbTokenInfo == null) {
|
||||
jntyzxDingTalkFactory.sendMsg("退款失败,请检查是否录入退款人登录信息-->" + refundName);
|
||||
}
|
||||
OkHttpUtil client = OkHttpUtil.getInstance();
|
||||
//获取退款人的订单列表
|
||||
String s = client.postJson(ZlbUrlConstants.getOrderInfoUrl, getHeaders(zlbTokenInfo.getTokenId()), "{\"curPage\":1,\"maxPage\":10,\"state\":2,\"type\":2}");
|
||||
log.info("{}订单列表==> \n {}", refundName, s);
|
||||
//获取当前日期下的orderId
|
||||
JSONObject jsonObject = JSONObject.parseObject(s);
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
if (data.getInteger("total").equals(0)) {
|
||||
jntyzxDingTalkFactory.sendMsg("退款失败,请检查是否存在待使用订单-->" + refundName);
|
||||
return;
|
||||
}
|
||||
JSONArray list = data.getJSONArray("list");
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
JSONObject jsonObject1 = list.getJSONObject(i);
|
||||
String orderId = jsonObject1.getString("orderId");
|
||||
Integer stadiumId = jsonObject1.getInteger("stadiumId");
|
||||
String validity = jsonObject1.getString("validity");
|
||||
log.info("stadiumId:{} ,validity:{},orderId:{}", stadiumId, validity, orderId);
|
||||
if (stadiumId.equals(49) && validity.contains(day)) {
|
||||
//拿到订单详情
|
||||
String orderDetailStr = client.postJson(String.format(ZlbUrlConstants.getOrderDetailUrl, orderId), getHeaders(zlbTokenInfo.getTokenId()), "{}");
|
||||
log.info("{}订单详情==> \n {}", orderId, orderDetailStr);
|
||||
JSONObject jsonObject2 = JSONObject.parseObject(orderDetailStr);
|
||||
JSONObject data1 = jsonObject2.getJSONObject("data");
|
||||
JSONArray ticketInfos = data1.getJSONArray("ticketInfos");
|
||||
for (int j = 0; j < ticketInfos.size(); j++) {
|
||||
JSONObject ticketInfo = ticketInfos.getJSONObject(j);
|
||||
String detailOrderId = ticketInfo.getString("detailOrderId");
|
||||
//取消订单
|
||||
String cancelOrder = client.postJson(ZlbUrlConstants.getOrderRefundUrl, getHeaders(zlbTokenInfo.getTokenId()), String.format(ZlbUrlConstants.refundStr, orderId, detailOrderId));
|
||||
log.info("{}退款订单==> \n {}", refundName, cancelOrder);
|
||||
if (cancelOrder.contains("退款成功")) {
|
||||
jntyzxDingTalkFactory.sendMsg(refundName + "退款成功");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelOrder(String cancelName, String day) throws Exception {
|
||||
//找到取消人的token
|
||||
ZlbTokenInfo zlbTokenInfo = zlbTokenInfoService.getOne(new LambdaQueryWrapper<ZlbTokenInfo>().eq(ZlbTokenInfo::getName, cancelName));
|
||||
if (zlbTokenInfo == null) {
|
||||
jntyzxDingTalkFactory.sendMsg("取消失败,请检查是否录入取消人登录信息-->" + cancelName);
|
||||
}
|
||||
OkHttpUtil client = OkHttpUtil.getInstance();
|
||||
//获取取消人的订单列表
|
||||
String s = client.postJson(ZlbUrlConstants.getOrderInfoUrl, getHeaders(zlbTokenInfo.getTokenId()), "{\"curPage\":1,\"maxPage\":10,\"state\":1,\"type\":2}");
|
||||
log.info("{}订单列表==> \n {}", cancelName, s);
|
||||
//获取当前日期下的orderId
|
||||
JSONObject jsonObject = JSONObject.parseObject(s);
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
if (data.getInteger("total").equals(0)) {
|
||||
jntyzxDingTalkFactory.sendMsg("取消失败,请检查是否存在待使用订单-->" + cancelName);
|
||||
return;
|
||||
}
|
||||
JSONArray list = data.getJSONArray("list");
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
JSONObject jsonObject1 = list.getJSONObject(i);
|
||||
String orderId = jsonObject1.getString("orderId");
|
||||
Integer stadiumId = jsonObject1.getInteger("stadiumId");
|
||||
String validity = jsonObject1.getString("validity");
|
||||
log.info("stadiumId:{} ,validity:{},orderId:{}", stadiumId, validity, orderId);
|
||||
if (stadiumId.equals(49) && validity.contains(day)) {
|
||||
//取消订单,并直接删除redis相关信息
|
||||
String cancelOrder = client.postJson(ZlbUrlConstants.getOrderCancelUrl, getHeaders(zlbTokenInfo.getTokenId()), String.format(ZlbUrlConstants.cancelStr, orderId));
|
||||
deleteRedis(orderId);
|
||||
log.info("{}取消订单==> \n {}", cancelName, cancelOrder);
|
||||
if (cancelOrder.contains("取消成功")) {
|
||||
jntyzxDingTalkFactory.sendMsg(cancelName + "取消成功");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String sendPost(OkHttpUtil client, Map<String, String> headers, String encrypt) throws IOException {
|
||||
String newOrderJson = buildNewOrder(encrypt, client);
|
||||
String response = null;
|
||||
try {
|
||||
response = client.postJson(ZlbUrlConstants.newOrderUrl, headers, newOrderJson);
|
||||
log.info("抢场地返回信息: \n {}", response);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testJs(String token, String name) throws IOException {
|
||||
log.info("获取到name:{},token:{}", name, token);
|
||||
LambdaQueryWrapper<ZlbTokenInfo> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(ZlbTokenInfo::getName, name);
|
||||
ZlbTokenInfo tokenInfo = zlbTokenInfoService.getOne(wrapper);
|
||||
if (tokenInfo != null) {
|
||||
tokenInfo.setTokenId(token);
|
||||
tokenInfo.setUpdatedDate(new Date());
|
||||
zlbTokenInfoService.update(tokenInfo, wrapper);
|
||||
jntyzxDingTalkFactory.sendMsg(name + "更新token为" + token);
|
||||
} else {
|
||||
jntyzxDingTalkFactory.sendMsg(name + "更新token失败没有该用户-->" + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.xiang.service.module.jntyzx.zlb.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbSiteInfo;
|
||||
|
||||
/**
|
||||
* @author a123
|
||||
* @description 针对表【zlb_site_info】的数据库操作Service
|
||||
* @createDate 2025-06-19 23:32:29
|
||||
*/
|
||||
public interface ZlbSiteInfoService extends IService<ZlbSiteInfo> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.xiang.service.module.jntyzx.zlb.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xiang.common.mapper.ZlbSiteInfoMapper;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbSiteInfo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author a123
|
||||
* @description 针对表【zlb_site_info】的数据库操作Service实现
|
||||
* @createDate 2025-06-19 23:32:29
|
||||
*/
|
||||
@Service
|
||||
public class ZlbSiteInfoServiceImpl extends ServiceImpl<ZlbSiteInfoMapper, ZlbSiteInfo>
|
||||
implements ZlbSiteInfoService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.xiang.service.module.jntyzx.zlb.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbTokenInfo;
|
||||
|
||||
/**
|
||||
* @author a123
|
||||
* @description 针对表【zlb_token_info】的数据库操作Service
|
||||
* @createDate 2025-06-20 23:51:24
|
||||
*/
|
||||
public interface ZlbTokenInfoService extends IService<ZlbTokenInfo> {
|
||||
|
||||
ZlbTokenInfo queryByName(String name);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.xiang.service.module.jntyzx.zlb.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xiang.common.mapper.ZlbTokenInfoMapper;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbTokenInfo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author a123
|
||||
* @description 针对表【zlb_token_info】的数据库操作Service实现
|
||||
* @createDate 2025-06-20 23:51:24
|
||||
*/
|
||||
@Service
|
||||
public class ZlbTokenInfoServiceImpl extends ServiceImpl<ZlbTokenInfoMapper, ZlbTokenInfo>
|
||||
implements ZlbTokenInfoService {
|
||||
|
||||
@Override
|
||||
public ZlbTokenInfo queryByName(String name) {
|
||||
LambdaQueryWrapper<ZlbTokenInfo> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(ZlbTokenInfo::getName, name);
|
||||
return this.getOne(wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.xiang.service.module.jntyzx.zlb.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbUserInfo;
|
||||
|
||||
public interface ZlbUserInfoService extends IService<ZlbUserInfo> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xiang.service.module.jntyzx.zlb.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xiang.common.mapper.ZlbUserInfoMapper;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbUserInfo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class ZlbUserInfoServiceImpl extends ServiceImpl<ZlbUserInfoMapper, ZlbUserInfo>
|
||||
implements ZlbUserInfoService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user