| | |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import io.swagger.annotations.*; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | Long days = jsonObject.getLong("days"); |
| | | Order order = orderService.getById(orderId); |
| | | order.setAfterSaleTime(LocalDateTime.now().plusDays(days)); |
| | | order.setIsCommission(0); |
| | | order.setOrderStatus(OrderStatus.COMPLETED.getCode()); |
| | | orderService.updateById(order); |
| | | return R.ok(); |
| | |
| | | |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | List<Order> orderList = orderService.list(new LambdaQueryWrapper<Order>() |
| | | .ne(Order::getOrderStatus, 5) |
| | | .eq(sysUser.getRoleType() == 2, Order::getShopId, sysUser.getObjectId()) |
| | | LambdaQueryWrapper<Order> wrapper = new LambdaQueryWrapper<Order>() |
| | | .in(Order::getOrderStatus, Arrays.asList(1, 2, 3, 4, 7, 8)) |
| | | .eq(Order::getPayStatus, 2) |
| | | .eq(Order::getDelFlag, 0) |
| | | .between(Order::getCreateTime, LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")), LocalDateTime.parse(endTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))) |
| | | .orderByAsc(Order::getCreateTime)); |
| | | |
| | | |
| | | .orderByAsc(Order::getCreateTime); |
| | | if(sysUser.getRoleType() == 2){ |
| | | //门店只拥有服务订单和自提商品订单 |
| | | wrapper.eq(Order::getShopId, sysUser.getObjectId()).eq(Order::getOrderType, 1).or().eq(Order::getOrderType, 2).eq(Order::getDistributionMode, 1); |
| | | } |
| | | List<Order> orderList = orderService.list(wrapper); |
| | | Map<String, List<Order>> map = orderList.stream() |
| | | .collect(Collectors.groupingBy( |
| | | item -> item.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")), |
| | |
| | | return R.ok(collect); |
| | | } |
| | | |
| | | /** |
| | | * 获取指定门店的核销订单 |
| | | */ |
| | | @GetMapping("/getRedeemedOrdersByShop") |
| | | public R<List<Order>> getRedeemedOrdersByShop(@RequestParam("shopId") Integer shopId) { |
| | | return R.ok(orderService.list(new LambdaQueryWrapper<Order>() |
| | | .isNotNull(Order::getEndTime) |
| | | .eq(Order::getShopId, shopId))); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取订单快递明细 |
| | |
| | | */ |
| | | @GetMapping("/exportExpress") |
| | | public void exportExpress(HttpServletResponse response, OrderPageList orderPage) { |
| | | //搜索条件,用户姓名 |
| | | if (StringUtils.isNotEmpty(orderPage.getUserName())) { |
| | | List<AppUser> data = appUserClient.getAppUserByNameNoFilter(orderPage.getUserName()).getData(); |
| | | List<Long> collect = data.stream().map(AppUser::getId).collect(Collectors.toList()); |
| | | if (CollectionUtils.isEmpty(collect)) { |
| | | return; |
| | | } |
| | | if (null != orderPage.getAppUserIds()) { |
| | | List<Long> appUserIds = orderPage.getAppUserIds(); |
| | | appUserIds.addAll(collect); |
| | | orderPage.setAppUserIds(appUserIds); |
| | | } else { |
| | | orderPage.setAppUserIds(collect); |
| | | } |
| | | } |
| | | //搜索条件,用户电话 |
| | | if (StringUtils.isNotEmpty(orderPage.getPhone())) { |
| | | List<AppUser> data = appUserClient.getAppUserByPhoneNoFilter(orderPage.getPhone()).getData(); |
| | | List<Long> collect = data.stream().map(AppUser::getId).collect(Collectors.toList()); |
| | | if (CollectionUtils.isEmpty(collect)) { |
| | | return; |
| | | } |
| | | |
| | | if (null != orderPage.getAppUserIds()) { |
| | | List<Long> appUserIds = orderPage.getAppUserIds(); |
| | | if (!containsAny(appUserIds, collect)) { |
| | | return; |
| | | } |
| | | appUserIds.addAll(collect); |
| | | orderPage.setAppUserIds(appUserIds); |
| | | } else { |
| | | orderPage.setAppUserIds(collect); |
| | | } |
| | | } |
| | | if (null != orderPage.getAppUserIds()) { |
| | | orderPage.setAppUserIds(orderPage.getAppUserIds().stream().distinct().collect(Collectors.toList())); |
| | | } |
| | | |
| | | // UserAddress userAddress = JSON.parseObject(order.getAddressJson(), UserAddress.class); |
| | | // orderInfo.setRecipient(userAddress.getRecieveName() + "-" + userAddress.getRecievePhone()); |
| | | // userAddress.setRecieveAddress(userAddress.getProvince() + userAddress.getCity() + userAddress.getDistrict() + userAddress.getRecieveAddress()); |
| | | // orderInfo.setAddress(userAddress.getRecieveAddress()); |
| | | |
| | | |
| | | List<OrderExport> orderExportList = orderMapper.getOrderExportList(orderPage); |
| | | orderExportList.forEach(orderExport -> { |
| | | Long appUserId = orderExport.getAppUserId(); |
| | | AppUser appUserById = appUserClient.getAppUserById(appUserId); |
| | | if (null != appUserById){ |
| | | if (null != appUserById) { |
| | | orderExport.setUserName(appUserById.getName()); |
| | | orderExport.setPhone(appUserById.getPhone()); |
| | | } |
| | |
| | | if (StringUtils.isNotEmpty(goodJson) && !"NULL".equals(goodJson)) { |
| | | Goods goods = JSONObject.parseObject(goodJson, Goods.class); |
| | | orderExport.setGoodsName(goods.getName()); |
| | | orderExport.setCostPrice(goods.getShopCost().add(goods.getOperatingCost())); |
| | | orderExport.setCompanyCostPrice(goods.getOperatingCost()); |
| | | orderExport.setSupplierCostPrice(goods.getShopCost()); |
| | | } |
| | | |
| | | String expressJson = orderExport.getExpressJson(); |
| | |
| | | orderExport.setExpressNum(jsonObject.getString("num")); |
| | | orderExport.setExpressName(ExpressCompanyMap.getCompanyNameByCode(jsonObject.getString("com"))); |
| | | } |
| | | String addressJson = orderExport.getAddressJson(); |
| | | if (StringUtils.isNotEmpty(addressJson)) { |
| | | UserAddress userAddress = JSON.parseObject(addressJson, UserAddress.class); |
| | | orderExport.setAddress( |
| | | userAddress.getProvince() + |
| | | userAddress.getCity() + |
| | | userAddress.getDistrict() + |
| | | userAddress.getRecieveAddress() |
| | | ); |
| | | } |
| | | |
| | | |
| | | |
| | | }); |
| | | |
| | | ExcelUtil<OrderExport> util = new ExcelUtil<OrderExport>(OrderExport.class); |
| | | util.exportExcel(response, orderExportList, "订单数据"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 判断 list1 是否包含 list2 中的至少一个元素 |
| | | * |
| | | * @param list1 第一个列表 |
| | | * @param list2 第二个列表 |
| | | * @return 如果 list1 包含 list2 中的至少一个元素,返回 true;否则返回 false |
| | | */ |
| | | private boolean containsAny(List<Long> list1, List<Long> list2) { |
| | | // 将 list1 转换为 HashSet 以提高查询效率 |
| | | Set<Long> set1 = new HashSet<>(list1); |
| | | |
| | | // 遍历 list2,检查是否有元素存在于 set1 中 |
| | | for (Long element : list2) { |
| | | if (set1.contains(element)) { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | // 如果没有找到共同元素,返回 false |
| | | return false; |
| | | } |
| | | |
| | | |
| | |
| | | .eq(Order::getPayStatus, 2)); |
| | | return R.ok(count); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询给定用户在给定门店核销的订单 |
| | | * @param shopId |
| | | * @param appUserId |
| | | * @return |
| | | */ |
| | | @PostMapping("/getOrderByAppUserIdsAndWriteOffShop") |
| | | public R<List<Order>> getOrderByAppUserIdsAndWriteOffShop(@RequestParam("shopId") Integer shopId, @RequestParam("appUserId") Set<Long> appUserId){ |
| | | List<Order> list = orderService.getOrderByAppUserIdsAndWriteOffShop(shopId, appUserId); |
| | | return R.ok(list); |
| | | } |
| | | } |
| | | |