|
|
|
|
@ -3,6 +3,7 @@ package com.flossom.miniProgram.service.impl;
|
|
|
|
|
import com.flossom.common.core.domain.entity.*;
|
|
|
|
|
import com.flossom.common.core.domain.req.WxClockLogReq;
|
|
|
|
|
import com.flossom.common.core.domain.ret.WxClockLogRet;
|
|
|
|
|
import com.flossom.common.core.enums.IntegralChangeTypeEnum;
|
|
|
|
|
import com.flossom.common.core.enums.Status;
|
|
|
|
|
import com.flossom.common.core.mapper.*;
|
|
|
|
|
import com.flossom.common.core.utils.DateUtils;
|
|
|
|
|
@ -21,6 +22,7 @@ import java.math.RoundingMode;
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.time.LocalTime;
|
|
|
|
|
import java.time.ZoneId;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
@ -52,6 +54,12 @@ public class WxClockLogServiceImpl implements IWxClockLogService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private WxUserMemberMapper wxUserMemberMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private WxUserIntegralLogMapper wxUserIntegralLogMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IntegralClockMapper integralClockMapper;
|
|
|
|
|
|
|
|
|
|
@Value("${rank.clock.redisKey}")
|
|
|
|
|
private String CLOCK_RANK_REDIS_KEY;
|
|
|
|
|
|
|
|
|
|
@ -73,9 +81,44 @@ public class WxClockLogServiceImpl implements IWxClockLogService {
|
|
|
|
|
// 打卡记录一天只有一条
|
|
|
|
|
wxClockLog.setId(wxClockLogList.get(0).getId());
|
|
|
|
|
} else {
|
|
|
|
|
/**
|
|
|
|
|
* TODO:当天首次打卡奖励积分
|
|
|
|
|
*/
|
|
|
|
|
IntegralClock integralClock = integralClockMapper.selectIntegralClockById(1L);
|
|
|
|
|
// 日常奖励加分
|
|
|
|
|
Long credit = integralClock.getDailyClockCredit();
|
|
|
|
|
if (credit != null && 1 == integralClock.getIsExtraClock() && integralClock.getStartTime() != null
|
|
|
|
|
&& integralClock.getEndTime() != null && integralClock.getExtraClockCredit() != null) {
|
|
|
|
|
LocalDateTime nowTime = LocalDateTime.now();
|
|
|
|
|
if (nowTime.isAfter(integralClock.getStartTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime())
|
|
|
|
|
&& nowTime.isBefore(integralClock.getEndTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime())) {
|
|
|
|
|
credit += integralClock.getExtraClockCredit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (credit != null && credit != 0) {
|
|
|
|
|
// 增加积分
|
|
|
|
|
WxUserMember query = wxUserMemberMapper.selectWxUserMemberById(wxUserMember.getId());
|
|
|
|
|
WxUserMember updateEntity = new WxUserMember();
|
|
|
|
|
updateEntity.setId(query.getId());
|
|
|
|
|
updateEntity.setCredit(updateEntity.getCredit() + credit.intValue());
|
|
|
|
|
updateEntity.setUpdateBy(wxUserMember.getNickname());
|
|
|
|
|
updateEntity.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
wxUserMemberMapper.updateWxUserMember(updateEntity);
|
|
|
|
|
|
|
|
|
|
// 保存积分操作记录
|
|
|
|
|
WxUserIntegralLog wxUserIntegralLog = new WxUserIntegralLog();
|
|
|
|
|
wxUserIntegralLog.setUserId(wxUserMember.getId());
|
|
|
|
|
wxUserIntegralLog.setUserName(wxUserMember.getNickname());
|
|
|
|
|
wxUserIntegralLog.setUserPhone(wxUserMember.getMobile());
|
|
|
|
|
wxUserIntegralLog.setSource(IntegralChangeTypeEnum.INCREASE.getCode());
|
|
|
|
|
wxUserIntegralLog.setFloatScore(credit);
|
|
|
|
|
wxUserIntegralLog.setRemarkContent("打卡积分奖励");
|
|
|
|
|
wxUserIntegralLog.setCreateBy(SecurityUtils.getLoginUser().getWxUserMember().getNickname());
|
|
|
|
|
wxUserIntegralLog.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
wxUserIntegralLogMapper.insertWxUserIntegralLog(wxUserIntegralLog);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* TODO:当天首次打卡奖励积分,同步数云
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
wxClockLog.setClockContent(wxClockLogReq.getClockContent());
|
|
|
|
|
wxClockLog.setUserId(wxUserMember.getId());
|
|
|
|
|
|