Browse Source

12/20

master
wangpengfei 1 year ago
parent
commit
32d5136a55
  1. 38
      src/main/java/com/yxt/yyth/biz/lpkgiftcard/LpkGiftCardService.java
  2. 66
      src/main/java/com/yxt/yyth/biz/scheduled/scheduledRest.java

38
src/main/java/com/yxt/yyth/biz/lpkgiftcard/LpkGiftCardService.java

@ -146,7 +146,7 @@ public class LpkGiftCardService extends MybatisBaseService<LpkGiftCardMapper, Lp
return rb.setMsg("参数不能为空");
}
QueryWrapper<LpkGiftCard> qw = new QueryWrapper<>();
updateIsItInvalid(query.getCustomerSid());
// updateIsItInvalid(query.getCustomerSid());
if (StringUtils.isNotBlank(query.getCustomerSid())) {
qw.eq("customerSid", query.getCustomerSid());
}
@ -169,43 +169,7 @@ public class LpkGiftCardService extends MybatisBaseService<LpkGiftCardMapper, Lp
// }
// return rb.success();
// }
public ResultBean updateIsItInvalid(String customerSid) {
ResultBean rb = new ResultBean();
List<LpkGiftBag> lpkGiftBags = lpkGiftBagService.list(new QueryWrapper<LpkGiftBag>());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (LpkGiftBag lpkGiftBag : lpkGiftBags) {
int in = DateUtil.parse(sdf.format(lpkGiftBag.getDateEnd())).compareTo(DateUtil.parse(sdf.format(new Date())));
if (String.valueOf(in).equals("-1")) {
Integer i = baseMapper.selectCount(new QueryWrapper<LpkGiftCard>().eq("giftbagSid", lpkGiftBag.getSid()).ne("state", "5"));
if (i != 0) {
baseMapper.updateIsItInvalid(lpkGiftBag.getSid(), "5");
}
} else {
List<LpkGiftCard> list = baseMapper.selectList(new QueryWrapper<LpkGiftCard>().eq("customerSid", customerSid).eq("giftbagSid", lpkGiftBag.getSid()));
for (LpkGiftCard card : list) {
LpkReserveOrderVo LpkReserveOrderVo = lpkReserveOrderService.selByCardSid(card.getSid()).getData();
if (null != LpkReserveOrderVo) {
int c = DateUtil.parse(sdf.format(LpkReserveOrderVo.getReserveDate())).compareTo(DateUtil.parse(sdf.format(new Date())));
// LpkGiftCard card1 = baseMapper.selectOne(new QueryWrapper<LpkGiftCard>().eq("sid", card.getSid()));
if (String.valueOf(c).equals("-1")) {
card.setIsReservation("1");
baseMapper.updateById(card);
}
}
}
}
}
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
// List<LpkGiftBag> lpkGiftBags = lpkGiftBagService.list(new QueryWrapper<LpkGiftBag>().lt("dateEnd", sdf.format(new Date())));
// for (LpkGiftBag lpkGiftBag : lpkGiftBags) {
// Integer i = baseMapper.selectCount(new QueryWrapper<LpkGiftCard>().eq("giftbagSid", lpkGiftBag.getSid()).ne("state", "5"));
// if (i != 0) {
// baseMapper.updateIsItInvalid(lpkGiftBag.getSid(), "5");
// }
// }
return rb.success();
}
public ResultBean<AppletVo> getGifCardBySid(String sid) {
ResultBean rb = new ResultBean().fail();

66
src/main/java/com/yxt/yyth/biz/scheduled/scheduledRest.java

@ -0,0 +1,66 @@
package com.yxt.yyth.biz.scheduled;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yxt.common.core.result.ResultBean;
import com.yxt.yyth.api.lpkgiftbag.LpkGiftBag;
import com.yxt.yyth.api.lpkgiftcard.LpkGiftCard;
import com.yxt.yyth.api.lpkreserveorder.LpkReserveOrderVo;
import com.yxt.yyth.biz.lpkgiftbag.LpkGiftBagService;
import com.yxt.yyth.biz.lpkgiftcard.LpkGiftCardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
/**
* @author wangpengfei
* @date 2023/12/20 10:44
*/
public class scheduledRest {
@Autowired
LpkGiftBagService lpkGiftBagService;
@Autowired
LpkGiftCardService lpkGiftCardService;
// @Scheduled(cron = "0 0 1 * * ? ")
public void updateIsItInvalid(String customerSid) {
// ResultBean rb = new ResultBean();
// List<LpkGiftBag> lpkGiftBags = lpkGiftBagService.list(new QueryWrapper<LpkGiftBag>());
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
// for (LpkGiftBag lpkGiftBag : lpkGiftBags) {
// int in = DateUtil.parse(sdf.format(lpkGiftBag.getDateEnd())).compareTo(DateUtil.parse(sdf.format(new Date())));
// if (String.valueOf(in).equals("-1")) {
// Integer i = baseMapper.selectCount(new QueryWrapper<LpkGiftCard>().eq("giftbagSid", lpkGiftBag.getSid()).ne("state", "5"));
// if (i != 0) {
// baseMapper.updateIsItInvalid(lpkGiftBag.getSid(), "5");
// }
// } else {
// List<LpkGiftCard> list = baseMapper.selectList(new QueryWrapper<LpkGiftCard>().eq("customerSid", customerSid).eq("giftbagSid", lpkGiftBag.getSid()));
// for (LpkGiftCard card : list) {
// LpkReserveOrderVo LpkReserveOrderVo = lpkReserveOrderService.selByCardSid(card.getSid()).getData();
// if (null != LpkReserveOrderVo) {
// int c = DateUtil.parse(sdf.format(LpkReserveOrderVo.getReserveDate())).compareTo(DateUtil.parse(sdf.format(new Date())));
//// LpkGiftCard card1 = baseMapper.selectOne(new QueryWrapper<LpkGiftCard>().eq("sid", card.getSid()));
// if (String.valueOf(c).equals("-1")) {
// card.setIsReservation("1");
// baseMapper.updateById(card);
// }
// }
// }
// }
// }
//
//// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//// List<LpkGiftBag> lpkGiftBags = lpkGiftBagService.list(new QueryWrapper<LpkGiftBag>().lt("dateEnd", sdf.format(new Date())));
//// for (LpkGiftBag lpkGiftBag : lpkGiftBags) {
//// Integer i = baseMapper.selectCount(new QueryWrapper<LpkGiftCard>().eq("giftbagSid", lpkGiftBag.getSid()).ne("state", "5"));
//// if (i != 0) {
//// baseMapper.updateIsItInvalid(lpkGiftBag.getSid(), "5");
//// }
//// }
// return rb.success();
}
}
Loading…
Cancel
Save