Compare commits

...

3 Commits

Author SHA1 Message Date
科技小王子 74a7b47a67 refactor(core):优化时间字段处理与日志输出 6 days ago
科技小王子 9229aa4885 refactor(cms): 将LocalDateTime替换为Date类型并调整过期逻辑 6 days ago
科技小王子 1da96e7ff3 ```feat(redis): 微信小程序配置从缓存获取并支持Redis存储 7 days ago
  1. 9
      src/main/java/com/gxwebsoft/cms/entity/CmsWebsite.java
  2. 41
      src/main/java/com/gxwebsoft/cms/service/impl/CmsWebsiteServiceImpl.java
  3. 58
      src/main/java/com/gxwebsoft/cms/service/impl/CmsWebsiteServiceImplHelper.java
  4. 2
      src/main/java/com/gxwebsoft/common/core/constants/RedisConstants.java
  5. 74
      src/main/java/com/gxwebsoft/common/system/controller/WxLoginController.java
  6. 8
      src/main/java/com/gxwebsoft/common/system/mapper/SettingMapper.java
  7. 9
      src/main/java/com/gxwebsoft/common/system/mapper/xml/SettingMapper.xml
  8. 93
      src/main/java/com/gxwebsoft/common/system/service/impl/SettingServiceImpl.java
  9. 2
      src/main/java/com/gxwebsoft/oa/controller/OaAppController.java
  10. 4
      src/main/java/com/gxwebsoft/project/service/impl/ProjectServiceImpl.java
  11. 4
      src/main/java/com/gxwebsoft/shop/entity/ShopDealerApply.java
  12. 2
      src/main/java/com/gxwebsoft/shop/mapper/xml/ShopDealerApplyMapper.xml
  13. 2
      src/main/java/com/gxwebsoft/shop/service/impl/OrderCancelServiceImpl.java
  14. 3
      src/main/resources/application.yml
  15. 60
      src/test/java/com/gxwebsoft/JacksonTest.java

9
src/main/java/com/gxwebsoft/cms/entity/CmsWebsite.java

@ -6,17 +6,16 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.gxwebsoft.common.system.entity.User;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -87,7 +86,7 @@ public class CmsWebsite implements Serializable {
@Schema(description = "服务到期时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime expirationTime;
private Date expirationTime;
@Schema(description = "是否到期")
@TableField(exist = false)
@ -250,11 +249,11 @@ public class CmsWebsite implements Serializable {
@Schema(description = "创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
private Date createTime;
@Schema(description = "修改时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
private Date updateTime;
@Schema(description = "预设字段")
@TableField(exist = false)

41
src/main/java/com/gxwebsoft/cms/service/impl/CmsWebsiteServiceImpl.java

@ -84,11 +84,20 @@ public class CmsWebsiteServiceImpl extends ServiceImpl<CmsWebsiteMapper, CmsWebs
page.setDefaultOrder("create_time desc");
List<CmsWebsite> list = baseMapper.selectPageRel(page, param);
list.forEach(d -> {
LocalDateTime now = LocalDateTime.now();
// 即将过期(一周内过期的)
d.setSoon(d.getExpirationTime().minusDays(30).compareTo(now));
// 是否过期 -1已过期 大于0 未过期
d.setStatus(d.getExpirationTime().compareTo(now));
LocalDateTime now = LocalDateTime.now();
if (d.getExpirationTime() != null) {
// 将Date转换为LocalDateTime进行计算
LocalDateTime expirationTime = d.getExpirationTime().toInstant()
.atZone(java.time.ZoneId.systemDefault())
.toLocalDateTime();
// 即将过期(30天内过期的)
d.setSoon(expirationTime.minusDays(30).compareTo(now));
// 是否过期 -1已过期 大于0 未过期
d.setStatus(expirationTime.compareTo(now));
} else {
d.setSoon(0);
d.setStatus(1);
}
});
return new PageResult<>(list, page.getTotal());
}
@ -115,11 +124,20 @@ public class CmsWebsiteServiceImpl extends ServiceImpl<CmsWebsiteMapper, CmsWebs
page.setDefaultOrder("create_time desc");
List<CmsWebsite> list = baseMapper.selectPageRelAll(page, param);
list.forEach(d -> {
LocalDateTime now = LocalDateTime.now();
// 即将过期(一周内过期的)
d.setSoon(d.getExpirationTime().minusDays(30).compareTo(now));
// 是否过期 -1已过期 大于0 未过期
d.setStatus(d.getExpirationTime().compareTo(now));
LocalDateTime now = LocalDateTime.now();
if (d.getExpirationTime() != null) {
// 将Date转换为LocalDateTime进行计算
LocalDateTime expirationTime = d.getExpirationTime().toInstant()
.atZone(java.time.ZoneId.systemDefault())
.toLocalDateTime();
// 即将过期(30天内过期的)
d.setSoon(expirationTime.minusDays(30).compareTo(now));
// 是否过期 -1已过期 大于0 未过期
d.setStatus(expirationTime.compareTo(now));
} else {
d.setSoon(0);
d.setStatus(1);
}
});
return new PageResult<>(list, page.getTotal());
}
@ -137,7 +155,8 @@ public class CmsWebsiteServiceImpl extends ServiceImpl<CmsWebsiteMapper, CmsWebs
website.setWebsiteType("云·企业官网");
website.setAdminUrl("site.websoft.top");
website.setVersion(10);
website.setExpirationTime(LocalDateTime.now().plusMonths(1));
website.setExpirationTime(java.util.Date.from(LocalDateTime.now().plusMonths(1)
.atZone(java.time.ZoneId.systemDefault()).toInstant()));
website.setUserId(loginUser.getUserId());
website.setDeveloper(loginUser.getNickname());
website.setTenantId(loginUser.getTenantId());

58
src/main/java/com/gxwebsoft/cms/service/impl/CmsWebsiteServiceImplHelper.java

@ -8,6 +8,7 @@ import com.gxwebsoft.shop.vo.ShopVo;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
@ -24,25 +25,30 @@ public class CmsWebsiteServiceImplHelper {
public static void processExpirationTime(CmsWebsite website) {
if (website.getExpirationTime() != null) {
LocalDateTime now = LocalDateTime.now();
LocalDateTime expirationTime = website.getExpirationTime();
// 计算是否即将过期(30天内过期)
LocalDateTime thirtyDaysLater = now.plusDays(30);
website.setSoon(expirationTime.isBefore(thirtyDaysLater) ? 1 : 0);
// 计算是否已过期
website.setExpired(expirationTime.isBefore(now) ? -1 : 1);
// 计算剩余天数
long daysBetween = ChronoUnit.DAYS.between(now, expirationTime);
website.setExpiredDays(daysBetween);
} else {
// 没有过期时间的默认值
website.setSoon(0);
website.setExpired(1);
website.setExpiredDays(0L);
Date expirationTimeDate = website.getExpirationTime();
// 将Date转换为LocalDateTime进行计算
LocalDateTime expirationTime = expirationTimeDate.toInstant()
.atZone(java.time.ZoneId.systemDefault())
.toLocalDateTime();
// 计算是否即将过期(30天内过期)
LocalDateTime thirtyDaysLater = now.plusDays(30);
website.setSoon(expirationTime.isBefore(thirtyDaysLater) ? 1 : 0);
// 计算是否已过期
website.setExpired(expirationTime.isBefore(now) ? -1 : 1);
// 计算剩余天数
long daysBetween = ChronoUnit.DAYS.between(now, expirationTime);
website.setExpiredDays(daysBetween);
} else {
// 没有过期时间的默认值
website.setSoon(0);
website.setExpired(1);
website.setExpiredDays(0L);
}
}
}
/**
* 将实体对象转换为VO对象
@ -63,13 +69,21 @@ public class CmsWebsiteServiceImplHelper {
vo.setRunning(website.getRunning());
vo.setVersion(website.getVersion());
if (website.getCreateTime() != null) {
vo.setCreateTime(website.getCreateTime().format(formatter));
// 将Date转换为LocalDateTime后格式化
LocalDateTime createTime = website.getCreateTime().toInstant()
.atZone(java.time.ZoneId.systemDefault())
.toLocalDateTime();
vo.setCreateTime(createTime.format(formatter));
}
// 时间字段 - 格式化为字符串
// if (website.getExpirationTime() != null) {
// vo.setExpirationTime(website.getExpirationTime().format(formatter));
// }
if (website.getExpirationTime() != null) {
// 将Date转换为LocalDateTime后格式化
LocalDateTime expirationTime = website.getExpirationTime().toInstant()
.atZone(java.time.ZoneId.systemDefault())
.toLocalDateTime();
vo.setExpirationTime(expirationTime.format(formatter));
}
// 过期相关信息
vo.setExpired(website.getExpired());

2
src/main/java/com/gxwebsoft/common/core/constants/RedisConstants.java

@ -24,6 +24,8 @@ public class RedisConstants {
public static final String TEN_ANT_SETTING_KEY = "setting";
// 排行榜Key
public static final String USER_RANKING_BY_APPS_5 = "cache5:userRankingByApps";
// 微信小程序Key
public static final String MP_WX_KEY = "mp-weixin:";

74
src/main/java/com/gxwebsoft/common/system/controller/WxLoginController.java

@ -44,6 +44,7 @@ import java.util.concurrent.TimeUnit;
import static com.gxwebsoft.common.core.constants.PlatformConstants.MP_WEIXIN;
import static com.gxwebsoft.common.core.constants.RedisConstants.ACCESS_TOKEN_KEY;
import static com.gxwebsoft.common.core.constants.RedisConstants.MP_WX_KEY;
@RestController
@RequestMapping("/api/wx-login")
@ -224,8 +225,8 @@ public class WxLoginController extends BaseController {
// 获取openid
private JSONObject getOpenIdByCode(UserParam userParam) {
// 获取微信小程序配置信息
JSONObject setting = settingService.getBySettingKey("mp-weixin", getTenantId());
// 从缓存获取微信小程序配置信息
JSONObject setting = getWxConfigFromCache(getTenantId());
// 获取openId
String apiUrl = "https://api.weixin.qq.com/sns/jscode2session?appid=" + setting.getString("appId") + "&secret=" + setting.getString("appSecret") + "&js_code=" + userParam.getCode() + "&grant_type=authorization_code";
// 执行get请求
@ -282,8 +283,8 @@ public class WxLoginController extends BaseController {
Integer tenantId = getTenantId();
String key = ACCESS_TOKEN_KEY.concat(":").concat(tenantId.toString());
// 使用跨租户方式获取微信小程序配置信息
JSONObject setting = settingService.getBySettingKeyIgnoreTenant("mp-weixin", tenantId);
// 从缓存获取微信小程序配置信息
JSONObject setting = getWxConfigFromCache(tenantId);
if (setting == null) {
throw new BusinessException("请先配置小程序");
}
@ -332,7 +333,7 @@ public class WxLoginController extends BaseController {
// 请求微信接口获取openid
String apiUrl = "https://api.weixin.qq.com/sns/jscode2session";
final HashMap<String, Object> map = new HashMap<>();
final JSONObject setting = settingService.getBySettingKey("mp-weixin", getTenantId());
final JSONObject setting = getWxConfigFromCache(getTenantId());
final String appId = setting.getString("appId");
final String appSecret = setting.getString("appSecret");
map.put("appid", appId);
@ -360,7 +361,7 @@ public class WxLoginController extends BaseController {
String apiUrl = "https://api.weixin.qq.com/sns/jscode2session";
final HashMap<String, Object> map = new HashMap<>();
final JSONObject setting = settingService.getBySettingKey("mp-weixin", getTenantId());
final JSONObject setting = getWxConfigFromCache(getTenantId());
final String appId = setting.getString("appId");
final String appSecret = setting.getString("appSecret");
map.put("appid", appId);
@ -548,9 +549,9 @@ public class WxLoginController extends BaseController {
}
}
// 使用跨租户方式获取微信小程序配置信息
// 从缓存获取微信小程序配置信息
Integer tenantId = getTenantId();
JSONObject setting = settingService.getBySettingKeyIgnoreTenant("mp-weixin", tenantId);
JSONObject setting = getWxConfigFromCache(tenantId);
if (setting == null) {
throw new IOException("请先配置小程序");
}
@ -603,18 +604,20 @@ public class WxLoginController extends BaseController {
result.put("tenantId", tenantId);
try {
// 尝试获取配置
JSONObject setting = settingService.getBySettingKeyIgnoreTenant("mp-weixin", tenantId);
// 尝试从缓存获取配置
JSONObject setting = getWxConfigFromCache(tenantId);
result.put("hasConfig", true);
result.put("config", setting);
result.put("cacheKey", MP_WX_KEY + tenantId);
} catch (Exception e) {
result.put("hasConfig", false);
result.put("error", e.getMessage());
result.put("cacheKey", MP_WX_KEY + tenantId);
// 提供创建配置的建议
Map<String, Object> suggestion = new HashMap<>();
suggestion.put("message", "请在系统设置中创建微信小程序配置");
suggestion.put("configKey", "mp-weixin");
suggestion.put("message", "请在Redis中创建微信小程序配置");
suggestion.put("cacheKey", MP_WX_KEY + tenantId);
suggestion.put("tenantId", tenantId);
suggestion.put("sampleConfig", createSampleWxConfig());
result.put("suggestion", suggestion);
@ -636,23 +639,21 @@ public class WxLoginController extends BaseController {
}
try {
// 创建配置对象
Setting setting = new Setting();
setting.setSettingKey("mp-weixin");
setting.setTenantId(tenantId);
// 直接在Redis中创建配置
String key = MP_WX_KEY + tenantId;
// 创建配置内容
Map<String, String> config = new HashMap<>();
config.put("appId", appId);
config.put("appSecret", appSecret);
setting.setContent(JSON.toJSONString(config));
setting.setComments("微信小程序配置");
setting.setSortNumber(1);
config.put("tenantId", tenantId.toString());
config.put("settingKey", "mp-weixin");
config.put("settingId", "301");
// 保存配置
settingService.save(setting);
// 保存到Redis缓存
redisUtil.set(key, JSON.toJSONString(config));
return success("微信小程序配置创建成功", setting);
return success("微信小程序配置创建成功", config);
} catch (Exception e) {
return fail("创建配置失败: " + e.getMessage(), null);
}
@ -691,6 +692,24 @@ public class WxLoginController extends BaseController {
}
}
/**
* 从Redis缓存中获取微信小程序配置
* @param tenantId 租户ID
* @return 微信配置信息
*/
private JSONObject getWxConfigFromCache(Integer tenantId) {
String key = MP_WX_KEY + tenantId;
String cacheValue = redisUtil.get(key);
if (StrUtil.isBlank(cacheValue)) {
throw new BusinessException("未找到微信小程序配置,请检查缓存key: " + key);
}
try {
return JSON.parseObject(cacheValue);
} catch (Exception e) {
throw new BusinessException("微信小程序配置格式错误: " + e.getMessage());
}
}
/**
* 从scene参数中提取租户ID
* scene格式可能是: uid_33103 或其他包含用户ID的格式
@ -732,12 +751,6 @@ public class WxLoginController extends BaseController {
try {
String key = ACCESS_TOKEN_KEY.concat(":").concat(tenantId.toString());
// 使用跨租户方式获取微信小程序配置信息
JSONObject setting = settingService.getBySettingKeyIgnoreTenant("mp-weixin", tenantId);
if (setting == null) {
throw new RuntimeException("租户 " + tenantId + " 的小程序未配置");
}
// 从缓存获取access_token
String value = redisUtil.get(key);
if (value != null) {
@ -757,8 +770,9 @@ public class WxLoginController extends BaseController {
}
// 缓存中没有,重新获取
String appId = setting.getString("appId");
String appSecret = setting.getString("appSecret");
JSONObject wxConfig = getWxConfigFromCache(tenantId);
String appId = wxConfig.getString("appId");
String appSecret = wxConfig.getString("appSecret");
String apiUrl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appId + "&secret=" + appSecret;
System.out.println("调用微信API获取token - 租户ID: " + tenantId + ", AppID: " + (appId != null ? appId.substring(0, Math.min(8, appId.length())) + "..." : "null"));

8
src/main/java/com/gxwebsoft/common/system/mapper/SettingMapper.java

@ -38,12 +38,4 @@ public interface SettingMapper extends BaseMapper<Setting> {
@InterceptorIgnore(tenantLine = "true")
Setting getBySettingKeyIgnore(@Param("param") SettingParam param);
/**
* 跨库查询指定租户的设置配置
* @param settingKey 设置键
* @param tenantId 租户ID
* @return Setting
*/
@InterceptorIgnore(tenantLine = "true")
Setting getCrossDbSetting(@Param("settingKey") String settingKey, @Param("tenantId") Integer tenantId);
}

9
src/main/java/com/gxwebsoft/common/system/mapper/xml/SettingMapper.xml

@ -30,13 +30,4 @@
<include refid="selectSql"></include>
</select>
<!-- 跨库查询指定租户的设置配置 -->
<select id="getCrossDbSetting" resultType="com.gxwebsoft.common.system.entity.Setting">
SELECT a.*
FROM gxwebsoft_core.sys_setting a
WHERE a.setting_key = #{settingKey}
AND a.tenant_id = #{tenantId}
AND a.deleted = 0
</select>
</mapper>

93
src/main/java/com/gxwebsoft/common/system/service/impl/SettingServiceImpl.java

@ -113,47 +113,7 @@ public class SettingServiceImpl extends ServiceImpl<SettingMapper, Setting> impl
@Override
@IgnoreTenant("跨租户获取指定租户的设置配置")
public JSONObject getBySettingKeyIgnoreTenant(String key, Integer tenantId) {
System.out.println("跨租户查询设置 - key: " + key + ", tenantId: " + tenantId);
final List<Setting> list = list(new LambdaQueryWrapper<Setting>().eq(Setting::getTenantId, tenantId));
System.out.println("跨租户获取指定租户的设置配置 list = " + list);
// 使用跨租户查询,指定租户ID - 通过XML方式查询跨库数据(方式二:更简洁的方法)
Setting setting = baseMapper.getCrossDbSetting(key, tenantId);
System.out.println("跨租户查询结果: " + setting);
if(setting == null){
if ("mp-weixin".equals(key)) {
// 尝试从cms_website_field表中读取微信小程序配置
JSONObject websiteFieldConfig = getWeixinConfigFromWebsiteField(tenantId);
if (websiteFieldConfig != null) {
System.out.println("从cms_website_field表获取到微信小程序配置: " + websiteFieldConfig);
return websiteFieldConfig;
}
throw new BusinessException("租户 " + tenantId + " 的小程序未配置,请先在系统设置中配置微信小程序信息");
}
if ("payment".equals(key)) {
throw new BusinessException("租户 " + tenantId + " 的支付未配置");
}
if ("sms".equals(key)) {
throw new BusinessException("租户 " + tenantId + " 的短信未配置");
}
if ("wx-work".equals(key)){
throw new BusinessException("租户 " + tenantId + " 的企业微信未配置");
}
if ("setting".equals(key)) {
throw new BusinessException("租户 " + tenantId + " 的基本信息未配置");
}
if ("wx-official".equals(key)) {
throw new BusinessException("租户 " + tenantId + " 的微信公众号未配置");
}
if ("printer".equals(key)) {
throw new BusinessException("租户 " + tenantId + " 的打印机未配置");
}
throw new BusinessException("租户 " + tenantId + " 的配置项 " + key + " 未找到");
}
return JSON.parseObject(setting.getContent());
throw new BusinessException("此方法已废弃,请使用缓存方式获取配置:mp-weixin:" + tenantId);
}
@Override
@ -235,55 +195,4 @@ public class SettingServiceImpl extends ServiceImpl<SettingMapper, Setting> impl
return configMap.get(tenantId.toString());
}
/**
* 从cms_website_field表中获取微信小程序配置
* @param tenantId 租户ID
* @return 微信小程序配置JSON对象
*/
private JSONObject getWeixinConfigFromWebsiteField(Integer tenantId) {
try {
System.out.println("尝试从cms_website_field表获取微信小程序配置 - 租户ID: " + tenantId);
// 查询AppID
CmsWebsiteField appIdField = cmsWebsiteFieldService.getOne(
new LambdaQueryWrapper<CmsWebsiteField>()
.eq(CmsWebsiteField::getName, "AppID")
.eq(CmsWebsiteField::getTenantId, tenantId)
.eq(CmsWebsiteField::getDeleted, 0)
);
// 查询AppSecret
CmsWebsiteField appSecretField = cmsWebsiteFieldService.getOne(
new LambdaQueryWrapper<CmsWebsiteField>()
.eq(CmsWebsiteField::getName, "AppSecret")
.eq(CmsWebsiteField::getTenantId, tenantId)
.eq(CmsWebsiteField::getDeleted, 0)
);
System.out.println("AppID字段查询结果: " + appIdField);
System.out.println("AppSecret字段查询结果: " + appSecretField);
if (appIdField != null && appSecretField != null
&& appIdField.getValue() != null && !appIdField.getValue().trim().isEmpty()
&& appSecretField.getValue() != null && !appSecretField.getValue().trim().isEmpty()) {
// 构建微信小程序配置JSON
JSONObject config = new JSONObject();
config.put("appId", appIdField.getValue().trim());
config.put("appSecret", appSecretField.getValue().trim());
System.out.println("成功从cms_website_field表构建微信小程序配置: " + config);
return config;
} else {
System.out.println("cms_website_field表中未找到完整的AppID和AppSecret配置");
return null;
}
} catch (Exception e) {
System.err.println("从cms_website_field表获取微信小程序配置异常: " + e.getMessage());
e.printStackTrace();
return null;
}
}
}

2
src/main/java/com/gxwebsoft/oa/controller/OaAppController.java

@ -76,7 +76,7 @@ public class OaAppController extends BaseController {
if(!StrUtil.equals(d.getRoleCode(),"superAdmin") && !StrUtil.equals(d.getRoleCode(),"admin")){
// 非管理员按项目成员权限显示
final List<OaAppUser> list = oaAppUserService.list(new LambdaQueryWrapper<OaAppUser>().eq(OaAppUser::getUserId, userId));
System.out.println("list = " + list);
System.out.println("非管理员按项目成员权限显示 list = " + list);
final Set<Integer> collect = list.stream().map(OaAppUser::getAppId).collect(Collectors.toSet());
param.setAppIds(collect);
}

4
src/main/java/com/gxwebsoft/project/service/impl/ProjectServiceImpl.java

@ -227,7 +227,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
if (!project.getWebsiteId().equals(0)) {
final CmsWebsite website = new CmsWebsite();
website.setVersion(20);
website.setExpirationTime(expirationTime);
// 将LocalDateTime转换为Date
Date expirationDate = Date.from(expirationTime.atZone(ZoneId.systemDefault()).toInstant());
website.setExpirationTime(expirationDate);
website.setWebsiteId(project.getWebsiteId());
cmsWebsiteService.updateByIdAll(website);
}

4
src/main/java/com/gxwebsoft/shop/entity/ShopDealerApply.java

@ -38,6 +38,10 @@ public class ShopDealerApply implements Serializable {
@TableField(exist = false)
private String nickName;
@Schema(description = "手机号码")
@TableField(exist = false)
private String phone;
@Schema(description = "姓名")
private String realName;

2
src/main/java/com/gxwebsoft/shop/mapper/xml/ShopDealerApplyMapper.xml

@ -4,7 +4,7 @@
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*, b.nickname as nickName, c.nickname as refereeName
SELECT a.*, b.nickname as nickName, b.phone, c.nickname as refereeName
FROM shop_dealer_apply a
LEFT JOIN gxwebsoft_core.sys_user b ON a.user_id = b.user_id
LEFT JOIN gxwebsoft_core.sys_user c ON a.referee_id = c.user_id

2
src/main/java/com/gxwebsoft/shop/service/impl/OrderCancelServiceImpl.java

@ -126,7 +126,7 @@ public class OrderCancelServiceImpl implements OrderCancelService {
.last("LIMIT " + batchSize);
final List<ShopOrder> list = shopOrderService.list(queryWrapper);
System.out.println("list = " + list.size());
System.out.println("定时任务需要查询所有租户的超时订单 list = " + list.size());
return shopOrderService.list(queryWrapper);
}

3
src/main/resources/application.yml

@ -26,9 +26,6 @@ spring:
write-dates-as-timestamps: false
deserialization:
fail-on-unknown-properties: false
# 启用JSR310模块支持Java 8时间类型
modules:
- com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
# 连接池配置
datasource:

60
src/test/java/com/gxwebsoft/JacksonTest.java

@ -1,60 +0,0 @@
package com.gxwebsoft;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.gxwebsoft.cms.entity.CmsWebsite;
import lombok.Data;
import org.junit.jupiter.api.Test;
import java.time.LocalDateTime;
/**
* Jackson序列化测试
*/
public class JacksonTest {
@Test
public void testLocalDateTimeSerialization() throws Exception {
// 创建ObjectMapper并注册JavaTimeModule
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
// 创建测试对象
TestObject testObj = new TestObject();
testObj.setName("测试");
testObj.setExpirationTime(LocalDateTime.now());
// 序列化
String json = mapper.writeValueAsString(testObj);
System.out.println("序列化结果: " + json);
// 反序列化
TestObject result = mapper.readValue(json, TestObject.class);
System.out.println("反序列化结果: " + result);
}
@Test
public void testCmsWebsiteSerialization() throws Exception {
// 创建ObjectMapper并注册JavaTimeModule
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
// 创建CmsWebsite对象
CmsWebsite website = new CmsWebsite();
website.setWebsiteName("测试网站");
website.setExpirationTime(LocalDateTime.now());
// 序列化
String json = mapper.writeValueAsString(website);
System.out.println("CmsWebsite序列化结果: " + json);
}
@Data
public static class TestObject {
private String name;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime expirationTime;
}
}
Loading…
Cancel
Save