|
|
@@ -9,8 +9,11 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import org.apache.poi.ss.formula.functions.Now;
|
|
|
+import org.dromara.common.core.constant.CacheNames;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
+import org.dromara.common.json.utils.JsonUtils;
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
import org.dromara.server.consume.domain.XfCardLimited;
|
|
|
@@ -18,11 +21,14 @@ import org.dromara.server.consume.domain.bo.XfCardLimitedBo;
|
|
|
import org.dromara.server.consume.domain.vo.XfCardLimitedVo;
|
|
|
import org.dromara.server.consume.mapper.XfCardLimitedMapper;
|
|
|
import org.dromara.server.consume.service.IXfCardLimitedService;
|
|
|
+import org.springframework.cache.annotation.CachePut;
|
|
|
+import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.Collection;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -295,8 +301,8 @@ public class XfCardLimitedServiceImpl implements IXfCardLimitedService {
|
|
|
XfCardLimitedVo vo = this.queryByCardNo(cardNo);
|
|
|
if (ObjUtil.isNotEmpty(vo)) {
|
|
|
LambdaUpdateWrapper<XfCardLimited> luw = new LambdaUpdateWrapper<>();
|
|
|
- luw.set(XfCardLimited::getDayDiscountCount, vo.getDayDiscountCount()+1);
|
|
|
- luw.set(XfCardLimited::getMealDiscountCount, vo.getMealDiscountCount()+1);
|
|
|
+ luw.set(XfCardLimited::getDayDiscountCount, vo.getDayDiscountCount() + 1);
|
|
|
+ luw.set(XfCardLimited::getMealDiscountCount, vo.getMealDiscountCount() + 1);
|
|
|
|
|
|
luw.eq(XfCardLimited::getCardNo, cardNo);
|
|
|
return baseMapper.update(null, luw) > 0;
|
|
|
@@ -309,7 +315,7 @@ public class XfCardLimitedServiceImpl implements IXfCardLimitedService {
|
|
|
public void insertOrUpdate(XfCardLimitedBo bo) {
|
|
|
XfCardLimited entity = MapstructUtils.convert(bo, XfCardLimited.class);
|
|
|
XfCardLimited temp = baseMapper.selectOne(new LambdaQueryWrapper<XfCardLimited>().eq(XfCardLimited::getCardNo, bo.getCardNo()));
|
|
|
- if(ObjUtil.isNotEmpty(temp)){
|
|
|
+ if (ObjUtil.isNotEmpty(temp)) {
|
|
|
entity.setLimitedId(temp.getLimitedId());
|
|
|
baseMapper.updateById(entity);
|
|
|
} else {
|
|
|
@@ -320,9 +326,45 @@ public class XfCardLimitedServiceImpl implements IXfCardLimitedService {
|
|
|
@Override
|
|
|
public void updateByVo(XfCardLimitedVo vo) {
|
|
|
XfCardLimited entity = MapstructUtils.convert(vo, XfCardLimited.class);
|
|
|
- LambdaUpdateWrapper<XfCardLimited> luw = new LambdaUpdateWrapper<XfCardLimited>()
|
|
|
- .eq(XfCardLimited::getCardNo, vo.getCardNo());
|
|
|
- baseMapper.update(entity, luw);
|
|
|
+ XfCardLimitedVo limitedVo = queryByCardNo(vo.getCardNo());
|
|
|
+ if (limitedVo != null) {
|
|
|
+ LambdaUpdateWrapper<XfCardLimited> luw = new LambdaUpdateWrapper<XfCardLimited>()
|
|
|
+ .eq(XfCardLimited::getCardNo, vo.getCardNo());
|
|
|
+ baseMapper.update(entity, luw);
|
|
|
+ } else {
|
|
|
+ baseMapper.insert(entity);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @CachePut(cacheNames = CacheNames.T_XF_CARD_LIMITED, key = "#vo.cardNo")
|
|
|
+ public String cacheLimitedAndOther(XfCardLimitedVo vo) {
|
|
|
+ return JsonUtils.toJsonString(vo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Cacheable(cacheNames = CacheNames.T_XF_CARD_LIMITED, key = "#cardNo", unless = "#result == null")
|
|
|
+ public String getLimitedAndOtherByNo(Long cardNo) {
|
|
|
+ XfCardLimitedVo vo = queryByCardNo(cardNo);
|
|
|
+ if (vo == null) {
|
|
|
+ vo = initXfCardLimited(cardNo);
|
|
|
+ }
|
|
|
+ return JsonUtils.toJsonString(vo);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static XfCardLimitedVo initXfCardLimited(Long cardNo) {
|
|
|
+ XfCardLimitedVo vo = new XfCardLimitedVo();
|
|
|
+ vo.setCardNo(cardNo);
|
|
|
+ vo.setDayCount(0L);
|
|
|
+ vo.setDayMoney(BigDecimal.ZERO);
|
|
|
+ vo.setMealCount(0L);
|
|
|
+ vo.setMealMoney(BigDecimal.ZERO);
|
|
|
+ vo.setDayDiscountCount(0L);
|
|
|
+ vo.setMealDiscountCount(0L);
|
|
|
+ vo.setLastPay(new Date());
|
|
|
+ vo.setLastMeal(0L);
|
|
|
|
|
|
+ return vo;
|
|
|
}
|
|
|
}
|