From 281c6016ab0ea5b2eeecb9167d9ee690b6fdac1f Mon Sep 17 00:00:00 2001 From: liujie <1793218484@qq.com> Date: 星期五, 04 七月 2025 17:17:06 +0800 Subject: [PATCH] 三方对接 --- ruoyi-applet/src/main/java/com/ruoyi/web/controller/system/UserAccountController.java | 4 ruoyi-common/src/main/java/com/ruoyi/common/utils/OssUploadUtil.java | 136 +++++++++ ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java | 40 ++ ruoyi-system/pom.xml | 2 ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/WxLoginController.java | 16 ruoyi-system/src/main/java/com/ruoyi/system/model/TbOrder.java | 3 ruoyi-applet/src/main/java/com/ruoyi/web/controller/system/UploadController.java | 30 ++ ruoyi-applet/src/main/resources/application-test.yml | 35 - ruoyi-common/pom.xml | 24 + ruoyi-applet/src/main/java/com/ruoyi/web/controller/system/CompanyController.java | 62 +++ /dev/null | 187 ------------ ruoyi-common/src/main/java/com/ruoyi/common/utils/AliSmsUtil.java | 126 ++++++++ ruoyi-system/src/main/java/com/ruoyi/system/vo/CompanyDetailVo.java | 4 ruoyi-applet/src/main/resources/application-prod.yml | 53 +-- ruoyi-system/src/main/java/com/ruoyi/system/query/UserAccountDetailQuery.java | 6 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbOrderServiceImpl.java | 6 ruoyi-common/src/main/java/com/ruoyi/common/utils/QiChaChaUtil.java | 71 ++++ ruoyi-applet/src/main/java/com/ruoyi/web/controller/system/messageController.java | 44 +- 18 files changed, 554 insertions(+), 295 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/MsgUtils.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/MsgUtils.java deleted file mode 100644 index 119a5ea..0000000 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/MsgUtils.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.ruoyi.web.controller.tool; - -import com.aliyun.dysmsapi20170525.models.SendSmsRequest; -import com.aliyun.dysmsapi20170525.models.SendSmsResponse; -import com.aliyun.tea.TeaException; -import com.aliyun.teaopenapi.models.Config; -import com.aliyun.teautil.models.RuntimeOptions; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -@Component -@Slf4j -public class MsgUtils { - - @Value("${code.config.accessKeyId}") - private String accessKeyId; - @Value("${code.config.accessKeySecret}") - private String accessKeySecret; - @Value("${code.config.signName}") - private String signName; - @Value("${code.config.templateCode}") - private String templateCode; - @Value("${code.config.signNameTest}") - private String signNameTest; - @Value("${code.config.templateCodeTest}") - private String templateCodeTest; - - /** - * 使用AK&SK初始化账号Client - * @param accessKeyId - * @param accessKeySecret - * @return Client - * @throws Exception - */ - public static com.aliyun.dysmsapi20170525.Client createClient(String accessKeyId, String accessKeySecret) throws Exception { - Config config = new Config() - // 您的 AccessKey ID - .setAccessKeyId(accessKeyId) - // 您的 AccessKey Secret - .setAccessKeySecret(accessKeySecret); - // 访问的域名 - config.endpoint = "dysmsapi.aliyuncs.com"; - return new com.aliyun.dysmsapi20170525.Client(config); - } - - public void sendMsg(String phone,String code) throws Exception { - com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient(accessKeyId,accessKeySecret); - SendSmsRequest sendSmsRequest = new SendSmsRequest() - .setSignName(signName) - .setTemplateCode(templateCode) - .setPhoneNumbers(phone) - .setTemplateParam("{\"code\":\""+code+"\"}"); - RuntimeOptions runtime = new RuntimeOptions(); - try { - // 复制代码运行请自行打印 API 的返回值 - SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); - log.info("短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode()); - } catch (TeaException error) { - // 如有需要,请打印 error - com.aliyun.teautil.Common.assertAsString(error.message); - log.info("短信发送失败:{}",error.message); - } catch (Exception _error) { - TeaException error = new TeaException(_error.getMessage(), _error); - // 如有需要,请打印 error - com.aliyun.teautil.Common.assertAsString(error.message); - log.info("短信发送失败:{}",error.message); - } - } -} diff --git a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/WxLoginController.java b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/WxLoginController.java index e6854aa..9dbf926 100644 --- a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/WxLoginController.java +++ b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/WxLoginController.java @@ -11,6 +11,7 @@ import com.ruoyi.common.core.domain.model.LoginBody; import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.redis.service.RedisService; +import com.ruoyi.common.utils.AliSmsUtil; import com.ruoyi.common.utils.NumberUtil; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; @@ -136,8 +137,8 @@ if (user==null){ user = new TbUser(); user.setPhone(appletUserDecodeData.getPhoneNumber()); - user.setAvatar(appletUserDecodeData.getAvatarUrl()); - user.setUserName(appletUserDecodeData.getNickName()); + user.setAvatar("https://yizhengcheng.oss-cn-chengdu.aliyuncs.com/img/18dfce33c55644d38abdb88b57db906f.png"); + user.setUserName(appletUserDecodeData.getPhoneNumber()); user.setOpenId(appletUserDecodeData.getOpenId()); user.setInviteId(data.getInviteUserId()); user.setStatus(1); @@ -197,19 +198,22 @@ String code = NumberUtil.getRandomInteger(6); redisService.setCacheObject("login_"+phone, code, 5L, TimeUnit.MINUTES); // 发送验证码 - - + try { + AliSmsUtil.sendSuccessMessage(phone,code); + }catch (Exception e) { + e.printStackTrace(); + return R.fail(e.getMessage()); + } return R.ok(); } @ApiOperation(value = "获取协议 1=用户协议,2=隐私协议",tags = {"登录模块"}) - @GetMapping("/getAgreement/{type}") + @GetMapping("/getAgreement") public R<List<TbAgreement>> getAgreement() { List<TbAgreement> list = agreementService.list(new LambdaQueryWrapper<TbAgreement>().in(TbAgreement::getType, 1, 2)); return R.ok(list); } - 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 67502ea..4aa39d2 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 @@ -5,11 +5,15 @@ import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpResponse; import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fasterxml.jackson.databind.JsonNode; 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.utils.QiChaChaUtil; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.http.HttpUtils; import com.ruoyi.framework.web.service.TokenService; @@ -65,6 +69,12 @@ private TbCompanyTypeService companyTypeService; + @Autowired + private QiChaChaUtil qiChaChaUtil; + + + + @ApiOperation(value = "获取我发布的公司",tags = {"发布模块"}) @GetMapping("/getMyPushCompanyList") @@ -108,6 +118,22 @@ tbCompanyService.pushCompany(dto,userId); return R.ok(); } + + @ApiOperation(value = "发布前获取公司信息--企查查",tags = {"发布模块"}) + @GetMapping("/getCompanyFromQiChaCha") + public R<Object> getCompanyFromQiChaCha(@RequestParam String companyName) { + long count = tbCompanyService.count(new LambdaQueryWrapper<TbCompany>().eq(TbCompany::getCompanyName,companyName).ne(TbCompany::getStatus, 3)); + if (count > 0) { + return R.fail("该公司已发布"); + } + Object qiChaChaToken = QiChaChaUtil.getQiChaChaCompanyInfo(companyName); + if(qiChaChaToken==null){ + return R.fail("查询公司信息失败请联系客服"); + } + return R.ok(qiChaChaToken); + } + + @ApiOperation(value = "编辑公司",tags = {"发布模块"}) @PostMapping("/editCompany") @@ -234,18 +260,18 @@ } - public static void main(String[] args) { + + 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\":\""+"ZZD20250321019744801521301"+"\"}"); + post.body("{\"sn\":\""+sign+"\"}"); HttpResponse execute = post.execute(); - System.out.println(execute.body()); + String body = execute.body(); + JSONObject jsonObject = JSONObject.parseObject(body); + return jsonObject; } - - - @ApiOperation(value = "已完成",tags = {"发布模块"}) @PostMapping("/saleSuccessOrder") @@ -277,15 +303,37 @@ @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); + Object qiChaChaCompanyExceptionCheck = QiChaChaUtil.getQiChaChaCompanyExceptionCheck(companyDetailVo.getCompanyName()); + companyDetailVo.setCompanyExceptionInfo(qiChaChaCompanyExceptionCheck); + return R.ok(companyDetailVo); } + @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); + } + + + + + + + } diff --git a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/system/UploadController.java b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/system/UploadController.java new file mode 100644 index 0000000..1f4c9e4 --- /dev/null +++ b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/system/UploadController.java @@ -0,0 +1,30 @@ +package com.ruoyi.web.controller.system; + +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.utils.OssUploadUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletRequest; + +@Slf4j +@RestController +@RequestMapping("/upload") +@Api(tags = "上传") +public class UploadController { + @ApiOperation(value = "文件上传",notes="文件上传") + @PostMapping("/uploadFile") + @ResponseBody + public R<String> upload(HttpServletRequest request, @RequestPart("file") MultipartFile picture) { + String filePath=""; + try { + filePath = OssUploadUtil.ossUpload(request,picture); + } catch (Exception e) { + e.printStackTrace(); + } + return R.ok(filePath); + } +} diff --git a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/system/UserAccountController.java b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/system/UserAccountController.java index e6123fb..ba358e1 100644 --- a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/system/UserAccountController.java +++ b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/system/UserAccountController.java @@ -80,8 +80,8 @@ public R<Page<TbAccountDetail>> getUserAccountDetail(UserAccountDetailQuery query) { LoginUser loginUser = tokenService.getLoginUser(); LambdaQueryWrapper<TbAccountDetail> wrapper = new LambdaQueryWrapper<>(); - if(StringUtils.isNotEmpty(query.getStartTime()) && StringUtils.isNotEmpty(query.getEndTime())){ - wrapper.between(TbAccountDetail::getCreateTime,query.getStartTime(),query.getEndTime()); + if(StringUtils.isNotEmpty(query.getTime())){ + wrapper.likeRight(TbAccountDetail::getCreateTime,query.getTime()); } wrapper.eq(TbAccountDetail::getUserId,loginUser.getUserId()); wrapper.orderByDesc(TbAccountDetail::getCreateTime); diff --git a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/system/messageController.java b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/system/messageController.java index 589a24c..e8dde5e 100644 --- a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/system/messageController.java +++ b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/system/messageController.java @@ -74,28 +74,28 @@ - @ApiOperation(value = "分享有礼列表",tags = {"分享有礼列表"}) - @GetMapping("/getInviteUserList") - public R<Page<InviteUserListVo>> getInviteUserList(BasePage page) { - LoginUser loginUser = tokenService.getLoginUser(); - Long userId = loginUser.getUserId(); - Page<TbUser> page1 = userService.page(new Page<>(page.getPageNum(), page.getPageSize()), new LambdaQueryWrapper<TbUser>().eq(TbUser::getInviteId, userId).orderByDesc(TbUser::getCreateTime)); - Page<InviteUserListVo> inviteUserListVoPage = new Page<>(); - if(page1.getRecords().isEmpty()){ - return R.ok(inviteUserListVoPage); - } - ArrayList<InviteUserListVo> inviteUserListVos = new ArrayList<>(); - for (TbUser record : page1.getRecords()) { - InviteUserListVo inviteUserListVo = new InviteUserListVo(); - inviteUserListVo.setUsername(record.getUserName()); - inviteUserListVo.setCreateTime(record.getCreateTime()); - inviteUserListVo.setInviteNum(record.getInviteNum()); - inviteUserListVos.add(inviteUserListVo); - } - BeanUtils.copyProperties(page1,inviteUserListVoPage); - inviteUserListVoPage.setRecords(inviteUserListVos); - return R.ok(inviteUserListVoPage); - } +// @ApiOperation(value = "分享有礼列表",tags = {"分享有礼列表"}) +// @GetMapping("/getInviteUserList") +// public R<Page<InviteUserListVo>> getInviteUserList(BasePage page) { +// LoginUser loginUser = tokenService.getLoginUser(); +// Long userId = loginUser.getUserId(); +// Page<TbUser> page1 = userService.page(new Page<>(page.getPageNum(), page.getPageSize()), new LambdaQueryWrapper<TbUser>().eq(TbUser::getInviteId, userId).orderByDesc(TbUser::getCreateTime)); +// Page<InviteUserListVo> inviteUserListVoPage = new Page<>(); +// if(page1.getRecords().isEmpty()){ +// return R.ok(inviteUserListVoPage); +// } +// ArrayList<InviteUserListVo> inviteUserListVos = new ArrayList<>(); +// for (TbUser record : page1.getRecords()) { +// InviteUserListVo inviteUserListVo = new InviteUserListVo(); +// inviteUserListVo.setUsername(record.getUserName()); +// inviteUserListVo.setCreateTime(record.getCreateTime()); +// inviteUserListVo.setInviteNum(record.getInviteNum()); +// inviteUserListVos.add(inviteUserListVo); +// } +// BeanUtils.copyProperties(page1,inviteUserListVoPage); +// inviteUserListVoPage.setRecords(inviteUserListVos); +// return R.ok(inviteUserListVoPage); +// } } diff --git a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/tool/MsgUtils.java b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/tool/MsgUtils.java deleted file mode 100644 index 119a5ea..0000000 --- a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/tool/MsgUtils.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.ruoyi.web.controller.tool; - -import com.aliyun.dysmsapi20170525.models.SendSmsRequest; -import com.aliyun.dysmsapi20170525.models.SendSmsResponse; -import com.aliyun.tea.TeaException; -import com.aliyun.teaopenapi.models.Config; -import com.aliyun.teautil.models.RuntimeOptions; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -@Component -@Slf4j -public class MsgUtils { - - @Value("${code.config.accessKeyId}") - private String accessKeyId; - @Value("${code.config.accessKeySecret}") - private String accessKeySecret; - @Value("${code.config.signName}") - private String signName; - @Value("${code.config.templateCode}") - private String templateCode; - @Value("${code.config.signNameTest}") - private String signNameTest; - @Value("${code.config.templateCodeTest}") - private String templateCodeTest; - - /** - * 使用AK&SK初始化账号Client - * @param accessKeyId - * @param accessKeySecret - * @return Client - * @throws Exception - */ - public static com.aliyun.dysmsapi20170525.Client createClient(String accessKeyId, String accessKeySecret) throws Exception { - Config config = new Config() - // 您的 AccessKey ID - .setAccessKeyId(accessKeyId) - // 您的 AccessKey Secret - .setAccessKeySecret(accessKeySecret); - // 访问的域名 - config.endpoint = "dysmsapi.aliyuncs.com"; - return new com.aliyun.dysmsapi20170525.Client(config); - } - - public void sendMsg(String phone,String code) throws Exception { - com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient(accessKeyId,accessKeySecret); - SendSmsRequest sendSmsRequest = new SendSmsRequest() - .setSignName(signName) - .setTemplateCode(templateCode) - .setPhoneNumbers(phone) - .setTemplateParam("{\"code\":\""+code+"\"}"); - RuntimeOptions runtime = new RuntimeOptions(); - try { - // 复制代码运行请自行打印 API 的返回值 - SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); - log.info("短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode()); - } catch (TeaException error) { - // 如有需要,请打印 error - com.aliyun.teautil.Common.assertAsString(error.message); - log.info("短信发送失败:{}",error.message); - } catch (Exception _error) { - TeaException error = new TeaException(_error.getMessage(), _error); - // 如有需要,请打印 error - com.aliyun.teautil.Common.assertAsString(error.message); - log.info("短信发送失败:{}",error.message); - } - } -} diff --git a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/tool/TencentCosUtil.java b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/tool/TencentCosUtil.java deleted file mode 100644 index f86298b..0000000 --- a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/tool/TencentCosUtil.java +++ /dev/null @@ -1,187 +0,0 @@ -package com.ruoyi.web.controller.tool; - -import com.qcloud.cos.COSClient; -import com.qcloud.cos.ClientConfig; -import com.qcloud.cos.auth.BasicCOSCredentials; -import com.qcloud.cos.auth.COSCredentials; -import com.qcloud.cos.http.HttpProtocol; -import com.qcloud.cos.model.ObjectMetadata; -import com.qcloud.cos.model.PutObjectResult; -import com.qcloud.cos.region.Region; -import com.ruoyi.common.utils.WebUtils; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; -import org.springframework.web.multipart.MultipartFile; - -import javax.servlet.ServletOutputStream; -import javax.servlet.http.HttpServletResponse; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.util.Base64; -import java.util.UUID; - -/** - * @author HJL - */ -@Component -public class TencentCosUtil { - - /** - * COS的SecretId - */ - @Value("${cos.client.accessKey}") - private String secretId; - /** - * COS的SecretKey - */ - @Value("${cos.client.secretKey}") - private String secretKey; - /** - * 文件上传后访问路径的根路径,后面要最佳文件名字与类型 - */ - @Value("${cos.client.rootSrc}") - private String rootSrc; - /** - * 上传的存储桶的地域 - */ - @Value("${cos.client.bucketAddr}") - private String bucketAddr; - /** - * 存储桶的名字,是自己在存储空间自己创建的,我创建的名字是:qq-test-1303****** - */ - @Value("${cos.client.bucket}") - private String bucketName; - /** - * 文件存放位置 - */ - @Value("${cos.client.location}") - private String location; - - /** - * 1.调用静态方法getCosClient()就会获得COSClient实例 - * 2.本方法根据永久密钥初始化 COSClient的,官方是不推荐,官方推荐使用临时密钥,是可以限制密钥使用权限,创建cred时有些区别 - * - * @return COSClient实例 - */ - private COSClient getCosClient() { - // 1 初始化用户身份信息(secretId, secretKey)。 - COSCredentials cred = new BasicCOSCredentials(secretId, secretKey); - // 2.1 设置存储桶的地域(上文获得) - Region region = new Region(bucketAddr); - ClientConfig clientConfig = new ClientConfig(region); - // 2.2 使用https协议传输 - clientConfig.setHttpProtocol(HttpProtocol.https); - // 生成 cos 客户端 - return new COSClient(cred, clientConfig); - } - - /** - * 只要调用静态方法upLoadFile(MultipartFile multipartFile)就可以获取上传后文件的全路径 - * - * @param file - * @return 返回文件的浏览全路径 - */ - public String upLoadFile(MultipartFile file) { - try { - // 获取上传的文件的输入流 - InputStream inputStream = file.getInputStream(); - // 避免文件覆盖,获取文件的原始名称,如123.jpg,然后通过截取获得文件的后缀,也就是文件的类型 - String originalFilename = file.getOriginalFilename(); - //获取文件的类型 - String fileType = originalFilename.substring(originalFilename.lastIndexOf(".")); - //使用UUID工具 创建唯一名称,放置文件重名被覆盖,在拼接上上命令获取的文件类型 - String fileName = UUID.randomUUID() + fileType; - // 指定文件上传到 COS 上的路径,即对象键。最终文件会传到存储桶名字中的images文件夹下的fileName名字 - String key = location+"/" + fileName; - // 创建上传Object的Metadata - ObjectMetadata objectMetadata = new ObjectMetadata(); - // - 使用输入流存储,需要设置请求长度 - objectMetadata.setContentLength(inputStream.available()); - // - 设置缓存 - objectMetadata.setCacheControl("no-cache"); - // - 设置Content-Type - objectMetadata.setContentType(fileType); - //上传文件 - PutObjectResult putResult = getCosClient().putObject(bucketName, key, inputStream, objectMetadata); - // 创建文件的网络访问路径 - String url = rootSrc + key; - //关闭 cosClient,并释放 HTTP 连接的后台管理线程 - getCosClient().shutdown(); - return url; - } catch (Exception e) { - e.printStackTrace(); - // 发生IO异常、COS连接异常等,返回空 - return null; - } - } - - /** - * 下载文件 - * @param file - * @return - */ - public void downLoadFile(String file) { - HttpServletResponse response = WebUtils.response(); - String replace = file.replace(rootSrc, ""); - response.setHeader("Access-Control-Expose-Headers","File-Type"); - COSCredentials cred = new BasicCOSCredentials( - secretId, - secretKey); - // 2.1 设置存储桶的地域(上文获得) - Region region = new Region(bucketAddr); - ClientConfig clientConfig = new ClientConfig(region); - // 2.2 使用https协议传输 - clientConfig.setHttpProtocol(HttpProtocol.https); - COSClient cosClient = new COSClient(cred, clientConfig); - try { - // 5. 下载文件并获取输入流 - InputStream inputStream = cosClient.getObject(bucketName, replace).getObjectContent(); - ServletOutputStream outputStream = response.getOutputStream(); - // 6. 处理输入流,例如读取内容或保存到本地文件 - // 这里仅作示例,实际应用中需要根据需求处理输入流 - byte[] buffer = new byte[1024]; - int len; - while ((len = inputStream.read(buffer)) != -1) { - // 处理读取到的数据 - outputStream.write(buffer, 0, len); - } - } catch (Exception e) { - e.printStackTrace(); - } finally { - // 7. 关闭输入流 - cosClient.shutdown(); - } - } - public String downLoadFileImg(String file) { - byte[] data = null; - String replace = file.replace(rootSrc, ""); - COSCredentials cred = new BasicCOSCredentials( - secretId, - secretKey); - // 2.1 设置存储桶的地域(上文获得) - Region region = new Region(bucketAddr); - ClientConfig clientConfig = new ClientConfig(region); - // 2.2 使用https协议传输 - clientConfig.setHttpProtocol(HttpProtocol.https); - COSClient cosClient = new COSClient(cred, clientConfig); - try { - // 5. 下载文件并获取输入流 - InputStream inputStream = cosClient.getObject(bucketName, replace).getObjectContent(); - ByteArrayOutputStream swapStream = new ByteArrayOutputStream(); - // 6. 处理输入流,例如读取内容或保存到本地文件 - byte[] buffer = new byte[1024]; - int len; - while ((len = inputStream.read(buffer)) != -1) { - // 处理读取到的数据 - swapStream.write(buffer, 0, len); - } - data = swapStream.toByteArray(); - } catch (Exception e) { - e.printStackTrace(); - } finally { - // 7. 关闭输入流 - cosClient.shutdown(); - } - return Base64.getEncoder().encodeToString(data); - } -} \ No newline at end of file diff --git a/ruoyi-applet/src/main/resources/application-prod.yml b/ruoyi-applet/src/main/resources/application-prod.yml index 10c4c27..5cac8b5 100644 --- a/ruoyi-applet/src/main/resources/application-prod.yml +++ b/ruoyi-applet/src/main/resources/application-prod.yml @@ -18,7 +18,7 @@ # 开发环境配置 server: # 服务器的HTTP端口,默认为8080 - port: 8082 + port: 9082 servlet: # 应用的访问路径 context-path: / @@ -70,20 +70,19 @@ # redis 配置 redis: # 地址 - # host: 127.0.0.1 + host: 127.0.0.1 # # 端口,默认为6379 # port: 6379 # # 数据库索引 # database: 0 # # 密码 # password: 123456 - host: 127.0.0.1 # 端口,默认为6379 - port: 16379 + port: 6379 # 数据库索引 - database: 0 + database: 6 # 密码 - password: 8f5z9g52gx4bg + password: 123456 # 连接超时时间 timeout: 10s lettuce: @@ -103,9 +102,9 @@ druid: # 主库数据源 master: - url: jdbc:mysql://172.27.0.13:3306/xizang?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai - username: xzgt - password: changyun!6f2gshj6h3j + url: jdbc:mysql://127.0.0.1:3306/zhengshengxin?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai + username: root + password: Zsx38817!@# # 从库数据源 slave: # 从数据源开关/默认关闭 @@ -200,31 +199,15 @@ accessPath: /file/ allowExt: .jpg|.png|.gif|.jpeg|.doc|.docx|.apk|.MP4|.mp4|.pdf|.PDF url: + # prefix: http://localhost:${server.port}${server.servlet.context-path} prefix: https://xzgt.test.591taxi.cn:${server.port}${server.servlet.context-path} wx: - conf: - appId: wxe91f1af7638aa5dd - secretId: a787e1a462715604e0c9528b6d8960d1 -#OSS及短信配置 -code: - config: - templateCodeTest: "SMS_154950909" - signNameTest: "阿里云短信测试" - accessKeyId: LTAI5tAdba8HtT1C6UqtSxBt - accessKeySecret: 0SRb6XGkciQDPWn2rYqbJtq2qRMDY8 - signName: "四川金达通信工程" - templateCode: "SMS_293985284" -cos: - client: - accessKey: AKIDCF5EF2c0DE1e5JK8r4EGJF4mNsMgp26x - secretKey: lLl184rUyFOOE0d5KNGC3kmfNsCWk4GU - bucket: xzgttest-1305134071 - bucketAddr: ap-chengdu - rootSrc: https://xzgttest-1305134071.cos.ap-chengdu.myqcloud.com/ - location: xizang -sms: - enable: true - appId: 1400957506 - secretid: AKIDCF5EF2c0DE1e5JK8r4EGJF4mNsMgp26x - secretkey: lLl184rUyFOOE0d5KNGC3kmfNsCWk4GU - sign: 畅云出行 + memberAppId: wx31b64f0d4f09053b + memberAppSecret: 2f3604b43c3e7128414408d0fc67b048 + mchId: 1720552698 #微信支付商户号 + mchKey: 5Kb8zX9qR3r4D7Yw3vHnJgLp6sA4cE1M #微信支付商户密钥 + keyPath: C:\Users\Admin\Desktop\zsxcert\apiclient_cert.p12 # p12证书的位置 + callbackPath: https://api.dshl.vip/WalletApi/WX/callback + notifyUrl: http://127.0.0.1:9081/order/WX/zxsCallback + + diff --git a/ruoyi-applet/src/main/resources/application-test.yml b/ruoyi-applet/src/main/resources/application-test.yml index 0ec1df9..1d9092f 100644 --- a/ruoyi-applet/src/main/resources/application-test.yml +++ b/ruoyi-applet/src/main/resources/application-test.yml @@ -80,7 +80,7 @@ # 端口,默认为6379 port: 6379 # 数据库索引 - database: 0 + database: 6 # 密码 password: 123456 # 连接超时时间 @@ -202,35 +202,12 @@ # prefix: http://localhost:${server.port}${server.servlet.context-path} prefix: https://xzgt.test.591taxi.cn:${server.port}${server.servlet.context-path} wx: - memberAppId: wx31b64f0d4f09053b - memberAppSecret: 2f3604b43c3e7128414408d0fc67b048 - mchId: 1703389452 #微信支付商户号 - mchKey: t30dr8AnRWPQenwCpwik34hZGBHppnNi #微信支付商户密钥 - keyPath: /opt/cert/apiclient_cert.p12 # p12证书的位置 + memberAppId: wx180c41e1915992e8 + memberAppSecret: 8c6cc3410891d3096988b92c154ba5e9 + mchId: 1720552698 #微信支付商户号 + mchKey: 5Kb8zX9qR3r4D7Yw3vHnJgLp6sA4cE1M #微信支付商户密钥 + keyPath: C:\Users\Admin\Desktop\zsxcert\apiclient_cert.p12 # p12证书的位置 callbackPath: https://api.dshl.vip/WalletApi/WX/callback notifyUrl: http://127.0.0.1:9081/order/WX/zxsCallback -#OSS及短信配置 -code: - config: - templateCodeTest: "SMS_154950909" - signNameTest: "阿里云短信测试" - accessKeyId: LTAI5tAdba8HtT1C6UqtSxBt - accessKeySecret: 0SRb6XGkciQDPWn2rYqbJtq2qRMDY8 - signName: "四川金达通信工程" - templateCode: "SMS_293985284" -cos: - client: - accessKey: AKIDCF5EF2c0DE1e5JK8r4EGJF4mNsMgp26x - secretKey: lLl184rUyFOOE0d5KNGC3kmfNsCWk4GU - bucket: xzgttest-1305134071 - bucketAddr: ap-chengdu - rootSrc: https://xzgttest-1305134071.cos.ap-chengdu.myqcloud.com/ - location: xizang -sms: - enable: true - appId: 1400957506 - secretid: AKIDCF5EF2c0DE1e5JK8r4EGJF4mNsMgp26x - secretkey: lLl184rUyFOOE0d5KNGC3kmfNsCWk4GU - sign: 畅云出行 diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml index 6a1ae59..b4341ea 100644 --- a/ruoyi-common/pom.xml +++ b/ruoyi-common/pom.xml @@ -206,6 +206,30 @@ <artifactId>javax.mail</artifactId> <version>1.6.2</version> <!-- 请检查是否有更新的版本 --> </dependency> + + + <dependency> + <groupId>com.aliyun</groupId> + <artifactId>dysmsapi20170525</artifactId> + <version>3.1.0</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + </dependency> + <dependency> + <groupId>com.vaadin.external.google</groupId> + <artifactId>android-json</artifactId> + <version>0.0.20131108.vaadin1</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>com.aliyun.oss</groupId> + <artifactId>aliyun-sdk-oss</artifactId> + <version>3.15.1</version> + <scope>compile</scope> + </dependency> + </dependencies> </project> \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/AliSmsUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/AliSmsUtil.java new file mode 100644 index 0000000..ecebfca --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/AliSmsUtil.java @@ -0,0 +1,126 @@ +package com.ruoyi.common.utils; + +import com.alibaba.fastjson2.JSON; +import com.ruoyi.common.core.exception.ServiceException; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import com.aliyun.dysmsapi20170525.Client; +import com.aliyun.dysmsapi20170525.models.SendBatchSmsRequest; +import com.aliyun.dysmsapi20170525.models.SendBatchSmsResponse; +import com.aliyun.dysmsapi20170525.models.SendSmsRequest; +import com.aliyun.dysmsapi20170525.models.SendSmsResponse; +import com.aliyun.teaopenapi.models.Config; + +import java.util.*; + + +@Slf4j +public class AliSmsUtil { + private static final String ACCESS_KEY_ID = "LTAI5tHYSpwifc3rqLYJoETo"; + private static final String ACCESS_KEY_SECRET = "xrDyQ89h8P0alWW7rrLIW2D2rt7Eig"; + private static final String SIGN_NAME = "一证成"; + // 模板 + private static final String TEMPLATE_CODE = "SMS_489660108"; + + + public static void sendSuccessMessage(String phone,String code) { + Map<String, String> param = new HashMap<>(3); + param.put("code",code); + sendSms(phone,SIGN_NAME,TEMPLATE_CODE,param); + } + + public static void main(String[] args) { + sendSuccessMessage("17828262728","123456"); + } + + /** + * 阿里发送短信 + * + * @param phone + * @param signName + * @param templateCode + * @param param + * @return + */ + private static boolean sendSms(String phone, String signName, String templateCode, Map<String, String> param) { + // 可自助调整超时时间 + System.setProperty("sun.net.client.defaultConnectTimeout", "30000"); + System.setProperty("sun.net.client.defaultReadTimeout", "30000"); + try { + + // 初始化请求客户端 + Client client = createClient(); + + // 构造请求对象,请填入请求参数值 + SendSmsRequest sendSmsRequest = new SendSmsRequest() + .setPhoneNumbers(phone) + .setSignName(signName) + .setTemplateCode(templateCode) + .setTemplateParam(JSON.toJSONString(param)); + //if (aliSmsConfig.isDebug()) { + // log.info("短信 DEBUG code= {}", param); + // return true; + //} + // 获取响应对象 + SendSmsResponse sendSmsResponse = client.sendSms(sendSmsRequest); + // hint 此处可能会抛出异常,注意catch + if (StringUtils.equalsIgnoreCase("ok", sendSmsResponse.getBody().getCode())) { + log.info("{}短信发送成功:{}", phone, sendSmsResponse.getBody().getMessage()); + return true; + } else { + log.error("{}短信发送失败:{}", phone, sendSmsResponse.getBody().getMessage()); + } + } catch (Exception e) { + log.error("{}短信发送失败:{}", phone, e.getMessage(),e); + throw new ServiceException("短信发送失败:"+e.getMessage()); + } + return false; + } + private static boolean sendBatchSms(List<String> phones, String signName, String templateCode, Map<String, String> param) { + // 可自助调整超时时间 + System.setProperty("sun.net.client.defaultConnectTimeout", "30000"); + System.setProperty("sun.net.client.defaultReadTimeout", "30000"); + try { + + // 初始化请求客户端 + Client client = createClient(); + + // 构造请求对象,请填入请求参数值 + SendBatchSmsRequest request = new SendBatchSmsRequest() + .setPhoneNumberJson(JSON.toJSONString(phones)) // 手机号数组JSON + .setSignNameJson(JSON.toJSONString(Collections.nCopies(phones.size(), SIGN_NAME))) + .setTemplateCode(templateCode) + .setTemplateParamJson(JSON.toJSONString(Collections.nCopies(phones.size(), param))); // 参数数组JSON + //if (aliSmsConfig.isDebug()) { + // log.info("短信 DEBUG code= {}", param); + // return true; + //} + // 获取响应对象 + SendBatchSmsResponse sendBatchSmsResponse = client.sendBatchSms(request); + // hint 此处可能会抛出异常,注意catch + if (StringUtils.equalsIgnoreCase("ok", sendBatchSmsResponse.getBody().getCode())) { + return true; + } else { + log.error("{}短信发送失败:{}", JSON.toJSONString(phones), sendBatchSmsResponse.getBody().getMessage()); + } + } catch (Exception e) { + log.error("{}短信发送失败:{}", JSON.toJSONString(phones), e.getMessage(),e); + throw new RuntimeException("短信发送失败", e); + } + return false; + } + public static Client createClient() throws Exception { + Config config = new Config() + // 配置 AccessKey ID + .setAccessKeyId(ACCESS_KEY_ID) + // 配置 AccessKey Secret + .setAccessKeySecret(ACCESS_KEY_SECRET); + + // 配置 Endpoint + config.endpoint = "dysmsapi.aliyuncs.com"; + + return new Client(config); + } + + +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/OssUploadUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/OssUploadUtil.java new file mode 100644 index 0000000..08732c5 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/OssUploadUtil.java @@ -0,0 +1,136 @@ +package com.ruoyi.common.utils; + +import com.aliyun.oss.OSSClient; +import com.aliyun.oss.model.ObjectMetadata; +import com.aliyun.oss.model.PutObjectResult; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletRequest; +import java.io.*; +import java.util.Objects; +import java.util.UUID; + +public class OssUploadUtil { + public static String oss_domain = "https://yizhengcheng.oss-cn-chengdu.aliyuncs.com/"; + public static String accessKeyId = "LTAI5tHYSpwifc3rqLYJoETo"; + public static String accessKeySecret = "xrDyQ89h8P0alWW7rrLIW2D2rt7Eig"; + public static String bucketName="yizhengcheng"; + public static String endpoint = "oss-cn-chengdu.aliyuncs.com"; + + public static OSSClient ossClient = new OSSClient(endpoint, accessKeyId,accessKeySecret); + + public static String ossUpload(HttpServletRequest request, MultipartFile file) throws IOException { + //CommonsMultipartFile file = (CommonsMultipartFile)multipartFile; + String fileName = ""; + if (file != null && !"".equals(file.getOriginalFilename()) && file.getOriginalFilename() != null) { + InputStream content = file.getInputStream();//获得指定文件的输入流 + ObjectMetadata meta = new ObjectMetadata();// 创建上传Object的Metadata + meta.setContentLength(file.getSize()); // 必须设置ContentLength + String originalFilename = file.getOriginalFilename(); + fileName = UUID.randomUUID().toString().replaceAll("-", "") + originalFilename.subSequence(originalFilename.lastIndexOf("."), originalFilename.length()); + ossClient.putObject(bucketName, "img/" + fileName, content, meta);// 上传Object. + if (fileName != null && !"".equals(fileName)) { + fileName = oss_domain + "img/" + fileName; + } + } + return fileName; + } + + public static String obsUploadPdf(String fileType, ByteArrayOutputStream file) throws IOException { + String fileName = UUID.randomUUID() + ".pdf"; + //获得指定文件的输入流 + InputStream content = new ByteArrayInputStream(file.toByteArray()); + ObjectMetadata meta = new ObjectMetadata();// 创建上传Object的Metadata + meta.setContentLength(Long.valueOf(file.size())); // 必须设置ContentLength + ossClient.putObject(bucketName, fileType + fileName, content, meta);// 上传Object. + if (fileName != null && !"".equals(fileName)) { + System.out.println(fileName); + fileName = oss_domain + fileType + fileName; + } + return fileName; + } + + + //上传图片 + public static String uploadByteOSS(byte[] b) { + + // byte[] content = "Hello OSS".getBytes(); + + // 以输入流的形式上传文件 + String folder = ""; + // 文件名 + String timefile = UUID.randomUUID().toString().replaceAll("-","");// 文件名 + String fileName = ".jpg";// 后缀扩展名 + fileName = timefile + fileName; + + Long fileSize = (long) b.length; +// String timefile = FORMATS; +//// String fileName = file.getName(); +// file = timefile + file.substring(file.lastIndexOf(".")); + // 创建上传Object的Metadata + ObjectMetadata metadata = new ObjectMetadata(); + metadata.setContentLength(fileSize); + // 指定该Object被下载时的网页的缓存行为 + metadata.setCacheControl("no-cache"); + // 指定该Object下设置Header + metadata.setHeader("Pragma", "no-cache"); + // 指定该Object被下载时的内容编码格式 + metadata.setContentEncoding("utf-8"); + // 文件的MIME,定义文件的类型及网页编码,决定浏览器将以什么形式、什么编码读取文件。如果用户没有指定则根据Key或文件名的扩展名生成, + // 如果没有扩展名则填默认值application/octet-stream + metadata.setContentType(getContentType(fileName)); + // 指定该Object被下载时的名称(指示MINME用户代理如何显示附加的文件,打开或下载,及文件名称) + metadata.setContentDisposition("filename/filesize=" + fileName + "/" + fileSize + "Byte."); + + PutObjectResult putResult = ossClient.putObject(bucketName, folder + fileName, new ByteArrayInputStream(b), + metadata); + //ossClient.shutdown(); + String filepath = folder + fileName; + return oss_domain+filepath; + } + + /** + * 通过文件名判断并获取OSS服务文件上传时文件的contentType + * + * @param fileName + * 文件名 + * @return 文件的contentType + */ + public static String getContentType(String fileName) { + // 文件的后缀名 + String fileExtension = fileName.substring(fileName.lastIndexOf(".")); + if (".bmp".equalsIgnoreCase(fileExtension)) { + return "image/bmp"; + } + if (".gif".equalsIgnoreCase(fileExtension)) { + return "image/gif"; + } + if (".jpeg".equalsIgnoreCase(fileExtension) || ".jpg".equalsIgnoreCase(fileExtension) + || ".png".equalsIgnoreCase(fileExtension)) { + return "image/jpeg"; + } + if (".html".equalsIgnoreCase(fileExtension)) { + return "text/html"; + } + if (".txt".equalsIgnoreCase(fileExtension)) { + return "text/plain"; + } + if (".vsd".equalsIgnoreCase(fileExtension)) { + return "application/vnd.visio"; + } + if (".ppt".equalsIgnoreCase(fileExtension) || "pptx".equalsIgnoreCase(fileExtension)) { + return "application/vnd.ms-powerpoint"; + } + if (".doc".equalsIgnoreCase(fileExtension) || "docx".equalsIgnoreCase(fileExtension)) { + return "application/msword"; + } + if (".xml".equalsIgnoreCase(fileExtension)) { + return "text/xml"; + } + if (".mp4".equalsIgnoreCase(fileExtension)) { + return "video/mp4"; + } + // 默认返回类型 + return "image/jpeg"; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/QiChaChaUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/QiChaChaUtil.java new file mode 100644 index 0000000..81ef6c1 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/QiChaChaUtil.java @@ -0,0 +1,71 @@ +package com.ruoyi.common.utils; + +import cn.hutool.crypto.SecureUtil; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson2.JSONObject; +import com.ruoyi.common.core.redis.RedisCache; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import java.util.concurrent.TimeUnit; + +@Component +public class QiChaChaUtil { + + @Autowired + private RedisCache redisCache; + + private static QiChaChaUtil qiChaChaUtil; + + @PostConstruct + public void init() { + qiChaChaUtil = this; + } + + public static QiChaChaUtil getInstance() { + return qiChaChaUtil; + } + + public static Object getQiChaChaCompanyInfo(String companyName){ + String url = "https://api.qichacha.com/ECIV4/GetBasicDetailsByName?key=642987ca3faf4a7daeac70463ae22695&keyword="+companyName; + HttpRequest get = HttpUtil.createGet(url); + String timeStr = String.valueOf(System.currentTimeMillis() / 1000); + get.header("Token", SecureUtil.md5("642987ca3faf4a7daeac70463ae22695"+timeStr+"AC776F2957291EAE3B4161702E89A9F3").toUpperCase()); + get.header("Timespan", timeStr); + HttpResponse execute = get.execute(); + String body = execute.body(); + JSONObject jsonObject = JSONObject.parseObject(body); + if("200".equals(jsonObject.get("Status"))){ + return jsonObject; + } + return null; + } + + + public static Object getQiChaChaCompanyExceptionCheck(String companyName){ + Object cacheObject = getInstance().redisCache.getCacheObject("qichacha_" + companyName); + if(cacheObject != null){ + JSONObject jsonObject = JSONObject.parseObject(cacheObject.toString()); + return jsonObject; + } + String url = "https://api.qichacha.com/ExceptionCheck/GetList?key=642987ca3faf4a7daeac70463ae22695&searchKey="+companyName; + HttpRequest get = HttpUtil.createGet(url); + String timeStr = String.valueOf(System.currentTimeMillis() / 1000); + get.header("Token", SecureUtil.md5("642987ca3faf4a7daeac70463ae22695"+timeStr+"AC776F2957291EAE3B4161702E89A9F3").toUpperCase()); + get.header("Timespan", timeStr); + HttpResponse execute = get.execute(); + String body = execute.body(); + JSONObject jsonObject = JSONObject.parseObject(body); + if("200".equals(jsonObject.get("Status"))){ + String string = jsonObject.toString(); + getInstance().redisCache.setCacheObject("qichacha_"+companyName,string,24, TimeUnit.HOURS); + return jsonObject; + } + return null; + } + + +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java index 589d123..7b8b001 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java @@ -7,6 +7,12 @@ import java.nio.charset.StandardCharsets; import javax.servlet.ServletRequest; import org.apache.commons.lang3.exception.ExceptionUtils; +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -52,4 +58,36 @@ } return sb.toString(); } -} + + /** + * 执行HTTP GET请求并返回响应内容 + * @param url 请求的URL + * @param headers 请求头数组 + * @return 响应内容字符串 + */ + public static String httpGet(String url, org.apache.http.Header[] headers) { + CloseableHttpClient httpClient = HttpClients.createDefault(); + HttpGet httpGet = new HttpGet(url); + + // 设置请求头 + if (headers != null) { + for (org.apache.http.Header header : headers) { + httpGet.setHeader(header); + } + } + + try { + CloseableHttpResponse response = httpClient.execute(httpGet); + return EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); + } catch (IOException e) { + LOGGER.error("执行HTTP GET请求时发生错误:{}", e.getMessage()); + return null; + } finally { + try { + httpClient.close(); + } catch (IOException e) { + LOGGER.error("关闭HTTP客户端时发生错误:{}", e.getMessage()); + } + } + } +} \ No newline at end of file diff --git a/ruoyi-system/pom.xml b/ruoyi-system/pom.xml index 71cdb3b..8a6f57c 100644 --- a/ruoyi-system/pom.xml +++ b/ruoyi-system/pom.xml @@ -18,6 +18,8 @@ <dependencies> + + <!-- wx 支付 --> <dependency> <groupId>com.github.binarywang</groupId> diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/model/TbOrder.java b/ruoyi-system/src/main/java/com/ruoyi/system/model/TbOrder.java index e38c5c4..42072d2 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/model/TbOrder.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/model/TbOrder.java @@ -83,6 +83,9 @@ @TableField("out_trade_no") private String outTradeNo; + @TableField("transaction_id") + private String transactionId; + @TableField("finish_time") private Date finishTime; diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/query/UserAccountDetailQuery.java b/ruoyi-system/src/main/java/com/ruoyi/system/query/UserAccountDetailQuery.java index d9bd0a6..8b50729 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/query/UserAccountDetailQuery.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/query/UserAccountDetailQuery.java @@ -6,8 +6,6 @@ @Data public class UserAccountDetailQuery extends BasePage { - @ApiModelProperty(value = "开始时间") - private String startTime; - @ApiModelProperty(value = "结束时间") - private String endTime; + @ApiModelProperty(value = "时间 2025-07") + private String time; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbOrderServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbOrderServiceImpl.java index 842584a..2761b95 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbOrderServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbOrderServiceImpl.java @@ -104,7 +104,8 @@ if (order!=null) { order.setStatus(4); order.setPayTime(new Date()); - order.setOutTradeNo(notifyResult.getTransactionId()); + order.setOutTradeNo(notifyResult.getOutTradeNo()); + order.setTransactionId(notifyResult.getTransactionId()); TbCompany company = companyService.getById(order.getCompanyId()); // 生成记录 看是否分佣 金额 TbUser user = userService.getById(company.getUserId()); @@ -150,10 +151,11 @@ messageService.addMessage("下单成功,请及时发送快递", order.getUserId(),order.getId()); messageService.addMessage("您发布的订单买家已支付,请尽快处理!", company.getUserId(),order.getId()); + return "<xml> <return_code><![CDATA[SUCCESS]]></return_code> <return_msg><![CDATA[OK]]></return_msg> </xml>"; } + return null; - return "<xml> <return_code><![CDATA[SUCCESS]]></return_code> <return_msg><![CDATA[OK]]></return_msg> </xml>"; } @Override diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/vo/CompanyDetailVo.java b/ruoyi-system/src/main/java/com/ruoyi/system/vo/CompanyDetailVo.java index f0c5f25..d3ddcf4 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/vo/CompanyDetailVo.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/vo/CompanyDetailVo.java @@ -163,4 +163,8 @@ private Date confirmTime; + @ApiModelProperty("企业经营异常信息 企查查参数说明") + private Object companyExceptionInfo; + + } -- Gitblit v1.7.1