From 30ad2f4290edddf4f06117d5e18cc312b68a54c8 Mon Sep 17 00:00:00 2001 From: KKSU <15274802129@163.com> Date: Fri, 10 Jan 2025 11:50:04 +0800 Subject: [PATCH] feat(mall): 活动列表按创建时间升序排序 - 在查询活动列表时,添加按创建时间升序排序的条件 - 优化活动列表的展示顺序,使最新的活动优先展示 --- src/main/java/cc/mrbird/febs/mall/quartz/WxxcxJob.java | 91 ++++++++++++++++++++++++++++----------------- 1 files changed, 57 insertions(+), 34 deletions(-) diff --git a/src/main/java/cc/mrbird/febs/mall/quartz/WxxcxJob.java b/src/main/java/cc/mrbird/febs/mall/quartz/WxxcxJob.java index d731967..ccd49dd 100644 --- a/src/main/java/cc/mrbird/febs/mall/quartz/WxxcxJob.java +++ b/src/main/java/cc/mrbird/febs/mall/quartz/WxxcxJob.java @@ -1,14 +1,11 @@ package cc.mrbird.febs.mall.quartz; -import cc.mrbird.febs.common.properties.XcxProperties; -import cc.mrbird.febs.common.utils.HttpCurlUtil; import cc.mrbird.febs.common.utils.RedisUtils; -import cc.mrbird.febs.common.utils.SpringContextHolder; -import cc.mrbird.febs.pay.util.WechatConfigure; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.extension.exceptions.ApiException; +import cc.mrbird.febs.mall.entity.MallMemberCoupon; +import cc.mrbird.febs.mall.mapper.MallMemberCouponMapper; +import cc.mrbird.febs.mall.service.MallInvoiceService; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -17,19 +14,21 @@ import org.springframework.web.client.RestTemplate; import javax.annotation.Resource; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; +import java.util.List; @Slf4j @Component @ConditionalOnProperty(prefix = "system", name = "job", havingValue = "true") public class WxxcxJob { - private final XcxProperties xcxProperties = SpringContextHolder.getBean(XcxProperties.class); +// private final XcxProperties xcxProperties = SpringContextHolder.getBean(XcxProperties.class); @Autowired private RedisUtils redisUtils; + @Autowired + private MallMemberCouponMapper mallMemberCouponMapper; + @Autowired + private MallInvoiceService mallInvoiceService; @Resource RestTemplate restTemplate; // @Autowired @@ -38,32 +37,56 @@ * 获取access_token * 有效期两小时 */ +// @Scheduled(cron = "0 0 0/1 * * ? ") +// public void getAccessToken() throws IOException { +// log.info("执行access_token刷新"); +// String appId = xcxProperties.getXcxAppid(); +// String appSecret = xcxProperties.getXcxSecret(); +// String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appId + "&secret=" + appSecret; +// String jsonStr = restTemplate.getForObject(url, String.class); +// +// /** +// * 返回结果 +// * {"access_token":"ACCESS_TOKEN","expires_in":7200} +// */ +// if (!jsonStr.contains("access_token")) { +// System.out.println("获取微信access_token失败"); +// } +// +// String accessTokenKey = WechatConfigure.WX_ACCESS_TOKEN_REDIS_KEY; +// JSONObject jsonObject = JSONObject.parseObject(jsonStr); +// String accessToken = jsonObject.getString(accessTokenKey); +// if (StrUtil.isEmpty(accessToken)) { +// log.error("获取access token失败: {}" , jsonObject.getString("errmsg")); +// throw new ApiException("获取access token失败"); +// } else { +// log.info("wx access_token : {}",accessToken); +// redisUtils.set(accessTokenKey,accessToken); +// } +// +// } + @Scheduled(cron = "0 0 0/1 * * ? ") - public void getAccessToken() throws IOException { - String appId = xcxProperties.getXcxAppid(); - String appSecret = xcxProperties.getXcxSecret(); - String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appId + "&secret=" + appSecret; - String jsonStr = restTemplate.getForObject(url, String.class); - - /** - * 返回结果 - * {"access_token":"ACCESS_TOKEN","expires_in":7200} - */ - if (!jsonStr.contains("access_token")) { - System.out.println("获取微信access_token失败"); + public void expireCoupon() { + List<MallMemberCoupon> mallMemberCoupons = mallMemberCouponMapper.selectListByExpireTime(DateUtil.date()); + if(CollUtil.isEmpty(mallMemberCoupons)){ + return; } - - String accessTokenKey = WechatConfigure.WX_ACCESS_TOKEN_REDIS_KEY; - JSONObject jsonObject = JSONObject.parseObject(jsonStr); - String accessToken = jsonObject.getString(accessTokenKey); - if (StrUtil.isEmpty(accessToken)) { - log.error("获取access token失败: {}" , jsonObject.getString("errmsg")); - throw new ApiException("获取access token失败"); - } else { - log.info("wx access_token : {}",accessToken); - redisUtils.set(accessTokenKey,accessToken); + for(MallMemberCoupon mallMemberCoupon : mallMemberCoupons){ + mallMemberCoupon.setState(3); + mallMemberCouponMapper.updateById(mallMemberCoupon); } } +// /** +// * 更新发票记录表数据 +// * 定时,每天凌晨一点 +// * 已完成的订单,更新到发票记录中 +// */ +// @Scheduled(cron = "0 0 1 * * ?") +// public void mallInvoiceJob() { +// mallInvoiceService.mallInvoiceJob(); +// } + } -- Gitblit v1.9.1