订单同步逻辑
This commit is contained in:
parent
0e38ab0bb6
commit
74b9f93218
@ -1,5 +1,7 @@
|
||||
package com.syzb.business.service;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
@ -12,6 +14,9 @@ import org.springframework.stereotype.Service;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -26,7 +31,9 @@ public class BusinessApiService {
|
||||
|
||||
private String getUserUrl = "/common/getUserByToken";
|
||||
|
||||
private String getUserModuleListUrl = "/user/getUserModuleList";
|
||||
private String getModuleListUrl = "/user/getUserModuleList";
|
||||
|
||||
private String getOrderListUrl = "/order/getAllBatchOrderListByPage";
|
||||
|
||||
private String authorizationDeptId = "16";
|
||||
|
||||
@ -42,7 +49,7 @@ public class BusinessApiService {
|
||||
|
||||
private static final int TOKEN_ERROR_CODE = 401;
|
||||
|
||||
public BusinessLoginVO loginByUserName(String userName, String password) {
|
||||
public BusinessLoginVO login(String userName, String password) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("username", userName);
|
||||
params.put("password", sha512(password));
|
||||
@ -50,17 +57,44 @@ public class BusinessApiService {
|
||||
return vo.getData();
|
||||
}
|
||||
|
||||
public BusinessUserVO getUserByToken(String token) {
|
||||
public BusinessUserVO getUser(String token) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("token", token);
|
||||
BusinessUserRspVO vo = post(getUserUrl, params, BusinessUserRspVO.class);
|
||||
return vo.getData();
|
||||
}
|
||||
|
||||
public List<BusinessModuleVO> getUserModuleList(String userId) {
|
||||
public List<BusinessModuleVO> getModuleList(String userId) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("userId", userId);
|
||||
BusinessModuleRspVO vo = post(getUserModuleListUrl, params, BusinessModuleRspVO.class);
|
||||
BusinessModuleRspVO vo = post(getModuleListUrl, params, BusinessModuleRspVO.class);
|
||||
return vo.getData();
|
||||
}
|
||||
|
||||
public List<BusinessOrderVO> getOrderList(LocalDateTime startTime, LocalDateTime endTime) {
|
||||
List<BusinessOrderVO> result = new ArrayList<>();
|
||||
String startTimeStr = LocalDateTimeUtil.format(startTime, DatePattern.NORM_DATETIME_PATTERN);
|
||||
String endTimeStr = LocalDateTimeUtil.format(endTime, DatePattern.NORM_DATETIME_PATTERN);
|
||||
Integer currentPage = 1;
|
||||
Integer pageSize = 100;
|
||||
while (true) {
|
||||
BusinessOrderExtVO extVO = getOrderList(startTimeStr, endTimeStr, currentPage, pageSize);
|
||||
result.addAll(extVO.getData());
|
||||
if (extVO.getData().size() < pageSize || result.size() >= extVO.getTotal()) {
|
||||
break;
|
||||
}
|
||||
currentPage++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public BusinessOrderExtVO getOrderList(String startTime, String endTime, Integer currentPage, Integer pageSize) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("currentPage", currentPage);
|
||||
params.put("pageSize", pageSize);
|
||||
params.put("updateStartTime", startTime);
|
||||
params.put("updateEndTime", endTime);
|
||||
BusinessOrderRspVO vo = post(getOrderListUrl, params, BusinessOrderRspVO.class);
|
||||
return vo.getData();
|
||||
}
|
||||
|
||||
@ -68,10 +102,12 @@ public class BusinessApiService {
|
||||
BusinessApiService service = new BusinessApiService();
|
||||
// BusinessLoginVO loginVO = service.loginByUserName("sz545138", "Abc@123");
|
||||
// String token = loginVO.getToken();
|
||||
String token = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI1NDUxMzgiLCJpYXQiOjE3Mzk5NTcxMjYsImV4cCI6MTczOTk2MDcyNn0.02FnOeW7RnIeI7sqwTTw0H9NPj03iFRAkr9PPXwpaDMgRTK2v7krDqAYa6dSIkuGx8wnKWPp-kcA4Ajr_MLjdw";
|
||||
BusinessUserVO userVO = service.getUserByToken(token);
|
||||
System.out.println(JSONUtil.toJsonStr(userVO));
|
||||
service.getUserModuleList(userVO.getUserId().toString());
|
||||
// String token = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI1NDUxMzgiLCJpYXQiOjE3Mzk5NTcxMjYsImV4cCI6MTczOTk2MDcyNn0.02FnOeW7RnIeI7sqwTTw0H9NPj03iFRAkr9PPXwpaDMgRTK2v7krDqAYa6dSIkuGx8wnKWPp-kcA4Ajr_MLjdw";
|
||||
// BusinessUserVO userVO = service.getUser(token);
|
||||
// System.out.println(JSONUtil.toJsonStr(userVO));
|
||||
// service.getModuleList(userVO.getUserId().toString());
|
||||
List<BusinessOrderVO> orderList = service.getOrderList(LocalDate.now().withDayOfYear(1).atStartOfDay(), LocalDateTime.now());
|
||||
System.out.println(JSONUtil.toJsonStr(orderList));
|
||||
}
|
||||
|
||||
private <T extends BusinessVO> T post(String url, Map<String, Object> params, Class<T> type) {
|
||||
|
||||
46
src/main/java/com/syzb/business/vo/BusinessOrderExtVO.java
Normal file
46
src/main/java/com/syzb/business/vo/BusinessOrderExtVO.java
Normal file
@ -0,0 +1,46 @@
|
||||
package com.syzb.business.vo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BusinessOrderExtVO {
|
||||
|
||||
private Integer currentPage;
|
||||
|
||||
private Integer pageSize;
|
||||
|
||||
private Integer total;
|
||||
|
||||
private List<BusinessOrderVO> data;
|
||||
|
||||
public Integer getCurrentPage() {
|
||||
return currentPage;
|
||||
}
|
||||
|
||||
public void setCurrentPage(Integer currentPage) {
|
||||
this.currentPage = currentPage;
|
||||
}
|
||||
|
||||
public Integer getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public void setPageSize(Integer pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
public Integer getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(Integer total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public List<BusinessOrderVO> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(List<BusinessOrderVO> data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
14
src/main/java/com/syzb/business/vo/BusinessOrderRspVO.java
Normal file
14
src/main/java/com/syzb/business/vo/BusinessOrderRspVO.java
Normal file
@ -0,0 +1,14 @@
|
||||
package com.syzb.business.vo;
|
||||
|
||||
public class BusinessOrderRspVO extends BusinessVO {
|
||||
|
||||
private BusinessOrderExtVO data;
|
||||
|
||||
public BusinessOrderExtVO getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(BusinessOrderExtVO data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
338
src/main/java/com/syzb/business/vo/BusinessOrderVO.java
Normal file
338
src/main/java/com/syzb/business/vo/BusinessOrderVO.java
Normal file
@ -0,0 +1,338 @@
|
||||
package com.syzb.business.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class BusinessOrderVO {
|
||||
|
||||
@ApiModelProperty("订单号")
|
||||
private Integer orderId;
|
||||
|
||||
@ApiModelProperty("产品名称")
|
||||
private String productName;
|
||||
|
||||
@ApiModelProperty("订购天数")
|
||||
private Integer orderDay;
|
||||
|
||||
@ApiModelProperty("当前价格")
|
||||
private BigDecimal currentPrice;
|
||||
|
||||
@ApiModelProperty("订单状态 180:新订单 200:已支付 220:已开通 205:已升级 90:已退款 80:已过期 60:已关闭 50:已暂停")
|
||||
private Integer orderState;
|
||||
|
||||
@ApiModelProperty("订单原价")
|
||||
private BigDecimal originalPrice;
|
||||
|
||||
@ApiModelProperty("开通状态 0:未开通 1:已开通")
|
||||
private Integer isOpen;
|
||||
|
||||
@ApiModelProperty("到账金额(多笔付款合计)")
|
||||
private BigDecimal receivedAmount;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private String createTime;
|
||||
|
||||
@ApiModelProperty("用户编号")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty("手机号(脱敏)")
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty("手机号(无规则的唯一键)")
|
||||
private String umId;
|
||||
|
||||
@ApiModelProperty("订单批次号")
|
||||
private String batchId;
|
||||
|
||||
@ApiModelProperty("产品的唯一ID")
|
||||
private String sku;
|
||||
|
||||
@ApiModelProperty("渠道号")
|
||||
private Integer channel;
|
||||
|
||||
@ApiModelProperty("部门ID")
|
||||
private Integer departmentId;
|
||||
|
||||
@ApiModelProperty("开通时间")
|
||||
private String openTime;
|
||||
|
||||
@ApiModelProperty("暂停时间")
|
||||
private String suspendTime;
|
||||
|
||||
@ApiModelProperty("暂停原因")
|
||||
private String suspendRemark;
|
||||
|
||||
@ApiModelProperty("剩余天数")
|
||||
private Integer remainingDay;
|
||||
|
||||
@ApiModelProperty("到账时间")
|
||||
private String receivedAmountTime;
|
||||
|
||||
@ApiModelProperty("终止类型 1:升级 2:退款 3:作废 4:过期")
|
||||
private Integer stopType;
|
||||
|
||||
@ApiModelProperty("终止时间")
|
||||
private String stopTime;
|
||||
|
||||
@ApiModelProperty("下单时间")
|
||||
private String orderTime;
|
||||
|
||||
@ApiModelProperty("附加信息")
|
||||
private String extInfo;
|
||||
|
||||
@ApiModelProperty("订单备注:可以填写客户昵称、备注作为区分")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private String updateTime;
|
||||
|
||||
@ApiModelProperty("活动名称")
|
||||
private String activityName;
|
||||
|
||||
@ApiModelProperty("是否有合同")
|
||||
private Boolean hasPdf;
|
||||
|
||||
@ApiModelProperty("是否可以签约")
|
||||
private Boolean canSign;
|
||||
|
||||
public Integer getOrderId() {
|
||||
return orderId;
|
||||
}
|
||||
|
||||
public void setOrderId(Integer orderId) {
|
||||
this.orderId = orderId;
|
||||
}
|
||||
|
||||
public String getProductName() {
|
||||
return productName;
|
||||
}
|
||||
|
||||
public void setProductName(String productName) {
|
||||
this.productName = productName;
|
||||
}
|
||||
|
||||
public Integer getOrderDay() {
|
||||
return orderDay;
|
||||
}
|
||||
|
||||
public void setOrderDay(Integer orderDay) {
|
||||
this.orderDay = orderDay;
|
||||
}
|
||||
|
||||
public BigDecimal getCurrentPrice() {
|
||||
return currentPrice;
|
||||
}
|
||||
|
||||
public void setCurrentPrice(BigDecimal currentPrice) {
|
||||
this.currentPrice = currentPrice;
|
||||
}
|
||||
|
||||
public Integer getOrderState() {
|
||||
return orderState;
|
||||
}
|
||||
|
||||
public void setOrderState(Integer orderState) {
|
||||
this.orderState = orderState;
|
||||
}
|
||||
|
||||
public BigDecimal getOriginalPrice() {
|
||||
return originalPrice;
|
||||
}
|
||||
|
||||
public void setOriginalPrice(BigDecimal originalPrice) {
|
||||
this.originalPrice = originalPrice;
|
||||
}
|
||||
|
||||
public Integer getIsOpen() {
|
||||
return isOpen;
|
||||
}
|
||||
|
||||
public void setIsOpen(Integer isOpen) {
|
||||
this.isOpen = isOpen;
|
||||
}
|
||||
|
||||
public BigDecimal getReceivedAmount() {
|
||||
return receivedAmount;
|
||||
}
|
||||
|
||||
public void setReceivedAmount(BigDecimal receivedAmount) {
|
||||
this.receivedAmount = receivedAmount;
|
||||
}
|
||||
|
||||
public String getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(String createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public String getUmId() {
|
||||
return umId;
|
||||
}
|
||||
|
||||
public void setUmId(String umId) {
|
||||
this.umId = umId;
|
||||
}
|
||||
|
||||
public String getBatchId() {
|
||||
return batchId;
|
||||
}
|
||||
|
||||
public void setBatchId(String batchId) {
|
||||
this.batchId = batchId;
|
||||
}
|
||||
|
||||
public String getSku() {
|
||||
return sku;
|
||||
}
|
||||
|
||||
public void setSku(String sku) {
|
||||
this.sku = sku;
|
||||
}
|
||||
|
||||
public Integer getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
public void setChannel(Integer channel) {
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
public Integer getDepartmentId() {
|
||||
return departmentId;
|
||||
}
|
||||
|
||||
public void setDepartmentId(Integer departmentId) {
|
||||
this.departmentId = departmentId;
|
||||
}
|
||||
|
||||
public String getOpenTime() {
|
||||
return openTime;
|
||||
}
|
||||
|
||||
public void setOpenTime(String openTime) {
|
||||
this.openTime = openTime;
|
||||
}
|
||||
|
||||
public String getSuspendTime() {
|
||||
return suspendTime;
|
||||
}
|
||||
|
||||
public void setSuspendTime(String suspendTime) {
|
||||
this.suspendTime = suspendTime;
|
||||
}
|
||||
|
||||
public String getSuspendRemark() {
|
||||
return suspendRemark;
|
||||
}
|
||||
|
||||
public void setSuspendRemark(String suspendRemark) {
|
||||
this.suspendRemark = suspendRemark;
|
||||
}
|
||||
|
||||
public Integer getRemainingDay() {
|
||||
return remainingDay;
|
||||
}
|
||||
|
||||
public void setRemainingDay(Integer remainingDay) {
|
||||
this.remainingDay = remainingDay;
|
||||
}
|
||||
|
||||
public String getReceivedAmountTime() {
|
||||
return receivedAmountTime;
|
||||
}
|
||||
|
||||
public void setReceivedAmountTime(String receivedAmountTime) {
|
||||
this.receivedAmountTime = receivedAmountTime;
|
||||
}
|
||||
|
||||
public Integer getStopType() {
|
||||
return stopType;
|
||||
}
|
||||
|
||||
public void setStopType(Integer stopType) {
|
||||
this.stopType = stopType;
|
||||
}
|
||||
|
||||
public String getStopTime() {
|
||||
return stopTime;
|
||||
}
|
||||
|
||||
public void setStopTime(String stopTime) {
|
||||
this.stopTime = stopTime;
|
||||
}
|
||||
|
||||
public String getOrderTime() {
|
||||
return orderTime;
|
||||
}
|
||||
|
||||
public void setOrderTime(String orderTime) {
|
||||
this.orderTime = orderTime;
|
||||
}
|
||||
|
||||
public String getExtInfo() {
|
||||
return extInfo;
|
||||
}
|
||||
|
||||
public void setExtInfo(String extInfo) {
|
||||
this.extInfo = extInfo;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(String updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public String getActivityName() {
|
||||
return activityName;
|
||||
}
|
||||
|
||||
public void setActivityName(String activityName) {
|
||||
this.activityName = activityName;
|
||||
}
|
||||
|
||||
public Boolean getHasPdf() {
|
||||
return hasPdf;
|
||||
}
|
||||
|
||||
public void setHasPdf(Boolean hasPdf) {
|
||||
this.hasPdf = hasPdf;
|
||||
}
|
||||
|
||||
public Boolean getCanSign() {
|
||||
return canSign;
|
||||
}
|
||||
|
||||
public void setCanSign(Boolean canSign) {
|
||||
this.canSign = canSign;
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,5 @@
|
||||
package com.syzb.business.vo;
|
||||
|
||||
// {"id":3326,"userId":545138,"username":"sz545138","state":0,"email":"","mobile":"","umid":"","nickName":"sz545138","headPicUrl":"https://oss.ceniu.sztg.com/CRM2/HeadPic/16.jpg?t=20250215115612","regChannel":0,"regIp":"120.238.224.24","regExt":"","clientExt":"","remark":"","createTime":"2025-02-15 11:56:12","updateTime":"2025-02-15 11:56:56","userBindList":[],"userBusinessChannelList":[],"userModuleList":[]}
|
||||
public class BusinessUserVO {
|
||||
|
||||
private Integer id;
|
||||
|
||||
@ -64,7 +64,7 @@ public class AppUserService {
|
||||
if (StrUtil.isEmpty(userName) || StrUtil.isEmpty(password)) {
|
||||
throw new BizException(ResponseStatus.PARM_ERROR, "用户名或密码为空");
|
||||
}
|
||||
BusinessLoginVO loginVO = businessApiService.loginByUserName(userName, password);
|
||||
BusinessLoginVO loginVO = businessApiService.login(userName, password);
|
||||
token = loginVO.getToken();
|
||||
refreshToken = loginVO.getRefreshToken();
|
||||
} else if (AppLoginType.TOKEN.value.equals(loginType)) {
|
||||
@ -74,7 +74,7 @@ public class AppUserService {
|
||||
} else {
|
||||
throw new BizException(ResponseStatus.PARM_ERROR, "登录方式错误");
|
||||
}
|
||||
BusinessUserVO userVO = businessApiService.getUserByToken(token);
|
||||
BusinessUserVO userVO = businessApiService.getUser(token);
|
||||
AppCUserInfoVO userInfoVO = new AppCUserInfoVO(token, refreshToken, userVO, clientType);
|
||||
FrontUserVO frontUserVO = new FrontUserVO(userInfoVO);
|
||||
if (frontUserVO != null) {
|
||||
@ -118,7 +118,7 @@ public class AppUserService {
|
||||
if (CollUtil.isEmpty(auths)) {
|
||||
return new AuthResultVO(true);
|
||||
}
|
||||
List<BusinessModuleVO> moduleList = businessApiService.getUserModuleList(frontUserVO.getUserId());
|
||||
List<BusinessModuleVO> moduleList = businessApiService.getModuleList(frontUserVO.getUserId());
|
||||
if (CollUtil.isNotEmpty(moduleList)) {
|
||||
String now = LocalDateTimeUtil.format(LocalDateTimeUtil.now(), DatePattern.NORM_DATETIME_PATTERN);
|
||||
for (BusinessModuleVO moduleVO : moduleList) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user