积分模块相关代码

This commit is contained in:
谭凯凯
2024-10-31 10:27:47 +08:00
committed by Tankaikai
parent 1e9d7c84c3
commit 2d82ec84d6
5 changed files with 35 additions and 1 deletions

View File

@@ -20,4 +20,6 @@ public interface TbPointsGoodsSettingService extends IService<TbPointsGoodsSetti
boolean update(TbPointsGoodsSetting dto);
void delete(Long id);
}

View File

@@ -126,6 +126,9 @@ public class TbPointsExchangeRecordServiceImpl extends ServiceImpl<TbPointsExcha
if (goods == null) {
throw new MsgException("兑换的商品信息不存在");
}
if (goods.getDelFlag() == 1) {
throw new MsgException("兑换的商品信息不存在");
}
record.setPointsGoodsName(goods.getGoodsName());
record.setGoodsImageUrl(goods.getGoodsImageUrl());
@@ -178,6 +181,10 @@ public class TbPointsExchangeRecordServiceImpl extends ServiceImpl<TbPointsExcha
log.setFloatPoints(-requiredPoints);
log.setCreateTime(new Date());
tbMemberPointsLogMapper.insert(log);
// 更新累计兑换数量
goods.setTotalExchangeCount(goods.getTotalExchangeCount() + 1);
goods.setUpdateTime(new Date());
tbPointsGoodsSettingMapper.updateById(goods);
return record;
}

View File

@@ -92,4 +92,9 @@ public class TbPointsGoodsSettingServiceImpl extends ServiceImpl<TbPointsGoodsSe
entity.setUpdateTime(new Date());
return super.updateById(entity);
}
@Override
public void delete(Long id) {
super.update(Wrappers.<TbPointsGoodsSetting>lambdaUpdate().set(TbPointsGoodsSetting::getDelFlag, 1).eq(TbPointsGoodsSetting::getId, id));
}
}