tj
2025-04-02 e2c56f53fcfeb638c35464e9da18b78334daad0f
1.VIP订单过期检测-每天凌晨一点执行一次
已修改4个文件
23 ■■■■■ 文件已修改
src/main/java/com/mzl/flower/mapper/customer/CustomerMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/schedule/ScheduleService.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/service/customer/CustomerService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/customer/CustomerMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/mapper/customer/CustomerMapper.java
@@ -41,4 +41,6 @@
    @Select("select * from t_customer_info where  user_id  = ( select id from t_user where tel =#{phone} and type = 'customer')")
    CustomerDTO findCustomerByPhone(String phone);
    void checkVipExpireTime();
}
src/main/java/com/mzl/flower/schedule/ScheduleService.java
@@ -1,7 +1,9 @@
package com.mzl.flower.schedule;
import com.mzl.flower.service.customer.CustomerService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -10,6 +12,9 @@
@Slf4j
public class ScheduleService {
    @Autowired
    private CustomerService customerService;
    @Scheduled(cron = "0 15 17 * * ?")
    @Profile("prod")
    public void DealSendMessageInfoBySupplier() {
@@ -17,4 +22,10 @@
        log.info("供应商下单供货提示结束:" + DateFormatUtils.format(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss"));
    }
    // vip过期时间校验,每隔1个小时执行一次
    @Scheduled(cron = "0 0 1 * * ?")
    public void checkVipExpireTime() {
        customerService.checkVipExpireTime();
    }
}
src/main/java/com/mzl/flower/service/customer/CustomerService.java
@@ -276,4 +276,9 @@
    public void updateMemberInfo(Customer customer) {
        customerMapper.updateById(customer);
    }
    public void checkVipExpireTime() {
        // 获取当天日期之前,且is_member=1的用户,设置为is_member=0并且将member_overtime设置为null
        customerMapper.checkVipExpireTime();
    }
}
src/main/resources/mapper/customer/CustomerMapper.xml
@@ -4,6 +4,11 @@
    <update id="bindPartner">
        update t_customer_info set partner_id = #{partnerId} , partner_user_id = #{userId} where id = #{id}
    </update>
    <update id="checkVipExpireTime">
        update t_customer_info c
        set c.is_member = 0,c.member_overtime = NULL
        where c.member_overtime < now() and c.is_member = 1
    </update>
    <select id="queryCustomer" resultType="com.mzl.flower.dto.response.customer.CustomerDTO">
        SELECT
            c.*,