|
|
@ -7,9 +7,13 @@ 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.LpkGiftCardMapper; |
|
|
|
import com.yxt.yyth.biz.lpkgiftcard.LpkGiftCardService; |
|
|
|
import com.yxt.yyth.biz.lpkreserveorder.LpkReserveOrderService; |
|
|
|
import org.junit.Test; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.Date; |
|
|
@ -19,48 +23,49 @@ import java.util.List; |
|
|
|
* @author wangpengfei |
|
|
|
* @date 2023/12/20 10:44 |
|
|
|
*/ |
|
|
|
|
|
|
|
@RestController |
|
|
|
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();
|
|
|
|
LpkGiftCardMapper lpkGiftCardMapper; |
|
|
|
@Autowired |
|
|
|
LpkReserveOrderService lpkReserveOrderService; |
|
|
|
@Scheduled(cron = "0 0 1 * * ? ") |
|
|
|
public void updateIsItInvalid() { |
|
|
|
List<LpkGiftBag> lpkGiftBags = lpkGiftBagService.list(new QueryWrapper<LpkGiftBag>().eq("isSel","1")); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
for (LpkGiftBag lpkGiftBag : lpkGiftBags) { |
|
|
|
//1>2 1 、1<2 -1 、1=2 0
|
|
|
|
int in = DateUtil.parse(sdf.format(lpkGiftBag.getDateEnd())).compareTo(DateUtil.parse(sdf.format(new Date()))); |
|
|
|
if (String.valueOf(in).equals("-1")) { |
|
|
|
Integer i = lpkGiftCardMapper.selectCount(new QueryWrapper<LpkGiftCard>().eq("giftbagSid", lpkGiftBag.getSid()).ne("state", "5")); |
|
|
|
if (i != 0) { |
|
|
|
lpkGiftBag.setIsSel("2"); |
|
|
|
lpkGiftBagService.updateById(lpkGiftBag); |
|
|
|
lpkGiftCardMapper.updateIsItInvalid(lpkGiftBag.getSid(), "5"); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// List<LpkGiftCard> list = lpkGiftCardMapper.selectList(new QueryWrapper<LpkGiftCard>().eq("customerSid", customerSid).eq("giftbagSid", lpkGiftBag.getSid()));
|
|
|
|
List<LpkGiftCard> list = lpkGiftCardMapper.selectList(new QueryWrapper<LpkGiftCard>().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()))); |
|
|
|
if (String.valueOf(c).equals("-1")) { |
|
|
|
if(card.getState().equals("5")){ |
|
|
|
card.setIsItInvalid("1"); |
|
|
|
} |
|
|
|
card.setIsReservation("1"); |
|
|
|
lpkGiftCardMapper.updateById(card); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// @Scheduled(cron = "0/1 * * * * ?")
|
|
|
|
// public void test() {
|
|
|
|
// System.out.println("执行");
|
|
|
|
// }
|
|
|
|
} |
|
|
|