From 1e621d98f4361158df25f2b4af9b53899bfde32f Mon Sep 17 00:00:00 2001 From: liujie <1793218484@qq.com> Date: 星期一, 02 六月 2025 14:36:10 +0800 Subject: [PATCH] 小程序接口 详情 --- ruoyi-applet/src/main/java/com/ruoyi/web/controller/system/CompanyController.java | 217 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 198 insertions(+), 19 deletions(-) diff --git a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/system/CompanyController.java b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/system/CompanyController.java index 878c7c0..1d917d6 100644 --- a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/system/CompanyController.java +++ b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/system/CompanyController.java @@ -1,22 +1,28 @@ package com.ruoyi.web.controller.system; + import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.core.domain.BasePage; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.framework.web.service.TokenService; -import com.ruoyi.system.model.TbBanner; +import com.ruoyi.system.dto.*; +import com.ruoyi.system.model.*; import com.ruoyi.system.query.CompanyListQuery; -import com.ruoyi.system.service.TbBannerService; -import com.ruoyi.system.service.TbCompanyService; +import com.ruoyi.system.query.MyPushCompanyListQuery; +import com.ruoyi.system.service.*; +import com.ruoyi.system.vo.CompanyDetailVo; import com.ruoyi.system.vo.IndexCompanyListVo; +import com.ruoyi.system.vo.MyPushCompanyListVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; +import org.apache.poi.ss.formula.functions.T; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.util.List; @@ -24,37 +30,210 @@ @Slf4j @RestController @RequestMapping("/user") -@Api(tags = "商城模块") +@Api(tags = "发布模块") public class CompanyController { @Autowired private TbCompanyService tbCompanyService; @Autowired - private TbBannerService bannerService; + private TbIndustryService industryService; + + @Autowired + private TbOrderService orderService; @Autowired private TokenService tokenService; + @Autowired + private TbScheduleService scheduleService; - @ApiOperation(value = "获取banner",tags = {"获取banner"}) - @GetMapping("/getBannerList") - public R<List<TbBanner>> getBannerList() { - List<TbBanner> list = bannerService.list(new LambdaQueryWrapper<TbBanner>().eq(TbBanner::getDelFlag, 0)); - return R.ok(list); - } + @Autowired + private TbMessageService messageService; - @ApiOperation(value = "获取商城首页",tags = {"获取商城首页"}) - @GetMapping("/getCompanyList") - public R<Page<IndexCompanyListVo>> getCompanyList(@Valid CompanyListQuery query) { + + @ApiOperation(value = "获取我发布的公司",tags = {"发布模块"}) + @GetMapping("/getMyPushCompanyList") + public R<Page<MyPushCompanyListVo>> getMyPushCompanyList(MyPushCompanyListQuery query) { LoginUser loginUser = tokenService.getLoginUser(); Long userId = loginUser.getUserId(); - Page<IndexCompanyListVo> page = tbCompanyService.getCompanyList(query,userId); - + Page<MyPushCompanyListVo> page = tbCompanyService.getMyPushCompanyList(query,userId); return R.ok(page); } + @ApiOperation(value = "获取行业信息",tags = {"发布模块"}) + @GetMapping("/getIndustryList") + public R<Page<TbIndustry>> getIndustryList(BasePage page) { + Page<TbIndustry> page1 = industryService.page(new Page<>(page.getPageNum(),page.getPageSize()),new LambdaQueryWrapper<TbIndustry>().orderByDesc(TbIndustry::getOrderNum)); + return R.ok(page1); + } + + @ApiOperation(value = "立即发布",tags = {"发布模块"}) + @PostMapping("/pushCompany") + public R<?> pushCompany(@Valid @RequestBody PushCompanyDto dto) { + LoginUser loginUser = tokenService.getLoginUser(); + Long userId = loginUser.getUserId(); + tbCompanyService.pushCompany(dto,userId); + return R.ok(); + } + + @ApiOperation(value = "编辑公司",tags = {"发布模块"}) + @PostMapping("/editCompany") + public R<?> editCompany(@Valid @RequestBody EditCompanyDto dto) { + LoginUser loginUser = tokenService.getLoginUser(); + Long userId = loginUser.getUserId(); + TbCompany company = tbCompanyService.getById(dto.getId()); + if (company == null || !company.getUserId().equals(userId.toString())) { + return R.fail("非法操作"); + } + long count = orderService.count(new LambdaQueryWrapper<TbOrder>().eq(TbOrder::getCompanyId, dto.getId()).in(TbOrder::getStatus, 3, 4, 5)); + if (count > 0) { + return R.fail("订单状态不能修改"); + } + tbCompanyService.editCompany(dto,company,userId); + return R.ok(); + } + + + @ApiOperation(value = "上下架",tags = {"发布模块"}) + @PostMapping("/companyUpdateStatus") + public R<?> companyUpdateStatus(@Valid @RequestBody CompanyUpdateStatusDto dto) { + LoginUser loginUser = tokenService.getLoginUser(); + Long userId = loginUser.getUserId(); + TbCompany company = tbCompanyService.getById(dto.getId()); + if (company == null || !company.getUserId().equals(userId.toString())) { + return R.fail("非法操作"); + } + long count = orderService.count(new LambdaQueryWrapper<TbOrder>().eq(TbOrder::getCompanyId, dto.getId()).in(TbOrder::getStatus, 3, 4, 5)); + if (count > 0) { + return R.fail("订单状态不能修改"); + } + if(dto.getStatus()<1 || dto.getStatus()>2){ + return R.fail("状态错误"); + } + company.setStatus(dto.getStatus()); + tbCompanyService.updateById(company); + return R.ok(); + } + + @ApiOperation(value = "确认订单",tags = {"发布模块"}) + @PostMapping("/confirmOrder") + public R<?> confirmOrder(String orderId) { + if(StringUtils.isEmpty(orderId)){ + return R.fail("参数错误"); + } + LoginUser loginUser = tokenService.getLoginUser(); + Long userId = loginUser.getUserId(); + TbOrder order = orderService.getById(orderId); + if(order==null){ + return R.fail("订单不存在"); + } + TbCompany company = tbCompanyService.getById(order.getCompanyId()); + if (company == null || !company.getUserId().equals(userId.toString())) { + return R.fail("非法操作"); + } + if(order.getStatus()!=2){ + return R.fail("该订单状态不需要确认"); + } + order.setStatus(3); + order.updateById(); + return R.ok(); + } + + + @ApiOperation(value = "取消确认订单",tags = {"发布模块"}) + @PostMapping("/cancelConfirmOrder") + public R<?> cancelConfirmOrder(String orderId) { + if(StringUtils.isEmpty(orderId)){ + return R.fail("参数错误"); + } + LoginUser loginUser = tokenService.getLoginUser(); + Long userId = loginUser.getUserId(); + TbOrder order = orderService.getById(orderId); + if(order==null){ + return R.fail("订单不存在"); + } + TbCompany company = tbCompanyService.getById(order.getCompanyId()); + if (company == null || !company.getUserId().equals(userId.toString())) { + return R.fail("非法操作"); + } + // 待支付才能取消订单 已确认后 + if(order.getStatus()!=3){ + return R.fail("该订单状态不需要确认"); + } + order.setStatus(3); + order.updateById(); + + company.setStatus(1); + company.updateById(); + + + messageService.addMessage("您有订单被取消", order.getUserId(),order.getId()); + return R.ok(); + } + + @ApiOperation(value = "添加办理进度",tags = {"发布模块"}) + @PostMapping("/addSchedule") + public R<?> addSchedule(@RequestBody @Valid AddScheduleDto dto) { + LoginUser loginUser = tokenService.getLoginUser(); + Long userId = loginUser.getUserId(); + TbOrder order = orderService.getById(dto.getOrderId()); + if(order==null){ + return R.fail("订单不存在"); + } + TbCompany company = tbCompanyService.getById(order.getCompanyId()); + if (company == null || !company.getUserId().equals(userId.toString())) { + return R.fail("非法操作"); + } + scheduleService.addSchedule(dto,userId); + + messageService.addMessage("您有订单卖家已完成,等待确认", order.getUserId(),order.getId()); + return R.ok(); + } + + + + + + @ApiOperation(value = "已完成",tags = {"发布模块"}) + @PostMapping("/saleSuccessOrder") + public R<?> saleSuccessOrder(String orderId) { + if(StringUtils.isEmpty(orderId)){ + return R.fail("参数错误"); + } + LoginUser loginUser = tokenService.getLoginUser(); + Long userId = loginUser.getUserId(); + TbOrder order = orderService.getById(orderId); + if(order==null){ + return R.fail("订单不存在"); + } + TbCompany company = tbCompanyService.getById(order.getCompanyId()); + if (company == null || !company.getUserId().equals(userId.toString())) { + return R.fail("非法操作"); + } + if(order.getStatus()!=4){ + return R.fail("该订单状态不能完成"); + } + order.setStatus(5); + order.updateById(); + + messageService.addMessage("您有订单卖家已完成,等待确认", order.getUserId(),orderId); + return R.ok(); + } + + + @ApiOperation(value = "公司详情",tags = {"发布模块"}) + @GetMapping("/companyDetail") + public R<CompanyDetailVo> companyDetail(@RequestParam String companyId) { + if(StringUtils.isEmpty(companyId)){ + return R.fail("参数错误"); + } + LoginUser loginUser = tokenService.getLoginUser(); + Long userId = loginUser.getUserId(); + CompanyDetailVo companyDetailVo = tbCompanyService.companyDetail(companyId,userId); + return R.ok(companyDetailVo); + } } -- Gitblit v1.7.1