Commit cc28ffaf by 庞善天

Revert "拉取美团订单数据"

This reverts commit fa803f6c.
1 parent fa803f6c
Showing 22 changed files with 0 additions and 776 deletions
......@@ -63,21 +63,5 @@
<groupId>org.oreframework.boot</groupId>
<artifactId>ore-boot-starter-elasticjob</artifactId>
</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>
</project>
\ 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
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
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
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
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
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
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
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
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
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
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
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
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
package cn.com.glsx.dj.staff.request.meituan;
import lombok.Data;
/**
* 报备详情主对象
*/
@Data
public class ReportDetailQueryResult {
private ReportInfo reportInfo;
}
\ 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
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
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
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
  • @wangxw1
    commented
    Master

    你好,我是负责此次代码审查的架构师。你提交的代码主要涉及对“美团订单数据拉取”功能的整体回滚(Revert)。虽然回滚操作本身通常是为了快速止损或撤销误操作,但在本次提交中,我发现了一些涉及安全和稳定性的关键问题,需要你立即关注。

    以下是我的审查意见:

    一、关键问题与优化建议(Top 3)

    1. [高危] 敏感密钥已泄露,单纯回滚无法消除安全隐患

    • 问题描述: 在删除的 MeiTuanOrderConstants.java 文件中,我看到了硬编码的 accessKey ("F6TZVPM1XEDE-TK") 和 secretKey ("J2LoHiu8O26vDxkwsVWzRw==")。虽然本次提交删除了该文件,但这些密钥已经存在于 Git 的历史提交记录中(即被回滚的那个 Commit)。
    • 影响分析: Git 历史是永久保留的,任何有仓库访问权限的人(或一旦仓库被镜像/泄露)都可以从历史记录中恢复这些密钥。这意味着你的美团企业版接口权限实际上已经处于暴露状态,单纯的代码删除(Revert)不能修复此安全漏洞。
    • 优化建议:
      1. 立即作废并轮换密钥:请务必通知运维或相关负责人,登录美团开放平台重置/重新生成新的 AccessKey 和 SecretKey。旧密钥必须被视为已泄露。
      2. 配置隔离:未来重新接入时,严禁将密钥硬编码在 Java 类中。应使用配置中心(如 Nacos, Apollo)或环境变量注入,并在代码中使用 @Value 或 @ConfigurationProperties 读取。

    2. [风险] 移除基础依赖可能导致由于传递依赖缺失引发的运行时异常

    • 问题描述: 在 pom.xml 中,你移除了 httpclient (4.5.4) 和 httpcore (4.4.7)。
    • 影响分析: httpclient 是极通用的基础库。虽然你删除了美团相关的业务代码,但项目中其他模块(或第三方 SDK)可能隐式依赖于这两个库。如果父工程(Parent POM)没有管理这两个依赖的版本,或者其他模块依赖于此处显式引入的版本,移除它们可能导致项目启动失败(ClassNotFoundException)或运行时错误。
    • 优化建议:
      • 执行 mvn dependency:tree 检查项目中是否还有其他组件依赖 httpclient。
      • 如果项目基于 Spring Boot,建议由 spring-boot-starter-parent 管理版本,而不是手动指定版本号,除非有特殊兼容性需求。
      • 示例:确认移除后,全量运行一次单元测试或集成测试,确保无“类缺失”报错。

    3. [规范] Revert 提交信息缺乏上下文(Context)

    • 问题描述: 提交信息仅为自动生成的 Revert "拉取美团订单数据" ...。
    • 影响分析: 代码维护需要可追溯性。三个月后,没人会记得为什么要回滚这个功能。是因为功能本身有 Bug?是因为需求取消?还是因为发现了安全漏洞(如上述密钥问题)?缺乏“Why”会让后续维护者困惑。
    • 优化建议: 修改 Commit Message,补充回滚原因。

      • 建议格式:

        Revert "拉取美团订单数据" due to security risk and feature cancellation
        
        Reason:
        1. Removed hardcoded credentials inadvertently committed.
        2. The feature is postponed to Q3.
        
        This reverts commit fa803f6...
        

    二、评分明细

    1. 功能实现的正确性与健壮性(35/40分)

      • 理由:回滚操作本身逻辑是清除代码,这部分是正确的。扣分点在于直接移除 pom.xml 中的基础 HTTP 组件风险较高,未提供证据表明已排查对其他模块的副作用。
    2. 安全性与潜在风险(10/30分)

      • 理由:虽然代码删除了密钥文件(这是对的),但作为资深工程师,必须指出历史泄露问题。此次提交反映出之前的开发过程严重违反安全规范(硬编码密钥),且回滚操作未能闭环处理安全风险(未提及轮换密钥),因此给予较低分以示警示。
    3. 最佳实践与可维护性(15/20分)

      • 理由:代码清理得比较干净(包结构、类文件都删除了),没有残留僵尸代码。扣分点在于 Commit Message 缺乏具体的业务上下文。
    4. 性能与资源利用(5/5分)

      • 理由:删除代码减少了系统包体积和潜在的定时任务资源占用,无性能问题。
    5. 提交信息质量(3/5分)

      • 理由:使用了 Git 自动生成的 Revert 模板,准确但缺乏人工补充的背景信息。

    三、总分

    总分:68分

Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!