Commit 7109b0ae authored by 万成波's avatar 万成波

积分模块

parent 776895b4
......@@ -84,7 +84,7 @@ public class BbsUserPointsController extends BaseController {
@PreAuthorize("@ss.hasPermi('points:points:incr')")
@Log(title = "用户积分", businessType = BusinessType.UPDATE)
@PutMapping("/incr")
public AjaxResult incrUserPoints(@RequestBody BbsUserPoints points) {
public synchronized AjaxResult incrUserPoints(@RequestBody BbsUserPoints points) {
this.bbsUserPointsService.addUserPoints(points);
return AjaxResult.success();
}
......@@ -97,7 +97,7 @@ public class BbsUserPointsController extends BaseController {
@PreAuthorize("@ss.hasPermi('points:points:decr')")
@Log(title = "用户积分", businessType = BusinessType.UPDATE)
@PutMapping("/decr")
public AjaxResult decrUserPoints(@RequestBody BbsUserPoints points) {
public synchronized AjaxResult decrUserPoints(@RequestBody BbsUserPoints points) {
this.bbsUserPointsService.deleteUserPoints(points);
return AjaxResult.success();
}
......
package com.tangguo.controller;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tangguo.common.annotation.Log;
import com.tangguo.common.core.controller.BaseController;
import com.tangguo.common.core.domain.AjaxResult;
import com.tangguo.common.core.page.TableDataInfo;
import com.tangguo.common.enums.BusinessType;
import com.tangguo.common.utils.poi.ExcelUtil;
import com.tangguo.domain.BbsPointsGoods;
import com.tangguo.domain.BbsUserPointsExchange;
import com.tangguo.domain.vo.QwmhSysUserVO;
import com.tangguo.mapper.BbsUserPointsExchangeMapper;
import com.tangguo.service.IBbsPointsGoodsService;
import com.tangguo.service.IBbsUserPointsExchangeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -14,8 +20,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;
/**
......@@ -29,81 +33,68 @@ import java.util.List;
@RequestMapping("/bbs/points/exchange")
public class BbsUserPointsExchangeController extends BaseController {
@Resource
private BbsUserPointsExchangeMapper userPointsExchangeMapper;
@Resource
private IBbsUserPointsExchangeService bbsUserPointsExchangeService;
@Resource
private IBbsPointsGoodsService pointsGoodsService;
/**
* 查询用户积分兑换列表
* 查询兑换人
*/
@ApiOperation("查询用户积分兑换列表")
@ApiOperation("查询兑换人")
@PreAuthorize("@ss.hasPermi('points:points:list')")
@GetMapping("/list")
public TableDataInfo list(BbsUserPointsExchange bbsUserPointsExchange) {
startPage();
List<BbsUserPointsExchange> list = bbsUserPointsExchangeService.selectBbsUserPointsExchangeList(bbsUserPointsExchange);
return getDataTable(list);
@GetMapping("/select/users")
public AjaxResult selectUsers(String keyword) {
List<QwmhSysUserVO> users = this.userPointsExchangeMapper.selectPointsUsers(keyword);
return AjaxResult.success(users);
}
/**
* 导出用户积分兑换列表
* 查询兑换商品
*/
@ApiOperation("导出用户积分兑换列表")
@PreAuthorize("@ss.hasPermi('points:points:export')")
@Log(title = "用户积分兑换", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, BbsUserPointsExchange bbsUserPointsExchange) {
List<BbsUserPointsExchange> list = bbsUserPointsExchangeService.selectBbsUserPointsExchangeList(bbsUserPointsExchange);
ExcelUtil<BbsUserPointsExchange> util = new ExcelUtil<BbsUserPointsExchange>(BbsUserPointsExchange.class);
util.exportExcel(response, list, "用户积分兑换数据");
@ApiOperation("查询兑换人")
@PreAuthorize("@ss.hasPermi('points:points:list')")
@GetMapping("/select/goods")
public AjaxResult selectGoods(String keyword) {
LambdaQueryWrapper<BbsPointsGoods> wrapper = new LambdaQueryWrapper<>();
wrapper.like(StrUtil.isNotBlank(keyword), BbsPointsGoods::getName, keyword);
wrapper.or();
wrapper.like(StrUtil.isNotBlank(keyword), BbsPointsGoods::getCode, keyword);
wrapper.orderByDesc(BbsPointsGoods::getCreateTime);
List<BbsPointsGoods> goods = this.pointsGoodsService.list(wrapper);
return AjaxResult.success(goods);
}
/**
* 获取用户积分兑换详细信息
* 查询用户积分兑换列表
*/
@ApiOperation("获取用户积分兑换详细信息")
@PreAuthorize("@ss.hasPermi('points:points:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(bbsUserPointsExchangeService.getById(id));
@ApiOperation("查询用户积分兑换列表")
@PreAuthorize("@ss.hasPermi('points:points:list')")
@GetMapping("/list")
public TableDataInfo list(BbsUserPointsExchange exchange) {
startPage();
List<BbsUserPointsExchange> list = bbsUserPointsExchangeService.selectBbsUserPointsExchangeList(exchange);
return getDataTable(list);
}
/**
* 新增用户积分兑换
* 用户积分兑换
*/
@ApiOperation("新增用户积分兑换")
@PreAuthorize("@ss.hasPermi('points:points:add')")
@ApiOperation("用户积分兑换")
@PreAuthorize("@ss.hasPermi('points:points:exchange')")
@Log(title = "用户积分兑换", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody BbsUserPointsExchange bbsUserPointsExchange) {
return toAjax(bbsUserPointsExchangeService.save(bbsUserPointsExchange));
}
/**
* 修改用户积分兑换
*/
@ApiOperation("修改用户积分兑换")
@PreAuthorize("@ss.hasPermi('points:points:edit')")
@Log(title = "用户积分兑换", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody BbsUserPointsExchange bbsUserPointsExchange) {
return toAjax(bbsUserPointsExchangeService.updateById(bbsUserPointsExchange));
}
/**
* 删除用户积分兑换
*/
@ApiOperation("删除用户积分兑换")
@PreAuthorize("@ss.hasPermi('points:points:remove')")
@Log(title = "用户积分兑换", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(bbsUserPointsExchangeService.removeByIds(Arrays.asList(ids)));
@PostMapping("/exchange")
public synchronized AjaxResult exchange(@RequestBody BbsUserPointsExchange exchange) {
this.bbsUserPointsExchangeService.addUserPointsExchange(exchange);
return AjaxResult.success();
}
}
package com.tangguo.domain.dto;
import lombok.Data;
/**
* 积分明细DTO
*
* @author 谈笑
* @createTime 2025-08-29 17:23:29 星期五
*/
@Data
public class PointsDetailDTO {
/**
* 明细名称
*/
private String detailName;
/**
* 明细编码
*/
private String detailCode;
/**
* 明细积分
*/
private Integer detailPoints;
/**
* 明细说明
*/
private String description;
}
package com.tangguo.domain.vo;
import com.tangguo.common.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 企微门户用户VO
*
* @author 谈笑
* @createTime 2025-08-29 16:13:32 星期五
*/
@Data
public class QwmhSysUserVO {
/**
* 用户Id
*/
private String userId;
/**
* 用户名
*/
private String userName;
/**
* 用户姓名
*/
private String nikeName;
/**
* 部门名称
*/
private String deptName;
/**
* 用户等级
*/
private String gradeName;
/**
* 当前积分
*/
private Integer currentPoints;
/**
* 累计积分
*/
private Integer accumulatedPoints;
}
......@@ -2,6 +2,7 @@ package com.tangguo.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tangguo.domain.BbsPointsGoods;
import org.apache.ibatis.annotations.Param;
/**
* 积分商品Mapper接口
......@@ -10,4 +11,10 @@ import com.tangguo.domain.BbsPointsGoods;
* @date 2025-08-28
*/
public interface BbsPointsGoodsMapper extends BaseMapper<BbsPointsGoods> {
int decrGoodsStock(@Param("goodsId") long goodsId, @Param("goodsNum") int goodsNum);
int incrGoodsSales(@Param("goodsId") long goodsId, @Param("goodsNum") int goodsNum);
}
......@@ -2,6 +2,10 @@ package com.tangguo.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tangguo.domain.BbsUserPointsExchange;
import com.tangguo.domain.vo.QwmhSysUserVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 用户积分兑换Mapper接口
......@@ -10,4 +14,10 @@ import com.tangguo.domain.BbsUserPointsExchange;
* @date 2025-08-29
*/
public interface BbsUserPointsExchangeMapper extends BaseMapper<BbsUserPointsExchange> {
List<QwmhSysUserVO> selectPointsUsers(@Param("keyword") String keyword);
List<BbsUserPointsExchange> selectBbsUserPointsExchangeList(@Param("exchange") BbsUserPointsExchange exchange);
}
......@@ -2,6 +2,7 @@ package com.tangguo.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tangguo.domain.BbsUserPoints;
import com.tangguo.domain.vo.QwmhSysUserVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......
......@@ -45,4 +45,32 @@ public interface IBbsPointsGoodsService extends IService<BbsPointsGoods> {
*/
void deleteGoods(Long goodsId);
/**
* 查询积分商品
*
* @param goodsCode 商品编码
* @return 商品
*/
BbsPointsGoods getByGoodsCode(String goodsCode);
/**
* 扣减积分商品库存数量
*
* @param goodsId 商品Id
* @param goodsNum 商品数量
* @return
*/
boolean decrGoodsStock(long goodsId, int goodsNum);
/**
* 扣减积分商品库存数量
*
* @param goodsId 商品Id
* @param goodsNum 商品数量
*/
void incrGoodsSales(long goodsId, int goodsNum);
}
......@@ -19,6 +19,14 @@ public interface IBbsUserPointsExchangeService extends IService<BbsUserPointsExc
* @param bbsUserPointsExchange 用户积分兑换
* @return 用户积分兑换集合
*/
List<BbsUserPointsExchange> selectBbsUserPointsExchangeList(BbsUserPointsExchange bbsUserPointsExchange);
List<BbsUserPointsExchange> selectBbsUserPointsExchangeList(BbsUserPointsExchange bbsUserPointsExchange);
/**
* 添加用户积分兑换记录
*
* @param exchange 兑换
*/
void addUserPointsExchange(BbsUserPointsExchange exchange);
}
......@@ -3,6 +3,7 @@ package com.tangguo.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.tangguo.domain.BbsUserPoints;
import com.tangguo.domain.BbsUserPointsDetail;
import com.tangguo.domain.dto.PointsDetailDTO;
import java.util.List;
......@@ -39,7 +40,7 @@ public interface IBbsUserPointsService extends IService<BbsUserPoints> {
* @param points 积分
* @param detail 积分明细
*/
void incrUserPoints(String userName, int points, BbsUserPointsDetail detail);
void incrUserPoints(String userName, int points, PointsDetailDTO detail);
/**
......@@ -49,7 +50,7 @@ public interface IBbsUserPointsService extends IService<BbsUserPoints> {
* @param points 积分
* @param detail 积分明细
*/
void decrUserPoints(String userName, int points, BbsUserPointsDetail detail);
void decrUserPoints(String userName, int points, PointsDetailDTO detail);
/**
......
......@@ -10,6 +10,7 @@ import com.tangguo.domain.BbsPointsGoods;
import com.tangguo.mapper.BbsPointsGoodsMapper;
import com.tangguo.service.IBbsPointsGoodsService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
......@@ -64,6 +65,10 @@ public class BbsPointsGoodsServiceImpl extends ServiceImpl<BbsPointsGoodsMapper,
throw new ServiceException("添加失败,当前商品名称已存在。");
}
if (goods.getStockNum() < 0) {
throw new ServiceException("增加失败,商品库存数量不能小于0。");
}
BbsPointsGoods addGoods = new BbsPointsGoods();
addGoods.setName(goods.getName());
addGoods.setCode(IdUtil.fastSimpleUUID());
......@@ -89,6 +94,10 @@ public class BbsPointsGoodsServiceImpl extends ServiceImpl<BbsPointsGoodsMapper,
throw new ServiceException("修改失败,未查询到当前商品数据。");
}
if (goods.getStockNum() < 0) {
throw new ServiceException("修改失败,商品库存数量不能小于0。");
}
if (!dbGoods.getName().equals(goods.getName())) {
long nameCount = this.count(
Wrappers.lambdaQuery(BbsPointsGoods.class).eq(BbsPointsGoods::getName, goods.getName())
......@@ -120,4 +129,45 @@ public class BbsPointsGoodsServiceImpl extends ServiceImpl<BbsPointsGoodsMapper,
this.removeById(goodsId);
}
/**
* 查询积分商品
*
* @param goodsCode 商品编码
* @return 商品
*/
@Override
public BbsPointsGoods getByGoodsCode(String goodsCode) {
return this.getOne(
Wrappers.lambdaQuery(BbsPointsGoods.class).eq(BbsPointsGoods::getCode, goodsCode)
);
}
/**
* 扣减积分商品库存数量
*
* @param goodsId 商品Id
* @param goodsNum 商品数量
* @return 扣减结果
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean decrGoodsStock(long goodsId, int goodsNum) {
return this.baseMapper.decrGoodsStock(goodsId, goodsNum) > 0;
}
/**
* 扣减积分商品库存数量
*
* @param goodsId 商品Id
* @param goodsNum 商品数量
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void incrGoodsSales(long goodsId, int goodsNum) {
this.baseMapper.incrGoodsSales(goodsId, goodsNum);
}
}
package com.tangguo.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tangguo.common.utils.StringUtils;
import com.tangguo.common.exception.ServiceException;
import com.tangguo.domain.BbsPointsGoods;
import com.tangguo.domain.BbsUserPoints;
import com.tangguo.domain.BbsUserPointsDetail;
import com.tangguo.domain.BbsUserPointsExchange;
import com.tangguo.domain.dto.PointsDetailDTO;
import com.tangguo.mapper.BbsUserPointsExchangeMapper;
import com.tangguo.service.IBbsPointsGoodsService;
import com.tangguo.service.IBbsUserPointsExchangeService;
import com.tangguo.service.IBbsUserPointsService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* 用户积分兑换Service业务层处理
......@@ -25,30 +30,78 @@ public class BbsUserPointsExchangeServiceImpl extends ServiceImpl<BbsUserPointsE
@Resource
private BbsUserPointsExchangeMapper bbsUserPointsExchangeMapper;
@Resource
private IBbsUserPointsService userPointsService;
@Resource
private IBbsPointsGoodsService pointsGoodsService;
/**
* 查询用户积分兑换列表
*
* @param bbsUserPointsExchange 用户积分兑换
* @param exchange 用户积分兑换
* @return 用户积分兑换
*/
@Override
public List<BbsUserPointsExchange> selectBbsUserPointsExchangeList(BbsUserPointsExchange bbsUserPointsExchange) {
return bbsUserPointsExchangeMapper.selectList(buildQueryWrapper(bbsUserPointsExchange));
public List<BbsUserPointsExchange> selectBbsUserPointsExchangeList(BbsUserPointsExchange exchange) {
return this.baseMapper.selectBbsUserPointsExchangeList(exchange);
}
private LambdaQueryWrapper<BbsUserPointsExchange> buildQueryWrapper(BbsUserPointsExchange query) {
Map<String, Object> params = query.getParams();
LambdaQueryWrapper<BbsUserPointsExchange> lqw = Wrappers.lambdaQuery();
lqw.orderByDesc(BbsUserPointsExchange::getCreateTime);
lqw.like(StringUtils.isNotBlank(query.getNikeName()), BbsUserPointsExchange::getNikeName, query.getNikeName());
lqw.like(StringUtils.isNotBlank(query.getUserName()), BbsUserPointsExchange::getUserName, query.getUserName());
lqw.like(StringUtils.isNotBlank(query.getUserGradeName()), BbsUserPointsExchange::getUserGradeName, query.getUserGradeName());
lqw.like(StringUtils.isNotBlank(query.getGoodsName()), BbsUserPointsExchange::getGoodsName, query.getGoodsName());
lqw.eq(StringUtils.isNotBlank(query.getGoodsCode()), BbsUserPointsExchange::getGoodsCode, query.getGoodsCode());
lqw.eq(query.getGoodsExchangePoints() != null, BbsUserPointsExchange::getGoodsExchangePoints, query.getGoodsExchangePoints());
lqw.eq(query.getUserRemainingPoints() != null, BbsUserPointsExchange::getUserRemainingPoints, query.getUserRemainingPoints());
return lqw;
/**
* 添加用户积分兑换记录
*
* @param exchange 兑换
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void addUserPointsExchange(BbsUserPointsExchange exchange) {
// 积分商品校验
BbsPointsGoods dbGoods = this.pointsGoodsService.getByGoodsCode(exchange.getGoodsCode());
if (Objects.isNull(dbGoods)) {
throw new ServiceException("兑换失败,未查询到当前兑换的商品数据。");
}
if (dbGoods.getStockNum() < 1) {
throw new ServiceException("兑换失败,当前兑换的商品库存数量不足。");
}
// 用户积分校验
String userName = exchange.getUserName();
Integer exchangePoints = dbGoods.getExchangePoints();
BbsUserPoints dbUserPoints = this.userPointsService.getUserPoints(userName);
int currentPoints = dbUserPoints.getCurrentPoints() - dbGoods.getExchangePoints();
if (currentPoints < 0) {
throw new ServiceException("兑换失败,当前用户可用积分不足。");
}
// 扣减商品库存
Long goodsId = dbGoods.getId();
boolean decrResult = this.pointsGoodsService.decrGoodsStock(goodsId, 1);
if (!decrResult) {
throw new ServiceException("兑换失败,当前兑换的商品库存数量不足。");
}
// 增加商品销量
this.pointsGoodsService.incrGoodsSales(goodsId, 1);
// 扣减用户积分
PointsDetailDTO detail = new PointsDetailDTO();
detail.setDetailName(dbGoods.getName());
detail.setDetailCode(dbGoods.getCode());
detail.setDescription(String.format("用户【%s】兑换积分商品【%s-%s】", userName, dbGoods.getName(), dbGoods.getCode()));
this.userPointsService.decrUserPoints(userName, exchangePoints, detail);
// 添加兑换记录
BbsUserPointsExchange addExchange = new BbsUserPointsExchange();
addExchange.setNikeName(exchange.getNikeName());
addExchange.setUserName(exchange.getUserName());
addExchange.setUserGradeName(exchange.getUserGradeName());
addExchange.setGoodsName(dbGoods.getName());
addExchange.setGoodsCode(dbGoods.getCode());
addExchange.setGoodsExchangePoints(dbGoods.getExchangePoints());
addExchange.setUserRemainingPoints(currentPoints);
this.save(addExchange);
}
}
......@@ -6,13 +6,13 @@ import com.tangguo.common.exception.ServiceException;
import com.tangguo.common.utils.SecurityUtils;
import com.tangguo.domain.BbsUserPoints;
import com.tangguo.domain.BbsUserPointsDetail;
import com.tangguo.domain.dto.PointsDetailDTO;
import com.tangguo.mapper.BbsUserPointsMapper;
import com.tangguo.service.IBbsUserPointsDetailService;
import com.tangguo.service.IBbsUserPointsService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionTemplate;
import javax.annotation.Resource;
import java.util.List;
......@@ -78,7 +78,7 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void incrUserPoints(String userName, int points, BbsUserPointsDetail detail) {
public void incrUserPoints(String userName, int points, PointsDetailDTO detail) {
if (points < 1) {
throw new ServiceException("增加用户积分失败,增加的积分分值不能小于0。");
}
......@@ -92,11 +92,15 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
this.updateById(userPoints);
// 添加用户积分明细
detail.setUserName(userName);
detail.setDetailPoints(points);
detail.setBeforePoints(currentPoints);
detail.setAfterPoints(incrCurrentPoints);
this.pointsDetailService.addUsrePointsDetail(detail);
BbsUserPointsDetail newDetail = new BbsUserPointsDetail();
newDetail.setUserName(userName);
newDetail.setDetailName(detail.getDetailName());
newDetail.setDetailCode(detail.getDetailCode());
newDetail.setDetailPoints(points);
newDetail.setBeforePoints(currentPoints);
newDetail.setAfterPoints(incrCurrentPoints);
newDetail.setDescription(detail.getDescription());
this.pointsDetailService.save(newDetail);
}
......@@ -109,7 +113,7 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void decrUserPoints(String userName, int points, BbsUserPointsDetail detail) {
public void decrUserPoints(String userName, int points, PointsDetailDTO detail) {
if (points < 1) {
throw new ServiceException("扣减用户积分失败,扣减的积分分值不能小于0。");
}
......@@ -123,15 +127,18 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
int decrCurrentPoints = currentPoints - points;
userPoints.setCurrentPoints(decrCurrentPoints);
userPoints.setAccumulatedPoints(userPoints.getAccumulatedPoints() - points);
this.updateById(userPoints);
// 添加用户积分明细
detail.setUserName(userName);
detail.setDetailPoints(points);
detail.setBeforePoints(currentPoints);
detail.setAfterPoints(decrCurrentPoints);
this.pointsDetailService.addUsrePointsDetail(detail);
BbsUserPointsDetail newDetail = new BbsUserPointsDetail();
newDetail.setUserName(userName);
newDetail.setDetailName(detail.getDetailName());
newDetail.setDetailCode(detail.getDetailCode());
newDetail.setDetailPoints(points);
newDetail.setBeforePoints(currentPoints);
newDetail.setAfterPoints(decrCurrentPoints);
newDetail.setDescription(detail.getDescription());
this.pointsDetailService.save(newDetail);
}
......@@ -144,7 +151,7 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
@Override
public void addUserPoints(BbsUserPoints points) {
String userName = points.getUserName();
BbsUserPointsDetail detail = new BbsUserPointsDetail();
PointsDetailDTO detail = new PointsDetailDTO();
detail.setDetailName("后台手动增加");
detail.setDescription(String.format("管理员【%s】后台手动增加用户【%s】积分", SecurityUtils.getUsername(), userName));
this.incrUserPoints(userName, points.getIncrOrDecrPoints(), detail);
......@@ -160,7 +167,7 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
@Override
public void deleteUserPoints(BbsUserPoints points) {
String userName = points.getUserName();
BbsUserPointsDetail detail = new BbsUserPointsDetail();
PointsDetailDTO detail = new PointsDetailDTO();
detail.setDetailName("后台手动扣减");
detail.setDescription(String.format("管理员【%s】后台手动扣减用户【%s】积分", SecurityUtils.getUsername(), userName));
this.decrUserPoints(userName, points.getIncrOrDecrPoints(), detail);
......
......@@ -3,7 +3,24 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tangguo.mapper.BbsPointsGoodsMapper">
<update id="decrGoodsStock">
UPDATE
bbs_points_goods
SET
stock_num = stock_num - #{goodsNum}
WHERE
id = #{goodsId}
</update>
<update id="incrGoodsSales">
UPDATE
bbs_points_goods
SET
sales_num = sales_num + #{goodsNum}
WHERE
id = #{goodsId}
</update>
</mapper>
......@@ -3,6 +3,56 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tangguo.mapper.BbsUserPointsExchangeMapper">
<select id="selectPointsUsers" resultType="com.tangguo.domain.vo.QwmhSysUserVO">
SELECT
uv.*,
g.grade_name,
IFNULL(p.current_points, 0) AS current_points,
IFNULL(p.accumulated_points, 0) AS accumulated_points
FROM
qwmh_sys_user_view uv
LEFT JOIN
bbs_user_grade g ON g.user_name = uv.user_name
LEFT JOIN
bbs_user_points p ON p.user_name = uv.user_name
<where>
<if test="keyword != null and keyword != ''">
nike_name LIKE CONCAT('%', #{keyword}, '%') OR user_name LIKE CONCAT('%', #{keyword}, '%')
</if>
</where>
ORDER BY
uv.user_id
</select>
<select id="selectBbsUserPointsExchangeList" resultType="com.tangguo.domain.BbsUserPointsExchange">
SELECT
e.*
FROM
bbs_user_points_exchange e
<where>
<if test="exchange.nikeName != null and exchange.nikeName != ''">
e.nike_name LIKE CONCAT('%', #{exchange.nikeName}, '%')
</if>
<if test="exchange.userName != null and exchange.userName != ''">
AND e.user_name LIKE CONCAT('%', #{exchange.userName}, '%')
</if>
<if test="exchange.goodsName != null and exchange.goodsName != ''">
AND e.goods_name LIKE CONCAT('%', #{exchange.goodsName}, '%')
</if>
<if test="exchange.goodsCode != null and exchange.goodsCode != ''">
AND e.goods_code LIKE CONCAT('%', #{exchange.goodsCode}, '%')
</if>
<if test="exchange.params.startTime != null and exchange.params.startTime != ''">
AND DATE_FORMAT(create_time, '%Y-%m-%d') >= #{exchange.params.startTime}
</if>
<if test="exchange.params.endTime != null and exchange.params.endTime != ''">
AND DATE_FORMAT(create_time, '%Y-%m-%d') &lt;= #{exchange.params.endTime}
</if>
</where>
ORDER BY
e.create_time DESC
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment