| | |
| | | |
| | | @Override |
| | | public FootPrint saveFootprint(FootPrint footPrint) { |
| | | LambdaQueryWrapper<FootPrint> queryWrapper = Wrappers.lambdaQuery(); |
| | | queryWrapper.eq(FootPrint::getMemberId, footPrint.getMemberId()); |
| | | queryWrapper.eq(FootPrint::getGoodsId, footPrint.getGoodsId()); |
| | | //如果已存在某商品记录,则更新其修改时间 |
| | | //如果不存在则添加记录 |
| | | //为了保证足迹的排序,将原本足迹删除后重新添加 |
| | | List<FootPrint> oldPrints = list(queryWrapper); |
| | | if (oldPrints != null && !oldPrints.isEmpty()) { |
| | | FootPrint oldPrint = oldPrints.get(0); |
| | | this.removeById(oldPrint.getId()); |
| | | } |
| | | footPrint.setCreateTime(new Date()); |
| | | this.save(footPrint); |
| | | //删除超过100条后的记录 |
| | | this.baseMapper.deleteLastFootPrint(footPrint.getMemberId()); |
| | | return footPrint; |
| | | } |
| | | |
| | |
| | | public boolean deleteByIds(List<String> ids) { |
| | | LambdaQueryWrapper<FootPrint> lambdaQueryWrapper = Wrappers.lambdaQuery(); |
| | | lambdaQueryWrapper.eq(FootPrint::getMemberId, UserContext.getCurrentUser().getId()); |
| | | lambdaQueryWrapper.in(FootPrint::getGoodsId, ids); |
| | | lambdaQueryWrapper.in(FootPrint::getRefId, ids); |
| | | return this.remove(lambdaQueryWrapper); |
| | | } |
| | | |
| | |
| | | lambdaQueryWrapper.eq(FootPrint::getDeleteFlag, false); |
| | | return this.count(lambdaQueryWrapper); |
| | | } |
| | | } |
| | | } |