yujian
2019-08-29 278c4212005b70a5584e4c835663a49240f92e92
口令过期
5个文件已修改
1个文件已添加
94 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/user/TokenRecordMapper.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/job/TokenJob.java 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/user/TokenRecordMapper.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponGiveRecordMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/TokenRecordService.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/user/TokenRecordMapper.java
@@ -1,5 +1,7 @@
package com.yeshi.fanli.dao.mybatis.user;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
@@ -22,4 +24,12 @@
     * @return
     */
    TokenRecord getNearByTypeAndIdentify(@Param("type")String type, @Param("identify")String identify);
    /**
     * 口令失效
     * @param token
     * @return
     */
    List<TokenRecord> overdueList(@Param("count") int count);
}
fanli/src/main/java/com/yeshi/fanli/job/TokenJob.java
New file
@@ -0,0 +1,41 @@
package com.yeshi.fanli.job;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import com.yeshi.fanli.entity.bus.user.TokenRecord;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.user.TokenRecordService;
import com.yeshi.fanli.util.Constant;
@Component
public class TokenJob {
    @Resource
    private TokenRecordService tokenRecordService;
    /**
     * 每天一个小时更新券
     */
    @Scheduled(cron = "0 0 0/1 * * ? ")
    public void updateCouponInfo() {
        if (!Constant.IS_TASK)
            return;
        try {
            for (int i = 0; i < 100; i++) {
                List<TokenRecord> overdueList = tokenRecordService.overdueList(500);
                if (overdueList == null || overdueList.size() == 0) {
                    break;
                }
                tokenRecordService.overdue(overdueList);
            }
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/mapping/user/TokenRecordMapper.xml
@@ -74,4 +74,10 @@
    LIMIT 1
  </select>
  
  <select id="overdueList" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_token_record
    WHERE tr_state = 0 AND tr_end_time IS NOT NULL AND tr_end_time <![CDATA[<]]> NOW()
    LIMIT #{count}
  </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponGiveRecordMapper.xml
@@ -66,14 +66,14 @@
  
  <select id="overdueList" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_user_system_coupon_give_record d
    WHERE d.`cgr_state` = 0 AND d.`cgr_end_time` IS NOT NULL AND d.`cgr_end_time` <![CDATA[<]]> CURDATE()
    WHERE d.`cgr_state` = 0 AND d.`cgr_end_time` IS NOT NULL AND d.`cgr_end_time` <![CDATA[<]]> NOW()
    LIMIT #{count}
  </select>
  
  <select id="overdueListByUser" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_user_system_coupon_give_record d
    WHERE d.cgr_give_uid = #{uid} AND d.`cgr_state` = 0 AND d.`cgr_end_time` IS NOT NULL 
          AND d.`cgr_end_time` <![CDATA[<]]> CURDATE()
          AND d.`cgr_end_time` <![CDATA[<]]> NOW()
  </select>
  
   <select id="getByReceiveId" resultMap="BaseResultMap">
fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java
@@ -576,5 +576,23 @@
        }
        return invite;
    }
    @Override
    public List<TokenRecord> overdueList(int count) {
        return tokenRecordMapper.overdueList(count);
    }
    @Override
    public void overdue(List<TokenRecord> list) {
        if (list == null || list.size() == 0)
            return;
        Date date = new Date();
        for (TokenRecord tokenRecord: list) {
            tokenRecord.setState(1);
            tokenRecord.setUpdateTime(date);
            tokenRecordMapper.updateByPrimaryKeySelective(tokenRecord);
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/inter/user/TokenRecordService.java
@@ -1,5 +1,7 @@
package com.yeshi.fanli.service.inter.user;
import java.util.List;
import com.yeshi.fanli.entity.bus.user.TokenRecord;
import com.yeshi.fanli.exception.user.TokenRecordException;
import com.yeshi.fanli.vo.msg.TokenVO;
@@ -37,4 +39,17 @@
    
    public void updateByPrimaryKeySelective(TokenRecord record);
    /**
     * 待过期的口令
     * @param count
     * @return
     */
    public List<TokenRecord> overdueList(int count);
    /**
     * 过期口令
     * @param list
     */
    public void overdue(List<TokenRecord> list);
}