积分模块相关代码

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

@@ -2,6 +2,7 @@ package com.chaozhanggui.system.cashierservice.controller;
import com.chaozhanggui.system.cashierservice.entity.TbPointsGoodsSetting;
import com.chaozhanggui.system.cashierservice.service.TbPointsGoodsSettingService;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;
@@ -40,7 +41,7 @@ public class TbPointsGoodsSettingController {
* @return
*/
@GetMapping("{id}")
public Result get(@PathVariable("id") Integer id) {
public Result get(@PathVariable("id") Long id) {
TbPointsGoodsSetting data = tbPointsGoodsSettingService.getById(id);
return Result.successWithData(data);
}
@@ -66,4 +67,15 @@ public class TbPointsGoodsSettingController {
boolean ret = tbPointsGoodsSettingService.update(dto);
return Result.successWithData(ret);
}
/**
* 删除
* @param id
* @return
*/
@DeleteMapping("{id}")
public Result delete(@PathVariable("id") Long id) {
tbPointsGoodsSettingService.delete(id);
return Result.success(CodeEnum.SUCCESS);
}
}

View File

@@ -63,6 +63,10 @@ public class TbPointsGoodsSetting {
*/
@TableField(value = "goods_description", updateStrategy = FieldStrategy.IGNORED)
private String goodsDescription;
/**
* 累计兑换数量
*/
private Integer totalExchangeCount;
/**
* 是否上架 1-是 0-否
*/
@@ -75,4 +79,8 @@ public class TbPointsGoodsSetting {
* 更新时间
*/
private Date updateTime;
/**
* 逻辑删除标志 1-是 0-否
*/
private Integer delFlag;
}

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));
}
}