| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | |
| | | import cn.hutool.http.HttpResponse; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | |
| | | import com.ruoyi.common.core.constant.CacheConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.poi.ExcelUtil; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | |
| | | |
| | | |
| | | |
| | | /* |
| | | |
| | | @GetMapping("/detail") |
| | | @ApiOperation(value = "用户列表-详情", tags = {"管理后台"}) |
| | | public R<AppUser> detail(Long id, Integer shopId) { |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | public R<AppUser> detail(Long id) { |
| | | AppUser byId = appUserService.getById(id); |
| | | Shop shop1 = shopClient.getServiceProvider(byId.getId()).getData(); |
| | | if(null != shop1){ |
| | | byId.setShopName(shop1.getName()); |
| | | byId.setShopId(shop1.getId()); |
| | | //获取店铺名称 |
| | | List<String> shopNames=shopClient.getServiceProvider(byId.getId()).getData(); |
| | | if(null != shopNames){ |
| | | byId.setShopNames(shopNames); |
| | | } |
| | | R<List<Shop>> shopByUserId = shopClient.getShopByUserId(id); |
| | | if (shopByUserId.getData() != null) { |
| | | List<String> shopName = new ArrayList<>(); |
| | | for (Shop datum : shopByUserId.getData()) { |
| | | shopName.add(datum.getName()); |
| | | } |
| | | byId.setShopNames(shopName); |
| | | } |
| | | |
| | | //最后下单时间 |
| | | R<Order> lastOrder = remoteOrderGoodsClient.getLastOrder(id); |
| | | if (lastOrder.getData() != null) { |
| | | byId.setLastOrderTime(lastOrder.getData().getCreateTime()); |
| | | } |
| | | |
| | | //消费总金额 |
| | | if(null == shopId || 1 == sysUser.getRoleType()){ |
| | | shopId = -1; |
| | | } |
| | | if(null == shopId && 2 == sysUser.getRoleType()){ |
| | | shopId = sysUser.getObjectId(); |
| | | } |
| | | R<List<Order>> orderR = remoteOrderGoodsClient.byUserId(id, shopId); |
| | | List<Order> orderList = orderR.getData(); |
| | | if (!CollectionUtils.isEmpty(orderList)){ |
| | | BigDecimal paymentAmount = orderList.stream().map(Order::getPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | byId.setShopAmount(paymentAmount); |
| | | }else { |
| | | byId.setShopAmount(BigDecimal.ZERO); |
| | | } |
| | | Integer customPoint =(byId.getExchangePoint()==null?0:byId.getExchangePoint())+ |
| | | (byId.getTransferableOutPoint()==null?0:byId.getTransferableOutPoint())- |
| | | (byId.getCancelPoint()==null?0:byId.getCancelPoint()); |
| | | byId.setCustomPoint(customPoint); |
| | | |
| | | return R.ok(byId); |
| | | } |
| | | */ |
| | | |
| | | |
| | | |
| | |
| | | /** |
| | | * 工作台-顶部 |
| | | */ |
| | | @GetMapping("/homeStatistics/statistics") |
| | | @GetMapping("/statistics") |
| | | @ApiOperation(value = "统计", tags = {"后台-工作台-顶部"}) |
| | | public R<UserStatistics> statistics() { |
| | | QueryWrapper<AppUser> queryWrapper = new QueryWrapper<>(); |
| | |
| | | queryWrapper.eq("del_flag", 0);//未删除的 |
| | | queryWrapper.ne("status", 3);//未注销的 |
| | | if (userId != null) { |
| | | queryWrapper.eq("user_id", userId); |
| | | queryWrapper.eq("id", userId); |
| | | } |
| | | //统计充值积分 |
| | | Map<String, Object> result = appUserService.getMap(queryWrapper); |
| | |
| | | return R.ok(pageInfo); |
| | | } |
| | | |
| | | /** |
| | | * 导出用户积分列表 |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping("/exportUserPoint") |
| | | @ApiOperation(value = "导出用户积分列表", tags = "后台-财务统计-用户积分统计") |
| | | public void exportUserPoint(HttpServletResponse response, @RequestParam(value = "name",required = false) String name) { |
| | | |
| | | List<UserPointStatisticsVO> exportList=appUserMapper.exportUserPoint(name); |
| | | ExcelUtil<UserPointStatisticsVO> util = new ExcelUtil<UserPointStatisticsVO>(UserPointStatisticsVO.class); |
| | | util.exportExcel(response, exportList, "用户积分汇总"); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/saveOrUpdateAppUser") |
| | | Long saveOrUpdateAppUser(@RequestBody AppUser appuser){ |
| | | if (appuser.getId() == null) { |
| | |
| | | |
| | | } |
| | | |
| | | @GetMapping("/getAllUser") |
| | | @ApiOperation(value = "获取所有用户") |
| | | public R<List<AppUser>> getAllUser() { |
| | | LambdaQueryWrapper<AppUser> queryWrapper=new LambdaQueryWrapper<>(); |
| | | queryWrapper.select(AppUser::getId,AppUser::getName); |
| | | queryWrapper.eq(AppUser::getDelFlag,0);//未删除的 |
| | | queryWrapper.ne(AppUser::getStatus, 3);//未注销的 |
| | | List<AppUser> list = appUserService.list(queryWrapper); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | } |
| | | |