|
|
|
|
@ -46,21 +46,22 @@ public class WxClockLogServiceImpl implements IWxClockLogService {
|
|
|
|
|
WxUserMember wxUserMember = SecurityUtils.getLoginUser().getWxUserMember();
|
|
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
|
|
|
|
|
// 首次打卡奖励
|
|
|
|
|
/* 查询当天是否有打卡 */
|
|
|
|
|
WxClockLog queryClockLog = new WxClockLog();
|
|
|
|
|
queryClockLog.setUserId(SecurityUtils.getLoginUser().getWxUserMember().getId());
|
|
|
|
|
queryClockLog.getParams().put("beginTime", LocalDateTime.of(now.toLocalDate(), LocalTime.MIN));
|
|
|
|
|
queryClockLog.getParams().put("endTime", LocalDateTime.of(now.toLocalDate(), LocalTime.MAX));
|
|
|
|
|
Integer count = wxClockLogMapper.selectCountByUserId(queryClockLog);
|
|
|
|
|
if (count == null || count == 0) {
|
|
|
|
|
List<WxClockLog> wxClockLogList = wxClockLogMapper.selectWxClockLogList(queryClockLog);
|
|
|
|
|
WxClockLog wxClockLog = new WxClockLog();
|
|
|
|
|
if (wxClockLogList != null && wxClockLogList.size() == 1) {
|
|
|
|
|
// 打卡记录一天只有一条
|
|
|
|
|
wxClockLog.setId(wxClockLogList.get(0).getId());
|
|
|
|
|
} else {
|
|
|
|
|
/**
|
|
|
|
|
* TODO:当天首次打卡奖励积分
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 打卡记录
|
|
|
|
|
WxClockLog wxClockLog = new WxClockLog();
|
|
|
|
|
BeanUtils.copyProperties(wxClockLogReq, wxClockLog);
|
|
|
|
|
wxClockLog.setClockContent(wxClockLogReq.getClockContent());
|
|
|
|
|
wxClockLog.setUserId(wxUserMember.getId());
|
|
|
|
|
wxClockLog.setCreateBy(wxUserMember.getNickname());
|
|
|
|
|
wxClockLog.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
@ -85,10 +86,15 @@ public class WxClockLogServiceImpl implements IWxClockLogService {
|
|
|
|
|
.collect(Collectors.joining(","));
|
|
|
|
|
wxClockLog.setInstrumentName(instrumentNameList);
|
|
|
|
|
}
|
|
|
|
|
wxClockLogMapper.insertWxClockLog(wxClockLog);
|
|
|
|
|
if (wxClockLog.getId() == null) {
|
|
|
|
|
wxClockLogMapper.insertWxClockLog(wxClockLog);
|
|
|
|
|
} else {
|
|
|
|
|
wxClockLogMapper.updateWxClockLog(wxClockLog);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 打卡图片
|
|
|
|
|
/* 先删除当天的打卡图片,保存打卡图片 */
|
|
|
|
|
if (wxClockLogReq.getClockImageList() != null && wxClockLogReq.getClockImageList().size() > 0) {
|
|
|
|
|
wxClockImgMapper.deleteByUserClockId(wxClockLog.getId());
|
|
|
|
|
for (String image : wxClockLogReq.getClockImageList()) {
|
|
|
|
|
WxClockImg wxClockImg = new WxClockImg();
|
|
|
|
|
wxClockImg.setUserClockId(wxClockLog.getId());
|
|
|
|
|
@ -125,18 +131,18 @@ public class WxClockLogServiceImpl implements IWxClockLogService {
|
|
|
|
|
List<WxClockLog> wxClockLogList = wxClockLogMapper.selectWxClockLogList(queryClockLog);
|
|
|
|
|
if (wxClockLogList != null && wxClockLogList.size() > 0) {
|
|
|
|
|
// 直接获取最新的打卡记录
|
|
|
|
|
WxClockLog saveClockLog = new WxClockLog();
|
|
|
|
|
WxClockLog updateClockLog = new WxClockLog();
|
|
|
|
|
WxClockLog newWxClockLog = wxClockLogList.get(0);
|
|
|
|
|
// 获取打卡记录的使用过的仪器ID
|
|
|
|
|
List<Long> usedList = Arrays.asList(newWxClockLog.getInstrumentId().split(",")).stream().map(Long::valueOf).collect(Collectors.toList());
|
|
|
|
|
if (!usedList.contains(instrumentId)) {
|
|
|
|
|
saveClockLog.setInstrumentId(newWxClockLog.getInstrumentId() + "," + instrumentId);
|
|
|
|
|
updateClockLog.setInstrumentId(newWxClockLog.getInstrumentId() + "," + instrumentId);
|
|
|
|
|
WxInstrument instrument = wxInstrumentMapper.selectWxInstrumentById(instrumentId);
|
|
|
|
|
if (instrument != null) {
|
|
|
|
|
saveClockLog.setInstrumentName(newWxClockLog.getInstrumentName() + "," + instrument.getName());
|
|
|
|
|
updateClockLog.setInstrumentName(newWxClockLog.getInstrumentName() + "," + instrument.getName());
|
|
|
|
|
}
|
|
|
|
|
saveClockLog.setId(newWxClockLog.getId());
|
|
|
|
|
wxClockLogMapper.updateWxClockLog(saveClockLog);
|
|
|
|
|
updateClockLog.setId(newWxClockLog.getId());
|
|
|
|
|
wxClockLogMapper.updateWxClockLog(updateClockLog);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|