Commit fa803f6c by 庞善天

拉取美团订单数据

1 parent 9d29c7a9
Showing 22 changed files with 776 additions and 0 deletions
...@@ -63,5 +63,21 @@ ...@@ -63,5 +63,21 @@
<groupId>org.oreframework.boot</groupId> <groupId>org.oreframework.boot</groupId>
<artifactId>ore-boot-starter-elasticjob</artifactId> <artifactId>ore-boot-starter-elasticjob</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.4</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.7</version>
</dependency>
<dependency>
<groupId>com.meituan.sqt</groupId>
<artifactId>open-platform-sdk</artifactId>
<version>1.0.48</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.staff.constant;
/**
* @Title MeiTuanOrderConstants
* @author pangst
* @date 2026/2/10 10:10
* @version V1.0
**/
public class MeiTuanOrderConstants {
public static final Long entId = 56637L;
public static final String accessKey = "F6TZVPM1XEDE-TK";
public static final String secretKey = "J2LoHiu8O26vDxkwsVWzRw==";
public static final String orderUrl = "https://bep-openapi.meituan.com/api/sqt/open/order/queryList";
public static final String orderDetailUrl = "https://bep-openapi.meituan.com/api/sqt/open/order/queryDetail";
public static final String reportDetailUrl = "https://bep-openapi.meituan.com/api/sqt/open/report/v1/queryDetail";
public static final String realDetailUrl = "https://bep-openapi.meituan.com/api/sqt/open/repast/applyDetail/pageQuery";
public static final String userDetailUrl = "https://bep-openapi.meituan.com/api/sqt/open/staff/batch/query";
public static final String deptUrl = "https://bep-openapi.meituan.com/api/sqt/open/org/batch/query";
public static final String DEFAULT_CREATE_BY = "system";
}
package cn.com.glsx.dj.staff.job;
import cn.com.glsx.dj.staff.request.meituan.MtOrderResult;
import cn.com.glsx.dj.staff.service.common.MeiTuanOrderManager;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import lombok.extern.slf4j.Slf4j;
import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.List;
/**
* @Title: MeiTuanOrderJob
* @Description: 每天凌晨1点定时任务获取前一天的美团订单数据
* @Author pangst
* @Date 2025/02/09
**/
@Service
@Slf4j
@ElasticJobConf(name = "MeiTuanOrderJob", cron = "0 0 1 * * ?", description = "每天凌晨1点定时任务获取前一天的美团订单数据", overwrite = false)
public class MeiTuanOrderJob implements SimpleJob {
@Autowired
private MeiTuanOrderManager meiTuanOrderManager;
@Override
public void execute(ShardingContext shardingContext) {
log.info("每天凌晨1点定时任务获取前一天的美团订单数据开始");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// 获取昨天的时间
LocalDate yesterday = LocalDate.now().minusDays(1);
LocalDateTime dayStart = yesterday.atStartOfDay();
LocalDateTime dayEnd = yesterday.atTime(23, 59, 59);
long minUpdateTime = dayStart.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
long maxUpdateTime = dayEnd.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
try {
List<MtOrderResult> mtOrderResults = meiTuanOrderManager.obtainOrderList(minUpdateTime, maxUpdateTime);
log.info("mtOrderResults Size:{}", mtOrderResults.size());
// todo 帮我入库到 dj_car_life_staff_meituan_order 表里面
} catch (Exception e) {
log.error(e.getMessage(), e);
}
log.info("每天凌晨1点定时任务获取前一天的美团订单数据任务结束");
}
public static void main(String[] args) {
log.info("每天凌晨1点定时任务获取前一天的美团订单数据开始");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// 获取昨天的时间
LocalDate yesterday = LocalDate.now().minusDays(1);
LocalDateTime dayStart = yesterday.atStartOfDay();
LocalDateTime dayEnd = yesterday.atTime(23, 59, 59);
long minUpdateTime = dayStart.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
long maxUpdateTime = dayEnd.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
try {
MeiTuanOrderManager mtMapper = new MeiTuanOrderManager();
List<MtOrderResult> mtOrderResults = mtMapper.obtainOrderList(minUpdateTime, maxUpdateTime);
log.info("mtOrderResults Size:{}", mtOrderResults.size());
} catch (Exception e) {
log.error(e.getMessage(), e);
}
log.info("每天凌晨1点定时任务获取前一天的美团订单数据任务结束");
}
}
package cn.com.glsx.dj.staff.request.meituan;
import lombok.Data;
/**
* 住客信息
*/
@Data
public class ApplyExceedInfo {
private Integer isExceed;
private String exceedAmount;
private String exceedReason;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.staff.request.meituan;
import lombok.Data;
/**
* 酒店住宿详情信息
*/
@Data
public class AptInfo {
private String checkinTime;
private String checkoutTime;
private String actualCheckinTime;
private String lastCancelTime;
private String hotelStar;
private Long brandId;
private String brandName;
private Integer hotelGroupId;
private String hotelGroupName;
private String breakfast;
private String cityName;
private String cityId;
private String provinceName;
private String provinceId;
private Long poiId;
private String poiName;
private String poiAddress;
private Long goodsId;
private String roomName;
private String partnerName;
private String partnerType;
private String hotelRating;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.staff.request.meituan;
import lombok.Data;
/**
* 住客信息
*/
@Data
public class GuestInfo {
private Integer personType;
private Long personId;
private Integer guestType;
private String guestName;
private String guestPhone;
private String guestEmail;
private Boolean isVip;
private Integer roomIndexId;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.staff.request.meituan;
import lombok.Data;
/**
* 酒店订单基础信息
*/
@Data
public class HotelBaseInfo {
private Integer orderStatus;
private String orderAmount;
private Integer invoiceType;
private Boolean isAgreement;
private Boolean isReceptionInvoice;
private Boolean isOverseal;
private Integer hotelPayType;
private String currency;
private String expressAmount;
private Integer roomCount;
private Integer roomNightCount;
private String createTime;
private String modifyTime;
private String riskAmount;
private String avgNightAmount;
private String invoiceSubject;
private Boolean isVip;
private String bookType;
private Integer cancelRuleType;
private String lastTimeCST;
private String bookSucTime;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.staff.request.meituan;
import lombok.Data;
import java.util.List;
/**
* 酒店订单详情主对象
*/
@Data
public class HotelOrderDetail {
private HotelBaseInfo hotelBaseInfo;
private AptInfo aptInfo;
private List<GuestInfo> guestList;
private List<RoomNightInfo> roomNightList;
private List<Object> appealList;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.staff.request.meituan;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author pangst
* @date 2026/02/10 20:22
* @description
*/
@Data
public class MtOrderResult {
/**
* 美团企业版订单ID
*/
private Long sqtBizOrderId;
/**
* 业务原始订单ID
*/
private String origOrderId;
/**
* 支付状态,10:未支付,20:已支付,31:部分退款,32:全额退款
*/
private Integer payStatus;
/**
* 下单员工美团侧员工ID
*/
private Long staffId;
/**
* 员工名称
*/
private String staffName;
/**
* 员工手机号
*/
private String staffPhone;
/**
* 消费城市编码
*/
private String expenseCityId;
/**
* 消费城市名称
*/
private String expenseCityName;
/**
* 订单金额,单位元,精确到小数点后两位
*/
private BigDecimal orderAmount;
/**
* 总支付金额,单位元,精确到小数点后两位
*/
private BigDecimal totalPayAmount;
/**
* 总退款金额,单位元,精确到小数点后两位
*/
private BigDecimal totalRefundAmount;
/**
* 实际支付金额,单位元,精确到小数点后两位
*/
private BigDecimal totalRealAmount;
/**
* 下单时间,格式:yyyy-MM-dd HH:mm:ss
*/
private Date createTime;
/**
* 更新时间,格式:yyyy-MM-dd HH:mm:ss
*/
private Date updateTime;
/**
* 美团企业版用餐申请单号
*/
private String applyNo;
/**
* 美团企业版用餐申请事由
*/
private String realReason;
/**
* 下单场景编码 1-商务宴请 3-商务差旅
*/
private Integer sceneType;
/**
* 下单场景名称
*/
private String sceneTypeName;
/**
* 美团侧部门编码路径 0-128-483
*/
private String orgIdPath;
/**
* 美团侧部门名称路径 美团-XX事业部-XX
*/
private String orgNamePath;
/**
* 美团侧直属部门id
*/
private Long directOrgId;
/**
* 美团侧直属部门名称
*/
private String directOrgName;
/**
* 直属上级美团企业版员工ID
*/
private Long parentStaffId;
/**
* 直属上级美团企业版员工电话
*/
private String parentStaffPhone;
/**
* 店铺id
*/
private Long shopId;
/**
* 店铺名称
*/
private String shopName;
/**
* 店铺地址
*/
private String shopAddress;
/**
* 消费数量:餐饮消费人次、差旅入住天数
*/
private Integer consumeCount;
/**
* 平均消费金额:人均消费金额、平均每天房价 单位:元,精确到小数点后两位
*/
private BigDecimal avgConsumeAmount;
/**
* 餐饮标准 单位:元,精确到小数点后两位
*/
private BigDecimal standardAmount;
/**
* 是否超标 0:未超标,1:超标
*/
private Integer isExceed;
/**
* 超标金额 单位:元,精确到小数点后两位
*/
private BigDecimal exceedAmount;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.staff.request.meituan;
import lombok.Data;
/**
* @author pangst
* @date 2026/02/10 20:22
* @description
*/
@Data
public class OrderOriginInfoResult {
/**
* 支付
*/
private String entPayAmountSum;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.staff.request.meituan;
import lombok.Data;
/**
* @author pangst
* @date 2026/02/10 20:22
* @description
*/
@Data
public class ParentStaffOrderResult {
/**
* 美团企业版订单ID
*/
private Long sqtBizOrderId;
/**
* 下单员工美团侧员工ID
*/
private Long staffId;
/**
* 员工名称
*/
private String staffName;
/**
* 员工手机号
*/
private String staffPhone;
/**
* 直属上级美团企业版员工ID
*/
private Long parentStaffId;
/**
* 直属上级美团企业版员工电话
*/
private String parentStaffPhone;
/**
* 推送内容
*/
private String pushContent;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.staff.request.meituan;
import lombok.Data;
import java.util.Date;
/**
* @author pangst
* @date 2026/02/10 20:22
* @description
*/
@Data
public class PushOrderResult {
/**
* 美团企业版订单ID
*/
private Long sqtBizOrderId;
/**
* 下单员工美团侧员工ID
*/
private Long staffId;
/**
* 员工名称
*/
private String staffName;
/**
* 员工手机号
*/
private String staffPhone;
/**
* 推送对象 1-员工 2-员工上级 3-HR 4-部门总 5-公司总
*/
private Integer pushObject;
/**
* 推送周期:1-按天 2-按月
*/
private Integer pushPeriod;
/**
* 下单时间,格式:yyyy-MM-dd HH:mm:ss
*/
private Date createTime;
/**
* 更新时间,格式:yyyy-MM-dd HH:mm:ss
*/
private Date updateTime;
/**
* 推送内容
*/
private String pushContent;
/**
* 推送状态 0-失败 1-成功
*/
private Integer pushStatus;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.staff.request.meituan;
import com.meituan.sqt.annotation.ApiMeta;
import com.meituan.sqt.request.in.BaseApiRequest;
import com.meituan.sqt.utils.JsonUtil;
import java.util.List;
/**
* @author pangst
* @date 2026/02/10 20:22
* @description
*/
@ApiMeta(
apiName = "用餐申请详情查询接口",
path = "/repast/applyDetail/pageQuery",
connectTimeout = 5000,
socketTimeout = 5000
)
public class RealDetailQueryRequest extends BaseApiRequest<RealDetailQueryResult> {
/**
* 美团企业版申请单号列表
*/
private List<String> applyNoList;
/**
* 员工id
*/
private Long submitStaffId;
/**
* 最小订单支付时间,13位时间戳,需要与最大订单支付时间结合使用,可以实现支付时间的区间查询
*/
private Long minCreatedTime;
/**
* 最大订单支付时间,13位时间戳,需要与最小订单支付时间结合使用,可以实现支付时间的区间查询
*/
private Long maxCreatedTime;
public Long getMinCreatedTime() {
return minCreatedTime;
}
public void setMinCreatedTime(Long minCreatedTime) {
this.minCreatedTime = minCreatedTime;
}
public Long getMaxCreatedTime() {
return maxCreatedTime;
}
public void setMaxCreatedTime(Long maxCreatedTime) {
this.maxCreatedTime = maxCreatedTime;
}
public List<String> getApplyNoList() {
return applyNoList;
}
public void setApplyNoList(List<String> applyNoList) {
this.applyNoList = applyNoList;
}
public Long getSubmitStaffId() {
return submitStaffId;
}
public void setSubmitStaffId(Long submitStaffId) {
this.submitStaffId = submitStaffId;
}
@Override
public RealDetailQueryResult deserializeResponse(String data) {
return JsonUtil.json2Object(data, RealDetailQueryResult.class);
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.staff.request.meituan;
import lombok.Data;
import java.util.List;
/**
* 用餐申请详情主对象
*/
@Data
public class RealDetailQueryResult {
private List<RepastApplyInfo> applyList;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.staff.request.meituan;
import lombok.Data;
/**
* 申请单数据信息
*/
@Data
public class RepastApplyInfo {
private String applyNo;
private String externalApplyNo;
private String reason;
private Integer planPersonCount;
private String predictAmount;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.staff.request.meituan;
import com.meituan.sqt.annotation.ApiMeta;
import com.meituan.sqt.request.in.BaseApiRequest;
import com.meituan.sqt.utils.JsonUtil;
/**
* @author pangst
* @date 2026/02/10 20:22
* @description
*/
@ApiMeta(
apiName = "消费报备详情查询接口",
path = "/report/v1/queryDetail",
connectTimeout = 5000,
socketTimeout = 5000
)
public class ReportDetailQueryRequest extends BaseApiRequest<ReportDetailQueryResult> {
/**
* 商企通订单ID
*/
private Long sqtBizOrderId;
public Long getSqtBizOrderId() {
return sqtBizOrderId;
}
public void setSqtBizOrderId(Long sqtBizOrderId) {
this.sqtBizOrderId = sqtBizOrderId;
}
@Override
public ReportDetailQueryResult deserializeResponse(String data) {
return JsonUtil.json2Object(data, ReportDetailQueryResult.class);
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.staff.request.meituan;
import lombok.Data;
/**
* 报备详情主对象
*/
@Data
public class ReportDetailQueryResult {
private ReportInfo reportInfo;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.staff.request.meituan;
import lombok.Data;
/**
* 住客信息
*/
@Data
public class ReportInfo {
private Integer numOfConsumer;
private String personAvgAmount;
private ApplyExceedInfo applyExceedInfo;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.staff.request.meituan;
import lombok.Data;
/**
* 房晚价格信息
*/
@Data
public class RoomNightInfo {
private String bizDay;
private Integer roomIndexId;
private Integer breakfastNum;
private String roomNightPrice;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.staff.request.meituan;
import lombok.Data;
/**
* @author pangst
* @date 2026/02/10 20:22
* @description
*/
@Data
public class StaffOrderResult {
/**
* 美团企业版订单ID
*/
private Long sqtBizOrderId;
/**
* 下单员工美团侧员工ID
*/
private Long staffId;
/**
* 员工名称
*/
private String staffName;
/**
* 员工手机号
*/
private String staffPhone;
/**
* 直属上级美团企业版员工ID
*/
private Long parentStaffId;
/**
* 直属上级美团企业版员工电话
*/
private String parentStaffPhone;
/**
* 推送内容
*/
private String pushContent;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.staff.request.meituan;
import lombok.Data;
/**
* 住客信息
*/
@Data
public class StaffUniqueMarkInfo {
private Long staffId;
private String staffIdentifier;
}
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!