|
|
@ -1,6 +1,7 @@ |
|
|
|
package com.yxt.yyth.biz.lpkgiftcard; |
|
|
|
|
|
|
|
import cn.hutool.core.date.DateTime; |
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import cn.hutool.core.img.ImgUtil; |
|
|
|
import cn.hutool.extra.qrcode.QrCodeUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
@ -18,6 +19,7 @@ import com.yxt.yyth.api.lpkcardgrantrecord.LpkCardGrantRecordDto; |
|
|
|
import com.yxt.yyth.api.lpkgiftbag.LpkGiftBag; |
|
|
|
import com.yxt.yyth.api.lpkgiftbaggoods.LpkGiftBagGoodsVo; |
|
|
|
import com.yxt.yyth.api.lpkgiftcard.*; |
|
|
|
import com.yxt.yyth.api.lpkreserveorder.LpkReserveOrder; |
|
|
|
import com.yxt.yyth.api.lpkreserveorder.LpkReserveOrderVo; |
|
|
|
import com.yxt.yyth.api.lpkreserveordergoods.LpkReserveOrderGoods; |
|
|
|
import com.yxt.yyth.api.lpkstore.LpkStoreDetailsVo; |
|
|
@ -73,11 +75,11 @@ public class LpkGiftCardService extends MybatisBaseService<LpkGiftCardMapper, Lp |
|
|
|
ResultBean rb = new ResultBean().fail(); |
|
|
|
LpkGiftCard lpkGiftCard = baseMapper.selectOne(new QueryWrapper<LpkGiftCard>().eq("code", bindCardDto.getCode()) |
|
|
|
.eq("codeKey", bindCardDto.getCodeKey())); |
|
|
|
AppletVo vo = baseMapper.getGifCardBySid(lpkGiftCard.getSid()); |
|
|
|
if (null == lpkGiftCard) { |
|
|
|
return rb.setMsg("请核对卡号和密钥"); |
|
|
|
} |
|
|
|
if (vo.getState().equals("失效")) { |
|
|
|
AppletVo vo = baseMapper.getGifCardBySid(lpkGiftCard.getSid()); |
|
|
|
if (vo.getState().equals("已过期")) { |
|
|
|
return rb.setMsg("该卡已过期"); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(lpkGiftCard.getCustomerSid())) { |
|
|
@ -94,7 +96,7 @@ public class LpkGiftCardService extends MybatisBaseService<LpkGiftCardMapper, Lp |
|
|
|
ResultBean rb = new ResultBean().fail(); |
|
|
|
LpkGiftCardQuery query = pq.getParams(); |
|
|
|
QueryWrapper<LpkGiftCard> qw = new QueryWrapper<>(); |
|
|
|
updateIsItInvalid(); |
|
|
|
updateIsItInvalid(query.getCustomerSid()); |
|
|
|
if (StringUtils.isNotBlank(query.getCustomerSid())) { |
|
|
|
qw.eq("customerSid", query.getCustomerSid()); |
|
|
|
} |
|
|
@ -104,17 +106,53 @@ public class LpkGiftCardService extends MybatisBaseService<LpkGiftCardMapper, Lp |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
return rb.success().setData(p); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean updateIsItInvalid() { |
|
|
|
// public ResultBean updateIsItInvalid() {
|
|
|
|
// ResultBean rb = new ResultBean();
|
|
|
|
// 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 updateIsItInvalid(String customerSid) { |
|
|
|
ResultBean rb = new ResultBean(); |
|
|
|
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) { |
|
|
|
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")){ |
|
|
|
card1.setIsReservation("1"); |
|
|
|
baseMapper.updateById(card1); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 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(); |
|
|
|
} |
|
|
|
|
|
|
@ -125,7 +163,7 @@ public class LpkGiftCardService extends MybatisBaseService<LpkGiftCardMapper, Lp |
|
|
|
List<GoodsVo> goodsVos = new ArrayList<>(); |
|
|
|
list.forEach(s -> { |
|
|
|
LpkReserveOrderGoods goods = lpkReserveOrderGoodsService.getReserveByCardSid(vo.getSid(), s.getGoodsSid()).getData(); |
|
|
|
if (vo.getState().equals("失效")) { |
|
|
|
if (vo.getState().equals("已过期")) { |
|
|
|
GoodsVo goodsVo = new GoodsVo(); |
|
|
|
goodsVo.setGoods(s.getGoodsName()); |
|
|
|
goodsVo.setNum(s.getGoodsNumber()); |
|
|
|