| | |
| | | import java.util.List;
|
| | | import java.util.Set;
|
| | |
|
| | | import javax.annotation.Nullable;
|
| | |
|
| | | import org.apache.ibatis.annotations.Param;
|
| | |
|
| | | import com.yeshi.fanli.dao.BaseMapper;
|
| | |
| | | * 1倒序-创建时间
|
| | | * @return
|
| | | */
|
| | | List<IntegralTaskRecord> listSignRecordByDateTime(@Param("uid") Long uid, @Param("cid") Long cid, @Param("dateTime") String dateTime);
|
| | | List<IntegralTaskRecord> listSignRecordByDateTime(@Param("uid") Long uid, @Param("cid") Long cid,
|
| | | @Param("dateTime") String dateTime);
|
| | |
|
| | | |
| | | /**
|
| | | * 未领取金币
|
| | | *
|
| | |
| | | * @param minTime
|
| | | * @param maxTime
|
| | | */
|
| | | int countGetCountByTaskIdAndDay(@Param("taskId") Long taskId,@Param("uid")Long uid, @Param("minTime") Date minTime,
|
| | | @Param("maxTime") Date maxTime);
|
| | | |
| | | |
| | | int countGetCountByTaskIdAndDay(@Param("taskId") Long taskId, @Param("uid") Long uid,
|
| | | @Param("minTime") Date minTime, @Param("maxTime") Date maxTime);
|
| | |
|
| | | /**
|
| | | * 统计今日第几次完成的任务
|
| | | *
|
| | |
| | | * @return
|
| | | */
|
| | | int countByTaskIdTodayNum(@Param("uid") Long uid, @Param("tid") Long tid, @Param("date") String date);
|
| | |
|
| | | /**
|
| | | * 根据类型与创建时间检索
|
| | | * |
| | | * @param cid
|
| | | * @param minTime
|
| | | * @param maxTime
|
| | | * @param start
|
| | | * @param count
|
| | | * @return
|
| | | */
|
| | | List<IntegralTaskRecord> listByCidAndUidAndCreateTime(@Param("cid") Long cid,@Param("uid") Long uid, @Param("minTime") Date minTime,
|
| | | @Param("maxTime") Date maxTime, @Param("start") long start, @Param("count") int count);
|
| | |
|
| | | long countByCidAndUidAndCreateTime(@Param("cid") Long cid,@Param("uid") Long uid, @Param("minTime") Date minTime,
|
| | | @Param("maxTime") Date maxTime);
|
| | | }
|
| | |
| | | package com.yeshi.fanli.job;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.scheduling.annotation.Scheduled;
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | import com.yeshi.fanli.entity.integral.IntegralTaskClass;
|
| | | import com.yeshi.fanli.entity.integral.IntegralTaskClass.UniqueKeyEnum;
|
| | | import com.yeshi.fanli.entity.integral.IntegralTaskRecord;
|
| | | import com.yeshi.fanli.exception.PushException;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralTaskClassService;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralTaskRecordService;
|
| | | import com.yeshi.fanli.service.inter.push.PushService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | |
|
| | | /**
|
| | | * 金币任务
|
| | |
| | | @Resource
|
| | | private PushService pushService;
|
| | |
|
| | | @Resource
|
| | | private IntegralTaskRecordService integralTaskRecordService;
|
| | |
|
| | | @Resource
|
| | | private IntegralTaskClassService integralTaskClassService;
|
| | |
|
| | | /**
|
| | | * 推送签到提醒(每天15点半查询)
|
| | | */
|
| | | @Scheduled(cron="0 30 15 * * ? ")
|
| | | @Scheduled(cron = "0 30 15 * * ? ")
|
| | | public void pushSignInNotify() {
|
| | | if (!Constant.IS_TASK)
|
| | | return;
|
| | | // 获取昨天签到过的
|
| | | IntegralTaskClass dailySignClass = integralTaskClassService.getByUniqueKey(UniqueKeyEnum.dailySign.name());
|
| | | if (dailySignClass == null)
|
| | | return;
|
| | | Long cid = dailySignClass.getId();
|
| | |
|
| | | // 查询今天是否已经签到
|
| | | long timeStamp = System.currentTimeMillis();
|
| | | Date minTime = new Date(TimeUtil.convertToTimeTemp(
|
| | | TimeUtil.getGernalTime(timeStamp - 1000 * 60 * 60 * 24L, "yyyy-MM-dd"), "yyyy-MM-dd"));
|
| | | Date maxTime = new Date(
|
| | | TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(timeStamp, "yyyy-MM-dd"), "yyyy-MM-dd"));
|
| | |
|
| | | // 如果未签到,需要推送信息
|
| | | // pushService.pushUserSignInNotification(uid, title, content, null,
|
| | | // null);
|
| | | Date todayMinTime = new Date(
|
| | | TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(timeStamp, "yyyy-MM-dd"), "yyyy-MM-dd"));
|
| | |
|
| | | Date todayMaxTime = new Date(TimeUtil.convertToTimeTemp(
|
| | | TimeUtil.getGernalTime(timeStamp + 1000 * 60 * 60 * 24L, "yyyy-MM-dd"), "yyyy-MM-dd"));
|
| | |
|
| | | long count = integralTaskRecordService.countByCidAndUidAndCreateTime(cid, null, minTime, maxTime);
|
| | | int page = (int) (count % 200 == 0 ? count / 200 : count / 200 + 1);
|
| | | for (int p = 0; p < page; p++) {
|
| | | List<IntegralTaskRecord> list = integralTaskRecordService.listByCidAndUidAndCreateTime(cid, null, minTime,
|
| | | maxTime, p + 1, 200);
|
| | | if (list != null) {
|
| | | for (IntegralTaskRecord record : list) {
|
| | | // 查询今天是否已经签到
|
| | | long todayCount = integralTaskRecordService.countByCidAndUidAndCreateTime(cid, record.getUid(),
|
| | | todayMinTime, todayMaxTime);
|
| | | if (todayCount <= 0) {// 如果未签到,需要推送信息
|
| | | try {
|
| | | pushService.pushUserSignInNotification(record.getUid(), "今日未签到提醒", "今日还未签到,连续签到金币翻倍哦", null,
|
| | | null);
|
| | | } catch (PushException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | AND TO_DAYS(tr.ir_create_time) = TO_DAYS('${date}') AND tr.ir_create_time <![CDATA[<=]]>'${date}'
|
| | | </select>
|
| | |
|
| | | |
| | | <select id="listByCidAndUidAndCreateTime" resultMap="BaseResultMap">
|
| | | select * from yeshi_ec_integral_task_record where ir_cid=#{cid}
|
| | | <if test="uid!=null">
|
| | | and ir_uid=#{uid}
|
| | | </if>
|
| | | <if test="minTime!=null">
|
| | | and ir_create_time>=#{minTime}
|
| | | </if>
|
| | | <if test="maxTime!=null">
|
| | | and #{maxTime}>ir_create_time
|
| | | </if>
|
| | | limit #{start},#{count}
|
| | | </select>
|
| | | |
| | | <select id="countByCidAndUidAndCreateTime" resultType="java.lang.Long">
|
| | | select count(ir_id) from yeshi_ec_integral_task_record where ir_cid=#{cid}
|
| | | <if test="uid!=null">
|
| | | and ir_uid=#{uid}
|
| | | </if>
|
| | | <if test="minTime!=null">
|
| | | and ir_create_time>=#{minTime}
|
| | | </if>
|
| | | |
| | | <if test="maxTime!=null">
|
| | | and #{maxTime}>ir_create_time
|
| | | </if>
|
| | | </select>
|
| | | |
| | | </mapper> |
| | |
| | | if (UniqueKeyEnum.dailySign == taskClass.getUniqueKey()) {
|
| | | SimpleDateFormat format = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
|
| | | Date recordTime = record.getCreateTime();
|
| | | List<IntegralTaskRecord> list = integralTaskRecordMapper.listSignRecordByDateTime(uid, cid, format.format(recordTime));
|
| | | List<IntegralTaskRecord> list = integralTaskRecordMapper.listSignRecordByDateTime(uid, cid,
|
| | | format.format(recordTime));
|
| | | int num = 1;
|
| | | if (list != null && list.size() > 0) {
|
| | | try { |
| | | try {
|
| | | Date nextDate = null;
|
| | | for (IntegralTaskRecord tntegralTaskRecord : list) {
|
| | | if (nextDate == null) {
|
| | |
| | | int num = 0;
|
| | | FrequencyEnum frequency = integralTask.getFrequency();
|
| | | if (frequency == FrequencyEnum.everyday) {
|
| | | num = integralTaskRecordMapper.countByTaskIdTodayNum(uid, taskId, TimeUtil.getWholeTime(record.getCreateTime().getTime()));
|
| | | num = integralTaskRecordMapper.countByTaskIdTodayNum(uid, taskId,
|
| | | TimeUtil.getWholeTime(record.getCreateTime().getTime()));
|
| | | } else if (frequency == FrequencyEnum.onlyOne) {
|
| | | num = 1;
|
| | | }
|
| | | |
| | |
|
| | | if (num <= 0)
|
| | | num = 1;
|
| | | String title = taskClass.getName() + "-" + integralTask.getName() + "-" + num + "次";
|
| | | detail.setTitle(title);
|
| | | }
|
| | | |
| | |
|
| | | detail.setUid(uid);
|
| | | detail.setMoney(record.getGoldCoin());
|
| | | detail.setCreateTime(record.getCreateTime());
|
| | |
| | | integralTaskRecordMapper.insertSelective(record);
|
| | | return record;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<IntegralTaskRecord> listByCidAndUidAndCreateTime(Long cid, Long uid, Date minTime, Date maxTime,
|
| | | int page, int count) {
|
| | | return integralTaskRecordMapper.listByCidAndUidAndCreateTime(cid, uid, minTime, maxTime, (page - 1) * count,
|
| | | count);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countByCidAndUidAndCreateTime(Long cid, Long uid, Date minTime, Date maxTime) {
|
| | | return integralTaskRecordMapper.countByCidAndUidAndCreateTime(cid, uid, minTime, maxTime);
|
| | | }
|
| | | }
|
| | |
| | | */
|
| | | public IntegralTaskRecord addRecord(IntegralTaskRecord record) throws IntegralTaskRecordException;
|
| | |
|
| | | /**
|
| | | * 根据类型与时间检索
|
| | | * @param cid
|
| | | * @param minTime
|
| | | * @param maxTime
|
| | | * @param page
|
| | | * @param count
|
| | | * @return
|
| | | */
|
| | | public List<IntegralTaskRecord> listByCidAndUidAndCreateTime(Long cid,Long uid, Date minTime, Date maxTime, int page, int count);
|
| | |
|
| | | /**
|
| | | * 根据类型与时间检索
|
| | | * @param cid
|
| | | * @param minTime
|
| | | * @param maxTime
|
| | | * @return
|
| | | */
|
| | | public long countByCidAndUidAndCreateTime(Long cid,Long uid, Date minTime, Date maxTime);
|
| | |
|
| | | }
|