liujie
1 天以前 f697280f473e9387ee387f25a678f113d734c9fe
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCrmWarehouseController.java
@@ -81,25 +81,32 @@
     */
    @ApiOperation(value = "获取crm供应商下的仓库管理列表")
    @PostMapping(value = "/listBySupplierId")
    public R<List<TCrmWarehouse>> listBySupplierId() {
    public R<TCrmWarehouse> listBySupplierId() {
        Integer roleType = tokenService.getLoginUser().getUser().getRoleType();
        Long userId = tokenService.getLoginUser().getUserId();
        if(roleType == 4){
            TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class)
                    .eq(TCrmSupplier::getUserId, userId)
                    .last("LIMIT 1"));
            List<TCrmSupplierToWarehouse> list = crmSupplierToWarehouseService.list(Wrappers.lambdaQuery(TCrmSupplierToWarehouse.class)
                    .eq(TCrmSupplierToWarehouse::getSupplierId, crmSupplier.getId()));
            if(CollectionUtils.isEmpty(list)){
                return R.ok();
            TCrmWarehouse crmWarehouse = crmWarehouseService.getById(crmSupplier.getWarehouseId());
            return R.ok(crmWarehouse);
            }
            List<String> warehouseIds = list.stream().map(TCrmSupplierToWarehouse::getWarehouseId).collect(Collectors.toList());
            List<TCrmWarehouse> crmWarehouseList = crmWarehouseService.list(Wrappers.lambdaQuery(TCrmWarehouse.class)
                    .eq(TCrmWarehouse::getStatus, 1)
                    .in(TCrmWarehouse::getId, warehouseIds)
                    .orderByDesc(TCrmWarehouse::getCreateTime));
            return R.ok(crmWarehouseList);
        }
//        if(roleType == 4){
//            TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class)
//                    .eq(TCrmSupplier::getUserId, userId)
//                    .last("LIMIT 1"));
//            List<TCrmSupplierToWarehouse> list = crmSupplierToWarehouseService.list(Wrappers.lambdaQuery(TCrmSupplierToWarehouse.class)
//                    .eq(TCrmSupplierToWarehouse::getSupplierId, crmSupplier.getId()));
//            if(CollectionUtils.isEmpty(list)){
//                return R.ok();
//            }
//            List<String> warehouseIds = list.stream().map(TCrmSupplierToWarehouse::getWarehouseId).collect(Collectors.toList());
//            List<TCrmWarehouse> crmWarehouseList = crmWarehouseService.list(Wrappers.lambdaQuery(TCrmWarehouse.class)
//                    .eq(TCrmWarehouse::getStatus, 1)
//                    .in(TCrmWarehouse::getId, warehouseIds)
//                    .orderByDesc(TCrmWarehouse::getCreateTime));
//            return R.ok(crmWarehouseList);
//        }
        return R.ok();
    }