Commit 15b66247 authored by shiyu's avatar shiyu

判断用户当天是否还有其它发布的商品,没有则需要取消签到记录

parent 71a62261
...@@ -38,8 +38,7 @@ import java.io.IOException; ...@@ -38,8 +38,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.URL; import java.net.URL;
import java.time.Duration; import java.time.*;
import java.time.Instant;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -617,16 +616,29 @@ public class SysSupplierItemServiceImpl implements SysSupplierItemService { ...@@ -617,16 +616,29 @@ public class SysSupplierItemServiceImpl implements SysSupplierItemService {
String url = wxAppletApi.getUrlLink("/pages/saleSelf/index","userId=" + oldItem.getCreatorId() + "&shareRecordId="); String url = wxAppletApi.getUrlLink("/pages/saleSelf/index","userId=" + oldItem.getCreatorId() + "&shareRecordId=");
String msg = "您发布的" + oldItem.getName() + ",内容涉嫌违反平台规定,已被平台下架,请前往"+ url + "查看"; String msg = "您发布的" + oldItem.getName() + ",内容涉嫌违反平台规定,已被平台下架,请前往"+ url + "查看";
//如果用户今天签到了,则取消签到记录
UserSignIn todaySignIn = userSignInDao.findTodayRecord(oldItem.getCreatorId()); //判断用户当天是否还有其它发布的商品,没有则需要取消签到记录
if (todaySignIn != null) { LocalDate today = LocalDate.now();
UserSignIn updateDto = new UserSignIn(); SupplierItemRequestDto supplierItemRequestDto = new SupplierItemRequestDto();
updateDto.setId(todaySignIn.getId()); LocalDateTime startOfDay = today.atTime(LocalTime.MIN);
updateDto.setIsValid(false); Date startDate = Date.from(startOfDay.atZone(java.time.ZoneId.systemDefault()).toInstant());
userSignInDao.updateByPrimaryKey(updateDto); LocalDateTime endOfDay = today.atTime(LocalTime.MAX);
msg = "您发布的" + oldItem.getName() + ",内容涉嫌违反平台规定,已被平台下架,并取消了今天的签到记录,请前往"+ url + "查看"; Date endDate = Date.from(endOfDay.atZone(java.time.ZoneId.systemDefault()).toInstant());
supplierItemRequestDto.setStartCreateTime(startDate);
supplierItemRequestDto.setEndCreateTime(endDate);
supplierItemRequestDto.setCreatorId(oldItem.getCreatorId());
if (!supplierItemDao.isUploadItem(supplierItemRequestDto)) {
//没有其它发布的商品,如果用户今天签到了,则取消签到记录
UserSignIn todaySignIn = userSignInDao.findTodayRecord(oldItem.getCreatorId());
if (todaySignIn != null) {
UserSignIn updateDto = new UserSignIn();
updateDto.setId(todaySignIn.getId());
updateDto.setIsValid(false);
userSignInDao.updateByPrimaryKey(updateDto);
msg = "您发布的" + oldItem.getName() + ",内容涉嫌违反平台规定,已被平台下架,并取消了今天的签到记录,请前往"+ url + "查看";
}
aliSmsSender.sendSms(oldItem.getCreatorId(), msg);
} }
aliSmsSender.sendSms(oldItem.getCreatorId(), msg);
return Result.success(); return Result.success();
} catch (Exception e) { } catch (Exception e) {
logger.error("违规下架失败 error : {}", e); logger.error("违规下架失败 error : {}", e);
......
...@@ -75,9 +75,9 @@ public class SignInNoticeJob { ...@@ -75,9 +75,9 @@ public class SignInNoticeJob {
/** /**
* 每天下午两点执行一次 * 每天晚上八点执行一次
*/ */
@Scheduled(cron = "0 0 14 * * ?") @Scheduled(cron = "0 0 20 * * ?")
public void execute() { public void execute() {
if ("dev".equals(env)) { if ("dev".equals(env)) {
logger.info(">>>>>>>>>>>>>>>>>>>>>>> dev环境, 不执行发送签到提醒通知定时作业<<<<<<<<<<<<<<<<<<<<<"); logger.info(">>>>>>>>>>>>>>>>>>>>>>> dev环境, 不执行发送签到提醒通知定时作业<<<<<<<<<<<<<<<<<<<<<");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment