linhw 2024-05-08 10:26:31 +08:00
parent 8da66d5720
commit b773612966
4 changed files with 45 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import com.ruoyi.common.security.annotation.EnableRyFeignClients;
import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
/**
*
@ -15,6 +16,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@EnableCustomSwagger2
@EnableRyFeignClients
@SpringBootApplication
@EnableScheduling
public class RuoYiAppApplication
{
public static void main(String[] args)

View File

@ -65,4 +65,7 @@ public interface AppUserMapper
AppUser selectAppUserByPhone(@Param("phoneNumber") String phoneNumber);
List<AppUserDataVo> selectList(AppUser appUser);
List<Long> listByOrderTime();
void updateAppUserById(@Param("ids")List<Long> ids);
}

View File

@ -0,0 +1,22 @@
package com.ruoyi.app.service;
import com.ruoyi.app.mapper.AppUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public class ScheduledService {
@Autowired
private AppUserMapper appUserMapper;
@Scheduled(cron = "0/5 * * * * *")
public void updateUserMember(){
List<Long> ids = appUserMapper.listByOrderTime();
if (ids != null && ids.size() > 0) {
appUserMapper.updateAppUserById(ids);
}
}
}

View File

@ -162,6 +162,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
group by a.id
</select>
<select id="listByOrderTime" resultType="java.lang.Long">
select
a.id
from app_user a
<where>
a.is_member = 0
and a.order_end_time &gt; now()
</where>
</select>
<update id="updateAppUserById" parameterType="java.lang.Long">
update app_user set is_member = 1
where id in
<foreach collection="ids" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<insert id="insertAppUser" parameterType="AppUser" useGeneratedKeys="true" keyProperty="id">
insert into app_user