From 87f979fb201a82ebad5926735ed6dfa75ca004d3 Mon Sep 17 00:00:00 2001 From: liujie <1793218484@qq.com> Date: 星期一, 21 七月 2025 09:21:42 +0800 Subject: [PATCH] 修改bug --- ruoyi-applet/src/main/java/com/ruoyi/web/controller/system/CompanyController.java | 236 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 208 insertions(+), 28 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 e74f124..86ca34a 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,36 +1,47 @@ package com.ruoyi.web.controller.system; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson2.JSONObject; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.constant.HttpStatus; 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.core.redis.RedisCache; +import com.ruoyi.common.redis.service.RedisService; +import com.ruoyi.common.utils.QiChaChaUtil; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.framework.web.service.TokenService; -import com.ruoyi.system.dto.*; +import com.ruoyi.system.dto.AddScheduleDto; +import com.ruoyi.system.dto.CompanyUpdateStatusDto; +import com.ruoyi.system.dto.EditCompanyDto; +import com.ruoyi.system.dto.PushCompanyDto; import com.ruoyi.system.model.*; -import com.ruoyi.system.query.CompanyListQuery; 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.*; import javax.validation.Valid; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.concurrent.TimeUnit; @Slf4j @RestController -@RequestMapping("/user") +@RequestMapping("/company") @Api(tags = "发布模块") public class CompanyController { @@ -58,62 +69,140 @@ @Autowired private TbCompanyTypeService companyTypeService; + @Autowired + private TbQichachaService tbQichachaService; + + @Autowired + private RedisCache redisCache; + + @ApiOperation(value = "获取我发布的公司",tags = {"发布模块"}) @GetMapping("/getMyPushCompanyList") - public R<Page<MyPushCompanyListVo>> getMyPushCompanyList(MyPushCompanyListQuery query) { + public R< HashMap<String, Object>> getMyPushCompanyList(MyPushCompanyListQuery query) { LoginUser loginUser = tokenService.getLoginUser(); + if(loginUser==null){ + return R.fail(HttpStatus.UNAUTHORIZED,"请重新登录"); + } Long userId = loginUser.getUserId(); Page<MyPushCompanyListVo> page = tbCompanyService.getMyPushCompanyList(query,userId); - return R.ok(page); + HashMap<String, Object> map = new HashMap<>(); + map.put("data",page); + map = tbCompanyService.getMyPushCompanyListNum(userId,map); + return R.ok(map); } + + + @ApiOperation(value = "获取上次发布的信息",tags = {"发布模块"}) + @GetMapping("/getMyPushCompanyLast") + public R<HashMap<String, Object>> getMyPushCompanyLast() { + LoginUser loginUser = tokenService.getLoginUser(); + if(loginUser==null){ + return R.fail(HttpStatus.UNAUTHORIZED,"请重新登录"); + } + Long userId = loginUser.getUserId(); + TbCompany company = tbCompanyService.getOne(new LambdaQueryWrapper<TbCompany>().eq(TbCompany::getUserId,userId).orderByDesc(TbCompany::getCreateTime).last("limit 1")); + HashMap<String, Object> map = new HashMap<>(); + if(company!=null){ + map.put("recipient",company.getRecipient()); + map.put("recipientAddress",company.getRecipientAddress()); + }else { + map.put("recipient",""); + map.put("recipientAddress",""); + } + return R.ok(map); + } + + @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)); + public R<List<TbIndustry>> getIndustryList() { + List<TbIndustry> page1 = industryService.list(new LambdaQueryWrapper<TbIndustry>().eq(TbIndustry::getDelFlag,0).orderByDesc(TbIndustry::getOrderNum)); return R.ok(page1); } - @ApiOperation(value = "获取许可证信息",tags = {"发布模块"}) + @ApiOperation(value = "获取公司类型信息",tags = {"发布模块"}) @GetMapping("/getCompanyTypeList") - public R<Page<TbCompanyType>> getCompanyTypeList(BasePage page) { - Page<TbCompanyType> page1 = companyTypeService.page(new Page<>(page.getPageNum(),page.getPageSize()),new LambdaQueryWrapper<TbCompanyType>().eq(TbCompanyType::getDelFlag,0).orderByDesc(TbCompanyType::getOrderNum)); + public R<List<TbCompanyType>> getCompanyTypeList() { + List<TbCompanyType> page1 = companyTypeService.list(new LambdaQueryWrapper<TbCompanyType>().eq(TbCompanyType::getDelFlag,0).orderByDesc(TbCompanyType::getOrderNum)); return R.ok(page1); } @ApiOperation(value = "获取许可证信息",tags = {"发布模块"}) @GetMapping("/getLicenceList") - public R<Page<TbLicence>> getLicenceList(BasePage page) { - Page<TbLicence> page1 = licenceService.page(new Page<>(page.getPageNum(),page.getPageSize()),new LambdaQueryWrapper<TbLicence>().eq(TbLicence::getDelFlag,0).orderByDesc(TbLicence::getOrderNum)); + public R<List<TbLicence>> getLicenceList() { + List<TbLicence> page1 = licenceService.list(new LambdaQueryWrapper<TbLicence>().eq(TbLicence::getDelFlag,0).orderByDesc(TbLicence::getOrderNum)); return R.ok(page1); } @ApiOperation(value = "立即发布",tags = {"发布模块"}) @PostMapping("/pushCompany") - public R<?> pushCompany(@Valid @RequestBody PushCompanyDto dto) { + public synchronized R<?> pushCompany(@Valid @RequestBody PushCompanyDto dto) { LoginUser loginUser = tokenService.getLoginUser(); + if(loginUser==null){ + return R.fail(HttpStatus.UNAUTHORIZED,"请重新登录"); + } Long userId = loginUser.getUserId(); - tbCompanyService.pushCompany(dto,userId); - return R.ok(); + long count = tbCompanyService.count(new LambdaQueryWrapper<TbCompany>().eq(TbCompany::getIsDelete,0).eq(TbCompany::getCompanyName, dto.getCompanyName()).ne(TbCompany::getStatus, 3)); + if (count > 0) { + return R.fail("该公司已发布"); + } + String companyId = tbCompanyService.pushCompany(dto, userId); + return R.ok(companyId); } + + @ApiOperation(value = "发布前获取公司信息--企查查",tags = {"发布模块"}) + @GetMapping("/getCompanyFromQiChaCha") + public R<Object> getCompanyFromQiChaCha(@RequestParam String companyName) { + long count = tbCompanyService.count(new LambdaQueryWrapper<TbCompany>().eq(TbCompany::getCompanyName,companyName).eq(TbCompany::getIsDelete,0).ne(TbCompany::getStatus, 3)); + if (count > 0) { + return R.fail("该公司已发布"); + } + Object cacheObject = redisCache.getCacheObject("push_" + companyName); + if(cacheObject!=null){ + return R.ok(cacheObject); + } + Object qiChaChaToken = QiChaChaUtil.getQiChaChaCompanyInfo(companyName); + TbQichacha tbQichacha = new TbQichacha(); + tbQichacha.setType(1); + tbQichachaService.save(tbQichacha); + if(qiChaChaToken==null){ + return R.fail("查询公司信息失败请联系客服"); + } + redisCache.setCacheObject("push_" + companyName, qiChaChaToken, 24, TimeUnit.HOURS); + return R.ok(qiChaChaToken); + } + + @ApiOperation(value = "编辑公司",tags = {"发布模块"}) @PostMapping("/editCompany") public R<?> editCompany(@Valid @RequestBody EditCompanyDto dto) { LoginUser loginUser = tokenService.getLoginUser(); + if(loginUser==null){ + return R.fail(HttpStatus.UNAUTHORIZED,"请重新登录"); + } Long userId = loginUser.getUserId(); + TbCompany company = tbCompanyService.getById(dto.getId()); if (company == null || !company.getUserId().equals(userId.toString())) { return R.fail("非法操作"); } + + long count1 = tbCompanyService.count(new LambdaQueryWrapper<TbCompany>().eq(TbCompany::getCompanyName, dto.getCompanyName()).eq(TbCompany::getIsDelete,0).ne(TbCompany::getId,dto.getId()).ne(TbCompany::getStatus, 3)); + if (count1 > 0) { + 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(); + return R.ok(dto.getId()); } @@ -121,6 +210,9 @@ @PostMapping("/companyUpdateStatus") public R<?> companyUpdateStatus(@Valid @RequestBody CompanyUpdateStatusDto dto) { LoginUser loginUser = tokenService.getLoginUser(); + if(loginUser==null){ + return R.fail(HttpStatus.UNAUTHORIZED,"请重新登录"); + } Long userId = loginUser.getUserId(); TbCompany company = tbCompanyService.getById(dto.getId()); if (company == null || !company.getUserId().equals(userId.toString())) { @@ -133,10 +225,37 @@ if(dto.getStatus()<1 || dto.getStatus()>2){ return R.fail("状态错误"); } + if(dto.getStatus()==2){ + orderService.update(new LambdaUpdateWrapper<TbOrder>().eq(TbOrder::getCompanyId,dto.getId()).set(TbOrder::getStatus,-1)); + } company.setStatus(dto.getStatus()); tbCompanyService.updateById(company); return R.ok(); } + + + @ApiOperation(value = "删除公司",tags = {"发布模块"}) + @DeleteMapping("/delete/{id}") + public R<?> delete(@PathVariable("id")String id) { + LoginUser loginUser = tokenService.getLoginUser(); + if(loginUser==null){ + return R.fail(HttpStatus.UNAUTHORIZED,"请重新登录"); + } + Long userId = loginUser.getUserId(); + TbCompany company = tbCompanyService.getById(id); + if (company == null || !company.getUserId().equals(userId.toString())) { + return R.fail("非法操作"); + } + long count = orderService.count(new LambdaQueryWrapper<TbOrder>().eq(TbOrder::getCompanyId,id).in(TbOrder::getStatus, 3, 4, 5)); + if (company.getStatus()!=1) { + return R.fail("订单状态不能修改"); + } + company.setIsDelete(1); + tbCompanyService.updateById(company); + return R.ok(); + } + + @ApiOperation(value = "确认订单",tags = {"发布模块"}) @PostMapping("/confirmOrder") @@ -145,6 +264,9 @@ return R.fail("参数错误"); } LoginUser loginUser = tokenService.getLoginUser(); + if(loginUser==null){ + return R.fail(HttpStatus.UNAUTHORIZED,"请重新登录"); + } Long userId = loginUser.getUserId(); TbOrder order = orderService.getById(orderId); if(order==null){ @@ -172,6 +294,9 @@ return R.fail("参数错误"); } LoginUser loginUser = tokenService.getLoginUser(); + if(loginUser==null){ + return R.fail(HttpStatus.UNAUTHORIZED,"请重新登录"); + } Long userId = loginUser.getUserId(); TbOrder order = orderService.getById(orderId); if(order==null){ @@ -185,14 +310,15 @@ if(order.getStatus()!=3){ return R.fail("该订单状态不需要确认"); } - order.setStatus(3); + order.setStatus(-1); + order.setCancelType(1); order.updateById(); company.setStatus(1); company.updateById(); - messageService.addMessage("您有订单被取消", order.getUserId(),order.getId()); + messageService.addMessage("您有订单被取消", order.getUserId(),order.getId(),2); return R.ok(); } @@ -200,6 +326,9 @@ @PostMapping("/addSchedule") public R<?> addSchedule(@RequestBody @Valid AddScheduleDto dto) { LoginUser loginUser = tokenService.getLoginUser(); + if(loginUser==null){ + return R.fail(HttpStatus.UNAUTHORIZED,"请重新登录"); + } Long userId = loginUser.getUserId(); TbOrder order = orderService.getById(dto.getOrderId()); if(order==null){ @@ -211,13 +340,23 @@ } scheduleService.addSchedule(dto,userId); - messageService.addMessage("您有订单卖家已完成,等待确认", order.getUserId(),order.getId()); + messageService.addMessage("您的订单有新的进度提醒", order.getUserId(),order.getId(),2); return R.ok(); } - + private static Object getReport(String sign){ + HttpRequest post = HttpUtil.createPost("https://shuimui.szsmjr.com/index/index/result"); + HashMap<String, String> stringStringHashMap = new HashMap<>(); + stringStringHashMap.put("Origin","https://shuimui.szsmjr.com"); + post.addHeaders(stringStringHashMap); + post.body("{\"sn\":\""+sign+"\"}"); + HttpResponse execute = post.execute(); + String body = execute.body(); + JSONObject jsonObject = JSONObject.parseObject(body); + return jsonObject; + } @ApiOperation(value = "已完成",tags = {"发布模块"}) @PostMapping("/saleSuccessOrder") @@ -226,6 +365,9 @@ return R.fail("参数错误"); } LoginUser loginUser = tokenService.getLoginUser(); + if(loginUser==null){ + return R.fail(HttpStatus.UNAUTHORIZED,"请重新登录"); + } Long userId = loginUser.getUserId(); TbOrder order = orderService.getById(orderId); if(order==null){ @@ -242,22 +384,60 @@ order.setSellerFinishTime(new Date()); order.updateById(); - messageService.addMessage("您有订单卖家已完成,等待确认", order.getUserId(),orderId); + messageService.addMessage("您有订单卖家已完成,等待确认", order.getUserId(),orderId,2); return R.ok(); } @ApiOperation(value = "公司详情",tags = {"发布模块"}) @GetMapping("/companyDetail") - public R<CompanyDetailVo> companyDetail(@RequestParam String companyId) { + public R<CompanyDetailVo> companyDetail(@RequestParam String companyId) throws Exception { if(StringUtils.isEmpty(companyId)){ return R.fail("参数错误"); } - LoginUser loginUser = tokenService.getLoginUser(); - Long userId = loginUser.getUserId(); - CompanyDetailVo companyDetailVo = tbCompanyService.companyDetail(companyId,userId); + CompanyDetailVo companyDetailVo = tbCompanyService.companyDetail(companyId,null); + Object qiChaChaCompanyExceptionCheck = QiChaChaUtil.getQiChaChaCompanyExceptionCheck(companyDetailVo.getCompanyName()); + if(qiChaChaCompanyExceptionCheck!=null && qiChaChaCompanyExceptionCheck.toString().contains("query_type")){ + TbQichacha tbQichacha = new TbQichacha(); + tbQichacha.setType(2); + tbQichacha.insert(); + } + companyDetailVo.setCompanyExceptionInfo(qiChaChaCompanyExceptionCheck); + companyDetailVo.setEstablishTime(companyDetailVo.getEstablishTime().substring(0,10)); return R.ok(companyDetailVo); } + @ApiOperation(value = "公司详情--异常信息",tags = {"发布模块"}) + @GetMapping("/qiChaChaCompanyExceptionCheck") + public R<Object> qiChaChaCompanyExceptionCheck(@RequestParam String companyName) { + Object qiChaChaCompanyExceptionCheck = QiChaChaUtil.getQiChaChaCompanyExceptionCheck(companyName); + if(qiChaChaCompanyExceptionCheck!=null && qiChaChaCompanyExceptionCheck.toString().contains("query_type")){ + TbQichacha tbQichacha = new TbQichacha(); + tbQichacha.setType(2); + tbQichacha.insert(); + } + return R.ok(qiChaChaCompanyExceptionCheck); + } + + @ApiOperation(value = "公司详情--财务征信信息",tags = {"发布模块"}) + @GetMapping("/companyDetailDataInfo") + public R<Object> companyDetailDataInfo(@RequestParam String companyId) { + if(StringUtils.isEmpty(companyId)){ + return R.fail("参数错误"); + } + TbCompany company = tbCompanyService.getById(companyId); + String link = company.getLink(); + String sign = link.split("=")[1]; + Object report = getReport(sign); + return R.ok(report); + } + + + + + + + + } -- Gitblit v1.7.1