| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.api.model.UserPoint; |
| | | import com.ruoyi.account.api.model.UserPointCopy; |
| | | import com.ruoyi.account.mapper.UserPointCopyMapper; |
| | | import com.ruoyi.account.service.AppUserService; |
| | | import com.ruoyi.account.service.UserPointService; |
| | | import com.ruoyi.account.vo.TransferPoint; |
| | |
| | | import com.ruoyi.common.core.web.page.TableDataInfo; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.order.feignClient.OrderClient; |
| | | import com.ruoyi.order.model.Order; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | |
| | | @Resource |
| | | private UserPointService userPointService; |
| | | @Resource |
| | | private AppUserService appUserService; |
| | | private UserPointCopyMapper userPointCopyMapper; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | private OrderClient orderClient; |
| | | |
| | | |
| | | /** |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PostMapping("/saveUserPointCopy") |
| | | public R saveUserPointCopy(@RequestBody UserPointCopy userPointCopy) { |
| | | userPointCopyMapper.insert(userPointCopy); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @DeleteMapping("/deleteUserPointCopy") |
| | | public R deleteUserPointCopy(@RequestParam("orderId") Long orderId, @RequestParam("type") List<Integer> type) { |
| | | userPointCopyMapper.delete(new LambdaQueryWrapper<UserPointCopy>().in(UserPointCopy::getType, type) |
| | | .eq(UserPointCopy::getObjectId, orderId)); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | @DeleteMapping("/deleteUserPointCopyByIds") |
| | | public R deleteUserPointCopyByIds(@RequestParam("ids") List<Long> ids){ |
| | | userPointCopyMapper.deleteBatchIds(ids); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/getUserPointCopy") |
| | | public R<List<UserPointCopy>> getUserPointCopy(@RequestParam("orderId") Long orderId, @RequestParam("type") List<Integer> type) { |
| | | List<UserPointCopy> list = userPointCopyMapper.selectList(new LambdaQueryWrapper<UserPointCopy>().in(UserPointCopy::getType, type) |
| | | .eq(UserPointCopy::getObjectId, orderId)); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 积分统计 |
| | |
| | | |
| | | @GetMapping("/user/list") |
| | | @ApiOperation(value = "积分管理-用户积分明细(必传用户id)", tags = "后台") |
| | | public R<Page<UserPoint>> userlist(UserPoint userPoint) { |
| | | Page<UserPoint> page = userPointService.lambdaQuery().eq(UserPoint::getAppUserId, userPoint.getAppUserId()).orderByDesc(UserPoint::getCreateTime).page(Page.of(userPoint.getPageNum(), userPoint.getPageSize())); |
| | | public R<IPage<UserPoint>> userlist(UserPoint userPoint) { |
| | | IPage<UserPoint> page = userPointService.getUserPointPage(Page.of(userPoint.getPageNum(), userPoint.getPageSize()), userPoint); |
| | | for (UserPoint record : page.getRecords()) { |
| | | int i = record.getHistoricalPoint() - record.getBalance(); |
| | | if (i>0){ |
| | | if (record.getType()==1 || record.getType()==11){ |
| | | Order data = orderClient.getOrderById(record.getObjectId()).getData(); |
| | | if (data!=null){ |
| | | record.setExtention(data.getOrderNumber()); |
| | | } |
| | | } |
| | | if (record.getChangeDirection() == -1){ |
| | | record.setVariableType(2); |
| | | }else if (i<0){ |
| | | record.setVariableType(1); |
| | | }else{ |
| | | record.setVariableType(0); |
| | | record.setVariableType(1); |
| | | } |
| | | } |
| | | return R.ok(page); |
| | |
| | | List<UserPoint> list = userPointService.list(queryWrapper); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 判断当天是否分享获得过积分 |
| | | * @param appUserId |
| | | * @return |
| | | */ |
| | | @PostMapping("/judgmentDailyShare") |
| | | public R<Boolean> judgmentDailyShare(@RequestParam("appUserId") Long appUserId){ |
| | | long count = userPointService.count(new LambdaQueryWrapper<UserPoint>().eq(UserPoint::getAppUserId, appUserId) |
| | | .eq(UserPoint::getType, 4).last(" and DATE_FORMAT(NOW(), '%Y-%m-%d') = DATE_FORMAT(create_time, '%Y-%m-%d')")); |
| | | return R.ok(count != 0); |
| | | } |
| | | } |
| | | |